Commit ba7cfd53 by YuleiLan

feat: 新增子表单功能。

parent f28e9536
......@@ -58,8 +58,10 @@
:data="models[item.model]"
border
style="width: 100%"
:header-cell-style="{padding: '5px 0'}"
>
<el-table-column
v-if="!preview"
fixed
width="50"
>
......@@ -92,7 +94,6 @@
:is-label="false"
:subform-index="scope.$index"
:subform-model="item.model"
@input-change="onSubformInputChange"
/>
</template>
</el-table-column>
......@@ -224,12 +225,8 @@ export default {
reset() {
this.$refs.generateForm.resetFields()
},
onSubformInputChange(value, field, index) {
console.log(value, field, index)
// this.$emit('on-change', field, value, this.models)
},
onInputChange(value, field) {
this.$emit('on-change', field, value, this.models)
// this.$emit('on-change', field, value, this.models)
},
refresh() {
......
......@@ -3,6 +3,7 @@
:label-width="isLabel===false||!widget.options.labelWidthStatus?'0px': widgetLabelWidth + 'px'"
:label="isLabel===false||widget.type==='divider' || !widget.options.labelWidthStatus?'':widget.name"
:prop="widget.model"
:style="subformIndex !== undefined?{'margin-bottom': '0'}: {}"
>
<template v-if="preview">
<template v-if="widget.type === 'color'">
......@@ -327,7 +328,7 @@ export default {
data() {
return {
widgetLabelWidth: '',
dataModel: this.models[this.widget.model],
dataModel: this.subformIndex===undefined?this.models[this.widget.model]:this.models[this.subformModel][this.subformIndex][this.widget.model],
tableData: []
}
},
......@@ -335,27 +336,33 @@ export default {
dataModel: {
deep: true,
handler(val) {
if (this.subformIndex !== undefined) {
this.models[this.subformModel][this.subformIndex][this.widget.model] = val
this.$emit('update:models', {
...this.models[this.subformModel][this.subformIndex],
[this.widget.model]: val
})
this.$emit('input-change', val, this.widget.model, this.subformIndex)
} else {
this.models[this.widget.model] = val
this.$emit('update:models', {
...this.models,
[this.widget.model]: val
})
this.$emit('input-change', val, this.widget.model)
if (val !== undefined) {
if (this.subformIndex !== undefined) {
this.models[this.subformModel][this.subformIndex][this.widget.model] = val
this.$emit('update:models', {
...this.models,
[this.subformModel]: this.models[this.subformModel]
})
this.$emit('input-change', val, this.widget.model, this.subformIndex)
} else {
this.models[this.widget.model] = val
this.$emit('update:models', {
...this.models,
[this.widget.model]: val
})
this.$emit('input-change', val, this.widget.model)
}
}
}
},
models: {
deep: true,
handler(val) {
this.dataModel = val[this.widget.model]
if (this.subformIndex === undefined) {
this.dataModel = val[this.widget.model]
} else {
this.dataModel = val[this.subformModel][this.subformIndex][this.widget.model]
}
}
}
},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment