From 87f7f7a7588e926c6535eea2910ae98ca4101994 Mon Sep 17 00:00:00 2001
From: haoxuan <haoxuan>
Date: 星期二, 29 八月 2023 18:52:49 +0800
Subject: [PATCH] 采购 添加 列表编辑 子段补充,联调

---
 src/views/purchaseManage/purchase/components/AddPurchase.vue |  143 ++++++++++++++++++++++++++++++++++-------------
 1 files changed, 102 insertions(+), 41 deletions(-)

diff --git a/src/views/purchaseManage/purchase/components/AddPurchase.vue b/src/views/purchaseManage/purchase/components/AddPurchase.vue
index 8211eb2..7205625 100644
--- a/src/views/purchaseManage/purchase/components/AddPurchase.vue
+++ b/src/views/purchaseManage/purchase/components/AddPurchase.vue
@@ -37,9 +37,9 @@
                   >
                     <el-option
                       v-for="ele in plcBrandList"
-                      :key="ele.id"
+                      :key="ele.name"
                       :label="ele.name"
-                      :value="ele.name"
+                      :value="ele.ID"
                     ></el-option>
                   </el-select>
                   <i
@@ -85,9 +85,9 @@
                 </el-form-item>
               </el-col>
               <el-col :span="12">
-                <el-form-item label="鍗曟嵁鏉ユ簮" prop="number">
+                <el-form-item label="鍗曟嵁鏉ユ簮" prop="orderSource">
                   <el-input
-                    v-model="editConfig.infomation.number"
+                    v-model="editConfig.infomation.orderSource"
                     disabled
                     placeholder="璇峰~鍐�"
                   ></el-input>
@@ -177,7 +177,7 @@
               <div class="table-bottom-l">
                 <el-form-item label="鏁村崟鎶樻墸" prop="member_id">
                   <el-select
-                    v-model="editConfig.infomation.fieldName"
+                    v-model="editConfig.infomation.wholeDiscountType"
                     placeholder="璇烽�夋嫨"
                     filterable
                   >
@@ -189,7 +189,7 @@
               <div class="table-bottom-r">
                 <el-form-item label="" prop="member_id">
                   <el-input
-                    v-model="editConfig.infomation.number"
+                    v-model="editConfig.infomation.wholeDiscount"
                     size="mini"
                     placeholder="璇峰~鍐�"
                   ></el-input>
@@ -200,7 +200,7 @@
               <div class="table-bottom-l">
                 <el-form-item label="璋冩暣" prop="member_id">
                   <el-select
-                    v-model="editConfig.infomation.fieldName"
+                    v-model="editConfig.infomation.priceAdjustmentType"
                     placeholder="璇烽�夋嫨"
                     filterable
                   >
@@ -212,7 +212,7 @@
               <div class="table-bottom-r">
                 <el-form-item label="" prop="member_id">
                   <el-input
-                    v-model="editConfig.infomation.number"
+                    v-model="editConfig.infomation.priceAdjustment"
                     size="mini"
                     placeholder="璇峰~鍐�"
                   ></el-input>
@@ -221,7 +221,7 @@
             </div>
             <div class="table-bottom-item">
               <div class="table-bottom-l">鍚堣</div>
-              <div class="table-bottom-r">26000.00</div>
+              <div class="table-bottom-r">{{ editConfig.infomation.realTotalPrice }}</div>
             </div>
           </div>
         </div>
@@ -246,6 +246,7 @@
       ref="editDialog"
       @sucessSet="handleGetBomKindDictList"
       @handleConfirmSave="handleConfirmSave"
+      :editRow="editRow"
       :workList="plcBrandList"
       title="閲囪喘绫诲瀷"
     ></BomDialog>
@@ -259,11 +260,10 @@
 import {
   addPurchase,
   updatePurchase,
+  savePurchaseType,
+  getPurchaseType,
 } from "@/api/purchaseManage/purchase";
