fix error in update me

This commit is contained in:
2026-07-16 11:36:16 +03:30
parent 14d0285847
commit 62414cac88
4 changed files with 129 additions and 108 deletions
@@ -9,6 +9,8 @@ import DatePicker from './datePick'
import locale from 'ant-design-vue/es/date-picker/locale/fa_IR' import locale from 'ant-design-vue/es/date-picker/locale/fa_IR'
import dayjs, { Dayjs } from 'dayjs' import dayjs, { Dayjs } from 'dayjs'
import { omit } from 'lodash' import { omit } from 'lodash'
import { computed, useAttrs } from 'vue'
import { persianToEnglishDigits } from '@/utils/persianDigits'
interface Props { interface Props {
value?: string | Dayjs value?: string | Dayjs
@@ -26,7 +28,7 @@ const _attrs = computed(() => {
const props = withDefaults(defineProps<Props>(), { const props = withDefaults(defineProps<Props>(), {
value: '', value: '',
format: 'YYYY/MM/DD', format: 'YYYY-MM-DD',
inputReadOnly:true inputReadOnly:true
}) })
@@ -39,7 +41,7 @@ const _date = computed({
set: (val) => { set: (val) => {
let temp: string | null = null let temp: string | null = null
if (val) { 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('update:value', temp)
emit('onchange', temp) emit('onchange', temp)
@@ -97,7 +97,7 @@ export function buildCustomerColumns(metals: CustomerMetalColumn[] = []): BaseTa
return [ return [
...baseColumns, ...baseColumns,
...metalColumns, ...metalColumns,
{ /* {
title: 'اخرین بازدید', title: 'اخرین بازدید',
dataIndex: 'last_seen_at', dataIndex: 'last_seen_at',
key: 'last_seen_at', key: 'last_seen_at',
@@ -105,7 +105,7 @@ export function buildCustomerColumns(metals: CustomerMetalColumn[] = []): BaseTa
customRender(data) { customRender(data) {
return toJalali(data.record.last_seen_at) return toJalali(data.record.last_seen_at)
} }
}, },*/
{ {
title: 'وضعیت کاربر', title: 'وضعیت کاربر',
dataIndex: 'active', dataIndex: 'active',
@@ -25,6 +25,12 @@ export function getProductColumns(): BaseTableColumn[] {
sortable: false, sortable: false,
customRender: (record: any) => record.index + 1 customRender: (record: any) => record.index + 1
}, },
{
title: 'کد محصول',
dataIndex: 'id',
key: 'id',
type: 'Number'
},
{ {
title: 'نام', title: 'نام',
dataIndex: 'title', dataIndex: 'title',
@@ -63,9 +69,7 @@ export function getProductColumns(): BaseTableColumn[] {
type: 'Number', type: 'Number',
customRender: (record) => ( customRender: (record) => (
<div class="flex justify-center"> <div class="flex justify-center">
{record?.record.reading_method {record?.record.reading_method ? `${record?.record.price_offset_percent ?? 0}` : '—'}
? `${record?.record.price_offset_percent ?? 0}`
: '—'}
</div> </div>
) )
}, },
@@ -87,14 +91,16 @@ export function getProductColumns(): BaseTableColumn[] {
dataIndex: 'cash_fee_buy', dataIndex: 'cash_fee_buy',
key: 'cash_fee_buy', key: 'cash_fee_buy',
type: 'Number', type: 'Number',
customRender: ({ record }) => formatAdminCashFeeLabel(record.cash_fee_buy, record.cash_fee_buy_is_percent) customRender: ({ record }) =>
formatAdminCashFeeLabel(record.cash_fee_buy, record.cash_fee_buy_is_percent)
}, },
{ {
title: 'هزینه فروش', title: 'هزینه فروش',
dataIndex: 'cash_fee_sell', dataIndex: 'cash_fee_sell',
key: 'cash_fee_sell', key: 'cash_fee_sell',
type: 'Number', type: 'Number',
customRender: ({ record }) => formatAdminCashFeeLabel(record.cash_fee_sell, record.cash_fee_sell_is_percent) customRender: ({ record }) =>
formatAdminCashFeeLabel(record.cash_fee_sell, record.cash_fee_sell_is_percent)
}, },
...(isStoreApp() ? [inventoryColumn] : []), ...(isStoreApp() ? [inventoryColumn] : []),
{ {
+13
View File
@@ -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, '.')
}