form表单 下拉选择优化
This commit is contained in:
@@ -134,7 +134,18 @@ export default {
|
|||||||
data() {
|
data() {
|
||||||
if (this.isEdit) { // 初始化待编辑数据
|
if (this.isEdit) { // 初始化待编辑数据
|
||||||
this.formConf.fields.forEach(conf => {
|
this.formConf.fields.forEach(conf => {
|
||||||
conf.__config__.defaultValue = this.formEditData[conf.__vModel__]
|
// 设置现有的数据
|
||||||
|
const hasValueForEdit = this.formEditData[conf.__vModel__]
|
||||||
|
if(hasValueForEdit){
|
||||||
|
conf.__config__.defaultValue = hasValueForEdit
|
||||||
|
}
|
||||||
|
// 如果是el-select标签 判断数据后改变实现默认选中效果
|
||||||
|
if(conf.__config__.tag === 'el-select' || conf.__config__.tag === 'el-radio-group'){
|
||||||
|
const perValue = conf.__slot__.options.filter(option => option.value == this.formEditData[conf.__vModel__])
|
||||||
|
if(perValue.length > 0){ // 有表单数据
|
||||||
|
conf.__config__.defaultValue = perValue[0].value
|
||||||
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
const data = {
|
const data = {
|
||||||
|
|||||||
@@ -102,7 +102,7 @@
|
|||||||
|
|
||||||
<!--编辑-->
|
<!--编辑-->
|
||||||
<el-dialog
|
<el-dialog
|
||||||
title="编辑订单"
|
:title="isCreate===0 ? '添加模板' : '编辑模板'"
|
||||||
:visible.sync="dialogVisible"
|
:visible.sync="dialogVisible"
|
||||||
width="500px"
|
width="500px"
|
||||||
:before-close="handleClose">
|
:before-close="handleClose">
|
||||||
|
|||||||
Reference in New Issue
Block a user