From c01c1da7e484481704bb9f460e4cd43bd5dcc05a Mon Sep 17 00:00:00 2001 From: safavimohadeseh78 Date: Thu, 19 Feb 2026 17:55:23 +0330 Subject: [PATCH] add discount page --- src/api/discount.ts | 12 ++ src/model/discount.ts | 17 ++ .../menuPages/discount/components/table.vue | 54 ++++++ .../discount/hooks/discountColumns.tsx | 101 +++++++++++ src/pages/menuPages/discount/index.vue | 169 ++++++++++++++++++ .../priceTriggers/components/table.vue | 24 --- src/router/routes/setting.ts | 13 +- 7 files changed, 365 insertions(+), 25 deletions(-) create mode 100644 src/api/discount.ts create mode 100644 src/model/discount.ts create mode 100644 src/pages/menuPages/discount/components/table.vue create mode 100644 src/pages/menuPages/discount/hooks/discountColumns.tsx create mode 100644 src/pages/menuPages/discount/index.vue diff --git a/src/api/discount.ts b/src/api/discount.ts new file mode 100644 index 0000000..eed5aa9 --- /dev/null +++ b/src/api/discount.ts @@ -0,0 +1,12 @@ +import type {TableInput} from "@core/type/baseTable"; +import useAxios from "@core/utils/useAxios"; +import type { Discount } from '@/model/discount' + +export const getDiscountTable = async (params: TableInput) => + await useAxios.post>('/admin/offer_code/table', params) + +export const createDiscount = async (obj: Discount) => + await useAxios.post(`/admin/offer_code/create`, obj) + +export const updateDiscount = async (id: number, obj: Discount) => + await useAxios.put(`/admin/offer_code/${id}`, obj) diff --git a/src/model/discount.ts b/src/model/discount.ts new file mode 100644 index 0000000..1b56dca --- /dev/null +++ b/src/model/discount.ts @@ -0,0 +1,17 @@ +export interface Discount { + id?: number + code?: string + title?: string + description?: string + start_at?: string + end_at?: string + type?: number + discount_percent?: number + discount_price?: number + is_active?: boolean + use_only?: number + use_count?: number + created_at?: string + updated_at?: string + deleted_at?: string +} \ No newline at end of file diff --git a/src/pages/menuPages/discount/components/table.vue b/src/pages/menuPages/discount/components/table.vue new file mode 100644 index 0000000..3021e5e --- /dev/null +++ b/src/pages/menuPages/discount/components/table.vue @@ -0,0 +1,54 @@ + + + + + diff --git a/src/pages/menuPages/discount/hooks/discountColumns.tsx b/src/pages/menuPages/discount/hooks/discountColumns.tsx new file mode 100644 index 0000000..3cdec9b --- /dev/null +++ b/src/pages/menuPages/discount/hooks/discountColumns.tsx @@ -0,0 +1,101 @@ +import type { BaseTableColumn } from '@core/type/baseTable' +import { toJalaliNoTime } from '@core/utils/useDataTime' +import { usePrice } from '@core/utils/usePrice' +import CustomTag from '@/components/CustomTag.vue' + +export const cols: BaseTableColumn[] = [ + { + title: 'ردیف', + dataIndex: 'id', + key: 'id', + filterable: false, + sortable: false, + customRender: (record: any) => { + return record.index + 1 + } + }, + { + title: 'کد تخفیف', + dataIndex: 'code', + key: 'code', + type: 'Number', + customRender: (record: any) => { + return record.record.code ? (record.record.code) : '-' + } + }, + { + title: 'عنوان تخفیف', + dataIndex: 'title', + key: 'title', + type: 'Text', + customRender: (record: any) => { + return record.record.title ? toJalaliNoTime(record.record.title) : '-' + } + }, + { + title: 'دفعات قابل استفاده', + dataIndex: 'use_only', + key: 'use_only', + type: 'Number', + customRender: (record: any) => { + return record.record.use_only ? (record.record.use_only) : '-' + } + }, + { + title: 'مبلغ تخفیف', + dataIndex: 'discount_price', + key: 'discount_price', + type: 'Text', + customRender: (record: any) => { + return record.record.discount_price ? usePrice(record.record.discount_price) : '-' + } + }, + { + title: 'تاریخ شروع', + dataIndex: 'start_at', + key: 'start_at', + type: 'DateTime', + customRender: (record: any) => { + return record.record.start_at ? toJalaliNoTime(record.record.start_at) : '-' + } + }, + { + title: 'تاریخ پایان', + dataIndex: 'end_at', + key: 'end_at', + type: 'DateTime', + customRender: (record: any) => { + return record.record.end_at ? toJalaliNoTime(record.record.end_at) : '-' + } + }, + { + title: 'وضعیت', + dataIndex: 'is_active', + key: 'is_active', + type: 'Boolean', + customRender: ({ record }) => { + return record.is_active ? ( +
+ + فعال + +
+ ) : ( +
+ + غیر فعال + +
+ ) + } + }, + + { + title: 'عملیات', + dataIndex: 'action', + key: 'action', + slot: 'action', + fixed: 'right', + filterable: false + } +] diff --git a/src/pages/menuPages/discount/index.vue b/src/pages/menuPages/discount/index.vue new file mode 100644 index 0000000..a75ba43 --- /dev/null +++ b/src/pages/menuPages/discount/index.vue @@ -0,0 +1,169 @@ + + + + + diff --git a/src/pages/menuPages/priceTriggers/components/table.vue b/src/pages/menuPages/priceTriggers/components/table.vue index 2be1b4a..33291d3 100644 --- a/src/pages/menuPages/priceTriggers/components/table.vue +++ b/src/pages/menuPages/priceTriggers/components/table.vue @@ -10,20 +10,6 @@ --> diff --git a/src/router/routes/setting.ts b/src/router/routes/setting.ts index 15a4c05..691b6d5 100644 --- a/src/router/routes/setting.ts +++ b/src/router/routes/setting.ts @@ -1,5 +1,5 @@ import type { RouteRecordRaw } from 'vue-router' - +import {getConfigApp} from "@/utils/config"; const Setting: RouteRecordRaw = { name: 'settings', path: '/settings', @@ -61,6 +61,17 @@ const Setting: RouteRecordRaw = { title: 'هشدار قیمت' } }, + { + name: 'discounts', + path: 'discounts', + component: () => import('@/pages/menuPages/discount/index.vue'), + meta: { + permissionsKey: 'discounts', + icon: 'vuesax-linear:notification-bing', + title: 'تخفیفات', + hideMenu: getConfigApp.name !== "goldsun" + } + }, { name: 'configuration', path: 'configuration',