UPDATE:1.完善主计划导入被检设备逻辑;2.完善新增编辑子计划逻辑。
This commit is contained in:
@@ -2,7 +2,6 @@ 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 检测计划管理模块
|
||||
@@ -23,7 +22,7 @@ export const updatePlan = (params: any) => {
|
||||
}
|
||||
|
||||
// 删除检测计划
|
||||
export const deletePlan = (params: { id: string[] ,pattern: string}) => {
|
||||
export const deletePlan = (params: { id: string[]; pattern: string }) => {
|
||||
return http.post(`/adPlan/delete?pattern=${params.pattern}`, params.id)
|
||||
}
|
||||
|
||||
@@ -119,3 +118,8 @@ export const getUnboundStandardDevList = (params:Plan.ResPlan) => {
|
||||
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-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-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'
|
||||
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'>
|
||||
<slot name="empty">
|
||||
<el-icon class="el-icon--upload">
|
||||
<upload-filled />
|
||||
</el-icon>
|
||||
<div class='el-upload__text'>将文件拖到此处,或<em>点击上传</em></div>
|
||||
<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 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 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
|
||||
}
|
||||
|
||||
// 是否覆盖数据
|
||||
@@ -66,9 +76,11 @@ const dialogVisible = ref(false)
|
||||
const parameter = ref<ExcelParameterProps>({
|
||||
title: '',
|
||||
fileSize: 5,
|
||||
fileType: ['application/vnd.ms-excel', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'],
|
||||
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 }
|
||||
@@ -78,7 +90,7 @@ const acceptParams = (params: ExcelParameterProps) => {
|
||||
// Excel 导入模板下载
|
||||
const downloadTemp = () => {
|
||||
if (!parameter.value.tempApi) return
|
||||
useDownload(parameter.value.tempApi, `${parameter.value.title}模板`, {'pattern':parameter.value.patternId}, false)
|
||||
useDownload(parameter.value.tempApi, `${parameter.value.title}模板`, { pattern: parameter.value.patternId }, false)
|
||||
}
|
||||
|
||||
// 文件上传
|
||||
@@ -93,13 +105,11 @@ const uploadExcel = async (param: UploadRequestOptions) => {
|
||||
|
||||
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))
|
||||
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)
|
||||
|
||||
@@ -113,12 +123,14 @@ async function handleImportResponse(res: any) {
|
||||
} else {
|
||||
ElMessage.error(jsonData.message)
|
||||
}
|
||||
emit('result', jsonData.data)
|
||||
} 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)
|
||||
@@ -142,14 +154,14 @@ const beforeExcelUpload = (file: UploadRawFile) => {
|
||||
ElNotification({
|
||||
title: '温馨提示',
|
||||
message: '上传文件只能是 xls / xlsx 格式!',
|
||||
type: 'warning',
|
||||
type: 'warning'
|
||||
})
|
||||
if (!fileSize)
|
||||
setTimeout(() => {
|
||||
ElNotification({
|
||||
title: '温馨提示',
|
||||
message: `上传文件大小不能超过 ${parameter.value.fileSize}MB!`,
|
||||
type: 'warning',
|
||||
type: 'warning'
|
||||
})
|
||||
}, 0)
|
||||
return isExcel && fileSize
|
||||
@@ -160,7 +172,7 @@ const handleExceed = () => {
|
||||
ElNotification({
|
||||
title: '温馨提示',
|
||||
message: '最多只能上传一个文件!',
|
||||
type: 'warning',
|
||||
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>
|
||||
|
||||
@@ -14,27 +14,16 @@
|
||||
class="table-box"
|
||||
:style="{ height: height - 64 + 'px', maxHeight: height - 64 + 'px', overflow: 'hidden' }"
|
||||
>
|
||||
<el-tabs
|
||||
v-model="editableTabsValue"
|
||||
type="card"
|
||||
@tab-remove="removeTab"
|
||||
@tab-click="handleTabClick"
|
||||
>
|
||||
<el-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-tab-pane>
|
||||
</el-tabs>
|
||||
<ProTable
|
||||
ref="proTable"
|
||||
:columns="columns"
|
||||
:request-api="getTableList"
|
||||
type="selection"
|
||||
>
|
||||
<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">
|
||||
@@ -49,11 +38,29 @@
|
||||
<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
|
||||
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-dropdown
|
||||
v-if="planFormContent && planFormContent?.children.length > 0"
|
||||
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>
|
||||
@@ -68,8 +75,17 @@
|
||||
</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-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>
|
||||
@@ -87,36 +103,52 @@
|
||||
</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>
|
||||
<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"/>
|
||||
<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 proTable = ref<ProTableInstance>()
|
||||
const modeStore = useModeStore();
|
||||
const modeStore = useModeStore()
|
||||
const planPopup = ref()
|
||||
const devTransfer = ref()
|
||||
|
||||
@@ -133,54 +165,51 @@ 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: '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,
|
||||
minWidth: 150
|
||||
},
|
||||
{
|
||||
prop: 'manufacturer',
|
||||
@@ -188,13 +217,12 @@ const columns = reactive<ColumnProps<Device.ResPqDev>[]>([
|
||||
enum: dictStore.getDictData('Dev_Manufacturers'),
|
||||
search: { el: 'select', props: { filterable: true }, order: 1 },
|
||||
fieldNames: { label: 'name', value: 'id' },
|
||||
minWidth: 200,
|
||||
minWidth: 200
|
||||
},
|
||||
{
|
||||
prop: 'cityName',
|
||||
label: '地市',
|
||||
minWidth: 150,
|
||||
|
||||
minWidth: 150
|
||||
},
|
||||
{
|
||||
prop: 'region',
|
||||
@@ -205,61 +233,61 @@ const columns = reactive<ColumnProps<Device.ResPqDev>[]>([
|
||||
el: 'input',
|
||||
label: '关键词',
|
||||
render: (scope: SearchRenderScope) => {
|
||||
return (
|
||||
<el-input
|
||||
v-model={scope.searchParam.region}
|
||||
placeholder="请输入关键词"
|
||||
clearable
|
||||
/>
|
||||
);
|
||||
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) => {
|
||||
render: scope => {
|
||||
console.log('boundPlanName', isTabPlanFather.value)
|
||||
const value = scope.row.boundPlanName;
|
||||
const value = scope.row.boundPlanName
|
||||
if (!value) {
|
||||
return '/'; // 空值直接返回空字符串
|
||||
return '/' // 空值直接返回空字符串
|
||||
}
|
||||
return (
|
||||
<el-link type='primary' link onClick={() => unbindDevice(scope.row)}>
|
||||
<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>
|
||||
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},
|
||||
{ prop: 'operation', label: '操作', fixed: 'right', width: 100 }
|
||||
])
|
||||
|
||||
|
||||
|
||||
const editableTabs = computed(() => {
|
||||
console.log('editableTabs', planFormContent.value)
|
||||
const tabs = []
|
||||
@@ -286,33 +314,34 @@ const editableTabs = computed(() => {
|
||||
|
||||
//解绑被检设备
|
||||
const unbindDevice = (row: any) => {
|
||||
if(row.state == '/')
|
||||
return
|
||||
if (row.state == '/') return
|
||||
|
||||
ElMessageBox.confirm(`确定将设备 ${row.name} 从子计划中解绑吗?`, '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(async () => {
|
||||
})
|
||||
.then(async () => {
|
||||
if (row.checkState != 0) {
|
||||
ElMessage.warning(`当前设备已检,无法解除绑定!`);
|
||||
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 字段)
|
||||
row.state = '/'
|
||||
proTable.value?.getTableList()
|
||||
// 可选:刷新表格或提交接口
|
||||
ElMessage.success('解绑成功')
|
||||
}).catch(() => {
|
||||
})
|
||||
.catch(() => {
|
||||
// 用户取消操作
|
||||
})
|
||||
}
|
||||
|
||||
// 新增 tab 方法
|
||||
const addTab = (type: string) => {
|
||||
if(type === "add"){
|
||||
planPopup.value?.open("edit", planFormContent.value,modeStore.currentMode,1)
|
||||
if (type === 'add') {
|
||||
planPopup.value?.open('edit', planFormContent.value, modeStore.currentMode, 1)
|
||||
} else {
|
||||
const subPlanFormContent = ref<Plan.ReqPlan>()
|
||||
// 从 planFormContent.value?.children 中找到 id 与 item.name 匹配的子计划
|
||||
@@ -320,7 +349,7 @@ const addTab = (type: string) => {
|
||||
(child: Plan.ReqPlan) => child.id === planId.value
|
||||
)
|
||||
console.log('0000---', subPlanFormContent.value)
|
||||
planPopup.value?.open("edit", subPlanFormContent.value,modeStore.currentMode,2)
|
||||
planPopup.value?.open('edit', subPlanFormContent.value, modeStore.currentMode, 2)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -331,30 +360,31 @@ const addNewChildTab = async () => {
|
||||
|
||||
//分配被检设备
|
||||
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}`);
|
||||
const names = invalidDevices.map((dev: { name: any }) => dev.name).join('、')
|
||||
ElMessage.warning(`以下设备不可分配:${names}`)
|
||||
proTable.value?.clearSelection()
|
||||
return;
|
||||
return
|
||||
}
|
||||
ElMessageBox.confirm(`确定将以下被检设备分配给 ${childPlan.name} 吗?`, '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning',
|
||||
}).then(async () => {
|
||||
await subPlanBindDev({'planId': childPlan.id, 'devIds': scope.selectedListIds ,'bindFlag': 1}) //解绑 0 绑定 1
|
||||
type: 'warning'
|
||||
})
|
||||
.then(async () => {
|
||||
await subPlanBindDev({ planId: childPlan.id, devIds: scope.selectedListIds, bindFlag: 1 }) //解绑 0 绑定 1
|
||||
proTable.value?.getTableList()
|
||||
ElMessage.success('分配成功')
|
||||
}).catch(() => {
|
||||
})
|
||||
.catch(() => {
|
||||
// 用户取消操作
|
||||
})
|
||||
}
|
||||
@@ -366,14 +396,13 @@ 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 的标题,若不存在则默认为 '未知计划'
|
||||
const tab = editableTabs.value.find(item => item.name === targetName)
|
||||
const tabTitle = tab?.title || '未知计划' // 获取 tab 的标题,若不存在则默认为 '未知计划'
|
||||
|
||||
await useHandleData(deletePlan, { id: [targetName], pattern: patternId.value }, `删除【${tabTitle}】检测计划`);
|
||||
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)
|
||||
@@ -386,33 +415,35 @@ const open = async (textTitle: string,data: Plan.ReqPlan,pattern: string) => {
|
||||
proTable.value?.getTableList()
|
||||
isTabPlanFather.value = false //子计划页面按钮默认展示主计划的
|
||||
patternId.value = pattern
|
||||
columns.forEach(item => {//刚进去子计划页面隐藏主计划的操作列
|
||||
columns.forEach(item => {
|
||||
//刚进去子计划页面隐藏主计划的操作列
|
||||
if (item.prop === 'operation') {
|
||||
item.isShow = false;
|
||||
item.isShow = false
|
||||
}
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
const handleTabClick = (tab: any) => {
|
||||
if (tab.props.closable) {
|
||||
columns.forEach(item => {//隐藏子计划名称
|
||||
columns.forEach(item => {
|
||||
//隐藏子计划名称
|
||||
if (item.prop === 'boundPlanName') {
|
||||
item.isShow = false;
|
||||
item.isShow = false
|
||||
}
|
||||
if (item.prop === 'operation') {
|
||||
item.isShow = true;
|
||||
item.isShow = true
|
||||
}
|
||||
});
|
||||
})
|
||||
isTabPlanFather.value = true
|
||||
} else {
|
||||
columns.forEach(item => {
|
||||
if (item.prop === 'boundPlanName') {
|
||||
item.isShow = true;
|
||||
item.isShow = true
|
||||
}
|
||||
if (item.prop === 'operation') {
|
||||
item.isShow = false;
|
||||
item.isShow = false
|
||||
}
|
||||
});
|
||||
})
|
||||
isTabPlanFather.value = false
|
||||
}
|
||||
planId.value = tab.props.name
|
||||
@@ -422,7 +453,7 @@ const handleTabClick = (tab:any) => {
|
||||
const handleTableDataUpdate = async (newData: any[]) => {
|
||||
// 👇 处理新数据,例如更新 planFormContent
|
||||
console.log('handleTableDataUpdate', newData)
|
||||
const matchedItem = findItemById(newData, planId.value);
|
||||
const matchedItem = findItemById(newData, planId.value)
|
||||
if (matchedItem) {
|
||||
planFormContent.value = matchedItem
|
||||
console.log('递归匹配成功:', planFormContent.value)
|
||||
@@ -434,19 +465,17 @@ const handleTableDataUpdate = async (newData: any[]) => {
|
||||
const findItemById = (data: any[], id: string): any => {
|
||||
for (const item of data) {
|
||||
if (item.id === id) {
|
||||
return item; // 找到匹配项,返回它
|
||||
return item // 找到匹配项,返回它
|
||||
}
|
||||
if (item.children && item.children.length > 0) {
|
||||
const result = findItemById(item.children, id); // 递归查找子项
|
||||
const result = findItemById(item.children, id) // 递归查找子项
|
||||
if (result) {
|
||||
return item; // 如果子项中找到,返回结果
|
||||
return item // 如果子项中找到,返回结果
|
||||
}
|
||||
}
|
||||
}
|
||||
return null; // 未找到匹配项
|
||||
};
|
||||
|
||||
|
||||
return null // 未找到匹配项
|
||||
}
|
||||
|
||||
//主计划下移除被检设备
|
||||
const handleRemove = async (row: any) => {
|
||||
@@ -454,16 +483,18 @@ const handleRemove = async (row: any) => {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(async () => {
|
||||
})
|
||||
.then(async () => {
|
||||
if (row.assign != 0) {
|
||||
ElMessage.warning(`当前设备已被子计划绑定,无法删除!`);
|
||||
ElMessage.warning(`当前设备已被子计划绑定,无法删除!`)
|
||||
return
|
||||
}
|
||||
console.log('shcn', planFormContent.value)
|
||||
proTable.value?.getTableList(); // 刷新当前表格
|
||||
}).catch(() => {
|
||||
proTable.value?.getTableList() // 刷新当前表格
|
||||
})
|
||||
.catch(() => {
|
||||
// 用户取消操作
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
//子计划下移除被检设备
|
||||
@@ -472,36 +503,34 @@ const subHandleRemove = async (row: any) => {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(async () => {
|
||||
})
|
||||
.then(async () => {
|
||||
if (row.checkState != 0) {
|
||||
ElMessage.warning(`当前设备已检,无法移除!`);
|
||||
ElMessage.warning(`当前设备已检,无法移除!`)
|
||||
return
|
||||
}
|
||||
await subPlanBindDev({'planId': row.planId, 'devIds': [row.id] ,'bindFlag': 0}) //解绑 0 绑定 1
|
||||
ElMessage.success('移除成功');
|
||||
proTable.value?.getTableList(); // 刷新当前表格
|
||||
}).catch(() => {
|
||||
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 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;
|
||||
const names = invalidDevices.map((dev: { name: any }) => dev.name).join('、')
|
||||
ElMessage.warning(`以下设备不可移除(已检):${names}`)
|
||||
proTable.value?.clearSelection()
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -509,16 +538,16 @@ const subBatchRemove = async (selectedListIds: string[]) => {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
});
|
||||
})
|
||||
|
||||
await subPlanBindDev({ planId: planId.value, devIds: selectedListIds, bindFlag: 0 });
|
||||
ElMessage.success('批量移除成功');
|
||||
proTable.value?.getTableList(); // 刷新表格
|
||||
await subPlanBindDev({ planId: planId.value, devIds: selectedListIds, bindFlag: 0 })
|
||||
ElMessage.success('批量移除成功')
|
||||
proTable.value?.getTableList() // 刷新表格
|
||||
} catch (error) {
|
||||
// 用户取消或接口异常
|
||||
console.error('批量移除失败:', error);
|
||||
console.error('批量移除失败:', error)
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const handleClose = () => {
|
||||
dialogVisible.value = false
|
||||
|
||||
@@ -1,27 +1,39 @@
|
||||
<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="700" draggable>
|
||||
<div>
|
||||
<el-transfer v-model="value"
|
||||
<el-transfer
|
||||
v-model="value"
|
||||
filterable
|
||||
:filter-method="filterMethod"
|
||||
filter-placeholder="请输入内容搜索"
|
||||
:data="allData"
|
||||
:titles="['未绑定标准设备', '已绑定标准设备']">
|
||||
:titles="['未绑定标准设备', '已绑定标准设备']"
|
||||
>
|
||||
<template #default="{ option }">
|
||||
<el-tooltip :content="option.tips" placement="top" :show-after=1000>
|
||||
<span>{{ option.label }}</span>
|
||||
</el-tooltip>
|
||||
<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>
|
||||
<el-button type="primary" @click="save()">保存</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
@@ -34,29 +46,49 @@
|
||||
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: i.name,
|
||||
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: i.name,
|
||||
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
|
||||
}
|
||||
@@ -66,20 +98,18 @@ const filterMethod = (query: string, item: { label?: string }) => {
|
||||
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_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[];
|
||||
|
||||
value.value = boundStandardDevList.value.map((i: { id: { toString: () => any } }) => i.id.toString());
|
||||
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())
|
||||
}
|
||||
const close = () => {
|
||||
dialogVisible.value = false
|
||||
}
|
||||
|
||||
|
||||
const emit = defineEmits(['update:table'])
|
||||
|
||||
const save = async () => {
|
||||
@@ -95,5 +125,10 @@ const filterMethod = (query: string, item: { label?: string }) => {
|
||||
|
||||
// 对外映射
|
||||
defineExpose({ open })
|
||||
|
||||
</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
|
||||
@@ -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,10 +565,8 @@ const save = () => {
|
||||
}
|
||||
close()
|
||||
// 刷新表格
|
||||
if (planType.value == 0) {
|
||||
await props.refreshTable!()
|
||||
}
|
||||
}
|
||||
})
|
||||
} catch (err) {
|
||||
console.error('验证过程中出现错误', err)
|
||||
@@ -759,8 +757,20 @@ const open = async (sign: string, data: Plan.ReqPlan, currentMode: string, plan:
|
||||
|
||||
Object.assign(formContent, { ...data })
|
||||
//设备绑定显示
|
||||
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 : []
|
||||
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