From c35ccb51c02c8852e345b831ef5d2dd96c2cf500 Mon Sep 17 00:00:00 2001
From: haoxuan <haoxuan>
Date: 星期三, 30 八月 2023 16:39:33 +0800
Subject: [PATCH] Merge branch 'master' of ssh://192.168.5.5:29418/web/SRM

---
 src/views/supplierManage/supplier/index.vue |  302 ++++++++++++++++++++++++++++++++++---------------
 1 files changed, 208 insertions(+), 94 deletions(-)

diff --git a/src/views/supplierManage/supplier/index.vue b/src/views/supplierManage/supplier/index.vue
index 5aa9d44..77a5721 100644
--- a/src/views/supplierManage/supplier/index.vue
+++ b/src/views/supplierManage/supplier/index.vue
@@ -13,23 +13,49 @@
         </div>
       </div>
       <template>
-        <TableCommonView
-          ref="tableListRef"
-          :table-list="tableList"
-          @selCommonClick="selCommonClick"
-          @getSelectArray="getSelectArray"
+        <el-table
+          ref="tableSupplier"
+          border
+          :data="tableList.tableInfomation"
+          tooltip-effect="dark"
+          style="width: 100%"
+          :lazy="tableList.lazy"
+          highlight-current-row
+          @row-click="tableRowClick"
+          :header-cell-style="{ background: '#ECF4FF', color: '#666' }"
         >
-          <template slot="tableButton">
-            <el-table-column label="鎿嶄綔" width="120">
-              <template slot-scope="scope">
-                <el-button @click="handleClick(scope.row)" type="text" size="small">鍚敤</el-button>
-                <el-button @click="followupClick(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>
-        </TableCommonView>
+          <el-table-column type="index" label="搴忓彿" width="50"> </el-table-column>
+          <el-table-column
+            v-for="(item, i) in tableList.tableColumn"
+            :key="i"
+            :prop="item.prop"
+            :label="item.label"
+            :width="item.width"
+            :min-width="item.min"
+            show-overflow-tooltip
+            :sortable="item.sortable"
+          >
+            <template slot-scope="scope">
+              <div v-if="item.status" :class="scope.row.status">{{ scope.row[item.prop] }}</div>
+              <span
+                v-else-if="item.isCommonClick && scope.row[item.prop]"
+                class="sel-name"
+                @click="selCommonClick(scope.row)"
+                >{{ scope.row[item.prop] }}</span
+              >
+              <span v-else>{{ scope.row[item.prop] ? scope.row[item.prop] : "--" }}</span>
+            </template>
+          </el-table-column>
+          <el-table-column label="鎿嶄綔" width="100">
+            <template slot-scope="scope">
+              <el-button v-if="scope.row.status === 0" @click="enableClick(scope.row, '鍚敤')" type="text" size="small"
+                >鍚敤</el-button
+              >
+              <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>
+            </template>
+          </el-table-column>
+        </el-table>
         <div class="btn-pager">
           <PagerView class="page" :pager-options="pagerOptions" v-on="pagerEvents" />
         </div>
@@ -45,52 +71,59 @@
           class="search"
           ref="searchCommonView"
           :search-options="searchProductOptions"
-          @searchClick="searchClick"
-          @resetClick="resetClick"
+          @searchClick="searchProductClick"
+          @resetClick="resetProductClick"
         />
         <div class="add-view">
-          <el-button type="primary" size="mini">鏂板缓</el-button>
+          <el-button type="primary" size="mini" @click="addNewProductClick">娣诲姞鏂颁骇鍝�</el-button>
         </div>
       </div>
       <template>
         <TableCommonView
-          ref="tableListRef"
+          ref="tableListProduct"
           :table-list="productTableList"
           @selCommonClick="selCommonClick"
           @getSelectArray="getSelectArray"
         >
           <template slot="tableButton">
-            <el-table-column label="鎿嶄綔" width="120">
+            <el-table-column label="鎿嶄綔" width="170">
               <template slot-scope="scope">
-                <el-button @click="handleClick(scope.row)" type="text" size="small">鐩稿叧渚涘簲鍟�</el-button>
-                <el-button @click="followupClick(scope.row)" type="text" size="small">淇敼</el-button>
+                <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>
         </TableCommonView>
         <div class="btn-pager">
