From 0f8844dcb400fcdee4ea7831336a6aff382a8cc2 Mon Sep 17 00:00:00 2001
From: songshankun <songshankun@foxmail.com>
Date: 星期六, 23 九月 2023 14:59:16 +0800
Subject: [PATCH] fix: 修复搜索供应商列表结果为空时产品列表不为空的bug, 修复产品列表翻页后搜索供应商时产品列表页码未重置的bug, 修复供应商列表/产品列表/采购订单/质检单/退货单翻页后再搜索页码未重置的bug

---
 src/views/productManage/product/index.vue |  149 ++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 108 insertions(+), 41 deletions(-)

diff --git a/src/views/productManage/product/index.vue b/src/views/productManage/product/index.vue
index 60844cb..53eef98 100644
--- a/src/views/productManage/product/index.vue
+++ b/src/views/productManage/product/index.vue
@@ -1,20 +1,37 @@
 <template>
-  <div class="rightContent">
-    <div class="top">
-      <div class="supplier-search">
-        <SearchCommonView
-          ref="searchCommonView"
-          :search-options="searchOptions"
-          @searchClick="searchClick"
-          @resetClick="resetClick"
+  <div class="product-manage">
+    <div class="filter">
+      <div class="filter-card">
+<!--              <SearchCommonView-->
+<!--                  ref="searchCommonView"-->
+<!--                  :search-options="searchOptions"-->
+<!--                  @searchClick="searchClick"-->
+<!--                  @resetClick="resetClick"-->
+<!--              />-->
+
+        <CommonSearch
+          :show-add="false"
+          :show-download="false"
+          :amount-view="false"
+          :show-action-btn="false"
+          :placeholder="'璇疯緭鍏ヤ骇鍝佸悕绉�/渚涘簲鍟�'"
+          @searchClick="onFilterSearch"
         />
+
         <div class="add-view">
-          <!-- <el-button type="primary" size="mini" @click="addBtnClick">鏂板缓</el-button> -->
+          <!--           <el-button type="primary" size="mini" @click="addBtnClick">鏂板缓</el-button>-->
         </div>
       </div>
-      <template>
+    </div>
+    <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">
@@ -25,11 +42,11 @@
           </template> -->
           </TableCommonView>
         </div>
-
         <div class="btn-pager">
           <PagerView class="page" :pager-options="pagerOptions" v-on="pagerEvents" />
         </div>
-      </template>
+      </div>
+
     </div>
     <!-- 鏂板缓/缂栬緫浜у搧 -->
     <AddProduct v-if="editConfig.visible" :add-common-config="editConfig" />
@@ -52,6 +69,7 @@
   computed: {},
   data() {
     return {
+      searchText:'',
       tableList: {},
       searchOptions: [],
       commonDetail: {
@@ -63,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() {
@@ -71,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
@@ -95,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) => {
@@ -115,13 +151,20 @@
       })
     },
     // 鎼滅储
-    searchClick(val, content) {
-      console.log(val, content)
-      this.getData(val.value, content)
-    },
-    resetClick() {
+    // searchClick(val, content) {
+    //   console.log(val, content)
+    //   this.getData(val.value, content)
+    // },
+
+    onFilterSearch(val){
+      this.searchText = val ?? ''
+      this.pagerOptions.currPage = 1
       this.getData()
     },
+
+    // resetClick() {
+    //   this.getData()
+    // },
     // 鏂板缓
     addBtnClick() {
       this.editConfig.visible = true
@@ -165,14 +208,37 @@
 
 <!-- Add "scoped" attribute to limit CSS to this component only -->
 <style lang="scss" scoped>
-.rightContent {
+.product-manage{
   height: 100%;
-  background: #f0f2f5;
-  padding: 10px;
-  .top {
-    margin-bottom: 20px;
-    height: calc(100% - 30px);
-    background: #fff;
+  overflow: hidden;
+  .filter{
+    height: 80px;
+    display: flex;
+    align-items: center;
+    padding: 12px 20px 0 20px;
+    &-card{
+      height: 80px;
+      display: flex;
+      align-items: center;
+      box-sizing: border-box;
+      padding: 10px 20px;
+      flex: 1;
+      border-radius: 12px;
+      background-color: #fff;
+    }
+  }
+  .body{
+    box-sizing: border-box;
+    padding: 10px 20px;
+    border-radius: 12px;
+    height: calc(100% - 92px);
+    .body-card {
+      background-color: #fff;
+      border-radius: 12px;
+      height: 100%;
+      overflow: hidden;
+    }
+
     .supplier-search {
       display: flex;
       align-items: center;
@@ -182,7 +248,8 @@
       }
     }
     .list-view {
-      height: calc(100% - 120px);
+      height: calc(100% - 60px);
+      overflow: hidden;
     }
     .btn-pager {
       display: flex;

--
Gitblit v1.8.0