From f4ed5ae8873f65c36b5cf37be264f6ec1e154647 Mon Sep 17 00:00:00 2001
From: zuozhengqing <a13193816592@163.com>
Date: 星期三, 20 三月 2024 19:36:58 +0800
Subject: [PATCH] 合并分支冲突解决

---
 src/views/purchaseManage/purchase/components/AddPurchase.vue |  798 +++++++++++++++++++++++++++++++++++++-------------------
 1 files changed, 524 insertions(+), 274 deletions(-)

diff --git a/src/views/purchaseManage/purchase/components/AddPurchase.vue b/src/views/purchaseManage/purchase/components/AddPurchase.vue
index 260540a..ed08a9b 100644
--- a/src/views/purchaseManage/purchase/components/AddPurchase.vue
+++ b/src/views/purchaseManage/purchase/components/AddPurchase.vue
@@ -24,13 +24,29 @@
           <div class="basic-info-view">
             <el-row>
               <el-col :span="12">
-                <el-form-item
-                  label="閲囪喘绫诲瀷"
-                  prop="purchaseTypeId"
-                  class="float_left"
-                  style="width:100%;"
-                >
+                <el-form-item label="閲囪喘鍗曞彿" prop="number">
+                  <!-- <el-input v-model="editConfig.infomation.number"></el-input> -->
+                  <el-input
+                    style="width: 85%"
+                    v-if="
+                      editConfig.title == '缂栬緫' ||
+                      editConfig.title == '鏌ョ湅' ||
+                      (editConfig.title == '鏂板缓' && codenumer && (explain != '' || isIdDisabled))
+                    "
+                    :disabled="editConfig.title != '鏂板缓'"
+                    v-model="editConfig.infomation.number"
+                    placeholder="璇疯緭鍏ョ紪鐮�"
+                  >
+                  </el-input>
+                  <span v-else-if="editConfig.title == '鏂板缓'" style="color: #f56c6c; width: 85%"
+                    >璇蜂紭鍏堥厤缃紪鐮佽鑼� <el-button type="text" @click="numberClick"> 閰嶇疆瑙勮寖 </el-button></span
+                  >
+                </el-form-item>
+              </el-col>
+              <el-col :span="12">
+                <el-form-item label="閲囪喘绫诲瀷" prop="purchaseTypeId" class="float_left" style="width: 100%">
                   <el-select
+                    :disabled="editConfig.isDisabled"
                     placeholder="璇烽�夋嫨閲囪喘绫诲瀷"
                     v-model="editConfig.infomation.purchaseTypeId"
                     clearable
@@ -38,12 +54,13 @@
                   >
                     <el-option
                       v-for="ele in plcBrandList"
-                      :key="ele.name"
+                      :key="ele.purchaseTypeId"
                       :label="ele.name"
-                      :value="ele.ID"
+                      :value="ele.id"
                     ></el-option>
                   </el-select>
                   <i
+                    v-if="!editConfig.isDisabled"
                     class="el-icon-setting margin_left_10px cursor_pointer"
                     style="font-size: 20px; color: #333"
                     @click="handleShow"
@@ -55,48 +72,40 @@
                 <el-form-item label="渚涘簲鍟嗗悕绉�" prop="supplierName">
                   <div class="custom-name">
                     <el-autocomplete
+                      :disabled="editConfig.isDisabled"
                       style="width: calc(100% - 40px)"
                       v-model="editConfig.infomation.supplierName"
                       :fetch-suggestions="
                         (queryString, callback) => {
-                          querySearchAsync(queryString, callback, 'client');
+                          querySearchAsync(queryString, callback, 'supplier')
                         }
                       "
                       value-key="name"
                       placeholder="璇烽�夋嫨"
                       @select="handleSelectClient('client', $event)"
                     ></el-autocomplete>
-                    <div
-                      class="common-select-btn"
-                      @click="selClientClick('client')"
-                    >
+                    <div v-if="!editConfig.isDisabled" class="common-select-btn" @click="selClientClick('client')">
                       <i class="el-icon-circle-plus-outline" title="閫夋嫨"></i>
                     </div>
                     <div
-                      v-if="
-                        editConfig.infomation.supplierName &&
-                        editConfig.infomation.supplierName.length > 0
-                      "
+                      v-if="editConfig.infomation.supplierName && editConfig.infomation.supplierName.length > 0"
                       class="common-select-btn"
                       @click="clearupClient('client')"
                     >
-                      <i class="el-icon-remove-outline" title="娓呴櫎"></i>
+                      <i class="el-icon-remove-outline" v-if="!editConfig.isDisabled" title="娓呴櫎"></i>
                     </div>
                   </div>
                 </el-form-item>
               </el-col>
-              <el-col :span="12">
+              <!-- <el-col :span="12">
                 <el-form-item label="鍗曟嵁鏉ユ簮" prop="orderSource">
-                  <el-input
-                    v-model="editConfig.infomation.orderSource"
-                    disabled
-                    placeholder="璇峰~鍐�"
-                  ></el-input>
+                  <el-input v-model="editConfig.infomation.orderSource" disabled placeholder="璇峰~鍐�"></el-input>
                 </el-form-item>
-              </el-col>
+              </el-col> -->
               <el-col :span="12">
                 <el-form-item label="閲囪喘鍗曞悕绉�" prop="name">
                   <el-input