-// import {
-//   postGetUnitDictList,
-//   postGetSaveSUnitDict,
-// } from "@/api/purchaseManage/purchase";
+
 import SelectSupplierDialog from "@/views/purchaseManage/purchase/components/SelectSupplierDialog";
 export default {
   name: "QuotationDialog",
@@ -284,6 +284,7 @@
     return {
       editConfig: this.editCommonConfig,
       rules: {
+        purchaseTypeId:[{ required: true, message: "璇烽�夋嫨", trigger: "change" }],
         supplierName: [{ required: true, message: "璇烽�夋嫨", trigger: "change" }],
         phone: [
           {
@@ -292,6 +293,22 @@
             trigger: "change",
           },
           { validator: this.validatorPhone, trigger: "change" },
+        ],
+        wholeDiscount: [
+          {
+            required: false,
+            message: "璇峰~鍐�",
+            trigger: "change",
+          },
+          { validator: this.validatorNum, trigger: "change" },
+        ],
+        priceAdjustment: [
+          {
+            required: false,
+            message: "璇峰~鍐�",
+            trigger: "change",
+          },
+          { validator: this.validatorNumThree, trigger: "change" },
         ],
       },
       productTableList: {},
@@ -321,6 +338,9 @@
       isNoProduct: true,
       clientList: [],
       plcBrandList:[],
+      editRow:{
+        isDefault:'pin'
+      }
     };
   },
   created() {
@@ -332,46 +352,80 @@
     'editCommonConfig.visible':{
       immediate:true,
       handler:function(){
+        
         this.setTableForm();
       }
     }
   },
   methods: {
+    validatorNum(rule, value, callback) {
+      if (value) {
+        if (value == undefined || value == null) {
+          callback(new Error("璇疯緭鍏ユ湁鏁堟暟瀛�"));
+        } else {
+          var reg = /^\+?[0-9]\d*$/;
+          if (!reg.test(value)) {
+            callback(new Error("璇峰~鍐欎笉灏忎簬0鐨勬暟瀛�"));
+          } else {
+            callback();
+          }
+        }
+      } else {
+        callback();
+      }
+    },
+    validatorNumThree(rule, value, callback){
+      if(value){
+        if(value==undefined||value==null){
+          callback(new Error("璇疯緭鍏ユ湁鏁堟暟瀛�"));
+        }else{
+          let reg2=/(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/
+          if(!reg2.test(value)){
+            callback(new Error('璇峰~鍐�2浣嶅皬鏁扮殑鏁板瓧'))
+          }else{
+            callback()
+          }
+        }
+      }else{
+        callback()
+      } 
+    },
     // PLC閰嶇疆璁剧疆
     handleShow() {
-      // this.handleGetBomKindDictList();
+      this.handleGetBomKindDictList();
       this.$refs.editDialog.editDialogVisible = true;
     },
     //  PLC閰嶇疆
     handleGetBomKindDictList(val) {
       console.log(val,'val')
-      // postGetUnitDictList().then((res) => {
-      //   this.plcBrandList = res.data;
-      //   if (val) {
-      //     for (let i in this.plcBrandList) {
-      //       if (this.plcBrandList[i].isDefault) {
-      //         this.form.unit = this.form.unit
-      //           ? this.form.unit
-      //           : this.plcBrandList[i].name;
-      //         this.$set(this.form, "unit", this.form.unit);
-      //         break;
-      //       }
-      //     }
-      //   }
-      // });
+      getPurchaseType().then((res) => {
+        this.plcBrandList = res.data;
+        if (val) {
+          for (let i in this.plcBrandList) {
+            if (this.plcBrandList[i][this.editRow.isDefault]) {
+              this.editConfig.infomation.purchaseTypeId = this.editConfig.infomation.purchaseTypeId
+                ? this.editConfig.infomation.purchaseTypeId
+                : this.plcBrandList[i].ID;
+              this.$set(this.editConfig.infomation, "purchaseTypeId", this.editConfig.infomation.purchaseTypeId);
+             
+              break;
+            }
+          }
+        }
+      });
     },
     handleConfirmSave(data) {
       console.log(data,'data')
-      // postGetSaveSUnitDict({ data: data }).then((res) => {
-      //   if (res.code == 200) {
-      //     this.$message({
-      //       message: "鎿嶄綔鎴愬姛锛�",
-      //       type: "success",
-      //     });
-      //     this.$refs.editDialog.editDialogVisible = false;
-      //     this.handleGetBomKindDictList();
-      //   }
-      // });
+      savePurchaseType(data).then((res) => {
+        if (res.code == 200) {
+          this.$message({
+            message: "鎿嶄綔鎴愬姛锛�",
+            type: "success",
+          });
+          this.$refs.editDialog.editDialogVisible = false;
+          this.handleGetBomKindDictList(true);
+        }
+      });
     },
     validatorPhone(rule, value, callback) {
       if (value) {
@@ -437,7 +491,6 @@
       });
     },
     saveParams() {
-      debugger
       let data =JSON.parse(JSON.stringify(this.editConfig.infomation));
       let params = {
         productList:this.tableData,
@@ -445,11 +498,17 @@
           supplierId:this.supplierId||0,
           signingDate:data.signingDate||'',
           remark:data.remark,
-          purchaseTypeId:this.purchaseTypeId||0,
+          orderSource:data.orderSource||'',
+          purchaseTypeId:data.purchaseTypeId||0,
           phone:data.phone||'',
           name:data.name||'',
           deliveryDate:data.deliveryDate||'',
-          contact:data.contact
+          contact:data.contact,
+          wholeDiscountType:data.wholeDiscountType,
+          wholeDiscount:Number(data.wholeDiscount),
+          priceAdjustmentType:data.priceAdjustmentType,
+          priceAdjustment:Number(data.priceAdjustment),
+          realTotalPrice:data.realTotalPrice||'',
         }
       };
       if(data.ID){
@@ -530,6 +589,7 @@
           {
             label: "浜у搧鍚嶇О",
             prop: "name",
+            min: 170,
             productName: true,
             isRequird: true,
           },
@@ -547,6 +607,7 @@
           { label: "鎻忚堪", prop: "remark", input: true },
         ],
       };
+      this.handleGetBomKindDictList(true);
     },
     // 浜у搧鍒楄〃杈撳叆
     inputContent(val, prop, row) {

--
Gitblit v1.8.0