From 1bb9802d1f0229b06908a3527b05440c622b4c57 Mon Sep 17 00:00:00 2001 From: "s.esmaeili" Date: Mon, 14 Sep 2026 16:56:30 +0330 Subject: [PATCH] admin-panel: convert promotion add/edit forms into modals PromotionForm.vue (shared by the omde and tak variants) gains open/id modal support; both thin wrappers (promotion_add_edit.vue, promotion_tak_add_edit.vue) pass the props/emits through unchanged. promotion_list.vue gets two ListPageHeader buttons (offers.create / offers.create.tak, matching the two routes' rids) and picks which variant's modal to open based on the edited row's type_customer, exactly as the old toEdit() picked which route to navigate to. Verified: pnpm build passes. Co-Authored-By: Claude Sonnet 5 --- .../src/views/promotion/PromotionForm.vue | 139 +++++++++++++++++- .../views/promotion/promotion_add_edit.vue | 16 +- .../src/views/promotion/promotion_list.vue | 63 ++++++-- .../promotion/promotion_tak_add_edit.vue | 17 ++- 4 files changed, 219 insertions(+), 16 deletions(-) diff --git a/apps/admin-panel/src/views/promotion/PromotionForm.vue b/apps/admin-panel/src/views/promotion/PromotionForm.vue index 569a079..6f98a08 100644 --- a/apps/admin-panel/src/views/promotion/PromotionForm.vue +++ b/apps/admin-panel/src/views/promotion/PromotionForm.vue @@ -8,7 +8,125 @@ option and its whole customer block COMMENTED OUT. Both differences are parameterised here rather than duplicating ~400 lines. --> - + +
+ + + + محصولات + دسته بندی + مشتری + برند + + + + + + + + + + + + {{ p.title }} + + + + + + + + {{ c.title }} + + + + + + + + {{ c.name }} + + + + + + + + {{ b.title }} + + + + + + + + + + + + + + + + + + + فقط یکبار + تا تاریخ پایان + + + + + + +
+ + + + +
+ + +
@@ -134,6 +252,7 @@ import { onMounted, reactive, ref } from 'vue'; import { useRoute, useRouter } from 'vue-router'; import { message } from 'ant-design-vue'; +import BaseFormModal from '../../components/common/BaseFormModal.vue'; import api from '../../api/client'; const props = withDefaults( @@ -144,14 +263,23 @@ const props = withDefaults( * is not offered there. Preserved behind this flag. */ allowCustomerScope?: boolean; + /** Present -> rendered as a modal by the parent list page. */ + open?: boolean; + id?: string; }>(), { title: 'تعریف تخفیف', allowCustomerScope: true }, ); +const emit = defineEmits<{ + (e: 'update:open', value: boolean): void; + (e: 'success'): void; +}>(); + +const asModal = props.open !== undefined; const route = useRoute(); const router = useRouter(); -const id = route.params.id as string | undefined; +const id = asModal ? props.id : (route.params.id as string | undefined); const loading = ref(false); const products = ref<{ id: string; title: string }[]>([]); @@ -209,7 +337,12 @@ async function handleSubmit() { await api.post('product/variant/promotion', form); } message.info('اطلاعات با موفقیت به ثبت رسید.'); - router.push('/major/promotion/list'); + if (asModal) { + emit('success'); + emit('update:open', false); + } else { + router.push('/major/promotion/list'); + } } catch (e: any) { message.error(e?.response?.data?.message ?? 'خطا در ثبت اطلاعات.'); } finally { diff --git a/apps/admin-panel/src/views/promotion/promotion_add_edit.vue b/apps/admin-panel/src/views/promotion/promotion_add_edit.vue index ce42396..d10a3cd 100644 --- a/apps/admin-panel/src/views/promotion/promotion_add_edit.vue +++ b/apps/admin-panel/src/views/promotion/promotion_add_edit.vue @@ -3,11 +3,23 @@ Ported from legacy henza_admin/src/views/promotion/promotion_add_edit.vue. Verified by diff against promotion_tak_add_edit.vue: the two files differ only in the card title and whether the "مشتری" scope is offered, so both are - thin wrappers over PromotionForm. + thin wrappers over PromotionForm. Props/emits pass through unchanged so this + wrapper works both as the /major/promotion/add(/edit/:id) route and as a + modal opened from promotion_list.vue. --> - + diff --git a/apps/admin-panel/src/views/promotion/promotion_list.vue b/apps/admin-panel/src/views/promotion/promotion_list.vue index 4390512..8358619 100644 --- a/apps/admin-panel/src/views/promotion/promotion_list.vue +++ b/apps/admin-panel/src/views/promotion/promotion_list.vue @@ -8,6 +8,11 @@ -->
+
+ + +
+ + + diff --git a/apps/admin-panel/src/views/promotion/promotion_tak_add_edit.vue b/apps/admin-panel/src/views/promotion/promotion_tak_add_edit.vue index baab69c..98e4033 100644 --- a/apps/admin-panel/src/views/promotion/promotion_tak_add_edit.vue +++ b/apps/admin-panel/src/views/promotion/promotion_tak_add_edit.vue @@ -2,11 +2,24 @@ - +