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 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<Props>(), {
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)
@@ -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',
@@ -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) => (
<div class="flex justify-center">
{record?.record.reading_method
? `${record?.record.price_offset_percent ?? 0}`
: '—'}
</div>
)
},
{
title: 'متد',
dataIndex: 'reading_method',
key: 'reading_method',
type: 'Text',
customRender: (record) => (
<div class="flex justify-center">
<CustomTag textColor="#1d4ed8" bgColor="#dbeafe">
{record?.record.reading_method ? record?.record.reading_method : 'دستی'}
</CustomTag>
</div>
)
},
{
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) => (
<div class="flex justify-center">
<CustomTag
class="px-3 font-bold py-1"
textColor={record?.record.active ? '#65a30d' : '#dc2626'}
bgColor={record?.record.active ? '#ecfccb' : '#fee2e2'}
>
{record?.record.active ? 'باز' : 'بسته'}
</CustomTag>
</div>
)
},
{
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) => (
<div class="flex justify-center">
{record?.record.reading_method ? `${record?.record.price_offset_percent ?? 0}` : '—'}
</div>
)
},
{
title: 'متد',
dataIndex: 'reading_method',
key: 'reading_method',
type: 'Text',
customRender: (record) => (
<div class="flex justify-center">
<CustomTag textColor="#1d4ed8" bgColor="#dbeafe">
{record?.record.reading_method ? record?.record.reading_method : 'دستی'}
</CustomTag>
</div>
)
},
{
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) => (
<div class="flex justify-center">
<CustomTag
class="px-3 font-bold py-1"
textColor={record?.record.active ? '#65a30d' : '#dc2626'}
bgColor={record?.record.active ? '#ecfccb' : '#fee2e2'}
>
{record?.record.active ? 'باز' : 'بسته'}
</CustomTag>
</div>
)
},
{
title: 'عملیات',
dataIndex: 'action',
key: 'action',
slot: 'action',
filterable: false
}
]
}
+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, '.')
}