UPDATE: 检测计划选择数据源逻辑改成主计划默认全选,子计划勾选校验

This commit is contained in:
贾同学
2025-09-05 08:57:39 +08:00
parent 5a7eea1052
commit 6122f53c8e
3 changed files with 35 additions and 26 deletions

View File

@@ -46,7 +46,7 @@ export namespace Plan {
export interface ReqPlan extends ResPlan {
datasourceIds:string;
datasourceIds:string | string[];
sourceIds: string | null;
planId:string;
scriptName: string ;

View File

@@ -19,6 +19,7 @@
<el-input
style="width: 82%; margin: 0 10px"
size="small"
clearable
v-model="filter.leftText"
:placeholder="props.filterPlaceholder"
/>
@@ -138,6 +139,7 @@
<el-input
style="width: 80%; margin: 0 10px"
size="small"
clearable
v-model="filter.rightText"
:placeholder="props.filterPlaceholder"
/>

View File

@@ -80,13 +80,13 @@
<el-form-item :label-width="110" label="数据源" prop="datasourceIds">
<el-select
v-model="formContent.datasourceIds"
:disabled="planType != 0 || allDisabled"
:max-collapse-tags="2"
:disabled="allDisabled"
:max-collapse-tags="1"
:multiple="selectByMode"
autocomplete="off"
clearable
:clearable="planType != 0"
collapse-tags
filterable
:filterable="planType != 0"
placeholder="请选择数据源"
@change="handleDataSourceChange"
>
@@ -95,6 +95,7 @@
:key="item.id"
:label="item.name"
:value="item.code || ''"
:disabled="planType == 0 || allDisabled"
/>
</el-select>
</el-form-item>
@@ -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 = ''
}
}
}