fix error in update me
This commit is contained in:
@@ -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',
|
||||||
|
|||||||
@@ -17,110 +17,116 @@ const inventoryColumn: BaseTableColumn = {
|
|||||||
|
|
||||||
export function getProductColumns(): BaseTableColumn[] {
|
export function getProductColumns(): BaseTableColumn[] {
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
title: 'ردیف',
|
title: 'ردیف',
|
||||||
dataIndex: 'id',
|
dataIndex: 'id',
|
||||||
key: 'id',
|
key: 'id',
|
||||||
filterable: false,
|
filterable: false,
|
||||||
sortable: false,
|
sortable: false,
|
||||||
customRender: (record: any) => record.index + 1
|
customRender: (record: any) => record.index + 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'نام',
|
title: 'کد محصول',
|
||||||
dataIndex: 'title',
|
dataIndex: 'id',
|
||||||
key: 'title',
|
key: 'id',
|
||||||
type: 'Text'
|
type: 'Number'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'وزن',
|
title: 'نام',
|
||||||
dataIndex: 'amount',
|
dataIndex: 'title',
|
||||||
key: 'amount',
|
key: 'title',
|
||||||
type: 'Number'
|
type: 'Text'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'واحد',
|
title: 'وزن',
|
||||||
dataIndex: 'unit',
|
dataIndex: 'amount',
|
||||||
key: 'unit',
|
key: 'amount',
|
||||||
type: 'Text'
|
type: 'Number'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'دسته بندی',
|
title: 'واحد',
|
||||||
dataIndex: 'group_type',
|
dataIndex: 'unit',
|
||||||
key: 'group_type',
|
key: 'unit',
|
||||||
type: 'Text'
|
type: 'Text'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'قیمت',
|
title: 'دسته بندی',
|
||||||
dataIndex: 'price',
|
dataIndex: 'group_type',
|
||||||
key: 'price',
|
key: 'group_type',
|
||||||
type: 'Text',
|
type: 'Text'
|
||||||
customRender: ({ record }) => formatMoney(record.price)
|
},
|
||||||
},
|
{
|
||||||
{
|
title: 'قیمت',
|
||||||
title: 'تعدیل قیمت (٪)',
|
dataIndex: 'price',
|
||||||
dataIndex: 'price_offset_percent',
|
key: 'price',
|
||||||
key: 'price_offset_percent',
|
type: 'Text',
|
||||||
type: 'Number',
|
customRender: ({ record }) => formatMoney(record.price)
|
||||||
customRender: (record) => (
|
},
|
||||||
<div class="flex justify-center">
|
{
|
||||||
{record?.record.reading_method
|
title: 'تعدیل قیمت (٪)',
|
||||||
? `${record?.record.price_offset_percent ?? 0}`
|
dataIndex: 'price_offset_percent',
|
||||||
: '—'}
|
key: 'price_offset_percent',
|
||||||
</div>
|
type: 'Number',
|
||||||
)
|
customRender: (record) => (
|
||||||
},
|
<div class="flex justify-center">
|
||||||
{
|
{record?.record.reading_method ? `${record?.record.price_offset_percent ?? 0}` : '—'}
|
||||||
title: 'متد',
|
</div>
|
||||||
dataIndex: 'reading_method',
|
)
|
||||||
key: 'reading_method',
|
},
|
||||||
type: 'Text',
|
{
|
||||||
customRender: (record) => (
|
title: 'متد',
|
||||||
<div class="flex justify-center">
|
dataIndex: 'reading_method',
|
||||||
<CustomTag textColor="#1d4ed8" bgColor="#dbeafe">
|
key: 'reading_method',
|
||||||
{record?.record.reading_method ? record?.record.reading_method : 'دستی'}
|
type: 'Text',
|
||||||
</CustomTag>
|
customRender: (record) => (
|
||||||
</div>
|
<div class="flex justify-center">
|
||||||
)
|
<CustomTag textColor="#1d4ed8" bgColor="#dbeafe">
|
||||||
},
|
{record?.record.reading_method ? record?.record.reading_method : 'دستی'}
|
||||||
{
|
</CustomTag>
|
||||||
title: 'هزینه خرید',
|
</div>
|
||||||
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_buy',
|
||||||
{
|
key: 'cash_fee_buy',
|
||||||
title: 'هزینه فروش',
|
type: 'Number',
|
||||||
dataIndex: 'cash_fee_sell',
|
customRender: ({ record }) =>
|
||||||
key: 'cash_fee_sell',
|
formatAdminCashFeeLabel(record.cash_fee_buy, record.cash_fee_buy_is_percent)
|
||||||
type: 'Number',
|
},
|
||||||
customRender: ({ record }) => formatAdminCashFeeLabel(record.cash_fee_sell, record.cash_fee_sell_is_percent)
|
{
|
||||||
},
|
title: 'هزینه فروش',
|
||||||
...(isStoreApp() ? [inventoryColumn] : []),
|
dataIndex: 'cash_fee_sell',
|
||||||
{
|
key: 'cash_fee_sell',
|
||||||
title: 'وضعیت محصول',
|
type: 'Number',
|
||||||
dataIndex: 'active',
|
customRender: ({ record }) =>
|
||||||
key: 'active',
|
formatAdminCashFeeLabel(record.cash_fee_sell, record.cash_fee_sell_is_percent)
|
||||||
type: 'Boolean',
|
},
|
||||||
customRender: (record) => (
|
...(isStoreApp() ? [inventoryColumn] : []),
|
||||||
<div class="flex justify-center">
|
{
|
||||||
<CustomTag
|
title: 'وضعیت محصول',
|
||||||
class="px-3 font-bold py-1"
|
dataIndex: 'active',
|
||||||
textColor={record?.record.active ? '#65a30d' : '#dc2626'}
|
key: 'active',
|
||||||
bgColor={record?.record.active ? '#ecfccb' : '#fee2e2'}
|
type: 'Boolean',
|
||||||
>
|
customRender: (record) => (
|
||||||
{record?.record.active ? 'باز' : 'بسته'}
|
<div class="flex justify-center">
|
||||||
</CustomTag>
|
<CustomTag
|
||||||
</div>
|
class="px-3 font-bold py-1"
|
||||||
)
|
textColor={record?.record.active ? '#65a30d' : '#dc2626'}
|
||||||
},
|
bgColor={record?.record.active ? '#ecfccb' : '#fee2e2'}
|
||||||
{
|
>
|
||||||
title: 'عملیات',
|
{record?.record.active ? 'باز' : 'بسته'}
|
||||||
dataIndex: 'action',
|
</CustomTag>
|
||||||
key: 'action',
|
</div>
|
||||||
slot: 'action',
|
)
|
||||||
filterable: false
|
},
|
||||||
}
|
{
|
||||||
|
title: 'عملیات',
|
||||||
|
dataIndex: 'action',
|
||||||
|
key: 'action',
|
||||||
|
slot: 'action',
|
||||||
|
filterable: false
|
||||||
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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, '.')
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user