From 8380b537474be9b9aa24efcd65c730e2907b9b8b Mon Sep 17 00:00:00 2001
From: yangfeng <wanwan926_4@163.com>
Date: 星期六, 26 八月 2023 18:07:48 +0800
Subject: [PATCH] 服务商相关接口联调

---
 src/views/supplierManage/supplier/index.vue |  117 ++++++++++++++++++++++++++++++----------------------------
 1 files changed, 61 insertions(+), 56 deletions(-)

diff --git a/src/views/supplierManage/supplier/index.vue b/src/views/supplierManage/supplier/index.vue
index 00e1117..1d45a91 100644
--- a/src/views/supplierManage/supplier/index.vue
+++ b/src/views/supplierManage/supplier/index.vue
@@ -17,7 +17,7 @@
           ref="tableListRef"
           :table-list="tableList"
           @selCommonClick="selCommonClick"
-          @getSelectArray="getSelectArray"
+          @tableRowClick="tableRowClick"
         >
           <template slot="tableButton">
             <el-table-column label="鎿嶄綔" width="120">
@@ -31,7 +31,6 @@
                 >
                 <el-button v-else @click="enableClick(scope.row, '鍋滅敤')" type="text" size="small">鍋滅敤</el-button>
                 <el-button @click="modifyClick(scope.row)" type="text" size="small">淇敼</el-button>
-                <!-- <el-button @click="delClick(scope.row.id)" type="text" size="small">鍒犻櫎</el-button> -->
               </template>
             </el-table-column>
           </template>
@@ -60,7 +59,7 @@
       </div>
       <template>
         <TableCommonView
-          ref="tableListRef"
+          ref="tableListProduct"
           :table-list="productTableList"
           @selCommonClick="selCommonClick"
           @getSelectArray="getSelectArray"
@@ -71,7 +70,6 @@
                 <el-button @click="raleteClick(scope.row)" type="text" size="small">鐩稿叧渚涘簲鍟�</el-button>
                 <el-button @click="editClick(scope.row)" type="text" size="small">淇敼</el-button>
                 <el-button @click="delClick(scope.row)" type="text" size="small">鍒犻櫎</el-button>
-                <!-- <el-button @click="delClick(scope.row.id)" type="text" size="small">鍒犻櫎</el-button> -->
               </template>
             </el-table-column>
           </template>
@@ -99,6 +97,7 @@
 import AddSupplier from "@/views/supplierManage/supplier/AddSupplier"
 import RaleteSupplierList from "@/views/supplierManage/supplier/RaleteSupplierList"
 import AddNewProduct from "@/views/supplierManage/supplier/AddNewProduct"
