From e1947c8638faedf07e2298a57a850f711196845f Mon Sep 17 00:00:00 2001
From: gaoshp <291585735@qq.com>
Date: 星期六, 27 四月 2024 21:41:39 +0800
Subject: [PATCH] 机器组
---
src/views/tpm/MachineGroup.vue | 80 ++++++++++++++++++++++++++++++++--------
1 files changed, 64 insertions(+), 16 deletions(-)
diff --git a/src/views/tpm/MachineGroup.vue b/src/views/tpm/MachineGroup.vue
index 918ea95..e77729e 100644
--- a/src/views/tpm/MachineGroup.vue
+++ b/src/views/tpm/MachineGroup.vue
@@ -1,7 +1,7 @@
<!--
* @Date: 2024-04-27 20:02:44
* @LastEditors: Sneed
- * @LastEditTime: 2024-04-27 20:49:52
+ * @LastEditTime: 2024-04-27 21:40:33
* @FilePath: /belleson-frontend/Users/mache/Documents/demo/cps-web/src/views/tpm/MachineGroup.vue
-->
<template>
@@ -9,8 +9,9 @@
<el-aside width="200px" v-loading="showGrouploading">
<el-container>
<el-main class="nopadding">
- <el-tree ref="group" node-key="id" :data="group" :current-node-key="treeCheckKey"
- :highlight-current="true" default-expand-all @node-click="groupClick"></el-tree>
+ <el-tree ref="group" node-key="id" :data="group" :current-node-key="form.id"
+ :highlight-current="true" :expand-on-click-node="false" default-expand-all
+ @node-click="groupClick"></el-tree>
</el-main>
</el-container>
</el-aside>
@@ -24,13 +25,15 @@
<el-main class="">
<el-form :model="form" :rules="rules" ref="dialogForm" label-width="200px" label-position="left">
<el-form-item label="涓婄骇鐩綍" prop="parentName">
- <el-input style="width: 240px" v-model="form.parentName"></el-input>
+ <el-input disabled style="width: 240px" v-model="form.parentName"></el-input>
</el-form-item>
<el-form-item label="鏈哄櫒缁勫悕绉�" prop="name">
- <el-input style="width: 240px" v-model="form.name" clearable></el-input>
+ <el-input :disabled="(form.id === '102' || form.id === '2')" style="width: 240px"
+ v-model="form.name" clearable></el-input>
</el-form-item>
</el-form>
- <el-button @click="save" style="width: 100px" type="primary" plain>淇濆瓨</el-button>
+ <el-button @click="save" v-show="!(form.id === '102' || form.id === '2')" style="width: 100px"
+ type="primary" plain>淇濆瓨</el-button>
</el-main>
</el-container>
</el-container>
@@ -41,16 +44,16 @@
data() {
return {
group: [],
- treeCheckKey: '',
form: {
+ code: '',
name: '',
+ id: '',
+ groupType: '',
+ groupCategory: '',
parentName: '',
parentId: '',
- id: '',
- groupType: 'group_machine',
- groupCategory: '1',
- code: ''
},
+ disabled: false,
}
},
created() {
@@ -61,17 +64,62 @@
this.$HTTP.get('/api/blade-cps/group/tree?groupCategory=1&groupType=group_machine').then(res => {
if (res.code === 200) {
this.group = res.data
- this.treeCheckKey = res.data[0].id
+ this.groupClick(res.data[0])
}
})
},
- groupClick() {
+ groupClick(node, node1) {
+ console.log(node, node1?.parent?.data?.name)
+ this.disabled = false
+ Object.keys(this.form).forEach(item => {
+ this.form[item] = node[item]
+ })
+ if (node1?.parent?.data?.name) {
+ this.form.parentName = node1?.parent?.data?.name
+ }
+ if (node.id === '102' || node.id === '2') {
+ this.form.parentName = node.name
+ this.disabled = true
+ }
+ },
+ addChild() {
+ let { name, id, groupType, groupCategory } = this.form
+ this.form.id = ''
+ this.form.name = ''
+ this.form.code = ''
+ this.form.groupType = groupType
+ this.form.groupCategory = groupCategory
+ this.form.parentName = name
+ this.form.parentId = id
+ },
+ del() {
+ this.$confirm(
+ '纭鍒犻櫎璇ユ満鍣ㄧ粍锛�',
+ {
+ distinguishCancelAndClose: true,
+ confirmButtonText: '鍒犻櫎',
+ cancelButtonText: '鍙栨秷',
+ }
+ )
+ .then(() => {
+ this.$HTTP.delete('/api/blade-cps/group/deleteGroup', {}, { params: { groupId: this.form.id } }).then(res => {
+ if (res.code === 200) {
+ this.$message.success("鎿嶄綔鎴愬姛");
+ this.getTreeData()
+ }
+ })
+ }).catch(() => {
+ this.$message.success("鍙栨秷鎿嶄綔");
+ })
},
- addChild() { },
- del() { },
save() {
-
+ this.group = []
+ this.$HTTP.post('/api/blade-cps/group', this.form).then(res => {
+ if (res.code === 200) {
+ this.getTreeData()
+ }
+ })
}
}
}
--
Gitblit v1.9.3