预检测
This commit is contained in:
@@ -35,11 +35,11 @@
|
||||
<span>{{ node.label }}</span>
|
||||
<!-- 子节点右侧图标 + tooltip -->
|
||||
<el-tooltip
|
||||
v-if="node.label!='未检' && node.label!='检测中' && node.label!='检测完成'"
|
||||
v-if="node.label!='未检' && node.label!='检测中' && node.label!='检测完成' && hasChildrenInPlanTable(node.data)"
|
||||
placement="top"
|
||||
:manual="true"
|
||||
content="子计划信息">
|
||||
<Menu
|
||||
<List
|
||||
@click.stop="childDetail(node.data)"
|
||||
style="width: 16px; height: 16px; margin-left: 8px; cursor: pointer; color: var(--el-color-primary)"
|
||||
/>
|
||||
@@ -54,12 +54,15 @@
|
||||
</template>
|
||||
<script lang='ts' setup>
|
||||
import { type Plan } from '@/api/plan/interface';
|
||||
import { Menu, Platform, CircleCheck,Loading } from '@element-plus/icons-vue'
|
||||
import { Menu, Platform ,List} from '@element-plus/icons-vue'
|
||||
import { nextTick, onMounted, PropType, ref, watch } from 'vue';
|
||||
import { useRouter } from 'vue-router'
|
||||
import {useCheckStore} from "@/stores/modules/check";
|
||||
import { ElTooltip } from 'element-plus';
|
||||
import SourceOpen from '@/views/plan/planList/components/childrenPlan.vue'
|
||||
import {getPlanList } from '@/api/plan/plan.ts'
|
||||
import { useModeStore } from '@/stores/modules/mode' // 引入模式 store
|
||||
import { useDictStore } from '@/stores/modules/dict'
|
||||
|
||||
|
||||
const openSourceView = ref()
|
||||
@@ -68,6 +71,8 @@ const checkStore = useCheckStore()
|
||||
const filterText = ref('')
|
||||
const treeRef = ref()
|
||||
const data: any = ref([])
|
||||
const modeStore = useModeStore()
|
||||
const dictStore = useDictStore()
|
||||
|
||||
const defaultProps = {
|
||||
children: 'children',
|
||||
@@ -124,12 +129,12 @@ const clickTableToTree = (val: any,id:any) => {
|
||||
}
|
||||
}
|
||||
|
||||
const {updateSelectedTreeNode,width,height,planArray} = defineProps<{
|
||||
const {updateSelectedTreeNode,width,height,planTable} = defineProps<{
|
||||
updateSelectedTreeNode:Function;
|
||||
width: number;
|
||||
height: number;
|
||||
planArray?: Plan.ReqPlan[];
|
||||
}>();
|
||||
planTable?: Array<[]>;
|
||||
}>();
|
||||
|
||||
watch(
|
||||
() => searchForm.value.planName,
|
||||
@@ -141,6 +146,20 @@ watch(
|
||||
},
|
||||
)
|
||||
|
||||
const hasChildrenInPlanTable = (nodeData: Plan.ResPlan) => {
|
||||
try {
|
||||
// 在 planTable 中查找对应的节点数据
|
||||
const foundItem = tableData.value.find((item: any) => item.id === nodeData.id);
|
||||
|
||||
// 检查是否有 children 且 children 数组不为空
|
||||
return foundItem && Array.isArray(foundItem.children) && foundItem.children.length > 0;
|
||||
} catch (error) {
|
||||
console.error('检查子节点时出错:', error);
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
const idd = ref('')
|
||||
const handleNodeClick = (data: Plan.ResPlan) => {
|
||||
|
||||
@@ -170,15 +189,49 @@ const detail = () => {
|
||||
}
|
||||
|
||||
|
||||
|
||||
const childDetail = (data: Plan.ResPlan) => {
|
||||
console.log('planArray',planArray)
|
||||
openSourceView.value.open("检测计划详情",data)
|
||||
const filteredPlans = tableData.value.filter(item => item.id === data.id);
|
||||
|
||||
// 确保有匹配项再访问 [0]
|
||||
if (filteredPlans.length > 0 && openSourceView.value) {
|
||||
openSourceView.value.open("检测计划详情", filteredPlans[0]);
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
// console.log()
|
||||
|
||||
function buildTree(flatList: any[]): any[] {
|
||||
const map = new Map();
|
||||
const tree: any[] = [];
|
||||
|
||||
// First, create a map of all items by id for fast lookup
|
||||
flatList.forEach(item => {
|
||||
map.set(item.id, { ...item, children: [] });
|
||||
});
|
||||
|
||||
// Then, assign each item to its parent's children array
|
||||
flatList.forEach(item => {
|
||||
if (item.fatherPlanId && map.has(item.fatherPlanId)) {
|
||||
map.get(item.fatherPlanId).children.push(map.get(item.id));
|
||||
} else if (item.fatherPlanId === '0') {
|
||||
// Items with fatherPlanId '0' are root nodes
|
||||
tree.push(map.get(item.id));
|
||||
}
|
||||
});
|
||||
|
||||
return tree;
|
||||
}
|
||||
|
||||
|
||||
|
||||
const tableData = ref<any[]>([])
|
||||
onMounted(async () => {
|
||||
if(modeStore.currentMode != '比对式')
|
||||
return;
|
||||
const patternId = dictStore.getDictData('Pattern').find(item => item.name === modeStore.currentMode)?.id;
|
||||
const result = await getPlanList({'patternId' : patternId});
|
||||
tableData.value = buildTree(result.data as any[]);
|
||||
})
|
||||
|
||||
defineExpose({ getTreeData ,clickTableToTree})
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user