新建检测计划时,检测项下拉框要和误差体系里配置的要一致
This commit is contained in:
@@ -148,4 +148,9 @@ export const importSubPlanCheckData = (params: Plan.ResPlan) => {
|
|||||||
// 合并子检测计划检测结果数据
|
// 合并子检测计划检测结果数据
|
||||||
export const mergeSubPlanCheckData = (params: Plan.ResPlan) => {
|
export const mergeSubPlanCheckData = (params: Plan.ResPlan) => {
|
||||||
return http.upload(`/adPlan/mergePlanCheckData?planId=${params.id}`)
|
return http.upload(`/adPlan/mergePlanCheckData?planId=${params.id}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
//根据误差体系id获取测试项
|
||||||
|
export const getPqErrSysTestItemList = (params: Plan.ResPlan) => {
|
||||||
|
return http.get(`/pqErrSys/getTestItems?id=${params.errorSysId}`)
|
||||||
}
|
}
|
||||||
@@ -122,6 +122,7 @@
|
|||||||
clearable
|
clearable
|
||||||
filterable
|
filterable
|
||||||
placeholder="请选择误差体系"
|
placeholder="请选择误差体系"
|
||||||
|
@change="handleErrorSysChange"
|
||||||
>
|
>
|
||||||
<el-option
|
<el-option
|
||||||
v-for="(option, index) in pqErrorArray"
|
v-for="(option, index) in pqErrorArray"
|
||||||
@@ -382,7 +383,8 @@ import {
|
|||||||
getPqScriptList,
|
getPqScriptList,
|
||||||
getTestSourceList,
|
getTestSourceList,
|
||||||
getUnboundPqDevList,
|
getUnboundPqDevList,
|
||||||
updatePlan
|
updatePlan,
|
||||||
|
getPqErrSysTestItemList
|
||||||
} from '@/api/plan/plan.ts'
|
} from '@/api/plan/plan.ts'
|
||||||
import { useDictStore } from '@/stores/modules/dict'
|
import { useDictStore } from '@/stores/modules/dict'
|
||||||
import { type TestSource } from '@/api/device/interface/testSource'
|
import { type TestSource } from '@/api/device/interface/testSource'
|
||||||
@@ -402,6 +404,7 @@ import { downloadTemplate, importPqDev } from '@/api/device/device/index'
|
|||||||
import { getTestConfig } from '@/api/system/base'
|
import { getTestConfig } from '@/api/system/base'
|
||||||
import { getRegRes } from '@/api/system/versionRegister'
|
import { getRegRes } from '@/api/system/versionRegister'
|
||||||
|
|
||||||
|
|
||||||
const modeStore = useModeStore()
|
const modeStore = useModeStore()
|
||||||
const AppSceneStore = useAppSceneStore()
|
const AppSceneStore = useAppSceneStore()
|
||||||
const dictStore = useDictStore()
|
const dictStore = useDictStore()
|
||||||
@@ -706,6 +709,7 @@ const save = () => {
|
|||||||
|
|
||||||
// 打开弹窗,可能是新增,也可能是编辑
|
// 打开弹窗,可能是新增,也可能是编辑
|
||||||
const open = async (sign: string, data: Plan.ReqPlan, currentMode: string, plan: number) => {
|
const open = async (sign: string, data: Plan.ReqPlan, currentMode: string, plan: number) => {
|
||||||
|
|
||||||
unboundPqDevList.value = []
|
unboundPqDevList.value = []
|
||||||
boundPqDevList.value = []
|
boundPqDevList.value = []
|
||||||
//处理异步调用
|
//处理异步调用
|
||||||
@@ -715,27 +719,6 @@ const open = async (sign: string, data: Plan.ReqPlan, currentMode: string, plan:
|
|||||||
titleType.value = sign
|
titleType.value = sign
|
||||||
isSelectDisabled.value = false
|
isSelectDisabled.value = false
|
||||||
planType.value = plan
|
planType.value = plan
|
||||||
console.log('planType.value', planType.value)
|
|
||||||
//比对式测试项下拉框
|
|
||||||
if (mode.value == '比对式') {
|
|
||||||
const dictCode = 'Script_Error'
|
|
||||||
const resDictTree: Dict.ResDictTree = {
|
|
||||||
name: '',
|
|
||||||
id: '',
|
|
||||||
pid: '',
|
|
||||||
pids: '',
|
|
||||||
code: dictCode,
|
|
||||||
sort: 0
|
|
||||||
}
|
|
||||||
const result = await getDictTreeByCode(resDictTree)
|
|
||||||
const allOptions = convertToOptions(result.data as Dict.ResDictTree[])
|
|
||||||
// 提取第二层节点
|
|
||||||
allOptions.forEach(option => {
|
|
||||||
if (option.children && option.children.length > 0) {
|
|
||||||
secondLevelOptions.push(...option.children)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sign == 'add') {
|
if (sign == 'add') {
|
||||||
resetFormContent()
|
resetFormContent()
|
||||||
@@ -810,6 +793,9 @@ const open = async (sign: string, data: Plan.ReqPlan, currentMode: string, plan:
|
|||||||
formContent.sourceIds = pqSourceList.value[0]?.id ?? ''
|
formContent.sourceIds = pqSourceList.value[0]?.id ?? ''
|
||||||
formContent.datasourceIds = dictStore.getDictData('Datasource')[0]?.code ?? ''
|
formContent.datasourceIds = dictStore.getDictData('Datasource')[0]?.code ?? ''
|
||||||
formContent.dataRule = dictStore.getDictData('Data_Rule')[0]?.id ?? ''
|
formContent.dataRule = dictStore.getDictData('Data_Rule')[0]?.id ?? ''
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
//编辑时先给表单赋值(这会没接收被检设备),需要手动再给被检设备复制后整体表单赋值
|
//编辑时先给表单赋值(这会没接收被检设备),需要手动再给被检设备复制后整体表单赋值
|
||||||
|
|
||||||
@@ -925,6 +911,16 @@ const open = async (sign: string, data: Plan.ReqPlan, currentMode: string, plan:
|
|||||||
|
|
||||||
pqToArray() //将对象转为数组
|
pqToArray() //将对象转为数组
|
||||||
|
|
||||||
|
|
||||||
|
//比对式测试项下拉框
|
||||||
|
if (mode.value == '比对式') {
|
||||||
|
// 如果是编辑模式且已有误差体系ID,则加载对应的测试项
|
||||||
|
if (formContent.errorSysId) {
|
||||||
|
await loadTestItemsForErrorSys(formContent.errorSysId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (mode.value != '比对式') {
|
if (mode.value != '比对式') {
|
||||||
selectByMode.value = false
|
selectByMode.value = false
|
||||||
// 将 formContent.sourceIds 从数组转换为字符串
|
// 将 formContent.sourceIds 从数组转换为字符串
|
||||||
@@ -961,6 +957,63 @@ const open = async (sign: string, data: Plan.ReqPlan, currentMode: string, plan:
|
|||||||
dialogVisible.value = true
|
dialogVisible.value = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 误差体系选择变化时的处理函数
|
||||||
|
const handleErrorSysChange = async (value: string) => {
|
||||||
|
// 清空测试项选择
|
||||||
|
formContent.testItems = [];
|
||||||
|
|
||||||
|
// 如果是比对式模式且选择了误差体系
|
||||||
|
if (mode.value === '比对式' && value) {
|
||||||
|
try {
|
||||||
|
const res = await getPqErrSysTestItemList({ errorSysId: value });
|
||||||
|
// 清空原有选项
|
||||||
|
secondLevelOptions.length = 0;
|
||||||
|
|
||||||
|
if (res.data) {
|
||||||
|
// 将返回的键值对对象转换为下拉选项格式
|
||||||
|
Object.keys(res.data).forEach(key => {
|
||||||
|
secondLevelOptions.push({
|
||||||
|
value: key,
|
||||||
|
label: res.data[key]
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('获取测试项失败:', error);
|
||||||
|
// 发生错误时清空选项
|
||||||
|
secondLevelOptions.length = 0;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 如果没有选择误差体系,清空测试项选项
|
||||||
|
secondLevelOptions.length = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 根据误差体系ID加载测试项(用于初始化)
|
||||||
|
const loadTestItemsForErrorSys = async (errorSysId: string) => {
|
||||||
|
if (!errorSysId) return;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const res = await getPqErrSysTestItemList({ errorSysId: errorSysId });
|
||||||
|
// 清空原有选项
|
||||||
|
secondLevelOptions.length = 0;
|
||||||
|
|
||||||
|
if (res.data) {
|
||||||
|
// 将返回的键值对对象转换为下拉选项格式
|
||||||
|
Object.keys(res.data).forEach(key => {
|
||||||
|
secondLevelOptions.push({
|
||||||
|
value: key,
|
||||||
|
label: res.data[key]
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('获取测试项失败:', error);
|
||||||
|
secondLevelOptions.length = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 转换函数
|
// 转换函数
|
||||||
const convertToOptions = (dictTree: Dict.ResDictTree[]): CascaderOption[] => {
|
const convertToOptions = (dictTree: Dict.ResDictTree[]): CascaderOption[] => {
|
||||||
return dictTree.map(item => ({
|
return dictTree.map(item => ({
|
||||||
|
|||||||
Reference in New Issue
Block a user