This commit is contained in:
sjl
2025-01-16 14:24:55 +08:00
parent 891c6d8e93
commit 55ae64b3e1
8 changed files with 113 additions and 32 deletions

View File

@@ -4,7 +4,8 @@
<el-row :gutter='10'>
<el-col :lg='4' :xl='4' :md='4' :sm='4'>
<div class='left_tree'>
<tree ref='treeRef' :updateSelectedTreeNode='getPieData || (() => {})' />
<!-- <tree ref='treeRef' :updateSelectedTreeNode='getPieData || (() => {})' /> -->
<tree ref='treeRef' :updateSelectedTreeNode='updateData|| (() => {})' />
</div>
</el-col>
<el-col :lg='20' :xl='20' :md='20' :sm='20'>
@@ -266,16 +267,10 @@ const findPlanById = (plans: Plan.ReqPlan[], id: string): Plan.ReqPlan | undefin
return undefined
}
const getPieData = async (id: string) => {
currentId.value = id // 设置当前ID
// 初始化计数对象
const checkStateCount: { [key: number]: number } = { 0: 0, 1: 0, 2: 0, 3: 0 }
const checkResultCount: { [key: number]: number } = { 0: 0, 1: 0, 2: 0 }
const reportStateCount: { [key: number]: number } = { 0: 0, 1: 0, 2: 0 }
if (id) {
const boundPqDevList = ref<Device.ResPqDev[]>([])//根据检测计划id查询出所有已绑定的设备
const plan = findPlanById(planList.value?.data || [], id)
planName.value = '所选计划:' + plan.name
const updateData = (id: string) => {
getPieData(id);//刷新饼图
//获取点击树的父节点名字
const parentNodeName = ref('')
for (let i = 0; i < planList.value.data.length; i++) {
@@ -293,6 +288,19 @@ const getPieData = async (id: string) => {
}else{
handleCheckFunction(0)
}
}
const getPieData = async (id: string) => {
currentId.value = id // 设置当前ID
// 初始化计数对象
const checkStateCount: { [key: number]: number } = { 0: 0, 1: 0, 2: 0, 3: 0 }
const checkResultCount: { [key: number]: number } = { 0: 0, 1: 0, 2: 0 }
const reportStateCount: { [key: number]: number } = { 0: 0, 1: 0, 2: 0 }
if (id) {
const boundPqDevList = ref<Device.ResPqDev[]>([])//根据检测计划id查询出所有已绑定的设备
const plan = findPlanById(planList.value?.data || [], id)
planName.value = '所选计划:' + plan.name
select_Plan.value = plan
if (plan) {
@@ -302,6 +310,7 @@ const getPieData = async (id: string) => {
// 处理未找到计划的情况
isTimeCheck.value = false // 或者其他默认值
}
console.log('饼图getBoundPqDevList')
const pqDevList_Result2 = await getBoundPqDevList({ 'planId': id, 'checkStateList': [0, 1, 2, 3] })
boundPqDevList.value = pqDevList_Result2.data as Device.ResPqDev[]
// 遍历 boundPqDevList 并更新计数对象
@@ -431,7 +440,8 @@ const resizeObserver = new ResizeObserver(entries => {
}
})
onBeforeMount(async () => {
const initPlan = async () => {
const patternId = dictStore.getDictData('Pattern').find(item => item.name === modeStore.currentMode)?.id ?? ''//获取数据字典中对应的id
const reqPlan: Plan.ReqPlan = {
pattern: patternId,
@@ -455,8 +465,10 @@ onBeforeMount(async () => {
state: 0,
}
planList.value = (await getPlanListByPattern(reqPlan)) as ResultData<Plan.ReqPlan[]>
}
console.log(planList.value.data)
onBeforeMount(async () => {
await initPlan()
for (let i = 0; i < planList.value.data.length; i++) {
if (Array.isArray(planList.value.data[i].children) && planList.value.data[i].children.length > 0) {
currentId.value = planList.value.data[i].children[0].id; // 直接赋值第一个 children 的 id
@@ -483,11 +495,13 @@ onUnmounted(() => {
}
})
const handleBatchGenerate = () => {
const handleBatchGenerate = async () => {
console.log('批量生成按钮被点击了');
// 在这里添加其他逻辑,比如显示对话框、更新状态等
await initPlan()
treeRef.value.clickTableToTree(planList.value.data,currentId.value)
getPieData(currentId.value)
if (form.value.activeTabs === 0)//设备检测
{
const tabledata = deviceData.filter((item) => item.document_State === '未归档')