UPDATE:1.完善主计划导入被检设备逻辑;2.完善新增编辑子计划逻辑。
This commit is contained in:
@@ -2,54 +2,53 @@ import type { Plan } from './interface'
|
||||
import http from '@/api'
|
||||
import type { ErrorSystem } from '../device/interface/error'
|
||||
import type { Device } from '../device/interface/device'
|
||||
import { pa } from 'element-plus/es/locale/index.mjs'
|
||||
|
||||
/**
|
||||
* @name 检测计划管理模块
|
||||
*/
|
||||
// 获取检测计划列表
|
||||
export const getPlanList = (params: Plan.ReqPlanParams) => {
|
||||
return http.post(`/adPlan/list`, params)
|
||||
return http.post(`/adPlan/list`, params)
|
||||
}
|
||||
|
||||
// 新增检测计划
|
||||
export const addPlan = (params: any) => {
|
||||
return http.post(`/adPlan/add`, params)
|
||||
return http.post(`/adPlan/add`, params)
|
||||
}
|
||||
|
||||
// 编辑检测计划
|
||||
export const updatePlan = (params: any) => {
|
||||
return http.post(`/adPlan/update`, params)
|
||||
return http.post(`/adPlan/update`, params)
|
||||
}
|
||||
|
||||
// 删除检测计划
|
||||
export const deletePlan = (params: { id: string[] ,pattern: string}) => {
|
||||
return http.post(`/adPlan/delete?pattern=${params.pattern}`, params.id)
|
||||
export const deletePlan = (params: { id: string[]; pattern: string }) => {
|
||||
return http.post(`/adPlan/delete?pattern=${params.pattern}`, params.id)
|
||||
}
|
||||
|
||||
// 获取指定模式下所有检测源
|
||||
// 获取指定模式下所有检测源
|
||||
export const getTestSourceList = (params: Plan.ReqPlan) => {
|
||||
return http.get(`/pqSource/getAll?patternId=${params.pattern}`)
|
||||
return http.get(`/pqSource/getAll?patternId=${params.pattern}`)
|
||||
}
|
||||
|
||||
// 获取指定模式下所有检测脚本
|
||||
export const getPqScriptList = (params: Plan.ReqPlan) => {
|
||||
return http.get(`/pqScript/getAll?patternId=${params.pattern}`)
|
||||
return http.get(`/pqScript/getAll?patternId=${params.pattern}`)
|
||||
}
|
||||
|
||||
//获取所有误差体系
|
||||
export const getPqErrSysList = () => {
|
||||
return http.get<ErrorSystem.ErrorSystemList>(`/pqErrSys/getAll`)
|
||||
return http.get<ErrorSystem.ErrorSystemList>(`/pqErrSys/getAll`)
|
||||
}
|
||||
|
||||
//获取指定模式下所有未绑定的设备
|
||||
export const getUnboundPqDevList = (params: Plan.ReqPlan) => {
|
||||
return http.get(`/pqDev/listUnbound?pattern=${params.pattern}`)
|
||||
return http.get(`/pqDev/listUnbound?pattern=${params.pattern}`)
|
||||
}
|
||||
|
||||
//根据检测计划id查询出所有已绑定的设备
|
||||
export const getBoundPqDevList = (params: any) => {
|
||||
return http.post(`/adPlan/listByPlanId`, params)
|
||||
return http.post(`/adPlan/listByPlanId`, params)
|
||||
}
|
||||
|
||||
//检测计划绑定设备
|
||||
@@ -59,63 +58,68 @@ export const getBoundPqDevList = (params: any) => {
|
||||
|
||||
// 按照模式查询检测计划(用于首页展示)
|
||||
export const getPlanListByPattern = (params: Plan.ReqPlan) => {
|
||||
return http.get(`/adPlan/listByPattern?pattern=${params.pattern}`)
|
||||
return http.get(`/adPlan/listByPattern?pattern=${params.pattern}`)
|
||||
}
|
||||
|
||||
// 导出检测计划
|
||||
export const exportPlan = (params: Device.ReqPqDevParams) => {
|
||||
return http.download(`/adPlan/export`, params)
|
||||
return http.download(`/adPlan/export`, params)
|
||||
}
|
||||
|
||||
// 下载模板
|
||||
export const downloadTemplate = (params: { patternId: string }) => {
|
||||
return http.download(`/adPlan/downloadTemplate`, params)
|
||||
return http.download(`/adPlan/downloadTemplate`, params)
|
||||
}
|
||||
// 导入检测计划
|
||||
export const importPlan = (params: Device.ReqPqDevParams) => {
|
||||
return http.uploadExcel(`/adPlan/import`, params)
|
||||
return http.uploadExcel(`/adPlan/import`, params)
|
||||
}
|
||||
|
||||
// 装置检测报告生成
|
||||
export const generateDevReport = (params: Device.ReqDevReportParams) => {
|
||||
return http.post(`/report/generateReport`, params)
|
||||
return http.post(`/report/generateReport`, params)
|
||||
}
|
||||
|
||||
// 装置检测报告下载
|
||||
export const downloadDevData = (params: Device.ReqDevReportParams) => {
|
||||
return http.download(`/report/downloadReport`, params)
|
||||
return http.download(`/report/downloadReport`, params)
|
||||
}
|
||||
|
||||
export const staticsAnalyse = (params: { id: string[] }) => {
|
||||
return http.download('/adPlan/analyse', params)
|
||||
return http.download('/adPlan/analyse', params)
|
||||
}
|
||||
|
||||
//根据计划id分页查询被检设
|
||||
export const getDevListByPlanId = (params:any) => {
|
||||
return http.post(`/adPlan/listDevByPlanId`, params)
|
||||
export const getDevListByPlanId = (params: any) => {
|
||||
return http.post(`/adPlan/listDevByPlanId`, params)
|
||||
}
|
||||
|
||||
//修改子计划名称
|
||||
export const updateSubPlanName = (params:Plan.ReqPlan) => {
|
||||
return http.get(`/adPlan/updateSubPlanName?planId=${params.id}&name=${params.name}`)
|
||||
export const updateSubPlanName = (params: Plan.ReqPlan) => {
|
||||
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 subPlanBindStandardDevList = (params: Plan.ReqPlan) => {
|
||||
return http.post(`/adPlan/updateBindStandardDev`, params)
|
||||
}
|
||||
|
||||
//子计划绑定/解绑被检设备
|
||||
export const subPlanBindDev = (params:Plan.ReqPlan) => {
|
||||
return http.post(`/adPlan/updateBindDev`, params)
|
||||
export const subPlanBindDev = (params: Plan.ReqPlan) => {
|
||||
return http.post(`/adPlan/updateBindDev`, params)
|
||||
}
|
||||
|
||||
//根据父计划ID获取未被子计划绑定的标准设备
|
||||
export const getUnboundStandardDevList = (params:Plan.ResPlan) => {
|
||||
return http.get(`/adPlan/getUnBoundStandardDev?fatherPlanId=${params.fatherPlanId}`)
|
||||
export const getUnboundStandardDevList = (params: Plan.ResPlan) => {
|
||||
return http.get(`/adPlan/getUnBoundStandardDev?fatherPlanId=${params.fatherPlanId}`)
|
||||
}
|
||||
|
||||
//根据计划ID获取已绑定的标准设备
|
||||
export const getBoundStandardDevList = (params:Plan.ResPlan) => {
|
||||
return http.get(`/adPlan/getBoundStandardDev?planId=${params.id}`)
|
||||
export const getBoundStandardDevList = (params: Plan.ResPlan) => {
|
||||
return http.get(`/adPlan/getBoundStandardDev?planId=${params.id}`)
|
||||
}
|
||||
|
||||
//根据计划ID获取已绑定的所有标准设备
|
||||
export const getBoundStandardDevAllList = (params: Plan.ResPlan) => {
|
||||
return http.get(`/adPlan/getBoundStandardDev?planId=${params.id}&all=1`)
|
||||
}
|
||||
@@ -1,59 +1,69 @@
|
||||
<template>
|
||||
<el-dialog v-model='dialogVisible' :title='`批量添加${parameter.title}`' :destroy-on-close='true' width='580px'
|
||||
draggable>
|
||||
<el-form class='drawer-multiColumn-form' label-width='100px'>
|
||||
<el-form-item label='模板下载 :'>
|
||||
<el-button type='primary' :icon='Download' @click='downloadTemp'> 点击下载</el-button>
|
||||
</el-form-item>
|
||||
<el-form-item label='文件上传 :'>
|
||||
<el-upload
|
||||
action='#'
|
||||
class='upload'
|
||||
:drag='true'
|
||||
:limit='excelLimit'
|
||||
:multiple='true'
|
||||
:show-file-list='true'
|
||||
:http-request='uploadExcel'
|
||||
:before-upload='beforeExcelUpload'
|
||||
:on-exceed='handleExceed'
|
||||
:accept="parameter.fileType!.join(',')"
|
||||
>
|
||||
<slot name='empty'>
|
||||
<el-icon class='el-icon--upload'>
|
||||
<upload-filled />
|
||||
</el-icon>
|
||||
<div class='el-upload__text'>将文件拖到此处,或<em>点击上传</em></div>
|
||||
</slot>
|
||||
<template #tip>
|
||||
<slot name='tip'>
|
||||
<div class='el-upload__tip'>请上传 .xls , .xlsx 标准格式文件,文件最大为 {{ parameter.fileSize }}M</div>
|
||||
</slot>
|
||||
</template>
|
||||
</el-upload>
|
||||
</el-form-item>
|
||||
<el-form-item v-if='parameter.showCover' label='数据覆盖 :'>
|
||||
<el-switch v-model='isCover' />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-dialog>
|
||||
<el-dialog
|
||||
v-model="dialogVisible"
|
||||
:title="`批量添加${parameter.title}`"
|
||||
:destroy-on-close="true"
|
||||
width="580px"
|
||||
draggable
|
||||
>
|
||||
<el-form class="drawer-multiColumn-form" label-width="100px">
|
||||
<el-form-item label="模板下载 :">
|
||||
<el-button type="primary" :icon="Download" @click="downloadTemp">点击下载</el-button>
|
||||
</el-form-item>
|
||||
<el-form-item label="文件上传 :">
|
||||
<el-upload
|
||||
action="#"
|
||||
class="upload"
|
||||
:drag="true"
|
||||
:limit="excelLimit"
|
||||
:multiple="true"
|
||||
:show-file-list="true"
|
||||
:http-request="uploadExcel"
|
||||
:before-upload="beforeExcelUpload"
|
||||
:on-exceed="handleExceed"
|
||||
:accept="parameter.fileType!.join(',')"
|
||||
>
|
||||
<slot name="empty">
|
||||
<el-icon class="el-icon--upload">
|
||||
<upload-filled />
|
||||
</el-icon>
|
||||
<div class="el-upload__text">
|
||||
将文件拖到此处,或
|
||||
<em>点击上传</em>
|
||||
</div>
|
||||
</slot>
|
||||
<template #tip>
|
||||
<slot name="tip">
|
||||
<div class="el-upload__tip">
|
||||
请上传 .xls , .xlsx 标准格式文件,文件最大为 {{ parameter.fileSize }}M
|
||||
</div>
|
||||
</slot>
|
||||
</template>
|
||||
</el-upload>
|
||||
</el-form-item>
|
||||
<el-form-item v-if="parameter.showCover" label="数据覆盖 :">
|
||||
<el-switch v-model="isCover" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup lang='ts' name='ImportExcel'>
|
||||
<script setup lang="ts" name="ImportExcel">
|
||||
import { ref } from 'vue'
|
||||
import { useDownload } from '@/hooks/useDownload'
|
||||
import { Download } from '@element-plus/icons-vue'
|
||||
import { ElNotification, UploadRequestOptions, UploadRawFile, ElMessage } from 'element-plus'
|
||||
import { ElMessage, ElNotification, UploadRawFile, UploadRequestOptions } from 'element-plus'
|
||||
|
||||
export interface ExcelParameterProps {
|
||||
title: string; // 标题
|
||||
showCover?: boolean; // 是否显示”数据覆盖“选项
|
||||
patternId?: string; // 模式ID
|
||||
planId?: string | null ;//计划ID
|
||||
fileSize?: number; // 上传文件的大小
|
||||
fileType?: File.ExcelMimeType[]; // 上传文件的类型
|
||||
tempApi?: (params: any) => Promise<any>; // 下载模板的Api
|
||||
importApi?: (params: any) => Promise<any>; // 批量导入的Api
|
||||
getTableList?: () => void; // 获取表格数据的Api
|
||||
title: string // 标题
|
||||
showCover?: boolean // 是否显示”数据覆盖“选项
|
||||
patternId?: string // 模式ID
|
||||
planId?: string | null //计划ID
|
||||
fileSize?: number // 上传文件的大小
|
||||
fileType?: File.ExcelMimeType[] // 上传文件的类型
|
||||
tempApi?: (params: any) => Promise<any> // 下载模板的Api
|
||||
importApi?: (params: any) => Promise<any> // 批量导入的Api
|
||||
getTableList?: () => void // 获取表格数据的Api
|
||||
}
|
||||
|
||||
// 是否覆盖数据
|
||||
@@ -64,71 +74,73 @@ const excelLimit = ref(1)
|
||||
const dialogVisible = ref(false)
|
||||
// 父组件传过来的参数
|
||||
const parameter = ref<ExcelParameterProps>({
|
||||
title: '',
|
||||
fileSize: 5,
|
||||
fileType: ['application/vnd.ms-excel', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'],
|
||||
title: '',
|
||||
fileSize: 5,
|
||||
fileType: ['application/vnd.ms-excel', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']
|
||||
})
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'result', data: boolean): void
|
||||
}>()
|
||||
// 接收父组件参数
|
||||
const acceptParams = (params: ExcelParameterProps) => {
|
||||
parameter.value = { ...parameter.value, ...params }
|
||||
dialogVisible.value = true
|
||||
parameter.value = { ...parameter.value, ...params }
|
||||
dialogVisible.value = true
|
||||
}
|
||||
|
||||
// Excel 导入模板下载
|
||||
const downloadTemp = () => {
|
||||
if (!parameter.value.tempApi) return
|
||||
useDownload(parameter.value.tempApi, `${parameter.value.title}模板`, {'pattern':parameter.value.patternId}, false)
|
||||
if (!parameter.value.tempApi) return
|
||||
useDownload(parameter.value.tempApi, `${parameter.value.title}模板`, { pattern: parameter.value.patternId }, false)
|
||||
}
|
||||
|
||||
// 文件上传
|
||||
const uploadExcel = async (param: UploadRequestOptions) => {
|
||||
let excelFormData = new FormData()
|
||||
excelFormData.append('file', param.file)
|
||||
if (parameter.value.patternId) {
|
||||
excelFormData.append('patternId', parameter.value.patternId)
|
||||
}
|
||||
let excelFormData = new FormData()
|
||||
excelFormData.append('file', param.file)
|
||||
if (parameter.value.patternId) {
|
||||
excelFormData.append('patternId', parameter.value.patternId)
|
||||
}
|
||||
|
||||
excelFormData.append('planId', parameter.value.planId)
|
||||
|
||||
isCover.value && excelFormData.append('isCover', isCover.value as unknown as Blob)
|
||||
//await parameter.value.importApi!(excelFormData);
|
||||
await parameter.value.importApi!(excelFormData)
|
||||
.then(res => handleImportResponse(res))
|
||||
parameter.value.getTableList && parameter.value.getTableList()
|
||||
dialogVisible.value = false
|
||||
excelFormData.append('planId', parameter.value.planId)
|
||||
|
||||
isCover.value && excelFormData.append('isCover', isCover.value as unknown as Blob)
|
||||
//await parameter.value.importApi!(excelFormData);
|
||||
await parameter.value.importApi!(excelFormData).then(res => handleImportResponse(res))
|
||||
parameter.value.getTableList && parameter.value.getTableList()
|
||||
dialogVisible.value = false
|
||||
}
|
||||
|
||||
|
||||
async function handleImportResponse(res: any) {
|
||||
console.log(res)
|
||||
console.log(res)
|
||||
|
||||
if (res.type === 'application/json') {
|
||||
const fileReader = new FileReader()
|
||||
fileReader.onloadend = () => {
|
||||
try {
|
||||
const jsonData = JSON.parse(fileReader.result)
|
||||
if (jsonData.code === 'A0000') {
|
||||
ElMessage.success('导入成功')
|
||||
} else {
|
||||
ElMessage.error(jsonData.message)
|
||||
if (res.type === 'application/json') {
|
||||
const fileReader = new FileReader()
|
||||
fileReader.onloadend = () => {
|
||||
try {
|
||||
const jsonData = JSON.parse(fileReader.result)
|
||||
if (jsonData.code === 'A0000') {
|
||||
ElMessage.success('导入成功')
|
||||
} else {
|
||||
ElMessage.error(jsonData.message)
|
||||
}
|
||||
emit('result', jsonData.data)
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
}
|
||||
fileReader.readAsText(res)
|
||||
} else {
|
||||
emit('result', false)
|
||||
ElMessage.error('导入失败,请查看下载附件!')
|
||||
let blob = new Blob([res], { type: 'application/vnd.ms-excel' })
|
||||
const url = window.URL.createObjectURL(blob)
|
||||
const link = document.createElement('a')
|
||||
link.href = url
|
||||
link.download = '导入失败数据'
|
||||
document.body.appendChild(link)
|
||||
link.click()
|
||||
link.remove()
|
||||
}
|
||||
fileReader.readAsText(res)
|
||||
} else {
|
||||
ElMessage.error('导入失败,请查看下载附件!')
|
||||
let blob = new Blob([res], { type: 'application/vnd.ms-excel' })
|
||||
const url = window.URL.createObjectURL(blob)
|
||||
const link = document.createElement('a')
|
||||
link.href = url
|
||||
link.download = '导入失败数据'
|
||||
document.body.appendChild(link)
|
||||
link.click()
|
||||
link.remove()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -136,32 +148,32 @@ async function handleImportResponse(res: any) {
|
||||
* @param file 上传的文件
|
||||
* */
|
||||
const beforeExcelUpload = (file: UploadRawFile) => {
|
||||
const isExcel = parameter.value.fileType!.includes(file.type as File.ExcelMimeType)
|
||||
const fileSize = file.size / 1024 / 1024 < parameter.value.fileSize!
|
||||
if (!isExcel)
|
||||
ElNotification({
|
||||
title: '温馨提示',
|
||||
message: '上传文件只能是 xls / xlsx 格式!',
|
||||
type: 'warning',
|
||||
})
|
||||
if (!fileSize)
|
||||
setTimeout(() => {
|
||||
ElNotification({
|
||||
title: '温馨提示',
|
||||
message: `上传文件大小不能超过 ${parameter.value.fileSize}MB!`,
|
||||
type: 'warning',
|
||||
})
|
||||
}, 0)
|
||||
return isExcel && fileSize
|
||||
const isExcel = parameter.value.fileType!.includes(file.type as File.ExcelMimeType)
|
||||
const fileSize = file.size / 1024 / 1024 < parameter.value.fileSize!
|
||||
if (!isExcel)
|
||||
ElNotification({
|
||||
title: '温馨提示',
|
||||
message: '上传文件只能是 xls / xlsx 格式!',
|
||||
type: 'warning'
|
||||
})
|
||||
if (!fileSize)
|
||||
setTimeout(() => {
|
||||
ElNotification({
|
||||
title: '温馨提示',
|
||||
message: `上传文件大小不能超过 ${parameter.value.fileSize}MB!`,
|
||||
type: 'warning'
|
||||
})
|
||||
}, 0)
|
||||
return isExcel && fileSize
|
||||
}
|
||||
|
||||
// 文件数超出提示
|
||||
const handleExceed = () => {
|
||||
ElNotification({
|
||||
title: '温馨提示',
|
||||
message: '最多只能上传一个文件!',
|
||||
type: 'warning',
|
||||
})
|
||||
ElNotification({
|
||||
title: '温馨提示',
|
||||
message: '最多只能上传一个文件!',
|
||||
type: 'warning'
|
||||
})
|
||||
}
|
||||
|
||||
// 上传错误提示
|
||||
@@ -183,9 +195,9 @@ const handleExceed = () => {
|
||||
// }
|
||||
|
||||
defineExpose({
|
||||
acceptParams,
|
||||
acceptParams
|
||||
})
|
||||
</script>
|
||||
<style lang='scss' scoped>
|
||||
@import "./index.scss";
|
||||
<style lang="scss" scoped>
|
||||
@use './index.scss';
|
||||
</style>
|
||||
|
||||
@@ -1,122 +1,154 @@
|
||||
<!--单列-->
|
||||
<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"
|
||||
@close="handleClose"
|
||||
>
|
||||
<div
|
||||
class="table-box"
|
||||
:style="{ height: height - 64 + 'px', maxHeight: height - 64 + 'px', overflow: 'hidden' }"
|
||||
<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"
|
||||
@close="handleClose"
|
||||
>
|
||||
<el-tabs
|
||||
v-model="editableTabsValue"
|
||||
type="card"
|
||||
@tab-remove="removeTab"
|
||||
@tab-click="handleTabClick"
|
||||
<div
|
||||
class="table-box"
|
||||
:style="{ height: height - 64 + 'px', maxHeight: height - 64 + 'px', overflow: 'hidden' }"
|
||||
>
|
||||
<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-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" v-if="isTabPlanFather" @click="subBatchRemove(scope.selectedListIds)">
|
||||
批量移除
|
||||
</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)"
|
||||
<el-button
|
||||
type="danger"
|
||||
:icon="Delete"
|
||||
plain
|
||||
:disabled="!scope.isSelected"
|
||||
v-if="isTabPlanFather"
|
||||
@click="subBatchRemove(scope.selectedListIds)"
|
||||
>
|
||||
{{ 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)"
|
||||
批量移除
|
||||
</el-button>
|
||||
<el-dropdown
|
||||
v-if="planFormContent && planFormContent?.children.length > 0"
|
||||
trigger="hover"
|
||||
placement="right-start"
|
||||
:disabled="!scope.isSelected"
|
||||
>
|
||||
{{ child.name }}
|
||||
</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
<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
|
||||
v-if="planFormContent && planFormContent?.children.length > 0"
|
||||
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>
|
||||
</el-dropdown>
|
||||
</template>
|
||||
<!-- 表格操作 -->
|
||||
<template #operation="scope">
|
||||
<el-button type="primary" link :icon="Delete" v-if="!isTabPlanFather" :disabled="scope.row.checkState != 0" @click="handleRemove(scope.row)">删除</el-button>
|
||||
<el-button type="primary" link :icon="Delete" v-if="isTabPlanFather" @click="subHandleRemove(scope.row)">移除</el-button>
|
||||
</template>
|
||||
</ProTable>
|
||||
</div>
|
||||
</el-dialog>
|
||||
<!-- 向计划导入/导出设备对话框 -->
|
||||
<PlanPopup :refresh-table='proTable?.getTableList' ref='planPopup' @update:tab="addNewChildTab"/>
|
||||
<DevTransfer ref='devTransfer' @update:table="addNewChildTab"/>
|
||||
<!-- 表格操作 -->
|
||||
<template #operation="scope">
|
||||
<el-button
|
||||
type="primary"
|
||||
link
|
||||
:icon="Delete"
|
||||
v-if="!isTabPlanFather"
|
||||
:disabled="scope.row.checkState != 0"
|
||||
@click="handleRemove(scope.row)"
|
||||
>
|
||||
删除
|
||||
</el-button>
|
||||
<el-button
|
||||
type="primary"
|
||||
link
|
||||
:icon="Delete"
|
||||
v-if="isTabPlanFather"
|
||||
@click="subHandleRemove(scope.row)"
|
||||
>
|
||||
移除
|
||||
</el-button>
|
||||
</template>
|
||||
</ProTable>
|
||||
</div>
|
||||
</el-dialog>
|
||||
<!-- 向计划导入/导出设备对话框 -->
|
||||
<PlanPopup :refresh-table="proTable?.getTableList" ref="planPopup" @update:tab="addNewChildTab" />
|
||||
<DevTransfer ref="devTransfer" @update:table="addNewChildTab" />
|
||||
</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 { computed, reactive, ref } from 'vue'
|
||||
import { CirclePlus, Delete, ScaleToOriginal } 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 { useModeStore } from '@/stores/modules/mode' // 引入模式 store
|
||||
import { ColumnProps, ProTableInstance, SearchRenderScope } from '@/components/ProTable/interface'
|
||||
import {getDevListByPlanId ,subPlanBindDev,deletePlan} from '@/api/plan/plan'
|
||||
import { deletePlan, 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'
|
||||
import { useHandleData } from '@/hooks/useHandleData'
|
||||
import router from '@/routers'
|
||||
|
||||
|
||||
const dictStore = useDictStore()
|
||||
const planFormContent = ref<Plan.ReqPlan>()
|
||||
const planFormContent = ref<Plan.ReqPlan>()
|
||||
const proTable = ref<ProTableInstance>()
|
||||
const modeStore = useModeStore();
|
||||
const modeStore = useModeStore()
|
||||
const planPopup = ref()
|
||||
const devTransfer = ref()
|
||||
|
||||
@@ -133,230 +165,228 @@ const patternId = ref('')
|
||||
|
||||
const getTableList = async (params: any) => {
|
||||
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))
|
||||
newParams.pattern = patternId.value
|
||||
if(!isTabPlanFather.value)
|
||||
newParams.planId = planFormContent.value.id
|
||||
else
|
||||
newParams.planId = planId.value
|
||||
newParams.planIdList = [newParams.planId];
|
||||
if (!isTabPlanFather.value) newParams.planId = planFormContent.value.id
|
||||
else newParams.planId = planId.value
|
||||
newParams.planIdList = [newParams.planId]
|
||||
proTable.value?.clearSelection()
|
||||
planTabDevList.value = await getDevListByPlanId(newParams);
|
||||
return planTabDevList.value;
|
||||
planTabDevList.value = await getDevListByPlanId(newParams)
|
||||
return planTabDevList.value
|
||||
}
|
||||
|
||||
|
||||
const columns = reactive<ColumnProps<Device.ResPqDev>[]>([
|
||||
{ type: 'selection', fixed: 'left', width: 70,selectable: (row) => row.checkState == 0 },
|
||||
{ type: 'index', fixed: 'left', width: 70, label: '序号' },
|
||||
{
|
||||
{ type: 'selection', fixed: 'left', width: 70, selectable: row => row.checkState == 0 },
|
||||
{ type: 'index', fixed: 'left', width: 70, label: '序号' },
|
||||
{
|
||||
prop: 'name',
|
||||
label: '名称',
|
||||
search: { el: 'input' },
|
||||
minWidth: 180,
|
||||
},
|
||||
{
|
||||
minWidth: 180
|
||||
},
|
||||
{
|
||||
prop: 'devType',
|
||||
label: '设备类型',
|
||||
minWidth: 150,
|
||||
},
|
||||
{
|
||||
minWidth: 150
|
||||
},
|
||||
{
|
||||
prop: 'createDate',
|
||||
label: '出厂日期',
|
||||
minWidth: 150,
|
||||
},
|
||||
{
|
||||
minWidth: 150
|
||||
},
|
||||
{
|
||||
prop: 'devChns',
|
||||
label: '通道数',
|
||||
minWidth: 100,
|
||||
},
|
||||
{
|
||||
minWidth: 100
|
||||
},
|
||||
{
|
||||
prop: 'devVolt',
|
||||
label: '额定电压V',
|
||||
minWidth: 150,
|
||||
},
|
||||
{
|
||||
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,
|
||||
},
|
||||
{
|
||||
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,
|
||||
|
||||
},
|
||||
{
|
||||
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
|
||||
/>
|
||||
);
|
||||
}
|
||||
isShow: false,
|
||||
search: {
|
||||
el: 'input',
|
||||
label: '关键词',
|
||||
render: (scope: SearchRenderScope) => {
|
||||
return <el-input v-model={scope.searchParam.region} placeholder="请输入关键词" clearable />
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
},
|
||||
{
|
||||
prop: 'gdName',
|
||||
label: '供电公司',
|
||||
minWidth: 150,
|
||||
},
|
||||
{
|
||||
minWidth: 150
|
||||
},
|
||||
{
|
||||
prop: 'subName',
|
||||
label: '变电站',
|
||||
minWidth: 150,
|
||||
},
|
||||
{
|
||||
minWidth: 150
|
||||
},
|
||||
{
|
||||
prop: 'boundPlanName',
|
||||
label: '子计划',
|
||||
minWidth: 150,
|
||||
|
||||
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>
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
|
||||
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},
|
||||
])
|
||||
|
||||
|
||||
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
|
||||
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
|
||||
if (row.state == '/') return
|
||||
|
||||
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
|
||||
// 👇 更新数据(例如清空 state 字段)
|
||||
row.state = '/'
|
||||
proTable.value?.getTableList()
|
||||
// 可选:刷新表格或提交接口
|
||||
ElMessage.success('解绑成功')
|
||||
}).catch(() => {
|
||||
// 用户取消操作
|
||||
})
|
||||
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
|
||||
// 👇 更新数据(例如清空 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)
|
||||
}
|
||||
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 addNewChildTab = async () => {
|
||||
await props.refreshTable!() //刷新检测计划列表
|
||||
}
|
||||
|
||||
//分配被检设备
|
||||
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} 吗?`, '提示', {
|
||||
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 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} 吗?`, '提示', {
|
||||
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) => {
|
||||
@@ -365,177 +395,176 @@ const allotStandardDev = (childPlan: Plan.ResPlan) => {
|
||||
|
||||
// 删除 tab 方法
|
||||
const removeTab = async (targetName: TabPaneName) => {
|
||||
// 找到匹配的 tab
|
||||
const tab = editableTabs.value.find(item => item.name === targetName);
|
||||
const tabTitle = tab?.title || '未知计划'; // 获取 tab 的标题,若不存在则默认为 '未知计划'
|
||||
// 找到匹配的 tab
|
||||
const tab = editableTabs.value.find(item => item.name === targetName)
|
||||
const tabTitle = tab?.title || '未知计划' // 获取 tab 的标题,若不存在则默认为 '未知计划'
|
||||
|
||||
await useHandleData(deletePlan, { id: [targetName], pattern: patternId.value }, `删除【${tabTitle}】检测计划`);
|
||||
await props.refreshTable!()//刷新检测计划列表
|
||||
await useHandleData(deletePlan, { id: [targetName], pattern: patternId.value }, `删除【${tabTitle}】检测计划`)
|
||||
await props.refreshTable!() //刷新检测计划列表
|
||||
}
|
||||
|
||||
|
||||
// 弹窗打开方法
|
||||
const open = async (textTitle: string,data: Plan.ReqPlan,pattern: string) => {
|
||||
console.log('open',data)
|
||||
dialogVisible.value = true
|
||||
title.value = textTitle
|
||||
planTitle.value = data.name
|
||||
planId.value = data.id
|
||||
planFormContent.value = data
|
||||
editableTabsValue.value = planFormContent.value.id//默认tab第一个
|
||||
proTable.value?.getTableList()
|
||||
isTabPlanFather.value = false//子计划页面按钮默认展示主计划的
|
||||
patternId.value = pattern
|
||||
columns.forEach(item => {//刚进去子计划页面隐藏主计划的操作列
|
||||
if (item.prop === 'operation') {
|
||||
item.isShow = false;
|
||||
}
|
||||
});
|
||||
const open = async (textTitle: string, data: Plan.ReqPlan, pattern: string) => {
|
||||
console.log('open', data)
|
||||
dialogVisible.value = true
|
||||
title.value = textTitle
|
||||
planTitle.value = data.name
|
||||
planId.value = data.id
|
||||
planFormContent.value = data
|
||||
editableTabsValue.value = planFormContent.value.id //默认tab第一个
|
||||
proTable.value?.getTableList()
|
||||
isTabPlanFather.value = false //子计划页面按钮默认展示主计划的
|
||||
patternId.value = pattern
|
||||
columns.forEach(item => {
|
||||
//刚进去子计划页面隐藏主计划的操作列
|
||||
if (item.prop === 'operation') {
|
||||
item.isShow = false
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const handleTabClick = (tab:any) => {
|
||||
if(tab.props.closable){
|
||||
columns.forEach(item => {//隐藏子计划名称
|
||||
if (item.prop === 'boundPlanName') {
|
||||
item.isShow = false;
|
||||
}
|
||||
if (item.prop === 'operation') {
|
||||
item.isShow = true;
|
||||
}
|
||||
});
|
||||
isTabPlanFather.value = true
|
||||
}else{
|
||||
columns.forEach(item => {
|
||||
if (item.prop === 'boundPlanName') {
|
||||
item.isShow = true;
|
||||
}
|
||||
if (item.prop === 'operation') {
|
||||
item.isShow = false;
|
||||
}
|
||||
});
|
||||
isTabPlanFather.value = false
|
||||
}
|
||||
planId.value = tab.props.name
|
||||
proTable.value?.getTableList()
|
||||
const handleTabClick = (tab: any) => {
|
||||
if (tab.props.closable) {
|
||||
columns.forEach(item => {
|
||||
//隐藏子计划名称
|
||||
if (item.prop === 'boundPlanName') {
|
||||
item.isShow = false
|
||||
}
|
||||
if (item.prop === 'operation') {
|
||||
item.isShow = true
|
||||
}
|
||||
})
|
||||
isTabPlanFather.value = true
|
||||
} else {
|
||||
columns.forEach(item => {
|
||||
if (item.prop === 'boundPlanName') {
|
||||
item.isShow = true
|
||||
}
|
||||
if (item.prop === 'operation') {
|
||||
item.isShow = false
|
||||
}
|
||||
})
|
||||
isTabPlanFather.value = false
|
||||
}
|
||||
planId.value = tab.props.name
|
||||
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)
|
||||
}
|
||||
// 👇 处理新数据,例如更新 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; // 找到匹配项,返回它
|
||||
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 // 如果子项中找到,返回结果
|
||||
}
|
||||
}
|
||||
}
|
||||
if (item.children && item.children.length > 0) {
|
||||
const result = findItemById(item.children, id); // 递归查找子项
|
||||
if (result) {
|
||||
return item; // 如果子项中找到,返回结果
|
||||
}
|
||||
}
|
||||
}
|
||||
return null; // 未找到匹配项
|
||||
};
|
||||
|
||||
|
||||
return null // 未找到匹配项
|
||||
}
|
||||
|
||||
//主计划下移除被检设备
|
||||
const handleRemove = async (row: any) => {
|
||||
ElMessageBox.confirm(`确定要移除计划【${row.name}】吗?`, '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(async () => {
|
||||
if(row.assign != 0){
|
||||
ElMessage.warning(`当前设备已被子计划绑定,无法删除!`);
|
||||
return
|
||||
}
|
||||
console.log('shcn',planFormContent.value)
|
||||
proTable.value?.getTableList(); // 刷新当前表格
|
||||
}).catch(() => {
|
||||
// 用户取消操作
|
||||
});
|
||||
ElMessageBox.confirm(`确定要移除计划【${row.name}】吗?`, '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
})
|
||||
.then(async () => {
|
||||
if (row.assign != 0) {
|
||||
ElMessage.warning(`当前设备已被子计划绑定,无法删除!`)
|
||||
return
|
||||
}
|
||||
console.log('shcn', planFormContent.value)
|
||||
proTable.value?.getTableList() // 刷新当前表格
|
||||
})
|
||||
.catch(() => {
|
||||
// 用户取消操作
|
||||
})
|
||||
}
|
||||
|
||||
//子计划下移除被检设备
|
||||
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(() => {
|
||||
// 用户取消操作
|
||||
});
|
||||
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)
|
||||
|
||||
const selectedDevices = planTabDevList.value.data.records.filter((dev: { id: any }) =>
|
||||
selectedListIds.includes(dev.id)
|
||||
);
|
||||
if (invalidDevices.length > 0) {
|
||||
const names = invalidDevices.map((dev: { name: any }) => dev.name).join('、')
|
||||
ElMessage.warning(`以下设备不可移除(已检):${names}`)
|
||||
proTable.value?.clearSelection()
|
||||
return
|
||||
}
|
||||
|
||||
const invalidDevices = selectedDevices.filter(
|
||||
(dev: { checkState: number }) => dev.checkState !== 0
|
||||
);
|
||||
try {
|
||||
await ElMessageBox.confirm(`确定要批量移除选中的 ${selectedListIds.length} 个设备吗?`, '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
})
|
||||
|
||||
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);
|
||||
}
|
||||
};
|
||||
|
||||
const handleClose = () => {
|
||||
dialogVisible.value = false
|
||||
router.push('/plan/planList')
|
||||
await subPlanBindDev({ planId: planId.value, devIds: selectedListIds, bindFlag: 0 })
|
||||
ElMessage.success('批量移除成功')
|
||||
proTable.value?.getTableList() // 刷新表格
|
||||
} catch (error) {
|
||||
// 用户取消或接口异常
|
||||
console.error('批量移除失败:', error)
|
||||
}
|
||||
}
|
||||
|
||||
defineExpose({ open,handleTableDataUpdate })
|
||||
const handleClose = () => {
|
||||
dialogVisible.value = false
|
||||
router.push('/plan/planList')
|
||||
}
|
||||
|
||||
defineExpose({ open, handleTableDataUpdate })
|
||||
|
||||
interface ChildrenPlanProps {
|
||||
refreshTable?: () => Promise<void>
|
||||
width?: number
|
||||
height?: number
|
||||
refreshTable?: () => Promise<void>
|
||||
width?: number
|
||||
height?: number
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<ChildrenPlanProps>(), {
|
||||
width: 800,
|
||||
height: 744
|
||||
width: 800,
|
||||
height: 744
|
||||
})
|
||||
// const props = defineProps<{
|
||||
// refreshTable: (() => Promise<void>) | undefined;
|
||||
|
||||
@@ -1,99 +1,134 @@
|
||||
<template>
|
||||
<!-- 权限信息弹出框 -->
|
||||
<el-dialog title="标准设备绑定" v-model='dialogVisible' @close="close" v-bind="dialogBig" width="600" draggable>
|
||||
<div>
|
||||
<el-transfer v-model="value"
|
||||
filterable
|
||||
:filter-method="filterMethod"
|
||||
filter-placeholder="请输入内容搜索"
|
||||
:data="allData"
|
||||
:titles="['未绑定标准设备', '已绑定标准设备']">
|
||||
<template #default="{ option }">
|
||||
<el-tooltip :content="option.tips" placement="top" :show-after=1000>
|
||||
<span>{{ option.label }}</span>
|
||||
</el-tooltip>
|
||||
</template>
|
||||
</el-transfer>
|
||||
|
||||
</div>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button @click="close()">取消</el-button>
|
||||
<el-button type="primary" @click="save()">
|
||||
保存
|
||||
</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { computed, ref } from 'vue'
|
||||
import type { StandardDevice } from '@/api/device/interface/standardDevice'
|
||||
import { dialogBig } from '@/utils/elementBind'
|
||||
import { getBoundStandardDevList,getUnboundStandardDevList,subPlanBindStandardDevList } from '@/api/plan/plan.ts'
|
||||
import { type Plan } from '@/api/plan/interface'
|
||||
import { ElMessage } from 'element-plus'
|
||||
const unboundStandardDevList=ref<StandardDevice.ResPqStandardDevice[]>([])//指定模式下所有未绑定的标准设备
|
||||
const boundStandardDevList=ref<StandardDevice.ResPqStandardDevice[]>([])//根据检测计划id查询出所有已绑定的标准设备
|
||||
const dialogVisible = ref(false)
|
||||
const planData = ref<Plan.ReqPlan | null>(null) // 新增状态管理
|
||||
|
||||
const value = ref<string[]>([])
|
||||
const generateData = () => {
|
||||
const unboundData = unboundStandardDevList.value.map((i: StandardDevice.ResPqStandardDevice) => ({
|
||||
key: i.id,
|
||||
label: i.name,
|
||||
}))
|
||||
const boundData = boundStandardDevList.value.map((i: StandardDevice.ResPqStandardDevice) => ({
|
||||
key: i.id,
|
||||
label: i.name,
|
||||
}))
|
||||
<el-dialog title="标准设备绑定" v-model="dialogVisible" @close="close" v-bind="dialogBig" width="700" draggable>
|
||||
<div>
|
||||
<el-transfer
|
||||
v-model="value"
|
||||
filterable
|
||||
:filter-method="filterMethod"
|
||||
filter-placeholder="请输入内容搜索"
|
||||
:data="allData"
|
||||
:titles="['未绑定标准设备', '已绑定标准设备']"
|
||||
>
|
||||
<template #default="{ option }">
|
||||
<div style="display: flex; align-items: center; justify-content: space-between">
|
||||
<span>{{ JSON.parse(option.label).manufacturer }} - {{ JSON.parse(option.label).name }}</span>
|
||||
<!-- <el-tooltip placement="top" effect="light">
|
||||
<template #content>
|
||||
<el-descriptions size="small" title="标准设备详情" border>
|
||||
<el-descriptions-item label="设备名称">
|
||||
{{ JSON.parse(option.label).name }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="设备厂家">
|
||||
{{ JSON.parse(option.label).manufacturer }}
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</template>
|
||||
<el-icon><Warning /></el-icon>
|
||||
</el-tooltip>-->
|
||||
</div>
|
||||
</template>
|
||||
</el-transfer>
|
||||
</div>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button @click="close()">取消</el-button>
|
||||
<el-button type="primary" @click="save()">保存</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
return [...unboundData, ...boundData]
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { computed, ref } from 'vue'
|
||||
import type { StandardDevice } from '@/api/device/interface/standardDevice'
|
||||
import { dialogBig } from '@/utils/elementBind'
|
||||
import { getBoundStandardDevList, getUnboundStandardDevList, subPlanBindStandardDevList } from '@/api/plan/plan.ts'
|
||||
import { type Plan } from '@/api/plan/interface'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { useDictStore } from '@/stores/modules/dict'
|
||||
|
||||
const unboundStandardDevList = ref<StandardDevice.ResPqStandardDevice[]>([]) //指定模式下所有未绑定的标准设备
|
||||
const boundStandardDevList = ref<StandardDevice.ResPqStandardDevice[]>([]) //根据检测计划id查询出所有已绑定的标准设备
|
||||
const dialogVisible = ref(false)
|
||||
const planData = ref<Plan.ReqPlan | null>(null) // 新增状态管理
|
||||
|
||||
const value = ref<string[]>([])
|
||||
const dictStore = useDictStore()
|
||||
const generateData = () => {
|
||||
const manufacturerDict = dictStore.getDictData('Dev_Manufacturers')
|
||||
unboundStandardDevList.value.forEach(i => {
|
||||
// 确保字段不为空且字典存在再进行查找
|
||||
if (i.manufacturer && manufacturerDict) {
|
||||
const manufacturer = manufacturerDict.find(item => item.id === i.manufacturer)
|
||||
if (manufacturer) {
|
||||
i.manufacturer = manufacturer.name
|
||||
}
|
||||
}
|
||||
})
|
||||
const unboundData = unboundStandardDevList.value.map((i: StandardDevice.ResPqStandardDevice) => ({
|
||||
key: i.id,
|
||||
label: JSON.stringify(i)
|
||||
}))
|
||||
boundStandardDevList.value.forEach(i => {
|
||||
// 确保字段不为空且字典存在再进行查找
|
||||
if (i.manufacturer && manufacturerDict) {
|
||||
const manufacturer = manufacturerDict.find(item => item.id === i.manufacturer)
|
||||
if (manufacturer) {
|
||||
i.manufacturer = manufacturer.name
|
||||
}
|
||||
}
|
||||
})
|
||||
const boundData = boundStandardDevList.value.map((i: StandardDevice.ResPqStandardDevice) => ({
|
||||
key: i.id,
|
||||
label: JSON.stringify(i)
|
||||
}))
|
||||
|
||||
return [...unboundData, ...boundData]
|
||||
}
|
||||
|
||||
const allData = computed(() => generateData())
|
||||
|
||||
|
||||
const filterMethod = (query: string, item: { label?: string }) => {
|
||||
return item.label?.toLowerCase().includes(query.toLowerCase()) ?? false
|
||||
return item.label?.toLowerCase().includes(query.toLowerCase()) ?? false
|
||||
}
|
||||
|
||||
// 打开弹窗,可能是新增,也可能是编辑
|
||||
const open = async (data: Plan.ReqPlan) => {
|
||||
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[];
|
||||
// 打开弹窗,可能是新增,也可能是编辑
|
||||
const open = async (data: Plan.ReqPlan) => {
|
||||
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[]
|
||||
|
||||
const standardDevList_Result2 = await getBoundStandardDevList(data);
|
||||
boundStandardDevList.value = standardDevList_Result2.data as StandardDevice.ResPqStandardDevice[];
|
||||
const standardDevList_Result2 = await getBoundStandardDevList(data)
|
||||
boundStandardDevList.value = standardDevList_Result2.data as StandardDevice.ResPqStandardDevice[]
|
||||
|
||||
value.value = boundStandardDevList.value.map((i: { id: { toString: () => any } }) => i.id.toString());
|
||||
|
||||
value.value = boundStandardDevList.value.map((i: { id: { toString: () => any } }) => i.id.toString())
|
||||
}
|
||||
const close = () => {
|
||||
const close = () => {
|
||||
dialogVisible.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const emit = defineEmits(['update:table'])
|
||||
|
||||
const emit = defineEmits(['update:table'])
|
||||
|
||||
const save = async () => {
|
||||
const save = async () => {
|
||||
if (planData.value) {
|
||||
planData.value.planId = planData.value.id
|
||||
planData.value.devIds = value.value
|
||||
await subPlanBindStandardDevList(planData.value)
|
||||
emit('update:table')
|
||||
ElMessage.success({ message: `标准设备绑定保存成功!` })
|
||||
planData.value.planId = planData.value.id
|
||||
planData.value.devIds = value.value
|
||||
await subPlanBindStandardDevList(planData.value)
|
||||
emit('update:table')
|
||||
ElMessage.success({ message: `标准设备绑定保存成功!` })
|
||||
}
|
||||
dialogVisible.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 对外映射
|
||||
// 对外映射
|
||||
defineExpose({ open })
|
||||
|
||||
</script>
|
||||
</script>
|
||||
<style scoped lang="scss">
|
||||
:deep(.el-transfer) {
|
||||
--el-transfer-panel-width: 250px;
|
||||
--el-transfer-panel-body-height: 315px;
|
||||
}
|
||||
</style>
|
||||
@@ -9,7 +9,7 @@
|
||||
align-center
|
||||
>
|
||||
<el-row :gutter="24">
|
||||
<el-col :span="planType == 0 ? 10 : 24">
|
||||
<el-col :span="10">
|
||||
<el-form :model="formContent" ref="dialogFormRef" :rules="rules">
|
||||
<el-form-item label="名称" prop="name" :label-width="110">
|
||||
<el-input
|
||||
@@ -20,18 +20,13 @@
|
||||
show-word-limit
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
label="标准设备"
|
||||
prop="standardDevIds"
|
||||
:label-width="110"
|
||||
v-if="selectByMode && planType == 0"
|
||||
>
|
||||
<el-form-item label="标准设备" prop="standardDevIds" :label-width="110">
|
||||
<el-select
|
||||
v-model="formContent.standardDevIds"
|
||||
multiple
|
||||
filterable
|
||||
collapse-tags
|
||||
:max-collapse-tags="2"
|
||||
:disabled="planType != 0"
|
||||
placeholder="请选择标准设备"
|
||||
clearable
|
||||
>
|
||||
@@ -46,6 +41,7 @@
|
||||
</el-form-item>
|
||||
<el-form-item label="测试项" prop="testItems" :label-width="110" v-if="selectByMode">
|
||||
<el-select
|
||||
filterable
|
||||
v-model="formContent.testItems"
|
||||
multiple
|
||||
collapse-tags
|
||||
@@ -64,6 +60,7 @@
|
||||
</el-form-item>
|
||||
<el-form-item label="检测源" prop="sourceIds" :label-width="110" v-if="!selectByMode">
|
||||
<el-select
|
||||
filterable
|
||||
v-model="formContent.sourceIds"
|
||||
:multiple="selectByMode"
|
||||
collapse-tags
|
||||
@@ -80,6 +77,7 @@
|
||||
</el-form-item>
|
||||
<el-form-item label="数据源" prop="datasourceIds" :label-width="110">
|
||||
<el-select
|
||||
filterable
|
||||
v-model="formContent.datasourceIds"
|
||||
:multiple="selectByMode"
|
||||
:max-collapse-tags="2"
|
||||
@@ -116,6 +114,7 @@
|
||||
</el-form-item>
|
||||
<el-form-item label="误差体系" prop="errorSysId" :label-width="110">
|
||||
<el-select
|
||||
filterable
|
||||
v-model="formContent.errorSysId"
|
||||
placeholder="请选择误差体系"
|
||||
autocomplete="off"
|
||||
@@ -180,7 +179,7 @@
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-col>
|
||||
<el-col :span="14" v-if="planType == 0">
|
||||
<el-col :span="14">
|
||||
<el-transfer
|
||||
v-model="value"
|
||||
filterable
|
||||
@@ -190,7 +189,7 @@
|
||||
:titles="['未绑定被检设备', '已绑定被检设备']"
|
||||
>
|
||||
<template #default="{ option }">
|
||||
<div style="display: flex; align-items: center; justify-content:space-between">
|
||||
<div style="display: flex; align-items: center; justify-content: space-between">
|
||||
<span>
|
||||
{{ JSON.parse(option.label).manufacturer }} - {{ JSON.parse(option.label).name }}
|
||||
</span>
|
||||
@@ -219,7 +218,7 @@
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template #left-footer>
|
||||
<template #left-footer v-if="planType === 0">
|
||||
<el-button
|
||||
class="transfer-footer"
|
||||
v-if="modeStore.currentMode !== '比对式'"
|
||||
@@ -243,7 +242,7 @@
|
||||
导入被检设备
|
||||
</el-button>
|
||||
</template>
|
||||
<template #right-footer>
|
||||
<template #right-footer v-if="planType === 0">
|
||||
<el-text></el-text>
|
||||
</template>
|
||||
<template #left-empty>
|
||||
@@ -261,7 +260,7 @@
|
||||
<el-button type="primary" @click="save()">确 定</el-button>
|
||||
</div>
|
||||
</template>
|
||||
<ImportExcel ref="deviceImportExcel" />
|
||||
<ImportExcel ref="deviceImportExcel" @result="importResult" />
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
@@ -273,12 +272,12 @@ import { type Plan } from '@/api/plan/interface'
|
||||
import {
|
||||
addPlan,
|
||||
getBoundPqDevList,
|
||||
getBoundStandardDevAllList,
|
||||
getPqErrSysList,
|
||||
getPqScriptList,
|
||||
getTestSourceList,
|
||||
getUnboundPqDevList,
|
||||
updatePlan,
|
||||
updateSubPlanName
|
||||
updatePlan
|
||||
} from '@/api/plan/plan.ts'
|
||||
import { useDictStore } from '@/stores/modules/dict'
|
||||
import { type TestSource } from '@/api/device/interface/testSource'
|
||||
@@ -322,7 +321,7 @@ 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 allData = ref<[any[], any[]]>([])
|
||||
const isSelectDisabled = ref(false)
|
||||
const planType = ref<number>(0)
|
||||
const subPlanBindStandardDev = ref<any>([]) //哪些标准设备已经被子计划绑定
|
||||
@@ -359,7 +358,7 @@ const generateData = () => {
|
||||
//tips: i.description
|
||||
disabled: i.checkState != 0 || i.assign == 1
|
||||
}))
|
||||
return [...unboundData, ...boundData]
|
||||
allData.value = [...unboundData, ...boundData]
|
||||
}
|
||||
|
||||
const filterMethod = (query: string, item: { label?: string }) => {
|
||||
@@ -504,7 +503,6 @@ const save = () => {
|
||||
dialogFormRef.value?.validate(async (valid: boolean) => {
|
||||
if (valid) {
|
||||
formContent.devIds = value.value
|
||||
|
||||
if (formContent.id) {
|
||||
// 把数据处理原则转成字典ID
|
||||
const patternItem = dictStore
|
||||
@@ -514,16 +512,18 @@ const save = () => {
|
||||
formContent.dataRule = patternItem.id
|
||||
}
|
||||
if (mode.value === '比对式') {
|
||||
// 新增子计划
|
||||
if (planType.value == 1) {
|
||||
formContent.fatherPlanId = formContent.id
|
||||
formContent.id = ''
|
||||
formContent.devIds = []
|
||||
formContent.standardDevIds = []
|
||||
formContent.standardDevMap = new Map<string, number>()
|
||||
//formContent.devIds = []
|
||||
//formContent.standardDevIds = []
|
||||
// formContent.standardDevMap = new Map<string, number>()
|
||||
await addPlan(formContent)
|
||||
emit('update:tab')
|
||||
// 编辑子计划
|
||||
} else if (planType.value == 2) {
|
||||
await updateSubPlanName(formContent)
|
||||
await updatePlan(formContent)
|
||||
emit('update:tab')
|
||||
console.log('更新子计划', formContent)
|
||||
} else {
|
||||
@@ -565,9 +565,7 @@ const save = () => {
|
||||
}
|
||||
close()
|
||||
// 刷新表格
|
||||
if (planType.value == 0) {
|
||||
await props.refreshTable!()
|
||||
}
|
||||
await props.refreshTable!()
|
||||
}
|
||||
})
|
||||
} catch (err) {
|
||||
@@ -759,8 +757,20 @@ const open = async (sign: string, data: Plan.ReqPlan, currentMode: string, plan:
|
||||
|
||||
Object.assign(formContent, { ...data })
|
||||
//设备绑定显示
|
||||
unboundPqDevList.value = unboundData as Device.ResPqDev[]
|
||||
boundPqDevList.value = boundData as Device.ResPqDev[]
|
||||
if (planType.value === 0) {
|
||||
unboundPqDevList.value = unboundData as Device.ResPqDev[]
|
||||
boundPqDevList.value = boundData as Device.ResPqDev[]
|
||||
} else if (planType.value === 1) {
|
||||
unboundPqDevList.value = boundData.filter(i => !i.boundPlanName) as Device.ResPqDev[]
|
||||
} else if (planType.value === 2) {
|
||||
const fatherBoundData_Result = await getBoundPqDevList({ planIdList: [data.fatherPlanId] })
|
||||
const fatherBoundData = Array.isArray(fatherBoundData_Result.data) ? fatherBoundData_Result.data : []
|
||||
// 从 fatherBoundData 中排除 boundData 中已存在的数据(根据 id 进行比较)
|
||||
unboundPqDevList.value = fatherBoundData.filter(
|
||||
fatherItem => !boundData.some(boundItem => boundItem.id === fatherItem.id)
|
||||
) as Device.ResPqDev[]
|
||||
boundPqDevList.value = boundData as Device.ResPqDev[]
|
||||
}
|
||||
}
|
||||
|
||||
pqToArray() //将对象转为数组
|
||||
@@ -796,6 +806,7 @@ const open = async (sign: string, data: Plan.ReqPlan, currentMode: string, plan:
|
||||
value: item.id
|
||||
}))
|
||||
}
|
||||
generateData()
|
||||
// 所有数据加载完成后显示对话框
|
||||
dialogVisible.value = true
|
||||
}
|
||||
@@ -837,10 +848,30 @@ function pqToArray() {
|
||||
}))
|
||||
|
||||
const sourceArray5 = Array.isArray(pqStandardDevList.value) ? pqStandardDevList.value : []
|
||||
pqStandardDevArray.value = sourceArray5.map(item => ({
|
||||
label: item.name,
|
||||
value: item.id
|
||||
}))
|
||||
if (planType.value === 0) {
|
||||
pqStandardDevArray.value = sourceArray5.map(item => ({
|
||||
label: item.name,
|
||||
value: item.id
|
||||
}))
|
||||
} else if (planType.value === 1) {
|
||||
pqStandardDevArray.value = sourceArray5
|
||||
.filter(item => formContent.standardDevIds.includes(item.id))
|
||||
.map(item => ({
|
||||
label: item.name,
|
||||
value: item.id
|
||||
}))
|
||||
formContent.standardDevIds = []
|
||||
formContent.standardDevMap = new Map<string, number>()
|
||||
} else if (planType.value === 2) {
|
||||
const params = { id: formContent.id }
|
||||
getBoundStandardDevAllList(params).then(result => {
|
||||
const boundStandardDevAllList = Array.isArray(result.data) ? result.data : []
|
||||
pqStandardDevArray.value = boundStandardDevAllList.map(item => ({
|
||||
label: item.name,
|
||||
value: item.id
|
||||
}))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const dataSourceType = computed(() => {
|
||||
@@ -899,7 +930,17 @@ const importFile = async (pattern: string) => {
|
||||
}
|
||||
deviceImportExcel.value?.acceptParams(params)
|
||||
}
|
||||
|
||||
const importResult = async (success: boolean | undefined) => {
|
||||
if (success) {
|
||||
const patternId = dictStore.getDictData('Pattern').find(item => item.name === mode.value)?.id ?? ''
|
||||
const data = { pattern: patternId }
|
||||
// 刷新未绑定的
|
||||
const unboundPqDevList_Result = await getUnboundPqDevList(data)
|
||||
const unboundData = Array.isArray(unboundPqDevList_Result.data) ? unboundPqDevList_Result.data : []
|
||||
unboundPqDevList.value = unboundData
|
||||
generateData()
|
||||
}
|
||||
}
|
||||
// 对外映射
|
||||
defineExpose({ open })
|
||||
const props = defineProps<{
|
||||
|
||||
Reference in New Issue
Block a user