+                    :disabled="editConfig.isDisabled"
                     v-model="editConfig.infomation.name"
                     placeholder="璇峰~鍐�"
                     clearable
@@ -106,6 +115,7 @@
               <el-col :span="12">
                 <el-form-item label="渚涘簲鍟嗚仈绯讳汉" prop="contact">
                   <el-input
+                    :disabled="editConfig.isDisabled"
                     v-model="editConfig.infomation.contact"
                     placeholder="璇峰~鍐�"
                     clearable
@@ -115,8 +125,11 @@
               <el-col :span="12">
                 <el-form-item label="鑱旂郴鐢佃瘽" prop="phone">
                   <el-input
+                    :disabled="editConfig.isDisabled"
                     v-model="editConfig.infomation.phone"
                     placeholder="璇峰~鍐�"
+                    maxlength="11"
+                    show-word-limit
                     clearable
                   ></el-input>
                 </el-form-item>
@@ -124,12 +137,14 @@
               <el-col :span="12">
                 <el-form-item label="绛剧害鏃ユ湡" prop="signingDate">
                   <el-date-picker
+                    :disabled="editConfig.isDisabled"
                     v-model="editConfig.infomation.signingDate"
                     style="width: 100%"
                     type="date"
                     clearable
                     placeholder="閫夋嫨鏃ユ湡"
                     value-format="yyyy-MM-dd"
+                    :picker-options="pickerOptionsBefore"
                   >
                   </el-date-picker>
                 </el-form-item>
@@ -137,19 +152,70 @@
               <el-col :span="12">
                 <el-form-item label="浜や粯鏃ユ湡" prop="deliveryDate">
                   <el-date-picker
+                    :disabled="editConfig.isDisabled"
                     v-model="editConfig.infomation.deliveryDate"
                     style="width: 100%"
                     type="date"
                     clearable
                     placeholder="閫夋嫨鏃ユ湡"
                     value-format="yyyy-MM-dd"
+                    :picker-options="pickerOptions"
                   >
                   </el-date-picker>
+                </el-form-item>
+              </el-col>
+              <el-col :span="12">
+                <el-form-item label="鏀惰揣浠撳簱" prop="warehouse">
+                  <el-select
+                    placeholder="璇烽�夋嫨鏀惰揣浠撳簱"
+                    v-model="editConfig.infomation.warehouse"
+                    clearable
+                    style="width: calc(100% - 0px)"
+                    :disabled="editConfig.isDisabled"
+                  >
+                    <el-option
+                      v-for="(ele, index) in receiveWhouseList"
+                      :key="index"
+                      :label="ele.name"
+                      :value="ele.name"
+                    ></el-option>
+                  </el-select>
+                </el-form-item>
+              </el-col>
+              <el-col :span="12">
+                <el-form-item label="鍦板潃" prop="warehouseAddress">
+                  <el-input
+                    :disabled="editConfig.isDisabled"
+                    v-model="editConfig.infomation.warehouseAddress"
+                    placeholder="璇峰~鍐�"
+                    clearable
+                  ></el-input>
+                </el-form-item>
+              </el-col>
+              <el-col :span="12">
+                <el-form-item label="鎺ユ敹浜�" prop="principal">
+                  <el-input
+                    :disabled="editConfig.isDisabled"
+                    v-model="editConfig.infomation.principal"
+                    placeholder="璇峰~鍐�"
+                    clearable
+                  ></el-input>
+                </el-form-item>
+              </el-col>
+              <el-col :span="12">
+                <el-form-item label="鏉ユ簮鍗曟嵁" prop="sourceOrder">
+                  <el-input
+                    :disabled="editConfig.isDisabled"
+                    v-model="editConfig.infomation.sourceOrder"
+                    placeholder="璇峰~鍐�"
+                    clearable
+                  ></el-input>
                 </el-form-item>
               </el-col>
               <el-col :span="24">
                 <el-form-item label="澶囨敞淇℃伅" prop="remark">
                   <el-input
+                    :disabled="editConfig.isDisabled"
                     type="textarea"
                     :autosize="{ minRows: 3, maxRows: 4 }"
                     maxlength="500"
@@ -164,15 +230,20 @@
           <div class="basic-info-title" style="display: flex">浜у搧淇℃伅</div>
           <div class="product-view">
             <CommonFormTableView
+              :detailEnter="editCommonConfig.detailEnter"
               :show-summary="showSummary"
               :recalculateShow="false"
+              :addTypeIdMultiple="true"
               :product-table-list="productTableList"
               sign="purchase"
               @inputContent="inputContent"
               @getSummaries="getSummaries"
               @addProductClick="addProductClick"
+              @getSelectArray="getSelectArray"
               @emptyProductClick="emptyProductClick"
               @clearupProduct="clearupProduct"
+              @rowClick="rowClick"
+              @handleProduct="handleProduct"
             />
           </div>
           <div class="table-bottom">
@@ -182,6 +253,7 @@
                   <el-select
                     v-model="editConfig.infomation.wholeDiscountType"
                     placeholder="璇烽�夋嫨"
+                    :disabled="editConfig.isDisabled"
                     filterable
                     @change="getTotal"
                   >
@@ -195,7 +267,7 @@
                   <el-input
                     v-model="editConfig.infomation.wholeDiscount"
                     size="mini"
