From 95e7cf48fe085f0afd231290bb0b10a12896cdae Mon Sep 17 00:00:00 2001
From: 李林 <z1292839451@163.com>
Date: 星期五, 18 八月 2023 17:50:02 +0800
Subject: [PATCH] 8.18模块“基础数据”新增页面

---
 src/components/view/record-content.vue |  339 ++++++++++++++++++++++++++++++++++++++------------------
 1 files changed, 230 insertions(+), 109 deletions(-)

diff --git a/src/components/view/record-content.vue b/src/components/view/record-content.vue
index 88d9fb3..370c50e 100644
--- a/src/components/view/record-content.vue
+++ b/src/components/view/record-content.vue
@@ -35,11 +35,50 @@
 	}
 
 	.thing {
-		width: calc(100% - 44px);
-		height: calc(100% - 42px - 82px - 66px);
+		width: 100%;
+		height: calc(100% - 120px);
 		background-color: #fff;
-		overflow: auto;
-		padding: 33px 22px;
+		display: flex;
+	}
+
+	.thing .left {
+		width: 295px;
+		height: calc(100% - 20px);
+		border-right: 3px solid rgb(245, 247, 251);
+		padding: 16px;
+	}
+
+	.thing .left .custom-tree-node span {
+		font-size: 14px;
+	}
+
+	.thing .left .custom-tree-node {
+		flex: 1;
+		display: flex;
+		align-items: center;
+		justify-content: space-between;
+		font-size: 14px;
+		padding-right: 8px;
+	}
+
+	.node_i {
+		color: orange;
+	}
+
+	.el-icon-delete {
+		display: none;
+		color: #004EA2;
+	}
+
+	.custom-tree-node:hover .el-icon-delete {
+		display: inline;
+	}
+
+	.thing .right {
+		width: calc(100% - 305px);
+		height: calc(100% - 25px);
+		overflow: hidden;
+		padding: 10px;
 	}
 
 	.table_do {
@@ -56,31 +95,14 @@
 		color: #004EA2;
 	}
 
