feat: complete admin panel and backend admin api migration

This commit is contained in:
s.esmaeili
2026-09-13 21:02:25 +03:30
parent 03119cd655
commit 267fc7b7d1
239 changed files with 25431 additions and 935 deletions
@@ -0,0 +1,72 @@
<template>
<!--
Shared implementation of legacy ListBranches.vue and ListWorkshop.vue.
Verified by diff: the two files differ by 14 lines — the card title, the
model import, and the edit route. Parameterised rather than duplicated.
Legacy quirks preserved:
- the delete action is COMMENTED OUT in both files and stays absent
- the status tooltip is labelled "وضعیت" and toggles on click
- legacy binds `slot-scope="text,record"` then reads `text.record.id`,
i.e. the row arrives as the FIRST argument; the Vue 3 slot gives us
`record` directly, which is the same row.
-->
<a-card :title="title">
<XTable ref="tbl" :model="model">
<template #actions="{ record }">
<div class="flex gap-2">
<a-tooltip title="ویرایش">
<EditOutlined class="cursor-pointer mx-1 text-primary" @click="toEdit(record.id)" />
</a-tooltip>
<a-tooltip title="وضعیت">
<CheckOutlined
v-if="record.is_active"
class="cursor-pointer mx-1 text-success"
@click="setOffer(record.id)"
/>
<CloseOutlined v-else class="cursor-pointer mx-1 text-danger" @click="setOffer(record.id)" />
</a-tooltip>
</div>
</template>
</XTable>
</a-card>
</template>
<script setup lang="ts">
import { ref } from 'vue';
import { useRouter } from 'vue-router';
import { message } from 'ant-design-vue';
import { CheckOutlined, CloseOutlined, EditOutlined } from '@ant-design/icons-vue';
import XTable from '../../components/x-table/XTable.vue';
import api from '../../api/client';
import type { XTbl } from '../../components/x-table/model';
const props = defineProps<{
title: string;
model: XTbl;
/** Where the edit pencil navigates, e.g. '/branch/edit' or '/workshop/edit'. */
editPath: string;
/** The toggle endpoint, e.g. 'branch/active' or 'workshop/active'. */
activePath: string;
}>();
const router = useRouter();
const tbl = ref<{ fetch: () => Promise<void> } | null>(null);
function toEdit(id: string) {
router.push(`${props.editPath}/${id}`);
}
/** legacy setOffer(): the status toggle */
async function setOffer(id: string) {
try {
await api.get(`${props.activePath}/${id}`);
message.success('تغییرات ثبت شد');
tbl.value?.fetch();
} catch (e: any) {
message.error(e?.response?.data?.message ?? 'خطا در تغییر وضعیت');
}
}
</script>