From 1888b426ff2b6a529f5fdef0f0453dadef71824b Mon Sep 17 00:00:00 2001
From: haoxuan <haoxuan>
Date: 星期三, 17 四月 2024 10:17:38 +0800
Subject: [PATCH] 隐藏多单位的问题

---
 src/views/warehouseManage/listingRules/index.vue |  204 +++++++++++++++++++++++++++++++++++---------------
 1 files changed, 142 insertions(+), 62 deletions(-)

diff --git a/src/views/warehouseManage/listingRules/index.vue b/src/views/warehouseManage/listingRules/index.vue
index a9ed679..32b3b4c 100644
--- a/src/views/warehouseManage/listingRules/index.vue
+++ b/src/views/warehouseManage/listingRules/index.vue
@@ -4,24 +4,32 @@
       <SearchCommonView
         :add-title="addTitle"
         :show-discard="showDiscard"
-        :placeholder="'璇疯緭鍏ヤ綅缃�/浜у搧'"
+        :placeholder="'璇疯緭鍏ヤ骇鍝�/浜у搧绫诲埆'"
         :amount-view="false"
+        :search-task-map="searchTaskMap"
         @addCommonClick="addProductClick"
         @searchClick="getList"
         @discardBtnClick="discardBtnClick"
         @applyBtnClick="applyBtnClick"
+        @delSelectClick="delSelectClick"
       />
     </div>
     <div class="list-view">
       <div class="table">
         <CommonFormTableView
+          ref="tableRef"
           :islistingrules="true"
           :product-table-list="tableList"
           @inputContent="inputContent"
           @tableRowClick="tableRowClick"
           @selLocationClick="selLocationClick"
+          @selSonLocationClick="selSonLocationClick"
+          @querySearchData="querySearchData"
           @selProductClick="selProductClick"
         >
+          <!-- 
+          @selProductTypeClick="selProductTypeClick"
+         -->
           <template slot="tableButton">
             <el-table-column label="鎿嶄綔" width="90" align="center">
               <template slot-scope="scope">
@@ -60,40 +68,39 @@
       addTitle: "鏂板缓",
       showDiscard: false,
       tableList: {},
-      tableData: [
-        {
-          location: "HC/閿�鍞尯",
-          productName: "澶忓鐪熶笣鍚婂甫瑁�",
-          amount: "0.00",
-          unit: "浠�",
-          count: "0.00",
-          date: "2023-12-31",
-          user: "绠$悊鍛�",
-          isSet: true,
-          isEdit: true
-        },
-        {
-          location: "HM/閿�鍞尯",
-          productName: "澶忓鐪熶笣鍚婂甫瑁�",
-          productCategory: "",
-          subLocation: "A鍖�",
-          companyName: "璐濇�濈",
-          isSet: true,
-          isEdit: true
-        }
-      ],
       searchOptions: [],
       countId: 0,
       isNoProduct: true, // 娣诲姞鏄庣粏琛屾椂鏄惁鏈変骇鍝佹湭閫夋嫨
       isRowClick: false,
       areaId: 0,
       productId: 0,
+      productCategoryId: 0,
       subLocationId: 0,
