From 4d8049330f1378c87115a7fcb66265f815b49801 Mon Sep 17 00:00:00 2001
From: zouyu <2723363702@qq.com>
Date: 星期三, 13 九月 2023 16:52:06 +0800
Subject: [PATCH] 	modified:   src/assets/api/controller.js 	modified:   src/components/view/standard-table/material.vue 	modified:   src/components/view/standard-table/product.vue 	modified:   src/components/view/standard-table/target.vue 	modified:   src/components/view/standard-table/technology.vue 	modified:   src/components/view/standard.vue

---
 src/components/view/standard.vue                  |   92 +++++++++++++++++++---
 src/components/view/standard-table/target.vue     |   30 ++++++-
 src/components/view/standard-table/technology.vue |   35 ++++++--
 src/assets/api/controller.js                      |    6 +
 src/components/view/standard-table/material.vue   |   33 ++++++-
 src/components/view/standard-table/product.vue    |   26 +++++
 6 files changed, 184 insertions(+), 38 deletions(-)

diff --git a/src/assets/api/controller.js b/src/assets/api/controller.js
index 5e90ab6..36976e0 100644
--- a/src/assets/api/controller.js
+++ b/src/assets/api/controller.js
@@ -24,7 +24,11 @@
 	addTechniqueByStandard:"/technique/add",//鍙充笂瑙掓柊澧�-->鐢熶骇宸ヨ壓
 	chooseProByProduct:"/technique/choosePro",//鍙充笂瑙掓柊澧�-->鐢熶骇宸ヨ壓-->閫夋嫨椤圭洰(鐖跺瓙),鍗曚綅
 	chooseDevByProduct:"/technique/chooseDev",//鍙充笂瑙掓柊澧�-->鐢熶骇宸ヨ壓-->閫夋嫨璁惧
-
+	addVersion:"/material/addVersion",//娣诲姞鍚屼竴涓瀷鍙峰伐鑹鸿矾绾�,鎶�鏈寚鏍�,鐗╂枡娓呭崟,鐢熶骇宸ヨ壓鐨勭増鏈�
+	delAllByTechnology:"/technology/delAllTech",//宸ヨ壓璺嚎-鎵归噺鍒犻櫎
+	delAllByTarget:"/product/delAllPro",//鎶�鏈寚鏍�-鎵归噺鍒犻櫎
+	delAllByMBom:"/mbom/delAllMbom",//鐗╂枡娓呭崟-鎵归噺鍒犻櫎
+	delAllByProduct:"/technique/delAllTeq",//鐢熶骇宸ヨ壓-鎵归噺鍒犻櫎
 	// 鎶�鏈鐞�-鎶�鏈枃浠�
 	selectAllOrder: "/orders/selectAllOrder", //鏌ヨ鎵�鏈夎鍗曞垪琛�
 	selectOrderById: "/orders/selectOrderById", //鏍规嵁璁㈠崟id鏌ヨ璁㈠崟璇︽儏
diff --git a/src/components/view/standard-table/material.vue b/src/components/view/standard-table/material.vue
index 32384da..4dc288b 100644
--- a/src/components/view/standard-table/material.vue
+++ b/src/components/view/standard-table/material.vue
@@ -56,7 +56,9 @@
       data() {
         return {
           hasChildren:true,
-          selects: []
+          selects: [],
+          isAllSelect:false,
+          deleteList:[],
         }
       },
       props:['tableData','tableType'],
@@ -109,14 +111,33 @@
             }
           }
         },
