|
|
@@ -1487,8 +1487,9 @@
|
|
|
});
|
|
|
},
|
|
|
//选择产品回调
|
|
|
- changeParent(obj = [], idx) {
|
|
|
- obj.forEach(async (item, index) => {
|
|
|
+ async changeParent(obj = [], idx) {
|
|
|
+ console.log('选择产品回调', obj);
|
|
|
+ const promises = obj.map(async (item, index) => {
|
|
|
let i = idx == -1 ? index : idx;
|
|
|
let row = JSON.parse(JSON.stringify(this.defaultForm));
|
|
|
row.key = this.form.datasource.length + 1;
|
|
|
@@ -1556,6 +1557,14 @@
|
|
|
this.form.datasource.push(row);
|
|
|
}
|
|
|
});
|
|
|
+
|
|
|
+ // 等待所有异步操作完成
|
|
|
+ await Promise.all(promises);
|
|
|
+
|
|
|
+ // 只有当idx == -1时才emit数据给父组件
|
|
|
+ if (idx == -1) {
|
|
|
+ this.$emit('getProductData', this.form.datasource);
|
|
|
+ }
|
|
|
},
|
|
|
remove(row, index) {
|
|
|
this.form.datasource.splice(index, 1);
|