From 03cfba0f636b42417070fc8caef44bcdd792a085 Mon Sep 17 00:00:00 2001
From: haoxuan <haoxuan>
Date: 星期二, 07 五月 2024 17:34:37 +0800
Subject: [PATCH] 概述 出库模块 编辑的时候循环处理对应产品调用接口获取在库数量的逻辑处理

---
 src/components/makepager/CommonFormTableView.vue |   75 +++++++++++++++++++++++++------------
 1 files changed, 51 insertions(+), 24 deletions(-)

diff --git a/src/components/makepager/CommonFormTableView.vue b/src/components/makepager/CommonFormTableView.vue
index aae5424..500bf19 100644
--- a/src/components/makepager/CommonFormTableView.vue
+++ b/src/components/makepager/CommonFormTableView.vue
@@ -79,13 +79,17 @@
                 <div class="custom-name">
                   <el-autocomplete
                     v-model="scope.row[item.prop]"
-                    :fetch-suggestions="querySearchAsync"
+                    :fetch-suggestions="
+                      (queryString, callback) => {
+                        querySearchAsync(queryString, callback, 'product')
+                      }
+                    "
                     value-key="name"
                     :disabled="!isOperate"
                     size="mini"
                     @select="
                       (val) => {
-                        handleSelectClient(val, item.prop, scope.row)
+                        handleSelectClient(val, item.prop, scope.row,scope)
                       }
                     "
                   ></el-autocomplete>
@@ -142,12 +146,12 @@
                 </div>
               </el-form-item>
               <el-form-item
-                v-else-if="item.inputFloat"
+                v-else-if="item.inputFloat||item.inputFloatValue"
                 label=" "
                 :prop="'tableData.' + scope.$index + '.' + item.prop"
                 :rules="[{ required: item.isRequird ? true : false, message: '杈撳叆涓嶈兘涓虹┖' }]"
               >
-                <span v-if="scope.row.isEdit">{{ scope.row[item.prop] }}</span>
+                <span v-if="scope.row.isEdit||(item.inputFloatValue&&!scope.row[item.isInputFloat])">{{ scope.row[item.prop] }}</span>
                 <div v-else @click.stop="commoInput">
                   <el-input-number
                     v-model="scope.row[item.prop]"
@@ -156,7 +160,7 @@
                     :controls="false"
                     size="mini"
                     style="width: 100%; margin-right: 5px"
