diff --git a/frontend/src/api/plan/interface/index.ts b/frontend/src/api/plan/interface/index.ts index aa38178..ec05ecf 100644 --- a/frontend/src/api/plan/interface/index.ts +++ b/frontend/src/api/plan/interface/index.ts @@ -46,7 +46,7 @@ export namespace Plan { export interface ReqPlan extends ResPlan { - datasourceIds:string; + datasourceIds:string | string[]; sourceIds: string | null; planId:string; scriptName: string ; diff --git a/frontend/src/views/plan/planList/components/devSelect.vue b/frontend/src/views/plan/planList/components/devSelect.vue index d0aba06..ba97db7 100644 --- a/frontend/src/views/plan/planList/components/devSelect.vue +++ b/frontend/src/views/plan/planList/components/devSelect.vue @@ -19,6 +19,7 @@ @@ -138,6 +139,7 @@ diff --git a/frontend/src/views/plan/planList/components/planPopup.vue b/frontend/src/views/plan/planList/components/planPopup.vue index 89ad285..a7cd78b 100644 --- a/frontend/src/views/plan/planList/components/planPopup.vue +++ b/frontend/src/views/plan/planList/components/planPopup.vue @@ -80,13 +80,13 @@ @@ -95,6 +95,7 @@ :key="item.id" :label="item.name" :value="item.code || ''" + :disabled="planType == 0 || allDisabled" /> @@ -731,7 +732,11 @@ const open = async (sign: string, data: Plan.ReqPlan, currentMode: string, plan: formContent.scriptId = pqScriptList.value[0]?.id ?? '' formContent.errorSysId = pqErrSysList.value[0]?.id ?? '' formContent.sourceIds = pqSourceList.value[0]?.id ?? '' - formContent.datasourceIds = dictStore.getDictData('Datasource')[0]?.code ?? '' + const datasourceDicts = dictStore.getDictData('Datasource') + if (plan == 0) { + formContent.datasourceIds = datasourceDicts.map(item => item.code) + } + // formContent.datasourceIds = dictStore.getDictData('Datasource')[0]?.code ?? '' formContent.dataRule = dictStore.getDictData('Data_Rule')[0]?.id ?? '' } else { //编辑时先给表单赋值(这会没接收被检设备),需要手动再给被检设备复制后整体表单赋值 @@ -1018,29 +1023,31 @@ const dataSourceType = computed(() => { const handleDataSourceChange = () => { if (mode.value != '比对式') return - // 获取当前选中的 datasourceIds,并确保为数组 - const values = Array.isArray(formContent.datasourceIds) - ? formContent.datasourceIds - : [formContent.datasourceIds].filter(Boolean) // 转为数组并过滤空值 + if (planType.value == 1 || planType.value == 2) { + // 获取当前选中的 datasourceIds,并确保为数组 + const values = Array.isArray(formContent.datasourceIds) + ? formContent.datasourceIds + : [formContent.datasourceIds].filter(Boolean) // 转为数组并过滤空值 - const selectedLabels = values.map(value => { - const matched = dictStore.getDictData(dataSourceType.value).find(item => item.code === value) - return matched ? matched.name : '' - }) + const selectedLabels = values.map(value => { + const matched = dictStore.getDictData(dataSourceType.value).find(item => item.code === value) + return matched ? matched.name : '' + }) - // 判断是否同时包含 '3s' 和 '分钟' - const hasThreeSeconds = selectedLabels.some(label => label.includes('3s')) - const hasMinuteStats = selectedLabels.some(label => label.includes('分钟')) + // 判断是否同时包含 '3s' 和 '分钟' + const hasThreeSeconds = selectedLabels.some(label => label.includes('3s')) + const hasMinuteStats = selectedLabels.some(label => label.includes('分钟')) - if (hasThreeSeconds && hasMinuteStats) { - ElMessage.warning('3s实时数据与分钟统计数据不能同时选择') - formContent.datasourceIds = '' - } - // 判断是否选择了多个“分钟统计数据”项 - const minuteStatLabels = selectedLabels.filter(label => label.includes('分钟')) - if (minuteStatLabels.length > 1) { - ElMessage.warning('分钟统计数据不能多选') - formContent.datasourceIds = '' + if (hasThreeSeconds && hasMinuteStats) { + ElMessage.warning('3s实时数据与分钟统计数据不能同时选择') + formContent.datasourceIds = '' + } + // 判断是否选择了多个“分钟统计数据”项 + const minuteStatLabels = selectedLabels.filter(label => label.includes('分钟')) + if (minuteStatLabels.length > 1) { + ElMessage.warning('分钟统计数据不能多选') + formContent.datasourceIds = '' + } } }