diff --git a/src/core/components/BaseDatePicker/src/BaseDatePicker.vue b/src/core/components/BaseDatePicker/src/BaseDatePicker.vue index 4069082..c492283 100644 --- a/src/core/components/BaseDatePicker/src/BaseDatePicker.vue +++ b/src/core/components/BaseDatePicker/src/BaseDatePicker.vue @@ -9,6 +9,8 @@ import DatePicker from './datePick' import locale from 'ant-design-vue/es/date-picker/locale/fa_IR' import dayjs, { Dayjs } from 'dayjs' import { omit } from 'lodash' +import { computed, useAttrs } from 'vue' +import { persianToEnglishDigits } from '@/utils/persianDigits' interface Props { value?: string | Dayjs @@ -26,7 +28,7 @@ const _attrs = computed(() => { const props = withDefaults(defineProps(), { value: '', - format: 'YYYY/MM/DD', + format: 'YYYY-MM-DD', inputReadOnly:true }) @@ -39,7 +41,7 @@ const _date = computed({ set: (val) => { let temp: string | null = null if (val) { - temp = val.calendar('gregory').locale('en').format(props.format) + temp = persianToEnglishDigits(val.calendar('gregory').locale('en').format(props.format)) } emit('update:value', temp) emit('onchange', temp) diff --git a/src/pages/menuPages/customers/base/hooks/customerColumns.tsx b/src/pages/menuPages/customers/base/hooks/customerColumns.tsx index 2430882..4842d97 100644 --- a/src/pages/menuPages/customers/base/hooks/customerColumns.tsx +++ b/src/pages/menuPages/customers/base/hooks/customerColumns.tsx @@ -97,7 +97,7 @@ export function buildCustomerColumns(metals: CustomerMetalColumn[] = []): BaseTa return [ ...baseColumns, ...metalColumns, - { +/* { title: 'اخرین بازدید', dataIndex: 'last_seen_at', key: 'last_seen_at', @@ -105,7 +105,7 @@ export function buildCustomerColumns(metals: CustomerMetalColumn[] = []): BaseTa customRender(data) { return toJalali(data.record.last_seen_at) } - }, + },*/ { title: 'وضعیت کاربر', dataIndex: 'active', diff --git a/src/pages/menuPages/products/base/hooks/productColumns.tsx b/src/pages/menuPages/products/base/hooks/productColumns.tsx index 792b96d..e2e3d80 100644 --- a/src/pages/menuPages/products/base/hooks/productColumns.tsx +++ b/src/pages/menuPages/products/base/hooks/productColumns.tsx @@ -17,110 +17,116 @@ const inventoryColumn: BaseTableColumn = { export function getProductColumns(): BaseTableColumn[] { return [ - { - title: 'ردیف', - dataIndex: 'id', - key: 'id', - filterable: false, - sortable: false, - customRender: (record: any) => record.index + 1 - }, - { - title: 'نام', - dataIndex: 'title', - key: 'title', - type: 'Text' - }, - { - title: 'وزن', - dataIndex: 'amount', - key: 'amount', - type: 'Number' - }, - { - title: 'واحد', - dataIndex: 'unit', - key: 'unit', - type: 'Text' - }, - { - title: 'دسته بندی', - dataIndex: 'group_type', - key: 'group_type', - type: 'Text' - }, - { - title: 'قیمت', - dataIndex: 'price', - key: 'price', - type: 'Text', - customRender: ({ record }) => formatMoney(record.price) - }, - { - title: 'تعدیل قیمت (٪)', - dataIndex: 'price_offset_percent', - key: 'price_offset_percent', - type: 'Number', - customRender: (record) => ( -
- {record?.record.reading_method - ? `${record?.record.price_offset_percent ?? 0}` - : '—'} -
- ) - }, - { - title: 'متد', - dataIndex: 'reading_method', - key: 'reading_method', - type: 'Text', - customRender: (record) => ( -
- - {record?.record.reading_method ? record?.record.reading_method : 'دستی'} - -
- ) - }, - { - title: 'هزینه خرید', - dataIndex: 'cash_fee_buy', - key: 'cash_fee_buy', - type: 'Number', - customRender: ({ record }) => formatAdminCashFeeLabel(record.cash_fee_buy, record.cash_fee_buy_is_percent) - }, - { - title: 'هزینه فروش', - dataIndex: 'cash_fee_sell', - key: 'cash_fee_sell', - type: 'Number', - customRender: ({ record }) => formatAdminCashFeeLabel(record.cash_fee_sell, record.cash_fee_sell_is_percent) - }, - ...(isStoreApp() ? [inventoryColumn] : []), - { - title: 'وضعیت محصول', - dataIndex: 'active', - key: 'active', - type: 'Boolean', - customRender: (record) => ( -
- - {record?.record.active ? 'باز' : 'بسته'} - -
- ) - }, - { - title: 'عملیات', - dataIndex: 'action', - key: 'action', - slot: 'action', - filterable: false - } + { + title: 'ردیف', + dataIndex: 'id', + key: 'id', + filterable: false, + sortable: false, + customRender: (record: any) => record.index + 1 + }, + { + title: 'کد محصول', + dataIndex: 'id', + key: 'id', + type: 'Number' + }, + { + title: 'نام', + dataIndex: 'title', + key: 'title', + type: 'Text' + }, + { + title: 'وزن', + dataIndex: 'amount', + key: 'amount', + type: 'Number' + }, + { + title: 'واحد', + dataIndex: 'unit', + key: 'unit', + type: 'Text' + }, + { + title: 'دسته بندی', + dataIndex: 'group_type', + key: 'group_type', + type: 'Text' + }, + { + title: 'قیمت', + dataIndex: 'price', + key: 'price', + type: 'Text', + customRender: ({ record }) => formatMoney(record.price) + }, + { + title: 'تعدیل قیمت (٪)', + dataIndex: 'price_offset_percent', + key: 'price_offset_percent', + type: 'Number', + customRender: (record) => ( +
+ {record?.record.reading_method ? `${record?.record.price_offset_percent ?? 0}` : '—'} +
+ ) + }, + { + title: 'متد', + dataIndex: 'reading_method', + key: 'reading_method', + type: 'Text', + customRender: (record) => ( +
+ + {record?.record.reading_method ? record?.record.reading_method : 'دستی'} + +
+ ) + }, + { + title: 'هزینه خرید', + dataIndex: 'cash_fee_buy', + key: 'cash_fee_buy', + type: 'Number', + customRender: ({ record }) => + formatAdminCashFeeLabel(record.cash_fee_buy, record.cash_fee_buy_is_percent) + }, + { + title: 'هزینه فروش', + dataIndex: 'cash_fee_sell', + key: 'cash_fee_sell', + type: 'Number', + customRender: ({ record }) => + formatAdminCashFeeLabel(record.cash_fee_sell, record.cash_fee_sell_is_percent) + }, + ...(isStoreApp() ? [inventoryColumn] : []), + { + title: 'وضعیت محصول', + dataIndex: 'active', + key: 'active', + type: 'Boolean', + customRender: (record) => ( +
+ + {record?.record.active ? 'باز' : 'بسته'} + +
+ ) + }, + { + title: 'عملیات', + dataIndex: 'action', + key: 'action', + slot: 'action', + filterable: false + } ] } diff --git a/src/utils/persianDigits.ts b/src/utils/persianDigits.ts new file mode 100644 index 0000000..e985219 --- /dev/null +++ b/src/utils/persianDigits.ts @@ -0,0 +1,13 @@ +const PERSIAN_DIGITS = '۰۱۲۳۴۵۶۷۸۹' +const ARABIC_DIGITS = '٠١٢٣٤٥٦٧٨٩' + +export function persianToEnglishDigits(value: string | number | null | undefined): string { + if (value == null) { + return '' + } + + return String(value) + .replace(/[۰-۹]/g, (d) => String(PERSIAN_DIGITS.indexOf(d))) + .replace(/[٠-٩]/g, (d) => String(ARABIC_DIGITS.indexOf(d))) + .replace(/٫/g, '.') +}