比对检测计划
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 })
|
||||
|
||||
@@ -3,15 +3,17 @@
|
||||
<ProTable
|
||||
ref='proTable'
|
||||
:columns='columns'
|
||||
:request-api='getTableList'
|
||||
:data="currentPageData"
|
||||
:request-api='getTableList'
|
||||
:pagination="false"
|
||||
>
|
||||
<!-- 表格 header 按钮 -->
|
||||
<template #tableHeader='scope'>
|
||||
<el-button type='primary' v-auth.plan="'import'" :icon='Download' @click='importClick' v-if="modeStore.currentMode != '比对式'">导入</el-button>
|
||||
<el-button type='primary' v-auth.plan="'export'" :icon='Upload' @click='exportClick' v-if="modeStore.currentMode != '比对式'">导出</el-button>
|
||||
<el-button type='primary' v-auth.plan="'combine'" :icon='ScaleToOriginal' :disabled='!(scope.selectedList.length > 1)' @click='combineClick'>
|
||||
<!-- <el-button type='primary' v-auth.plan="'combine'" :icon='ScaleToOriginal' :disabled='!(scope.selectedList.length > 1)' @click='combineClick'>
|
||||
合并
|
||||
</el-button>
|
||||
</el-button> -->
|
||||
<el-button type='primary' v-auth.plan="'add'" :icon='CirclePlus' @click="openDialog('add')">新增</el-button>
|
||||
<el-button type='primary' v-auth.plan="'analysis'" :icon='List' :disabled='!scope.isSelected' @click='statisticalAnalysisMore(scope.selectedListIds,scope.selectedList)'>统计分析</el-button>
|
||||
<el-button type='danger' v-auth.plan="'delete'" :icon='Delete' plain :disabled='!scope.isSelected' @click='batchDelete(scope.selectedListIds)'>
|
||||
@@ -23,37 +25,50 @@
|
||||
<template #operation='scope'>
|
||||
<el-button type='primary' v-auth.plan="'edit'" link :icon='EditPen' @click="openDialog('edit',scope.row)">编辑</el-button>
|
||||
<el-button type='primary' v-auth.plan="'delete'" link :icon='Delete' @click='handleDelete(scope.row)'>删除</el-button>
|
||||
<el-button type='primary' link :icon='List' @click="openTestSource(scope.row)">子计划</el-button>
|
||||
<el-button type='primary' link :icon='List' @click="openChildrenPlan(scope.row)" v-if="modeStore.currentMode == '比对式' && scope.row.fatherPlanId == 0">子计划</el-button>
|
||||
<!-- <el-button type='primary' link :icon='List' @click='showDeviceOpen(scope.row)'>设备绑定</el-button> -->
|
||||
<el-button type='primary' v-auth.plan="'analysis'" link :icon='List' v-if="scope.row.testState == '2'" @click='statisticalAnalysis(scope.row)'>统计分析</el-button>
|
||||
</template>
|
||||
|
||||
<!-- 在此处新增 footer 插槽 -->
|
||||
<template #pagination ='scope'>
|
||||
<el-pagination
|
||||
:background="true"
|
||||
:current-page="currentPage"
|
||||
:page-size="pageSize"
|
||||
:page-sizes="[10, 25, 50, 100]"
|
||||
:total="pageTotal"
|
||||
layout="total, sizes, prev, pager, next, jumper"
|
||||
@size-change="handleSizeChange"
|
||||
@current-change="handleCurrentChange"
|
||||
/>
|
||||
</template>
|
||||
</ProTable>
|
||||
</div>
|
||||
|
||||
<!-- 向计划导入/导出设备对话框 -->
|
||||
<PlanPopup :refresh-table='proTable?.getTableList' ref='planPopup'/>
|
||||
<PlanPopup :refresh-table='refreshTable' ref='planPopup'/>
|
||||
<!-- 查看误差体系详细信息 -->
|
||||
<ErrorStandardPopup :refresh-table='proTable?.getTableList' ref="errorStandardPopup"/>
|
||||
<!-- 查看检测源 -->
|
||||
<TestSourcePopup :refresh-table='proTable?.getTableList' ref="testSourcePopup"/>
|
||||
<!-- 查看设备绑定
|
||||
<DevTransfer :refresh-table='proTable?.getTableList' ref='devTransferPopup'/> -->
|
||||
|
||||
<ImportExcel ref='planImportExcel' />
|
||||
<SourceOpen :refresh-table='proTable?.getTableList' ref='openSourceView' :width='viewWidth' :height='viewHeight'></SourceOpen>
|
||||
|
||||
<ChildrenPlan :refresh-table='refreshTable' ref='childrenPlanView' :width='viewWidth' :height='viewHeight'></ChildrenPlan>
|
||||
|
||||
</template>
|
||||
|
||||
<script setup lang='tsx' name='useProTable'>
|
||||
import ProTable from '@/components/ProTable/index.vue'
|
||||
import type { ProTableInstance, ColumnProps } from '@/components/ProTable/interface'
|
||||
import type { ProTableInstance, ColumnProps, RenderScope } from '@/components/ProTable/interface'
|
||||
import { ScaleToOriginal, CirclePlus, Delete, EditPen, View, Upload, Download, List, Tools } from '@element-plus/icons-vue'
|
||||
import {getPlanList,deletePlan,exportPlan,downloadTemplate,importPlan } from '@/api/plan/plan.ts'
|
||||
import { computed, onMounted, reactive, ref } from 'vue'
|
||||
import { computed, onMounted, reactive, ref, watch } from 'vue'
|
||||
import type { Plan } from '@/api/plan/interface'
|
||||
import PlanPopup from '@/views/plan/planList/components/planPopup.vue' // 导入子组件
|
||||
import DeviceOpen from '@/views/plan/planList/components/devPopup.vue'
|
||||
import SourceOpen from '@/views/plan/planList/components/chidrenPlan.vue'
|
||||
import DevTransfer from './components/devTransfer.vue'
|
||||
import ChildrenPlan from '@/views/plan/planList/components/childrenPlan.vue'
|
||||
import { useViewSize } from '@/hooks/useViewSize'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { useDictStore } from '@/stores/modules/dict'
|
||||
@@ -72,41 +87,135 @@ import {useDownload} from "@/hooks/useDownload";
|
||||
import {getTestConfig } from '@/api/system/base/index'
|
||||
import {type Base } from '@/api/system/base/interface'
|
||||
import { getBoundPqDevList ,staticsAnalyse} from '@/api/plan/plan.ts'
|
||||
import { kMaxLength } from 'buffer'
|
||||
|
||||
// defineOptions({
|
||||
// name: 'planList'
|
||||
// })
|
||||
const dictStore = useDictStore()
|
||||
const openDeviceView = ref()
|
||||
const openSourceView = ref()
|
||||
const devTransferVisible = ref(false)
|
||||
const sourceTransferVisible = ref(false)
|
||||
const childrenPlanView = ref()
|
||||
// ProTable 实例
|
||||
const proTable = ref<ProTableInstance>()
|
||||
const errorStandardPopup = ref()
|
||||
const testSourcePopup = ref()
|
||||
const planPopup = ref()
|
||||
const devTransferPopup = ref()
|
||||
|
||||
const modeStore = useModeStore();
|
||||
|
||||
const tableData = ref<any[]>([])
|
||||
const planImportExcel = ref<InstanceType<typeof ImportExcel> | null>(null)
|
||||
const planList = ref<Plan.ResPlan[]>([]);
|
||||
const getTableList = async(params: any) => {
|
||||
let newParams = JSON.parse(JSON.stringify(params))
|
||||
const patternId = dictStore.getDictData('Pattern').find(item=>item.name=== modeStore.currentMode)?.id//获取数据字典中对应的id
|
||||
newParams.patternId = patternId
|
||||
|
||||
const { popupBaseView, viewWidth, viewHeight } = useViewSize()
|
||||
const pageTotal = ref(0)
|
||||
const currentPage = ref(1)
|
||||
const pageSize = ref(10)
|
||||
const currentPageData = ref<any[]>([])//当前页的数据
|
||||
const patternId = ref('')
|
||||
onMounted(async () => {
|
||||
refreshTable()
|
||||
|
||||
})
|
||||
//假分页后用data刷新
|
||||
const refreshTable = async () => {
|
||||
try {
|
||||
const result = await getPlanList(newParams);
|
||||
planList.value = result.data as Plan.ResPlan[];
|
||||
return result;
|
||||
console.log("表格刷新")
|
||||
patternId.value = dictStore.getDictData('Pattern').find(item => item.name === modeStore.currentMode)?.id;
|
||||
const result = await getPlanList({'patternId' : patternId.value});
|
||||
tableData.value = buildTree(result.data as any[]);
|
||||
pageTotal.value = tableData.value.length;
|
||||
updateCurrentPageData(tableData.value)
|
||||
console.log("表格刷新成功")
|
||||
} catch (error) {
|
||||
return { data: [] }; // 返回空数据或处理错误
|
||||
tableData.value = [];
|
||||
ElMessage.error('获取计划列表失败');
|
||||
}
|
||||
}
|
||||
|
||||
const { popupBaseView, viewWidth, viewHeight } = useViewSize()
|
||||
// 监听 tableData 变化
|
||||
watch(() => tableData.value, (newVal) => {
|
||||
if (childrenPlanView.value && newVal) {
|
||||
console.log('监听 tableData 变化', newVal)
|
||||
childrenPlanView.value.handleTableDataUpdate?.(newVal)
|
||||
updateCurrentPageData(newVal)
|
||||
}
|
||||
}, { deep: true, immediate: true })
|
||||
|
||||
//模糊查询计划列表
|
||||
const getTableList = async(params: any) => {
|
||||
let newParams = JSON.parse(JSON.stringify(params))
|
||||
// 从 newParams 中提取筛选条件
|
||||
const name = newParams.name
|
||||
const reportState = newParams.reportState
|
||||
const result = newParams.result
|
||||
const testState = newParams.testState
|
||||
|
||||
// 对 tableData.value 进行筛选
|
||||
const filteredData = tableData.value.filter(item => {
|
||||
let match = true
|
||||
|
||||
if (name) {
|
||||
match = item.name?.includes(name)
|
||||
}
|
||||
|
||||
if (reportState !== undefined && reportState !== null && reportState !== '') {
|
||||
match = item.reportState == (reportState)
|
||||
}
|
||||
|
||||
if (result !== undefined && result !== null && result !== '') {
|
||||
match = item.result == (result)
|
||||
}
|
||||
|
||||
if (testState !== undefined && testState !== null && testState !== '') {
|
||||
match = item.testState == (testState)
|
||||
}
|
||||
|
||||
return match
|
||||
})
|
||||
|
||||
|
||||
// 更新分页总数
|
||||
pageTotal.value = filteredData.length
|
||||
|
||||
// 更新当前页数据
|
||||
currentPage.value = 1
|
||||
updateCurrentPageData(filteredData)
|
||||
}
|
||||
|
||||
function buildTree(flatList: any[]): any[] {
|
||||
const map = new Map();
|
||||
const tree: any[] = [];
|
||||
|
||||
// First, create a map of all items by id for fast lookup
|
||||
flatList.forEach(item => {
|
||||
map.set(item.id, { ...item, children: [] });
|
||||
});
|
||||
|
||||
// Then, assign each item to its parent's children array
|
||||
flatList.forEach(item => {
|
||||
if (item.fatherPlanId && map.has(item.fatherPlanId)) {
|
||||
map.get(item.fatherPlanId).children.push(map.get(item.id));
|
||||
} else if (item.fatherPlanId === '0') {
|
||||
// Items with fatherPlanId '0' are root nodes
|
||||
tree.push(map.get(item.id));
|
||||
}
|
||||
});
|
||||
|
||||
return tree;
|
||||
}
|
||||
|
||||
const handleSizeChange = (size: number) => {
|
||||
pageSize.value = size
|
||||
updateCurrentPageData()
|
||||
}
|
||||
|
||||
const handleCurrentChange = (page: number) => {
|
||||
currentPage.value = page
|
||||
updateCurrentPageData()
|
||||
}
|
||||
|
||||
const updateCurrentPageData = (data = tableData.value) => {
|
||||
const start = (currentPage.value - 1) * pageSize.value
|
||||
const end = start + pageSize.value
|
||||
currentPageData.value = data.slice(start, end)
|
||||
console.log('currentPageData', currentPageData.value)
|
||||
}
|
||||
|
||||
const dataSourceType = computed(() => {
|
||||
// switch (modeStore.currentMode) {
|
||||
@@ -120,21 +229,20 @@ const dataSourceType = computed(() => {
|
||||
return 'Datasource'
|
||||
})
|
||||
|
||||
|
||||
// 表格配置项
|
||||
const columns = reactive<ColumnProps<Plan.ReqPlan>[]>([
|
||||
{ type: 'selection', fixed: 'left', minWidth: 70 },
|
||||
{ type: 'index', fixed: 'left', minWidth: 70, label: '序号' },
|
||||
{ type: 'index', fixed: 'left', minWidth: 70, label: '序号'},
|
||||
{
|
||||
prop: 'name',
|
||||
label: '名称',
|
||||
minWidth: 220,
|
||||
minWidth: 200,
|
||||
search: { el: 'input' },
|
||||
},
|
||||
{
|
||||
prop: 'testState',
|
||||
label: '检测状态',
|
||||
minWidth: 120,
|
||||
minWidth: 100,
|
||||
enum:dictTestState,
|
||||
search: { el:'select',props: { filterable: true }},
|
||||
fieldNames: { label: 'label', value: 'id' },
|
||||
@@ -149,14 +257,13 @@ const columns = reactive<ColumnProps<Plan.ReqPlan>[]>([
|
||||
{
|
||||
prop: 'progress',
|
||||
label: '检测进度',
|
||||
minWidth: 180,
|
||||
minWidth: 150,
|
||||
render: (scope) => {
|
||||
const randomPercentage = Math.floor(Math.random() * 101); // 生成 0 到 100 的随机整数
|
||||
return (
|
||||
<el-progress
|
||||
text-inside={true}
|
||||
stroke-width={20}
|
||||
percentage={randomPercentage}
|
||||
percentage={(scope.row.progress ?? 0) * 100}
|
||||
status='success'
|
||||
/>
|
||||
);
|
||||
@@ -178,12 +285,11 @@ const columns = reactive<ColumnProps<Plan.ReqPlan>[]>([
|
||||
{
|
||||
prop: 'result',
|
||||
label: '检测结果',
|
||||
minWidth: 120,
|
||||
minWidth: 100,
|
||||
enum:dictResult,
|
||||
search: { el: 'select', props: { filterable: true } },
|
||||
fieldNames: { label: 'label', value: 'id' },
|
||||
render: scope => {
|
||||
console.log('检测结果',scope.row.result)
|
||||
return (
|
||||
scope.row.result === 0 ? '不符合' : scope.row.result === 1 ? '符合' : '/'
|
||||
)
|
||||
@@ -192,7 +298,7 @@ const columns = reactive<ColumnProps<Plan.ReqPlan>[]>([
|
||||
{
|
||||
prop: 'createTime',
|
||||
label: '创建时间',
|
||||
minWidth: 200,
|
||||
minWidth: 180,
|
||||
render: scope => {
|
||||
if (scope.row.createTime) {
|
||||
const date = new Date(scope.row.createTime);
|
||||
@@ -210,7 +316,8 @@ const columns = reactive<ColumnProps<Plan.ReqPlan>[]>([
|
||||
{
|
||||
prop: 'sourceName',
|
||||
label: '检测源',
|
||||
minWidth: 400,
|
||||
minWidth: 300,
|
||||
isShow: modeStore.currentMode != "比对式",
|
||||
render: scope => {
|
||||
const sourceNames = Array.isArray(scope.row.sourceName) ? scope.row.sourceName : [];
|
||||
const sourceIds = Array.isArray(scope.row.sourceIds) ? scope.row.sourceIds : [];
|
||||
@@ -238,17 +345,30 @@ const columns = reactive<ColumnProps<Plan.ReqPlan>[]>([
|
||||
{
|
||||
prop: 'scriptId',
|
||||
label: '检测脚本',
|
||||
minWidth: 360,
|
||||
minWidth: 300,
|
||||
isShow: modeStore.currentMode != "比对式",
|
||||
render: scope => {
|
||||
return (
|
||||
<span>{scope.row.scriptName}</span>
|
||||
)
|
||||
},
|
||||
},
|
||||
{
|
||||
prop: 'standardDevNameStr',
|
||||
label: '标准设备',
|
||||
minWidth: 250,
|
||||
isShow: modeStore.currentMode == "比对式",
|
||||
|
||||
},
|
||||
{
|
||||
prop: 'testItemNameStr',
|
||||
label: '测试项',
|
||||
minWidth: 300,
|
||||
isShow: modeStore.currentMode == "比对式",
|
||||
},
|
||||
{
|
||||
prop: 'errorSysId',
|
||||
label: '误差体系',
|
||||
minWidth: 240,
|
||||
label: '误差体系', minWidth:300,
|
||||
render: scope => {
|
||||
return (
|
||||
<el-link type='primary' link onClick={() => showData(scope.row)}>
|
||||
@@ -257,12 +377,18 @@ const columns = reactive<ColumnProps<Plan.ReqPlan>[]>([
|
||||
)
|
||||
},
|
||||
},
|
||||
{
|
||||
prop: 'origin',//null 表示主计划 1表示子计划
|
||||
label: '来源',
|
||||
minWidth:200,
|
||||
isShow: modeStore.currentMode == "比对式",
|
||||
},
|
||||
{
|
||||
prop: 'datasourceIds',
|
||||
label: '数据源',
|
||||
enum: dictStore.getDictData(dataSourceType.value),
|
||||
fieldNames: { label: 'name', value: 'value' },
|
||||
minWidth: 250,
|
||||
minWidth: 230,
|
||||
render: (scope) => {
|
||||
const codes = scope.row.datasourceIds // 获取当前行的 datasourceIds 字段
|
||||
if (!codes) {
|
||||
@@ -295,7 +421,7 @@ const columns = reactive<ColumnProps<Plan.ReqPlan>[]>([
|
||||
minWidth: 120,
|
||||
},
|
||||
|
||||
{ prop: 'operation', label: '操作', fixed: 'right', minWidth: 300 },
|
||||
{ prop: 'operation', label: '操作', fixed: 'right', minWidth: 250 },
|
||||
])
|
||||
|
||||
|
||||
@@ -332,44 +458,6 @@ async function showTestSource(row:string) {
|
||||
|
||||
}
|
||||
|
||||
function showTestScript(row: string) {
|
||||
|
||||
}
|
||||
|
||||
function handleFiles(event: Event) {
|
||||
const target = event.target as HTMLInputElement
|
||||
const files = target.files
|
||||
if (files && files.length > 0) {
|
||||
// 处理文件
|
||||
// console.log(files)
|
||||
ElMessageBox.confirm(
|
||||
'导入的数据与当前数据有冲突,请选择以哪个数据为主进行覆盖',
|
||||
'数据冲突',
|
||||
{
|
||||
distinguishCancelAndClose: true,
|
||||
confirmButtonText: '以导入数据为主覆盖',
|
||||
cancelButtonText: '以当前数据为主覆盖',
|
||||
type: 'warning',
|
||||
},
|
||||
)
|
||||
.then(() => {
|
||||
ElMessage({
|
||||
type: 'info',
|
||||
message: '以导入数据为主完成数据覆盖',
|
||||
})
|
||||
})
|
||||
.catch((action: Action) => {
|
||||
ElMessage({
|
||||
type: 'info',
|
||||
message:
|
||||
action === 'cancel'
|
||||
? '以当前数据为主完成数据覆盖'
|
||||
: '取消本次导入操作',
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// 点击导入按钮
|
||||
const importClick = () => {
|
||||
const params = {
|
||||
@@ -378,7 +466,7 @@ const importClick = () => {
|
||||
patternId: dictStore.getDictData('Pattern').find(item=>item.name=== modeStore.currentMode)?.id ?? '',
|
||||
tempApi: downloadTemplate,
|
||||
importApi: importPlan,
|
||||
getTableList: proTable.value?.getTableList,
|
||||
getTableList: refreshTable(),
|
||||
}
|
||||
planImportExcel.value?.acceptParams(params)
|
||||
}
|
||||
@@ -391,51 +479,30 @@ const exportClick = () => {
|
||||
})
|
||||
}
|
||||
|
||||
// 点击合并按钮
|
||||
const combineClick = () => {
|
||||
ElMessageBox.prompt(
|
||||
'请输入合并后的计划名称',
|
||||
'检测计划合并',
|
||||
{
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
},
|
||||
)
|
||||
.then(({ value }) => {
|
||||
// console.log(`合并后的计划名为:`, value)
|
||||
proTable.value?.clearSelection()
|
||||
proTable.value?.getTableList()
|
||||
})
|
||||
}
|
||||
|
||||
// 打开 drawer(新增、编辑)
|
||||
const openDialog = (titleType: string, row: Partial<Plan.ReqPlan> = {}) => {
|
||||
planPopup.value?.open(titleType, row,modeStore.currentMode)
|
||||
planPopup.value?.open(titleType, row,modeStore.currentMode,0)//0主计划 1子计划 2修改子计划
|
||||
}
|
||||
|
||||
|
||||
// 批量删除设备
|
||||
const batchDelete = async (id: string[]) => {
|
||||
await useHandleData(deletePlan, id, '删除所选检测计划')
|
||||
await useHandleData(deletePlan, {'id':id, 'pattern':patternId.value},'删除所选检测计划')
|
||||
proTable.value?.clearSelection()
|
||||
proTable.value?.getTableList()
|
||||
await refreshTable()
|
||||
}
|
||||
|
||||
// 删除检测计划
|
||||
const handleDelete = async (params: Plan.ReqPlanParams) => {
|
||||
await useHandleData(deletePlan, [params.id], `删除【${params.name}】检测计划`)
|
||||
proTable.value?.getTableList()
|
||||
await useHandleData(deletePlan, {id: [params.id], 'pattern': patternId.value}, `删除【${params.name}】检测计划`)
|
||||
proTable.value?.clearSelection()
|
||||
await refreshTable()
|
||||
}
|
||||
|
||||
const openTestSource = (row: Partial<Plan.ReqPlan> = {}) => {
|
||||
openSourceView.value.open("检测计划详情",row.name)
|
||||
const openChildrenPlan = (row: Partial<Plan.ReqPlan> = {}) => {
|
||||
childrenPlanView.value.open("检测计划详情",row)
|
||||
}
|
||||
|
||||
const showDeviceOpen = (row: Partial<Plan.ReqPlan> = {}) => {
|
||||
devTransferPopup.value.open(row)
|
||||
}
|
||||
|
||||
const myDict = new Map<string, any[]>();
|
||||
|
||||
const statisticalAnalysisMore = async (ids: string[], rows: Plan.ReqPlan[]) => {
|
||||
const hasInvalidState = rows.some(row => row.testState != 2);
|
||||
@@ -452,39 +519,10 @@ const statisticalAnalysisMore = async (ids: string[], rows: Plan.ReqPlan[]) => {
|
||||
|
||||
const statisticalAnalysis = async (row: Partial<Plan.ReqPlan> = {}) => {
|
||||
useDownload(staticsAnalyse,'分析结果', [row.id], false,'.xlsx')
|
||||
|
||||
// const response = await getTestConfig() as unknown as Base.ResTestConfig
|
||||
// const maxTime= response.data.maxTime//检测最大次数
|
||||
// const dev = await getBoundPqDevList({ 'planId': row.id })
|
||||
// for (let i = 0; i <= maxTime; i++) {
|
||||
// dev.data.forEach((item: any) => {
|
||||
// if(item.reCheckNum === i){
|
||||
// // 向已有的数组中添加元素
|
||||
// if (myDict.has(i.toString())) {
|
||||
// myDict.get(i.toString())?.push(item.name);
|
||||
// }else{
|
||||
// myDict.set(i.toString(), [item.name]);
|
||||
// }
|
||||
// }
|
||||
|
||||
// })
|
||||
// }
|
||||
|
||||
// for (let i = 0; i <= maxTime; i++) {
|
||||
// if (myDict.has(i.toString())) {
|
||||
// const array = myDict.get(i.toString());
|
||||
// if (array) {
|
||||
// for (const value of array) {
|
||||
// console.log(i + '---'+value);
|
||||
// }
|
||||
// }
|
||||
|
||||
// }
|
||||
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
Reference in New Issue
Block a user