-        handleSelectionChange(val) {
-          this.deleteList = [];
-          val.forEach((v) => {
-            if (v.id !== undefined) {
-              this.deleteList.push(v.id);
+        //鏀瑰彉閫変腑
+        toggleSelection(row, flag) {
+          this.$set(row, "isChecked", flag);
+          this.$nextTick(() => {
+            if (flag) {
+              this.$refs.multipleTable.toggleRowSelection(row, flag);
+            } else {
+              this.$refs.multipleTable.clearSelection();
             }
           });
         },
+        handleSelectionChange(val) {
+        this.deleteList = [];
+        val.forEach((v) => {
+          this.searchIdFun(v);
+        });
+        this.$emit("childData",this.deleteList);
+      },
+      //閫掑綊鏌ユ壘閫変腑鏁版嵁id
+      searchIdFun(data){
+        let obj = data;
+        if(obj.children != undefined){
+          this.searchIdFun(obj.children);
+        }else{
+          this.deleteList.push(obj.id);
+        }
+      },
         // 琛ㄦ牸鏍戝叏閮ㄩ�変腑閰嶇疆  缁撴潫
       }
     }
diff --git a/src/components/view/standard-table/product.vue b/src/components/view/standard-table/product.vue
index 6141739..62990fd 100644
--- a/src/components/view/standard-table/product.vue
+++ b/src/components/view/standard-table/product.vue
@@ -91,6 +91,7 @@
         deviceGroupDialog:false,
         selects: [],
         isAllSelect:false,
+        deleteList:[],
       }
     },
     props:['tableData','tableType'],
@@ -134,13 +135,32 @@
           }
         }
       },
+      //鏀瑰彉閫変腑
+      toggleSelection(row, flag) {
+        this.$set(row, "isChecked", flag);
+        this.$nextTick(() => {
+          if (flag) {
+            this.$refs.multipleTable.toggleRowSelection(row, flag);
+          } else {
+            this.$refs.multipleTable.clearSelection();
+          }
+        });
+      },
       handleSelectionChange(val) {
         this.deleteList = [];
         val.forEach((v) => {
-          if (v.id !== undefined) {
-            this.deleteList.push(v.id);
-          }
+          this.searchIdFun(v);
         });
+        this.$emit("childData",this.deleteList);
+      },
+      //閫掑綊鏌ユ壘閫変腑鏁版嵁id
+      searchIdFun(data){
+        let obj = data;
+        if(obj.children != undefined){
+          this.searchIdFun(obj.children);
+        }else{
+          this.deleteList.push(obj.tqid);
+        }
       },
       // 琛ㄦ牸鏍戝叏閮ㄩ�変腑閰嶇疆  缁撴潫
     }
diff --git a/src/components/view/standard-table/target.vue b/src/components/view/standard-table/target.vue
index cb8ad69..9524ae4 100644
--- a/src/components/view/standard-table/target.vue
+++ b/src/components/view/standard-table/target.vue
@@ -57,6 +57,8 @@
       data() {
         return {
           selects: [],
+          deleteList:[],
+          isAllSelect:false,
         }
       },
       props:['tableData','tableType'],
@@ -99,13 +101,32 @@
           }
         }
       },
+      //鏀瑰彉閫変腑
+      toggleSelection(row, flag) {
+        this.$set(row, "isChecked", flag);
+        this.$nextTick(() => {
+          if (flag) {
+            this.$refs.multipleTable.toggleRowSelection(row, flag);
+          } else {
+            this.$refs.multipleTable.clearSelection();
+          }
+        });
+      },
       handleSelectionChange(val) {
         this.deleteList = [];
         val.forEach((v) => {
-          if (v.id !== undefined) {
-            this.deleteList.push(v.id);
-          }
+          this.searchIdFun(v);
         });
+        this.$emit("childData",this.deleteList);
+      },
+      //閫掑綊鏌ユ壘閫変腑鏁版嵁id
+      searchIdFun(data){
+        let obj = data;
+        if(obj.children != undefined){
+          this.searchIdFun(obj.children);
+        }else{
+          this.deleteList.push(obj.pid);
+        }
       },
       // 琛ㄦ牸鏍戝叏閮ㄩ�変腑閰嶇疆  缁撴潫
         updateVal(row){
@@ -118,9 +139,6 @@
           }).catch(error=>{
             this.$message.error(error.message);
           })
-        },
-        handleSelectionChange(val) {
-          this.selects = val;
         },
       }
     }
