检测计划列表
This commit is contained in:
@@ -4,7 +4,7 @@ import type { ReqPage,ResPage } from '@/api/interface'
|
||||
export namespace Device {
|
||||
|
||||
/**
|
||||
* 电能质量指标字典数据表格分页查询参数
|
||||
* 被检设备表格分页查询参数
|
||||
*/
|
||||
export interface ReqPqDevParams extends ReqPage{
|
||||
id: string; // 装置序号id 必填
|
||||
|
||||
@@ -37,11 +37,12 @@
|
||||
<pie
|
||||
:customData="{
|
||||
title: '设备检测状态',
|
||||
textAlign: 'center',
|
||||
textAlign: 'left',
|
||||
}"
|
||||
:legendData="{
|
||||
icon: 'circle',
|
||||
left: 'left',
|
||||
top: 'middle',
|
||||
}"
|
||||
:chartsData="chartsData1"
|
||||
ref="pieRef1"
|
||||
@@ -51,11 +52,12 @@
|
||||
<pie
|
||||
:customData="{
|
||||
title: '设备检测结果',
|
||||
textAlign: 'center',
|
||||
textAlign: 'left',
|
||||
}"
|
||||
:legendData="{
|
||||
icon: 'circle',
|
||||
left: 'left',
|
||||
top: 'middle',
|
||||
}"
|
||||
:chartsData="chartsData2"
|
||||
ref="pieRef2"
|
||||
@@ -65,7 +67,7 @@
|
||||
<pie
|
||||
:customData="{
|
||||
title: '设备报告状态',
|
||||
textAlign: 'center',
|
||||
textAlign: 'left',
|
||||
label: {
|
||||
normal: {
|
||||
position: 'inner',
|
||||
@@ -75,6 +77,7 @@
|
||||
:legendData="{
|
||||
icon: 'circle',
|
||||
left: 'left',
|
||||
top: 'middle',
|
||||
}"
|
||||
:chartsData="chartsData3"
|
||||
ref="pieRef3"
|
||||
@@ -119,6 +122,7 @@ import { type Plan } from "@/api/plan/interface";
|
||||
import type { CollapseModelValue } from "element-plus/es/components/collapse/src/collapse.mjs";
|
||||
import { type Device } from "@/api/device/interface/device";
|
||||
import { getBoundPqDevList } from '@/api/plan/plan.ts'
|
||||
import { CENTERED_ALIGNMENT } from "element-plus/es/components/virtual-list/src/defaults";
|
||||
|
||||
const dictStore = useDictStore()
|
||||
const modeStore = useModeStore();
|
||||
@@ -267,32 +271,55 @@ const chartsData1: any = ref([]),
|
||||
chartsData2: any = ref([]),
|
||||
chartsData3: any = ref([]);
|
||||
const getPieData = async (id: string) => {
|
||||
console.log('123111',id);
|
||||
console.log('1qaz')
|
||||
currentId.value = id; // 设置当前ID
|
||||
|
||||
|
||||
const boundPqDevList=ref<Device.ResPqDev[]>([])//根据检测计划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);
|
||||
}
|
||||
|
||||
@@ -20,8 +20,12 @@
|
||||
<el-table-column prop="condition" label="测量条件" />
|
||||
<el-table-column prop="maxErrorValue" label="最大误差" />
|
||||
</el-table>
|
||||
<label>注1:UN:测量的标称电压;IN:测量仪器的标称电流;Uh和Ih:测量值,h表示谐波次数。</label>
|
||||
<label>注2:对于数字式接入监测终端,与电能质量信号采集单元联合准确度需满足本表要求。</label>
|
||||
</div>
|
||||
<div>
|
||||
<label class="left-align-label">注1:UN:测量的标称电压;IN:测量仪器的标称电流;Uh和Ih:测量值,h表示谐波次数。</label>
|
||||
</div>
|
||||
<div>
|
||||
<label class="left-align-label">注2:对于数字式接入监测终端,与电能质量信号采集单元联合准确度需满足本表要求。</label>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</template>
|
||||
@@ -200,4 +204,6 @@ const props = defineProps<{
|
||||
display: block; /* 使每个label标签上下排列 */
|
||||
margin-bottom: 10px; /* 调整两个label之间的间距 */
|
||||
}
|
||||
|
||||
|
||||
</style>
|
||||
|
||||
@@ -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<Device.ReqPqDevParams[]>([])//指定模式下所有未绑定的设备
|
||||
const boundPqDevList=ref<Device.ReqPqDevParams[]>([])//根据检测计划id查询出所有已绑定的设备
|
||||
const unboundPqDevList=ref<Device.ResPqDev[]>([])//指定模式下所有未绑定的设备
|
||||
const boundPqDevList=ref<Device.ResPqDev[]>([])//根据检测计划id查询出所有已绑定的设备
|
||||
const value = ref<string[]>([])
|
||||
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<Record<string, Array<FormItemRule>>> = 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<Record<string, Array<FormItemRule>>> = 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 } 数组
|
||||
|
||||
@@ -153,7 +153,7 @@ const columns = reactive<ColumnProps<Plan.ReqPlan>[]>([
|
||||
width: 200,
|
||||
render: scope => {
|
||||
return (
|
||||
<el-link type='primary' link onClick={() => showData(scope.row.errorSysId || '')}>
|
||||
<el-link type='primary' link onClick={() => showData(scope.row.errorSysName || '')}>
|
||||
{scope.row.errorSysName}
|
||||
</el-link>
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user