From 890781f6894a4af2558e41cc5c9660477b68b9c5 Mon Sep 17 00:00:00 2001
From: yangfeng <wanwan926_4@163.com>
Date: 星期三, 01 十一月 2023 19:28:08 +0800
Subject: [PATCH] 公共搜索组件修改、供应商列表及添加产品搜索框修改

---
 src/views/productManage/product/index.vue |   77 +++++++++++++++++++++++++-------------
 1 files changed, 50 insertions(+), 27 deletions(-)

diff --git a/src/views/productManage/product/index.vue b/src/views/productManage/product/index.vue
index d6a3029..53eef98 100644
--- a/src/views/productManage/product/index.vue
+++ b/src/views/productManage/product/index.vue
@@ -26,7 +26,12 @@
     <div class="body">
       <div class="body-card">
         <div class="list-view">
-          <TableCommonView ref="tableListRef" :table-list="tableList" @selCommonClick="selCommonClick">
+          <TableCommonView
+            ref="tableListRef"
+            :table-list="tableList"
+            @selCommonClick="selCommonClick"
+            @selTableCol="selTableCol"
+          >
             <!-- <template slot="tableButton">
             <el-table-column label="鎿嶄綔" width="120">
               <template slot-scope="scope">
@@ -76,7 +81,20 @@
         visible: false,
         title: "鏂板缓",
         infomation: {}
-      }
+      },
+      tableColumn: [
+        { label: "浜у搧缂栫爜", prop: "number", min: 190, isCommonClick: true },
+        { label: "浜у搧鍚嶇О", prop: "name", min: 130 ,default:true},
+        { label: "渚涘簲鍟�", prop: "supplierName", min: 130 },
+        { label: "浜у搧绫诲埆", prop: "productType", min: 130 },
+        { label: "瑙勬牸", prop: "specifications", min: 130 },
+        { label: "鍨嬪彿", prop: "modelNumber", min: 130 },
+        { label: "鍗曚綅", prop: "unit", min: 60 },
+        { label: "浠锋牸", prop: "purchasePrice", min: 130 },
+        { label: "鏈�浣庡簱瀛�", prop: "minimumStock", min: 80 },
+        { label: "鏈�楂樺簱瀛�", prop: "maximumStock", min: 80 }
+      ],
+      showCol: ['浜у搧缂栫爜', '浜у搧鍚嶇О', '渚涘簲鍟�', '浜у搧绫诲埆', '瑙勬牸', '浠锋牸', '鏈�浣庡簱瀛�', '鏈�楂樺簱瀛�']
     }
   },
   created() {
@@ -84,23 +102,24 @@
     this.getData()
   },
   methods: {
+    setColumnVisible(showCol){
+      return  this.tableColumn.map(ele=>{
+        return {
+          ...ele,
+          isShowColumn:showCol.includes(ele.label)
+        }
+      })
+    },
     setTable() {
       this.tableList = {
         tableInfomation: [],
         selectIndex: true,
-        tableColumn: [
-          { label: "浜у搧缂栫爜", prop: "number", min: 190, isCommonClick: true },
-          { label: "浜у搧鍚嶇О", prop: "name", min: 130 },
-          { label: "渚涘簲鍟�", prop: "supplierNumber", min: 130 },
-          { label: "浜у搧绫诲埆", prop: "productType", min: 130 },
-          { label: "瑙勬牸", prop: "specifications", min: 130 },
-          { label: "鍨嬪彿", prop: "modelNumber", min: 130 },
-          { label: "鍗曚綅", prop: "unit", min: 60 },
-          { label: "浠锋牸", prop: "purchasePrice", min: 130 },
-          { label: "鏈�浣庡簱瀛�", prop: "minimumStock", min: 80 },
-          { label: "鏈�楂樺簱瀛�", prop: "maximumStock", min: 80 }
-        ]
+        showcol: this.showCol,
+        allcol: [],
+        tableColumn:this.setColumnVisible(this.showCol)
       }
+      this.tableList.allcol = this.tableList.tableColumn.filter(ele=>!ele.default).map(ele=>ele.label);
+
       this.searchOptions = []
       for (let i = 0; i < this.tableList.tableColumn.length; i++) {
         const label = this.tableList.tableColumn[i].label
@@ -108,10 +127,14 @@
         this.searchOptions.push({ value: value, label: label })
       }
     },
+    selTableCol(val) {
+      this.showcol = val;
+      this.tableList.tableColumn = this.setColumnVisible(val);
+    },
     // 璇锋眰鏁版嵁
-    async getData(val, content) {
+    async getData() {
       await getProductList({
-        [val]: content,
+        keyword: this.searchText,
         page: this.pagerOptions.currPage,
         pageSize: this.pagerOptions.pageSize
       }).then((res) => {
@@ -128,22 +151,20 @@
       })
     },
     // 鎼滅储
-    searchClick(val, content) {
-      console.log(val, content)
-      this.getData(val.value, content)
-    },
+    // searchClick(val, content) {
+    //   console.log(val, content)
+    //   this.getData(val.value, content)
+    // },
 
     onFilterSearch(val){
       this.searchText = val ?? ''
-      console.log(this.searchText)
-
-      // TODO: 闇�瑕佹帴鍙f敮鎸�
-      throw new Error("鍔熻兘鏈疄鐜�")
-    },
-
-    resetClick() {
+      this.pagerOptions.currPage = 1
       this.getData()
     },
+
+    // resetClick() {
+    //   this.getData()
+    // },
     // 鏂板缓
     addBtnClick() {
       this.editConfig.visible = true
@@ -199,6 +220,8 @@
       height: 80px;
       display: flex;
       align-items: center;
+      box-sizing: border-box;
+      padding: 10px 20px;
       flex: 1;
       border-radius: 12px;
       background-color: #fff;

--
Gitblit v1.8.0