-          <PagerView class="page" :pager-options="pagerOptions" v-on="pagerEvents" />
+          <PagerView class="page" :pager-options="productPagerOptions" v-on="pagerEvents" />
         </div>
       </template>
     </div>
     <!-- 鏂板缓/缂栬緫閿�鍞嚎绱� -->
-    <!-- <AddSalesLeadDialog v-if="editSalesLeadConfig.visible" :edit-rightContent-config="editSalesLeadConfig" /> -->
+    <AddSupplier v-if="editConfig.visible" :add-common-config="editConfig" />
     <!-- 璇︽儏 -->
     <DetailSupplier v-if="commonDetail.visible" :common-detail="commonDetail" />
+    <!-- 鐩稿叧渚涘簲鍟� -->
+    <RaleteSupplierList v-if="raleteSupplierConfig.visible" :common-config="raleteSupplierConfig" />
+    <!-- 娣诲姞鏂颁骇鍝� -->
+    <AddNewProduct v-if="newProductConfig.visible" :add-common-config="newProductConfig" />
   </div>
 </template>
 
 <script>
 import pageMixin from "@/components/makepager/pager/mixin/pageMixin"
-import { getSalesLeadsList, getDeleteSalesLeads } from "@/api/client/salesLead"
+import { getSupplierList, changeSupplierStatus } from "@/api/supplierManage/supplier"
 import DetailSupplier from "@/views/supplierManage/supplier/DetailSupplier"
+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",
   props: {},
-  components: { DetailSupplier },
+  components: { DetailSupplier, AddSupplier, RaleteSupplierList, AddNewProduct },
   mixins: [pageMixin],
   computed: {},
   data() {
@@ -109,7 +142,21 @@
         title: "鏂板缓",
         infomation: {}
       },