-      currentRowId: 0
+      currentRowId: 0,
+      rowIndex: -1,
+      RuleType: 0,
+      queryProductId: null,
+      categoryId: null,
+      searchTaskMap: [],
+      isCreate: false,
+      thatRow: {}
     }
   },
   created() {
     this.setTable()
+    let query = this.$route.query
+    if (query) {
+      this.queryProductId = query.productId?.length ? query.productId : null
+      this.categoryId = query.id ? Number(query.id) : null
+      this.pagerOptions.currPage = 1
+      this.searchTaskMap =
+        query?.id > 0
+          ? [{ categoryId: this.categoryId, title: query.categoryName }]
+          : query.productId?.length > 0
+          ? [{ productId: this.queryProductId, title: query.productName }]
+          : []
+      console.log(this.searchTaskMap)
+    }
     this.getData()
   },
   methods: {
@@ -103,18 +110,20 @@
         selectBox: false,
         selectIndex: true,
         tableColumn: [
-          { label: "褰撲骇鍝佸埌杈�", prop: "areaName", location: true },
+          { label: "褰撲骇鍝佸埌杈�", prop: "areaName", toLocation: true },
           { label: "浜у搧", prop: "productName", product: true },
-          { label: "浜у搧绫诲埆", prop: "productCategory" },
-          { label: "瀛樺偍鍒板瓙浣嶇疆", prop: "subLocation", location: true }
+          { label: "浜у搧绫诲埆", prop: "productCategory", productType: true },
+          { label: "瀛樺偍鍒板瓙浣嶇疆", prop: "subLocation", sonLocation: true }
           // { label: "鍏徃", prop: "companyName", company: true }
-        ]
+        ],
+        rowClickIndex: -1
       }
     },
     // 璇锋眰鏁版嵁
     async getData() {
       await getListingRulesList({
-        // keyword: this.keyword,
+        productId: this.queryProductId ? this.queryProductId : null,
+        productCategoryId: this.categoryId ? this.categoryId : null,
         page: this.pagerOptions.currPage,
         pageSize: this.pagerOptions.pageSize
       }).then((res) => {
@@ -122,8 +131,8 @@
           const list = res.data.map((item) => {
             return {
               ...item,
-              areaName: item.area.jointName,
-              subLocation: item.location.jointName,
+              areaName: { label: item.area.jointName, value: item.area.id },
+              subLocation: { label: item.location.jointName, value: item.location.id },
               productName: item.product.name,
               productCategory: item.productCategory.name,
               isSet: false,
@@ -147,6 +156,9 @@
     },
     // 鏂板
     addProductClick() {
+      this.isCreate = true
+      this.tableList.tableColumn[1].product = true
+      this.tableList.tableColumn[2].productType = true
       console.log(this.tableData)
       this.isSel()
       if (this.isNoProduct && this.addTitle === "鏂板缓") {
@@ -164,8 +176,10 @@
           subLocation: "",
           productName: "",
           companyName: "",
+          productCategory: "",
           isSet: true,
-          isEdit: false
+          isEdit: false,
+          isOrder: true
         })
         this.areaId = 0
         this.subLocationId = 0
@@ -174,8 +188,8 @@
       } else {
         if (this.areaId === 0) {
           this.$message.error("璇烽�夋嫨褰撳墠浜у搧鍒拌揪浣嶇疆")
-        } else if (this.productId === 0) {
-          this.$message.error("璇烽�夋嫨浜у搧")
+        } else if (this.productId === 0 && this.productCategoryId === 0) {
+          this.$message.error("璇烽�夋嫨浜у搧鎴栦骇鍝佺被鍒�")
         } else if (this.subLocationId === 0) {
           this.$message.error("璇烽�夋嫨瀛樺偍鍒板瓙浣嶇疆")
         } else {
@@ -193,6 +207,7 @@
           })
           let requestUrl = this.currentRowId === 0 ? addListingRules : updateListingRules
           requestUrl({
+            RuleType: this.RuleType,
             id: this.currentRowId,
             areaId: this.areaId,
             locationId: this.subLocationId,
@@ -204,6 +219,7 @@
               this.getData()
               let tipStr = this.currentRowId === 0 ? "娣诲姞鎴愬姛" : "淇敼鎴愬姛"
               this.$message.success(tipStr)
+              this.isCreate = false
             }
           })
         }
@@ -213,7 +229,7 @@
     isSel() {
       for (let i = 0; i < this.tableData.length; i++) {
         if (this.tableData[i].productName.length === 0) {
-          this.isNoProduct = false
+          this.isNoProduct = true // 鏆傛椂淇敼涓簍rue锛屽鏋滀骇鍝佷互鍚庢槸蹇呭~锛屾敼涓篺alse灏辫
           break
         } else {
           this.isNoProduct = true
@@ -222,13 +238,10 @@
     },
     // 鍙栨秷
     discardBtnClick() {
-      if (this.isRowClick) {
-        this.tableData.map((item) => {
-          item.isEdit = true
-        })
-      } else {
-        this.tableData.splice(0, 1)
-      }
+      this.getData()
+      this.isCreate = false
+      this.tableList.tableColumn[1].product = true
+      this.tableList.tableColumn[2].productType = true
       this.addTitle = "鏂板缓"
       this.showDiscard = false
     },
@@ -265,29 +278,56 @@
     },
     // 琛岀偣鍑�
     tableRowClick(row, rowIndex) {
-      console.log("11111")
+      this.thatRow = row
+      this.tableList.rowClickIndex = rowIndex
+      this.rowIndex = rowIndex
       this.isSel()
       if (!this.isNoProduct && this.currentRowId === 0) {
         this.$message.error("璇峰畬鎴愬綋鍓嶆柊寤烘垨鍙栨秷鏂板缓")
       } else {
-        this.currentRowId = row.id
+        this.currentRowId = row.id || 0
         this.addTitle = "淇濆瓨"
         this.showDiscard = true
         this.isRowClick = true
-        if (!this.isNoProduct) {
-          this.tableData.splice(this.tableData.length - 1, 1)
+        if (this.isNoProduct) {
+          // this.tableData.splice(this.tableData.length - 1, 1)
+          this.tableData.map((item, index) => {
+            if (index === rowIndex) {
+              item.isEdit = false
+              item.isOrder = true
+            } else {
+              item.isEdit = true
+            }
+          })
+          this.areaId = row.areaId
+          this.subLocationId = row.locationId
+          this.productCategoryId = row.productCategoryId
+          this.productId = row.productId
         }
-        this.tableData.map((item, index) => {
-          if (index === rowIndex) {
-            item.isEdit = false
-          } else {
-            item.isEdit = true
+      }
+    },
+    querySearchData(queryString, results, value) {
+      if (this.isCreate) {
+        if (queryString === "") {
+          this.tableList.tableColumn[1].product = true
+          this.tableList.tableColumn[2].productType = true
+        } else {
+          if (value === "product") {
+            this.tableList.tableColumn[2].productType = false
+            if (results.length !== 0) {
+              this.productId = results[0].id
+            } else {
+              this.productId = 0
+            }
+          } else if (value === "productType") {
+            this.tableList.tableColumn[1].product = false
+            if (results.length !== 0) {
+              this.productCategoryId = results[0].id
+            } else {
+              this.productCategoryId = 0
+            }
           }
-        })
-        this.areaId = row.areaId
-        this.subLocationId = row.locationId
-        this.productCategoryId = row.productCategoryId
-        this.productId = row.productId
+        }
       }
     },
     // 鎼滅储
@@ -313,20 +353,31 @@
       this.editConfig.visible = true
       this.editConfig.title = "鏂板缓"
     },
-    // 閫夋嫨浣嶇疆鏂规硶
+    // 閫夋嫨璧峰浣嶇疆鏂规硶
     selLocationClick(item, prop) {
-      console.log(item, prop)
       if (prop === "areaName") {
         this.areaId = item.value
       } else if (prop === "subLocation") {
         this.subLocationId = item.value
       }
     },
+    // 閫夋嫨瀛愪綅缃柟娉�
+    selSonLocationClick(item) {
+      this.subLocationId = item.value
+    },
     // 閫変腑浜у搧鏂规硶
-    selProductClick(item) {
-      console.log(item)
-      this.productId = item.value
-      this.productCategoryId = item.categoryId
+    selProductClick(value, item) {
+      console.log(value, item)
+      if (value === "product") {
+        this.RuleType = 1
+        this.tableList.tableColumn[2].productType = false
+        this.productId = item.productId
+        this.productCategoryId = item.categoryId
+      } else if (value === "productType") {
+        this.productCategoryId = item.id
+        this.RuleType = 2
+        this.tableList.tableColumn[1].product = false
+      }
     },
     // 鍒犻櫎
     async delClick(scope) {
@@ -337,6 +388,35 @@
           this.getData()
         }
       })
+    },
+    // 鍒犻櫎浜у搧绫诲瀷
+    delSelectClick() {
+      this.categoryId = 0
+      this.queryProductId = ""
+      this.getData()
+    }
+  },
+  watch: {
+    rowIndex(newVal) {
+      if (this.isCreate) {
+        if (newVal === 0) {
+          this.tableList.tableColumn[1].product = true
+          this.tableList.tableColumn[2].productType = true
+        } else {
+          this.$message.error("璇峰畬鎴愬綋鍓嶆柊寤烘垨鍙栨秷鏂板缓")
+          this.tableList.tableColumn[1].product = false
+          this.tableList.tableColumn[2].productType = false
+        }
+      } else {
+        if (this.tableList.tableData[newVal].productName === "") {
+          this.tableList.tableColumn[1].product = false
+          this.tableList.tableColumn[2].productType = true
+        } else {
+          this.tableList.tableColumn[1].product = true
+          this.tableList.tableColumn[2].productType = false
+        }
+      }
+      this.$refs.tableRef.getProductCategoryList()
     }
   }
 }

--
Gitblit v1.8.0