Browse Source

解决复制值不回显问题

002390 2 years ago
parent
commit
4bd8e24040

+ 76 - 34
src/views/purchase/purchase-order/add/index.vue

@@ -40,6 +40,7 @@ export default {
       },
       tabColumns: NewTabColumns,
       tabName: "puOrderItemList",
+      isCopy:false,
     };
   },
   computed: {},
@@ -64,46 +65,56 @@ export default {
       },
       deep: true,
     },
-    params: {
-      handler(nVal, oVal) {
-        // 组织变化
-        if (this.visible && nVal.puOrg != oVal.puOrg) {
-          for (const key in this.params) {
-            if (Array.isArray(this.params[key])) {
-              this.params[key] = [];
-            } else if (
-              key != "puOrg" &&
-              key != "puOrgName" &&
-              key != "buyer" &&
-              key != "buyerName" &&
-              key != "puDept" &&
-              key != "puDeptName" &&
-              key != "status"
-            ) {
-              this.params[key] = "";
-            } else {
-            }
-          }
-        }
-      },
-      deep: true,
-    },
+    // "params.puOrg": {
+    //   handler(nVal, oVal) {
+    //     console.log('nVal', nVal, 'oVal',oVal);
+    //     console.log(this.isCopy, 'this.isCopy');
+    //     // 组织变化
+    //     // if (this.visible && nVal.puOrg != oVal.puOrg) {
+    //     if (this.visible && oVal && nVal != oVal) {
+    //       for (const key in this.params) {
+    //         if (Array.isArray(this.params[key])) {
+    //           this.params[key] = [];
+    //         } else if (
+    //           key != "puOrg" &&
+    //           key != "puOrgName" &&
+    //           key != "buyer" &&
+    //           key != "buyerName" &&
+    //           key != "puDept" &&
+    //           key != "puDeptName" &&
+    //           key != "status"
+    //         ) {
+    //           this.params[key] = "";
+    //         } else {
+    //         }
+    //       }
+    //     }
+    //   },
+    //   deep: true,
+    // },
   },
   methods: {
     beforeOpen() {
-      const { deptName, deptId, name, nickName, orgName, orgId } = this.$store.state.user;
-      this.params.puOrg = orgId;
-      this.params.puOrgName = orgName;
-      this.params.buyer = name;
-      this.params.buyerName = nickName;
-      this.params.puDept = deptId;
-      this.params.puDeptName = deptName;
-      this.params.billDate = new Date().Format('yyyy-MM-dd');
-      this.addTableRow();
+
+      if(!this.isCopy){
+
+        const { deptName, deptId, name, nickName, orgName, orgId } = this.$store.state.user;
+        this.params.puOrg = orgId;
+        this.params.puOrgName = orgName;
+        this.params.buyer = name;
+        this.params.buyerName = nickName;
+        this.params.puDept = deptId;
+        this.params.puDeptName = deptName;
+        this.params.billDate = new Date().Format('yyyy-MM-dd');
+        console.log(this.params,'this.params');
+        this.addTableRow();
+      }
     },
-    setVisible(prop) {
+    setVisible(prop,iscopy) {
       this.visible = prop;
 
+      this.isCopy = iscopy;
+
       if(!this.visible){
         this.$refs['orderAddForm'].clearValidate();
       }
@@ -372,6 +383,37 @@ export default {
         })
         
       }
+
+      // 组织
+      if(type === 'ORG_PARAM'){
+
+          for (const key in this.params) {
+
+            // if (Array.isArray(this.params[key])) {
+            if (key === 'puOrderItemList' || key === 'puOrderExecuteList') {
+
+              this.params[key] = [];
+
+            }
+            else if(key === 'sysFileRecordList'){
+              this.params[key] = [];
+            }
+             else if (
+              key != "puOrg" &&
+              key != "puOrgName" &&
+              key != "buyer" &&
+              key != "buyerName" &&
+              key != "puDept" &&
+              key != "puDeptName" &&
+              key != "status"
+            ) {
+              this.params[key] = "";
+            } else {
+            }
+          }
+        
+
+      }
     },
 
     // 下拉框选择改变

+ 1 - 1
src/views/purchase/purchase-order/index.vue

@@ -117,7 +117,7 @@ export default {
     // 新增
     handleOpenAddDrawer(copyVal) {
       const { setVisible, setCopyParams } = this.$refs.addDrawerFef;
-      setVisible(true);
+      setVisible(true,(copyVal.id && copyVal.id != '') ? true :false);
 
       copyVal.id && copyVal.id != '' && setCopyParams(copyVal.id);
     },