admin-panel: convert financial document add/edit form into a modal

Same open/id pattern as the previous conversions.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
s.esmaeili
2026-09-14 16:53:02 +03:30
co-authored by Claude Sonnet 5
parent 3e24fe3fc7
commit 3345c86d18
2 changed files with 149 additions and 12 deletions
+20 -9
View File
@@ -8,6 +8,8 @@
<div id="page-user-list">
<a-spin :spinning="loading">
<a-card title="لیست اسناد مالی">
<ListPageHeader rid="document.create" add-label="ثبت سند مالی" @add="openAdd" />
<XTable ref="tbl" :model="model">
<template #confirmed="{ text }">
<a-tag v-if="text === 1" color="green">تایید شده</a-tag>
@@ -40,7 +42,7 @@
</a-tooltip>
<a-tooltip v-if="hasPermission('document.list.edit')" title="ویرایش">
<EditOutlined class="cursor-pointer mx-1 text-primary" @click="toEdit(record.id)" />
<EditOutlined class="cursor-pointer mx-1 text-primary" @click="openEdit(record.id)" />
</a-tooltip>
<a-tooltip v-if="hasPermission('document.list.remove')" title="حذف">
@@ -56,6 +58,8 @@
</a-tooltip>
</template>
</XTable>
<AddFinDoc :key="editingId ?? 'new'" :open="modalOpen" :id="editingId" @update:open="modalOpen = $event" @success="tbl?.fetch()" />
</a-card>
</a-spin>
</div>
@@ -63,7 +67,6 @@
<script setup lang="ts">
import { ref } from 'vue';
import { useRouter } from 'vue-router';
import { message } from 'ant-design-vue';
import {
CheckOutlined,
@@ -72,12 +75,13 @@ import {
EditOutlined,
} from '@ant-design/icons-vue';
import XTable from '../../components/x-table/XTable.vue';
import ListPageHeader from '../../components/common/ListPageHeader.vue';
import AddFinDoc from './addFinDoc.vue';
import { buildDocumentListModel } from './list_model';
import { useUsersStore } from '../../stores/users';
import { useDeleteHandler } from '../../composables/useDeleteHandler';
import api from '../../api/client';
const router = useRouter();
const users = useUsersStore();
const hasPermission = (rid: string) => Boolean(users.hasPermission(rid));
@@ -85,6 +89,19 @@ const model = buildDocumentListModel();
const tbl = ref<{ fetch: () => Promise<void> } | null>(null);
const loading = ref(false);
const modalOpen = ref(false);
const editingId = ref<string | undefined>(undefined);
function openAdd() {
editingId.value = undefined;
modalOpen.value = true;
}
function openEdit(id: string) {
editingId.value = id;
modalOpen.value = true;
}
/** legacy changeConfirme(): one toggle endpoint for both confirm and deny */
async function changeConfirme(record: Record<string, any>) {
try {
@@ -111,11 +128,5 @@ const { remove: deleteCashById } = useDeleteHandler({
function deleteCash(record: Record<string, any>) {
return deleteCashById(`cash/${record.id}`);
}
function toEdit(id: string) {
// legacy list.vue:137 opened /admin/edit/findoc/{id}; the route is
// /edit/findoc/:id, not /finical/edit/:id.
router.push(`/edit/findoc/${id}`);
}
</script>