Commit ba7cfd53 by YuleiLan

feat: 新增子表单功能。

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