admin-panel: add shared modal/header/icon/delete-handler components
New src/components/common/: - BaseFormModal.vue — the standard shell every converted add/edit modal will use: header=title, footer=buttons, body=form. Replaces the ad-hoc 60%/70%/80% <a-modal> widths used across the codebase with 4 named sizes. - ListPageHeader.vue — the add button that goes above every list page, gated on the same rid the create route used (modelled on the one place this already existed, ListUser.vue's add-user button). New src/components/icons.ts: the legacy-Feather-name -> ant-icon map, extracted out of TooltipBtn.vue so the sidebar can resolve the same names through the same map instead of a second copy. New src/composables/useDeleteHandler.ts: the delete-then-refetch-then-toast handler that was copy-pasted verbatim in 6 list views (city/cityList.vue, user/ListUser.vue, apps/category/List.vue, finical/list.vue, apps/product/ProductList.vue, manage/Const.vue). Preserves each site's exact success-message wording and message.success/info choice, and ProductList's irregular POST-based delete endpoint. Verified: pnpm build passes. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
f0de478940
commit
02d92fc465
@@ -64,7 +64,7 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { message, Modal } from 'ant-design-vue';
|
||||
import { message } from 'ant-design-vue';
|
||||
import {
|
||||
CheckOutlined,
|
||||
CloseOutlined,
|
||||
@@ -74,6 +74,7 @@ import {
|
||||
import XTable from '../../components/x-table/XTable.vue';
|
||||
import { buildDocumentListModel } from './list_model';
|
||||
import { useUsersStore } from '../../stores/users';
|
||||
import { useDeleteHandler } from '../../composables/useDeleteHandler';
|
||||
import api from '../../api/client';
|
||||
|
||||
const router = useRouter();
|
||||
@@ -99,16 +100,16 @@ async function changeConfirme(record: Record<string, any>) {
|
||||
}
|
||||
}
|
||||
|
||||
async function deleteCash(record: Record<string, any>) {
|
||||
try {
|
||||
await api.delete(`cash/${record.id}`);
|
||||
message.success('سند حذف شد');
|
||||
tbl.value?.fetch();
|
||||
} catch (e: any) {
|
||||
// The backend refuses to delete a confirmed entry — it has already moved the
|
||||
// customer's balance. Surface its Farsi explanation.
|
||||
Modal.error({ title: e?.response?.data?.message ?? 'خطا در حذف سند', okText: 'بستن' });
|
||||
}
|
||||
// The backend refuses to delete a confirmed entry — it has already moved the
|
||||
// customer's balance. Surface its Farsi explanation.
|
||||
const { remove: deleteCashById } = useDeleteHandler({
|
||||
onSuccess: () => tbl.value?.fetch(),
|
||||
successMessage: 'سند حذف شد',
|
||||
fallbackErrorMessage: 'خطا در حذف سند',
|
||||
});
|
||||
|
||||
function deleteCash(record: Record<string, any>) {
|
||||
return deleteCashById(`cash/${record.id}`);
|
||||
}
|
||||
|
||||
function toEdit(id: string) {
|
||||
|
||||
Reference in New Issue
Block a user