-      search_map: {}
+      raleteSupplierConfig: {
+        visible: false,
+        infomation: {}
+      },
+      newProductConfig: {
+        visible: false,
+        title: "娣诲姞",
+        infomation: {}
+      },
+      productPagerOptions: {
+        currPage: 1,
+        pageSize: 10,
+        totalCount: 0
+      },
+      supplierId: 0
     }
   },
   created() {
@@ -122,14 +169,15 @@
       this.tableList = {
         tableInfomation: [],
         selectIndex: true,
+        ref: "tableListRef",
         tableColumn: [
           { label: "渚涘簲鍟嗙紪鍙�", prop: "number", min: 190, isCommonClick: true },
           { 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: "supplierType", min: 130 },
+          { label: "鎵�灞炶涓�", prop: "industry", min: 130 },
+          { label: "鑱旂郴浜�", prop: "contact", min: 130 },
+          { label: "鑱旂郴鐢佃瘽", prop: "phone", min: 130 },
+          { label: "鐘舵��", prop: "status_name", min: 130 },
           { label: "鍒涘缓鏃堕棿", prop: "member_name", min: 130 }
         ]
       }
@@ -146,13 +194,13 @@
         selectBox: true,
         selectIndex: true,
         tableColumn: [
-          { label: "浜у搧缂栫爜", prop: "name", min: 190, isSalesLeadClick: true },
-          { label: "浜у搧鍚嶇О", prop: "number", 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: "number", min: 190 },
+          { label: "浜у搧鍚嶇О", prop: "name", 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 = []
@@ -163,87 +211,149 @@
       }
     },
     // 璇锋眰鏁版嵁
-    async getData() {
-      await getSalesLeadsList({
-        search_map: this.search_map,
+    async getData(val, content) {
+      this.getSupplierList(val, content)
+    },
+    // 渚涘簲鍟嗗垪琛�
+    async getSupplierList(val, content) {
+      await getSupplierList({
+        [val]: content,
         page: this.pagerOptions.currPage,
         pageSize: this.pagerOptions.pageSize
-      })
-        .then((res) => {
-          const list = res.data.list.map((item) => {
+      }).then((res) => {
+        console.log(res.data)
+        if (res.data.code === 200) {
+          const list = res.data.data.list.map((item) => {
             return {
               ...item,
-              province: item.Province.name,
-              city: item.City.name,
-              sales_resources: item.sales_sources.name,
-              member_name: item.member.username
+              status_name: item.status === 0 ? "鏈惎鐢�" : "鍚敤"
             }
           })
           this.tableList.tableInfomation = list || []
-          this.pagerOptions.totalCount = res.data.count
-        })
-        .catch((err) => {
-          console.log(err)
-        })
+          this.pagerOptions.totalCount = res.data.data.total
+          if (list && list.length > 0) {
+            this.supplierId = this.tableList.tableInfomation[0].ID
+          } else {
+            this.supplierId = 0
+          }
+          this.$nextTick(() => {
+            this.$refs.tableSupplier.setCurrentRow(this.tableList.tableInfomation[0])
+          })
+          this.getProductList()
+        }
+      })
     },
-    // 鎼滅储
+    // 浜у搧鍒楄〃
+    async getProductList(val, content) {
+      console.log(val, content)
+      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.search_map = {
-        [val.value]: content
-      }
-      this.getData()
+      this.getSupplierList(val.value, content)
     },
     resetClick() {
-      this.search_map = {}
-      this.getData()
+      this.getSupplierList()
+    },
+    // 鎼滅储浜у搧
+    searchProductClick(val, content) {
+      console.log(val, content)
+      this.getProductList(val.value, content)
+    },
+    resetProductClick() {
+      this.getProductList()
     },
     // 鏂板缓渚涘簲鍟�
-    addBtnClick() {},
-    // 缂栬緫渚涘簲鍟�
-    handleClick(row) {
-      console.log(row)
+    addBtnClick() {
+      this.editConfig.visible = true
+      this.editConfig.title = "鏂板缓"
+      this.editConfig.infomation = { fileId: 0 }
+    },
+    // 鍚敤渚涘簲鍟�
+    async enableClick(row, value) {
+      let status = value === "鍚敤" ? 1 : 0
+      await changeSupplierStatus({
+        id: row.ID,
+        status: status
+      }).then((res) => {
+        if (res.code === 200) {
+          this.$message.success("鐘舵�佷慨鏀规垚鍔�")
+          this.getData()
+        }
+      })
     },
     // 淇敼渚涘簲鍟�
     modifyClick(row) {
-      console.log(row)
-    },
-    // 璺熻繘
-    followupClick(row) {
       this.editConfig.visible = true
-      this.editConfig.title = "鏂板缓"
-      this.editConfig.infomation = { sales_leads_name: row.name }
+      this.editConfig.title = "淇敼"
+      this.editConfig.infomation = { ...row, file_name: row.contract.fileName }
+    },
+    // 鐩稿叧渚涘簲鍟�
+    raleteClick(row) {
+      console.log(row)
+      this.raleteSupplierConfig.visible = true
+      this.raleteSupplierConfig.infomation = { ...row }
+    },
+    // 娣诲姞鏂颁骇鍝�
+    addNewProductClick() {
+      this.newProductConfig.visible = true
+      this.newProductConfig.title = "娣诲姞"
+      this.newProductConfig.infomation = { supplierId: this.supplierId }
+    },
+    // 淇敼浜у搧
+    editClick(row) {
+      console.log(row)
+      this.newProductConfig.visible = true
+      this.newProductConfig.title = "淇敼"
+      this.newProductConfig.infomation = { ...row }
     },
     // 鍒犻櫎
-    delClick() {
-      if (this.selValueList && this.selValueList.length > 0) {
-        this.$confirm("鏄惁纭鍒犻櫎?", "璀﹀憡", {
-          confirmButtonText: "纭畾",
-          cancelButtonText: "鍙栨秷",
-          type: "warning"
-        })
-          .then(() => {
-            console.log("dddd")
-            getDeleteSalesLeads({ ids: 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)
       this.selValueList = []
       const list = val.map((item) => {
         return item.id
       })
       this.selValueList = list
+    },
+    tableRowClick(row) {
+      console.log(row)
+      this.supplierId = row.ID
+      this.getProductList()
     },
     // 璇︽儏
     selCommonClick(row) {
@@ -268,6 +378,10 @@
         margin-right: 20px;
       }
     }
+    .sel-name {
+      color: $color-primary;
+      cursor: pointer;
+    }
     .btn-pager {
       display: flex;
       .page {

--
Gitblit v1.8.0