From 47121dff8da689923f2f1af9daf63854f385c395 Mon Sep 17 00:00:00 2001
From: yangfeng <wanwan926_4@163.com>
Date: 星期五, 03 十一月 2023 13:37:58 +0800
Subject: [PATCH] 查看产品、产品类别弹窗调整上架规则

---
 src/views/warehouseManage/listingRules/index.vue                     |  119 ++++++++++++++---------
 src/views/productManage/product/index.vue                            |    1 
 src/views/productManage/productCategory/AddProductCategoryDialog.vue |   93 +++++++++++-------
 src/views/productManage/product/AddProductDialog.vue                 |   43 ++++++--
 4 files changed, 162 insertions(+), 94 deletions(-)

diff --git a/src/views/productManage/product/AddProductDialog.vue b/src/views/productManage/product/AddProductDialog.vue
index e24ecd2..8be8160 100644
--- a/src/views/productManage/product/AddProductDialog.vue
+++ b/src/views/productManage/product/AddProductDialog.vue
@@ -43,6 +43,7 @@
             :show-procure="showProcure"
             :countObject="statisticsMap"
             :show-sale="showSale"
+            @listingRulesClick="listingRulesClick"
           />
           <div class="bottom">
             <el-tabs v-model="activeName" type="card">
@@ -558,22 +559,24 @@
     /**
      * 闈炲繀濉」鍚庣杩斿洖鐨勬槸鏁板瓧 0,琛ㄥ崟闇�瑕佺┖涓叉墠鑳借涓烘湭閫夋嫨鍥炴樉
      */
-    setOptionalFieldsToEmpty(){
-      ['productType','categoryId']
-          .filter(filed => this.editConfig.infomation[filed] === 0)
-          .forEach(filed => {
-            this.editConfig.infomation[filed] = ''
-          })
+    setOptionalFieldsToEmpty() {
+      let arr = ["productType", "categoryId"]
+      arr
+        .filter((filed) => this.editConfig.infomation[filed] === 0)
+        .forEach((filed) => {
+          this.editConfig.infomation[filed] = ""
+        })
     },
     /**
      * 鍚庣鍙帴鍙楁暟瀛楀舰寮�, 淇濆瓨鏃惰繕寰楀啀杞洖鍘�
      */
-    unsetFieldsToNumber(){
-      ['productType','categoryId']
-          .filter(filed => this.editConfig.infomation[filed] === '')
-          .forEach(filed => {
-            this.editConfig.infomation[filed] = 0
-          })
+    unsetFieldsToNumber() {
+      let arr = ["productType", "categoryId"]
+      arr
+        .filter((filed) => this.editConfig.infomation[filed] === "")
+        .forEach((filed) => {
+          this.editConfig.infomation[filed] = 0
+        })
     },
     // 鑾峰彇浜у搧绫诲埆
     async getProductCategoryList() {
@@ -645,7 +648,7 @@
               this.$message.success("娣诲姞鎴愬姛")
               this.$parent.getData()
             }
-          },console.error)
+          }, console.error)
         }
       })
     },
@@ -779,6 +782,20 @@
         })
       }
     },
