mirror of
https://github.com/vform666/variant-form3-vite.git
synced 2025-01-11 00:29:13 +08:00
fix: 日期组件:已选中默认值,显示类型在由 dates 切换 到其他类型,或其他类型切换到 dates 时 的报错导致整个设计器无响应
This commit is contained in:
parent
5849f15766
commit
cf706a9e5b
@ -2,7 +2,7 @@
|
||||
<form-item-wrapper :designer="designer" :field="field" :rules="rules" :design-state="designState"
|
||||
:parent-widget="parentWidget" :parent-list="parentList" :index-of-parent-list="indexOfParentList"
|
||||
:sub-form-row-index="subFormRowIndex" :sub-form-col-index="subFormColIndex" :sub-form-row-id="subFormRowId">
|
||||
<el-date-picker ref="fieldEditor" :type="field.options.type" v-model="fieldModel"
|
||||
<el-date-picker ref="fieldEditor" :key="field.options.type" :type="field.options.type" v-model="fieldModel"
|
||||
:class="[!!field.options.autoFullWidth ? 'auto-full-width' : '']"
|
||||
:readonly="field.options.readonly" :disabled="field.options.disabled"
|
||||
:size="widgetSize"
|
||||
@ -63,6 +63,19 @@
|
||||
},
|
||||
computed: {
|
||||
|
||||
},
|
||||
watch: {
|
||||
'field.options.type': {
|
||||
deep: true,
|
||||
handler(val, oldVal){
|
||||
if (val === 'dates' && oldVal !== 'dates'){
|
||||
this.fieldModel = [this.fieldModel]
|
||||
}
|
||||
if (val !== 'dates' && oldVal === 'dates'){
|
||||
this.fieldModel = this.fieldModel[0]
|
||||
}
|
||||
},
|
||||
}
|
||||
},
|
||||
beforeCreate() {
|
||||
/* 这里不能访问方法和属性!! */
|
||||
|
@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<el-form-item :label="i18nt('designer.setting.defaultValue')">
|
||||
<el-date-picker :type="optionModel.type" v-model="optionModel.defaultValue" @change="emitDefaultValueChange"
|
||||
<el-date-picker :key="optionModel.type" :type="optionModel.type" v-model="optionModel.defaultValue" @change="emitDefaultValueChange"
|
||||
:format="optionModel.format" :value-format="optionModel.valueFormat" style="width: 100%">
|
||||
</el-date-picker>
|
||||
</el-form-item>
|
||||
@ -18,6 +18,19 @@
|
||||
selectedWidget: Object,
|
||||
optionModel: Object,
|
||||
},
|
||||
watch: {
|
||||
'optionModel.type': {
|
||||
deep: true,
|
||||
handler(val, oldVal){
|
||||
if (val === 'dates' && oldVal !== 'dates'){
|
||||
this.optionModel.defaultValue = [this.optionModel.defaultValue]
|
||||
}
|
||||
if (val !== 'dates' && oldVal === 'dates'){
|
||||
this.optionModel.defaultValue = this.optionModel.defaultValue[0]
|
||||
}
|
||||
},
|
||||
}
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user