🐛(component): 修复datePicker构建之后time选择器错误

This commit is contained in:
0o张不歪o0 2022-07-22 09:28:38 +08:00
parent a037f53eb7
commit 7a9d948c12
2 changed files with 15 additions and 10 deletions

View File

@ -23,7 +23,7 @@
:key="it"
:class="[
'num',
index.toString().padStart(2, '0') == (hms as hmsType)[item.type]
index == hms[item.type]
? 'layui-this'
: '',
]"
@ -64,6 +64,7 @@ export interface hmsType {
hh: number;
mm: number;
ss: number;
[key: string]: any;
}
export interface TimePanelProps {
modelValue: hmsType;
@ -77,7 +78,11 @@ const els = [
{ count: 60, type: "mm" },
{ count: 60, type: "ss" },
];
const hms = ref<{ hh: number; mm: number; ss: number }>(props.modelValue);
const hms = ref<hmsType>({
hh:props.modelValue.hh,
mm: props.modelValue.mm,
ss: props.modelValue.ss,
});
// - hms
const chooseTime = (e: any) => {
@ -94,9 +99,13 @@ onMounted(() => {
watch(
() => props.modelValue,
() => {
hms.value = props.modelValue;
hms.value = {
hh:props.modelValue.hh,
mm: props.modelValue.mm,
ss: props.modelValue.ss
};
},
{ deep: true }
{ deep: true}
);
const scrollTo = () => {
nextTick(() => {
@ -125,7 +134,7 @@ const scrollTo = () => {
//
const footOnOk = () => {
emits("update:modelValue", hms);
emits("update:modelValue", hms.value);
if (datePicker.range) {
//
emits("ok");

View File

@ -260,11 +260,7 @@ const getDateValueByRange = () => {
//
const ok = () => {
if (!props.range) {
if (props.type === "time") {
getDateValue();
} else {
getDateValue();
}
getDateValue();
} else {
getDateValueByRange();
}