UPDATE: 修改计划数据源选择逻辑。

This commit is contained in:
贾同学
2025-09-16 14:37:17 +08:00
parent 4a8f8bff6a
commit d0c3e1d9bd
2 changed files with 31 additions and 36 deletions

View File

@@ -141,7 +141,7 @@
link
icon="Postcard"
@click="openDrawer('报告生成', scope.row)"
v-if="form.activeTabs === 3"
v-if="form.activeTabs === 3 && modeStore.currentMode == '比对式'"
>
报告生成
</el-button>
@@ -204,7 +204,8 @@ import { onBeforeMount, onMounted, type PropType, reactive, ref, watch } from 'v
import { type Action, ElMessage, ElMessageBox } from 'element-plus'
import TestPopup from './testPopup.vue'
import dataCheckPopup from './dataCheckSingleChannelSingleTestPopup.vue'
import CompareDataCheckSingleChannelSingleTestPopup from '@/views/home/components/compareDataCheckSingleChannelSingleTestPopup.vue'
import CompareDataCheckSingleChannelSingleTestPopup
from '@/views/home/components/compareDataCheckSingleChannelSingleTestPopup.vue'
import ProTable from '@/components/ProTable/index.vue'
import SelectTestItemPopup from '@/views/home/components/selectTestItemPopup.vue'
import WriteTHPopup from '@/views/home/components/writeTHPopup.vue'

View File

@@ -87,9 +87,9 @@
collapse-tags-tooltip
:multiple="selectByMode"
autocomplete="off"
:clearable="planType != 0"
clearable
collapse-tags
:filterable="planType != 0"
filterable
placeholder="请选择数据源"
@change="handleDataSourceChange"
>
@@ -98,7 +98,7 @@
:key="item.id"
:label="item.name"
:value="item.code || ''"
:disabled="(selectByMode && planType == 0) || allDisabled"
:disabled="allDisabled"
></el-option>
</el-select>
</el-form-item>
@@ -817,13 +817,7 @@ const open = async (sign: string, data: Plan.ReqPlan, currentMode: string, plan:
formContent.errorSysId = pqErrSysList.value[0]?.id ?? ''
formContent.sourceIds = pqSourceList.value[0]?.id ?? ''
const datasourceDicts = dictStore.getDictData('Datasource')
if (plan == 0 && mode.value === '比对式') {
formContent.datasourceIds = datasourceDicts.map(item => item.code)
} else {
formContent.datasourceIds = dictStore.getDictData('Datasource')[0]?.code ?? ''
}
formContent.dataRule = dictStore.getDictData('Data_Rule')[0]?.id ?? ''
formContent.datasourceIds = datasourceDicts[0]?.code ?? ''
} else {
//编辑时先给表单赋值(这会没接收被检设备),需要手动再给被检设备复制后整体表单赋值
@@ -990,7 +984,9 @@ const open = async (sign: string, data: Plan.ReqPlan, currentMode: string, plan:
if (plan == 1) {
//新增子计划名称清空
formContent.name = ''
formContent.datasourceIds = []
// 新建子计划允许选择数据源
const datasourceDicts = dictStore.getDictData('Datasource')
formContent.datasourceIds = datasourceDicts[0]?.code ?? ''
formContent.memberIds = []
}
generateData()
@@ -1126,38 +1122,36 @@ const dataSourceType = computed(() => {
const handleDataSourceChange = () => {
if (mode.value != '比对式') return
if (planType.value == 1 || planType.value == 2) {
// 获取当前选中的 datasourceIds,并确保为数组
const values = Array.isArray(formContent.datasourceIds)
? formContent.datasourceIds
: [formContent.datasourceIds].filter(Boolean) // 转为数组并过滤空值
// 获取当前选中的 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 = ''
}
}
//导入设备
const deviceImportExcel = ref<InstanceType<typeof ImportExcel> | null>(null)
const importFile = async (pattern: string) => {
const importFile = async () => {
const params = {
title: '被检设备',
showCover: false,