检测计划列表

This commit is contained in:
sjl
2024-12-16 14:09:21 +08:00
parent ae47d429ba
commit d061fc9b32
5 changed files with 100 additions and 85 deletions

View File

@@ -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 } 数组

View File

@@ -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>
)