From 5ecb7958c96d3f0b6d47b79aff7eb306c2cf690f Mon Sep 17 00:00:00 2001
From: charles <981744753@qq.com>
Date: 星期二, 06 八月 2024 11:16:58 +0800
Subject: [PATCH] gitlab上面的wms转移到公司git

---
 src/views/productManage/productCategory/index.vue |   62 ++++++++++++++++++++++++++-----
 1 files changed, 52 insertions(+), 10 deletions(-)

diff --git a/src/views/productManage/productCategory/index.vue b/src/views/productManage/productCategory/index.vue
index 7d77f4e..25274f7 100644
--- a/src/views/productManage/productCategory/index.vue
+++ b/src/views/productManage/productCategory/index.vue
@@ -15,15 +15,20 @@
           ref="tableListRef"
           :table-list="tableList"
           :show-checkcol="false"
+          :selectClassRow="selectRow"
+          @tableRowClick="clickRow"
         >
           <template slot="tableButton">
-            <el-table-column label="鎿嶄綔" width="90" align="center">
+            <el-table-column label="鎿嶄綔" width="120" 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>
+                <span @click.stop="deleteRow(scope.row)" class="cursor_pointer">
+                  <span style="color: #2a78fb;margin-left: 10px">鍒犻櫎</span>
                 </span>
               </template>
             </el-table-column>
@@ -35,15 +40,15 @@
       </div>
     </div>
     <!-- 鏂板缓/缂栬緫 -->
-    <AddProductCategoryDialog v-if="editConfig.visible" :productCategoryList="tableList.tableInfomation" @refresh="refresh" :edit-common-config="editConfig" />
+    <AddProductCategoryDialog ref="addProductCategory1" v-if="editConfig.visible" :productCategoryList="categoryList" @refresh="refresh" :edit-common-config="editConfig" />
   </div>
 </template>
 
 <script>
 import pageMixin from "@/components/makepager/pager/mixin/pageMixin"
-import { getProductCategoryList } from "@/api/product/productCategory"
+import { getProductCategoryList,deleteProductCategory } from "@/api/product/productCategory"
 import AddProductCategoryDialog from "@/views/productManage/productCategory/AddProductCategoryDialog"
-
+import {getTreeData} from '@/common/untils/index.js';
 export default {
   name: "ProductCategory",
   props: {},
@@ -52,12 +57,14 @@
   computed: {},
   data() {
     return {
+        selectRow:{},
       tableList: {},
+        categoryList:[],
       searchOptions: [],
       editConfig: {
         visible: false,
         title: "鏂板缓",
-        infomation: {},
+        infomation: {parentId:0},
         autoEdit: false
       }
     }
@@ -67,8 +74,16 @@
     this.getData()
   },
   methods: {
+      clickRow(row){
+          if(row.id===this.selectRow.id){
+              this.selectRow={};
+          }else{
+              this.selectRow={...row};
+          }
+      },
     setTable() {
       this.tableList = {
+        key:"id",
         tableInfomation: [],
         selectBox: false,
         selectIndex: true,
@@ -90,9 +105,10 @@
         pageSize: this.pagerOptions.pageSize
       }).then((res) => {
         if (res.code === 200) {
-          const list = res.data?res.data:[]
-          this.tableList.tableInfomation = list
-          this.pagerOptions.totalCount = res.total
+          const list = res.data?res.data:[];
+          this.categoryList=list;
+          this.tableList.tableInfomation = getTreeData(list,'child');
+          this.pagerOptions.totalCount = res.total;
         }
       })
     },
@@ -117,7 +133,7 @@
     editRow(row){
       this.editConfig.autoEdit = true
       this.editConfig.title = "缂栬緫"
-      this.editConfig.infomation = { ...row }
+      this.editConfig.infomation = { ...row };
       this.editConfig.visible = true
     },
     // 鏂板缓
@@ -128,9 +144,35 @@
         forceRemovalStrategy:null,
         inventoryValuation:null,
         name:'',
-        parentId:null,
+        parentId:this.selectRow.id||0,
       }
       this.editConfig.visible = true
+    },
+
+    //鍒犻櫎
+    deleteRow(row){
+      this.$confirm('姝ゆ搷浣滃皢姘镐箙鍒犻櫎璇ヤ骇鍝佺被鍨�, 鏄惁缁х画?', '鎻愮ず', {
+          confirmButtonText: '纭畾',
+          cancelButtonText: '鍙栨秷',
+          type: 'warning',
+        })
+          .then(() => {
+            deleteProductCategory({
+              id: row.id,
+            }).then((res) => {
+              if (res.code == 200) {
+                this.$message({
+                  type: 'success',
+                  message: '鍒犻櫎鎴愬姛!',
+                })
+                this.getData()
+              }else{
+                this.$message.error('鍒犻櫎鏃跺嚭閿欙紝璇风◢鍚庨噸璇曟垨鑱旂郴绠$悊鍛�...');
+             
+              }
+            })
+          })
+          .catch(() => {})
     }
   }
 }

--
Gitblit v1.8.0