From fbe9459ed908eef6c25c3bcd244d0a7e74dfa792 Mon Sep 17 00:00:00 2001
From: songshankun <songshankun@foxmail.com>
Date: 星期四, 19 十月 2023 13:45:08 +0800
Subject: [PATCH] feat: 产品列表添加查看编辑按钮;弹窗根据情况展示对应标题

---
 src/views/productManage/productCategory/AddProductCategoryDialog.vue |   41 ++++++++++++++++++++++++++++++++++-------
 1 files changed, 34 insertions(+), 7 deletions(-)

diff --git a/src/views/productManage/productCategory/AddProductCategoryDialog.vue b/src/views/productManage/productCategory/AddProductCategoryDialog.vue
index 841d7b4..31356cf 100644
--- a/src/views/productManage/productCategory/AddProductCategoryDialog.vue
+++ b/src/views/productManage/productCategory/AddProductCategoryDialog.vue
@@ -36,10 +36,9 @@
         label-position="right"
         label-width="110px"
         size="mini"
-        style="height: 290px; overflow-x: hidden"
       >
         <div class="basic-info">
-          <FormBtnsView :showProduct="true" @productClick="productClick" />
+          <FormBtnsView :showProduct="true" :countObject="statisticsMap" @productClick="productClick" />
           <div class="basic-info-view">
             <!-- <el-row> -->
             <!-- <el-col :span="24">
@@ -89,7 +88,7 @@
                     style="width: 85%"
                     :disabled="!showFooter"
                   >
-                    <el-option v-for="item in productCategoryList" :key="item.id" :label="item.name" :value="item.id">
+                    <el-option v-for="item in productCategoryListWithDefault" :key="item.id" :label="item.name" :value="item.id">
                     </el-option>
                   </el-select>
                 </el-form-item>
@@ -161,9 +160,9 @@
         </div>
       </el-form>
       <!-- 灏� -->
-      <div v-if="showFooter" slot="footer" class="dialog-footer">
+      <div slot="footer" class="dialog-footer">
         <!-- <el-button type="primary" size="small" @click="editConfig.visible = false">淇濆苟鎻愪氦瀹℃壒</el-button> -->
-        <el-button type="primary" size="small" @click="saveClick('form')">淇濆瓨</el-button>
+        <el-button type="primary" size="small" @click="saveClick('form')" :disabled="!showFooter">淇濆瓨</el-button>
         <el-button size="small" @click="editConfig.visible = false">鍙栨秷</el-button>
       </div>
     </el-dialog>
@@ -174,6 +173,7 @@
 import { addProductCategory, updateProductCategory, deleteProductCategory } from "@/api/product/productCategory"
 
 import { getDataByType } from "@/api/data"
+import {getProductList} from "@/api/product/product";
 export default {
   name: "AddProductCategoryDialog",
   props: {
@@ -195,7 +195,12 @@
     }
   },
   components: {},
-  computed: {},
+  computed: {
+    productCategoryListWithDefault(){
+      console.log(this.productCategoryList)
+      return [{id:0,name:'璇烽�夋嫨'},...(this.productCategoryList?? [])]
+    }
+  },
   data() {
     return {
       dialogWidth: "50%",
@@ -213,13 +218,35 @@
       showButton: true,
       showEdit: false, // 鏄惁鏄剧ず缂栬緫鎸夐挳
       isDelClick: false, // 鍒犻櫎鎸夐挳鏄惁鍙偣鍑�
-      showFooter: false // 鏄惁鏄剧ず鍙栨秷淇濆瓨
+      showFooter: false, // 鏄惁鏄剧ず鍙栨秷淇濆瓨,
+      statisticsMap:{
+        product: 0 // 浜у搧鏁伴噺
+      }
     }
   },
   created() {
     this.setBottonView()
+    this.getProductCount()
   },
   methods: {
+    // 鑾峰彇浜у搧鏁伴噺
+    getProductCount(){
+      getProductList({
+        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
+      })
+    },
     // 璁剧疆鍒犻櫎/鎵撳嵃/缂栬緫鏄惁鏄剧ず
     setBottonView() {
       if (this.editConfig.title === "鏂板缓") {

--
Gitblit v1.8.0