From bef0978ab26369e2000820fafe76a1494ef7a3f0 Mon Sep 17 00:00:00 2001
From: 王震 <10952869+daywangzhen@user.noreply.gitee.com>
Date: 星期三, 13 九月 2023 14:34:50 +0800
Subject: [PATCH] 改bug

---
 src/components/view/mbom.vue |   90 ++++++++++++++++++++++++++++++++++-----------
 1 files changed, 68 insertions(+), 22 deletions(-)

diff --git a/src/components/view/mbom.vue b/src/components/view/mbom.vue
index fbfa699..5472b93 100644
--- a/src/components/view/mbom.vue
+++ b/src/components/view/mbom.vue
@@ -136,10 +136,15 @@
 		</div>
 		<div class="thing">
 			<div class="left">
-				<el-input v-model="search.technology" suffix-icon="el-icon-search" placeholder="璇疯緭鍏ユ悳绱㈠唴瀹�" size="small" clearable ></el-input>
-                <el-tree :data="list" ref="tree"  highlight-current
+				<el-input v-model="search.technology" @input="query" suffix-icon="el-icon-search" placeholder="璇疯緭鍏ユ悳绱㈠唴瀹�"  size="small" clearable ></el-input>
+                <el-tree 
+				:data="list" ref="tree"  
+				style="height: 500px;overflow-y: auto;" 
+				highlight-current
 				:props="{children: 'children',label: 'name'}" 
-				node-key="id" default-expand-all  @node-click="handleNodeClick" >
+				node-key="name" 
+				default-expand-all   
+				@node-click="handleNodeClick" >
 					<div class="custom-tree-node" slot-scope="{ node, data }">
 						<span><i :class="`node_i ${data.code != '[2]'?'el-icon-folder-opened':'el-icon-tickets'}`"></i>
 							{{data.code}} {{ data.name }}</span>
@@ -183,13 +188,13 @@
 			return {
               search:{
 					type: 0,
-					technology: null
+					technology: ''
 				},
               list:[],
 				process:{},
 				// handleClose:[],
 				checkTreeNode:{
-					id:2,
+					id:'',
 				},
 				tableData:[],
 				tableapi:[{
@@ -248,16 +253,18 @@
             })
 			},
 			addMbom(data) {
-				this.$axios.post(this.$api.url.addMbom,data
-				// {
-					// name:this.tableapi.name,
-					// qualityTraceability:this.tableapi.qualityTraceability,
-					// specifications:this.tableapi.specifications,
-					// supplier:this.tableapi.supplier,
-					// techTemId:this.craftapi.id,
-					// unit:this.tableapi.unit,
-				// }
-				, {
+				this.$axios.post(this.$api.url.addMbom,data,{
+					// params:{
+					// 	techTemId:this.craftapi.id,
+					// 	mbomModelDto2List:[{
+					// 		name:this.tableapi.name,
+					// 		qualityTraceability:this.tableapi.qualityTraceability,
+					// 		specifications:this.tableapi.specifications,
+					// 		supplier:this.tableapi.supplier,
+					// 		unit:this.tableapi.unit,
+					// 	}]
+					// }
+				}, {
 					headers: {
                 		"Content-Type": "application/json"
               		}
@@ -284,14 +291,42 @@
 				this.typeselect = val
 				this.selectAllleft()
 			},
+			query() {
+				this.selectAllleft()
+			},
 			//宸﹁竟
 			selectAllleft() {
 			this.$axios.get(this.$api.url.selectAllleft,{
-				params:{type:this.typeselect}
+				params:{type:this.typeselect,
+						message:this.search.technology
+				}
 			}).then(res => {
 				this.list = res.data;
 				console.log(this.list);
 				this.selectDataList()
+				this.$nextTick(() => {
+				this.$refs.tree.setCurrentKey(this.list[0].children[0].name) // 榛樿閫変腑鑺傜偣绗竴涓�
+			})
+				let one=this.list.filter(item=>{
+				return item.children.length>0
+				})[0]
+				console.log(one);
+				let name=one.children[0].id
+				console.log(name);
+				this.selectAllMbomStart(name)
+				this.selectDataList();
+			}, {
+				headers: {
+                		"Content-Type": "application/json"
+              		}
+            })
+			},
+			selectAllMbomStart(name) {
+			this.$axios.get(this.$api.url.selectAllMbom,{
+				params:{id:name}
+			}).then(res => {
+				this.tableData = res.data;
+				console.log(this.tableData);
 			}, {
 				headers: {
                 		"Content-Type": "application/json"
@@ -313,6 +348,7 @@
 			},
 			handleNodeClick(data){
                 this.checkTreeNode = data
+				console.log(data);
 				console.log(this.checkTreeNode.id);
 				this.selectAllMbom()
             },
@@ -323,30 +359,34 @@
 				})
 				.catch(_ => {});
 			},
+			//鏂板
             event(){
                 this.dialogVisible = true
 				this.chooseTechFath()
             },
+			//娣诲姞琛�
 			 Addrow() {
 			if (this.tableapi == undefined) {
 				this.tableapi = new Array();
 			}
 			let obj = [];
-			
 			this.tableapi.push(obj);
 			},
 			skipshow(){
 				console.log('666');
 				let data = this.tableapi.at(-1)
-				// this.addMbom()
 				data.techTemId = this.search.craft
-				// console.log(this.search.craft);
-				// console.log(data);
-
 				this.addMbom(data)
-				
 				this.dialogVisible = false
 			},
+			//delAllMbom 鎵归噺鍒犻櫎
+			delAllMbom() {
+                this.$axios.post(this.$api.url.delAllMbom,{
+                    ids:this.delete
+                }).then(res =>{
+                    this.selectAllMbom()
+                })
+            },
 			dels() {
 				this.selects.forEach(a => {
 					for (var b = 0; b < this.tableData.length; b++) {
@@ -356,6 +396,12 @@
 						}
 					}
 				})
+				let cc = this.selects.map(el => {
+					return el.id
+				})
+				this.delete = cc.join(',')
+				console.log(this.delete);
+				this.delAllMbom()
 				this.$message.success('鍒犻櫎瀹屾垚')
 			},
 			handleSelectionChange(val) {

--
Gitblit v1.9.3