-                    :min="item.prop === 'minInventory' ? 0 : 1"
+                    :min="item.prop === 'minInventory' ? 0 : 0"
                     @change="
                       (val) => {
                         commonInputChange(val, item.prop, scope.row)
@@ -194,7 +198,7 @@
                     style="width: 80%"
                     @change="
                       (val) => {
-                        selLocationClick(val, item.prop)
+                        selLocationClick(val, item.prop,scope.row)
                       }
                     "
                   >
@@ -255,7 +259,7 @@
                     style="width: 80%"
                     @change="
                       (val) => {
-                        selSonLocationClick(val, item.prop)
+                        selSonLocationClick(val, item.prop,scope.row,scope)
                       }
                     "
                   >
@@ -430,7 +434,7 @@
         <slot name="tableButton" />
       </el-table>
     </el-form>
-    <div v-if="!detailEnter && !isinventory && !isReorder" style="margin: 10px">
+    <div v-if="!detailEnter && !isinventory && !isReorder&&isOperateAdd" style="margin: 10px">
       <el-button size="small" type="primary" @click="add">鏂板</el-button>
       <el-button size="small" type="primary" @click="empty">娓呯┖</el-button>
     </div>
@@ -450,7 +454,7 @@
 import { getProductList } from "@/api/product/product"
 import { getLocationList } from "@/api/warehouseManage/warehouse"
 import { getCompanyList } from "@/api/common/other"
-import { getRuleList } from "@/api/operate/inventoryAdjustment"
+import { getRuleList} from "@/api/operate/inventoryAdjustment"
 import { getProductCategoryList } from "@/api/product/productCategory"
 import SimpleSearchInput from "@/components/makepager/SimpleSearchInput"
 import { getAmountAndPrediction } from "@/api/product/reorderRules"
@@ -507,7 +511,12 @@
     isOperate: {
       type: Boolean,
       default: true
-    }
+    },
+    // 鏄惁鏈夋柊澧炲拰娓呯┖鎿嶄綔
+    isOperateAdd: {
+      type: Boolean,
+      default: true
+    },
   },
   data() {
     return {
@@ -561,10 +570,19 @@
   computed: {},
   watch: {
     productTableList() {
-      this.tableList = this.productTableList
+      // this.showcol = this.productTableList.showcol
+      this.getTableInfo()
     }
   },
   methods: {
+    getTableInfo(){
+      this.tableList = this.productTableList
+      if (this.tableList.tableData.length === 1 && this.tableList.tableData[0].name === "") {
+        this.isRecalculate = false
+      } else {
+        this.isRecalculate = true
+      }
+    },
     // 浜у搧鍚嶇О
     async getProductList() {
       await getProductList({
@@ -579,8 +597,8 @@
       })
     },
     // 涓嬫媺鎼滅储
-    async handleSelectClient(value, item) {
-      this.$emit("selProductClick", value, item)
+    async handleSelectClient(value, item,row,scope) {
+      this.$emit("selProductClick", value, item,row,scope)
       if (value === "product") {
         if (item.categoryId === 0 || item.categoryName === "") {
           this.productTypeNameOptions = []
@@ -612,7 +630,7 @@
       } else if (value === "formLocation") {
         restaurants = this.selLocationOptions
       }
-      var results = queryString ? restaurants.filter(this.createStateFilter(queryString, value)) : restaurants
+      var results = (queryString&&restaurants) ? restaurants.filter(this.createStateFilter(queryString, value)) : restaurants
       cb(results)
       if (results.length === 0) {
         this.productTypeNameOptions = []
@@ -679,6 +697,7 @@
       this.locacionName = ""
       await getLocationList({
         // keyword: "",
+        type:3,
         jointName: this.initialPosition ? this.initialPosition : null,
         productId: this.queryProductId ? this.queryProductId : null,
         productCategoryId: this.categoryId ? this.categoryId : null,
@@ -772,6 +791,7 @@
     },
     // 閫夋嫨浜у搧
     selProductClick(item, row) {
+      console.log("閫夋嫨浜у搧",row,item)
       if (this.isReorder) {
         this.productId = item.id
         this.productName = item.name
@@ -794,13 +814,12 @@
             ite.productName = item.name
             ite.categoryId = item.categoryId
             ite.productCategory = item.categoryName
-            ite.amount = item.amount
+            // ite.amount = item.amount
             ite.unit = item.unit
           }
         })
         this.$emit("selProductClick", "product", this.tableList.tableData[selIndex])
       }
-
       if (this.isinventory) {
         getRuleList({
           locationId: 0,
@@ -813,6 +832,7 @@
           }
         })
       }
+
       // this.$emit("selProductClick", item)
     },
     // 閫夋嫨浜у搧绫诲瀷
@@ -844,6 +864,7 @@
     },
     // 閫夋嫨浣嶇疆
     selLocationClick(item, prop, row) {
+      console.log("浣嶇疆閫夋嫨",item,row)
       if (prop === "areaName") {
         getLocationList({
           jointName: item.label,
@@ -855,6 +876,8 @@
             this.selSonLocationOptions = list
           }
         })
+      }else if(prop==='locationName'){
+        console.log("locationName")
       }
       if (this.isReorder) {
         this.locacionId = item.value
@@ -877,8 +900,8 @@
       this.$emit("selLocationClick", item, prop)
     },
     // 閫夋嫨瀛愪綅缃�
-    selSonLocationClick(item) {
-      this.$emit("selSonLocationClick", item)
+    selSonLocationClick(item,prop,row,scope) {
+      this.$emit("selSonLocationClick", item,prop,row,scope)
     },
     // 鑾峰彇鍦ㄥ簱涓庨娴嬫暟閲�
     getAmountAndPrediction(item, val, ite) {
@@ -1013,17 +1036,21 @@
     },
     commoInput() {},
     selClient(item) {
-      let list = this.tableList.tableData.map((item) => item.number)
-      if (list.findIndex((v) => v == item.number) == -1) {
+      let list = this.tableList.tableData.map((item) => item.id)
+      if (list.findIndex((v) => v == item.id) == -1) {
         this.isRecalculate = true
         // this.editConfig.infomation.client_name = row.name
         this.tableList.tableData.map((ite, index) => {
           if (index === this.productIndex) {
+            ite.productName = item.name
+            ite.productId = item.id
             ite.name = item.name
-            ite.amount = item.amount || 1
-            ite.number = item.number
-            ite.price = item.price
-            ite.total = item.amount ? item.amount * item.price : 1 * item.price
+            ite.amount = 1
+            ite.number = item.id
+            ite.specs = item.specs
+            ite.model = item.model
+            // ite.price = item.price
+            // ite.total = item.amount ? item.amount * item.price : 1 * item.price
             ite.unit = item.unit
           }
         })

--
Gitblit v1.8.0