|
@@ -1573,6 +1573,7 @@
|
|
@close="closeformulaComp"
|
|
@close="closeformulaComp"
|
|
>
|
|
>
|
|
<FormulaEdit
|
|
<FormulaEdit
|
|
|
|
+ :istableType="!isNodeType"
|
|
:fromcurNode="curTreeData"
|
|
:fromcurNode="curTreeData"
|
|
:projectid="projectid"
|
|
:projectid="projectid"
|
|
:wbsid="id"
|
|
:wbsid="id"
|
|
@@ -3072,33 +3073,55 @@ export default {
|
|
}
|
|
}
|
|
},
|
|
},
|
|
// 重新加载整棵树
|
|
// 重新加载整棵树
|
|
- async reloadEntireTree() {
|
|
|
|
- this.isNodeType=false
|
|
|
|
- // 1. 保存当前状态
|
|
|
|
- const currentKey = this.$refs.treeByType.getCurrentKey();
|
|
|
|
- this.saveTreeState();
|
|
|
|
-
|
|
|
|
- // 2. 清空缓存
|
|
|
|
- this.cachedNodes.clear();
|
|
|
|
-
|
|
|
|
- // 3. 获取树组件引用
|
|
|
|
- const tree = this.$refs.treeByType;
|
|
|
|
- if (!tree) return;
|
|
|
|
-
|
|
|
|
- // 4. 清空根节点子节点
|
|
|
|
- const rootNode = tree.store.root;
|
|
|
|
- const rootId = rootNode.childNodes[0].data.id || 'root';
|
|
|
|
-
|
|
|
|
- await this.$nextTick();
|
|
|
|
- tree.updateKeyChildren(rootId, []);
|
|
|
|
-
|
|
|
|
- // 5. 强制重新加载根节点
|
|
|
|
- const root = tree.getNode(rootId);
|
|
|
|
- if (root) {
|
|
|
|
- root.loaded = false;
|
|
|
|
- root.expand(); // 这会触发loadNodeByType
|
|
|
|
|
|
+async reloadEntireTree() {
|
|
|
|
+ this.isNodeType = false;
|
|
|
|
+
|
|
|
|
+ // 1. 保存当前选中节点key和路径
|
|
|
|
+ const tree = this.$refs.treeByType;
|
|
|
|
+ if (!tree) return;
|
|
|
|
+
|
|
|
|
+ const currentKey = tree.getCurrentKey();
|
|
|
|
+ let nodePath = [];
|
|
|
|
+ if (currentKey) {
|
|
|
|
+ const currentNode = tree.getNode(currentKey);
|
|
|
|
+ if (currentNode) {
|
|
|
|
+ // 获取选中节点的所有父节点路径
|
|
|
|
+ let parent = currentNode.parent;
|
|
|
|
+ while (parent && parent.level > 0) {
|
|
|
|
+ nodePath.unshift(parent.data.id);
|
|
|
|
+ parent = parent.parent;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 2. 清空缓存并记录所有已展开节点(用于后续重置)
|
|
|
|
+ const previouslyExpandedNodes = [];
|
|
|
|
+ const collectExpandedNodes = (node) => {
|
|
|
|
+ if (node.expanded && node.level > 0) {
|
|
|
|
+ previouslyExpandedNodes.push(node.data.id);
|
|
}
|
|
}
|
|
- // 6. 等待树重新加载完成
|
|
|
|
|
|
+ if (node.childNodes) {
|
|
|
|
+ node.childNodes.forEach(collectExpandedNodes);
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+ collectExpandedNodes(tree.store.root);
|
|
|
|
+
|
|
|
|
+ this.cachedNodes.clear();
|
|
|
|
+
|
|
|
|
+ // 3. 清空根节点子节点
|
|
|
|
+ const rootNode = tree.store.root;
|
|
|
|
+ const rootId = rootNode.childNodes[0].data.id || 'root';
|
|
|
|
+ await this.$nextTick();
|
|
|
|
+ tree.updateKeyChildren(rootId, []);
|
|
|
|
+
|
|
|
|
+ // 4. 强制重新加载根节点
|
|
|
|
+ const root = tree.getNode(rootId);
|
|
|
|
+ if (root) {
|
|
|
|
+ root.loaded = false;
|
|
|
|
+ root.expand(); // 这会触发loadNodeByType
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 5. 等待树重新加载完成
|
|
await new Promise(resolve => {
|
|
await new Promise(resolve => {
|
|
const checkLoaded = () => {
|
|
const checkLoaded = () => {
|
|
if (root.loaded) {
|
|
if (root.loaded) {
|
|
@@ -3109,52 +3132,67 @@ export default {
|
|
};
|
|
};
|
|
checkLoaded();
|
|
checkLoaded();
|
|
});
|
|
});
|
|
- // 7. 恢复选中状态并获取最新数据
|
|
|
|
|
|
+
|
|
|
|
+ // 6. 重置其他节点的加载状态(使其下次展开时重新加载)
|
|
|
|
+ previouslyExpandedNodes.forEach(nodeId => {
|
|
|
|
+ // 跳过当前选中节点的路径节点
|
|
|
|
+ if (!nodePath.includes(nodeId)) {
|
|
|
|
+ const node = tree.getNode(nodeId);
|
|
|
|
+ if (node) {
|
|
|
|
+ node.loaded = false; // 标记为未加载
|
|
|
|
+ node.expanded = false; // 关闭节点
|
|
|
|
+ // 从缓存中移除(如果存在)
|
|
|
|
+ this.cachedNodes.delete(nodeId);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ // 7. 恢复选中节点路径的展开状态
|
|
|
|
+ this.defaultExpandedKeysType = [...nodePath];
|
|
|
|
+ for (const key of nodePath) {
|
|
|
|
+ const node = tree.getNode(key);
|
|
|
|
+ if (node && !node.expanded) {
|
|
|
|
+ node.expand();
|
|
|
|
+ await new Promise(resolve => setTimeout(resolve, 100));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 8. 恢复选中状态
|
|
if (currentKey) {
|
|
if (currentKey) {
|
|
tree.setCurrentKey(currentKey);
|
|
tree.setCurrentKey(currentKey);
|
|
await this.$nextTick();
|
|
await this.$nextTick();
|
|
- const highlightedEl = document.querySelector('.el-tree--highlight-current .is-current');
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- // 方法1:直接获取当前节点最新数据(推荐)
|
|
|
|
|
|
+
|
|
const currentNode = tree.getNode(currentKey);
|
|
const currentNode = tree.getNode(currentKey);
|
|
if (currentNode) {
|
|
if (currentNode) {
|
|
- console.log('最新节点数据:', currentNode.data);
|
|
|
|
this.currentNodeData = currentNode.data;
|
|
this.currentNodeData = currentNode.data;
|
|
- // this.currentNodeData.tableName = this.currentNodeData.title
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- if(highlightedEl){
|
|
|
|
- this.formData=[{...this.currentNodeData,tableName:this.currentNodeData.title} ]
|
|
|
|
- }else{
|
|
|
|
- this.formData=[]
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- }else{
|
|
|
|
- this.formData=[]
|
|
|
|
|
|
+ const highlightedEl = document.querySelector('.el-tree--highlight-current .is-current');
|
|
|
|
+ this.formData = highlightedEl ?
|
|
|
|
+ [{...this.currentNodeData, tableName: this.currentNodeData.title}] :
|
|
|
|
+ [];
|
|
|
|
+ } else {
|
|
|
|
+ this.formData = [];
|
|
}
|
|
}
|
|
-
|
|
|
|
-
|
|
|
|
}
|
|
}
|
|
- // 6. 恢复状态
|
|
|
|
- await this.$nextTick();
|
|
|
|
- if (this.currentNodeKey) {
|
|
|
|
- tree.setCurrentKey(this.currentNodeKey);
|
|
|
|
- // 方法1:使用getNode获取完整节点信息(推荐)
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
|
|
+},
|
|
|
|
+ // 关闭所有非路径上的展开节点
|
|
|
|
+closeOtherExpandedNodes(tree, keepOpenPath) {
|
|
|
|
+ const closeNodes = (node) => {
|
|
|
|
+ if (node.expanded && node.level > 0) {
|
|
|
|
+ const nodeId = node.data.id;
|
|
|
|
+ // 如果节点不在需要保持展开的路径中,则关闭它
|
|
|
|
+ if (!keepOpenPath.includes(nodeId)) {
|
|
|
|
+ node.expanded = false;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
- // 确保展开状态恢复
|
|
|
|
- this.defaultExpandedKeysType.forEach(key => {
|
|
|
|
- const node = tree.getNode(key);
|
|
|
|
- if (node && !node.expanded) {
|
|
|
|
- node.expand();
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- },
|
|
|
|
|
|
+ if (node.childNodes) {
|
|
|
|
+ node.childNodes.forEach(closeNodes);
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ // 从根节点开始遍历
|
|
|
|
+ closeNodes(tree.store.root);
|
|
|
|
+},
|
|
deleNode(data, node) {
|
|
deleNode(data, node) {
|
|
let pid = data.primaryKeyId ? data.primaryKeyId : data.pKeyId;
|
|
let pid = data.primaryKeyId ? data.primaryKeyId : data.pKeyId;
|
|
this.$confirm(
|
|
this.$confirm(
|
|
@@ -4432,7 +4470,10 @@ clearSearch1() {
|
|
},
|
|
},
|
|
hideEditElementVisible() {
|
|
hideEditElementVisible() {
|
|
this.editElementVisible = false;
|
|
this.editElementVisible = false;
|
|
- this.updateNodeTable();
|
|
|
|
|
|
+ // this.updateNodeTable();
|
|
|
|
+ if(this.isNodeType){
|
|
|
|
+ this.updateNodeTable();
|
|
|
|
+ }
|
|
},
|
|
},
|
|
async getExcelHtml2(pkeyId) {
|
|
async getExcelHtml2(pkeyId) {
|
|
const { data: res } = await getExcelHtml({ pkeyId });
|
|
const { data: res } = await getExcelHtml({ pkeyId });
|