fix some bugs
This commit is contained in:
@@ -76,11 +76,10 @@
|
||||
|
||||
<a-time-picker
|
||||
v-else-if="fieldType === 'time'"
|
||||
:value="modelValue || undefined"
|
||||
:value="timePickerValue"
|
||||
:disabled="disabled"
|
||||
class="w-full"
|
||||
format="HH:mm"
|
||||
value-format="HH:mm:ss"
|
||||
:minute-step="5"
|
||||
placeholder="انتخاب ساعت"
|
||||
@update:value="onTimeChange"
|
||||
@@ -137,6 +136,7 @@ import TemplateTextField from './TemplateTextField.vue'
|
||||
import ZaarboxPriceKeyField from './ZaarboxPriceKeyField.vue'
|
||||
import { hasTemplateField } from './templateFields'
|
||||
import {
|
||||
normalizeTimeValue,
|
||||
parseSelectOptions,
|
||||
resolveSettingFieldType,
|
||||
resolveSwitchChecked,
|
||||
@@ -144,6 +144,10 @@ import {
|
||||
switchValueFromChecked,
|
||||
type SettingFieldType
|
||||
} from './settingTypes'
|
||||
import dayjs, { type Dayjs } from 'dayjs'
|
||||
import customParseFormat from 'dayjs/plugin/customParseFormat'
|
||||
|
||||
dayjs.extend(customParseFormat)
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
@@ -207,9 +211,25 @@ function onMultiSelectChange(val: string[] | undefined) {
|
||||
emit('update:value', list.join(','))
|
||||
}
|
||||
|
||||
function onTimeChange(val: string | string[] | undefined) {
|
||||
const v = Array.isArray(val) ? val[0] : val
|
||||
emit('update:value', v ?? '')
|
||||
function parseTimePickerValue(raw?: string | null): Dayjs | undefined {
|
||||
const normalized = normalizeTimeValue(raw)
|
||||
if (!normalized) return undefined
|
||||
|
||||
const parsed = dayjs(normalized, 'HH:mm:ss', true)
|
||||
return parsed.isValid() ? parsed : undefined
|
||||
}
|
||||
|
||||
const timePickerValue = computed(() => parseTimePickerValue(props.modelValue))
|
||||
|
||||
function onTimeChange(val: Dayjs | string | null | undefined) {
|
||||
if (val == null || val === '') {
|
||||
emit('update:value', '')
|
||||
emit('blur')
|
||||
return
|
||||
}
|
||||
|
||||
const parsed = dayjs.isDayjs(val) ? val : dayjs(String(val), 'HH:mm:ss', true)
|
||||
emit('update:value', parsed.isValid() ? normalizeTimeValue(parsed.format('HH:mm:ss')) : '')
|
||||
emit('blur')
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user