From d061fc9b32f2c3270cc6aa8d4f27eaf1e25a3500 Mon Sep 17 00:00:00 2001 From: sjl <1716605279@qq.com> Date: Mon, 16 Dec 2024 14:09:21 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A3=80=E6=B5=8B=E8=AE=A1=E5=88=92=E5=88=97?= =?UTF-8?q?=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/api/device/interface/device.ts | 2 +- frontend/src/views/home/tabs/dashboard.vue | 61 +++++++--- .../components/errorStandardPopup.vue | 10 +- .../plan/planList/components/planPopup.vue | 110 ++++++++---------- frontend/src/views/plan/planList/index.vue | 2 +- 5 files changed, 100 insertions(+), 85 deletions(-) diff --git a/frontend/src/api/device/interface/device.ts b/frontend/src/api/device/interface/device.ts index a5e48f1..8143ff8 100644 --- a/frontend/src/api/device/interface/device.ts +++ b/frontend/src/api/device/interface/device.ts @@ -4,7 +4,7 @@ import type { ReqPage,ResPage } from '@/api/interface' export namespace Device { /** - * 电能质量指标字典数据表格分页查询参数 + * 被检设备表格分页查询参数 */ export interface ReqPqDevParams extends ReqPage{ id: string; // 装置序号id 必填 diff --git a/frontend/src/views/home/tabs/dashboard.vue b/frontend/src/views/home/tabs/dashboard.vue index fc519cd..33d7749 100644 --- a/frontend/src/views/home/tabs/dashboard.vue +++ b/frontend/src/views/home/tabs/dashboard.vue @@ -37,11 +37,12 @@ { - console.log('123111',id); + console.log('1qaz') currentId.value = id; // 设置当前ID - const boundPqDevList=ref([])//根据检测计划id查询出所有已绑定的设备 const pqDevList_Result2 = await getBoundPqDevList({'planId': id, 'checkStateList':[0,1,2]}); boundPqDevList.value = pqDevList_Result2.data as Device.ResPqDev[]; - console.log('饼图',boundPqDevList.value) + + // 初始化计数对象 + const checkStateCount: { [key: number]: number } = { 0: 0, 1: 0, 2: 0, 3: 0 }; + // 遍历 boundPqDevList 并更新计数对象 + boundPqDevList.value.forEach(t => { + if (t.checkState !== undefined && t.checkState !== null && checkStateCount[t.checkState] !== undefined) { + checkStateCount[t.checkState]++; + } + }); + + // 统计检测结果的数量 + const checkResultCount: { [key: number]: number } = { 0: 0, 1: 0, 2: 0 }; + boundPqDevList.value.forEach(t => { + if (t.checkResult !== undefined && t.checkResult !== null && checkResultCount[t.checkResult] !== undefined) { + checkResultCount[t.checkResult]++; + } + }); + + //报告状态 + const reportStateCount: { [key: number]: number } = { 0: 0, 1: 0, 2: 0 }; + boundPqDevList.value.forEach(t => { + if (t.reportState !== undefined && t.reportState !== null && reportStateCount[t.reportState] !== undefined) { + reportStateCount[t.reportState]++; + } + }); chartsData1.value = [ - { value: 12, name: "未检", itemStyle: { color: '#fac858' } }, - { value: 0, name: "检测中", itemStyle: { color: '#ee6666' } }, - { value: 6, name: "检测完成", itemStyle: { color: '#91cc75' } }, - { value: 2, name: "归档", itemStyle: { color: '#5470c6' } }, + { value: checkStateCount[0], name: "未检", itemStyle: { color: '#fac858' } }, + { value: checkStateCount[1], name: "检测中", itemStyle: { color: '#ee6666' } }, + { value: checkStateCount[2], name: "检测完成", itemStyle: { color: '#91cc75' } }, + { value: checkStateCount[3], name: "归档", itemStyle: { color: '#5470c6' } }, ]; chartsData2.value = [ - { value: 12, name: "未检" , itemStyle: { color: '#fac858' } }, - { value: 3, name: "不符合" , itemStyle: { color: '#ee6666' } }, - { value: 5, name: "符合", itemStyle: { color: '#91cc75' } }, + { value: checkResultCount[0], name: "未检" , itemStyle: { color: '#fac858' } }, + { value: checkResultCount[1], name: "不符合" , itemStyle: { color: '#ee6666' } }, + { value: checkResultCount[2], name: "符合", itemStyle: { color: '#91cc75' } }, ]; chartsData3.value = [ - { value: 12, name: "未检" , itemStyle: { color: '#fac858' } }, - { value: 4, name: "未生成" , itemStyle: { color: '#ee6666' } }, - { value: 4, name: "已生成", itemStyle: { color: '#91cc75' } }, + { value: reportStateCount[0], name: "未检" , itemStyle: { color: '#fac858' } }, + { value: reportStateCount[1], name: "未生成" , itemStyle: { color: '#ee6666' } }, + { value: reportStateCount[2], name: "已生成", itemStyle: { color: '#91cc75' } }, ]; pieRef1.value.init(); @@ -334,6 +361,7 @@ const handleCheckFunction = (val: any) => { switch (val) { case 0://自动检测 + getPieData(currentId.value); tabLabel1.value = "设备检测"; break; case 1://手动检测 @@ -394,7 +422,6 @@ onMounted(async () => { state: 0 }; const planList = await getPlanListByPattern(reqPlan); - console.log('1111111111111111') if (chartsInfoRef.value) { resizeObserver.observe(chartsInfoRef.value); } diff --git a/frontend/src/views/machine/errorSystem/components/errorStandardPopup.vue b/frontend/src/views/machine/errorSystem/components/errorStandardPopup.vue index 297d133..34e74d8 100644 --- a/frontend/src/views/machine/errorSystem/components/errorStandardPopup.vue +++ b/frontend/src/views/machine/errorSystem/components/errorStandardPopup.vue @@ -20,8 +20,12 @@ - - + +
+ +
+
+
@@ -200,4 +204,6 @@ const props = defineProps<{ display: block; /* 使每个label标签上下排列 */ margin-bottom: 10px; /* 调整两个label之间的间距 */ } + + diff --git a/frontend/src/views/plan/planList/components/planPopup.vue b/frontend/src/views/plan/planList/components/planPopup.vue index e8286b0..a0f2055 100644 --- a/frontend/src/views/plan/planList/components/planPopup.vue +++ b/frontend/src/views/plan/planList/components/planPopup.vue @@ -93,6 +93,9 @@ import { type TestScript } from '@/api/device/interface/testScript'; import { type ErrorSystem } from '@/api/device/interface/error'; import { type Device } from '@/api/device/interface/device'; +import { Loading } from '@element-plus/icons-vue/dist/types'; + + const dictStore = useDictStore() // 定义弹出组件元信息 @@ -111,20 +114,21 @@ - const unboundPqDevList=ref([])//指定模式下所有未绑定的设备 - const boundPqDevList=ref([])//根据检测计划id查询出所有已绑定的设备 + const unboundPqDevList=ref([])//指定模式下所有未绑定的设备 + const boundPqDevList=ref([])//根据检测计划id查询出所有已绑定的设备 const value = ref([]) const allData = computed(() => generateData()) const generateData = () => { - const unboundData = unboundPqDevList.value.map((i: Device.ReqPqDevParams) => ({ + const unboundData = unboundPqDevList.value.map((i: Device.ResPqDev) => ({ key: i.id, label: i.name, //tips: i.description })) - const boundData = boundPqDevList.value.map((i: Device.ReqPqDevParams) => ({ + const boundData = boundPqDevList.value.map((i: Device.ResPqDev) => ({ key: i.id, label: i.name, //tips: i.description + disabled:i.checkState != 0 , })) return [...unboundData, ...boundData] } @@ -226,17 +230,15 @@ const rules: Ref>> = ref({ if (valid) { formContent.devIds = value.value // 将 formContent.devIds 转换为 ReqPqDevParams 数组 - boundPqDevList.value = pqDevList.value - .filter(device => formContent.devIds.includes(device.id)) - .map(device => ({ - id: device.id, - name: device.name, - devType: device.devType, - createTime: device.createDate, - pattern: device.pattern, - pageNum: 1, - pageSize: 10 - })); + // boundPqDevList.value = pqDevList.value + // .filter(device => formContent.devIds.includes(device.id)) + // .map(device => ({ + // id: device.id, + // name: device.name, + // devType: device.devType, + // createTime: device.createDate, + // pattern: device.pattern, + // })); console.log('保持',formContent.devIds) if (formContent.id) { @@ -246,9 +248,9 @@ const rules: Ref>> = ref({ await updatePlan({...formContent,'sourceIds':[formContent.sourceIds],'datasourceIds':[formContent.datasourceIds]}); } ElMessage.success({ message: `${dialogTitle.value}成功!` }) - console.log('保存完成后还有吗',boundPqDevList) - console.log('保存完成后还有吗1',formContent.devIds) - console.log('保存完成后还有吗2',unboundPqDevList) + console.log('保存完成后还有绑定',boundPqDevList) + console.log('保存完成后还有表单',formContent.devIds) + console.log('保存完成后还有未绑定',unboundPqDevList) } else { // 新增需要把设备模式转成字典ID const patternItem = dictStore.getDictData('Pattern').find(item => item.name === formContent.pattern); @@ -284,15 +286,7 @@ const open = async (sign: string, data.pattern = patternId mode.value = currentMode titleType.value = sign - dialogVisible.value = true - - const pqSource_Result = await getTestSourceList(data); - pqSourceList.value = pqSource_Result.data as TestSource.ResTestSource[]; - const PqScript_Result = await getPqScriptList(data); - pqScriptList.value = PqScript_Result.data as TestScript.ResTestScript[]; - const PqErrSys_Result = await getPqErrSysList(); - pqErrSysList.value = PqErrSys_Result.data as unknown as ErrorSystem.ErrorSystemList[]; - + if (data.id) { Object.assign(formContent,{ ...data }) } else { @@ -303,35 +297,41 @@ const open = async (sign: string, if(sign == 'add') { - const pqDevList_Result = await getUnboundPqDevList(data); + const [pqSource_Result, PqScript_Result, PqErrSys_Result,pqDevList_Result] = await Promise.all([ + getTestSourceList(data), + getPqScriptList(data), + getPqErrSysList(), + getUnboundPqDevList(data) + ]); + + pqSourceList.value = pqSource_Result.data as TestSource.ResTestSource[]; + pqScriptList.value = PqScript_Result.data as TestScript.ResTestScript[]; + pqErrSysList.value = PqErrSys_Result.data as unknown as ErrorSystem.ErrorSystemList[]; pqDevList.value = pqDevList_Result.data as Device.ResPqDev[]; // 初始化 boundPqDevList 为空数组 - unboundPqDevList.value = pqDevList.value.map((item) => ({ - id: item.id, - name: item.name, - devType: item.devType, - createTime: item.createDate, - pattern: item.pattern, - pageNum: 1, - pageSize: 10 - })); + unboundPqDevList.value = pqDevList.value boundPqDevList.value = []; }else{//编辑时先给表单赋值(这会没接收被检设备),需要手动再给被检设备复制后整体表单赋值 - const boundPqDevList_Result = await getBoundPqDevList({ 'planId': data.id }); - const unboundPqDevList_Result = await getUnboundPqDevList(data); + const [pqSource_Result, PqScript_Result, PqErrSys_Result,boundPqDevList_Result, unboundPqDevList_Result] = await Promise.all([ + getTestSourceList(data), + getPqScriptList(data), + getPqErrSysList(), + getBoundPqDevList({ 'planId': data.id }), + getUnboundPqDevList(data,) + ]); + pqSourceList.value = pqSource_Result.data as TestSource.ResTestSource[]; + pqScriptList.value = PqScript_Result.data as TestScript.ResTestScript[]; + pqErrSysList.value = PqErrSys_Result.data as unknown as ErrorSystem.ErrorSystemList[]; const boundData = Array.isArray(boundPqDevList_Result.data) ? boundPqDevList_Result.data : []; const unboundData = Array.isArray(unboundPqDevList_Result.data) ? unboundPqDevList_Result.data : []; - console.log('编辑boundData', boundData) pqDevList.value = [...boundData,...unboundData] as Device.ResPqDev[]; formContent.devIds = boundData.map(i => i.id );// 已绑定设备id集合 Object.assign(formContent,{ ...data }) //设备绑定显示 - unboundPqDevList.value = unboundPqDevList_Result.data as Device.ReqPqDevParams[]; - boundPqDevList.value = boundPqDevList_Result.data as Device.ReqPqDevParams[]; - - console.log('编辑打开时', formContent.devIds) + unboundPqDevList.value = unboundPqDevList_Result.data as Device.ResPqDev[]; + boundPqDevList.value = boundPqDevList_Result.data as Device.ResPqDev[]; } pqToArray();//将对象转为数组 @@ -348,30 +348,12 @@ const open = async (sign: string, } } - // //设备绑定显示 - // const pqDevList_Result1 = await getUnboundPqDevList(data); - // unboundPqDevList.value = pqDevList_Result1.data as Device.ReqPqDevParams[]; - - // const pqDevList_Result2 = await getBoundPqDevList({'planId': data.id}); - // boundPqDevList.value = pqDevList_Result2.data as Device.ReqPqDevParams[]; - - // value.value = boundPqDevList.value.map((i: { id: { toString: () => any } }) => i.id.toString()); - // console.log('1245',value.value) - //设备绑定显示 - // if(sign == 'add') { - - // } else { - - // } - value.value = boundPqDevList.value.map((i: { id: { toString: () => any } }) => i.id.toString()); - console.log('1245',value.value) - + // 所有数据加载完成后显示对话框 + dialogVisible.value = true; } - - function pqToArray() { const sourceArray1 = Array.isArray(pqSourceList.value) ? pqSourceList.value : [] // 将 pqSource_Result 转换成 { label, value } 数组 diff --git a/frontend/src/views/plan/planList/index.vue b/frontend/src/views/plan/planList/index.vue index d2278ba..7c9bc97 100644 --- a/frontend/src/views/plan/planList/index.vue +++ b/frontend/src/views/plan/planList/index.vue @@ -153,7 +153,7 @@ const columns = reactive[]>([ width: 200, render: scope => { return ( - showData(scope.row.errorSysId || '')}> + showData(scope.row.errorSysName || '')}> {scope.row.errorSysName} )