比对检测计划
This commit is contained in:
@@ -1,330 +0,0 @@
|
||||
<!--单列-->
|
||||
<template>
|
||||
<el-dialog
|
||||
class="table-box"
|
||||
v-model="dialogVisible"
|
||||
top="114px"
|
||||
:style="{ height: height + 'px', maxHeight: height + 'px', overflow: 'hidden' }"
|
||||
:title="title"
|
||||
:width="width"
|
||||
:modal="false"
|
||||
>
|
||||
<div
|
||||
class="table-box"
|
||||
:style="{ height: height - 64 + 'px', maxHeight: height - 64 + 'px', overflow: 'hidden' }"
|
||||
>
|
||||
<div style="margin-bottom: 20px">
|
||||
<el-button type="primary" :icon="CirclePlus" @click="addTab(editableTabsValue)">新增计划</el-button>
|
||||
</div>
|
||||
<el-tabs
|
||||
v-model="editableTabsValue"
|
||||
type="card"
|
||||
class="demo-tabs"
|
||||
closable
|
||||
@tab-remove="removeTab"
|
||||
>
|
||||
<el-tab-pane
|
||||
v-for="item in editableTabs"
|
||||
:key="item.name"
|
||||
:label="item.title"
|
||||
:name="item.name"
|
||||
>
|
||||
<ProTable
|
||||
ref="proTable"
|
||||
:columns="item.columns"
|
||||
:data="item.tableData"
|
||||
type="selection"
|
||||
style="height: 750px;"
|
||||
>
|
||||
<!-- 表格 header 按钮 -->
|
||||
<template #tableHeader="scope">
|
||||
<el-button type="primary" :icon="Delete" v-if="item.name == '1'">
|
||||
新增
|
||||
</el-button>
|
||||
<el-button type="primary" :icon="Delete" v-if="item.name != '1'">
|
||||
导出检测方案
|
||||
</el-button>
|
||||
<el-button type="primary" :icon="Delete" >
|
||||
导入检测结果
|
||||
</el-button>
|
||||
<el-button type="danger" :icon="Delete" plain :disabled="!scope.isSelected">
|
||||
批量移除
|
||||
</el-button>
|
||||
</template>
|
||||
<!-- 表格操作 -->
|
||||
<template #operation="scope">
|
||||
<el-button type="primary" link :icon="Delete" v-if="item.name == '1'">删除</el-button>
|
||||
<el-button type="primary" link :icon="Delete" v-if="item.name != '1'">移除</el-button>
|
||||
</template>
|
||||
</ProTable>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</template>
|
||||
<script setup lang="tsx">
|
||||
import { TabPaneName } from 'element-plus'
|
||||
import { ref, reactive } from 'vue'
|
||||
import { CirclePlus, Delete } from '@element-plus/icons-vue'
|
||||
const sourceDataList = [
|
||||
{
|
||||
id: 'device1',
|
||||
name:"电能质量监测仪A001",
|
||||
type:"PQS-882A",
|
||||
date:"2022-05-05",
|
||||
channel: "2",
|
||||
vol: "57.74",
|
||||
cur: "5",
|
||||
company: "南京灿能",
|
||||
state: 0,
|
||||
check:1,
|
||||
},
|
||||
{
|
||||
id: 'device2',
|
||||
name:"电能质量监测仪A002",
|
||||
type:"PQS-882B4",
|
||||
date:"2022-05-05",
|
||||
channel: "4",
|
||||
vol: "57.74",
|
||||
cur: "5",
|
||||
company: "南京灿能",
|
||||
state: 1,
|
||||
check:2,
|
||||
},
|
||||
{
|
||||
id: 'device3',
|
||||
name:"电能质量监测仪A003",
|
||||
type:"PQS-882B4",
|
||||
date:"2022-05-05",
|
||||
channel: "4",
|
||||
vol: "57.74",
|
||||
cur: "5",
|
||||
company: "南京灿能",
|
||||
state: 1,
|
||||
check:2,
|
||||
},
|
||||
]
|
||||
const sourceDataList2 = [
|
||||
{
|
||||
id: 'device1',
|
||||
name:"电能质量监测仪A003",
|
||||
type:"PQS-882A",
|
||||
date:"2022-05-05",
|
||||
channel: "2",
|
||||
vol: "57.74",
|
||||
cur: "5",
|
||||
company: "南京灿能",
|
||||
state: 0,
|
||||
check:1,
|
||||
},
|
||||
]
|
||||
// 初始数据源
|
||||
const SourceData = sourceDataList
|
||||
const SourceData2 = sourceDataList2
|
||||
// 控制弹窗显示与标题
|
||||
const dialogVisible = ref(false)
|
||||
const title = ref('')
|
||||
const planTitle = ref('')
|
||||
// tab 相关
|
||||
let tabIndex = 2
|
||||
const editableTabsValue = ref('2')
|
||||
const editableTabs = ref([
|
||||
{
|
||||
title: planTitle,
|
||||
name: '1',
|
||||
content: 'Tab 1 content',
|
||||
tableData: [...SourceData],
|
||||
columns: [
|
||||
{ type: 'selection', fixed: 'left', width: 70 },
|
||||
{ type: 'index', fixed: 'left', width: 70, label: '序号' },
|
||||
{
|
||||
prop: 'name',
|
||||
label: '名称',
|
||||
search: { el: 'input' },
|
||||
minWidth: 180,
|
||||
},
|
||||
{
|
||||
prop: 'type',
|
||||
label: '设备类型',
|
||||
search: { el: 'select' },
|
||||
minWidth: 150,
|
||||
},
|
||||
{
|
||||
prop: 'date',
|
||||
label: '出厂日期',
|
||||
search: { el: 'select' },
|
||||
minWidth: 150,
|
||||
},
|
||||
{
|
||||
prop: 'channel',
|
||||
label: '通道数',
|
||||
search: { el: 'select' },
|
||||
minWidth: 100,
|
||||
},
|
||||
{
|
||||
prop: 'vol',
|
||||
label: '额定电压V',
|
||||
search: { el: 'select' },
|
||||
minWidth: 150,
|
||||
},
|
||||
{
|
||||
prop: 'cur',
|
||||
label: '额定电流A',
|
||||
search: { el: 'select' },
|
||||
minWidth: 150,
|
||||
},
|
||||
{
|
||||
prop: 'company',
|
||||
label: '设备厂家',
|
||||
search: { el: 'select' },
|
||||
minWidth: 150,
|
||||
|
||||
},
|
||||
{
|
||||
prop: 'state',
|
||||
label: '分配状态',
|
||||
search: { el: 'select' },
|
||||
minWidth: 150,
|
||||
render: () => {
|
||||
return (
|
||||
<el-tag type='success' effect="dark">已分配</el-tag>
|
||||
)
|
||||
},
|
||||
},
|
||||
{
|
||||
prop: 'check',
|
||||
label: '检测状态',
|
||||
search: { el: 'select' },
|
||||
minWidth: 150,
|
||||
render: (scope: { row: { check: number } }) => {
|
||||
return (
|
||||
scope.row.check === 0 ? <el-tag type='warning' effect="dark">未检</el-tag> :
|
||||
scope.row.check === 1 ? <el-tag type='danger' effect="dark">检测中</el-tag> :
|
||||
<el-tag type='success' effect="dark">检测完成</el-tag>
|
||||
)
|
||||
},
|
||||
},
|
||||
{ prop: 'operation', label: '操作', fixed: 'right', width: 100 },
|
||||
],
|
||||
},
|
||||
{
|
||||
title: '子计划',
|
||||
name: '2',
|
||||
content: 'Tab 2 content',
|
||||
tableData: [...SourceData2],
|
||||
columns: [
|
||||
{ type: 'selection', fixed: 'left', width: 70 },
|
||||
{ type: 'index', fixed: 'left', width: 70, label: '序号' },
|
||||
{
|
||||
prop: 'name',
|
||||
label: '名称',
|
||||
search: { el: 'input' },
|
||||
minWidth: 180,
|
||||
},
|
||||
{
|
||||
prop: 'type',
|
||||
label: '设备类型',
|
||||
search: { el: 'select' },
|
||||
minWidth: 150,
|
||||
},
|
||||
{
|
||||
prop: 'date',
|
||||
label: '出厂日期',
|
||||
search: { el: 'select' },
|
||||
minWidth: 150,
|
||||
},
|
||||
{
|
||||
prop: 'channel',
|
||||
label: '通道数',
|
||||
search: { el: 'select' },
|
||||
minWidth: 100,
|
||||
},
|
||||
{
|
||||
prop: 'vol',
|
||||
label: '额定电压V',
|
||||
search: { el: 'select' },
|
||||
minWidth: 150,
|
||||
},
|
||||
{
|
||||
prop: 'cur',
|
||||
label: '额定电流A',
|
||||
search: { el: 'select' },
|
||||
minWidth: 150,
|
||||
},
|
||||
{
|
||||
prop: 'company',
|
||||
label: '设备厂家',
|
||||
search: { el: 'select' },
|
||||
minWidth: 150,
|
||||
|
||||
},
|
||||
{
|
||||
prop: 'check',
|
||||
label: '检测状态',
|
||||
search: { el: 'select' },
|
||||
minWidth: 150,
|
||||
render: (scope: { row: { check: number } }) => {
|
||||
return (
|
||||
scope.row.check === 0 ? <el-tag type='warning' effect="dark">未检</el-tag> :
|
||||
scope.row.check === 1 ? <el-tag type='danger' effect="dark">检测中</el-tag> :
|
||||
<el-tag type='success' effect="dark">检测完成</el-tag>
|
||||
)
|
||||
},
|
||||
},
|
||||
{ prop: 'operation', label: '操作', fixed: 'right', width: 100 },
|
||||
],
|
||||
},
|
||||
])
|
||||
|
||||
// 新增 tab 方法
|
||||
const addTab = (targetName: string) => {
|
||||
const newTabName = `${++tabIndex}`
|
||||
editableTabs.value.push({
|
||||
title: '子计划',
|
||||
name: newTabName,
|
||||
content: 'New Tab content',
|
||||
tableData: [], // 每个 tab 独立的数据副本
|
||||
columns: [...editableTabs.value[0].columns], // 复用已有列配置
|
||||
})
|
||||
editableTabsValue.value = newTabName
|
||||
}
|
||||
|
||||
// 删除 tab 方法
|
||||
const removeTab = (targetName: TabPaneName) => {
|
||||
const tabs = editableTabs.value
|
||||
let activeName = editableTabsValue.value
|
||||
if (activeName === targetName) {
|
||||
tabs.forEach((tab, index) => {
|
||||
if (tab.name === targetName) {
|
||||
const nextTab = tabs[index + 1] || tabs[index - 1]
|
||||
if (nextTab) {
|
||||
activeName = nextTab.name
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
editableTabsValue.value = activeName
|
||||
editableTabs.value = tabs.filter((tab) => tab.name !== targetName)
|
||||
}
|
||||
|
||||
// 弹窗打开方法
|
||||
const open = (textTitle: string,planName: string) => {
|
||||
dialogVisible.value = true
|
||||
title.value = textTitle
|
||||
planTitle.value = planName
|
||||
}
|
||||
defineExpose({ open })
|
||||
|
||||
// props
|
||||
const props = defineProps({
|
||||
width: {
|
||||
type: Number,
|
||||
default: 800,
|
||||
},
|
||||
height: {
|
||||
type: Number,
|
||||
default: 744,
|
||||
},
|
||||
})
|
||||
</script>
|
||||
436
frontend/src/views/plan/planList/components/childrenPlan.vue
Normal file
436
frontend/src/views/plan/planList/components/childrenPlan.vue
Normal file
@@ -0,0 +1,436 @@
|
||||
<!--单列-->
|
||||
<template>
|
||||
<el-dialog
|
||||
class="table-box"
|
||||
v-model="dialogVisible"
|
||||
top="114px"
|
||||
:style="{ height: height + 'px', maxHeight: height + 'px', overflow: 'hidden' }"
|
||||
:title="title"
|
||||
:width="width"
|
||||
:modal="false"
|
||||
>
|
||||
<div
|
||||
class="table-box"
|
||||
:style="{ height: height - 64 + 'px', maxHeight: height - 64 + 'px', overflow: 'hidden' }"
|
||||
>
|
||||
<el-tabs
|
||||
v-model="editableTabsValue"
|
||||
type="card"
|
||||
@tab-remove="removeTab"
|
||||
@tab-click="handleTabClick"
|
||||
>
|
||||
<el-tab-pane
|
||||
v-for="item in editableTabs"
|
||||
:key="item.name"
|
||||
:label="item.title"
|
||||
:name="item.name"
|
||||
:closable="item.closable"
|
||||
>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
<ProTable
|
||||
ref="proTable"
|
||||
:columns="columns"
|
||||
:request-api="getTableList"
|
||||
type="selection"
|
||||
>
|
||||
<!-- 表格 header 按钮 -->
|
||||
<template #tableHeader="scope">
|
||||
<el-button type="primary" :icon="CirclePlus" @click="addTab('add')" v-if="!isTabPlanFather">
|
||||
新增子计划
|
||||
</el-button>
|
||||
<el-button type="primary" :icon="CirclePlus" @click="addTab('edit')" v-if="isTabPlanFather">
|
||||
编辑子计划
|
||||
</el-button>
|
||||
<el-button type="primary" :icon="Upload" >
|
||||
导出检测方案
|
||||
</el-button>
|
||||
<el-button type="primary" :icon="Download" >
|
||||
导入检测结果
|
||||
</el-button>
|
||||
<el-button type="danger" :icon="Delete" plain :disabled="!scope.isSelected">
|
||||
批量移除
|
||||
</el-button>
|
||||
<el-dropdown trigger="hover" placement="right-start" :disabled="!scope.isSelected">
|
||||
<el-button type="primary" :icon="ScaleToOriginal" style="margin-left: 10px;" v-if="!isTabPlanFather" :disabled="!scope.isSelected">
|
||||
分配被检设备
|
||||
</el-button>
|
||||
<template #dropdown >
|
||||
<el-dropdown-menu>
|
||||
<el-dropdown-item
|
||||
v-for="child in planFormContent?.children"
|
||||
:key="child.id"
|
||||
@click="distribute(child,scope)"
|
||||
>
|
||||
{{ child.name }}
|
||||
</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</template>
|
||||
</el-dropdown>
|
||||
<el-dropdown trigger="hover" placement="right-start">
|
||||
<el-button type="primary" :icon="ScaleToOriginal" style="margin-left: 10px;" v-if="!isTabPlanFather">
|
||||
标准设备管理
|
||||
</el-button>
|
||||
<template #dropdown >
|
||||
<el-dropdown-menu>
|
||||
<el-dropdown-item
|
||||
v-for="child in planFormContent?.children"
|
||||
:key="child.id"
|
||||
@click="allotStandardDev(child)"
|
||||
>
|
||||
{{ child.name }}
|
||||
</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</template>
|
||||
</el-dropdown>
|
||||
</template>
|
||||
<!-- 表格操作 -->
|
||||
<template #operation="">
|
||||
<el-button type="primary" link :icon="Delete" v-if="!isTabPlanFather">删除</el-button>
|
||||
<el-button type="primary" link :icon="Delete" v-if="isTabPlanFather">移除</el-button>
|
||||
</template>
|
||||
</ProTable>
|
||||
</div>
|
||||
</el-dialog>
|
||||
<!-- 向计划导入/导出设备对话框 -->
|
||||
<PlanPopup :refresh-table='proTable?.getTableList' ref='planPopup' @update:tab="addNewChildTab"/>
|
||||
<DevTransfer ref='devTransfer' />
|
||||
</template>
|
||||
<script setup lang="tsx">
|
||||
import { ElMessage, ElMessageBox, TabPaneName } from 'element-plus'
|
||||
import { ref, computed, watch, reactive } from 'vue'
|
||||
import { ScaleToOriginal, CirclePlus, Delete, Upload, Download } from '@element-plus/icons-vue'
|
||||
import PlanPopup from '@/views/plan/planList/components/planPopup.vue' // 导入子组件
|
||||
import { Plan } from '@/api/plan/interface'
|
||||
import {useModeStore } from '@/stores/modules/mode'; // 引入模式 store
|
||||
import { ColumnProps, ProTableInstance, SearchRenderScope } from '@/components/ProTable/interface'
|
||||
import {getDevListByPlanId ,subPlanBindDev} from '@/api/plan/plan'
|
||||
import { Device } from '@/api/device/interface/device'
|
||||
import { useDictStore } from '@/stores/modules/dict'
|
||||
import DevTransfer from '@/views/plan/planList/components/devTransfer.vue'
|
||||
|
||||
const dictStore = useDictStore()
|
||||
const planFormContent = ref<Plan.ReqPlan>()
|
||||
const proTable = ref<ProTableInstance>()
|
||||
const modeStore = useModeStore();
|
||||
const planPopup = ref()
|
||||
const devTransfer = ref()
|
||||
|
||||
// 控制弹窗显示与标题
|
||||
const dialogVisible = ref(false)
|
||||
const title = ref('')
|
||||
const planTitle = ref('')
|
||||
// tab 相关
|
||||
const editableTabsValue = ref('0')
|
||||
const isTabPlanFather = ref(true)
|
||||
const planId = ref('')
|
||||
const getTableList = async (params: any) => {
|
||||
if (!planFormContent.value) {
|
||||
return Promise.resolve({ data: [], total: 0 });
|
||||
}
|
||||
let newParams = JSON.parse(JSON.stringify(params));
|
||||
const patternId = dictStore.getDictData('Pattern').find(item => item.name === modeStore.currentMode)?.id//获取数据字典中对应的id
|
||||
newParams.pattern = patternId
|
||||
if(!isTabPlanFather.value)
|
||||
newParams.planId = planFormContent.value.id
|
||||
else
|
||||
newParams.planId = planId.value
|
||||
newParams.planIdList = [newParams.planId];
|
||||
proTable.value?.clearSelection()
|
||||
return getDevListByPlanId(newParams);
|
||||
}
|
||||
|
||||
|
||||
const columns = reactive<ColumnProps<Device.ResPqDev>[]>([
|
||||
{ type: 'selection', fixed: 'left', width: 70 },
|
||||
{ type: 'index', fixed: 'left', width: 70, label: '序号' },
|
||||
{
|
||||
prop: 'name',
|
||||
label: '名称',
|
||||
search: { el: 'input' },
|
||||
minWidth: 180,
|
||||
},
|
||||
{
|
||||
prop: 'devType',
|
||||
label: '设备类型',
|
||||
minWidth: 150,
|
||||
},
|
||||
{
|
||||
prop: 'createDate',
|
||||
label: '出厂日期',
|
||||
minWidth: 150,
|
||||
},
|
||||
{
|
||||
prop: 'devChns',
|
||||
label: '通道数',
|
||||
minWidth: 100,
|
||||
},
|
||||
{
|
||||
prop: 'devVolt',
|
||||
label: '额定电压V',
|
||||
minWidth: 150,
|
||||
},
|
||||
{
|
||||
prop: 'devCurr',
|
||||
label: '额定电流A',
|
||||
minWidth: 150,
|
||||
},
|
||||
{
|
||||
prop: 'manufacturer',
|
||||
label: '设备厂家',
|
||||
enum: dictStore.getDictData('Dev_Manufacturers'),
|
||||
search: {el: 'select', props: {filterable: true}, order: 1},
|
||||
fieldNames: {label: 'name', value: 'id'},
|
||||
minWidth: 200,
|
||||
},
|
||||
{
|
||||
prop: 'cityName',
|
||||
label: '地市',
|
||||
minWidth: 150,
|
||||
|
||||
},
|
||||
{
|
||||
prop: 'region',
|
||||
label: '地市',
|
||||
minWidth: 150,
|
||||
isShow:false,
|
||||
search: {
|
||||
el: 'input',
|
||||
label :'关键词',
|
||||
render: (scope: SearchRenderScope) => {
|
||||
return (
|
||||
<el-input
|
||||
v-model={scope.searchParam.region}
|
||||
placeholder="请输入关键词"
|
||||
clearable
|
||||
/>
|
||||
);
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
prop: 'gdName',
|
||||
label: '供电公司',
|
||||
minWidth: 150,
|
||||
},
|
||||
{
|
||||
prop: 'subName',
|
||||
label: '变电站',
|
||||
minWidth: 150,
|
||||
},
|
||||
{
|
||||
prop: 'boundPlanName',
|
||||
label: '子计划',
|
||||
minWidth: 150,
|
||||
isShow: isTabPlanFather.value,
|
||||
render: (scope) => {
|
||||
console.log('boundPlanName', isTabPlanFather.value)
|
||||
const value = scope.row.boundPlanName;
|
||||
if (!value) {
|
||||
return '/'; // 空值直接返回空字符串
|
||||
}
|
||||
return (
|
||||
<el-link type='primary' link onClick={() => unbindDevice(scope.row)}>
|
||||
{value}
|
||||
</el-link>
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
prop: 'checkState',
|
||||
label: '检测状态',
|
||||
minWidth: 150,
|
||||
render: (scope: { row: { checkState: number } }) => {
|
||||
return (
|
||||
scope.row.checkState === 0 ? <el-tag type='warning' effect="dark">未检</el-tag> :
|
||||
scope.row.checkState === 1 ? <el-tag type='danger' effect="dark">检测中</el-tag> :
|
||||
<el-tag type='success' effect="dark">检测完成</el-tag>
|
||||
)
|
||||
},
|
||||
},
|
||||
{ prop: 'operation', label: '操作', fixed: 'right', width: 100 },
|
||||
])
|
||||
|
||||
|
||||
|
||||
const editableTabs = computed(() => {
|
||||
console.log('editableTabs',planFormContent.value)
|
||||
const tabs = []
|
||||
// 主计划 tab
|
||||
if (planFormContent.value) {
|
||||
tabs.push({
|
||||
title: planFormContent.value.name,
|
||||
name: planFormContent.value.id,
|
||||
closable: false
|
||||
})
|
||||
}
|
||||
// 子计划 tabs
|
||||
if (planFormContent.value?.children?.length > 0) {
|
||||
planFormContent.value.children.forEach((child, index) => {
|
||||
tabs.push({
|
||||
title: child.name,
|
||||
name: child.id,
|
||||
closable: true
|
||||
})
|
||||
})
|
||||
}
|
||||
return tabs
|
||||
})
|
||||
|
||||
const unbindDevice = (row: any) => {
|
||||
if(row.state == '/')
|
||||
return
|
||||
ElMessageBox.confirm(`确定将设备 ${row.name} 从子计划中解绑吗?`, '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(async () => {
|
||||
await subPlanBindDev({'planId': row.planId, 'devIds': [row.id] ,'bindFlag': 0}) //解绑 0 绑定 1
|
||||
// 👇 更新数据(例如清空 state 字段)
|
||||
row.state = '/'
|
||||
proTable.value?.getTableList()
|
||||
// 可选:刷新表格或提交接口
|
||||
ElMessage.success('解绑成功')
|
||||
}).catch(() => {
|
||||
// 用户取消操作
|
||||
})
|
||||
}
|
||||
|
||||
// 新增 tab 方法
|
||||
const addTab = (type: string) => {
|
||||
if(type === "add"){
|
||||
planPopup.value?.open("edit", planFormContent.value,modeStore.currentMode,1)
|
||||
}else {
|
||||
const subPlanFormContent = ref<Plan.ReqPlan>()
|
||||
// 从 planFormContent.value?.children 中找到 id 与 item.name 匹配的子计划
|
||||
subPlanFormContent.value = planFormContent.value?.children?.find(
|
||||
(child: Plan.ReqPlan) => child.id === planId.value
|
||||
)
|
||||
console.log('0000---',subPlanFormContent.value)
|
||||
planPopup.value?.open("edit", subPlanFormContent.value,modeStore.currentMode,2)
|
||||
}
|
||||
}
|
||||
|
||||
//收到子组件回复后新增子计划tab
|
||||
const addNewChildTab = async () => {
|
||||
await props.refreshTable!()//刷新检测计划列表
|
||||
}
|
||||
|
||||
|
||||
const distribute = (childPlan: Plan.ResPlan, scope: any) => {
|
||||
|
||||
ElMessageBox.confirm(`确定将以下被检设备分配给 ${childPlan.name} 吗?`, '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning',
|
||||
}).then(async () => {
|
||||
await subPlanBindDev({'planId': childPlan.id, 'devIds': scope.selectedListIds ,'bindFlag': 1}) //解绑 0 绑定 1
|
||||
proTable.value?.getTableList()
|
||||
ElMessage.success('分配成功')
|
||||
}).catch(() => {
|
||||
// 用户取消操作
|
||||
})
|
||||
}
|
||||
|
||||
const allotStandardDev = (childPlan: Plan.ResPlan) => {
|
||||
devTransfer.value.open(childPlan)
|
||||
}
|
||||
|
||||
// 删除 tab 方法
|
||||
const removeTab = (targetName: TabPaneName) => {
|
||||
// 👇 添加 ElMessageBox 确认删除
|
||||
ElMessageBox.confirm('确定要删除该计划吗?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning',
|
||||
}).then(() => {
|
||||
const tabs = editableTabs.value
|
||||
let activeName = editableTabsValue.value
|
||||
|
||||
if (activeName === targetName) {
|
||||
tabs.forEach((tab, index) => {
|
||||
if (tab.name === targetName) {
|
||||
const nextTab = tabs[index + 1] || tabs[index - 1]
|
||||
if (nextTab) {
|
||||
activeName = nextTab.name
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
editableTabsValue.value = activeName
|
||||
editableTabs.value = tabs.filter((tab) => tab.name !== targetName)
|
||||
|
||||
// 可选:删除后提示成功
|
||||
ElMessage.success('删除成功')
|
||||
}).catch(() => {
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
// 弹窗打开方法
|
||||
const open = async (textTitle: string,data: Plan.ReqPlan) => {
|
||||
dialogVisible.value = true
|
||||
title.value = textTitle
|
||||
planTitle.value = data.name
|
||||
planId.value = data.id
|
||||
planFormContent.value = data
|
||||
console.log('弹窗打开方法',planFormContent.value)
|
||||
|
||||
}
|
||||
|
||||
const handleTabClick = (tab:any) => {
|
||||
if(tab.props.closable){
|
||||
isTabPlanFather.value = true
|
||||
}else{
|
||||
isTabPlanFather.value = false
|
||||
}
|
||||
planId.value = tab.props.name
|
||||
console.log('handleTabClick',tab)
|
||||
proTable.value?.getTableList()
|
||||
}
|
||||
|
||||
const handleTableDataUpdate = async (newData: any[]) => {
|
||||
// 👇 处理新数据,例如更新 planFormContent
|
||||
console.log('handleTableDataUpdate', newData)
|
||||
const matchedItem = findItemById(newData, planId.value);
|
||||
if (matchedItem) {
|
||||
planFormContent.value = matchedItem
|
||||
console.log('递归匹配成功:', planFormContent.value)
|
||||
} else {
|
||||
console.warn('未找到匹配的 planId:', planId.value)
|
||||
}
|
||||
}
|
||||
|
||||
const findItemById = (data: any[], id: string): any => {
|
||||
for (const item of data) {
|
||||
if (item.id === id) {
|
||||
return item; // 找到匹配项,返回它
|
||||
}
|
||||
if (item.children && item.children.length > 0) {
|
||||
const result = findItemById(item.children, id); // 递归查找子项
|
||||
if (result) {
|
||||
return item; // 如果子项中找到,返回结果
|
||||
}
|
||||
}
|
||||
}
|
||||
return null; // 未找到匹配项
|
||||
};
|
||||
|
||||
|
||||
|
||||
defineExpose({ open,handleTableDataUpdate })
|
||||
|
||||
const props = defineProps<{
|
||||
refreshTable: (() => Promise<void>) | undefined;
|
||||
width: {
|
||||
type: Number,
|
||||
default: 800,
|
||||
},
|
||||
height: {
|
||||
type: Number,
|
||||
default: 744,
|
||||
},
|
||||
}>()
|
||||
</script>
|
||||
@@ -29,28 +29,25 @@
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { computed, ref } from 'vue'
|
||||
import type { Device } from '@/api/device/interface'
|
||||
import deviceDataList from '@/api/device/deviceData'
|
||||
import type { StandardDevice } from '@/api/device/interface/standardDevice'
|
||||
import { dialogBig } from '@/utils/elementBind'
|
||||
import { getUnboundPqDevList,getBoundPqDevList } from '@/api/plan/plan.ts'
|
||||
import { getBoundStandardDevList,getUnboundStandardDevList } from '@/api/plan/plan.ts'
|
||||
import { type Plan } from '@/api/plan/interface'
|
||||
import { ElMessage } from 'element-plus'
|
||||
const unboundPqDevList=ref<Device.ReqPqDevParams[]>([])//指定模式下所有未绑定的设备
|
||||
const boundPqDevList=ref<Device.ReqPqDevParams[]>([])//根据检测计划id查询出所有已绑定的设备
|
||||
const unboundStandardDevList=ref<StandardDevice.ResPqStandardDevice[]>([])//指定模式下所有未绑定的标准设备
|
||||
const boundStandardDevList=ref<StandardDevice.ResPqStandardDevice[]>([])//根据检测计划id查询出所有已绑定的标准设备
|
||||
const dialogVisible = ref(false)
|
||||
const planData = ref<Plan.ReqPlan | null>(null) // 新增状态管理
|
||||
const planData = ref<Plan.ResPlan | null>(null) // 新增状态管理
|
||||
|
||||
const value = ref<string[]>([])
|
||||
const generateData = () => {
|
||||
const unboundData = unboundPqDevList.value.map((i: Device.ReqPqDevParams) => ({
|
||||
const unboundData = unboundStandardDevList.value.map((i: StandardDevice.ResPqStandardDevice) => ({
|
||||
key: i.id,
|
||||
label: i.name,
|
||||
tips: i.description
|
||||
}))
|
||||
const boundData = boundPqDevList.value.map((i: Device.ReqPqDevParams) => ({
|
||||
const boundData = boundStandardDevList.value.map((i: StandardDevice.ResPqStandardDevice) => ({
|
||||
key: i.id,
|
||||
label: i.name,
|
||||
tips: i.description
|
||||
}))
|
||||
|
||||
return [...unboundData, ...boundData]
|
||||
@@ -65,20 +62,15 @@ const filterMethod = (query: string, item: { label?: string }) => {
|
||||
}
|
||||
|
||||
// 打开弹窗,可能是新增,也可能是编辑
|
||||
const open = async (data: Plan.ReqPlan) => {
|
||||
const open = async (data: Plan.ResPlan) => {
|
||||
dialogVisible.value = true
|
||||
planData.value = data
|
||||
console.log('planData.value',planData.value)
|
||||
const standardDevList_Result1 = await getUnboundStandardDevList(data);
|
||||
unboundStandardDevList.value = standardDevList_Result1.data as StandardDevice.ResPqStandardDevice[];
|
||||
|
||||
//console.log('123')
|
||||
|
||||
const pqDevList_Result1 = await getUnboundPqDevList(data);
|
||||
unboundPqDevList.value = pqDevList_Result1.data as Device.ReqPqDevParams[];
|
||||
|
||||
const pqDevList_Result2 = await getBoundPqDevList({'planId': data.id});
|
||||
boundPqDevList.value = pqDevList_Result2.data as Device.ReqPqDevParams[];
|
||||
|
||||
value.value = boundPqDevList.value.map((i: { id: { toString: () => any } }) => i.id.toString());
|
||||
//console.log('123',value.value)
|
||||
const standardDevList_Result2 = await getBoundStandardDevList(data);
|
||||
boundStandardDevList.value = standardDevList_Result2.data as StandardDevice.ResPqStandardDevice[];
|
||||
}
|
||||
const close = () => {
|
||||
dialogVisible.value = false
|
||||
@@ -87,15 +79,12 @@ const filterMethod = (query: string, item: { label?: string }) => {
|
||||
|
||||
const save = async () => {
|
||||
if (planData.value) {
|
||||
//await BindPqDevList({ 'planId': planData.value.id,'pqDevIds': value.value })
|
||||
ElMessage.success({ message: `设备绑定保存成功成功!` })
|
||||
ElMessage.success({ message: `标准设备绑定保存成功!` })
|
||||
}
|
||||
dialogVisible.value = false
|
||||
}
|
||||
|
||||
// 对外映射
|
||||
defineExpose({ open })
|
||||
const props = defineProps<{
|
||||
refreshTable: (() => Promise<void>) | undefined;
|
||||
}>()
|
||||
|
||||
</script>
|
||||
@@ -1,14 +1,34 @@
|
||||
<template>
|
||||
<!-- 基础信息弹出框 -->
|
||||
<el-dialog :title="dialogTitle" v-model='dialogVisible' @close="close" v-bind="dialogBig" align-center>
|
||||
<el-dialog :title="dialogTitle" v-model='dialogVisible' @close="close" v-bind="planType == 0 ? dialogBig : dialogMiddle" align-center>
|
||||
<div>
|
||||
<el-row :gutter="24">
|
||||
<el-col :span="12">
|
||||
<el-form :model="formContent" ref='dialogFormRef' :rules='rules'>
|
||||
<el-form-item label="名称" prop="name" :label-width="100">
|
||||
<el-col :span="planType == 0 ? 12 : 24">
|
||||
<el-form :model="formContent" ref='dialogFormRef' :rules='rules' >
|
||||
<el-form-item label="名称" prop="name" :label-width="110" >
|
||||
<el-input v-model="formContent.name" placeholder="请输入名称" autocomplete="off" maxlength="32" show-word-limit/>
|
||||
</el-form-item>
|
||||
<el-form-item label='检测源' prop='sourceIds' :label-width='100'>
|
||||
<el-form-item label='标准设备' prop='standardDevIdList' :label-width='110' v-if="selectByMode && planType == 0" >
|
||||
<el-select v-model="formContent.standardDevIdList" multiple collapse-tags :max-collapse-tags="2" :disabled="planType != 0" placeholder="请选择标准设备" clearable>
|
||||
<el-option
|
||||
v-for="option in pqStandardDevArray"
|
||||
:key="option.value"
|
||||
:label="option.label"
|
||||
:value="option.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label='测试项' prop='testItems' :label-width='110' v-if="selectByMode" >
|
||||
<el-select v-model="formContent.testItems" multiple collapse-tags :max-collapse-tags="3" :disabled="planType != 0" placeholder="请选择测试项" clearable>
|
||||
<el-option
|
||||
v-for="(option, index) in secondLevelOptions"
|
||||
:key="index"
|
||||
:label="option.label"
|
||||
:value="option.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label='检测源' prop='sourceIds' :label-width='110' v-if="!selectByMode">
|
||||
<el-select v-model="formContent.sourceIds" :multiple="selectByMode" collapse-tags placeholder="请选择检测源" clearable>
|
||||
<el-option
|
||||
v-for="(option, index) in pqSourceArray"
|
||||
@@ -18,8 +38,8 @@
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="数据源" prop="datasourceIds" :label-width="100">
|
||||
<el-select v-model="formContent.datasourceIds" :multiple="selectByMode" collapse-tags placeholder="请选择数据源" autocomplete="off" clearable>
|
||||
<el-form-item label="数据源" prop="datasourceIds" :label-width="110">
|
||||
<el-select v-model="formContent.datasourceIds" :multiple="selectByMode" :max-collapse-tags="2" :disabled="planType != 0" collapse-tags placeholder="请选择数据源" autocomplete="off" clearable @change="handleDataSourceChange">
|
||||
<el-option
|
||||
v-for="item in dictStore.getDictData(dataSourceType)"
|
||||
:key="item.id"
|
||||
@@ -28,7 +48,7 @@
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="检测脚本" prop="scriptId" :label-width="100">
|
||||
<el-form-item label="检测脚本" prop="scriptId" :label-width="110" v-if="!selectByMode">
|
||||
<el-select v-model="formContent.scriptId" placeholder="请选择检测脚本" autocomplete="off" :disabled="isSelectDisabled" clearable>
|
||||
<el-option
|
||||
v-for="(option, index) in pqScriptArray"
|
||||
@@ -38,8 +58,8 @@
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="误差体系" prop="errorSysId" :label-width="100">
|
||||
<el-select v-model="formContent.errorSysId" placeholder="请选择误差体系" autocomplete="off" :disabled="isSelectDisabled" clearable>
|
||||
<el-form-item label="误差体系" prop="errorSysId" :label-width="110">
|
||||
<el-select v-model="formContent.errorSysId" placeholder="请选择误差体系" autocomplete="off" :disabled="isSelectDisabled" clearable>
|
||||
<el-option
|
||||
v-for="(option, index) in pqErrorArray"
|
||||
:key="index"
|
||||
@@ -49,17 +69,17 @@
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="数据处理原则" prop="dataRule" :label-width="110">
|
||||
<el-select v-model="formContent.dataRule" placeholder="请选择数据处理原则" autocomplete="off" :disabled="isSelectDisabled" clearable>
|
||||
<el-select v-model="formContent.dataRule" placeholder="请选择数据处理原则" autocomplete="off" :disabled="isSelectDisabled" clearable>
|
||||
<el-option
|
||||
v-for="item in dictStore.getDictData('Data_Rule')"
|
||||
:key="item.id"
|
||||
:label="item.name"
|
||||
:value="item.id"
|
||||
:key="item.id"
|
||||
:label="item.name"
|
||||
:value="item.id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="守时检测" :label-width="100" prop='timeCheck'>
|
||||
<el-radio-group v-model="formContent.timeCheck">
|
||||
<el-form-item label="守时检测" :label-width="110" prop='timeCheck' >
|
||||
<el-radio-group v-model="formContent.timeCheck" :disabled="planType != 0">
|
||||
<el-radio :value="1">是</el-radio>
|
||||
<el-radio :value="0">否</el-radio>
|
||||
</el-radio-group>
|
||||
@@ -70,8 +90,8 @@
|
||||
<el-radio :value="0">否</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item> -->
|
||||
<el-form-item label="模版名称" prop="reportTemplateName" :label-width="100" v-if="formContent.associateReport === 1">
|
||||
<el-select v-model="formContent.reportTemplateName" placeholder="请选择报告模版" autocomplete="off" >
|
||||
<el-form-item label="模版名称" prop="reportTemplateName" :label-width="110" v-if="formContent.associateReport === 1">
|
||||
<el-select v-model="formContent.reportTemplateName" placeholder="请选择报告模版" autocomplete="off" :disabled="planType != 0" >
|
||||
<el-option
|
||||
v-for="(option, index) in pqReportName"
|
||||
:key="index"
|
||||
@@ -80,10 +100,13 @@
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
</el-form>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-col :span="12" v-if="planType == 0">
|
||||
<div style="text-align: center; margin-bottom: -30px;">
|
||||
<el-button type='primary' v-auth.plan="'import'" :icon='Download'>导入</el-button>
|
||||
</div>
|
||||
|
||||
<el-transfer
|
||||
v-model="value"
|
||||
filterable
|
||||
@@ -108,20 +131,24 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import{ElMessage, type FormInstance,type FormItemRule}from'element-plus'
|
||||
import { defineProps, defineEmits, reactive,watch,ref, type Ref, computed } from 'vue';
|
||||
import { dialogBig} from '@/utils/elementBind'
|
||||
import{CascaderOption, ElMessage,type FormItemRule}from'element-plus'
|
||||
import { defineProps, reactive,ref, computed } from 'vue';
|
||||
import { dialogBig,dialogMiddle} from '@/utils/elementBind'
|
||||
import { type Plan } from '@/api/plan/interface';
|
||||
import { addPlan, updatePlan,getUnboundPqDevList,getBoundPqDevList,getPqErrSysList,getPqScriptList,getTestSourceList } from '@/api/plan/plan.ts'
|
||||
import { addPlan, updatePlan,getUnboundPqDevList,getBoundPqDevList,getPqErrSysList,getPqScriptList,getTestSourceList,updateSubPlanName } from '@/api/plan/plan.ts'
|
||||
import { useDictStore } from '@/stores/modules/dict'
|
||||
import { type TestSource } from '@/api/device/interface/testSource';
|
||||
import { type TestScript } from '@/api/device/interface/testScript';
|
||||
import { type ErrorSystem } from '@/api/device/interface/error';
|
||||
import { type Device } from '@/api/device/interface/device';
|
||||
import {getPqReportAllName,getPqReportAllVersion} from '@/api/device/report/index.ts'
|
||||
import {getPqReportAllName} from '@/api/device/report/index.ts'
|
||||
import {useAppSceneStore} from "@/stores/modules/mode";
|
||||
import { fromPairs } from 'lodash';
|
||||
import { el } from 'element-plus/es/locale';
|
||||
import {Download } from '@element-plus/icons-vue'
|
||||
import {getAllPqStandardDev} from '@/api/device/standardDevice/index.ts'
|
||||
import { StandardDevice } from '@/api/device/interface/standardDevice';
|
||||
import { Dict } from '@/api/system/dictionary/interface';
|
||||
import { getDictTreeByCode } from '@/api/system/dictionary/dictTree';
|
||||
import {getAllUser} from '@/api/user/user'
|
||||
|
||||
|
||||
const AppSceneStore = useAppSceneStore()
|
||||
@@ -131,25 +158,29 @@ import { el } from 'element-plus/es/locale';
|
||||
const mode = ref()
|
||||
const selectByMode = ref(true)
|
||||
const pqSourceList=ref<TestSource.ResTestSource[]>([])//获取指定模式下所有检测源
|
||||
const pqScriptList=ref<TestScript.ResTestScript[]>([])//获取指定模式下所有检测源
|
||||
const pqErrSysList=ref<ErrorSystem.ErrorSystemList[]>([])//获取指定模式下所有检测源
|
||||
const pqDevList=ref<Device.ResPqDev[]>([])//获取指定模式下所有检测源
|
||||
const pqScriptList=ref<TestScript.ResTestScript[]>([])//获取指定模式下所有检测脚本
|
||||
const pqErrSysList=ref<ErrorSystem.ErrorSystemList[]>([])//获取指定模式下所有误差体系
|
||||
const pqDevList=ref<Device.ResPqDev[]>([])//获取指定模式下所有被检设备
|
||||
const pqStandardDevList=ref<StandardDevice.ResPqStandardDevice[]>([])//获取指定模式下所有标准设备
|
||||
|
||||
const pqReportName = ref<{ name: string }[]>([])
|
||||
|
||||
|
||||
const pqSourceArray = ref<{ label: string; value: string; }[]>()
|
||||
const pqScriptArray = ref<{ label: string; value: string; }[]>()
|
||||
const pqErrorArray = ref<{ label: string; value: string; }[]>()
|
||||
const pqDevArray = ref<{ label: string; value: string; }[]>()
|
||||
|
||||
|
||||
const pqStandardDevArray = ref<{ label: string; value: string; }[]>()
|
||||
const secondLevelOptions: any[] = [];
|
||||
const userArray = ref<{ label: string; value: string; }[]>([])
|
||||
|
||||
const unboundPqDevList=ref<Device.ResPqDev[]>([])//指定模式下所有未绑定的设备
|
||||
const boundPqDevList=ref<Device.ResPqDev[]>([])//根据检测计划id查询出所有已绑定的设备
|
||||
const value = ref<string[]>([])
|
||||
const allData = computed(() => generateData())
|
||||
const isSelectDisabled = ref(false)
|
||||
const planType = ref<number>(0)
|
||||
|
||||
|
||||
const generateData = () => {
|
||||
const unboundData = unboundPqDevList.value.map((i: Device.ResPqDev) => ({
|
||||
key: i.id,
|
||||
@@ -160,7 +191,7 @@ const generateData = () => {
|
||||
key: i.id,
|
||||
label: i.name,
|
||||
//tips: i.description
|
||||
disabled:i.checkState != 0 ,
|
||||
disabled:i.checkState != 0 || i.assign == 1,
|
||||
}))
|
||||
return [...unboundData, ...boundData]
|
||||
}
|
||||
@@ -169,7 +200,6 @@ const filterMethod = (query: string, item: { label?: string }) => {
|
||||
return item.label?.toLowerCase().includes(query.toLowerCase()) ?? false
|
||||
}
|
||||
|
||||
|
||||
function useMetaInfo() {
|
||||
const dialogVisible = ref(false)
|
||||
const titleType = ref('add')
|
||||
@@ -198,6 +228,12 @@ const filterMethod = (query: string, item: { label?: string }) => {
|
||||
reportTemplateName:'',
|
||||
reportTemplateVersion:'',
|
||||
dataRule:'',
|
||||
standardDevNameStr:'',
|
||||
testItemNameStr:'',
|
||||
standardDevIdList:[],
|
||||
standardDevMap:new Map<string, number>(),
|
||||
testItems:[],
|
||||
Check_By:'',
|
||||
})
|
||||
return { dialogVisible, titleType, formContent }
|
||||
}
|
||||
@@ -232,17 +268,26 @@ const filterMethod = (query: string, item: { label?: string }) => {
|
||||
reportTemplateName:'',
|
||||
reportTemplateVersion:'',
|
||||
dataRule:'',
|
||||
standardDevNameStr:'',
|
||||
standardDevIdList:[],
|
||||
standardDevMap:new Map<string, number>(),
|
||||
testItemNameStr:'',
|
||||
testItems:[],
|
||||
Check_By:'',
|
||||
}
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
let dialogTitle = computed(() => {
|
||||
return titleType.value === 'add' ? '新增检测计划' : '编辑检测计划'
|
||||
})
|
||||
|
||||
|
||||
|
||||
let dialogTitle = computed(() => {
|
||||
if (planType.value === 1) {
|
||||
return '新增子计划'
|
||||
} else if (titleType.value === 'add') {
|
||||
return '新增检测计划'
|
||||
} else {
|
||||
return '编辑检测计划'
|
||||
}
|
||||
})
|
||||
|
||||
// 定义表单校验规则
|
||||
const baseRules: Record<string, Array<FormItemRule>> = {
|
||||
@@ -252,6 +297,8 @@ const baseRules: Record<string, Array<FormItemRule>> = {
|
||||
scriptId: [{ required: true, message: '检测脚本必选!', trigger: 'change' }],
|
||||
errorSysId: [{ required: true, message: '误差体系必选!', trigger: 'change' }],
|
||||
dataRule: [{ required: true, message: '数据处理原则必选!', trigger: 'change' }],
|
||||
standardDevIdList: [{ required: true, message: '标准设备必选!', trigger: 'change' }],
|
||||
testItems: [{ required: true, message: '测试项必选!', trigger: 'change' }],
|
||||
};
|
||||
|
||||
// 使用计算属性根据 scene 动态生成规则
|
||||
@@ -278,38 +325,42 @@ const rules = computed(() => {
|
||||
}
|
||||
|
||||
|
||||
const emit = defineEmits(['update:tab'])
|
||||
// 保存数据
|
||||
const save = () => {
|
||||
try {
|
||||
dialogFormRef.value?.validate(async (valid: boolean) => {
|
||||
if (valid) {
|
||||
formContent.devIds = value.value
|
||||
// 将 formContent.devIds 转换为 ReqPqDevParams 数组
|
||||
// boundPqDevList.value = pqDevList.value
|
||||
// .filter(device => formContent.devIds.includes(device.id))
|
||||
// .map(device => ({
|
||||
// id: device.id,
|
||||
// name: device.name,
|
||||
// devType: device.devType,
|
||||
// createTime: device.createDate,
|
||||
// pattern: device.pattern,
|
||||
// }));
|
||||
|
||||
|
||||
|
||||
if (formContent.id) {
|
||||
// 把数据处理原则转成字典ID
|
||||
const patternItem = dictStore.getDictData('Data_Rule').find(item => item.name === formContent.dataRule);
|
||||
if (patternItem) {
|
||||
formContent.dataRule = patternItem.id;
|
||||
}
|
||||
|
||||
if( mode.value === '比对式'){
|
||||
await updatePlan(formContent)
|
||||
if(planType.value == 1){
|
||||
formContent.fatherPlanId = formContent.id;
|
||||
formContent.id = '';
|
||||
formContent.devIds = []
|
||||
formContent.standardDevIdList = []
|
||||
formContent.standardDevMap = new Map<string, number>();
|
||||
await addPlan(formContent)
|
||||
emit('update:tab')
|
||||
}
|
||||
else if(planType.value == 2){
|
||||
await updateSubPlanName(formContent)
|
||||
emit('update:tab')
|
||||
console.log('更新子计划',formContent)
|
||||
}
|
||||
else{
|
||||
await updatePlan(formContent)
|
||||
}
|
||||
|
||||
}else{
|
||||
|
||||
await updatePlan({...formContent,'sourceIds':[formContent.sourceIds],'datasourceIds':[formContent.datasourceIds]});
|
||||
}
|
||||
|
||||
ElMessage.success({ message: `${dialogTitle.value}成功!` })
|
||||
|
||||
} else {
|
||||
@@ -324,6 +375,7 @@ const rules = computed(() => {
|
||||
formContent.dataRule = patternItem2.id;
|
||||
}
|
||||
if( mode.value === '比对式'){
|
||||
formContent.sourceIds = null;
|
||||
await addPlan(formContent);
|
||||
}else{
|
||||
await addPlan({...formContent,'sourceIds':[formContent.sourceIds],'datasourceIds':[formContent.datasourceIds]});
|
||||
@@ -332,20 +384,20 @@ const rules = computed(() => {
|
||||
}
|
||||
close()
|
||||
// 刷新表格
|
||||
await props.refreshTable!()
|
||||
|
||||
if(planType.value == 0){
|
||||
await props.refreshTable!()
|
||||
}
|
||||
|
||||
}
|
||||
})
|
||||
} catch (err) {
|
||||
console.error('验证过程中出现错误', err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 打开弹窗,可能是新增,也可能是编辑
|
||||
const open = async (sign: string,
|
||||
data: Plan.ReqPlan,
|
||||
currentMode: string,) => {
|
||||
const open = async (sign: string, data: Plan.ReqPlan,currentMode: string,plan:number) => {
|
||||
unboundPqDevList.value = []
|
||||
boundPqDevList.value = []
|
||||
//处理异步调用
|
||||
@@ -354,29 +406,71 @@ const open = async (sign: string,
|
||||
mode.value = currentMode
|
||||
titleType.value = sign
|
||||
isSelectDisabled.value = false
|
||||
|
||||
planType.value = plan
|
||||
//比对式测试项下拉框
|
||||
if(mode.value == '比对式'){
|
||||
const dictCode = 'Script_Error';
|
||||
const resDictTree: Dict.ResDictTree = {
|
||||
name: '',
|
||||
id: '',
|
||||
pid: '',
|
||||
pids: '',
|
||||
code: dictCode,
|
||||
sort: 0
|
||||
};
|
||||
const result = await getDictTreeByCode(resDictTree)
|
||||
const allOptions = convertToOptions(result.data as Dict.ResDictTree[]);
|
||||
// 提取第二层节点
|
||||
allOptions.forEach(option => {
|
||||
if (option.children && option.children.length > 0) {
|
||||
secondLevelOptions.push(...option.children);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if(sign == 'add')
|
||||
{
|
||||
resetFormContent()
|
||||
const [pqSource_Result, PqScript_Result, PqErrSys_Result,pqDevList_Result,pqReportName_Result] = await Promise.all([
|
||||
|
||||
let pqSource_Result, PqScript_Result, PqErrSys_Result, pqDevList_Result, pqReportName_Result, pqStandardDev_Result;
|
||||
|
||||
if (mode.value === '比对式') {
|
||||
const commonResults = await Promise.all([
|
||||
getPqErrSysList(),
|
||||
getUnboundPqDevList(data),
|
||||
getPqReportAllName(),
|
||||
getAllPqStandardDev()
|
||||
]);
|
||||
[PqErrSys_Result, pqDevList_Result, pqReportName_Result, pqStandardDev_Result] = commonResults;
|
||||
|
||||
// 比对式下这两个接口不需要
|
||||
pqSource_Result = { data: [] };
|
||||
PqScript_Result = { data: [] };
|
||||
} else {
|
||||
const commonResults = await Promise.all([
|
||||
getTestSourceList(data),
|
||||
getPqScriptList(data),
|
||||
getPqErrSysList(),
|
||||
getUnboundPqDevList(data),
|
||||
getPqReportAllName(),
|
||||
|
||||
]);
|
||||
]);
|
||||
[pqSource_Result, PqScript_Result, PqErrSys_Result, pqDevList_Result, pqReportName_Result] = commonResults;
|
||||
}
|
||||
|
||||
if (Array.isArray(pqReportName_Result.data)) {
|
||||
pqReportName.value = pqReportName_Result.data.map(item => ({ name: item }));
|
||||
} else {
|
||||
pqReportName.value = [];
|
||||
console.error('pqReportName_Result.data is not an array:', pqReportName_Result.data);
|
||||
}
|
||||
pqSourceList.value = pqSource_Result.data as TestSource.ResTestSource[];
|
||||
pqScriptList.value = PqScript_Result.data as TestScript.ResTestScript[];
|
||||
pqErrSysList.value = PqErrSys_Result.data as unknown as ErrorSystem.ErrorSystemList[];
|
||||
pqDevList.value = pqDevList_Result.data as Device.ResPqDev[];
|
||||
if (pqStandardDev_Result && Array.isArray(pqStandardDev_Result.data)) {
|
||||
pqStandardDevList.value = pqStandardDev_Result.data as StandardDevice.ResPqStandardDevice[];
|
||||
} else {
|
||||
pqStandardDevList.value = [];
|
||||
}
|
||||
// 初始化 boundPqDevList 为空数组
|
||||
unboundPqDevList.value = pqDevList.value
|
||||
boundPqDevList.value = [];
|
||||
@@ -389,35 +483,60 @@ const open = async (sign: string,
|
||||
formContent.dataRule = dictStore.getDictData('Data_Rule')[0]?.id ?? '';
|
||||
|
||||
}else{//编辑时先给表单赋值(这会没接收被检设备),需要手动再给被检设备复制后整体表单赋值
|
||||
|
||||
|
||||
if(data.testState === 0){
|
||||
isSelectDisabled.value = false
|
||||
}else{
|
||||
if(plan == 1 || plan == 2){
|
||||
isSelectDisabled.value = true
|
||||
}else{
|
||||
if(data.testState === 0){
|
||||
isSelectDisabled.value = false
|
||||
}else{
|
||||
isSelectDisabled.value = true
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Object.assign(formContent,{ ...data })
|
||||
|
||||
const [pqSource_Result, PqScript_Result, PqErrSys_Result,boundPqDevList_Result, unboundPqDevList_Result,pqReportName_Result] = await Promise.all([
|
||||
let pqSource_Result, PqScript_Result, PqErrSys_Result, boundPqDevList_Result, unboundPqDevList_Result, pqReportName_Result, pqStandardDev_Result;
|
||||
|
||||
if (mode.value === '比对式') {
|
||||
const commonResults = await Promise.all([
|
||||
getPqErrSysList(),
|
||||
getBoundPqDevList({ 'planIdList': [data.id] }),
|
||||
getUnboundPqDevList(data),
|
||||
getPqReportAllName(),
|
||||
getAllPqStandardDev()
|
||||
]);
|
||||
[PqErrSys_Result, boundPqDevList_Result, unboundPqDevList_Result, pqReportName_Result, pqStandardDev_Result] = commonResults;
|
||||
|
||||
// 比对式下这两个接口不需要
|
||||
pqSource_Result = { data: [] };
|
||||
PqScript_Result = { data: [] };
|
||||
} else {
|
||||
const commonResults = await Promise.all([
|
||||
getTestSourceList(data),
|
||||
getPqScriptList(data),
|
||||
getPqErrSysList(),
|
||||
getBoundPqDevList({ 'planId': data.id }),
|
||||
getBoundPqDevList({ 'planIdList': [data.id] }),
|
||||
getUnboundPqDevList(data),
|
||||
getPqReportAllName(),
|
||||
]);
|
||||
]);
|
||||
[pqSource_Result, PqScript_Result, PqErrSys_Result, boundPqDevList_Result, unboundPqDevList_Result, pqReportName_Result] = commonResults;
|
||||
}
|
||||
|
||||
if (Array.isArray(pqReportName_Result.data)) {
|
||||
pqReportName.value = pqReportName_Result.data.map(item => ({ name: item }));
|
||||
} else {
|
||||
pqReportName.value = [];
|
||||
console.error('pqReportName_Result.data is not an array:', pqReportName_Result.data);
|
||||
}
|
||||
|
||||
pqSourceList.value = pqSource_Result.data as TestSource.ResTestSource[];
|
||||
pqScriptList.value = PqScript_Result.data as TestScript.ResTestScript[];
|
||||
pqErrSysList.value = PqErrSys_Result.data as unknown as ErrorSystem.ErrorSystemList[];
|
||||
if (pqStandardDev_Result && Array.isArray(pqStandardDev_Result.data)) {
|
||||
pqStandardDevList.value = pqStandardDev_Result.data as StandardDevice.ResPqStandardDevice[];
|
||||
} else {
|
||||
pqStandardDevList.value = [];
|
||||
}
|
||||
const boundData = Array.isArray(boundPqDevList_Result.data) ? boundPqDevList_Result.data : [];
|
||||
const unboundData = Array.isArray(unboundPqDevList_Result.data) ? unboundPqDevList_Result.data : [];
|
||||
|
||||
@@ -432,7 +551,7 @@ const open = async (sign: string,
|
||||
|
||||
pqToArray();//将对象转为数组
|
||||
|
||||
if( mode.value != '比对式'){
|
||||
if(mode.value != '比对式'){
|
||||
selectByMode.value = false
|
||||
// 将 formContent.sourceIds 从数组转换为字符串
|
||||
if (Array.isArray(formContent.sourceIds)) {
|
||||
@@ -451,12 +570,31 @@ const open = async (sign: string,
|
||||
}else{
|
||||
formContent.associateReport = 1
|
||||
}
|
||||
|
||||
if(plan == 1)//新增子计划名称清空
|
||||
{
|
||||
formContent.name = ''
|
||||
const userList = await getAllUser()
|
||||
const sourceArray1 = Array.isArray(userList.data) ? userList.data : []
|
||||
// 将 pqSource_Result 转换成 { label, value } 数组
|
||||
userArray.value = sourceArray1.map(item => ({
|
||||
label: item.loginName || '',
|
||||
value: item.id
|
||||
}));
|
||||
}
|
||||
// 所有数据加载完成后显示对话框
|
||||
dialogVisible.value = true;
|
||||
}
|
||||
|
||||
|
||||
// 转换函数
|
||||
const convertToOptions = (dictTree: Dict.ResDictTree[]): CascaderOption[] => {
|
||||
return dictTree.map(item => ({
|
||||
value: item.id,
|
||||
label: item.name,
|
||||
code: item.code,
|
||||
children: item.children ? convertToOptions(item.children) : undefined,
|
||||
remark: item.remark
|
||||
}));
|
||||
};
|
||||
function pqToArray() {
|
||||
const sourceArray1 = Array.isArray(pqSourceList.value) ? pqSourceList.value : []
|
||||
// 将 pqSource_Result 转换成 { label, value } 数组
|
||||
@@ -482,8 +620,19 @@ function pqToArray() {
|
||||
label: item.name,
|
||||
value: item.id
|
||||
}))
|
||||
|
||||
const sourceArray5 = Array.isArray(pqStandardDevList.value) ? pqStandardDevList.value : []
|
||||
console.log('5',sourceArray5)
|
||||
pqStandardDevArray.value = sourceArray5.map(item => ({
|
||||
label: item.name,
|
||||
value: item.id
|
||||
}))
|
||||
console.log('25',pqStandardDevArray.value)
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
const dataSourceType = computed(() => {
|
||||
// switch (mode.value) {
|
||||
// case '模拟式':
|
||||
@@ -496,6 +645,35 @@ const dataSourceType = computed(() => {
|
||||
return 'Datasource'
|
||||
})
|
||||
|
||||
const handleDataSourceChange = () => {
|
||||
if(mode.value != '比对式')
|
||||
return
|
||||
// 获取当前选中的 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 : '';
|
||||
})
|
||||
|
||||
// 判断是否同时包含 '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 = '';
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// 对外映射
|
||||
defineExpose({ open })
|
||||
|
||||
Reference in New Issue
Block a user