From 9c5d153fc0084cc4e73f1eaaf8bde4f4e9b86a1c Mon Sep 17 00:00:00 2001 From: MojtabaSoumi Date: Mon, 4 May 2026 16:22:10 +0330 Subject: [PATCH] 1405/02/14-add giftCards --- src/api/giftCard.ts | 14 + src/model/giftCard.ts | 46 ++ .../menuPages/giftCards/components/table.vue | 132 ++++++ .../giftCards/hooks/orderColumns.tsx | 239 ++++++++++ src/pages/menuPages/giftCards/index.vue | 412 ++++++++++++++++++ src/router/routes/giftCard.ts | 35 ++ 6 files changed, 878 insertions(+) create mode 100644 src/api/giftCard.ts create mode 100644 src/model/giftCard.ts create mode 100644 src/pages/menuPages/giftCards/components/table.vue create mode 100644 src/pages/menuPages/giftCards/hooks/orderColumns.tsx create mode 100644 src/pages/menuPages/giftCards/index.vue create mode 100644 src/router/routes/giftCard.ts diff --git a/src/api/giftCard.ts b/src/api/giftCard.ts new file mode 100644 index 0000000..7b70e87 --- /dev/null +++ b/src/api/giftCard.ts @@ -0,0 +1,14 @@ +import type { TableInput } from '@core/type/baseTable' +import useAxios from '@core/utils/useAxios' +import type { Order } from '@/model/order' +import type { AddId, Customer } from '@/model/customer' +import type {Giftcard, GiftcardInput} from "@/model/giftCard"; + +export const getGiftCardTable = async (params: TableInput) => + await useAxios.post>('/admin/giftcard/table', params) + +export const createGiftCard = async (obj: GiftcardInput) => + await useAxios.post(`/admin/giftcard/generate`, obj) + + + diff --git a/src/model/giftCard.ts b/src/model/giftCard.ts new file mode 100644 index 0000000..2469ade --- /dev/null +++ b/src/model/giftCard.ts @@ -0,0 +1,46 @@ +export interface Giftcard { + id: number + customer_id: any + count: number + amount: number + total: number + unit: number + unique_code: any + created_at: string + sts: any + expiry_date: string + used_count: any + updated_at: string + description: string + sts_str: any + giftcardcodes: Giftcardcode[] +} + +export interface Giftcardcode { + id: number + giftcard_id: number + code: string + sts: number + unit: number + amount: number + assigned_to: AssignedTo + used_at: string + expiry_date: string + created_at: string + updated_at: string +} +export interface AssignedTo { + id: number + name: string + mobile: string +} + +export interface GiftcardInput { + mobile: string + name: string + count: number + amount: number + unit: string + expiry_date: string + description: string +} diff --git a/src/pages/menuPages/giftCards/components/table.vue b/src/pages/menuPages/giftCards/components/table.vue new file mode 100644 index 0000000..c7bff75 --- /dev/null +++ b/src/pages/menuPages/giftCards/components/table.vue @@ -0,0 +1,132 @@ + + + + + diff --git a/src/pages/menuPages/giftCards/hooks/orderColumns.tsx b/src/pages/menuPages/giftCards/hooks/orderColumns.tsx new file mode 100644 index 0000000..acb627d --- /dev/null +++ b/src/pages/menuPages/giftCards/hooks/orderColumns.tsx @@ -0,0 +1,239 @@ +import type { BaseTableColumn } from '@core/type/baseTable' +import { toJalali, toJalaliNoTime, toTime } from '@core/utils/useDataTime' +import CustomTag from '@/components/CustomTag.vue' +import { usePrice } from '@core/utils/usePrice' +/*import BudgetSelect from '@/components/BudgetSelect.vue' +import { useStaticApiListsStore } from '@/store/staticApisStore' +import type { FilterSelect } from '@/model/filterSelect' +import type { DocItem } from '@/model/docType'*/ + +//define store +//const store = useStaticApiListsStore() +//document types +/*let docTypes: DocItem[]*/ +/*onMounted(async () => { + docTypes = await store.readyDocTypeList() +}) +const filteredDocTypes: FilterSelect = docTypes?.map((x: DocItem) => { + return { + label: x.title, + value: x.id + } +})*/ + +export const cols: BaseTableColumn[] = [ + { + title: 'ردیف', + dataIndex: 'id', + key: 'id', + filterable: false, + sortable: false, + customRender: (record: any) => { + return record.index + 1 + } + }, + { + title: 'کد ', + dataIndex: 'id', + key: 'id', + type: 'Number' + // className: 'column-money' + }, + { + title: 'نوع کارت هدیه', + dataIndex: 'unit', + key: 'unit', + filterable: false, + customRender: ({ record }) => { + switch (record.unit) { + case 2: + return ( +
+ + طلایی + +
+ ) + case 1: + return ( +
+ + ریالی + +
+ ) + } + } + }, + { + title: 'تعداد کد ها', + dataIndex: 'count', + key: 'count', + type: 'Number' + }, + { + title: 'مقدار (گرم)', + dataIndex: 'amount', + key: 'amount', + type: 'Text' + }, + { + title: 'مبلغ کل (ریال)', + dataIndex: 'total', + key: 'total', + type: 'Number', + customRender: (data) => { + return usePrice(data.record?.total ?? 0, true, '') + } + }, + { + title: 'کد یکتا', + dataIndex: 'unique_code', + key: 'unique_code', + type: 'Text' + }, + { + title: 'تعداد استفاده شده', + dataIndex: 'used_count', + key: 'used_count', + type: 'Number' + }, + { + title: 'مشتری', + dataIndex: 'customer.name', + key: 'customer.name', + type: 'Text', + customRender: ({ record }) => { + return record.customer?.name ?? '-' + } + }, + { + title: 'شماره موبایل مشتری', + dataIndex: 'customer.mobile', + key: 'customer.mobile', + type: 'Number', + customRender: ({ record }) => { + return record.customer?.mobile ?? '-' + } + }, + { + title: 'توضیحات', + dataIndex: 'description', + key: 'description', + type: 'Text' + }, + { + title: 'وضعیت', + dataIndex: 'sts', + key: 'sts', + filterable: false, + customRender: ({ record }) => { + switch (record.sts) { + case 1: + return ( +
+ + {record.sts_str} + +
+ ) + case 2: + return ( +
+ + {record.sts_str} + +
+ ) + default: + return ( +
+ + {record.sts_str} + +
+ ) + } + } + }, + { + title: 'تاریخ ثبت', + dataIndex: 'created_at', + key: 'created_at', + type: 'DateTime', + customRender: (record: any) => { + return toJalali(record.record.created_at) + } + }, + { + title: 'تاریخ انقضا', + dataIndex: 'expiry_date', + key: 'expiry_date', + type: 'DateTime', + customRender: (record: any) => { + return toJalali(record.record.expiry_date) + } + }, + /*{ + title: 'نقش', + dataIndex: 'user_type_record', + key: 'user_type_record', + type: 'Select', + filterable: false, + sortable: false, + filterComponentProps: { + multiple: true + }, + filterField: 'user_type_obj.id', + filterComponent: ReadyUserTypeSelect, + /!* customRender: (record: any) => { + return record.record.user_type_record?.value + }*!/ + customRender: ({ record }) => { + const items = record.is_admin ? ( + + ادمین + + ) : ( + record.user_type_obj.map((item: { title: any }, index: any) => { + if (item) { + return ( + + {item?.title} + + ) + } + }) + ) + return
{items}
+ } + }, + { + title: 'حوزه', + dataIndex: 'section', + key: 'section' + }, + { + title: 'شماره موبایل', + dataIndex: 'mobile', + type: 'Number', + key: 'mobile' + }, + { + title: 'تاریخ ثبت', + dataIndex: 'created_at', + key: 'created_at', + type: 'DateTime', + customRender: (record: any) => { + return toJalaliNoTime(record.record.created_at) + } + },*/ + { + title: 'عملیات', + dataIndex: 'action', + key: 'action', + slot: 'action', + fixed: 'right', + filterable: false + } +] diff --git a/src/pages/menuPages/giftCards/index.vue b/src/pages/menuPages/giftCards/index.vue new file mode 100644 index 0000000..41c69b5 --- /dev/null +++ b/src/pages/menuPages/giftCards/index.vue @@ -0,0 +1,412 @@ + + + + + diff --git a/src/router/routes/giftCard.ts b/src/router/routes/giftCard.ts new file mode 100644 index 0000000..912c4b7 --- /dev/null +++ b/src/router/routes/giftCard.ts @@ -0,0 +1,35 @@ +import type { RouteRecordRaw } from 'vue-router' + +const Orders: RouteRecordRaw = { + name: 'giftCard', + path: '/giftCard', + component: () => import('@core/layouts/BasicLayout.vue'), + redirect: { name: 'giftCardMain' }, + meta: { + icon: 'vuesax-linear:gift', + permissionsKey: 'giftCard', + title: 'کارت هدیه', + disabled: false, + hideMenu: false, + hideChildren: true, + order: 7 + }, + children: [ + { + name: 'giftCardMain', + path: '', + component: () => import('@/pages/menuPages/giftCards/index.vue'), + meta: { + permissionsKey: 'project', + icon: 'vuesax-linear:empty-wallet-time', + order: 3, + title: 'کارت هدیه', + disabled: false, + hideMenu: false + //hideChildren: false + } + } + ] +} + +export default Orders