-                    :disabled="editConfig.infomation.wholeDiscountType?false:true"
+                    :disabled="editConfig.isDisabled"
                     @change="getTotal"
                     placeholder="璇峰~鍐�"
                   ></el-input>
@@ -206,6 +278,7 @@
               <div class="table-bottom-l">
                 <el-form-item label="璋冩暣" prop="member_id">
                   <el-select
+                    :disabled="editConfig.isDisabled"
                     v-model="editConfig.infomation.priceAdjustmentType"
                     placeholder="璇烽�夋嫨"
                     filterable
@@ -219,9 +292,9 @@
               <div class="table-bottom-r">
                 <el-form-item label="" prop="member_id">
                   <el-input
+                    :disabled="editConfig.isDisabled"
                     v-model="editConfig.infomation.priceAdjustment"
                     size="mini"
-                    :disabled="editConfig.infomation.priceAdjustmentType?false:true"
                     @change="getTotal"
                     placeholder="璇峰~鍐�"
                   ></el-input>
@@ -237,10 +310,10 @@
       </el-form>
       <div slot="footer" class="dialog-footer">
         <!-- <el-button type="primary" size="small" @click="editConfig.visible = false">淇濆苟鎻愪氦瀹℃壒</el-button> -->
-        <el-button type="primary" size="small" @click="saveClick('form')"
+        <el-button type="primary" v-if="this.editConfig.title != '鏌ョ湅'" size="small" @click="saveClick('form')"
           >淇濆瓨</el-button
         >
-        <el-button size="small" @click="editConfig.visible = false"
+        <el-button size="small" v-if="this.editConfig.title != '鏌ョ湅'" @click="editConfig.visible = false"
           >鍙栨秷</el-button
         >
       </div>
@@ -263,216 +336,245 @@
 </template>
 
 <script>
-import CommonFormTableView from "@/components/makepager/CommonFormTableView";
-import BomDialog from "@/components/makepager/BomDialog";
-
+import CommonFormTableView from "@/components/makepager/CommonFormTableView"
+import BomDialog from "@/components/makepager/BomDialog"
+import { getProductList } from "@/api/productManage/product"
 import {
   addPurchase,
   updatePurchase,
   savePurchaseType,
   getPurchaseType,
-} from "@/api/purchaseManage/purchase";
+  getWarehouseInfo
+} from "@/api/purchaseManage/purchase"
+import SelectSupplierDialog from "@/views/purchaseManage/purchase/components/SelectSupplierDialog"
+// import { formToJSON } from "axios";
+import codeMixin from "@/components/mixin/codeMixin"
 
-import SelectSupplierDialog from "@/views/purchaseManage/purchase/components/SelectSupplierDialog";
 export default {
   name: "QuotationDialog",
-  components: { SelectSupplierDialog, CommonFormTableView,BomDialog },
+  components: { SelectSupplierDialog, CommonFormTableView, BomDialog },
+  mixins: [codeMixin],
   props: {
     editCommonConfig: {
       type: Object,
       default: () => {
         return {
+          detailEnter: true,
           visible: false,
-          title: "鍒涘缓",
-          infomation: {},
-        };
-      },
-    },
+          title: "鏂板缓",
+          infomation: {}
+        }
+      }
+    }
   },
   data() {
     return {
       editConfig: this.editCommonConfig,
       rules: {
-        purchaseTypeId:[{ required: true, message: "璇烽�夋嫨", trigger: "change" }],
-        supplierName: [{ required: true, message: "璇烽�夋嫨", trigger: "change" }],
+        purchaseTypeId: [{ required: true, message: "璇烽�夋嫨", trigger: "change" }],
+        supplierName: [{ required: true, message: "璇烽�夋嫨渚涘簲鍟嗗悕绉�", trigger: "change" }],
         phone: [
           {
             required: false,
             message: "璇峰~鍐�",
-            trigger: "change",
+            trigger: "change"
           },
-          { validator: this.validatorPhone, trigger: "change" },
+          { validator: this.validatorPhone, trigger: "change" }
         ],
         wholeDiscount: [
           {
             required: false,
             message: "璇峰~鍐�0-100鐨勬暟瀛�",
-            trigger: "change",
+            trigger: "change"
           },
-          { validator: this.validatorNum, trigger: "change" },
+          { validator: this.validatorNum, trigger: "change" }
         ],
         priceAdjustment: [
           {
             required: false,
             message: "璇峰~鍐�",
-            trigger: "change",
+            trigger: "change"
           },
-          { validator: this.validatorNumThree, trigger: "change" },
+          { validator: this.validatorNumThree, trigger: "change" }
         ],
+        number: [{ required: true, validator: this.validateCheckCode, trigger: ["change", "blur"] }],
+        warehouse: [{ required: true, message: "璇烽�夋嫨鏀惰揣浠撳簱", trigger: "change" }],
+        signingDate: [{ required: true, message: "璇烽�夋嫨绛剧害鏃ユ湡", trigger: "change" }],
+        deliveryDate: [{ required: true, message: "璇烽�夋嫨浜や粯鏃ユ湡", trigger: "change" }],
       },
       productTableList: {},
       showSummary: {
         show: true,
         total: false,
         sumProp: ["price", "total"],
-        multiply:['amount','price'],
-        titleProp: [
-          "缂栧彿",
-          "浜у搧鍚嶇О",
-          "浜у搧缂栧彿",
-          "璁¢噺鍗曚綅",
-          "瑙勬牸鍨嬪彿",
-          "閲囪喘鍗曚环",
-          "鎻忚堪",
-        ],
+        multiply: ["amount", "price"],
+        titleProp: ["缂栧彿", "浜у搧鍚嶇О", "浜у搧缂栧彿", "璁¢噺鍗曚綅", "瑙勬牸", "鍨嬪彿", "閲囪喘鍗曚环", "鎻忚堪"],
         mergeNumber: 4,
-        totalName:'灏忚'
+        totalName: "灏忚"
       },
       editSelectSupplierConfig: {
         editVisible: false,
         title: "",
-        infomation: {},
+        infomation: {}
       },
       supplierId: this.editCommonConfig.infomation.supplierId,
       tableData: [],
-      productId: 1,
+      productIndex: 0,
+      productId: "",
       isNoProduct: true,
       clientList: [],
-      plcBrandList:[],
-      editRow:{
-        isDefault:'pin'
+      plcBrandList: [],
+      editRow: {
+        isDefault: "pin"
       },
-      total:0,
-      totalTwo:0,
-    };
+      total: 0,
+      totalTwo: 0,
+      productListIdx: 0,
+      lacks: [],
+      pickerOptions: {
+        disabledDate(time) {
+          return time.getTime() < Date.now() - 8.64e7
+        }
+      },
+      pickerOptionsBefore: {
+        disabledDate(time) {
+          return time.getTime() > Date.now()
+        }
+      },
+      receiveWhouseList: [] // 鏀惰揣浠撳簱鍒楄〃
+    }
   },
   created() {
-    this.handleGetBomKindDictList();
+    this.handleGetBomKindDictList()
+    this.getWarehouseInfo()
+    this.$store.dispatch("getSupplier")
+    this.formInfo()
   },
   computed: {
+    supplierList() {
+      return this.$store.state.getSupplierName.supplierList
+    }
   },