+    // 涓婃灦瑙勫垯
+    listingRulesClick() {
+      this.$refs.form.validate((valid) => {
+        if (valid) {
+          this.$router.push({
+            path: "/warehouseManage/listingRules",
+            query: {
+              productName: this.editConfig.infomation.name,
+              productId: this.editConfig.title === "鏂板缓" ? "" : this.editConfig.infomation.id
+            }
+          })
+        }
+      })
+    },
     // 鍙攢鍞�/鍙噰璐�
     checkboxChange(val, param) {
       if (val === "閲囪喘") {
diff --git a/src/views/productManage/product/index.vue b/src/views/productManage/product/index.vue
index 2eed6ad..c5855a4 100644
--- a/src/views/productManage/product/index.vue
+++ b/src/views/productManage/product/index.vue
@@ -125,7 +125,6 @@
       this.pagerOptions.currPage = 1
       this.searchTaskMap = query.id ? [{ categoryId: this.categoryId, title: query.categoryName }] : []
     }
-
     this.getData()
   },
   methods: {
diff --git a/src/views/productManage/productCategory/AddProductCategoryDialog.vue b/src/views/productManage/productCategory/AddProductCategoryDialog.vue
index b8453ee..63c4f32 100644
--- a/src/views/productManage/productCategory/AddProductCategoryDialog.vue
+++ b/src/views/productManage/productCategory/AddProductCategoryDialog.vue
@@ -38,7 +38,12 @@
         size="mini"
       >
         <div class="basic-info">
-          <FormBtnsView :showProduct="true" :countObject="statisticsMap" @productClick="productClick" />
+          <FormBtnsView
+            :showProduct="true"
+            :countObject="statisticsMap"
+            @productClick="productClick"
+            @listingRulesClick="listingRulesClick"
+          />
           <div class="basic-info-view">
             <!-- <el-row> -->
             <!-- <el-col :span="24">
@@ -173,7 +178,7 @@
 import { addProductCategory, updateProductCategory, deleteProductCategory } from "@/api/product/productCategory"
 
 import { getDataByType } from "@/api/data"
-import {getProductList} from "@/api/product/product";
+import { getProductList } from "@/api/product/product"
 export default {
   name: "AddProductCategoryDialog",
   props: {
@@ -184,7 +189,7 @@
           visible: false,
           title: "鏂板缓",
           infomation: { type: [] },
-          autoEdit: false,
+          autoEdit: false
         }
       }
     },
@@ -197,13 +202,13 @@
   },
   components: {},
   computed: {
-    modalTitle(){
-      if (this.editConfig.title === '缂栬緫' && this.editConfig.autoEdit){
-        return '缂栬緫'
-      }else if (this.editConfig.title === '缂栬緫') {
-        return !this.showEdit ? '缂栬緫' : '鏌ョ湅'
-      }else {
-        return '鏂板缓'
+    modalTitle() {
+      if (this.editConfig.title === "缂栬緫" && this.editConfig.autoEdit) {
+        return "缂栬緫"
+      } else if (this.editConfig.title === "缂栬緫") {
+        return !this.showEdit ? "缂栬緫" : "鏌ョ湅"
+      } else {
+        return "鏂板缓"
       }
     }
   },
@@ -225,7 +230,7 @@
       showEdit: false, // 鏄惁鏄剧ず缂栬緫鎸夐挳
       isDelClick: false, // 鍒犻櫎鎸夐挳鏄惁鍙偣鍑�
       showFooter: false, // 鏄惁鏄剧ず鍙栨秷淇濆瓨,
-      statisticsMap:{
+      statisticsMap: {
         product: 0 // 浜у搧鏁伴噺
       }
     }
@@ -233,7 +238,7 @@
   created() {
     this.setBottonView()
     this.getProductCount()
-    if (this.editConfig.autoEdit){
+    if (this.editConfig.autoEdit) {
       this.editClick()
     }
     this.setOptionalFieldsToEmpty()
@@ -242,40 +247,44 @@
     /**
      * 闈炲繀濉」鍚庣杩斿洖鐨勬槸鏁板瓧 0,琛ㄥ崟闇�瑕佺┖涓叉墠鑳借涓烘湭閫夋嫨鍥炴樉
      */
-    setOptionalFieldsToEmpty(){
-      ['parentId','costingMethod','inventoryValuation','forceRemovalStrategy']
-          .filter(filed => this.editConfig.infomation[filed] === 0)
-          .forEach(filed => {
-            this.editConfig.infomation[filed] = ''
-          })
+    setOptionalFieldsToEmpty() {
+      let arr = ["parentId", "costingMethod", "inventoryValuation", "forceRemovalStrategy"]
+      arr
+        .filter((filed) => this.editConfig.infomation[filed] === 0)
+        .forEach((filed) => {
+          this.editConfig.infomation[filed] = ""
+        })
     },
     /**
      * 鍚庣鍙帴鍙楁暟瀛楀舰寮�, 淇濆瓨鏃惰繕寰楀啀杞洖鍘�
      */
-    unsetFieldsToNumber(){
-      ['parentId','costingMethod','inventoryValuation','forceRemovalStrategy']
-          .filter(filed => this.editConfig.infomation[filed] === '')
-          .forEach(filed => {
-            this.editConfig.infomation[filed] = 0
-          })
+    unsetFieldsToNumber() {
+      let arr = ["parentId", "costingMethod", "inventoryValuation", "forceRemovalStrategy"]
+      arr
+        .filter((filed) => this.editConfig.infomation[filed] === "")
+        .forEach((filed) => {
+          this.editConfig.infomation[filed] = 0
+        })
     },
     // 鑾峰彇浜у搧鏁伴噺
-    getProductCount(){
+    getProductCount() {
       getProductList({
-        keyWord: '',
+        keyWord: "",
         categoryId: this.editConfig.title === "鏂板缓" ? null : this.editConfig.infomation.id,
         page: 1,
         pageSize: 1
-      }).then((res) => {
-        if (res.code === 200) {
-          this.statisticsMap.product = res?.total ?? 0
-        }else{
-          this.statisticsMap.product = 0
-        }
-      }).catch(err=>{
-        console.error(err)
-        this.statisticsMap.product = 0
       })
+        .then((res) => {
+          if (res.code === 200) {
+            this.statisticsMap.product = res?.total ?? 0
+          } else {
+            this.statisticsMap.product = 0
+          }
+        })
+        .catch((err) => {
+          console.error(err)
+          this.statisticsMap.product = 0
+        })
     },
     // 璁剧疆鍒犻櫎/鎵撳嵃/缂栬緫鏄惁鏄剧ず
     setBottonView() {
@@ -374,6 +383,20 @@
           })
         }
       })
+    },
+    // 涓婃灦瑙勫垯
+    listingRulesClick() {
+      this.$refs.form.validate((valid) => {
+        if (valid) {
+          this.$router.push({
+            path: "/warehouseManage/listingRules",
+            query: {
+              categoryName: this.editConfig.infomation.name,
+              id: this.editConfig.title === "鏂板缓" ? "" : this.editConfig.infomation.id
+            }
+          })
+        }
+      })
     }
   }
 }
