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 link
icon="Postcard" icon="Postcard"
@click="openDrawer('报告生成', scope.row)" @click="openDrawer('报告生成', scope.row)"
v-if="form.activeTabs === 3" v-if="form.activeTabs === 3 && modeStore.currentMode == '比对式'"
> >
报告生成 报告生成
</el-button> </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 { type Action, ElMessage, ElMessageBox } from 'element-plus'
import TestPopup from './testPopup.vue' import TestPopup from './testPopup.vue'
import dataCheckPopup from './dataCheckSingleChannelSingleTestPopup.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 ProTable from '@/components/ProTable/index.vue'
import SelectTestItemPopup from '@/views/home/components/selectTestItemPopup.vue' import SelectTestItemPopup from '@/views/home/components/selectTestItemPopup.vue'
import WriteTHPopup from '@/views/home/components/writeTHPopup.vue' import WriteTHPopup from '@/views/home/components/writeTHPopup.vue'

View File

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