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

---
 src/views/productManage/productCategory/AddProductCategoryDialog.vue |   19 ++++++++++++++++---
 src/views/productManage/productCategory/index.vue                    |   31 ++++++++++++++++++++++++++-----
 2 files changed, 42 insertions(+), 8 deletions(-)

diff --git a/src/views/productManage/productCategory/AddProductCategoryDialog.vue b/src/views/productManage/productCategory/AddProductCategoryDialog.vue
index 31356cf..1bcd7f4 100644
--- a/src/views/productManage/productCategory/AddProductCategoryDialog.vue
+++ b/src/views/productManage/productCategory/AddProductCategoryDialog.vue
@@ -1,14 +1,14 @@
 <template>
   <div class="add-common">
     <el-dialog
-      :title="editCommonConfig.title + '浜у搧绫诲埆'"
+      :title="modalTitle + '浜у搧绫诲埆'"
       :visible.sync="editConfig.visible"
       :width="dialogWidth"
       :before-close="handleClose"
     >
       <!-- 澶� -->
       <div slot="title" class="dialog-header">
-        <span>{{ editCommonConfig.title + "浜у搧绫诲埆" }}</span>
+        <span>{{ modalTitle + "浜у搧绫诲埆" }}</span>
         <div class="header_btns">
           <!-- <span class="btn">
             <i class="el-icon-printer"></i>
@@ -183,7 +183,8 @@
         return {
           visible: false,
           title: "鏂板缓",
-          infomation: { type: [] }
+          infomation: { type: [] },
+          autoEdit: false,
         }
       }
     },
@@ -199,6 +200,15 @@
     productCategoryListWithDefault(){
       console.log(this.productCategoryList)
       return [{id:0,name:'璇烽�夋嫨'},...(this.productCategoryList?? [])]
+    },
+    modalTitle(){
+      if (this.editConfig.title === '缂栬緫' && this.editConfig.autoEdit){
+        return '缂栬緫'
+      }else if (this.editConfig.title === '缂栬緫') {
+        return !this.showEdit ? '缂栬緫' : '鏌ョ湅'
+      }else {
+        return '鏂板缓'
+      }
     }
   },
   data() {
@@ -227,6 +237,9 @@
   created() {
     this.setBottonView()
     this.getProductCount()
+    if (this.editConfig.autoEdit){
+      this.editClick()
+    }
   },
   methods: {
     // 鑾峰彇浜у搧鏁伴噺
diff --git a/src/views/productManage/productCategory/index.vue b/src/views/productManage/productCategory/index.vue
index 0f14b1c..7d77f4e 100644
--- a/src/views/productManage/productCategory/index.vue
+++ b/src/views/productManage/productCategory/index.vue
@@ -15,8 +15,20 @@
           ref="tableListRef"
           :table-list="tableList"
           :show-checkcol="false"
-          @tableRowClick="tableRowClick"
-        ></TableCommonView>
+        >
+          <template slot="tableButton">
+            <el-table-column label="鎿嶄綔" width="90" align="center">
+              <template slot-scope="scope">
+                <span @click.stop="showDetail(scope.row)" class="cursor_pointer" style="margin-right: 10px">
+                  <span style="color: #2a78fb">鏌ョ湅</span>
+                </span>
+                <span @click.stop="editRow(scope.row)" class="cursor_pointer">
+                  <span style="color: #2a78fb">缂栬緫</span>
+                </span>
+              </template>
+            </el-table-column>
+          </template>
+        </TableCommonView>
       </div>
       <div class="btn-pager">
         <PagerView class="page" :pager-options="pagerOptions" v-on="pagerEvents" />
@@ -45,7 +57,8 @@
       editConfig: {
         visible: false,
         title: "鏂板缓",
-        infomation: {}
+        infomation: {},
+        autoEdit: false
       }
     }
   },
@@ -93,8 +106,16 @@
       this.pagerOptions.currPage=1
       this.getData()
     },
-    // 琛岀偣鍑�
-    tableRowClick(row) {
+    // 鏌ョ湅
+    showDetail(row) {
+      this.editConfig.autoEdit = false
+      this.editConfig.title = "缂栬緫"
+      this.editConfig.infomation = { ...row }
+      this.editConfig.visible = true
+    },
+    // 缂栬緫
+    editRow(row){
+      this.editConfig.autoEdit = true
       this.editConfig.title = "缂栬緫"
       this.editConfig.infomation = { ...row }
       this.editConfig.visible = true

--
Gitblit v1.8.0