-	.record_content .thing * {
-		font-size: 14px;
+	.record_content .thing .left .el-tree--highlight-current .el-tree-node.is-current>.el-tree-node__content {
+		background: rgba(58, 124, 253, 0.2);
+		color: #004EA2;
 	}
 
-	.record_content .has-gutter .el-table__cell {
-		background-color: #F0F1F5 !important;
-		color: #333;
-	}
-
-	.record_content .has-gutter .el-table__cell .cell {
-		font-size: 16px;
-		font-weight: 500;
-	}
-
-	.record_content .cell {
-		color: #333;
-		padding-left: 17px !important;
-	}
-
-	.record_content .el-table__body-wrapper {
-		height: 100%;
-	}
-
-	.raw_ins .el-table__body {
-		height: 100%;
+	.record_content .el-tree-node__content {
+		height: 30px;
+		border-radius: 2px;
 	}
 </style>
 
@@ -92,7 +114,7 @@
 				<el-col :span="12" style="text-align: right;">
 					<el-button type="primary" icon="el-icon-plus" style="background: #004EA2;">鏂板</el-button>
 					<el-button icon="el-icon-edit-outline">淇敼</el-button>
-					<el-button icon="el-icon-delete">鍒犻櫎</el-button>
+					<el-button icon="el-icon-delete" @click="dels">鍒犻櫎</el-button>
 				</el-col>
 			</el-row>
 		</div>
@@ -113,30 +135,68 @@
 					璇�</span></el-button>
 		</div>
 		<div class="thing">
-			<el-table :data="tableData" border style="width: 100%;overflow-y: auto;min-height: calc(100% - 50px)"
-				max-height="calc(100% - 50px)" @selection-change="handleSelectionChange" default-expand-all
-				:tree-props="{children: 'children', hasChildren: 'hasChildren'}" row-key="id">
-				<el-table-column type="selection" width="50">
-				</el-table-column>
-				<el-table-column type="index" label="搴忓彿" width="70">
-				</el-table-column>
-				<el-table-column prop="name" label="宸ュ簭">
-					<template slot-scope="scope">
-						<span>
-							<font>{{scope.row.ids}}</font>{{scope.row.name}}
-						</span>
-					</template>
-				</el-table-column>
-				<el-table-column prop="address" label="澶囨敞">
-				</el-table-column>
-				<el-table-column label="鎿嶄綔" width="130">
-					<template slot-scope="scope">
-						<span class="table_do">缂栬緫&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
-						<span class="table_do" @click="deleteRow(scope.$index, tableData)">鍒犻櫎</span>
-					</template>
-				</el-table-column>
-			</el-table>
+			<div class="left">
+				<el-input v-model="search.technology" suffix-icon="el-icon-search" placeholder="璇疯緭鍏ユ悳绱㈠唴瀹�" size="small" clearable @input="(val)=>$refs.tree.filter(val)"></el-input>
+				<el-tree :data="list" ref="tree" :props="{children: 'children',label: 'name'}" node-key="id" default-expand-all
+					@node-click="handleNodeClick" highlight-current @node-expand="nodeOpen" @node-collapse="nodeClose" :filter-node-method="filterNode"
+					:key="upIndex">
+					<div class="custom-tree-node" slot-scope="{ node, data }">
+						<span><i :class="`node_i ${data.code != '[3]'?'el-icon-folder-opened':'el-icon-tickets'}`"></i>
+							{{data.code}} {{ data.name }}</span>
+						<el-button type="text" size="mini" @click.stop="remove(node, data)">
+							<i class="el-icon-delete"></i>
+						</el-button>
+					</div>
+				</el-tree>
+			</div>
+			<div class="right">
+				<el-table :data="tableData" border style="width: 100%;overflow-y: auto;min-height: 100%" max-height="100%"
+					@selection-change="handleSelectionChange" default-expand-all>
+					<el-table-column type="selection" width="50">
+					</el-table-column>
+					<el-table-column type="index" label="搴忓彿" width="70">
+					</el-table-column>
+					<el-table-column prop="name" label="鍚嶇О">
+					</el-table-column>
+					<el-table-column prop="unit" label="鍗曚綅">
+					</el-table-column>
+					<el-table-column prop="thing" label="澶囨敞">
+					</el-table-column>
+					<el-table-column label="鎿嶄綔" width="130">
+						<template slot-scope="scope">
+							<span class="table_do" @click="upContent(scope.row)">缂栬緫&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
+							<span class="table_do" @click="deleteRow(scope.$index, tableData)">鍒犻櫎</span>
+						</template>
+					</el-table-column>
+				</el-table>
+			</div>
 		</div>
+		<el-dialog title="缂栬緫璁板綍鍐呭" :visible.sync="upDia" width="500px">
+			<div class="body">
+				<el-row style="line-height: 46px;">
+					<el-col :span="4" style="font-size: 14px;text-align: right;">鍚嶇О:</el-col>
+					<el-col :span="16" :offset="1">
+						<el-input v-model="upData.name" size="small" clearable></el-input>
+					</el-col>
+				</el-row>
+				<el-row style="line-height: 46px;">
+					<el-col :span="4" style="font-size: 14px;text-align: right;">鍗曚綅:</el-col>
+					<el-col :span="16" :offset="1">
+						<el-input v-model="upData.unit" size="small" clearable></el-input>
+					</el-col>
+				</el-row>
+				<el-row style="line-height: 46px;">
+					<el-col :span="4" style="font-size: 14px;text-align: right;">澶囨敞:</el-col>
+					<el-col :span="16" :offset="1">
+						<el-input v-model="upData.thing" size="small" clearable></el-input>
+					</el-col>
+				</el-row>
+			</div>
+			<span slot="footer" class="dialog-footer">
+				<el-button type="primary" @click="submitUpData">纭� 瀹�</el-button>
+				<el-button @click="upDia = false">鍙� 娑�</el-button>
+			</span>
+		</el-dialog>
 	</div>
 </template>
 
@@ -146,91 +206,152 @@
 			return {
 				search: {
 					type: 0,
-					name: null
+					name: null,
+					technology: null
 				},
 				process: [],
-				tableData: [{
-					id: 1,
-					date: '2016-05-02',
-					name: '鐜嬪皬铏�',
-					address: '涓婃捣甯傛櫘闄�鍖洪噾娌欐睙璺� 1518 寮�'
-				}, {
-					id: 2,
-					date: '2016-05-04',
-					name: '鐜嬪皬铏�',
-					address: '涓婃捣甯傛櫘闄�鍖洪噾娌欐睙璺� 1517 寮�'
-				}, {
-					id: 3,
-					date: '2016-05-01',
-					name: '鐜嬪皬铏�',
-					address: '涓婃捣甯傛櫘闄�鍖洪噾娌欐睙璺� 1519 寮�',
+				list: [{
+					id: 0,
+					name: "鍘熸潗鏂�",
 					children: [{
-						id: 31,
-						date: '2016-05-01',
-						name: '鐜嬪皬铏�',
-						address: '涓婃捣甯傛櫘闄�鍖洪噾娌欐睙璺� 1519 寮�',
+						id: 3,
+						name: "宸ヨ壓",
 						children: [{
-							id: 33,
-							date: '2016-05-01',
-							name: '鐜嬪皬铏�',
-							address: '涓婃捣甯傛櫘闄�鍖洪噾娌欐睙璺� 1519 寮�'
-						}, {
-							id: 34,
-							date: '2016-05-01',
-							name: '鐜嬪皬铏�',
-							address: '涓婃捣甯傛櫘闄�鍖洪噾娌欐睙璺� 1519 寮�'
+							id: 6,
+							name: "璁惧1"
 						}]
-					}, {
-						id: 32,
-						date: '2016-05-01',
-						name: '鐜嬪皬铏�',
-						address: '涓婃捣甯傛櫘闄�鍖洪噾娌欐睙璺� 1519 寮�'
 					}]
 				}, {
-					id: 4,
-					date: '2016-05-03',
-					name: '鐜嬪皬铏�',
-					address: '涓婃捣甯傛櫘闄�鍖洪噾娌欐睙璺� 1516 寮�'
+					id: 1,
+					name: "鎴愬搧",
+					children: [{
+						id: 4,
+						name: "宸ヨ壓"
+					}]
+				}, {
+					id: 2,
+					name: "鍗婃垚鍝�",
+					children: [{
+						id: 5,
+						name: "宸ヨ壓"
+					}]
 				}],
-				selects: []
+				checkTreeNode: {},
+				tableData: [{
+					id: 1,
+					name: "璐ㄩ噺杩芥函鍙�",
+					unit: "鍗曚綅",
+					thing: "dajskda"
+				}, {
+					id: 2,
+					name: "浣滀笟浜哄憳",
+					unit: "鍗曚綅",
+					thing: "dajskda"
+				}, {
+					id: 3,
+					name: "瑙勬牸",
+					unit: "鍗曚綅",
+					thing: "dajskda"
+				}, {
+					id: 4,
+					name: "瑙勬牸",
+					unit: "鍗曚綅",
+					thing: "dajskda"
+				}, {
+					id: 5,
+					name: "瑙勬牸",
+					unit: "鍗曚綅",
+					thing: "dajskda"
+				}],
+				upIndex: 0,
+				selects: [],
+				upDia: false,
+				upData: {
+					id: 0,
+					name: null,
+					unit: null,
+					thing: null
+				}
 			}
 		},
 		mounted() {
 			this.selectDataList()
 		},
 		methods: {
-			clean() {
-				this.search = {
-					type: null,
-					name: null
-				}
+			filterNode(value, data) {
+			  if (!value) return true;
+			  return data.name.indexOf(value) !== -1;
 			},
-			selectDataList(){
-				this.tableData.forEach(a=>{
-					a.ids = '01'
-					if(a.children!=undefined){
-						a.children.forEach(b=>{
-							b.ids = '02'
-							if(b.children!=undefined){
-								b.children.forEach(c=>{
-									c.ids = '03'
+			remove(node, data) {
+				this.$confirm("鏄惁鍒犻櫎", "璀﹀憡", {
+					type: "warning"
+				}).then(res => {
+					const parent = node.parent;
+					const children = parent.data.children || parent.data;
+					const index = children.findIndex(d => d.id === data.id);
+					children.splice(index, 1);
+				}).catch(e => {})
+			},
+			selectDataList() {
+				this.list.forEach(a => {
+					a.code = '[1]'
+					if (a.children != undefined) {
+						a.children.forEach(b => {
+							b.code = '[2]'
+							if (b.children != undefined) {
+								b.children.forEach(c => {
+									c.code = '[3]'
 								})
 							}
 						})
 					}
 				})
+				this.upIndex++
+			},
+			handleNodeClick(data) {
+				this.checkTreeNode = data
+				if(data.code=='[3]'){
+					console.log(data);
+				}
+			},
+			nodeOpen(data, node, el) {
+				$($(el.$el).find('.node_i')[0]).attr('class', 'node_i el-icon-folder-opened')
+			},
+			nodeClose(data, node, el) {
+				$($(el.$el).find('.node_i')[0]).attr('class', 'node_i el-icon-folder')
 			},
 			handleSelectionChange(val) {
 				this.selects = val;
 			},
-			del(ob) {
-				console.log(ob)
+			dels() {
+				this.selects.forEach(a => {
+					for (var b = 0; b < this.tableData.length; b++) {
+						if (this.tableData[b].id == a.id) {
+							this.tableData.splice(b, 1)
+							b--
+						}
+					}
+				})
+				this.$message.success('鍒犻櫎瀹屾垚')
 			},
 			deleteRow(index, rows) {
-				console.log(index);
-				console.log(rows);
 				rows.splice(index, 1);
+			},
+			upContent(ob) {
+				this.upData = this.HaveJson(ob)
+				this.upDia = true
+			},
+			submitUpData() {
+				this.tableData.forEach(a => {
+					if (a.id == this.upData.id) {
+						a.name = this.upData.name
+						a.unit = this.upData.unit
+						a.thing = this.upData.thing
+					}
+				})
+				this.$message.success('淇敼鎴愬姛')
+				this.upDia = false
 			}
 		}
 	}
-</script>
\ No newline at end of file
+</script>

--
Gitblit v1.9.3