fix bugs
This commit is contained in:
@@ -10,13 +10,12 @@ 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 { computed, useAttrs } from 'vue'
|
||||||
import { persianToEnglishDigits } from '@/utils/persianDigits'
|
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
value?: string | Dayjs
|
value?: string | Dayjs
|
||||||
size?: string
|
size?: string
|
||||||
format?: string
|
format?: string
|
||||||
inputReadOnly?:boolean
|
inputReadOnly?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
const attrs = useAttrs()
|
const attrs = useAttrs()
|
||||||
@@ -41,7 +40,7 @@ const _date = computed({
|
|||||||
set: (val) => {
|
set: (val) => {
|
||||||
let temp: string | null = null
|
let temp: string | null = null
|
||||||
if (val) {
|
if (val) {
|
||||||
temp = persianToEnglishDigits(val.calendar('gregory').locale('en').format(props.format))
|
temp = val.calendar('gregory').locale('en').format(props.format)
|
||||||
}
|
}
|
||||||
emit('update:value', temp)
|
emit('update:value', temp)
|
||||||
emit('onchange', temp)
|
emit('onchange', temp)
|
||||||
|
|||||||
@@ -1,13 +0,0 @@
|
|||||||
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