فهرست منبع

采购订单复制功能

002390 2 سال پیش
والد
کامیت
983660def1
2فایلهای تغییر یافته به همراه50 افزوده شده و 34 حذف شده
  1. 46 31
      src/views/purchase/purchase-order/add/index.vue
  2. 4 3
      src/views/purchase/purchase-order/index.vue

+ 46 - 31
src/views/purchase/purchase-order/add/index.vue

@@ -57,7 +57,6 @@ export default {
     "params": {
       handler(nVal, oVal) {
 
-
         // 组织变化
         if (nVal.puOrg != oVal.puOrg) {
           console.log(nVal.puOrg, 'nVal.puOrg', oVal.puOrg, 'oVal.puOrg');
@@ -96,9 +95,12 @@ export default {
     },
     // 复制赋值
     async setCopyParams(id) {
+      console.log(id, 'iid-----------------------');
       try {
         const { code, msg, data } = await orderApi.details(id);
+
         if (code === 200) {
+
           this.params = {
             ...data,
             id: '',
@@ -106,6 +108,19 @@ export default {
             status: '0',
             source: '3',
           };
+
+          for (const key in this.params) {
+
+            if (Array.isArray(this.params[key])) {
+
+              this.params[key].forEach(v => {
+
+                v.id = '';
+
+              })
+            }
+          }
+
         }
       } catch (err) {
         //
@@ -204,36 +219,36 @@ export default {
     },
     // 保存并新增
     async handleSubmit() {
-      // this.$refs["orderAddForm"].validate(async (valid) => {
-      //   if (valid) {
-      try {
-        const createById = this.params.buyer;
-        const createByName = this.params.buyerName;
-        const updateById = this.$store.state.user.id;
-        const updateByName = this.$store.state.user.name;
-        const { code, msg } = await orderApi.create({
-          createById,
-          createByName,
-          updateById,
-          updateByName,
-          ...this.params,
-        });
-        if (code === 200) {
-          this.$notify.success({ title: msg });
-          this.setVisible(false);
+      this.$refs["orderAddForm"].validate(async (valid) => {
+        if (valid) {
+          try {
+            const createById = this.params.buyer;
+            const createByName = this.params.buyerName;
+            const updateById = this.$store.state.user.id;
+            const updateByName = this.$store.state.user.name;
+            const { code, msg } = await orderApi.create({
+              createById,
+              createByName,
+              updateById,
+              updateByName,
+              ...this.params,
+            });
+            if (code === 200) {
+              this.$notify.success({ title: msg });
+              this.setVisible(false);
+            } else {
+              this.$notify.warning({ title: msg });
+            }
+          } catch (err) {
+            this.$notify.error({ title: "error", message: err });
+          } finally {
+            // this.setVisible(false);
+          }
         } else {
-          this.$notify.warning({ title: msg });
+          console.log("error submit!!");
+          return false;
         }
-      } catch (err) {
-        this.$notify.error({ title: "error", message: err });
-      } finally {
-        // this.setVisible(false);
-      }
-      //   } else {
-      //     console.log("error submit!!");
-      //     return false;
-      //   }
-      // });
+      });
     },
     // 子表参照改变之后
     handleReferChange(val, source, type) {
@@ -297,9 +312,9 @@ export default {
           <div style="text-align: right">
             <el-button size="mini" @click="handleCancel">取消</el-button>
             <el-button size="mini" type="danger" @click="handleSava">保存</el-button>
-            <el-button size="mini" type="info" @click="handleSubmit">
+            <!-- <el-button size="mini" type="info" @click="handleSubmit">
               保存并新增
-            </el-button>
+            </el-button> -->
           </div>
         </div>
         <el-row style="display:flex; flex-wrap: wrap;">

+ 4 - 3
src/views/purchase/purchase-order/index.vue

@@ -115,10 +115,11 @@ export default {
     },
     handleTabClick() { },
     // 新增
-    handleOpenAddDrawer(copyId) {
+    handleOpenAddDrawer(copyVal) {
       const { setVisible, setCopyParams } = this.$refs.addDrawerFef;
       setVisible(true);
-      copyId && setCopyParams(copyId);
+
+      copyVal.id && copyVal.id != '' && setCopyParams(copyVal.id);
     },
     // 复制
     handleCopy() {
@@ -130,7 +131,7 @@ export default {
       //   status: '0',
       //   source: '3',
       // };
-      this.handleOpenAddDrawer(this.checkedList[0].id);
+      this.handleOpenAddDrawer(this.checkedList[0]);
     },
     // 查看
     async handleOpenSeeDrawer(row) {