|
|
@@ -176,14 +176,16 @@ export default {
|
|
|
forms: [],
|
|
|
multipleSelection: [],
|
|
|
baoliuxiaoshu:true,
|
|
|
- config: 1
|
|
|
+ config: 1,
|
|
|
+ isUpdatingFromParent: false // 标记是否来自父组件的更新
|
|
|
}
|
|
|
},
|
|
|
computed: {},
|
|
|
watch: {
|
|
|
formData: {
|
|
|
+ /*
|
|
|
handler(val) {
|
|
|
- // console.log('formData', val)
|
|
|
+ console.log('formData', val)
|
|
|
if (val.lieBiaoShuJu) {
|
|
|
if (!this.isCul) {
|
|
|
this.forms = this.initData(val.lieBiaoShuJu)
|
|
|
@@ -196,15 +198,43 @@ export default {
|
|
|
}
|
|
|
this.culXiuZheng()
|
|
|
},
|
|
|
+ */
|
|
|
+
|
|
|
+ handler(val) {
|
|
|
+ if (val.lieBiaoShuJu) {
|
|
|
+ // 标记开始内部更新,避免无限循环调用initData导致卡死(控制forms里的this.$emit的循环调用)
|
|
|
+ this.isUpdatingFromParent = true
|
|
|
+ //现在每一次watch到数据变化,都会执行initData方法
|
|
|
+ if (!this.isCul) {
|
|
|
+ this.forms = this.initData(val.lieBiaoShuJu)
|
|
|
+ } else {
|
|
|
+ this.forms = this.initData(val.lieBiaoShuJu)
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ this.culXiuZheng()
|
|
|
+ },
|
|
|
+
|
|
|
deep: true,
|
|
|
immediate: true
|
|
|
},
|
|
|
forms: {
|
|
|
+ /*
|
|
|
handler(val) {
|
|
|
// console.log('forms', val)
|
|
|
this.culXiuZheng()
|
|
|
this.$emit('change-data', 'lieBiaoShuJu', JSON.stringify(val))
|
|
|
},
|
|
|
+ */
|
|
|
+ handler(val) {
|
|
|
+ this.culXiuZheng()
|
|
|
+ //只有非内部更新时才向父组件发送数据(避免无限循环的调用导致卡死,由formData里的方法对该变量控制)
|
|
|
+ if (!this.isUpdatingFromParent) {
|
|
|
+ this.$emit('change-data', 'lieBiaoShuJu', JSON.stringify(val))
|
|
|
+ } else {
|
|
|
+ this.isUpdatingFromParent = false // 重置标记
|
|
|
+ }
|
|
|
+ },
|
|
|
deep: true
|
|
|
}
|
|
|
},
|