diff --git a/src/components/view/standard-table/technology.vue b/src/components/view/standard-table/technology.vue
index a550804..990a804 100644
--- a/src/components/view/standard-table/technology.vue
+++ b/src/components/view/standard-table/technology.vue
@@ -72,11 +72,6 @@
     methods: {
       // 琛ㄦ牸鏍戝叏閮ㄩ�変腑閰嶇疆
       // 鍏ㄩ��/鍙栨秷閫夋搷浣�
-      selectAll(val) {
-        this.isAllSelect = !this.isAllSelect;
-        let data = this.tableData;
-        this.toggleSelect(data, this.isAllSelect, "all");
-      },
       //閫夋嫨鏌愯
 		  selectTr(selection, row) {
         this.$set(row, "isChecked", !row.isChecked);
@@ -106,13 +101,37 @@
           }
         }
       },
+      //鏀瑰彉閫変腑
+      toggleSelection(row, flag) {
+        this.$set(row, "isChecked", flag);
+        this.$nextTick(() => {
+          if (flag) {
+            this.$refs.multipleTable.toggleRowSelection(row, flag);
+          } else {
+            this.$refs.multipleTable.clearSelection();
+          }
+        });
+      },
+      selectAll(val) {
+        this.isAllSelect = !this.isAllSelect;
+        let data = this.tableData;
+        this.toggleSelect(data, this.isAllSelect, "all");
+      },
       handleSelectionChange(val) {
         this.deleteList = [];
         val.forEach((v) => {
-          if (v.id !== undefined) {
-            this.deleteList.push(v.id);
-          }
+          this.searchIdFun(v);
         });
+        this.$emit("childData",this.deleteList);
+      },
+      //閫掑綊鏌ユ壘閫変腑鏁版嵁id
+      searchIdFun(data){
+        let obj = data;
+        if(obj.children != undefined){
+          this.searchIdFun(obj.children);
+        }else{
+          this.deleteList.push(obj.id);
+        }
       },
       // 琛ㄦ牸鏍戝叏閮ㄩ�変腑閰嶇疆  缁撴潫
       showDialog(){
diff --git a/src/components/view/standard.vue b/src/components/view/standard.vue
index 2018424..2a3269a 100644
--- a/src/components/view/standard.vue
+++ b/src/components/view/standard.vue
@@ -5,9 +5,9 @@
         <el-col :span="12" style="line-height: 32px;">鏍囧噯BOM</el-col>
         <el-col :span="12" style="text-align: right;">
           <el-button type="primary" icon="el-icon-plus" style="background: #004EA2;"
-            @click="bomAddModelVisible = true">鏂板</el-button>
-          <el-button icon="el-icon-plus">鏂板鐗堟湰</el-button>
-          <el-button @click="bomRightDl=true" icon="el-icon-delete">鍒犻櫎</el-button>
+            @click="showBomAddModel">鏂板</el-button>
+          <el-button icon="el-icon-plus" @click="addVersionBtn">鏂板鐗堟湰</el-button>
+          <el-button @click="deleteDataBtn" icon="el-icon-delete">鍒犻櫎</el-button>
         </el-col>
       </el-row>
     </div>
@@ -56,16 +56,17 @@
         </div>
 
         <div class="contentTable" v-if="this.typeselect == 0">
-          <technology  :tableType="tableType" :tableData="tableData"></technology>
+          <technology @childData="getChildData"  :tableType="tableType" :tableData="tableData"></technology>
         </div>
         <div v-if="this.typeselect == 1">
-          <target :tableType="tableType" :tableData="tableData"></target>
+          <target @childData="getChildData" :tableType="tableType" :tableData="tableData"></target>
         </div>
         <div v-if="this.typeselect == 2">
-          <bom  :tableType="tableType" :tableData="tableData"></bom>
+          <material @childData="getChildData" :tableType="tableType" :tableData="tableData"></material>
         </div>
-        <div v-if="this.typeselect == 3">鐢熶骇宸ヨ壓</div>
-        
+        <div v-if="this.typeselect == 3">
+          <product @childData="getChildData" :tableType="tableType" :tableData="tableData"></product>
+        </div>
       </div>
     </div>
 
@@ -332,10 +333,11 @@
 <script>
 import technology from "./standard-table/technology.vue"
 import material from "./standard-table/material.vue"
-// import bom from "./standard-table/bom.vue"
+import target from "./standard-table/target.vue"
+import product from "./standard-table/product.vue"
 import bomClickAdd from '@/components/view/standard-box/bomClickAdd'
 export default {
-  components: { technology,material,bomClickAdd },
+  components: { technology,material,target,product,bomClickAdd },
 
   data() {
     var checkPq = (rule,value,callback)=>{
@@ -352,6 +354,8 @@
       callback();
     };
     return {
+      //瀛愮粍浠朵紶鐨刬d鍒楄〃
+      childIds:[],
       //宸ュ簭鍒楄〃
       technologyIdList:[],
       fatherList:[],
@@ -429,7 +433,7 @@
       // BOM鏍戞暟鎹粨鏋�
       list: [],
       search: null,
-      tableType: 1, // 琛ㄦ牸绫诲瀷 1锛氭妧鏈寚鏍囷紝0锛氬伐鑹鸿矾绾�
+      tableType: 0, // 琛ㄦ牸绫诲瀷 1锛氭妧鏈寚鏍囷紝0锛氬伐鑹鸿矾绾�
       searchName: "",// 鏌ヨ鏉′欢-鍚嶇О
       checkTreeNode: {},// 鐐瑰嚮閫変腑鏍戣妭鐐�
       tableData: [],
@@ -439,9 +443,7 @@
       bomRightDl: false,
       formTypeOptions: null,
       typeselect: 0,
-      returntree: {
-        id:28,
-      },
+      returntree: {id:28},
       version: {},
       leftAdd:{
         type: [],
@@ -574,6 +576,68 @@
     leftAddBom(){
       
     },
+    //鑾峰彇瀛愮粍浠舵暟鎹�
+    getChildData(data){
+      this.childIds = data;
+    },
+    //鍒犻櫎鎸夐挳
+    deleteDataBtn(){
+      let ids;
+      let url;
+      ids = this.childIds.filter(item=>{
+        return item != undefined;
+      });
+      if(ids.length < 1){
+        this.$message.error("璇峰厛閫夋嫨鏁版嵁锛�");
+        return;
+      }
+      switch(this.typeselect){
+        case 0:
+          url = this.$api.url.delAllByTechnology;
+          break;
+        case 1:
+          url = this.$api.url.delAllByTarget;
+          break;
+        case 2:
+          url = this.$api.url.delAllByMBom;
+          break;
+        case 3:
+          url = this.$api.url.delAllByProduct;
+          break;
+      }
+      this.$confirm('纭鍒犻櫎宸查�変腑鐨勬暟鎹悧', '鍒犻櫎', {
+          confirmButtonText: '纭畾',
+          cancelButtonText: '鍙栨秷',
+          type: 'warning'
+        }).then(() => {
+          this.$axios.post(url,{
+            ids : ids.join(",")
+          }).then(res=>{
+            this.selectAll();
+            this.$message.success(res.message);
+          }).catch(error=>{
+            this.$message.error(error.message);
+          })
+        }).catch(() => {});
+    },
+    //鏂板鐗堟湰
+    addVersionBtn(){
+        this.$confirm('纭鏂板鐗堟湰鍚�', '鏂板鐗堟湰', {
+          confirmButtonText: '纭畾',
+          cancelButtonText: '鍙栨秷',
+          type: 'info'
+        }).then(() => {
+          this.$axios.post(this.$api.url.addVersion,{
+            specificationsId : this.returntree.id,
+            version : this.version2.substring(1,2),
+          }).then(res=>{
+            this.selectVersion();
+            this.$message.success(res.message);
+          }).catch(error=>{
+            this.$message.error(error.message);
+          })
+        }).catch(() => {});
+    },
     //鍙充晶bom,纭鏂板
     confirmAdd(formName){
       this.$refs[formName].validate(valid=>{

--
Gitblit v1.9.3