首页隐藏子计划,计划列表子计划设备管理
This commit is contained in:
@@ -88,7 +88,7 @@ export namespace Device {
|
|||||||
coefficientTime?: number;//系数校准耗时
|
coefficientTime?: number;//系数校准耗时
|
||||||
formalCheckTime?: number;//正式检测耗时
|
formalCheckTime?: number;//正式检测耗时
|
||||||
|
|
||||||
boundPlanName?: string;
|
boundPlanName?: string| null;
|
||||||
assign?: number;////是否分配给检测人员 0否 1是
|
assign?: number;////是否分配给检测人员 0否 1是
|
||||||
monitorList: Monitor.ResPqMon[] ;
|
monitorList: Monitor.ResPqMon[] ;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ export namespace Plan {
|
|||||||
reportTemplateVersion:string;
|
reportTemplateVersion:string;
|
||||||
dataRule:string;//数据处理原则
|
dataRule:string;//数据处理原则
|
||||||
|
|
||||||
standardDevIdList:string[];
|
standardDevIds:string[];
|
||||||
standardDevMap:Map<string,number>;//标准设备
|
standardDevMap:Map<string,number>;//标准设备
|
||||||
testItems:string[];//测试项
|
testItems:string[];//测试项
|
||||||
Check_By?:string;//计划检测人
|
Check_By?:string;//计划检测人
|
||||||
|
|||||||
@@ -100,6 +100,11 @@ export const updateSubPlanName = (params:Plan.ReqPlan) => {
|
|||||||
return http.get(`/adPlan/updateSubPlanName?planId=${params.id}&name=${params.name}`)
|
return http.get(`/adPlan/updateSubPlanName?planId=${params.id}&name=${params.name}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//子计划绑定/解绑标准设备
|
||||||
|
export const subPlanBindStandardDevList = (params:Plan.ReqPlan) => {
|
||||||
|
return http.post(`/adPlan/updateBindStandardDev`, params)
|
||||||
|
}
|
||||||
|
|
||||||
//子计划绑定/解绑被检设备
|
//子计划绑定/解绑被检设备
|
||||||
export const subPlanBindDev = (params:Plan.ReqPlan) => {
|
export const subPlanBindDev = (params:Plan.ReqPlan) => {
|
||||||
return http.post(`/adPlan/updateBindDev`, params)
|
return http.post(`/adPlan/updateBindDev`, params)
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form> -->
|
</el-form> -->
|
||||||
<!-- <el-button @click="logConnections">打印当前配对</el-button> -->
|
<el-button @click="logConnections">打印当前配对</el-button>
|
||||||
<VueFlow
|
<VueFlow
|
||||||
:nodes="nodes"
|
:nodes="nodes"
|
||||||
:edges="edges"
|
:edges="edges"
|
||||||
@@ -350,8 +350,7 @@ const open = async () => {
|
|||||||
'4': 1, // 标准设备2 → 1个通道
|
'4': 1, // 标准设备2 → 1个通道
|
||||||
}
|
}
|
||||||
|
|
||||||
const yPosition = ref(25)
|
|
||||||
const yPosition2 = ref(25)
|
|
||||||
const createNodes = () => {
|
const createNodes = () => {
|
||||||
const newNodes: any[] = []
|
const newNodes: any[] = []
|
||||||
|
|
||||||
@@ -365,6 +364,9 @@ const createNodes = () => {
|
|||||||
const outputChannelX = 800
|
const outputChannelX = 800
|
||||||
const standardWidth = 950
|
const standardWidth = 950
|
||||||
|
|
||||||
|
const yPosition = ref(25)
|
||||||
|
const yPosition2 = ref(25)
|
||||||
|
|
||||||
// 添加被检通道
|
// 添加被检通道
|
||||||
Object.entries(channelCounts).forEach(([deviceId, count]) => {
|
Object.entries(channelCounts).forEach(([deviceId, count]) => {
|
||||||
for (let i = 1; i <= count; i++) {
|
for (let i = 1; i <= count; i++) {
|
||||||
|
|||||||
@@ -523,11 +523,11 @@ const columns = reactive<ColumnProps<Device.ResPqDev>[]>([
|
|||||||
prop: 'devType',
|
prop: 'devType',
|
||||||
label: '设备类型',
|
label: '设备类型',
|
||||||
minWidth: 100,
|
minWidth: 100,
|
||||||
render: (scope) => {
|
// render: (scope) => {
|
||||||
// 查找设备类型名称
|
// // 查找设备类型名称
|
||||||
const name = devTypeOptions.value.find(option => option.id === scope.row.devType)
|
// const name = devTypeOptions.value.find(option => option.id === scope.row.devType)
|
||||||
return <span>{name?.name}</span>
|
// return <span>{name?.name}</span>
|
||||||
},
|
// },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
prop: 'devChns',
|
prop: 'devChns',
|
||||||
|
|||||||
@@ -80,7 +80,8 @@ const defaultChecked = ref<string[]>([]) // 明确类型为 number[]
|
|||||||
const tree = ref(false)//确保左侧树高凉只执行一次
|
const tree = ref(false)//确保左侧树高凉只执行一次
|
||||||
const getTreeData = (val: any) => {
|
const getTreeData = (val: any) => {
|
||||||
defaultChecked.value = [];
|
defaultChecked.value = [];
|
||||||
data.value = val;
|
// 遍历 val 的每个 children,过滤掉 pid !== '0'
|
||||||
|
data.value = val
|
||||||
|
|
||||||
for (let item of data.value) {
|
for (let item of data.value) {
|
||||||
if (item.children.length > 0) {
|
if (item.children.length > 0) {
|
||||||
|
|||||||
@@ -300,7 +300,8 @@ const getPieData = async (id: string) => {
|
|||||||
const reportStateCount: { [key: number]: number } = { 0: 0, 1: 0, 2: 0 }
|
const reportStateCount: { [key: number]: number } = { 0: 0, 1: 0, 2: 0 }
|
||||||
if (id) {
|
if (id) {
|
||||||
const boundPqDevList = ref<Device.ResPqDev[]>([])//根据检测计划id查询出所有已绑定的设备
|
const boundPqDevList = ref<Device.ResPqDev[]>([])//根据检测计划id查询出所有已绑定的设备
|
||||||
const plan = findPlanById(planList.value?.data || [], id)
|
const plan = findPlanById(planList.value, id)
|
||||||
|
console.log('所选计划:',plan)
|
||||||
planName.value = '所选计划:' + plan.name
|
planName.value = '所选计划:' + plan.name
|
||||||
|
|
||||||
select_Plan.value = plan
|
select_Plan.value = plan
|
||||||
@@ -493,22 +494,30 @@ const initPlan = async () => {
|
|||||||
dataRule: '',
|
dataRule: '',
|
||||||
testItemNameStr:'',
|
testItemNameStr:'',
|
||||||
testItems: [],
|
testItems: [],
|
||||||
standardDevIdList:[],
|
standardDevIds:[],
|
||||||
standardDevMap: new Map<string, number>(),
|
standardDevMap: new Map<string, number>(),
|
||||||
}
|
}
|
||||||
planList.value = (await getPlanListByPattern(reqPlan)) as ResultData<Plan.ReqPlan[]>
|
planList.value = (await getPlanListByPattern(reqPlan)) as ResultData<Plan.ReqPlan[]>
|
||||||
|
|
||||||
|
planList.value = planList.value.data.map((item: any) => {
|
||||||
|
if (item.children) {
|
||||||
|
item.children = item.children.filter(child => child.pid === '0');
|
||||||
|
}
|
||||||
|
return item;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
onBeforeMount(async () => {
|
onBeforeMount(async () => {
|
||||||
|
|
||||||
await initPlan()
|
await initPlan()
|
||||||
for (let i = 0; i < planList.value.data.length; i++) {
|
console.log(planList.value)
|
||||||
if (Array.isArray(planList.value.data[i].children) && planList.value.data[i].children.length > 0) {
|
for (let i = 0; i < planList.value.length; i++) {
|
||||||
currentId.value = planList.value.data[i].children[0].id; // 直接赋值第一个 children 的 id
|
if (Array.isArray(planList.value[i].children) && planList.value[i].children.length > 0) {
|
||||||
|
currentId.value = planList.value[i].children[0].id; // 直接赋值第一个 children 的 id
|
||||||
break; // 确保只执行一次
|
break; // 确保只执行一次
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
console.log('planList.valuecurrentId.value', currentId.value)
|
||||||
// if (planList.value.data[0].children[0]) {
|
// if (planList.value.data[0].children[0]) {
|
||||||
// currentId.value = planList.value.data[0].children[0].id
|
// currentId.value = planList.value.data[0].children[0].id
|
||||||
// console.log('currentId.value',planList.value.data[0])
|
// console.log('currentId.value',planList.value.data[0])
|
||||||
@@ -517,8 +526,7 @@ onBeforeMount(async () => {
|
|||||||
if (chartsInfoRef.value) {
|
if (chartsInfoRef.value) {
|
||||||
resizeObserver.observe(chartsInfoRef.value)
|
resizeObserver.observe(chartsInfoRef.value)
|
||||||
}
|
}
|
||||||
getTree(planList.value.data)
|
getTree(planList.value)
|
||||||
|
|
||||||
getPieData(currentId.value)
|
getPieData(currentId.value)
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -532,7 +540,7 @@ const handleBatchGenerate = async () => {
|
|||||||
// console.log('批量生成按钮被点击了');
|
// console.log('批量生成按钮被点击了');
|
||||||
// 在这里添加其他逻辑,比如显示对话框、更新状态等
|
// 在这里添加其他逻辑,比如显示对话框、更新状态等
|
||||||
await initPlan()
|
await initPlan()
|
||||||
treeRef.value.clickTableToTree(planList.value.data,currentId.value)
|
treeRef.value.clickTableToTree(planList.value,currentId.value)
|
||||||
getPieData(currentId.value)
|
getPieData(currentId.value)
|
||||||
|
|
||||||
if (form.value.activeTabs === 0)//设备检测
|
if (form.value.activeTabs === 0)//设备检测
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
:title="title"
|
:title="title"
|
||||||
:width="width"
|
:width="width"
|
||||||
:modal="false"
|
:modal="false"
|
||||||
|
@close="handleClose"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class="table-box"
|
class="table-box"
|
||||||
@@ -42,13 +43,13 @@
|
|||||||
<el-button type="primary" :icon="CirclePlus" @click="addTab('edit')" v-if="isTabPlanFather">
|
<el-button type="primary" :icon="CirclePlus" @click="addTab('edit')" v-if="isTabPlanFather">
|
||||||
编辑子计划
|
编辑子计划
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-button type="primary" :icon="Upload" >
|
<!-- <el-button type="primary" :icon="Upload" >
|
||||||
导出检测方案
|
导出检测方案
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-button type="primary" :icon="Download" >
|
<el-button type="primary" :icon="Download" >
|
||||||
导入检测结果
|
导入检测结果
|
||||||
</el-button>
|
</el-button> -->
|
||||||
<el-button type="danger" :icon="Delete" plain :disabled="!scope.isSelected">
|
<el-button type="danger" :icon="Delete" plain :disabled="!scope.isSelected" v-if="isTabPlanFather" @click="subBatchRemove(scope.selectedListIds)">
|
||||||
批量移除
|
批量移除
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-dropdown trigger="hover" placement="right-start" :disabled="!scope.isSelected">
|
<el-dropdown trigger="hover" placement="right-start" :disabled="!scope.isSelected">
|
||||||
@@ -85,16 +86,16 @@
|
|||||||
</el-dropdown>
|
</el-dropdown>
|
||||||
</template>
|
</template>
|
||||||
<!-- 表格操作 -->
|
<!-- 表格操作 -->
|
||||||
<template #operation="">
|
<template #operation="scope">
|
||||||
<el-button type="primary" link :icon="Delete" v-if="!isTabPlanFather">删除</el-button>
|
<el-button type="primary" link :icon="Delete" v-if="!isTabPlanFather" :disabled="scope.row.checkState != 0" >删除</el-button>
|
||||||
<el-button type="primary" link :icon="Delete" v-if="isTabPlanFather">移除</el-button>
|
<el-button type="primary" link :icon="Delete" v-if="isTabPlanFather" @click="subHandleRemove(scope.row)">移除</el-button>
|
||||||
</template>
|
</template>
|
||||||
</ProTable>
|
</ProTable>
|
||||||
</div>
|
</div>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
<!-- 向计划导入/导出设备对话框 -->
|
<!-- 向计划导入/导出设备对话框 -->
|
||||||
<PlanPopup :refresh-table='proTable?.getTableList' ref='planPopup' @update:tab="addNewChildTab"/>
|
<PlanPopup :refresh-table='proTable?.getTableList' ref='planPopup' @update:tab="addNewChildTab"/>
|
||||||
<DevTransfer ref='devTransfer' />
|
<DevTransfer ref='devTransfer' @update:table="addNewChildTab"/>
|
||||||
</template>
|
</template>
|
||||||
<script setup lang="tsx">
|
<script setup lang="tsx">
|
||||||
import { ElMessage, ElMessageBox, TabPaneName } from 'element-plus'
|
import { ElMessage, ElMessageBox, TabPaneName } from 'element-plus'
|
||||||
@@ -104,10 +105,12 @@ import PlanPopup from '@/views/plan/planList/components/planPopup.vue' // 导入
|
|||||||
import { Plan } from '@/api/plan/interface'
|
import { Plan } from '@/api/plan/interface'
|
||||||
import {useModeStore } from '@/stores/modules/mode'; // 引入模式 store
|
import {useModeStore } from '@/stores/modules/mode'; // 引入模式 store
|
||||||
import { ColumnProps, ProTableInstance, SearchRenderScope } from '@/components/ProTable/interface'
|
import { ColumnProps, ProTableInstance, SearchRenderScope } from '@/components/ProTable/interface'
|
||||||
import {getDevListByPlanId ,subPlanBindDev} from '@/api/plan/plan'
|
import {getDevListByPlanId ,subPlanBindDev,deletePlan} from '@/api/plan/plan'
|
||||||
import { Device } from '@/api/device/interface/device'
|
import { Device } from '@/api/device/interface/device'
|
||||||
import { useDictStore } from '@/stores/modules/dict'
|
import { useDictStore } from '@/stores/modules/dict'
|
||||||
import DevTransfer from '@/views/plan/planList/components/devTransfer.vue'
|
import DevTransfer from '@/views/plan/planList/components/devTransfer.vue'
|
||||||
|
import { useHandleData } from '@/hooks/useHandleData'
|
||||||
|
|
||||||
|
|
||||||
const dictStore = useDictStore()
|
const dictStore = useDictStore()
|
||||||
const planFormContent = ref<Plan.ReqPlan>()
|
const planFormContent = ref<Plan.ReqPlan>()
|
||||||
@@ -124,25 +127,28 @@ const planTitle = ref('')
|
|||||||
const editableTabsValue = ref('0')
|
const editableTabsValue = ref('0')
|
||||||
const isTabPlanFather = ref(true)
|
const isTabPlanFather = ref(true)
|
||||||
const planId = ref('')
|
const planId = ref('')
|
||||||
|
const planTabDevList = ref<any[]>([])
|
||||||
|
const patternId = ref('')
|
||||||
|
|
||||||
const getTableList = async (params: any) => {
|
const getTableList = async (params: any) => {
|
||||||
if (!planFormContent.value) {
|
if (!planFormContent.value) {
|
||||||
return Promise.resolve({ data: [], total: 0 });
|
return Promise.resolve({ data: [], total: 0 });
|
||||||
}
|
}
|
||||||
let newParams = JSON.parse(JSON.stringify(params));
|
let newParams = JSON.parse(JSON.stringify(params));
|
||||||
const patternId = dictStore.getDictData('Pattern').find(item => item.name === modeStore.currentMode)?.id//获取数据字典中对应的id
|
newParams.pattern = patternId.value
|
||||||
newParams.pattern = patternId
|
|
||||||
if(!isTabPlanFather.value)
|
if(!isTabPlanFather.value)
|
||||||
newParams.planId = planFormContent.value.id
|
newParams.planId = planFormContent.value.id
|
||||||
else
|
else
|
||||||
newParams.planId = planId.value
|
newParams.planId = planId.value
|
||||||
newParams.planIdList = [newParams.planId];
|
newParams.planIdList = [newParams.planId];
|
||||||
proTable.value?.clearSelection()
|
proTable.value?.clearSelection()
|
||||||
return getDevListByPlanId(newParams);
|
planTabDevList.value = await getDevListByPlanId(newParams);
|
||||||
|
return planTabDevList.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const columns = reactive<ColumnProps<Device.ResPqDev>[]>([
|
const columns = reactive<ColumnProps<Device.ResPqDev>[]>([
|
||||||
{ type: 'selection', fixed: 'left', width: 70 },
|
{ type: 'selection', fixed: 'left', width: 70,selectable: (row) => row.checkState == 0 },
|
||||||
{ type: 'index', fixed: 'left', width: 70, label: '序号' },
|
{ type: 'index', fixed: 'left', width: 70, label: '序号' },
|
||||||
{
|
{
|
||||||
prop: 'name',
|
prop: 'name',
|
||||||
@@ -222,7 +228,7 @@ const columns = reactive<ColumnProps<Device.ResPqDev>[]>([
|
|||||||
prop: 'boundPlanName',
|
prop: 'boundPlanName',
|
||||||
label: '子计划',
|
label: '子计划',
|
||||||
minWidth: 150,
|
minWidth: 150,
|
||||||
isShow: isTabPlanFather.value,
|
|
||||||
render: (scope) => {
|
render: (scope) => {
|
||||||
console.log('boundPlanName', isTabPlanFather.value)
|
console.log('boundPlanName', isTabPlanFather.value)
|
||||||
const value = scope.row.boundPlanName;
|
const value = scope.row.boundPlanName;
|
||||||
@@ -280,11 +286,16 @@ const editableTabs = computed(() => {
|
|||||||
const unbindDevice = (row: any) => {
|
const unbindDevice = (row: any) => {
|
||||||
if(row.state == '/')
|
if(row.state == '/')
|
||||||
return
|
return
|
||||||
|
|
||||||
ElMessageBox.confirm(`确定将设备 ${row.name} 从子计划中解绑吗?`, '提示', {
|
ElMessageBox.confirm(`确定将设备 ${row.name} 从子计划中解绑吗?`, '提示', {
|
||||||
confirmButtonText: '确定',
|
confirmButtonText: '确定',
|
||||||
cancelButtonText: '取消',
|
cancelButtonText: '取消',
|
||||||
type: 'warning'
|
type: 'warning'
|
||||||
}).then(async () => {
|
}).then(async () => {
|
||||||
|
if(row.checkState != 0){
|
||||||
|
ElMessage.warning(`当前设备已检,无法解除绑定!`);
|
||||||
|
return
|
||||||
|
}
|
||||||
await subPlanBindDev({'planId': row.planId, 'devIds': [row.id] ,'bindFlag': 0}) //解绑 0 绑定 1
|
await subPlanBindDev({'planId': row.planId, 'devIds': [row.id] ,'bindFlag': 0}) //解绑 0 绑定 1
|
||||||
// 👇 更新数据(例如清空 state 字段)
|
// 👇 更新数据(例如清空 state 字段)
|
||||||
row.state = '/'
|
row.state = '/'
|
||||||
@@ -319,6 +330,20 @@ const addNewChildTab = async () => {
|
|||||||
|
|
||||||
const distribute = (childPlan: Plan.ResPlan, scope: any) => {
|
const distribute = (childPlan: Plan.ResPlan, scope: any) => {
|
||||||
|
|
||||||
|
// 获取当前选中的设备对象
|
||||||
|
const selectedDevices = planTabDevList.value.data.records.filter((dev: { id: any }) =>
|
||||||
|
scope.selectedListIds.includes(dev.id)
|
||||||
|
);
|
||||||
|
// 找出不符合条件的设备
|
||||||
|
const invalidDevices = selectedDevices.filter(
|
||||||
|
(dev: { checkState: number; assign: number }) => dev.checkState !== 0 || dev.assign === 1
|
||||||
|
);
|
||||||
|
if (invalidDevices.length > 0) {
|
||||||
|
const names = invalidDevices.map((dev: { name: any }) => dev.name).join('、');
|
||||||
|
ElMessage.warning(`以下设备不可分配:${names}`);
|
||||||
|
proTable.value?.clearSelection()
|
||||||
|
return;
|
||||||
|
}
|
||||||
ElMessageBox.confirm(`确定将以下被检设备分配给 ${childPlan.name} 吗?`, '提示', {
|
ElMessageBox.confirm(`确定将以下被检设备分配给 ${childPlan.name} 吗?`, '提示', {
|
||||||
confirmButtonText: '确定',
|
confirmButtonText: '确定',
|
||||||
cancelButtonText: '取消',
|
cancelButtonText: '取消',
|
||||||
@@ -337,53 +362,45 @@ const allotStandardDev = (childPlan: Plan.ResPlan) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 删除 tab 方法
|
// 删除 tab 方法
|
||||||
const removeTab = (targetName: TabPaneName) => {
|
const removeTab = async (targetName: TabPaneName) => {
|
||||||
// 👇 添加 ElMessageBox 确认删除
|
// 找到匹配的 tab
|
||||||
ElMessageBox.confirm('确定要删除该计划吗?', '提示', {
|
const tab = editableTabs.value.find(item => item.name === targetName);
|
||||||
confirmButtonText: '确定',
|
const tabTitle = tab?.title || '未知计划'; // 获取 tab 的标题,若不存在则默认为 '未知计划'
|
||||||
cancelButtonText: '取消',
|
|
||||||
type: 'warning',
|
|
||||||
}).then(() => {
|
|
||||||
const tabs = editableTabs.value
|
|
||||||
let activeName = editableTabsValue.value
|
|
||||||
|
|
||||||
if (activeName === targetName) {
|
await useHandleData(deletePlan, { id: [targetName], pattern: patternId.value }, `删除【${tabTitle}】检测计划`);
|
||||||
tabs.forEach((tab, index) => {
|
await props.refreshTable!()//刷新检测计划列表
|
||||||
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) => {
|
const open = async (textTitle: string,data: Plan.ReqPlan,pattern: string) => {
|
||||||
dialogVisible.value = true
|
dialogVisible.value = true
|
||||||
title.value = textTitle
|
title.value = textTitle
|
||||||
planTitle.value = data.name
|
planTitle.value = data.name
|
||||||
planId.value = data.id
|
planId.value = data.id
|
||||||
planFormContent.value = data
|
planFormContent.value = data
|
||||||
|
editableTabsValue.value = planFormContent.value.id//默认tab第一个
|
||||||
|
proTable.value?.getTableList()
|
||||||
|
isTabPlanFather.value = false//子计划页面按钮默认展示主计划的
|
||||||
|
patternId.value = pattern
|
||||||
console.log('弹窗打开方法',planFormContent.value)
|
console.log('弹窗打开方法',planFormContent.value)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleTabClick = (tab:any) => {
|
const handleTabClick = (tab:any) => {
|
||||||
if(tab.props.closable){
|
if(tab.props.closable){
|
||||||
|
columns.forEach(item => {//隐藏子计划名称
|
||||||
|
if (item.prop === 'boundPlanName') {
|
||||||
|
item.isShow = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
isTabPlanFather.value = true
|
isTabPlanFather.value = true
|
||||||
}else{
|
}else{
|
||||||
|
columns.forEach(item => {
|
||||||
|
if (item.prop === 'boundPlanName') {
|
||||||
|
item.isShow = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
isTabPlanFather.value = false
|
isTabPlanFather.value = false
|
||||||
}
|
}
|
||||||
planId.value = tab.props.name
|
planId.value = tab.props.name
|
||||||
@@ -418,7 +435,59 @@ const findItemById = (data: any[], id: string): any => {
|
|||||||
return null; // 未找到匹配项
|
return null; // 未找到匹配项
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//子计划下移除被检设备
|
||||||
|
const subHandleRemove = async (row: any) => {
|
||||||
|
ElMessageBox.confirm(`确定要移除计划【${row.name}】吗?`, '提示', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning'
|
||||||
|
}).then(async () => {
|
||||||
|
if(row.checkState != 0){
|
||||||
|
ElMessage.warning(`当前设备已检,无法移除!`);
|
||||||
|
return
|
||||||
|
}
|
||||||
|
await subPlanBindDev({'planId': row.planId, 'devIds': [row.id] ,'bindFlag': 0}) //解绑 0 绑定 1
|
||||||
|
ElMessage.success('移除成功');
|
||||||
|
proTable.value?.getTableList(); // 刷新当前表格
|
||||||
|
}).catch(() => {
|
||||||
|
// 用户取消操作
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 子计划下批量移除被检设备
|
||||||
|
const subBatchRemove = async (selectedListIds: string[]) => {
|
||||||
|
|
||||||
|
|
||||||
|
const selectedDevices = planTabDevList.value.data.records.filter((dev: { id: any }) =>
|
||||||
|
selectedListIds.includes(dev.id)
|
||||||
|
);
|
||||||
|
|
||||||
|
const invalidDevices = selectedDevices.filter(
|
||||||
|
(dev: { checkState: number }) => dev.checkState !== 0
|
||||||
|
);
|
||||||
|
|
||||||
|
if (invalidDevices.length > 0) {
|
||||||
|
const names = invalidDevices.map((dev: { name: any }) => dev.name).join('、');
|
||||||
|
ElMessage.warning(`以下设备不可移除(已检):${names}`);
|
||||||
|
proTable.value?.clearSelection();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
await ElMessageBox.confirm(`确定要批量移除选中的 ${selectedListIds.length} 个设备吗?`, '提示', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning'
|
||||||
|
});
|
||||||
|
|
||||||
|
await subPlanBindDev({ planId: planId.value, devIds: selectedListIds, bindFlag: 0 });
|
||||||
|
ElMessage.success('批量移除成功');
|
||||||
|
proTable.value?.getTableList(); // 刷新表格
|
||||||
|
} catch (error) {
|
||||||
|
// 用户取消或接口异常
|
||||||
|
console.error('批量移除失败:', error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
defineExpose({ open,handleTableDataUpdate })
|
defineExpose({ open,handleTableDataUpdate })
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
<template>
|
<template>
|
||||||
<!-- 权限信息弹出框 -->
|
<!-- 权限信息弹出框 -->
|
||||||
<el-dialog title="设备绑定" v-model='dialogVisible' @close="close" v-bind="dialogBig" width="600" draggable>
|
<el-dialog title="标准设备绑定" v-model='dialogVisible' @close="close" v-bind="dialogBig" width="600" draggable>
|
||||||
<div>
|
<div>
|
||||||
<el-transfer v-model="value"
|
<el-transfer v-model="value"
|
||||||
filterable
|
filterable
|
||||||
:filter-method="filterMethod"
|
:filter-method="filterMethod"
|
||||||
filter-placeholder="请输入内容搜索"
|
filter-placeholder="请输入内容搜索"
|
||||||
:data="allData"
|
:data="allData"
|
||||||
:titles="['未绑定设备', '已绑定设备']">
|
:titles="['未绑定标准设备', '已绑定标准设备']">
|
||||||
<template #default="{ option }">
|
<template #default="{ option }">
|
||||||
<el-tooltip :content="option.tips" placement="top" :show-after=1000>
|
<el-tooltip :content="option.tips" placement="top" :show-after=1000>
|
||||||
<span>{{ option.label }}</span>
|
<span>{{ option.label }}</span>
|
||||||
@@ -31,13 +31,13 @@
|
|||||||
import { computed, ref } from 'vue'
|
import { computed, ref } from 'vue'
|
||||||
import type { StandardDevice } from '@/api/device/interface/standardDevice'
|
import type { StandardDevice } from '@/api/device/interface/standardDevice'
|
||||||
import { dialogBig } from '@/utils/elementBind'
|
import { dialogBig } from '@/utils/elementBind'
|
||||||
import { getBoundStandardDevList,getUnboundStandardDevList } from '@/api/plan/plan.ts'
|
import { getBoundStandardDevList,getUnboundStandardDevList,subPlanBindStandardDevList } from '@/api/plan/plan.ts'
|
||||||
import { type Plan } from '@/api/plan/interface'
|
import { type Plan } from '@/api/plan/interface'
|
||||||
import { ElMessage } from 'element-plus'
|
import { ElMessage } from 'element-plus'
|
||||||
const unboundStandardDevList=ref<StandardDevice.ResPqStandardDevice[]>([])//指定模式下所有未绑定的标准设备
|
const unboundStandardDevList=ref<StandardDevice.ResPqStandardDevice[]>([])//指定模式下所有未绑定的标准设备
|
||||||
const boundStandardDevList=ref<StandardDevice.ResPqStandardDevice[]>([])//根据检测计划id查询出所有已绑定的标准设备
|
const boundStandardDevList=ref<StandardDevice.ResPqStandardDevice[]>([])//根据检测计划id查询出所有已绑定的标准设备
|
||||||
const dialogVisible = ref(false)
|
const dialogVisible = ref(false)
|
||||||
const planData = ref<Plan.ResPlan | null>(null) // 新增状态管理
|
const planData = ref<Plan.ReqPlan | null>(null) // 新增状态管理
|
||||||
|
|
||||||
const value = ref<string[]>([])
|
const value = ref<string[]>([])
|
||||||
const generateData = () => {
|
const generateData = () => {
|
||||||
@@ -62,7 +62,7 @@ const filterMethod = (query: string, item: { label?: string }) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 打开弹窗,可能是新增,也可能是编辑
|
// 打开弹窗,可能是新增,也可能是编辑
|
||||||
const open = async (data: Plan.ResPlan) => {
|
const open = async (data: Plan.ReqPlan) => {
|
||||||
dialogVisible.value = true
|
dialogVisible.value = true
|
||||||
planData.value = data
|
planData.value = data
|
||||||
console.log('planData.value',planData.value)
|
console.log('planData.value',planData.value)
|
||||||
@@ -71,14 +71,23 @@ const filterMethod = (query: string, item: { label?: string }) => {
|
|||||||
|
|
||||||
const standardDevList_Result2 = await getBoundStandardDevList(data);
|
const standardDevList_Result2 = await getBoundStandardDevList(data);
|
||||||
boundStandardDevList.value = standardDevList_Result2.data as StandardDevice.ResPqStandardDevice[];
|
boundStandardDevList.value = standardDevList_Result2.data as StandardDevice.ResPqStandardDevice[];
|
||||||
|
|
||||||
|
value.value = boundStandardDevList.value.map((i: { id: { toString: () => any } }) => i.id.toString());
|
||||||
|
|
||||||
}
|
}
|
||||||
const close = () => {
|
const close = () => {
|
||||||
dialogVisible.value = false
|
dialogVisible.value = false
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const emit = defineEmits(['update:table'])
|
||||||
|
|
||||||
const save = async () => {
|
const save = async () => {
|
||||||
if (planData.value) {
|
if (planData.value) {
|
||||||
|
planData.value.planId = planData.value.id
|
||||||
|
planData.value.devIds = value.value
|
||||||
|
await subPlanBindStandardDevList(planData.value)
|
||||||
|
emit('update:table')
|
||||||
ElMessage.success({ message: `标准设备绑定保存成功!` })
|
ElMessage.success({ message: `标准设备绑定保存成功!` })
|
||||||
}
|
}
|
||||||
dialogVisible.value = false
|
dialogVisible.value = false
|
||||||
|
|||||||
@@ -8,13 +8,14 @@
|
|||||||
<el-form-item label="名称" prop="name" :label-width="110" >
|
<el-form-item label="名称" prop="name" :label-width="110" >
|
||||||
<el-input v-model="formContent.name" placeholder="请输入名称" autocomplete="off" maxlength="32" show-word-limit/>
|
<el-input v-model="formContent.name" placeholder="请输入名称" autocomplete="off" maxlength="32" show-word-limit/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label='标准设备' prop='standardDevIdList' :label-width='110' v-if="selectByMode && planType == 0" >
|
<el-form-item label='标准设备' prop='standardDevIds' :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-select v-model="formContent.standardDevIds" multiple collapse-tags :max-collapse-tags="2" :disabled="planType != 0" placeholder="请选择标准设备" clearable>
|
||||||
<el-option
|
<el-option
|
||||||
v-for="option in pqStandardDevArray"
|
v-for="option in pqStandardDevArray"
|
||||||
:key="option.value"
|
:key="option.value"
|
||||||
:label="option.label"
|
:label="option.label"
|
||||||
:value="option.value"
|
:value="option.value"
|
||||||
|
:disabled="subPlanBindStandardDev.includes(option.label)"
|
||||||
/>
|
/>
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
@@ -113,7 +114,7 @@
|
|||||||
:filter-method="filterMethod"
|
:filter-method="filterMethod"
|
||||||
filter-placeholder="请输入内容搜索"
|
filter-placeholder="请输入内容搜索"
|
||||||
:data="allData"
|
:data="allData"
|
||||||
:titles="['未绑定设备', '已绑定设备']">
|
:titles="['未绑定被检设备', '已绑定被检设备']">
|
||||||
<template #default="{ option }">
|
<template #default="{ option }">
|
||||||
<span>{{ option.label }}</span>
|
<span>{{ option.label }}</span>
|
||||||
</template>
|
</template>
|
||||||
@@ -179,7 +180,7 @@
|
|||||||
const allData = computed(() => generateData())
|
const allData = computed(() => generateData())
|
||||||
const isSelectDisabled = ref(false)
|
const isSelectDisabled = ref(false)
|
||||||
const planType = ref<number>(0)
|
const planType = ref<number>(0)
|
||||||
|
const subPlanBindStandardDev = ref<any>([])//哪些标准设备已经被子计划绑定
|
||||||
|
|
||||||
const generateData = () => {
|
const generateData = () => {
|
||||||
const unboundData = unboundPqDevList.value.map((i: Device.ResPqDev) => ({
|
const unboundData = unboundPqDevList.value.map((i: Device.ResPqDev) => ({
|
||||||
@@ -230,7 +231,7 @@ const filterMethod = (query: string, item: { label?: string }) => {
|
|||||||
dataRule:'',
|
dataRule:'',
|
||||||
standardDevNameStr:'',
|
standardDevNameStr:'',
|
||||||
testItemNameStr:'',
|
testItemNameStr:'',
|
||||||
standardDevIdList:[],
|
standardDevIds:[],
|
||||||
standardDevMap:new Map<string, number>(),
|
standardDevMap:new Map<string, number>(),
|
||||||
testItems:[],
|
testItems:[],
|
||||||
Check_By:'',
|
Check_By:'',
|
||||||
@@ -269,7 +270,7 @@ const filterMethod = (query: string, item: { label?: string }) => {
|
|||||||
reportTemplateVersion:'',
|
reportTemplateVersion:'',
|
||||||
dataRule:'',
|
dataRule:'',
|
||||||
standardDevNameStr:'',
|
standardDevNameStr:'',
|
||||||
standardDevIdList:[],
|
standardDevIds:[],
|
||||||
standardDevMap:new Map<string, number>(),
|
standardDevMap:new Map<string, number>(),
|
||||||
testItemNameStr:'',
|
testItemNameStr:'',
|
||||||
testItems:[],
|
testItems:[],
|
||||||
@@ -297,7 +298,7 @@ const baseRules: Record<string, Array<FormItemRule>> = {
|
|||||||
scriptId: [{ required: true, message: '检测脚本必选!', trigger: 'change' }],
|
scriptId: [{ required: true, message: '检测脚本必选!', trigger: 'change' }],
|
||||||
errorSysId: [{ required: true, message: '误差体系必选!', trigger: 'change' }],
|
errorSysId: [{ required: true, message: '误差体系必选!', trigger: 'change' }],
|
||||||
dataRule: [{ required: true, message: '数据处理原则必选!', trigger: 'change' }],
|
dataRule: [{ required: true, message: '数据处理原则必选!', trigger: 'change' }],
|
||||||
standardDevIdList: [{ required: true, message: '标准设备必选!', trigger: 'change' }],
|
standardDevIds: [{ required: true, message: '标准设备必选!', trigger: 'change' }],
|
||||||
testItems: [{ required: true, message: '测试项必选!', trigger: 'change' }],
|
testItems: [{ required: true, message: '测试项必选!', trigger: 'change' }],
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -344,7 +345,7 @@ const rules = computed(() => {
|
|||||||
formContent.fatherPlanId = formContent.id;
|
formContent.fatherPlanId = formContent.id;
|
||||||
formContent.id = '';
|
formContent.id = '';
|
||||||
formContent.devIds = []
|
formContent.devIds = []
|
||||||
formContent.standardDevIdList = []
|
formContent.standardDevIds = []
|
||||||
formContent.standardDevMap = new Map<string, number>();
|
formContent.standardDevMap = new Map<string, number>();
|
||||||
await addPlan(formContent)
|
await addPlan(formContent)
|
||||||
emit('update:tab')
|
emit('update:tab')
|
||||||
@@ -355,6 +356,7 @@ const rules = computed(() => {
|
|||||||
console.log('更新子计划',formContent)
|
console.log('更新子计划',formContent)
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
formContent.sourceIds = null
|
||||||
await updatePlan(formContent)
|
await updatePlan(formContent)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -375,7 +377,7 @@ const rules = computed(() => {
|
|||||||
formContent.dataRule = patternItem2.id;
|
formContent.dataRule = patternItem2.id;
|
||||||
}
|
}
|
||||||
if( mode.value === '比对式'){
|
if( mode.value === '比对式'){
|
||||||
formContent.sourceIds = null;
|
formContent.sourceIds = null
|
||||||
await addPlan(formContent);
|
await addPlan(formContent);
|
||||||
}else{
|
}else{
|
||||||
await addPlan({...formContent,'sourceIds':[formContent.sourceIds],'datasourceIds':[formContent.datasourceIds]});
|
await addPlan({...formContent,'sourceIds':[formContent.sourceIds],'datasourceIds':[formContent.datasourceIds]});
|
||||||
@@ -407,6 +409,7 @@ const open = async (sign: string, data: Plan.ReqPlan,currentMode: string,plan:nu
|
|||||||
titleType.value = sign
|
titleType.value = sign
|
||||||
isSelectDisabled.value = false
|
isSelectDisabled.value = false
|
||||||
planType.value = plan
|
planType.value = plan
|
||||||
|
console.log('planType.value',planType.value)
|
||||||
//比对式测试项下拉框
|
//比对式测试项下拉框
|
||||||
if(mode.value == '比对式'){
|
if(mode.value == '比对式'){
|
||||||
const dictCode = 'Script_Error';
|
const dictCode = 'Script_Error';
|
||||||
@@ -511,6 +514,19 @@ const open = async (sign: string, data: Plan.ReqPlan,currentMode: string,plan:nu
|
|||||||
// 比对式下这两个接口不需要
|
// 比对式下这两个接口不需要
|
||||||
pqSource_Result = { data: [] };
|
pqSource_Result = { data: [] };
|
||||||
PqScript_Result = { data: [] };
|
PqScript_Result = { data: [] };
|
||||||
|
|
||||||
|
//编辑时,把标准设备map赋值给数组
|
||||||
|
formContent.standardDevIds = Object.keys(formContent.standardDevMap)
|
||||||
|
//哪些标准设备已经被子计划绑定
|
||||||
|
subPlanBindStandardDev.value = Object.entries(formContent.standardDevMap)
|
||||||
|
.filter(([key, value]) => value === 1)
|
||||||
|
.map(([key]) => {
|
||||||
|
const matched = pqStandardDev_Result.data?.find(
|
||||||
|
(item: StandardDevice.ResPqStandardDevice) => item.id === key
|
||||||
|
);
|
||||||
|
return matched ? matched.name : key;
|
||||||
|
});
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
const commonResults = await Promise.all([
|
const commonResults = await Promise.all([
|
||||||
getTestSourceList(data),
|
getTestSourceList(data),
|
||||||
@@ -622,12 +638,11 @@ function pqToArray() {
|
|||||||
}))
|
}))
|
||||||
|
|
||||||
const sourceArray5 = Array.isArray(pqStandardDevList.value) ? pqStandardDevList.value : []
|
const sourceArray5 = Array.isArray(pqStandardDevList.value) ? pqStandardDevList.value : []
|
||||||
console.log('5',sourceArray5)
|
|
||||||
pqStandardDevArray.value = sourceArray5.map(item => ({
|
pqStandardDevArray.value = sourceArray5.map(item => ({
|
||||||
label: item.name,
|
label: item.name,
|
||||||
value: item.id
|
value: item.id
|
||||||
}))
|
}))
|
||||||
console.log('25',pqStandardDevArray.value)
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -56,7 +56,6 @@
|
|||||||
<ImportExcel ref='planImportExcel'/>
|
<ImportExcel ref='planImportExcel'/>
|
||||||
|
|
||||||
<ChildrenPlan :refresh-table='refreshTable' ref='childrenPlanView' :width='viewWidth' :height='viewHeight'></ChildrenPlan>
|
<ChildrenPlan :refresh-table='refreshTable' ref='childrenPlanView' :width='viewWidth' :height='viewHeight'></ChildrenPlan>
|
||||||
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang='tsx' name='useProTable'>
|
<script setup lang='tsx' name='useProTable'>
|
||||||
@@ -108,6 +107,8 @@ const currentPage = ref(1)
|
|||||||
const pageSize = ref(10)
|
const pageSize = ref(10)
|
||||||
const currentPageData = ref<any[]>([])//当前页的数据
|
const currentPageData = ref<any[]>([])//当前页的数据
|
||||||
const patternId = ref('')
|
const patternId = ref('')
|
||||||
|
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
refreshTable()
|
refreshTable()
|
||||||
|
|
||||||
@@ -200,6 +201,7 @@ function buildTree(flatList: any[]): any[] {
|
|||||||
return tree;
|
return tree;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const handleSizeChange = (size: number) => {
|
const handleSizeChange = (size: number) => {
|
||||||
pageSize.value = size
|
pageSize.value = size
|
||||||
updateCurrentPageData()
|
updateCurrentPageData()
|
||||||
@@ -472,9 +474,7 @@ const importClick = () => {
|
|||||||
}
|
}
|
||||||
// 点击导出按钮
|
// 点击导出按钮
|
||||||
const exportClick = () => {
|
const exportClick = () => {
|
||||||
|
|
||||||
ElMessageBox.confirm('确认导出检测计划?', '温馨提示', { type: 'warning' }).then(() =>{
|
ElMessageBox.confirm('确认导出检测计划?', '温馨提示', { type: 'warning' }).then(() =>{
|
||||||
const patternId = dictStore.getDictData('Pattern').find(item=>item.name=== modeStore.currentMode)?.id//获取数据字典中对应的id
|
|
||||||
useDownload(exportPlan,'检测计划导出数据', {...proTable.value?.searchParam,patternId:patternId}, false,'.xlsx')
|
useDownload(exportPlan,'检测计划导出数据', {...proTable.value?.searchParam,patternId:patternId}, false,'.xlsx')
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -500,7 +500,7 @@ const handleDelete = async (params: Plan.ReqPlanParams) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const openChildrenPlan = (row: Partial<Plan.ReqPlan> = {}) => {
|
const openChildrenPlan = (row: Partial<Plan.ReqPlan> = {}) => {
|
||||||
childrenPlanView.value.open("检测计划详情",row)
|
childrenPlanView.value.open("检测计划详情",row,patternId.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user