fix:任务树的展开收起功能修改

This commit is contained in:
2025-11-24 15:35:17 +08:00
parent 846870ab99
commit 9d29e59c40
4 changed files with 60 additions and 11 deletions

View File

@@ -16,7 +16,8 @@ export enum NODE_TYPE {
/** 混合类型不是某一个具体的nodeType合并多个 nodeType 的属性到一个 node 上时使用 */
MIXED = 'mixed',
/** 算例 */
RUN = 'run'
RUN = 'run',
WORKSPACE = 'workspace'
}
export enum LEVEL_TYPE {
/** 非任务和指标 */

View File

@@ -75,7 +75,7 @@ const props = defineProps({
default: () => { },
},
});
const emits = defineEmits(['filterParamChangeFn']);
const emits = defineEmits(['filterParamChangeFn', 'expandTree']);
const filterFormData = reactive({
ProjectType: '',
@@ -93,7 +93,7 @@ const dropdownList = ref([
value: 'all',
},
{
name: '节点',
name: '工位',
value: 'node',
},
{
@@ -108,6 +108,8 @@ const dropdownList = ref([
const expendChangeFn = (data: string) => {
filterFormData.expendType = data;
emits('expandTree', data);
// filterParamChangeFn();
};

View File

@@ -2,7 +2,7 @@
<div class="task-tree-content" @contextmenu.prevent="">
<div class="filter-content">
<filterProject @filter-param-change-fn="filterParamChangeFn"></filterProject>
<filterProject @filter-param-change-fn="filterParamChangeFn" @expand-tree="changeExpendTypeFn"></filterProject>
</div>
<div class="tree-content">
<el-tree
@@ -167,14 +167,60 @@ const showFileMenu = ref(false);
const showRunCreateOrEditWindow = ref(false);
const showRunVersionTreeWindow = ref(false);
const taskTreeRef = ref();
const defaultExpandKeys = ref<any>([]);
const changeExpendTypeFn = (data:any) => {
defaultExpandKeys.value = [];
setExpandElementFn(dataSource.value, data);
for (const key in taskTreeRef.value.store.nodesMap) {
if (defaultExpandKeys.value.includes(key)) {
taskTreeRef.value.store.nodesMap[key].expanded = true;
} else {
taskTreeRef.value.store.nodesMap[key].expanded = false;
}
}
};
const setExpandElementFn = (list:any, flag:any = 'all') => {
for (let i = 0;i < list.length;i++) {
if (flag === 'all') {
defaultExpandKeys.value.push(list[i].id);
}
if (flag === 'node') {
if (list[i].nodeType === NODE_TYPE.WORKSPACE) {
defaultExpandKeys.value.push(list[i].id);
}
}
if (flag === 'task') {
if (list[i].nodeType === NODE_TYPE.TASK) {
defaultExpandKeys.value.push(list[i].id);
}
}
if (flag === 'run') {
if (list[i].nodeType === NODE_TYPE.RUN) {
defaultExpandKeys.value.push(list[i].id);
}
}
if (list[i]?.children?.length) {
setExpandElementFn(list[i]?.children, flag);
}
}
};
// 过滤数内容
const filterParamChangeFn = async (data: any) => {
// currentNodeInfo.value = {};
emits('nodeClickFn', { node: currentNodeInfo.value });
await getTaskRunTreeDataFn(data);
console.log(defaultExpandKeys.value, 'defaultExpandKeys.value');
};
const dataSource = ref<any[]>([

View File

@@ -113,10 +113,10 @@ const handleCloseFn = () => {
// 确认事件
const createSuccessFn = () => {
if (!runInfoFormData.templateName) {
runInfoFormData.templateName = 1;
// runInfoFormData.templateName = 1;
// ElMessage.warning('未选择流程模板,无法新建算例!');
// return;
ElMessage.warning('未选择流程模板,无法新建算例!');
return;
}
if ( operateType.value != 'editRun') {
@@ -136,7 +136,7 @@ const createSuccessFn = () => {
// 拼接改变
const changeJoinFn = () => {
if (runInfoFormData.isJointProjectInfo) {
runInfoFormData.runNames = props.divInfo.nodeName || props.divInfo.runName + '_算例' + new Date().getTime();
runInfoFormData.runNames = props.divInfo.nodeName || props.divInfo.runName + '_V1' ;
} else {
runInfoFormData.runNames = '算例_' + 'V1';
}
@@ -173,7 +173,7 @@ watch(() => props.operateFlag, (newVal) => {
// 如果是新增算例
if (props.divInfo && props.divInfo?.nodeType === NODE_TYPE.TASK) {
if (runInfoFormData.isJointProjectInfo) {
runInfoFormData.runNames = props.divInfo.nodeName + '_算例' + new Date().getTime();
runInfoFormData.runNames = props.divInfo.nodeName + '_算例V1' ;
}
runInfoFormData.templateName = props.divInfo.flowTemplateName;
}
@@ -181,7 +181,7 @@ watch(() => props.operateFlag, (newVal) => {
// 如果是新增子算例或者复制算例
if (props.divInfo && props.divInfo?.nodeType === NODE_TYPE.RUN) {
if (runInfoFormData.isJointProjectInfo) {
runInfoFormData.runNames = props.divInfo.runName + '_算例' + new Date().getTime();
runInfoFormData.runNames = props.divInfo.runName + '_算例V1';
}
runInfoFormData.templateName = props.divInfo.flowTemplateName;
}