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 { export interface ReqPlan extends ResPlan {
datasourceIds:string; datasourceIds:string | string[];
sourceIds: string | null; sourceIds: string | null;
planId:string; planId:string;
scriptName: string ; scriptName: string ;

View File

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

View File

@@ -80,13 +80,13 @@
<el-form-item :label-width="110" label="数据源" prop="datasourceIds"> <el-form-item :label-width="110" label="数据源" prop="datasourceIds">
<el-select <el-select
v-model="formContent.datasourceIds" v-model="formContent.datasourceIds"
:disabled="planType != 0 || allDisabled" :disabled="allDisabled"
:max-collapse-tags="2" :max-collapse-tags="1"
:multiple="selectByMode" :multiple="selectByMode"
autocomplete="off" autocomplete="off"
clearable :clearable="planType != 0"
collapse-tags collapse-tags
filterable :filterable="planType != 0"
placeholder="请选择数据源" placeholder="请选择数据源"
@change="handleDataSourceChange" @change="handleDataSourceChange"
> >
@@ -95,6 +95,7 @@
:key="item.id" :key="item.id"
:label="item.name" :label="item.name"
:value="item.code || ''" :value="item.code || ''"
:disabled="planType == 0 || allDisabled"
/> />
</el-select> </el-select>
</el-form-item> </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.scriptId = pqScriptList.value[0]?.id ?? ''
formContent.errorSysId = pqErrSysList.value[0]?.id ?? '' formContent.errorSysId = pqErrSysList.value[0]?.id ?? ''
formContent.sourceIds = pqSourceList.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 ?? '' formContent.dataRule = dictStore.getDictData('Data_Rule')[0]?.id ?? ''
} else { } else {
//编辑时先给表单赋值(这会没接收被检设备),需要手动再给被检设备复制后整体表单赋值 //编辑时先给表单赋值(这会没接收被检设备),需要手动再给被检设备复制后整体表单赋值
@@ -1018,29 +1023,31 @@ const dataSourceType = computed(() => {
const handleDataSourceChange = () => { const handleDataSourceChange = () => {
if (mode.value != '比对式') return if (mode.value != '比对式') return
// 获取当前选中的 datasourceIds并确保为数组 if (planType.value == 1 || planType.value == 2) {
const values = Array.isArray(formContent.datasourceIds) // 获取当前选中的 datasourceIds,并确保为数组
? formContent.datasourceIds const values = Array.isArray(formContent.datasourceIds)
: [formContent.datasourceIds].filter(Boolean) // 转为数组并过滤空值 ? formContent.datasourceIds
: [formContent.datasourceIds].filter(Boolean) // 转为数组并过滤空值
const selectedLabels = values.map(value => { const selectedLabels = values.map(value => {
const matched = dictStore.getDictData(dataSourceType.value).find(item => item.code === value) const matched = dictStore.getDictData(dataSourceType.value).find(item => item.code === value)
return matched ? matched.name : '' return matched ? matched.name : ''
}) })
// 判断是否同时包含 '3s' 和 '分钟' // 判断是否同时包含 '3s' 和 '分钟'
const hasThreeSeconds = selectedLabels.some(label => label.includes('3s')) const hasThreeSeconds = selectedLabels.some(label => label.includes('3s'))
const hasMinuteStats = selectedLabels.some(label => label.includes('分钟')) const hasMinuteStats = selectedLabels.some(label => label.includes('分钟'))
if (hasThreeSeconds && hasMinuteStats) { if (hasThreeSeconds && hasMinuteStats) {
ElMessage.warning('3s实时数据与分钟统计数据不能同时选择') ElMessage.warning('3s实时数据与分钟统计数据不能同时选择')
formContent.datasourceIds = '' formContent.datasourceIds = ''
} }
// 判断是否选择了多个“分钟统计数据”项 // 判断是否选择了多个“分钟统计数据”项
const minuteStatLabels = selectedLabels.filter(label => label.includes('分钟')) const minuteStatLabels = selectedLabels.filter(label => label.includes('分钟'))
if (minuteStatLabels.length > 1) { if (minuteStatLabels.length > 1) {
ElMessage.warning('分钟统计数据不能多选') ElMessage.warning('分钟统计数据不能多选')
formContent.datasourceIds = '' formContent.datasourceIds = ''
}
} }
} }