From 89e2643dfff658440192b235768c5d5ae2c09046 Mon Sep 17 00:00:00 2001 From: adonis Date: Wed, 8 Jul 2026 11:24:25 +0330 Subject: [PATCH] added some text handling 2 --- src/api/physicalWithdraw.ts | 55 ++++++ src/model/wallet.ts | 2 + .../PhysicalWithdrawEditorFormBody.vue | 187 ++++++++++++++++++ .../physicalWithdraw/components/table.vue | 187 ++++++++++++++++++ .../hooks/physicalWithdrawColumns.tsx | 96 +++++++++ .../menuPages/physicalWithdraw/index.vue | 122 ++++++++++++ src/router/routes/physicalWithdraw.ts | 31 +++ 7 files changed, 680 insertions(+) create mode 100644 src/api/physicalWithdraw.ts create mode 100644 src/pages/menuPages/physicalWithdraw/components/PhysicalWithdrawEditorFormBody.vue create mode 100644 src/pages/menuPages/physicalWithdraw/components/table.vue create mode 100644 src/pages/menuPages/physicalWithdraw/hooks/physicalWithdrawColumns.tsx create mode 100644 src/pages/menuPages/physicalWithdraw/index.vue create mode 100644 src/router/routes/physicalWithdraw.ts diff --git a/src/api/physicalWithdraw.ts b/src/api/physicalWithdraw.ts new file mode 100644 index 0000000..baaa3ae --- /dev/null +++ b/src/api/physicalWithdraw.ts @@ -0,0 +1,55 @@ +import type { TableInput } from '@core/type/baseTable' +import useAxios from '@core/utils/useAxios' +import type { Withdraw } from '@/model/wallet' + +export interface PhysicalWithdrawProductOption { + product_id: number + title: string + wallet_id: number + available: number + unit: string + is_main_wallet?: boolean +} + +export interface PhysicalWithdrawAddressOption { + id: number + province?: string + city?: string + address?: string + phone?: string + zip?: string + default_address?: boolean +} + +export interface PhysicalWithdrawOptions { + products: PhysicalWithdrawProductOption[] + addresses: PhysicalWithdrawAddressOption[] +} + +export interface PhysicalWithdrawLineInput { + wallet_id: number + value: number +} + +export interface CreatePhysicalWithdrawPayload { + customer_id: number + address_id: number + wallets: PhysicalWithdrawLineInput[] +} + +export const getPhysicalWithdrawTable = async (params?: TableInput) => + await useAxios.post>('/admin/wallet/withdraw_physical/table', params) + +export const getPhysicalWithdrawOptions = async (customerId: number) => + await useAxios.get(`/admin/wallet/withdraw_physical/options/${customerId}`) + +export const createPhysicalWithdraw = async (payload: CreatePhysicalWithdrawPayload) => + await useAxios.post<{ id: number }>('/admin/wallet/withdraw_physical', payload) + +export const adjustPhysicalWithdraw = async ( + withdrawId: number, + payload: { transaction_id: number; direction: 'increase' | 'decrease' } +) => await useAxios.post(`/admin/wallet/withdraw_physical/${withdrawId}/adjust`, payload) + +export const approvePhysicalWithdraw = async (withdrawId: number, sts = 51) => + await useAxios.put(`/admin/wallet/withdraw/${withdrawId}`, { sts }) diff --git a/src/model/wallet.ts b/src/model/wallet.ts index 95209f0..bc703f4 100644 --- a/src/model/wallet.ts +++ b/src/model/wallet.ts @@ -60,8 +60,10 @@ export interface WalletTableSums { } export interface WithdrawTransaction { + id?: number title?: string gold?: number + product?: { title?: string; amount?: number } } export interface Withdraw { diff --git a/src/pages/menuPages/physicalWithdraw/components/PhysicalWithdrawEditorFormBody.vue b/src/pages/menuPages/physicalWithdraw/components/PhysicalWithdrawEditorFormBody.vue new file mode 100644 index 0000000..bca2793 --- /dev/null +++ b/src/pages/menuPages/physicalWithdraw/components/PhysicalWithdrawEditorFormBody.vue @@ -0,0 +1,187 @@ + + + diff --git a/src/pages/menuPages/physicalWithdraw/components/table.vue b/src/pages/menuPages/physicalWithdraw/components/table.vue new file mode 100644 index 0000000..c11d63e --- /dev/null +++ b/src/pages/menuPages/physicalWithdraw/components/table.vue @@ -0,0 +1,187 @@ + + + diff --git a/src/pages/menuPages/physicalWithdraw/hooks/physicalWithdrawColumns.tsx b/src/pages/menuPages/physicalWithdraw/hooks/physicalWithdrawColumns.tsx new file mode 100644 index 0000000..b604d85 --- /dev/null +++ b/src/pages/menuPages/physicalWithdraw/hooks/physicalWithdrawColumns.tsx @@ -0,0 +1,96 @@ +import type { BaseTableColumn } from '@core/type/baseTable' +import { toJalali } from '@core/utils/useDataTime' +import CustomTag from '@/components/CustomTag.vue' +import type { Withdraw } from '@/model/wallet' + +function formatProductsSummary(record: Withdraw): string { + const lines = record.transaction ?? [] + if (!lines.length) return '-' + + return lines + .map((tx) => { + const qty = Math.abs(Number(tx.gold ?? 0)) + const title = String(tx.title ?? '').trim() || 'محصول' + return `${title}: ${qty}` + }) + .join(' | ') +} + +function formatAddress(record: Withdraw & { address?: { province?: string; city?: string; address?: string } }): string { + const addr = record.address ?? (record as { Address?: { province?: string; city?: string; address?: string } }).Address + if (!addr) return '-' + const parts = [addr.province, addr.city, addr.address].filter(Boolean) + return parts.length ? parts.join(' / ') : '-' +} + +export function getPhysicalWithdrawColumns(): BaseTableColumn[] { + return [ + { + title: 'ردیف', + dataIndex: 'id', + key: 'row', + filterable: false, + sortable: false, + customRender: (record: { index: number }) => record.index + 1 + }, + { + title: 'کد سند', + dataIndex: 'id', + key: 'id', + type: 'Number' + }, + { + title: 'مشتری', + dataIndex: 'customer.name', + key: 'customer.name', + type: 'Text' + }, + { + title: 'محصولات', + dataIndex: 'transaction', + key: 'products', + filterable: false, + sortable: false, + customRender: ({ record }) => ( +
{formatProductsSummary(record)}
+ ) + }, + { + title: 'آدرس', + dataIndex: 'address', + key: 'address', + filterable: false, + sortable: false, + customRender: ({ record }) => ( +
{formatAddress(record)}
+ ) + }, + { + title: 'وضعیت', + dataIndex: 'sts', + key: 'sts', + filterable: false, + customRender: ({ record }) => ( + + {record?.sts_str ?? '-'} + + ) + }, + { + title: 'تاریخ ثبت', + dataIndex: 'created_at', + key: 'created_at', + type: 'DateTime', + customRender: (record: { record: { created_at?: string } }) => toJalali(record.record.created_at) + }, + { + title: 'عملیات', + dataIndex: 'action', + key: 'action', + width: 260, + slot: 'action', + filterable: false, + fixed: 'right' + } + ] +} diff --git a/src/pages/menuPages/physicalWithdraw/index.vue b/src/pages/menuPages/physicalWithdraw/index.vue new file mode 100644 index 0000000..c3db0d2 --- /dev/null +++ b/src/pages/menuPages/physicalWithdraw/index.vue @@ -0,0 +1,122 @@ + + + diff --git a/src/router/routes/physicalWithdraw.ts b/src/router/routes/physicalWithdraw.ts new file mode 100644 index 0000000..2ba2af0 --- /dev/null +++ b/src/router/routes/physicalWithdraw.ts @@ -0,0 +1,31 @@ +import type { RouteRecordRaw } from 'vue-router' + +const PhysicalWithdraw: RouteRecordRaw = { + name: 'physicalWithdraw', + path: '/physical-withdraw', + component: () => import('@core/layouts/BasicLayout.vue'), + redirect: { name: 'physicalWithdrawMain' }, + meta: { + icon: 'vuesax-linear:truck-tick', + title: 'برداشت فیزیکی', + disabled: false, + hideMenu: false, + hideChildren: true, + order: 7.5 + }, + children: [ + { + name: 'physicalWithdrawMain', + path: '', + component: () => import('@/pages/menuPages/physicalWithdraw/index.vue'), + meta: { + icon: 'vuesax-linear:truck-tick', + title: 'برداشت فیزیکی', + disabled: false, + hideMenu: false + } + } + ] +} + +export default PhysicalWithdraw