Merge 0176ea21af26e48d5621e979646d908e47a3981b into c67479e496bab56a93a3dff168a4f529d8293c67

This commit is contained in:
TTTTian 2024-12-03 22:56:12 +08:00 committed by GitHub
commit 676019066a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 28 additions and 2 deletions

View File

@ -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 ? this.fieldModel[0] : null
}
},
}
},
beforeCreate() {
/* 这里不能访问方法和属性!! */

View File

@ -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 ? this.optionModel.defaultValue[0] : null
}
},
}
},
}
</script>