diff --git a/src/views/warehouseManage/listingRules/index.vue b/src/views/warehouseManage/listingRules/index.vue
index 6e0c9d6..de53dd3 100644
--- a/src/views/warehouseManage/listingRules/index.vue
+++ b/src/views/warehouseManage/listingRules/index.vue
@@ -4,12 +4,14 @@
       <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">
@@ -89,15 +91,32 @@
       isRowClick: false,
       areaId: 0,
       productId: 0,
-      productCategoryId:0,
+      productCategoryId: 0,
       subLocationId: 0,
       currentRowId: 0,
-      rowIndex:-1,
-      RuleType:0,
+      rowIndex: -1,
+      RuleType: 0,
+      queryProductId: null,
+      categoryId: null,
+      searchTaskMap: []
     }
   },
   created() {
     this.setTable()
+    let query = this.$route.query
+    if (query) {
+      console.log("aaaaaaaaaaaaa", 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: {
@@ -109,7 +128,7 @@
         tableColumn: [
           { label: "褰撲骇鍝佸埌杈�", prop: "areaName", location: true },
           { label: "浜у搧", prop: "productName", product: true },
-          { label: "浜у搧绫诲埆", prop: "productCategory",productType: true },
+          { label: "浜у搧绫诲埆", prop: "productCategory", productType: true },
           { label: "瀛樺偍鍒板瓙浣嶇疆", prop: "subLocation", location: true }
           // { label: "鍏徃", prop: "companyName", company: true }
         ]
@@ -118,7 +137,8 @@
     // 璇锋眰鏁版嵁
     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) => {
@@ -151,8 +171,8 @@
     },
     // 鏂板
     addProductClick() {
-      this.tableList.tableColumn[1].product=true
-      this.tableList.tableColumn[2].productType=true
+      this.tableList.tableColumn[1].product = true
+      this.tableList.tableColumn[2].productType = true
       console.log(this.tableData)
       this.isSel()
       if (this.isNoProduct && this.addTitle === "鏂板缓") {
@@ -181,7 +201,7 @@
       } else {
         if (this.areaId === 0) {
           this.$message.error("璇烽�夋嫨褰撳墠浜у搧鍒拌揪浣嶇疆")
-        } else if (this.productId === 0 && this.productCategoryId==='') {
+        } else if (this.productId === 0 && this.productCategoryId === "") {
           this.$message.error("璇烽�夋嫨浜у搧鎴栦骇鍝佺被鍒�")
         } else if (this.subLocationId === 0) {
           this.$message.error("璇烽�夋嫨瀛樺偍鍒板瓙浣嶇疆")
@@ -200,12 +220,12 @@
           })
           let requestUrl = this.currentRowId === 0 ? addListingRules : updateListingRules
           requestUrl({
-              RuleType:this.RuleType,
-              id: this.currentRowId,
-              areaId: this.areaId,
-              locationId: this.subLocationId,
-              productCategoryId: this.productCategoryId||'',
-              productId: this.productId||''
+            RuleType: this.RuleType,
+            id: this.currentRowId,
+            areaId: this.areaId,
+            locationId: this.subLocationId,
+            productCategoryId: this.productCategoryId || "",
+            productId: this.productId || ""
           }).then((res) => {
             console.log(res)
             if (res.code === 200) {
@@ -230,8 +250,8 @@
     },
     // 鍙栨秷
     discardBtnClick() {
-      this.tableList.tableColumn[1].product=true
-      this.tableList.tableColumn[2].productType=true
+      this.tableList.tableColumn[1].product = true
+      this.tableList.tableColumn[2].productType = true
       if (this.isRowClick) {
         this.tableData.map((item) => {
           item.isEdit = true
@@ -275,12 +295,12 @@
     },
     // 琛岀偣鍑�
     tableRowClick(row, rowIndex) {
-      this.rowIndex=rowIndex
+      this.rowIndex = rowIndex
       this.isSel()
       if (!this.isNoProduct && this.currentRowId === 0) {
         this.$message.error("璇峰畬鎴愬綋鍓嶆柊寤烘垨鍙栨秷鏂板缓")
       } else {
-        this.tableList.tableColumn[2].productType=true
+        this.tableList.tableColumn[2].productType = true
         this.currentRowId = row.id
         this.addTitle = "淇濆瓨"
         this.showDiscard = true
@@ -300,14 +320,17 @@
         this.subLocationId = row.locationId
         this.productCategoryId = row.productCategoryId
         this.productId = row.productId
-        if(this.tableList.tableData[rowIndex].productName===""||this.tableList.tableData[rowIndex].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
+        if (
+          this.tableList.tableData[rowIndex].productName === "" ||
+          this.tableList.tableData[rowIndex].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
         }
-    }
+      }
     },
     // 鎼滅储
     getList(val) {
@@ -343,22 +366,22 @@
     },
     // 閫変腑浜у搧鏂规硶
     selProductClick(item) {
-      console.log(item,"浜у搧")
-      this.RuleType=1
-      this.tableList.tableColumn[2].productType=false
+      console.log(item, "浜у搧")
+      this.RuleType = 1
+      this.tableList.tableColumn[2].productType = false
       this.productId = item.value
       this.productCategoryId = item.categoryId
     },
     // 閫変腑浜у搧绫诲瀷鏂规硶
     selProductTypeClick(item) {
-      this.RuleType=2
-      if(this.currentRowId===0){
-        this.productCategoryId=item.value
-      }else{
-        this.tableList.tableColumn[1].product=false
-        this.tableList.tableData[this.rowIndex].productName=' '
-        this.productId=''
-        this.productCategoryId=this.tableList.tableData[this.rowIndex].productCategoryId
+      this.RuleType = 2
+      if (this.currentRowId === 0) {
+        this.productCategoryId = item.value
+      } else {
+        this.tableList.tableColumn[1].product = false
+        this.tableList.tableData[this.rowIndex].productName = " "
+        this.productId = ""
+        this.productCategoryId = this.tableList.tableData[this.rowIndex].productCategoryId
       }
     },
     // 鍒犻櫎
@@ -370,16 +393,22 @@
           this.getData()
         }
       })
+    },
+    // 鍒犻櫎浜у搧绫诲瀷
+    delSelectClick() {
+      this.categoryId = 0
+      this.queryProductId = ""
+      this.getData()
     }
   },
-  watch:{
-    rowIndex(newVal){
-      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
+  watch: {
+    rowIndex(newVal) {
+      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
       }
     }
   }

--
Gitblit v1.8.0