| | |
| | | </el-col> |
| | | <el-col :span="6"> |
| | | <el-button type="primary" @click="searchTree"><el-icon class="el-icon--right" style="margin-right: 6px;"><Search /></el-icon>搜索</el-button> |
| | | <el-button :icon="Delete"><el-icon class="el-icon--right" style="margin-right: 6px;"><Delete /></el-icon>清空</el-button> |
| | | <el-button :icon="Delete" @click="setClearTree"><el-icon class="el-icon--right" style="margin-right: 6px;"><Delete /></el-icon>清空</el-button> |
| | | </el-col> |
| | | </el-row> |
| | | </template> |
| | |
| | | export default { |
| | | data() { |
| | | return { |
| | | targetRow: {}, |
| | | upgradeModal: false, |
| | | file: null, |
| | | fileContent: "", |
| | |
| | | total: 0, |
| | | }, |
| | | option: { |
| | | highlightCurrentRow: true, |
| | | rowKey: "id", |
| | | treeProps: { |
| | | children: "children", |
| | | hasChildren: 'hasChildren', |
| | | }, |
| | | defaultExpandAll: false, |
| | | lazy: true, |
| | | rowKey: 'id', |
| | | addBtn: false, |
| | |
| | | menu: false, |
| | | searchBtn: false, |
| | | emptyBtn: false, |
| | | defaultExpandAll: false, |
| | | column: [ |
| | | { |
| | | label: '目录', |
| | |
| | | } |
| | | }, |
| | | methods: { |
| | | removeHasChildren(treeData) { //查询时候使用,删掉hasChildren |
| | | return treeData.map(node => { |
| | | if (node.children && node.children.length > 0) { |
| | | node.children = this.removeHasChildren(node.children); |
| | | } |
| | | // 删除当前节点的 hasChildren 属性 |
| | | const { hasChildren, ...rest } = node; |
| | | return rest; |
| | | }); |
| | | }, |
| | | // 递归查找目标行(name="机床1") |
| | | findTargetRow(data, targetName) { |
| | | for (const item of data) { |
| | | if (item.name === targetName) { |
| | | return item; // 找到目标行 |
| | | } |
| | | if (item.children && item.children.length > 0) { |
| | | const found = this.findTargetRow(item.children, targetName); |
| | | if (found) return found; // 在子节点中找到 |
| | | } |
| | | } |
| | | return null; // 未找到 |
| | | }, |
| | | highlightTargetRow() { // 高亮目标行 |
| | | const targetName = this.search.name; |
| | | this.targetRow = this.findTargetRow(this.treeData, targetName); |
| | | if (this.targetRow && this.$refs.crud) { |
| | | this.$refs.crud.setCurrentRow(this.targetRow); // 高亮目标行 |
| | | } |
| | | }, |
| | | searchTree() { |
| | | axios({ |
| | | url: '/blade-mdm/program/node/search-list', |
| | | method: 'get', |
| | | params: this.search, |
| | | }).then(res => { |
| | | |
| | | // this.option.defaultExpandAll = true; |
| | | this.treeData = res.data.data; |
| | | this.option.defaultExpandAll = true; |
| | | this.treeData = this.removeHasChildren(res.data.data); |
| | | this.$nextTick(() => { |
| | | this.highlightTargetRow(); // 设置当前行高亮 |
| | | this.tabsForm = this.targetRow; //tabs节点信息 |
| | | this.nodeTypeList.forEach(item=> { |
| | | if(item.dictKey == this.tabsForm.nodeType) { |
| | | this.tabsForm.nodeTypeName = item.dictValue; |
| | | } |
| | | }) |
| | | }) |
| | | if(this.treeData.length == 0) { |
| | | return; |
| | | } |
| | | |
| | | // this.$refs.crud.toggleRowExpansion(this.treeData[2],true) |
| | | // this.tabsForm = res.data.data[0]; //节点信息 |
| | | // this.nodeTypeList.forEach(item=> { |
| | | // if(item.dictKey == this.treeData[0].nodeType) { |
| | | // this.tabsForm.nodeTypeName = item.dictValue; |
| | | // } |
| | | // }) |
| | | |
| | | } |
| | | ); |
| | | }); |
| | | }, |
| | | setClearTree() { |
| | | this.option.defaultExpandAll = false; |
| | | this.treeData = []; |
| | | this.$nextTick(()=> { |
| | | this.onLoad(); |
| | | }) |
| | | }, |
| | | upgradeSubmit(row,done) { //升版 |
| | | axios({ |
| | |
| | | margin-left: 10px; |
| | | margin-top: 12px; |
| | | } |
| | | .highlight-row { |
| | | background-color: #f0f7ff !important; /* 浅蓝色背景 */ |
| | | font-weight: bold; /* 加粗文字 */ |
| | | } |
| | | |
| | | /* 如果需要悬停效果 */ |
| | | .highlight-row:hover { |
| | | background-color: #e6f0ff !important; |
| | | } |
| | | </style> |
| | | <style> |
| | | .highlight-row { |
| | | background-color: #f0f7ff; |
| | | font-weight: bold; |
| | | } |
| | | </style> |