+import { getProductList, deleteProduct } from "@/api/productManage/product"
 
 export default {
   name: "SupplierManage",
@@ -135,7 +134,8 @@
         currPage: 1,
         pageSize: 10,
         totalCount: 0
-      }
+      },
+      supplierId: 0
     }
   },
   created() {
@@ -148,6 +148,7 @@
       this.tableList = {
         tableInfomation: [],
         selectIndex: true,
+        ref: "tableListRef",
         tableColumn: [
           { label: "渚涘簲鍟嗙紪鍙�", prop: "number", min: 190, isCommonClick: true },
           { label: "渚涘簲鍟嗗悕绉�", prop: "name", min: 130 },
@@ -168,21 +169,17 @@
     },
     setProductTable() {
       this.productTableList = {
-        tableInfomation: [
-          {
-            number: "aaaaa"
-          }
-        ],
+        tableInfomation: [],
         selectBox: true,
         selectIndex: true,
         tableColumn: [
           { label: "浜у搧缂栫爜", prop: "number", min: 190 },
           { label: "浜у搧鍚嶇О", prop: "name", min: 130 },
-          { label: "浜у搧瑙勬牸", prop: "contact_name", min: 130 },
-          { label: "鍗曚綅", prop: "contact_phone", min: 130 },
-          { label: "閲囪喘浠锋牸", prop: "sales_resources", min: 130 },
-          { label: "渚涜揣鏃堕暱(澶�)", prop: "province", min: 130 },
-          { label: "鐗╂祦鏃堕暱(澶�)", prop: "city", min: 130 }
+          { label: "浜у搧瑙勬牸", prop: "specifications", min: 130 },
+          { label: "鍗曚綅", prop: "unit", min: 130 },
+          { label: "閲囪喘浠锋牸", prop: "purchasePrice", min: 130 },
+          { label: "渚涜揣鏃堕暱(澶�)", prop: "deliveryTime", min: 130 },
+          { label: "鐗╂祦鏃堕暱(澶�)", prop: "shippingDuration", min: 130 }
         ]
       }
       this.searchProductOptions = []
@@ -193,15 +190,8 @@
       }
     },
     // 璇锋眰鏁版嵁
-    async getData(val, content, searchName) {
-      if (searchName === "渚涘簲鍟�") {
-        this.getSupplierList(val, content)
-      } else if (searchName === "浜у搧") {
-        this.getProductList(val, content)
-      } else {
-        this.getSupplierList()
-        this.getProductList()
-      }
+    async getData(val, content) {
+      this.getSupplierList(val, content)
     },
     // 渚涘簲鍟嗗垪琛�
     async getSupplierList(val, content) {
@@ -220,35 +210,49 @@
           })
           this.tableList.tableInfomation = list || []
           this.pagerOptions.totalCount = res.data.data.total
+          if (list && list.length > 0) {
+            this.supplierId = this.tableList.tableInfomation[0].ID
+          } else {
+            this.supplierId = 0
+          }
+          this.getProductList()
         }
       })
     },
     // 浜у搧鍒楄〃
     async getProductList(val, content) {
       console.log(val, content)
-      // await getProductList({
-      //   [val]: content,
-      //   page: this.productPagerOptions.currPage,
-      //   pageSize: this.productPagerOptions.pageSize
-      // }).then((res) => {
-      //   console.log(res.data)
-      // })
+      await getProductList({
+        [val]: content,
+        supplierId: this.supplierId,
+        page: this.productPagerOptions.currPage,
+        pageSize: this.productPagerOptions.pageSize
+      }).then((res) => {
+        console.log(res.data)
+        const list = res.data.data.list.map((item) => {
+          return {
+            ...item
+          }
+        })
+        this.productTableList.tableInfomation = list || []
+        this.productPagerOptions.totalCount = res.data.data.total
+      })
     },
     // 鎼滅储渚涘簲鍟�
     searchClick(val, content) {
       console.log(val, content)
-      this.getData(val.value, content, "渚涘簲鍟�")
+      this.getSupplierList(val.value, content)
     },
     resetClick() {
-      this.getData("", "", "渚涘簲鍟�")
+      this.getSupplierList()
     },
     // 鎼滅储浜у搧
     searchProductClick(val, content) {
       console.log(val, content)
-      this.getData(val.value, content, "浜у搧")
+      this.getProductList(val.value, content)
     },
     resetProductClick() {
-      this.getData("", "", "浜у搧")
+      this.getProductList()
     },
     // 鏂板缓渚涘簲鍟�
     addBtnClick() {
@@ -293,28 +297,24 @@
       // this.newProductConfig.title = "淇敼"
     },
     // 鍒犻櫎
-    delClick() {
-      if (this.selValueList && this.selValueList.length > 0) {
-        this.$confirm("鏄惁纭鍒犻櫎?", "璀﹀憡", {
-          confirmButtonText: "纭畾",
-          cancelButtonText: "鍙栨秷",
-          type: "warning"
-        })
-          .then(() => {
-            console.log("dddd")
-            // deleteSupplier({ id: this.selValueList }).then((response) => {
-            //   if (response.code === 200) {
-            //     this.$message.success("鍒犻櫎鎴愬姛")
-            //     this.getData()
-            //   } else {
-            //     this.$message.warning("鍒犻櫎澶辫触")
-            //   }
-            // })
+    delClick(row) {
+      this.$confirm("鏄惁纭鍒犻櫎?", "璀﹀憡", {
+        confirmButtonText: "纭畾",
+        cancelButtonText: "鍙栨秷",
+        type: "warning"
+      })
+        .then(() => {
+          console.log("dddd")
+          deleteProduct({ id: row.ID }).then((response) => {
+            if (response.code === 200) {
+              this.$message.success("鍒犻櫎鎴愬姛")
+              this.getProductList()
+            } else {
+              this.$message.warning("鍒犻櫎澶辫触")
+            }
           })
-          .catch(() => {})
-      } else {
-        this.$message.warning("璇疯嚦灏戦�夋嫨涓�鏉¤褰�")
-      }
+        })
+        .catch(() => {})
     },
     getSelectArray(val) {
       console.log(val)
@@ -324,6 +324,11 @@
       })
       this.selValueList = list
     },
+    tableRowClick(row) {
+      console.log(row)
+      this.supplierId = row.ID
+      this.getProductList()
+    },
     // 璇︽儏
     selCommonClick(row) {
       console.log(row)

--
Gitblit v1.8.0