-  watch:{
-    'editCommonConfig.visible':{
-      immediate:true,
-      handler:function(){
-        
-        this.handleGetBomKindDictList(true);
+  watch: {
+    "editCommonConfig.visible": {
+      immediate: true,
+      handler: function () {
+        this.handleGetBomKindDictList(true)
       }
     }
   },
   methods: {
+    formInfo() {
+      this.objCode.type = "閲囪喘鍗曠紪鐮�"
+      this.objCode.codeStandID = ""
+      if (this.editConfig.infomation.codeStandardID) {
+        this.objCode.codeStandID = this.editConfig.infomation.codeStandardID
+      }
+      this.getRCodeStandardList()
+    },
     validatorNum(rule, value, callback) {
-      if(this.editConfig.infomation.wholeDiscountType==1){
-        if(value==undefined||value==null||(!value&&value!=0)){
-          callback(new Error("璇疯緭鍏ユ湁鏁堟暟瀛�"));
-        }else{
-          var reg=/^\+?[0-9]\d*$/
-          if(!reg.test(value)){
-            callback(new Error('璇峰~鍐�0-100鐨勬暟瀛�'))
-          }else{
-            if(Number(value)>100){
-              callback(new Error('璇峰~鍐�0-100鐨勬暟瀛�'))
-            }else{
+      if (this.editConfig.infomation.wholeDiscountType == 1) {
+        if (value == undefined || value == null || (!value && value != 0)) {
+          callback(new Error("璇疯緭鍏ユ湁鏁堟暟瀛�"))
+        } else {
+          var reg = /^\+?[0-9]\d*$/
+          if (!reg.test(value)) {
+            callback(new Error("璇峰~鍐�0-100鐨勬暟瀛�"))
+          } else {
+            if (Number(value) > 100) {
+              callback(new Error("璇峰~鍐�0-100鐨勬暟瀛�"))
+            } else {
               callback()
             }
           }
-        }  
-      }else{
+        }
+      } else {
         this.validatorNumThree(rule, value, 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{
+    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{
+      } else {
         callback()
-      } 
+      }
     },
     // PLC閰嶇疆璁剧疆
     handleShow() {
-      this.handleGetBomKindDictList();
-      this.$refs.editDialog.editDialogVisible = true;
+      this.handleGetBomKindDictList()
+      this.$refs.editDialog.editDialogVisible = true
     },
     //  PLC閰嶇疆
     handleGetBomKindDictList(val) {
       getPurchaseType().then((res) => {
-        this.plcBrandList = res.data;
+        this.plcBrandList = res.data
         this.setTableForm()
         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;
+                : this.plcBrandList[i].id
+              this.$set(this.editConfig.infomation, "purchaseTypeId", this.editConfig.infomation.purchaseTypeId)
+              break
             }
           }
         }
-      });
+      })
     },
     handleConfirmSave(data) {
-      console.log(data,'data')
-      data.forEach(ele=>{
+      console.log(data, "data")
+      data.forEach((ele) => {
         delete ele.created_at
       })
 
-      savePurchaseType(data).then((res) => {
-        if (res.code === 200) {
+      savePurchaseType(data).then(
+        (res) => {
+          if (res.code === 200) {
+            this.$message({
+              message: "鎿嶄綔鎴愬姛锛�",
+              type: "success"
+            })
+            this.$refs.editDialog.editDialogVisible = false
+            this.handleGetBomKindDictList(true)
+          }
+        },
+        (err) => {
+          console.error(err)
           this.$message({
-            message: "鎿嶄綔鎴愬姛锛�",
-            type: "success",
-          });
-          this.$refs.editDialog.editDialogVisible = false;
-          this.handleGetBomKindDictList(true);
+            message: "鎿嶄綔澶辫触锛�",
+            type: "warning"
+          })
         }
-      },(err)=>{
-        console.error(err)
-        this.$message({
-          message: "鎿嶄綔澶辫触锛�",
-          type: "warning",
-        });
-      });
+      )
     },
     validatorPhone(rule, value, callback) {
       if (value) {
         if (value == undefined || value == null) {
-          callback(new Error("璇疯緭鍏�"));
+          callback(new Error("璇疯緭鍏�"))
         } else {
           if (value.length != 11) {
-            callback(new Error("闀垮害鍦�11涓瓧绗︼紒"));
+            callback(new Error("闀垮害鍦�11涓瓧绗︼紒"))
           } else {
-            var reg =
-              /^1(3\d|4[5-9]|5[0-35-9]|6[2567]|7[0-8]|8\d|9[0-35-9])\d{8}$/;
+            var reg = /^1(3\d|4[5-9]|5[0-35-9]|6[2567]|7[0-8]|8\d|9[0-35-9])\d{8}$/
             if (!reg.test(value)) {
-              callback(new Error("璇峰~鍐欐纭殑鑱旂郴鐢佃瘽锛�"));
+              callback(new Error("璇峰~鍐欐纭殑鑱旂郴鐢佃瘽锛�"))
             } else {
-              callback();
+              callback()
             }
           }
         }
       } else {
-        callback();
+        callback()
       }
     },
     // 淇濆瓨
@@ -481,145 +583,252 @@
         if (valid) {
           for (let i = 0; i < this.tableData.length; i++) {
             if (this.tableData[i].name.length === 0) {
-              this.isNoProduct = true;
-              break;
+              this.isNoProduct = true
+              break
             } else {
-              this.isNoProduct = false;
+              this.isNoProduct = false
             }
           }
           if (this.isNoProduct) {
-            this.$message.error("浜у搧鍚嶇О涓嶈兘涓虹┖");
+            this.$message.error("浜у搧鍚嶇О涓嶈兘涓虹┖")
           } else {
-            const params = this.saveParams();
-            console.log(params);
-            if (this.editConfig.title === "鍒涘缓") {
-              addPurchase(params).then((res) => {
-                console.log(res);
-                this.editConfig.visible = false;
-                if (res.code === 200) {
-                  this.$message.success("娣诲姞鎴愬姛");
-                  this.$parent.getData();
+            const params = this.saveParams()
+            //鏂板缓
+            if (this.editConfig.title === "鏂板缓") {
+              this.lacks = []
+              this.tableData.forEach((item) => {
+                if (this.productTableList.tableProductList.map((obj) => obj.number).includes(item.number)) {
+                  console.log(`${item.name} 鍦ㄦ暟缁勪腑瀛樺湪`)
+                } else {
+                  this.lacks.push(item.name)
                 }
-              });
+              })
+              if (this.lacks.length > 0) {
+                this.$confirm(`褰撳墠渚涘簲鍟嗕笉鑳芥彁渚涙偍閫夋嫨鐨勪骇鍝�:${this.lacks},    鏄惁缁х画鍒涘缓閲囪喘鍗�?`, "鎻愮ず", {
+                  confirmButtonText: "纭畾",
+                  cancelButtonText: "鍙栨秷",
+                  type: "warning"
+                })
+                  .then(() => {
+                    console.log("纭畾鍒涘缓")
+                    //鍒涘缓閲囪喘鍗�
+                    addPurchase(params).then((res) => {
+                      this.editConfig.visible = false
+                      if (res.code === 200) {
+                        this.$message.success("鍒涘缓鎴愬姛")
+                        this.$parent.getData()
+                      }
+                    })
+                  })
+                  .catch(() => {
+                    console.log("鍙栨秷鍒涘缓")
+                  })
+              } else {
+                addPurchase(params).then((res) => {
+                  this.editConfig.visible = false
+                  if (res.code === 200) {
+                    this.$message.success("鍒涘缓鎴愬姛")
+                    this.$parent.getData()
+                  } else {
+                    this.$message.error(res.msg)
+                  }
+                })
+              }
             } else {
-              updatePurchase(params).then((res) => {
-                this.editConfig.visible = false;
+              // 缂栬緫
+              getProductList({
+                supplierId: this.editConfig.infomation.supplierId,
+                page: 1,
+                pageSize: 100
+              }).then((res) => {
                 if (res.code === 200) {
-                  this.$message.success("缂栬緫鎴愬姛");
-                  this.$parent.getData();
+                  this.lacks = []
+                  // 缂栬緫鍓嶅厛鐪嬬湅褰撳墠渚涘簲鍟嗗搴旂殑浜у搧鍒楄〃
+                  this.productTableList.tableProductList = res.data.list
+                  //褰撳墠浜у搧鏄惁鍦ㄥ綋鍓嶄緵搴斿晢涓嬪瓨鍦�
+                  this.tableData.forEach((item) => {
+                    if (this.productTableList.tableProductList.map((obj) => obj.number).includes(item.number)) {
+                      console.log(`${item.name} 鍦ㄦ暟缁勪腑瀛樺湪`)
+                    } else {
+                      this.lacks.push(item.name)
+                    }
+                  })
+                  // 涓嶅瓨鍦ㄧ殑浜у搧淇℃伅
+                  if (this.lacks.length > 0) {
+                    this.$confirm(`褰撳墠渚涘簲鍟嗕笉鑳芥彁渚涙偍閫夋嫨鐨勪骇鍝�:${this.lacks},    鏄惁缁х画鏇存柊閲囪喘鍗�?`, "鎻愮ず", {
+                      confirmButtonText: "纭畾",
+                      cancelButtonText: "鍙栨秷",
+                      type: "warning"
+                    })
+                      .then(() => {
+                        console.log("纭畾鏇存柊")
+                        //鏇存柊閲囪喘鍗�
+                        updatePurchase(params).then((res) => {
+                          this.editConfig.visible = false
+                          if (res.code === 200) {
+                            this.$message.success("鏇存柊鎴愬姛")
+                            this.$parent.getData()
+                          }
+                        })
+                      })
+                      .catch(() => {
+                        console.log("鍙栨秷鏇存柊")
+                      })
+                  } else {
+                    updatePurchase(params).then((res) => {
+                      this.editConfig.visible = false
+                      if (res.code === 200) {
+                        this.$message.success("鏇存柊鎴愬姛")
+                        this.$parent.getData()
+                      }
+                    })
+                  }
                 }
-              });
+              })
             }
           }
         } else {
-          console.log("error submit");
-          return false;
+          console.log("error submit")
+          return false
         }
-      });
+      })
     },
     saveParams() {
-      let data =JSON.parse(JSON.stringify(this.editConfig.infomation));
-      
-      if(this.editConfig.infomation.wholeDiscountType==2&&this.editConfig.infomation.wholeDiscount){
-        if(Number(this.editConfig.infomation.wholeDiscount)>Number(this.totalTwo)){
-            this.$message.error('鐩存帴闄嶄环涓嶈兘瓒呰繃浠风◣鍚堣鐨勬�诲拰锛�')
-            return true;
+      let data = JSON.parse(JSON.stringify(this.editConfig.infomation))
+
+      if (this.editConfig.infomation.wholeDiscountType == 2 && this.editConfig.infomation.wholeDiscount) {
+        if (Number(this.editConfig.infomation.wholeDiscount) > Number(this.totalTwo)) {
+          this.$message.error("鐩存帴闄嶄环涓嶈兘瓒呰繃浠风◣鍚堣鐨勬�诲拰锛�")
+          return true
         }
       }
       let params = {
-        productList:this.tableData,
-        purchase:{
-          supplierId:this.supplierId||0,
-          signingDate:data.signingDate||'',
-          remark:data.remark,
-          orderSource:data.orderSource||'',
-          purchaseTypeId:data.purchaseTypeId||0,
-          phone:data.phone||'',
-          name:data.name||'',
-          deliveryDate:data.deliveryDate||'',
-          contact:data.contact,
-          wholeDiscountType:data.wholeDiscountType?data.wholeDiscountType:0,
-          wholeDiscount:data.wholeDiscount?Number(data.wholeDiscount):0,
-          priceAdjustmentType:data.priceAdjustmentType?data.priceAdjustmentType:0,
-          priceAdjustment:data.priceAdjustment?Number(data.priceAdjustment):0,
-          realTotalPrice:this.total?Number(this.total):0,
-          totalPrice:this.totalTwo?Number(this.totalTwo):0,
+        productList: this.tableData,
+        purchase: {
+          number: data.number || "",
+          supplierId: data.supplierId,
+          signingDate: data.signingDate || "",
+          remark: data.remark,
+          orderSource: data.orderSource || "",
+          purchaseTypeId: data.purchaseTypeId || 0,
+          phone: data.phone || "",
+          name: data.name || "",
+          deliveryDate: data.deliveryDate || "",
+          contact: data.contact,
+          wholeDiscountType: data.wholeDiscountType ? data.wholeDiscountType : 0,
+          wholeDiscount: data.wholeDiscount ? Number(data.wholeDiscount) : 0,
+          priceAdjustmentType: data.priceAdjustmentType ? data.priceAdjustmentType : 0,
+          priceAdjustment: data.priceAdjustment ? Number(data.priceAdjustment) : 0,
+          realTotalPrice: this.total ? Number(this.total) : 0,
+          totalPrice: this.totalTwo ? Number(this.totalTwo) : 0,
+          status: data.status,
+          quantity: data.quantity, // 閲囪喘鏁伴噺
+          warehouse: data.warehouse || "", // 鏀惰揣浠撳簱
+          warehouseAddress: data.warehouseAddress || "", // 鏀惰揣浠撳簱鍦板潃
+          principal: data.principal || "", // 浠撳簱璐熻矗浜�
+          sourceOrder: data.sourceOrder || "" //  鏉ユ簮鍗曟嵁
         }
-      };
-      if(data.ID){
-        params.purchase.id=data.ID
       }
-      return params;
+      if (data.id) {
+        params.purchase.id = data.id
+      }
+      return params
     },
     handleClose() {
-      this.editConfig.visible = false;
+      this.editConfig.visible = false
     },
     // 閫夋嫨瀹㈡埛鐩稿叧鏂规硶
     querySearchAsync(queryString, cb, value) {
-      var restaurants = [];
-      if (value === "client") {
-        restaurants = this.clientList;
-      } 
-      var results = queryString
-        ? restaurants.filter(this.createStateFilter(queryString))
-        : restaurants;
-      cb(results);
+      this.productTableList.tableProductList = []
+      var restaurants = []
+      if (value === "supplier") {
+        restaurants = this.supplierList
+      }
+      var results = queryString ? restaurants.filter(this.createStateFilter(queryString)) : restaurants
+      cb(results)
     },
     createStateFilter(queryString) {
       return (state) => {
-        return (
-          state.name.toLowerCase().indexOf(queryString.toLowerCase()) === 0
-        );
-      };
-    },
-    handleSelectClient(value, item) {
-      console.log(value);
-      if (value === "client") {
-        this.supplierId = item.id;
+        return state.name.toLowerCase().indexOf(queryString.toLowerCase()) === 0
       }
     },
-    selClientClick() {
-      this.editSelectSupplierConfig.editVisible = true;
+    // 閫夋嫨渚涘簲鍟�
+    async handleSelectClient(value, item) {
+      this.productTableList.supplierId = item.id
+      if (value === "client") {
+        this.supplierId = item.id
+        this.editConfig.infomation.supplierId = item.id
+      }
+      await getProductList({
+        supplierId: item.id,
+        page: 1,
+        pageSize: 100
+      }).then((res) => {
+        if (res.code === 200) {
+          this.productTableList.tableProductList = res.data.list
+          console.log(this.productTableList.tableProductList, "pop")
+        }
+      })
     },
-    selClient(row) {
-      this.$set(this.editConfig.infomation,'supplierName',row.name)
-      this.editConfig.infomation.contact = row.contact;
-      this.editConfig.infomation.phone = row.phone;
-      this.supplierId = row.ID;
+    selClientClick() {
+      this.editSelectSupplierConfig.editVisible = true
+    },
+    async selClient(row) {
+      await getProductList({
+        supplierId: row.id,
+        page: 1,
+        pageSize: 100
+      }).then((res) => {
+        if (res.code === 200) {
+          this.productTableList.tableProductList = res.data.list
+        }
+      })
+      this.$set(this.editConfig.infomation, "supplierName", row.name)
+      this.editConfig.infomation.contact = row.contact
+      this.editConfig.infomation.phone = row.phone
+      this.editConfig.infomation.supplierId = row.id
     },
     // 娓呴櫎宸查�夋嫨鐢ㄦ埛
     clearupClient(value) {
       if (value == "client") {
-        this.$set(this.editConfig.infomation, "supplierName", "");
-        this.supplierId = null;
-        this.$forceUpdate();
+        this.$set(this.editConfig.infomation, "supplierName", "")
+        this.supplierId = null
+        this.$forceUpdate()
       }
     },
     setTableForm() {
-      if (
-        !this.editConfig.infomation.ID  ||
-        this.editConfig.infomation.productList.length === 0
-      ) {
+      if (!this.editConfig.infomation.id || this.editConfig.infomation.productList.length === 0) {
         this.tableData = [
           {
-            productId: this.productId,
-            id: 0,
-            amount: 0,
-            desc: "",
+            purchaseId: 0,
+            productId: Number(this.productId),
+            productIndex: this.productIndex,
+            amount: 1,
             name: "",
             number: "",
             price: 0,
             total: 0,
-          },
-        ];
+            remark: "",
+            unit: "",
+            purchasePrice: "",
+            deliveryTime: "",
+            shippingDuration: "",
+            specifications: "",
+            modelNumber: ""
+          }
+        ]
       } else {
-        this.tableData = this.editConfig.infomation.productList;
+        this.tableData = this.editConfig.infomation.productList
         // this.tableData.map((item, index) => {
         //   item.productId = index + 1;
         // });
       }
       this.productTableList = {
+        tableProductList: [],
+        supplierId: undefined,
         tableData: this.tableData,
+        disabled: this.editConfig.isDisabled,
+        isReturn: true,
         tableColumn: [
           {
             label: "浜у搧鍚嶇О",
@@ -627,96 +836,137 @@
             min: 180,
             productName: true,
             isRequird: true,
+            disabled: this.editConfig.isDisabled
           },
-          { label: "浜у搧缂栧彿", prop: "number", min: 150,},
+          { label: "浜у搧缂栧彿", prop: "number", min: 150 },
           { label: "璁¢噺鍗曚綅", prop: "unit" },
-          { label: "瑙勬牸鍨嬪彿", prop: "specifications" },
-          { label: "鏁伴噺", prop: "amount", inputNumber: true, isRequird: true },
+          { label: "瑙勬牸", prop: "specifications" },
+          { label: "鍨嬪彿", prop: "modelNumber" },
+          { label: "鏁伴噺", prop: "amount", inputNumber: true, disabled: this.editConfig.isDisabled },
           {
             label: "閲囪喘鍗曚环",
-            prop: "price",
+            prop: "purchasePrice",
             inputFloat: true,
             isRequird: true,
+            disabled: this.editConfig.isDisabled
           },
-          { label: "浠风◣鍚堣", prop: "total", inputFloat: true,disabled:true,multiply:true, },
-          { label: "鎻忚堪", prop: "remark", input: true },
-        ],
-      };
-      this.toal=this.editConfig.infomation.realTotalPrice
-     
+          { label: "浠风◣鍚堣", prop: "total", inputFloat: true, disabled: this.editConfig.isDisabled, multiply: true },
+          { label: "鎻忚堪", prop: "remark", input: true, disabled: this.editConfig.isDisabled }
+        ]
+      }
+      this.toal = this.editConfig.infomation.realTotalPrice
     },
     // 浜у搧鍒楄〃杈撳叆
     inputContent(val, prop, row) {
-      this.productId = row.productId;
+      let num = 0
       this.tableData.map((item) => {
-        if (item.productId === row.productId) {
-          item[prop] = val;
+        num += item.amount
+        if (item.number === row.number) {
+          item[prop] = val
         }
-      });
-     
+      })
+      if (prop === "amount") {
+        this.editConfig.infomation.quantity = num
+      }
     },
-    getSummaries(total){
-      this.totalTwo= JSON.parse(JSON.stringify(total));
-      this.total=total;
+    getSummaries(total) {
+      this.totalTwo = JSON.parse(JSON.stringify(total))
+      this.total = total
       this.getTotal()
     },
-    getTotal(){
-      let prie=0
-      if(this.editConfig.infomation.priceAdjustmentType==1){
-        prie=Number(this.editConfig.infomation.priceAdjustment)
-      }else if(this.editConfig.infomation.priceAdjustmentType==2){
-        prie=(-1)*Number(this.editConfig.infomation.priceAdjustment)
-      }else{
-        prie=0
+    getTotal() {
+      let prie = 0
+      if (this.editConfig.infomation.priceAdjustmentType == 1) {
+        prie = Number(this.editConfig.infomation.priceAdjustment)
+      } else if (this.editConfig.infomation.priceAdjustmentType == 2) {
+        prie = -1 * Number(this.editConfig.infomation.priceAdjustment)
+      } else {
+        prie = 0
       }
-      let t=0
-      if(this.editConfig.infomation.wholeDiscountType==1){
-        t=this.totalTwo*Number(this.editConfig.infomation.wholeDiscount)/100
-      }else if(this.editConfig.infomation.wholeDiscountType==2){
-        t=Number(this.editConfig.infomation.wholeDiscount)
-      }else{
-        t=0
+      let t = 0
+      if (this.editConfig.infomation.wholeDiscountType == 1) {
+        t = (this.totalTwo * Number(this.editConfig.infomation.wholeDiscount)) / 100
+      } else if (this.editConfig.infomation.wholeDiscountType == 2) {
+        t = Number(this.editConfig.infomation.wholeDiscount)
+      } else {
+        t = 0
       }
-      this.total=this.totalTwo-t+Number(prie)
+      this.total = this.totalTwo - t + Number(prie)
     },
     // 浜у搧鏂板
     addProductClick() {
-      this.productId++;
-      this.tableData.push({
-        productId: this.productId,
-        id: 0,
-        amount: 0,
-        desc: "",
-        name: "",
-        number: "",
-        price: 0,
-        total: 0,
-      });
-      this.showSummary.show = true;
+      // this.productIndex++
+      // this.tableData.push({
+      //   productIndex: this.productIndex,
+      //   productId: "",
+      //   id: 0,
+      //   amount: 0,
+      //   desc: "",
+      //   name: "",
+      //   number: "",
+      //   price: 0,
+      //   total: 0
+      // })
+      // this.showSummary.show = true
+    },
+    // 鏂板鏂瑰紡淇敼
+    getSelectArray(val, index) {
+      console.log(val, "ddd99999")
+      if (this.tableData.length == 1 && this.tableData[0].number.length == 0) {
+        this.tableData = []
+      }
+      if (index < this.tableData.length) {
+        this.tableData.splice(index, 1)
+        val.map((item, ind) => {
+          this.tableData.splice(index + ind, 0, item)
+        })
+      } else {
+        this.tableData = this.tableData.concat(val)
+      }
+      this.productTableList.tableData = this.tableData
+      this.showSummary.show = true
     },
     //  浜у搧娓呯┖
     emptyProductClick() {
-      this.productId = 1;
+      this.productIndex = 1
       this.tableData = [
         {
-          productId: this.productId,
+          productId: "",
+          productIndex: this.productIndex,
           id: 0,
-          amount: 0,
+          amount: "0",
           desc: "",
           name: "",
           number: "",
           price: 0,
           total: 0
-        },
-      ];
-      this.productTableList.tableData = this.tableData;
+        }
+      ]
+      this.productTableList.tableData = this.tableData
     },
     clearupProduct(data) {
-      this.tableData = data;
-      this.productTableList.tableData = this.tableData;
+      this.tableData = data
+      this.productTableList.tableData = this.tableData
     },
-  },
-};
+    //閫夋嫨琛�
+    rowClick(row) {
+      console.log(row, "xuanze")
+      this.productListIdx = row.productIndex
+    },
+    //閫変腑浜у搧
+    handleProduct(item) {
+      this.tableData[this.productListIdx].productId = Number(item.id)
+      console.log(item, "閫変腑浜у搧", this.tableData)
+    },
+    // 鑾峰彇鏀惰揣浠撳簱鍒楄〃
+    async getWarehouseInfo() {
+      await getWarehouseInfo().then((res) => {
+        console.log(res)
+        this.receiveWhouseList = res.data.info
+      })
+    }
+  }
+}
 </script>
 
 <!-- Add "scoped" attribute to limit CSS to this component only -->

--
Gitblit v1.8.0