比对检测计划
This commit is contained in:
@@ -68,3 +68,7 @@ export const getPqDevById = (params: Device.ReqPqDevParams) => {
|
||||
export const getPqDev = () => {
|
||||
return http.get(`/devType/listAll`)
|
||||
}
|
||||
|
||||
export const getSelectOptions = (params:{ pattern: string }) => {
|
||||
return http.get(`/pqDev/getSelectOptions`, params)
|
||||
}
|
||||
|
||||
@@ -88,9 +88,18 @@ export namespace Device {
|
||||
coefficientTime?: number;//系数校准耗时
|
||||
formalCheckTime?: number;//正式检测耗时
|
||||
|
||||
boundPlanName?: string;
|
||||
assign?: number;////是否分配给检测人员 0否 1是
|
||||
monitorList: Monitor.ResPqMon[] ;
|
||||
}
|
||||
|
||||
export interface SelectOption {
|
||||
label: string;
|
||||
value: string | number;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
export interface ResDev {
|
||||
id: string;
|
||||
|
||||
@@ -44,3 +44,8 @@ export const downloadTemplate = () => {
|
||||
export const importPqStandardDev = (params: StandardDevice.ReqPqStandardDeviceParams) => {
|
||||
return http.uploadExcel(`/pqStandardDev/import`, params)
|
||||
}
|
||||
|
||||
//获取所有标准设备
|
||||
export const getAllPqStandardDev = () => {
|
||||
return http.get(`/pqStandardDev/getAll`)
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ export interface Result {
|
||||
* 请求响应参数(包含data)
|
||||
*/
|
||||
export interface ResultData<T = any> extends Result {
|
||||
map(arg0: (item: any) => { label: any; value: any; }): { label: string; value: string; }[] | { label: string; value: string; }[];
|
||||
data: T;
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,10 @@ export namespace Plan {
|
||||
reportTemplateVersion:string;
|
||||
dataRule:string;//数据处理原则
|
||||
|
||||
standardDevIdList:string[];
|
||||
standardDevMap:Map<string,number>;//标准设备
|
||||
testItems:string[];//测试项
|
||||
Check_By?:string;//计划检测人
|
||||
progress?: number; // 进度百分比,例如 75
|
||||
children?: ResPlan[];
|
||||
}
|
||||
@@ -40,11 +44,13 @@ export namespace Plan {
|
||||
|
||||
export interface ReqPlan extends ResPlan {
|
||||
datasourceIds:string;
|
||||
sourceIds: string;
|
||||
sourceIds: string | null;
|
||||
planId:string;
|
||||
scriptName: string ;
|
||||
errorSysName: string;
|
||||
sourceName: string ;
|
||||
standardDevNameStr: string;
|
||||
testItemNameStr:string;
|
||||
devIds: string[];
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import type { Plan } from './interface'
|
||||
import http from '@/api'
|
||||
import type { ErrorSystem } from '../device/interface/error'
|
||||
import type { Device } from '../device/interface/device'
|
||||
import { ReqDevReportParams } from '@/api/device/interface/device'
|
||||
import { pa } from 'element-plus/es/locale/index.mjs'
|
||||
|
||||
/**
|
||||
* @name 检测计划管理模块
|
||||
@@ -23,8 +23,8 @@ export const updatePlan = (params: any) => {
|
||||
}
|
||||
|
||||
// 删除检测计划
|
||||
export const deletePlan = (params: { id: string[] }) => {
|
||||
return http.post(`/adPlan/delete`, params)
|
||||
export const deletePlan = (params: { id: string[] ,pattern: string}) => {
|
||||
return http.post(`/adPlan/delete?pattern=${params.pattern}`, params.id)
|
||||
}
|
||||
|
||||
// 获取指定模式下所有检测源
|
||||
@@ -49,7 +49,7 @@ export const getUnboundPqDevList = (params: Plan.ReqPlan) => {
|
||||
|
||||
//根据检测计划id查询出所有已绑定的设备
|
||||
export const getBoundPqDevList = (params: any) => {
|
||||
return http.post(`/pqDev/listByPlanId`, params)
|
||||
return http.post(`/adPlan/listByPlanId`, params)
|
||||
}
|
||||
|
||||
//检测计划绑定设备
|
||||
@@ -90,3 +90,27 @@ export const staticsAnalyse = (params: { id: string[] }) => {
|
||||
return http.download('/adPlan/analyse', params)
|
||||
}
|
||||
|
||||
//根据计划id分页查询被检设
|
||||
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 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}`)
|
||||
}
|
||||
|
||||
//根据计划ID获取已绑定的标准设备
|
||||
export const getBoundStandardDevList = (params:Plan.ResPlan) => {
|
||||
return http.get(`/adPlan/getBoundStandardDev?planId=${params.id}`)
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
import { pa } from 'element-plus/es/locale/index.mjs';
|
||||
import type {Login} from '@/api/user/interface/user'
|
||||
import {ADMIN as rePrefix} from '@/api/system/config/serviceName'
|
||||
import http from '@/api'
|
||||
|
||||
@@ -37,3 +37,7 @@ export const updatePassWord = (params: User.ResPassWordUser) => {
|
||||
return http.post(`/sysUser/updatePassword`,params)
|
||||
}
|
||||
|
||||
// 获取所有用户
|
||||
export const getAllUser= () => {
|
||||
return http.get(`/sysUser/getAll`)
|
||||
}
|
||||
|
||||
@@ -48,6 +48,7 @@ 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
|
||||
@@ -87,6 +88,9 @@ const uploadExcel = async (param: UploadRequestOptions) => {
|
||||
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)
|
||||
|
||||
@@ -119,6 +119,7 @@ import TableColumn from './components/TableColumn.vue'
|
||||
import Sortable from 'sortablejs'
|
||||
|
||||
export interface ProTableProps {
|
||||
|
||||
columns: ColumnProps[]; // 列配置项 ==> 必传
|
||||
data?: any[]; // 静态 table data 数据,若存在则不会使用 requestApi 返回的 data ==> 非必传
|
||||
requestApi?: (params: any) => Promise<any>; // 请求表格数据的 api ==> 非必传
|
||||
|
||||
@@ -78,6 +78,7 @@ export const useTable = (
|
||||
});
|
||||
dataCallBack && (data = dataCallBack(data));
|
||||
state.tableData = isPageable ? data.records : data;
|
||||
//console.log(data);
|
||||
// 解构后台返回的分页数据 (如果有分页更新分页信息)
|
||||
if (isPageable) {
|
||||
state.resPageable.total = data.total;
|
||||
@@ -85,6 +86,7 @@ export const useTable = (
|
||||
state.resPageable.size = data.size;
|
||||
}
|
||||
} catch (error) {
|
||||
//console.log('123');
|
||||
requestError && requestError(error);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -20,13 +20,17 @@
|
||||
</template>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { onBeforeMount } from "vue";
|
||||
import { useRouter } from "vue-router";
|
||||
defineProps<{ menuList: Menu.MenuOptions[] }>();
|
||||
const router = useRouter();
|
||||
const handleClickMenu = (subItem: Menu.MenuOptions) => {
|
||||
console.log('1456----------------',subItem);
|
||||
if (subItem.meta.isLink) return window.open(subItem.meta.isLink, "_blank");
|
||||
router.push(subItem.path);
|
||||
};
|
||||
|
||||
|
||||
</script>
|
||||
<style lang="scss">
|
||||
.el-sub-menu .el-sub-menu__title:hover {
|
||||
|
||||
@@ -8,6 +8,9 @@ import {
|
||||
} from "@/utils";
|
||||
import { useRouter } from "vue-router";
|
||||
import { AUTH_STORE_KEY } from "@/stores/constant";
|
||||
import {useModeStore} from '@/stores/modules/mode'
|
||||
|
||||
|
||||
export const useAuthStore = defineStore({
|
||||
id: AUTH_STORE_KEY,
|
||||
state: (): AuthState => ({
|
||||
@@ -43,7 +46,13 @@ export const useAuthStore = defineStore({
|
||||
},
|
||||
// Get AuthMenuList
|
||||
async getAuthMenuList() {
|
||||
const { data } = await getAuthMenuListApi();
|
||||
const modeStore = useModeStore()
|
||||
|
||||
const { data: menuData } = await getAuthMenuListApi();
|
||||
let data = menuData; // 新增变量接收并操作
|
||||
if(modeStore.currentMode === '比对式'){
|
||||
data = filterMenuTree(data);
|
||||
}
|
||||
this.authMenuList = data;
|
||||
|
||||
},
|
||||
@@ -73,3 +82,16 @@ export const useAuthStore = defineStore({
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
// 工具函数:递归过滤掉 name == 'test' 的菜单项
|
||||
function filterMenuTree(menuList: any[]) {
|
||||
return menuList.filter(menu => {
|
||||
// 如果当前项有 children,递归处理子项
|
||||
if (menu.children && menu.children.length > 0) {
|
||||
menu.children = filterMenuTree(menu.children);
|
||||
}
|
||||
// 过滤掉 name 是 testSource、testScript 或 controlSource 的菜单项
|
||||
return !['testSource', 'testScript', 'controlSource'].includes(menu.name);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import mitt from "mitt";
|
||||
|
||||
const mittBus = mitt();
|
||||
|
||||
export default mittBus;
|
||||
|
||||
@@ -483,7 +483,7 @@ const getTableList = async (params: any) => {
|
||||
}
|
||||
//console.log('table,getBoundPqDevList')
|
||||
return getBoundPqDevList({
|
||||
'planId': props.id,
|
||||
'planIdList': [props.id],
|
||||
'checkStateList': checkStateList.value,
|
||||
'checkResult': form.value.checkResult,
|
||||
'reportState': form.value.checkReportStatus,
|
||||
@@ -596,7 +596,7 @@ const columns = reactive<ColumnProps<Device.ResPqDev>[]>([
|
||||
label: '系数校准结果',
|
||||
minWidth: 100,
|
||||
sortable: true,
|
||||
isShow: factorCheckShow && appSceneStore.currentScene === "1" ,
|
||||
isShow: factorCheckShow.value && appSceneStore.currentScene === "1" ,
|
||||
render: scope => {
|
||||
if (scope.row.factorCheckResult === 0) {
|
||||
return '不合格'
|
||||
|
||||
@@ -35,12 +35,12 @@
|
||||
<span>{{ node.label }}</span>
|
||||
<!-- 子节点右侧图标 + tooltip -->
|
||||
<el-tooltip
|
||||
v-if="data.pid"
|
||||
v-if="data.name == '34535'"
|
||||
placement="top"
|
||||
:manual="true"
|
||||
:content="'子计划信息'">
|
||||
content="子计划信息">
|
||||
<Menu
|
||||
@click.stop="detail()"
|
||||
@click.stop="childDetail(node.data)"
|
||||
style="width: 16px; height: 16px; margin-left: 8px; cursor: pointer; color: var(--el-color-primary)"
|
||||
/>
|
||||
</el-tooltip>
|
||||
@@ -49,6 +49,8 @@
|
||||
</el-tree>
|
||||
</div>
|
||||
</div>
|
||||
<SourceOpen ref='openSourceView' :width="width" :height="height"></SourceOpen>
|
||||
|
||||
</template>
|
||||
<script lang='ts' setup>
|
||||
import { type Plan } from '@/api/plan/interface';
|
||||
@@ -57,7 +59,10 @@ import { nextTick, onMounted, ref, watch } from 'vue';
|
||||
import { useRouter } from 'vue-router'
|
||||
import {useCheckStore} from "@/stores/modules/check";
|
||||
import { ElTooltip } from 'element-plus';
|
||||
import SourceOpen from '@/views/plan/planList/components/childrenPlan.vue'
|
||||
|
||||
|
||||
const openSourceView = ref()
|
||||
const router = useRouter()
|
||||
const checkStore = useCheckStore()
|
||||
const filterText = ref('')
|
||||
@@ -96,7 +101,6 @@ const getTreeData = (val: any) => {
|
||||
|
||||
//点击表格后左侧树刷新,高亮显示对应节点
|
||||
const clickTableToTree = (val: any,id:any) => {
|
||||
|
||||
defaultChecked.value = []
|
||||
data.value = val
|
||||
let node = ref('')
|
||||
@@ -119,8 +123,10 @@ const clickTableToTree = (val: any,id:any) => {
|
||||
}
|
||||
}
|
||||
|
||||
const {updateSelectedTreeNode} = defineProps<{
|
||||
const {updateSelectedTreeNode,width,height} = defineProps<{
|
||||
updateSelectedTreeNode:Function;
|
||||
width: number;
|
||||
height: number;
|
||||
}>();
|
||||
watch(
|
||||
() => searchForm.value.planName,
|
||||
@@ -155,11 +161,16 @@ const filterNode = (value: string, data: any) => {
|
||||
return data.name.includes(value)
|
||||
}
|
||||
|
||||
|
||||
// 点击详情
|
||||
const detail = () => {
|
||||
router.push('/plan/planList')
|
||||
}
|
||||
|
||||
|
||||
const childDetail = (data: Plan.ResPlan) => {
|
||||
openSourceView.value.open("检测计划详情",data)
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
// console.log()
|
||||
})
|
||||
|
||||
@@ -41,7 +41,7 @@ const open = async () => {
|
||||
|
||||
// 清空表单内容
|
||||
const resetFormContent = () => {
|
||||
Object.assign(formContent,{temperature:'',humidity:''})
|
||||
Object.assign(formContent,{temperature:'22',humidity:'50'})
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -70,14 +70,14 @@ const modeList = [
|
||||
const handelOpen = async (isActive: any) => {
|
||||
await authStore.setShowMenu();
|
||||
return;
|
||||
if (isActive) {
|
||||
router.push({ path: "/static" });
|
||||
} else {
|
||||
ElMessage({
|
||||
message: "当前模式未配置",
|
||||
type: "warning",
|
||||
});
|
||||
}
|
||||
// if (isActive) {
|
||||
// router.push({ path: "/static" });
|
||||
// } else {
|
||||
// ElMessage({
|
||||
// message: "当前模式未配置",
|
||||
// type: "warning",
|
||||
// });
|
||||
// }
|
||||
};
|
||||
const handleSelect = (key: string, keyPath: string[]) => {
|
||||
//console.log(key, keyPath);
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
<!-- 真正的首页 -->
|
||||
<template>
|
||||
<div class='static'>
|
||||
<div class='static' ref='popupBaseView'>
|
||||
<el-row :gutter='10'>
|
||||
<el-col :lg='4' :xl='4' :md='4' :sm='4'>
|
||||
<div class='left_tree'>
|
||||
<!-- <tree ref='treeRef' :updateSelectedTreeNode='getPieData || (() => {})' /> -->
|
||||
<tree ref='treeRef' :updateSelectedTreeNode='updateData|| (() => {})' />
|
||||
<tree ref='treeRef' :updateSelectedTreeNode='updateData|| (() => {})' :width="viewWidth" :height="viewHeight" />
|
||||
</div>
|
||||
</el-col>
|
||||
<el-col :lg='20' :xl='20' :md='20' :sm='20'>
|
||||
@@ -29,8 +29,8 @@
|
||||
</div>
|
||||
<!--检测计划统计 饼图统计-->
|
||||
<div class='container_pieShow'>
|
||||
<el-collapse model-value='1' accordion @change='handleCollapseChange'>
|
||||
<el-collapse-item name='1'>
|
||||
<el-collapse model-value='1' accordion @change='handleCollapseChange' >
|
||||
<el-collapse-item name='1' >
|
||||
<template #title>
|
||||
<div class='container_pieShow_title'>
|
||||
<span>检测计划统计</span>
|
||||
@@ -118,6 +118,8 @@ import { type Plan } from '@/api/plan/interface'
|
||||
import type { CollapseModelValue } from 'element-plus/es/components/collapse/src/collapse.mjs'
|
||||
import { type Device } from '@/api/device/interface/device'
|
||||
import { ResultData } from '@/api/interface'
|
||||
import { useViewSize } from '@/hooks/useViewSize'
|
||||
import { map } from 'lodash'
|
||||
|
||||
const planName = ref('')
|
||||
const dictStore = useDictStore()
|
||||
@@ -148,6 +150,7 @@ const tableHeight = ref('calc(100% - 50px)') // 初始高度
|
||||
const planList = ref<ResultData<Plan.ReqPlan[]>>()
|
||||
const select_Plan = ref<Plan.ReqPlan>()
|
||||
const isLabelLineShow = ref(true)
|
||||
const { popupBaseView,viewWidth, viewHeight } = useViewSize()
|
||||
const handleCollapseChange = (val: CollapseModelValue) => {
|
||||
|
||||
// 计算新的高度
|
||||
@@ -302,7 +305,7 @@ const getPieData = async (id: string) => {
|
||||
|
||||
select_Plan.value = plan
|
||||
|
||||
const pqDevList_Result2 = await getBoundPqDevList({ 'planId': id, 'checkStateList': [0, 1, 2, 3] })
|
||||
const pqDevList_Result2 = await getBoundPqDevList({ 'planIdList': [id], 'checkStateList': [0, 1, 2, 3] })
|
||||
boundPqDevList.value = pqDevList_Result2.data as Device.ResPqDev[]
|
||||
// 遍历 boundPqDevList 并更新计数对象
|
||||
boundPqDevList.value.forEach(t => {
|
||||
@@ -409,7 +412,6 @@ const planDetail = () => {
|
||||
|
||||
//功能选择css切换
|
||||
const handleCheckFunction = (val: any) => {
|
||||
|
||||
editableTabsValue.value = '0'
|
||||
form.value.activeChildTabs = 0
|
||||
tabsList.value.map((item: any, index: any) => {
|
||||
@@ -454,7 +456,6 @@ const handleCheckFunction = (val: any) => {
|
||||
const resizeObserver = new ResizeObserver(entries => {
|
||||
for (let entry of entries) {
|
||||
chartsWidth.value = entry.contentRect.width
|
||||
//console.log('Charts Info Width:', chartsWidth.value);
|
||||
|
||||
pieRef1.value?.reSize(chartsWidth.value * 0.95, 180, true)
|
||||
pieRef2.value?.reSize(chartsWidth.value * 0.95, 180, true)
|
||||
@@ -485,11 +486,21 @@ const initPlan = async () => {
|
||||
result: 0,
|
||||
code: 0,
|
||||
state: 0,
|
||||
standardDevNameStr: '',
|
||||
associateReport: 0,
|
||||
reportTemplateName: '',
|
||||
reportTemplateVersion: '',
|
||||
dataRule: '',
|
||||
testItemNameStr:'',
|
||||
testItems: [],
|
||||
standardDevIdList:[],
|
||||
standardDevMap: new Map<string, number>(),
|
||||
}
|
||||
planList.value = (await getPlanListByPattern(reqPlan)) as ResultData<Plan.ReqPlan[]>
|
||||
}
|
||||
|
||||
onBeforeMount(async () => {
|
||||
|
||||
await initPlan()
|
||||
for (let i = 0; i < planList.value.data.length; i++) {
|
||||
if (Array.isArray(planList.value.data[i].children) && planList.value.data[i].children.length > 0) {
|
||||
@@ -646,7 +657,7 @@ const handleBatchGenerate = async () => {
|
||||
justify-content: space-between;
|
||||
padding: 0 15px;
|
||||
font-weight: bold;
|
||||
width: 100%;
|
||||
width: 99%;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
|
||||
@@ -53,6 +53,7 @@ import { useAuthStore } from "@/stores/modules/auth";
|
||||
import { useModeStore, useAppSceneStore } from "@/stores/modules/mode"; // 引入模式 store
|
||||
import { ref } from "vue";
|
||||
import {getCurrentScene} from "@/api/user/login";
|
||||
|
||||
const authStore = useAuthStore();
|
||||
const modeStore = useModeStore(); // 使用模式 store
|
||||
const AppSceneStore = useAppSceneStore();
|
||||
@@ -87,6 +88,7 @@ const handelOpen = async (item: any) => {
|
||||
// AppSceneStore.setCurrentMode(scene+'');//0:省级平台,1:设备出厂,2:研发自测
|
||||
AppSceneStore.setCurrentMode(scene+'');//0:省级平台,1:设备出厂,2:研发自测
|
||||
await authStore.setShowMenu();
|
||||
await authStore.getAuthMenuList();
|
||||
return;
|
||||
// if (isActive) {
|
||||
// router.push({ path: "/static" });
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
:key="item.id"
|
||||
:label="item.name"
|
||||
:value="item.id"
|
||||
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
@@ -39,7 +38,6 @@
|
||||
:key="item.id"
|
||||
:label="item.name"
|
||||
:value="item.id"
|
||||
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
@@ -51,12 +49,25 @@
|
||||
:disabled="formContent.importFlag == 1"
|
||||
/>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="固件版本" prop="hardwareVersion" v-if="scene === '0'">
|
||||
<el-input v-model="formContent.hardwareVersion" placeholder="请输入固件版本"/>
|
||||
<el-select v-model="formContent.hardwareVersion" clearable placeholder="请选择固件版本" filterable allow-create>
|
||||
<el-option
|
||||
v-for="item in selectOptions['hardwareVersion']"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="软件版本" prop="softwareVersion" v-if="scene === '0'">
|
||||
<el-input v-model="formContent.softwareVersion" placeholder="请输入软件版本"/>
|
||||
<el-select v-model="formContent.softwareVersion" clearable placeholder="请选择软件版本" filterable allow-create>
|
||||
<el-option
|
||||
v-for="item in selectOptions['softwareVersion']"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label='定检日期' prop='inspectDate' v-if="MonIsShow">
|
||||
<el-date-picker
|
||||
@@ -135,14 +146,35 @@
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label='所属地市' prop='cityName' clearable placeholder="请输入所属地市" v-if="MonIsShow">
|
||||
<el-input v-model='formContent.cityName' :disabled="formContent.importFlag == 1"/>
|
||||
<el-form-item label="所属地市" prop="cityName" v-if="MonIsShow">
|
||||
<el-select v-model="formContent.cityName" clearable placeholder="请选择所属地市" :disabled="formContent.importFlag == 1" filterable allow-create>
|
||||
<el-option
|
||||
v-for="item in selectOptions['cityName']"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label='所属供电公司' prop='gdName' clearable placeholder="请输入所属供电公司" v-if="MonIsShow">
|
||||
<el-input v-model='formContent.gdName' :disabled="formContent.importFlag == 1"/>
|
||||
<el-form-item label="所属供电公司" prop="gdName" v-if="MonIsShow">
|
||||
<el-select v-model="formContent.gdName" clearable placeholder="请选择所属供电公司" :disabled="formContent.importFlag == 1" filterable allow-create>
|
||||
<el-option
|
||||
v-for="item in selectOptions['gdName']"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label='所属电站' prop='subName' clearable placeholder="请输入所属电站" v-if="MonIsShow">
|
||||
<el-input v-model='formContent.subName' :disabled="formContent.importFlag == 1"/>
|
||||
<el-form-item label="所属电站" prop="subName" v-if="MonIsShow">
|
||||
<el-select v-model="formContent.subName" clearable placeholder="请选择所属电站" :disabled="formContent.importFlag == 1" filterable allow-create>
|
||||
<el-option
|
||||
v-for="item in selectOptions['subName']"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item v-auth.device="'factorFlag'" label="是否支持系数校准" prop='factorFlag' v-if="scene === '1'">
|
||||
<el-radio-group v-model="formContent.factorFlag">
|
||||
@@ -155,7 +187,7 @@
|
||||
</el-tab-pane>
|
||||
<el-tab-pane label="监测点台账信息" v-if="MonIsShow">
|
||||
<!-- 监测点台账信息 tab pane -->
|
||||
<MonitorTable @getParameter="getParameter" :DevFormContent = "formContent" :tableHeight="monitorTableHeight"></MonitorTable>
|
||||
<MonitorTable @getParameter="getParameter" :DevFormContent = "formContent" :tableHeight="monitorTableHeight" :selectOptions = "selectOptions"></MonitorTable>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
<template #footer>
|
||||
@@ -171,7 +203,7 @@
|
||||
import {dialogBig} from '@/utils/elementBind'
|
||||
import {type Device} from '@/api/device/interface/device'
|
||||
import {ElMessage, type FormItemRule} from 'element-plus'
|
||||
import {addPqDev, updatePqDev} from '@/api/device/device'
|
||||
import {addPqDev, updatePqDev,getSelectOptions} from '@/api/device/device'
|
||||
import {computed, reactive, type Ref, ref, watchEffect, nextTick} from 'vue'
|
||||
import {useDictStore} from '@/stores/modules/dict'
|
||||
import {CirclePlus, Delete, EditPen} from '@element-plus/icons-vue'
|
||||
@@ -198,6 +230,11 @@ const dialogFormRef = ref()
|
||||
const createDateTitle = ref('')
|
||||
const activeTab = ref('0') // '0' 对应第一个 tab
|
||||
const monitorTableHeight = ref(375) // 默认高度
|
||||
|
||||
const selectOptions = ref<Record<string, Device.SelectOption[]>>({})
|
||||
|
||||
|
||||
|
||||
const pqChannelArray = ref([
|
||||
{
|
||||
value: '1',
|
||||
@@ -348,8 +385,8 @@ const rules = computed(() => {
|
||||
}
|
||||
if (scene.value !== '0') {
|
||||
dynamicRules.name = [{required: true, message: '设备名称必填!', trigger: 'blur'}];
|
||||
dynamicRules.hardwareVersion = [{required: true, message: '固件版本必填!', trigger: 'blur'}];
|
||||
dynamicRules.softwareVersion = [{required: true, message: '软件版本必填!', trigger: 'blur'}];
|
||||
dynamicRules.hardwareVersion = [{required: true, message: '固件版本必选!', trigger: 'change'}];
|
||||
dynamicRules.softwareVersion = [{required: true, message: '软件版本必选!', trigger: 'change'}];
|
||||
dynamicRules.manufacturer = [{required: true, message: '生产厂家必选!', trigger: 'change'}];
|
||||
|
||||
}
|
||||
@@ -361,9 +398,9 @@ const rules = computed(() => {
|
||||
|
||||
if(mode.value === '比对式'){
|
||||
dynamicRules.inspectDate = [{required: true, message: '定检日期必填!', trigger: 'blur'}];
|
||||
dynamicRules.cityName = [{required: true, message: '所属地市必填!', trigger: 'blur'}];
|
||||
dynamicRules.gdName = [{required: true, message: '所属供电公司必填!', trigger: 'blur'}];
|
||||
dynamicRules.subName = [{required: true, message: '所属电站必填!', trigger: 'blur'}];
|
||||
dynamicRules.cityName = [{required: true, message: '所属地市必选!', trigger: 'change'}];
|
||||
dynamicRules.gdName = [{required: true, message: '所属供电公司必选!', trigger: 'change'}];
|
||||
dynamicRules.subName = [{required: true, message: '所属电站必选!', trigger: 'change'}];
|
||||
}
|
||||
|
||||
|
||||
@@ -473,6 +510,21 @@ const open = async (sign: string, data: Device.ResPqDev, currentMode: string, cu
|
||||
activeTab.value = '0' // 强制回到第一个 tab
|
||||
|
||||
if (currentMode === '比对式') {
|
||||
const patternItem = dictStore.getDictData('Pattern').find(item => item.name === currentMode)
|
||||
if (patternItem) {
|
||||
const { data } = await getSelectOptions({ pattern: patternItem.id }) as { data: Record<string, any[]> }
|
||||
|
||||
// 遍历 data 的所有字段并映射为 { label, value }
|
||||
for (const key in data) {
|
||||
if (Array.isArray(data[key])) {
|
||||
selectOptions.value[key] = data[key].map((value: string) => ({
|
||||
label: value,
|
||||
value: value
|
||||
}))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
createDateTitle.value = '投运日期'
|
||||
DevIsShow.value = false
|
||||
MonIsShow.value = true
|
||||
@@ -555,9 +607,9 @@ const handleDevTypeChange = (value: string) => {
|
||||
|
||||
const handleInput = (value: string) => {
|
||||
// 在这里处理选中事件的逻辑
|
||||
if (scene.value === '1') {
|
||||
//if (scene.value === '1') {
|
||||
formContent.name = value
|
||||
}
|
||||
//}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -16,14 +16,35 @@
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="所属母线" prop="busbar" placeholder="请输入所属母线" >
|
||||
<el-input v-model="formContent.busbar" />
|
||||
<el-form-item label="所属母线" prop="busbar">
|
||||
<el-select v-model="formContent.busbar" clearable placeholder="请选择所属母线" filterable allow-create>
|
||||
<el-option
|
||||
v-for="item in selectOptions['busbar']"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="PT变比" prop="pt" placeholder="请输入PT变比" >
|
||||
<el-input v-model="formContent.pt" />
|
||||
<el-form-item label="PT变比" prop="pt">
|
||||
<el-select v-model="formContent.pt" clearable placeholder="请选择PT变比" filterable allow-create>
|
||||
<el-option
|
||||
v-for="item in selectOptions['pt']"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="CT变比" prop="ct" placeholder="请输入CT变比" >
|
||||
<el-input v-model="formContent.ct" />
|
||||
<el-form-item label="CT变比" prop="ct">
|
||||
<el-select v-model="formContent.ct" clearable placeholder="请选择CT变比" filterable allow-create>
|
||||
<el-option
|
||||
v-for="item in selectOptions['ct']"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label='接线方式' prop='connection' >
|
||||
<el-select v-model="formContent.connection" clearable placeholder="请选择接线方式">
|
||||
@@ -36,7 +57,7 @@
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label='统计间隔' prop='statInterval' >
|
||||
<el-select v-model="formContent.statInterval" clearable placeholder="请选择统计间隔">
|
||||
<el-select v-model="formContent.statInterval" clearable placeholder="请选择统计间隔" >
|
||||
<el-option
|
||||
v-for="item in dictStore.getDictData('Dev_Chns')"
|
||||
:key="item.id"
|
||||
@@ -76,6 +97,7 @@
|
||||
const lineNum = ref<{ id: number; name: string }[]>([])
|
||||
const originalNum = ref<number | null>(null) // 存储编辑前的 num 值
|
||||
const monitorTable = ref<any[]>()
|
||||
const selectOptions = ref<Record<string, Device.SelectOption[]>>({})
|
||||
// 定义弹出组件元信息
|
||||
const dialogFormRef = ref()
|
||||
function useMetaInfo() {
|
||||
@@ -131,15 +153,15 @@ const resetFormContent = () => {
|
||||
name : [{ required: true, message: '监测点名称必填!', trigger: 'blur' }],
|
||||
num:[ { required: true, message: '线路号必选', trigger: 'change' }],
|
||||
pt: [
|
||||
{ required: true, message: 'PT变比必填!', trigger: 'blur' },
|
||||
{ pattern: /^[1-9]\d*:[1-9]\d*$/, message: 'PT变比格式应为 n:n 形式,例如 1:1', trigger: 'blur' }
|
||||
{ required: true, message: 'PT变比必选!', trigger: 'blur' },
|
||||
{ pattern: /^[1-9]\d*:[1-9]\d*$/, message: 'PT变比格式应为 n:n 形式,例如 1:1', trigger: 'change' }
|
||||
],
|
||||
ct: [
|
||||
{ required: true, message: 'CT变比必填!', trigger: 'blur' },
|
||||
{ pattern: /^[1-9]\d*:[1-9]\d*$/, message: 'CT变比格式应为 n:n 形式,例如 1:1', trigger: 'blur' }
|
||||
{ required: true, message: 'CT变比必选!', trigger: 'blur' },
|
||||
{ pattern: /^[1-9]\d*:[1-9]\d*$/, message: 'CT变比格式应为 n:n 形式,例如 1:1', trigger: 'change' }
|
||||
],
|
||||
connection: [{ required: true, message: '接线方式必选!', trigger: 'change' }],
|
||||
busbar : [{ required: true, message: '所属母线必填!', trigger: 'blur' }],
|
||||
busbar : [{ required: true, message: '所属母线必选!', trigger: 'change' }],
|
||||
harmSysId : [{ required: true, message: '谐波系统检测点id必填!', trigger: 'blur' }],
|
||||
})
|
||||
|
||||
@@ -176,9 +198,10 @@ const resetFormContent = () => {
|
||||
|
||||
|
||||
// 打开弹窗,可能是新增,也可能是编辑
|
||||
const open = async (sign: string, data: Monitor.ResPqMon,device: Device.ResPqDev,table: any[]) => {
|
||||
const open = async (sign: string, data: Monitor.ResPqMon,device: Device.ResPqDev,table: any[],options: any) => {
|
||||
// 重置表单
|
||||
//dialogFormRef.value?.resetFields()
|
||||
selectOptions.value = options
|
||||
titleType.value = sign
|
||||
dialogVisible.value = true
|
||||
monitorTable.value = table|| []
|
||||
@@ -237,3 +260,7 @@ const resetFormContent = () => {
|
||||
defineExpose({ open })
|
||||
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
|
||||
@@ -34,7 +34,6 @@
|
||||
import { ref, defineProps, reactive, watch } from 'vue';
|
||||
import ProTable from '@/components/ProTable/index.vue'; // 假设 ProTable 是自定义组件
|
||||
import { CirclePlus, Delete, EditPen, MessageBox } from '@element-plus/icons-vue';
|
||||
|
||||
import MonitorPopup from '@/views/machine/device/components/monitorPopup.vue'
|
||||
import { ProTableInstance, type ColumnProps } from '@/components/ProTable/interface'
|
||||
import { type Monitor } from '@/api/device/interface/monitor'
|
||||
@@ -46,7 +45,8 @@
|
||||
// 定义 props
|
||||
const props = defineProps<{
|
||||
DevFormContent:Device.ResPqDev,
|
||||
tableHeight?: number // 接收外部传入的高度
|
||||
tableHeight?: number, // 接收外部传入的高度
|
||||
selectOptions: Record<string, Device.SelectOption[]>,
|
||||
}>();
|
||||
|
||||
// ProTable 实例
|
||||
@@ -139,7 +139,7 @@ const getParameter = (data: Monitor.ResPqMon) => {
|
||||
return
|
||||
}
|
||||
title_Type.value = titleType
|
||||
monitorPopup.value?.open(titleType, row,props.DevFormContent,tableData.value)
|
||||
monitorPopup.value?.open(titleType, row,props.DevFormContent,tableData.value,props.selectOptions)
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -93,11 +93,7 @@ const columns = reactive<ColumnProps<Device.ResPqDev>[]>([
|
||||
prop: 'devType',
|
||||
label: '设备类型',
|
||||
minWidth: 200,
|
||||
render: (scope) => {
|
||||
// 查找设备类型名称
|
||||
const name = devTypeOptions.value.find(option => option.id === scope.row.devType)
|
||||
return <span>{name?.name}</span>
|
||||
},
|
||||
|
||||
},
|
||||
{
|
||||
prop: 'createDate',
|
||||
@@ -248,6 +244,7 @@ const importFile = async (pattern: string) => {
|
||||
title: '被检设备',
|
||||
showCover: false,
|
||||
patternId: dictStore.getDictData('Pattern').find(item => item.name === modeStore.currentMode)?.id,
|
||||
planId: null,
|
||||
tempApi: downloadTemplate,
|
||||
importApi: importPqDev,
|
||||
// importApi: modeStore.currentMode === "比对式"? importContrastPqDev: importCNDev,
|
||||
|
||||
@@ -32,16 +32,7 @@
|
||||
|
||||
<el-divider >参数信息</el-divider>
|
||||
|
||||
<el-form-item label='可检通道数' prop='inspectChannel' :label-width='100'>
|
||||
<el-select v-model="formContent.inspectChannel" multiple collapse-tags :max-collapse-tags="4" placeholder="请选择可检通道数" clearable>
|
||||
<el-option
|
||||
v-for="(option, index) in pqChannelArray"
|
||||
:key="index"
|
||||
:label="option.label"
|
||||
:value="option.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label='通讯协议' prop='protocol'>
|
||||
<el-select v-model="formContent.protocol" clearable placeholder="请选择通讯协议">
|
||||
<el-option
|
||||
@@ -58,6 +49,16 @@
|
||||
</el-form-item>
|
||||
<el-form-item label="端口号" prop="port" placeholder="请输入端口号" >
|
||||
<el-input v-model="formContent.port" />
|
||||
</el-form-item>
|
||||
<el-form-item label='可检通道数' prop='inspectChannel' >
|
||||
<el-select v-model="formContent.inspectChannel" multiple collapse-tags :max-collapse-tags="4" placeholder="请选择可检通道数" clearable>
|
||||
<el-option
|
||||
v-for="(option, index) in pqChannelArray"
|
||||
:key="index"
|
||||
:label="option.label"
|
||||
:value="option.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label='是否加密' prop='encryptionFlag' >
|
||||
<el-select v-model="formContent.encryptionFlag" clearable placeholder="请选择是否加密">
|
||||
@@ -258,7 +259,7 @@ const open = async (sign: string, data: StandardDevice.ResPqStandardDevice,devTy
|
||||
if (typeof formContent.inspectChannel === 'string') {
|
||||
formContent.inspectChannel = formContent.inspectChannel.split(',').filter(Boolean)
|
||||
}
|
||||
handleDevTypeChange(data.devType)
|
||||
//handleDevTypeChange(data.devType)
|
||||
} else {
|
||||
resetFormContent()
|
||||
}
|
||||
@@ -279,6 +280,10 @@ const handleDevTypeChange = (value: string) => {
|
||||
label: String(i + 1),
|
||||
}))
|
||||
|
||||
//if(titleType.value == 'add') // 默认全选所有通道
|
||||
formContent.inspectChannel = pqChannelArray.value.map(channel => channel.value)
|
||||
|
||||
|
||||
// 过滤掉超出新通道数范围的选项
|
||||
if (Array.isArray(formContent.inspectChannel)) {
|
||||
formContent.inspectChannel = formContent.inspectChannel.filter(
|
||||
|
||||
@@ -206,7 +206,6 @@ const importFile = async () => {
|
||||
importApi: importPqStandardDev,
|
||||
getTableList: proTable.value?.getTableList,
|
||||
}
|
||||
console.log(params)
|
||||
deviceImportExcel.value?.acceptParams(params)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,330 +0,0 @@
|
||||
<!--单列-->
|
||||
<template>
|
||||
<el-dialog
|
||||
class="table-box"
|
||||
v-model="dialogVisible"
|
||||
top="114px"
|
||||
:style="{ height: height + 'px', maxHeight: height + 'px', overflow: 'hidden' }"
|
||||
:title="title"
|
||||
:width="width"
|
||||
:modal="false"
|
||||
>
|
||||
<div
|
||||
class="table-box"
|
||||
:style="{ height: height - 64 + 'px', maxHeight: height - 64 + 'px', overflow: 'hidden' }"
|
||||
>
|
||||
<div style="margin-bottom: 20px">
|
||||
<el-button type="primary" :icon="CirclePlus" @click="addTab(editableTabsValue)">新增计划</el-button>
|
||||
</div>
|
||||
<el-tabs
|
||||
v-model="editableTabsValue"
|
||||
type="card"
|
||||
class="demo-tabs"
|
||||
closable
|
||||
@tab-remove="removeTab"
|
||||
>
|
||||
<el-tab-pane
|
||||
v-for="item in editableTabs"
|
||||
:key="item.name"
|
||||
:label="item.title"
|
||||
:name="item.name"
|
||||
>
|
||||
<ProTable
|
||||
ref="proTable"
|
||||
:columns="item.columns"
|
||||
:data="item.tableData"
|
||||
type="selection"
|
||||
style="height: 750px;"
|
||||
>
|
||||
<!-- 表格 header 按钮 -->
|
||||
<template #tableHeader="scope">
|
||||
<el-button type="primary" :icon="Delete" v-if="item.name == '1'">
|
||||
新增
|
||||
</el-button>
|
||||
<el-button type="primary" :icon="Delete" v-if="item.name != '1'">
|
||||
导出检测方案
|
||||
</el-button>
|
||||
<el-button type="primary" :icon="Delete" >
|
||||
导入检测结果
|
||||
</el-button>
|
||||
<el-button type="danger" :icon="Delete" plain :disabled="!scope.isSelected">
|
||||
批量移除
|
||||
</el-button>
|
||||
</template>
|
||||
<!-- 表格操作 -->
|
||||
<template #operation="scope">
|
||||
<el-button type="primary" link :icon="Delete" v-if="item.name == '1'">删除</el-button>
|
||||
<el-button type="primary" link :icon="Delete" v-if="item.name != '1'">移除</el-button>
|
||||
</template>
|
||||
</ProTable>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</template>
|
||||
<script setup lang="tsx">
|
||||
import { TabPaneName } from 'element-plus'
|
||||
import { ref, reactive } from 'vue'
|
||||
import { CirclePlus, Delete } from '@element-plus/icons-vue'
|
||||
const sourceDataList = [
|
||||
{
|
||||
id: 'device1',
|
||||
name:"电能质量监测仪A001",
|
||||
type:"PQS-882A",
|
||||
date:"2022-05-05",
|
||||
channel: "2",
|
||||
vol: "57.74",
|
||||
cur: "5",
|
||||
company: "南京灿能",
|
||||
state: 0,
|
||||
check:1,
|
||||
},
|
||||
{
|
||||
id: 'device2',
|
||||
name:"电能质量监测仪A002",
|
||||
type:"PQS-882B4",
|
||||
date:"2022-05-05",
|
||||
channel: "4",
|
||||
vol: "57.74",
|
||||
cur: "5",
|
||||
company: "南京灿能",
|
||||
state: 1,
|
||||
check:2,
|
||||
},
|
||||
{
|
||||
id: 'device3',
|
||||
name:"电能质量监测仪A003",
|
||||
type:"PQS-882B4",
|
||||
date:"2022-05-05",
|
||||
channel: "4",
|
||||
vol: "57.74",
|
||||
cur: "5",
|
||||
company: "南京灿能",
|
||||
state: 1,
|
||||
check:2,
|
||||
},
|
||||
]
|
||||
const sourceDataList2 = [
|
||||
{
|
||||
id: 'device1',
|
||||
name:"电能质量监测仪A003",
|
||||
type:"PQS-882A",
|
||||
date:"2022-05-05",
|
||||
channel: "2",
|
||||
vol: "57.74",
|
||||
cur: "5",
|
||||
company: "南京灿能",
|
||||
state: 0,
|
||||
check:1,
|
||||
},
|
||||
]
|
||||
// 初始数据源
|
||||
const SourceData = sourceDataList
|
||||
const SourceData2 = sourceDataList2
|
||||
// 控制弹窗显示与标题
|
||||
const dialogVisible = ref(false)
|
||||
const title = ref('')
|
||||
const planTitle = ref('')
|
||||
// tab 相关
|
||||
let tabIndex = 2
|
||||
const editableTabsValue = ref('2')
|
||||
const editableTabs = ref([
|
||||
{
|
||||
title: planTitle,
|
||||
name: '1',
|
||||
content: 'Tab 1 content',
|
||||
tableData: [...SourceData],
|
||||
columns: [
|
||||
{ type: 'selection', fixed: 'left', width: 70 },
|
||||
{ type: 'index', fixed: 'left', width: 70, label: '序号' },
|
||||
{
|
||||
prop: 'name',
|
||||
label: '名称',
|
||||
search: { el: 'input' },
|
||||
minWidth: 180,
|
||||
},
|
||||
{
|
||||
prop: 'type',
|
||||
label: '设备类型',
|
||||
search: { el: 'select' },
|
||||
minWidth: 150,
|
||||
},
|
||||
{
|
||||
prop: 'date',
|
||||
label: '出厂日期',
|
||||
search: { el: 'select' },
|
||||
minWidth: 150,
|
||||
},
|
||||
{
|
||||
prop: 'channel',
|
||||
label: '通道数',
|
||||
search: { el: 'select' },
|
||||
minWidth: 100,
|
||||
},
|
||||
{
|
||||
prop: 'vol',
|
||||
label: '额定电压V',
|
||||
search: { el: 'select' },
|
||||
minWidth: 150,
|
||||
},
|
||||
{
|
||||
prop: 'cur',
|
||||
label: '额定电流A',
|
||||
search: { el: 'select' },
|
||||
minWidth: 150,
|
||||
},
|
||||
{
|
||||
prop: 'company',
|
||||
label: '设备厂家',
|
||||
search: { el: 'select' },
|
||||
minWidth: 150,
|
||||
|
||||
},
|
||||
{
|
||||
prop: 'state',
|
||||
label: '分配状态',
|
||||
search: { el: 'select' },
|
||||
minWidth: 150,
|
||||
render: () => {
|
||||
return (
|
||||
<el-tag type='success' effect="dark">已分配</el-tag>
|
||||
)
|
||||
},
|
||||
},
|
||||
{
|
||||
prop: 'check',
|
||||
label: '检测状态',
|
||||
search: { el: 'select' },
|
||||
minWidth: 150,
|
||||
render: (scope: { row: { check: number } }) => {
|
||||
return (
|
||||
scope.row.check === 0 ? <el-tag type='warning' effect="dark">未检</el-tag> :
|
||||
scope.row.check === 1 ? <el-tag type='danger' effect="dark">检测中</el-tag> :
|
||||
<el-tag type='success' effect="dark">检测完成</el-tag>
|
||||
)
|
||||
},
|
||||
},
|
||||
{ prop: 'operation', label: '操作', fixed: 'right', width: 100 },
|
||||
],
|
||||
},
|
||||
{
|
||||
title: '子计划',
|
||||
name: '2',
|
||||
content: 'Tab 2 content',
|
||||
tableData: [...SourceData2],
|
||||
columns: [
|
||||
{ type: 'selection', fixed: 'left', width: 70 },
|
||||
{ type: 'index', fixed: 'left', width: 70, label: '序号' },
|
||||
{
|
||||
prop: 'name',
|
||||
label: '名称',
|
||||
search: { el: 'input' },
|
||||
minWidth: 180,
|
||||
},
|
||||
{
|
||||
prop: 'type',
|
||||
label: '设备类型',
|
||||
search: { el: 'select' },
|
||||
minWidth: 150,
|
||||
},
|
||||
{
|
||||
prop: 'date',
|
||||
label: '出厂日期',
|
||||
search: { el: 'select' },
|
||||
minWidth: 150,
|
||||
},
|
||||
{
|
||||
prop: 'channel',
|
||||
label: '通道数',
|
||||
search: { el: 'select' },
|
||||
minWidth: 100,
|
||||
},
|
||||
{
|
||||
prop: 'vol',
|
||||
label: '额定电压V',
|
||||
search: { el: 'select' },
|
||||
minWidth: 150,
|
||||
},
|
||||
{
|
||||
prop: 'cur',
|
||||
label: '额定电流A',
|
||||
search: { el: 'select' },
|
||||
minWidth: 150,
|
||||
},
|
||||
{
|
||||
prop: 'company',
|
||||
label: '设备厂家',
|
||||
search: { el: 'select' },
|
||||
minWidth: 150,
|
||||
|
||||
},
|
||||
{
|
||||
prop: 'check',
|
||||
label: '检测状态',
|
||||
search: { el: 'select' },
|
||||
minWidth: 150,
|
||||
render: (scope: { row: { check: number } }) => {
|
||||
return (
|
||||
scope.row.check === 0 ? <el-tag type='warning' effect="dark">未检</el-tag> :
|
||||
scope.row.check === 1 ? <el-tag type='danger' effect="dark">检测中</el-tag> :
|
||||
<el-tag type='success' effect="dark">检测完成</el-tag>
|
||||
)
|
||||
},
|
||||
},
|
||||
{ prop: 'operation', label: '操作', fixed: 'right', width: 100 },
|
||||
],
|
||||
},
|
||||
])
|
||||
|
||||
// 新增 tab 方法
|
||||
const addTab = (targetName: string) => {
|
||||
const newTabName = `${++tabIndex}`
|
||||
editableTabs.value.push({
|
||||
title: '子计划',
|
||||
name: newTabName,
|
||||
content: 'New Tab content',
|
||||
tableData: [], // 每个 tab 独立的数据副本
|
||||
columns: [...editableTabs.value[0].columns], // 复用已有列配置
|
||||
})
|
||||
editableTabsValue.value = newTabName
|
||||
}
|
||||
|
||||
// 删除 tab 方法
|
||||
const removeTab = (targetName: TabPaneName) => {
|
||||
const tabs = editableTabs.value
|
||||
let activeName = editableTabsValue.value
|
||||
if (activeName === targetName) {
|
||||
tabs.forEach((tab, index) => {
|
||||
if (tab.name === targetName) {
|
||||
const nextTab = tabs[index + 1] || tabs[index - 1]
|
||||
if (nextTab) {
|
||||
activeName = nextTab.name
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
editableTabsValue.value = activeName
|
||||
editableTabs.value = tabs.filter((tab) => tab.name !== targetName)
|
||||
}
|
||||
|
||||
// 弹窗打开方法
|
||||
const open = (textTitle: string,planName: string) => {
|
||||
dialogVisible.value = true
|
||||
title.value = textTitle
|
||||
planTitle.value = planName
|
||||
}
|
||||
defineExpose({ open })
|
||||
|
||||
// props
|
||||
const props = defineProps({
|
||||
width: {
|
||||
type: Number,
|
||||
default: 800,
|
||||
},
|
||||
height: {
|
||||
type: Number,
|
||||
default: 744,
|
||||
},
|
||||
})
|
||||
</script>
|
||||
436
frontend/src/views/plan/planList/components/childrenPlan.vue
Normal file
436
frontend/src/views/plan/planList/components/childrenPlan.vue
Normal file
@@ -0,0 +1,436 @@
|
||||
<!--单列-->
|
||||
<template>
|
||||
<el-dialog
|
||||
class="table-box"
|
||||
v-model="dialogVisible"
|
||||
top="114px"
|
||||
:style="{ height: height + 'px', maxHeight: height + 'px', overflow: 'hidden' }"
|
||||
:title="title"
|
||||
:width="width"
|
||||
:modal="false"
|
||||
>
|
||||
<div
|
||||
class="table-box"
|
||||
:style="{ height: height - 64 + 'px', maxHeight: height - 64 + 'px', overflow: 'hidden' }"
|
||||
>
|
||||
<el-tabs
|
||||
v-model="editableTabsValue"
|
||||
type="card"
|
||||
@tab-remove="removeTab"
|
||||
@tab-click="handleTabClick"
|
||||
>
|
||||
<el-tab-pane
|
||||
v-for="item in editableTabs"
|
||||
:key="item.name"
|
||||
:label="item.title"
|
||||
:name="item.name"
|
||||
:closable="item.closable"
|
||||
>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
<ProTable
|
||||
ref="proTable"
|
||||
:columns="columns"
|
||||
:request-api="getTableList"
|
||||
type="selection"
|
||||
>
|
||||
<!-- 表格 header 按钮 -->
|
||||
<template #tableHeader="scope">
|
||||
<el-button type="primary" :icon="CirclePlus" @click="addTab('add')" v-if="!isTabPlanFather">
|
||||
新增子计划
|
||||
</el-button>
|
||||
<el-button type="primary" :icon="CirclePlus" @click="addTab('edit')" v-if="isTabPlanFather">
|
||||
编辑子计划
|
||||
</el-button>
|
||||
<el-button type="primary" :icon="Upload" >
|
||||
导出检测方案
|
||||
</el-button>
|
||||
<el-button type="primary" :icon="Download" >
|
||||
导入检测结果
|
||||
</el-button>
|
||||
<el-button type="danger" :icon="Delete" plain :disabled="!scope.isSelected">
|
||||
批量移除
|
||||
</el-button>
|
||||
<el-dropdown trigger="hover" placement="right-start" :disabled="!scope.isSelected">
|
||||
<el-button type="primary" :icon="ScaleToOriginal" style="margin-left: 10px;" v-if="!isTabPlanFather" :disabled="!scope.isSelected">
|
||||
分配被检设备
|
||||
</el-button>
|
||||
<template #dropdown >
|
||||
<el-dropdown-menu>
|
||||
<el-dropdown-item
|
||||
v-for="child in planFormContent?.children"
|
||||
:key="child.id"
|
||||
@click="distribute(child,scope)"
|
||||
>
|
||||
{{ child.name }}
|
||||
</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</template>
|
||||
</el-dropdown>
|
||||
<el-dropdown trigger="hover" placement="right-start">
|
||||
<el-button type="primary" :icon="ScaleToOriginal" style="margin-left: 10px;" v-if="!isTabPlanFather">
|
||||
标准设备管理
|
||||
</el-button>
|
||||
<template #dropdown >
|
||||
<el-dropdown-menu>
|
||||
<el-dropdown-item
|
||||
v-for="child in planFormContent?.children"
|
||||
:key="child.id"
|
||||
@click="allotStandardDev(child)"
|
||||
>
|
||||
{{ child.name }}
|
||||
</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</template>
|
||||
</el-dropdown>
|
||||
</template>
|
||||
<!-- 表格操作 -->
|
||||
<template #operation="">
|
||||
<el-button type="primary" link :icon="Delete" v-if="!isTabPlanFather">删除</el-button>
|
||||
<el-button type="primary" link :icon="Delete" v-if="isTabPlanFather">移除</el-button>
|
||||
</template>
|
||||
</ProTable>
|
||||
</div>
|
||||
</el-dialog>
|
||||
<!-- 向计划导入/导出设备对话框 -->
|
||||
<PlanPopup :refresh-table='proTable?.getTableList' ref='planPopup' @update:tab="addNewChildTab"/>
|
||||
<DevTransfer ref='devTransfer' />
|
||||
</template>
|
||||
<script setup lang="tsx">
|
||||
import { ElMessage, ElMessageBox, TabPaneName } from 'element-plus'
|
||||
import { ref, computed, watch, reactive } from 'vue'
|
||||
import { ScaleToOriginal, CirclePlus, Delete, Upload, Download } from '@element-plus/icons-vue'
|
||||
import PlanPopup from '@/views/plan/planList/components/planPopup.vue' // 导入子组件
|
||||
import { Plan } from '@/api/plan/interface'
|
||||
import {useModeStore } from '@/stores/modules/mode'; // 引入模式 store
|
||||
import { ColumnProps, ProTableInstance, SearchRenderScope } from '@/components/ProTable/interface'
|
||||
import {getDevListByPlanId ,subPlanBindDev} from '@/api/plan/plan'
|
||||
import { Device } from '@/api/device/interface/device'
|
||||
import { useDictStore } from '@/stores/modules/dict'
|
||||
import DevTransfer from '@/views/plan/planList/components/devTransfer.vue'
|
||||
|
||||
const dictStore = useDictStore()
|
||||
const planFormContent = ref<Plan.ReqPlan>()
|
||||
const proTable = ref<ProTableInstance>()
|
||||
const modeStore = useModeStore();
|
||||
const planPopup = ref()
|
||||
const devTransfer = ref()
|
||||
|
||||
// 控制弹窗显示与标题
|
||||
const dialogVisible = ref(false)
|
||||
const title = ref('')
|
||||
const planTitle = ref('')
|
||||
// tab 相关
|
||||
const editableTabsValue = ref('0')
|
||||
const isTabPlanFather = ref(true)
|
||||
const planId = ref('')
|
||||
const getTableList = async (params: any) => {
|
||||
if (!planFormContent.value) {
|
||||
return Promise.resolve({ data: [], total: 0 });
|
||||
}
|
||||
let newParams = JSON.parse(JSON.stringify(params));
|
||||
const patternId = dictStore.getDictData('Pattern').find(item => item.name === modeStore.currentMode)?.id//获取数据字典中对应的id
|
||||
newParams.pattern = patternId
|
||||
if(!isTabPlanFather.value)
|
||||
newParams.planId = planFormContent.value.id
|
||||
else
|
||||
newParams.planId = planId.value
|
||||
newParams.planIdList = [newParams.planId];
|
||||
proTable.value?.clearSelection()
|
||||
return getDevListByPlanId(newParams);
|
||||
}
|
||||
|
||||
|
||||
const columns = reactive<ColumnProps<Device.ResPqDev>[]>([
|
||||
{ type: 'selection', fixed: 'left', width: 70 },
|
||||
{ type: 'index', fixed: 'left', width: 70, label: '序号' },
|
||||
{
|
||||
prop: 'name',
|
||||
label: '名称',
|
||||
search: { el: 'input' },
|
||||
minWidth: 180,
|
||||
},
|
||||
{
|
||||
prop: 'devType',
|
||||
label: '设备类型',
|
||||
minWidth: 150,
|
||||
},
|
||||
{
|
||||
prop: 'createDate',
|
||||
label: '出厂日期',
|
||||
minWidth: 150,
|
||||
},
|
||||
{
|
||||
prop: 'devChns',
|
||||
label: '通道数',
|
||||
minWidth: 100,
|
||||
},
|
||||
{
|
||||
prop: 'devVolt',
|
||||
label: '额定电压V',
|
||||
minWidth: 150,
|
||||
},
|
||||
{
|
||||
prop: 'devCurr',
|
||||
label: '额定电流A',
|
||||
minWidth: 150,
|
||||
},
|
||||
{
|
||||
prop: 'manufacturer',
|
||||
label: '设备厂家',
|
||||
enum: dictStore.getDictData('Dev_Manufacturers'),
|
||||
search: {el: 'select', props: {filterable: true}, order: 1},
|
||||
fieldNames: {label: 'name', value: 'id'},
|
||||
minWidth: 200,
|
||||
},
|
||||
{
|
||||
prop: 'cityName',
|
||||
label: '地市',
|
||||
minWidth: 150,
|
||||
|
||||
},
|
||||
{
|
||||
prop: 'region',
|
||||
label: '地市',
|
||||
minWidth: 150,
|
||||
isShow:false,
|
||||
search: {
|
||||
el: 'input',
|
||||
label :'关键词',
|
||||
render: (scope: SearchRenderScope) => {
|
||||
return (
|
||||
<el-input
|
||||
v-model={scope.searchParam.region}
|
||||
placeholder="请输入关键词"
|
||||
clearable
|
||||
/>
|
||||
);
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
prop: 'gdName',
|
||||
label: '供电公司',
|
||||
minWidth: 150,
|
||||
},
|
||||
{
|
||||
prop: 'subName',
|
||||
label: '变电站',
|
||||
minWidth: 150,
|
||||
},
|
||||
{
|
||||
prop: 'boundPlanName',
|
||||
label: '子计划',
|
||||
minWidth: 150,
|
||||
isShow: isTabPlanFather.value,
|
||||
render: (scope) => {
|
||||
console.log('boundPlanName', isTabPlanFather.value)
|
||||
const value = scope.row.boundPlanName;
|
||||
if (!value) {
|
||||
return '/'; // 空值直接返回空字符串
|
||||
}
|
||||
return (
|
||||
<el-link type='primary' link onClick={() => unbindDevice(scope.row)}>
|
||||
{value}
|
||||
</el-link>
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
prop: 'checkState',
|
||||
label: '检测状态',
|
||||
minWidth: 150,
|
||||
render: (scope: { row: { checkState: number } }) => {
|
||||
return (
|
||||
scope.row.checkState === 0 ? <el-tag type='warning' effect="dark">未检</el-tag> :
|
||||
scope.row.checkState === 1 ? <el-tag type='danger' effect="dark">检测中</el-tag> :
|
||||
<el-tag type='success' effect="dark">检测完成</el-tag>
|
||||
)
|
||||
},
|
||||
},
|
||||
{ prop: 'operation', label: '操作', fixed: 'right', width: 100 },
|
||||
])
|
||||
|
||||
|
||||
|
||||
const editableTabs = computed(() => {
|
||||
console.log('editableTabs',planFormContent.value)
|
||||
const tabs = []
|
||||
// 主计划 tab
|
||||
if (planFormContent.value) {
|
||||
tabs.push({
|
||||
title: planFormContent.value.name,
|
||||
name: planFormContent.value.id,
|
||||
closable: false
|
||||
})
|
||||
}
|
||||
// 子计划 tabs
|
||||
if (planFormContent.value?.children?.length > 0) {
|
||||
planFormContent.value.children.forEach((child, index) => {
|
||||
tabs.push({
|
||||
title: child.name,
|
||||
name: child.id,
|
||||
closable: true
|
||||
})
|
||||
})
|
||||
}
|
||||
return tabs
|
||||
})
|
||||
|
||||
const unbindDevice = (row: any) => {
|
||||
if(row.state == '/')
|
||||
return
|
||||
ElMessageBox.confirm(`确定将设备 ${row.name} 从子计划中解绑吗?`, '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(async () => {
|
||||
await subPlanBindDev({'planId': row.planId, 'devIds': [row.id] ,'bindFlag': 0}) //解绑 0 绑定 1
|
||||
// 👇 更新数据(例如清空 state 字段)
|
||||
row.state = '/'
|
||||
proTable.value?.getTableList()
|
||||
// 可选:刷新表格或提交接口
|
||||
ElMessage.success('解绑成功')
|
||||
}).catch(() => {
|
||||
// 用户取消操作
|
||||
})
|
||||
}
|
||||
|
||||
// 新增 tab 方法
|
||||
const addTab = (type: string) => {
|
||||
if(type === "add"){
|
||||
planPopup.value?.open("edit", planFormContent.value,modeStore.currentMode,1)
|
||||
}else {
|
||||
const subPlanFormContent = ref<Plan.ReqPlan>()
|
||||
// 从 planFormContent.value?.children 中找到 id 与 item.name 匹配的子计划
|
||||
subPlanFormContent.value = planFormContent.value?.children?.find(
|
||||
(child: Plan.ReqPlan) => child.id === planId.value
|
||||
)
|
||||
console.log('0000---',subPlanFormContent.value)
|
||||
planPopup.value?.open("edit", subPlanFormContent.value,modeStore.currentMode,2)
|
||||
}
|
||||
}
|
||||
|
||||
//收到子组件回复后新增子计划tab
|
||||
const addNewChildTab = async () => {
|
||||
await props.refreshTable!()//刷新检测计划列表
|
||||
}
|
||||
|
||||
|
||||
const distribute = (childPlan: Plan.ResPlan, scope: any) => {
|
||||
|
||||
ElMessageBox.confirm(`确定将以下被检设备分配给 ${childPlan.name} 吗?`, '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning',
|
||||
}).then(async () => {
|
||||
await subPlanBindDev({'planId': childPlan.id, 'devIds': scope.selectedListIds ,'bindFlag': 1}) //解绑 0 绑定 1
|
||||
proTable.value?.getTableList()
|
||||
ElMessage.success('分配成功')
|
||||
}).catch(() => {
|
||||
// 用户取消操作
|
||||
})
|
||||
}
|
||||
|
||||
const allotStandardDev = (childPlan: Plan.ResPlan) => {
|
||||
devTransfer.value.open(childPlan)
|
||||
}
|
||||
|
||||
// 删除 tab 方法
|
||||
const removeTab = (targetName: TabPaneName) => {
|
||||
// 👇 添加 ElMessageBox 确认删除
|
||||
ElMessageBox.confirm('确定要删除该计划吗?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning',
|
||||
}).then(() => {
|
||||
const tabs = editableTabs.value
|
||||
let activeName = editableTabsValue.value
|
||||
|
||||
if (activeName === targetName) {
|
||||
tabs.forEach((tab, index) => {
|
||||
if (tab.name === targetName) {
|
||||
const nextTab = tabs[index + 1] || tabs[index - 1]
|
||||
if (nextTab) {
|
||||
activeName = nextTab.name
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
editableTabsValue.value = activeName
|
||||
editableTabs.value = tabs.filter((tab) => tab.name !== targetName)
|
||||
|
||||
// 可选:删除后提示成功
|
||||
ElMessage.success('删除成功')
|
||||
}).catch(() => {
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
// 弹窗打开方法
|
||||
const open = async (textTitle: string,data: Plan.ReqPlan) => {
|
||||
dialogVisible.value = true
|
||||
title.value = textTitle
|
||||
planTitle.value = data.name
|
||||
planId.value = data.id
|
||||
planFormContent.value = data
|
||||
console.log('弹窗打开方法',planFormContent.value)
|
||||
|
||||
}
|
||||
|
||||
const handleTabClick = (tab:any) => {
|
||||
if(tab.props.closable){
|
||||
isTabPlanFather.value = true
|
||||
}else{
|
||||
isTabPlanFather.value = false
|
||||
}
|
||||
planId.value = tab.props.name
|
||||
console.log('handleTabClick',tab)
|
||||
proTable.value?.getTableList()
|
||||
}
|
||||
|
||||
const handleTableDataUpdate = async (newData: any[]) => {
|
||||
// 👇 处理新数据,例如更新 planFormContent
|
||||
console.log('handleTableDataUpdate', newData)
|
||||
const matchedItem = findItemById(newData, planId.value);
|
||||
if (matchedItem) {
|
||||
planFormContent.value = matchedItem
|
||||
console.log('递归匹配成功:', planFormContent.value)
|
||||
} else {
|
||||
console.warn('未找到匹配的 planId:', planId.value)
|
||||
}
|
||||
}
|
||||
|
||||
const findItemById = (data: any[], id: string): any => {
|
||||
for (const item of data) {
|
||||
if (item.id === id) {
|
||||
return item; // 找到匹配项,返回它
|
||||
}
|
||||
if (item.children && item.children.length > 0) {
|
||||
const result = findItemById(item.children, id); // 递归查找子项
|
||||
if (result) {
|
||||
return item; // 如果子项中找到,返回结果
|
||||
}
|
||||
}
|
||||
}
|
||||
return null; // 未找到匹配项
|
||||
};
|
||||
|
||||
|
||||
|
||||
defineExpose({ open,handleTableDataUpdate })
|
||||
|
||||
const props = defineProps<{
|
||||
refreshTable: (() => Promise<void>) | undefined;
|
||||
width: {
|
||||
type: Number,
|
||||
default: 800,
|
||||
},
|
||||
height: {
|
||||
type: Number,
|
||||
default: 744,
|
||||
},
|
||||
}>()
|
||||
</script>
|
||||
@@ -29,28 +29,25 @@
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { computed, ref } from 'vue'
|
||||
import type { Device } from '@/api/device/interface'
|
||||
import deviceDataList from '@/api/device/deviceData'
|
||||
import type { StandardDevice } from '@/api/device/interface/standardDevice'
|
||||
import { dialogBig } from '@/utils/elementBind'
|
||||
import { getUnboundPqDevList,getBoundPqDevList } from '@/api/plan/plan.ts'
|
||||
import { getBoundStandardDevList,getUnboundStandardDevList } from '@/api/plan/plan.ts'
|
||||
import { type Plan } from '@/api/plan/interface'
|
||||
import { ElMessage } from 'element-plus'
|
||||
const unboundPqDevList=ref<Device.ReqPqDevParams[]>([])//指定模式下所有未绑定的设备
|
||||
const boundPqDevList=ref<Device.ReqPqDevParams[]>([])//根据检测计划id查询出所有已绑定的设备
|
||||
const unboundStandardDevList=ref<StandardDevice.ResPqStandardDevice[]>([])//指定模式下所有未绑定的标准设备
|
||||
const boundStandardDevList=ref<StandardDevice.ResPqStandardDevice[]>([])//根据检测计划id查询出所有已绑定的标准设备
|
||||
const dialogVisible = ref(false)
|
||||
const planData = ref<Plan.ReqPlan | null>(null) // 新增状态管理
|
||||
const planData = ref<Plan.ResPlan | null>(null) // 新增状态管理
|
||||
|
||||
const value = ref<string[]>([])
|
||||
const generateData = () => {
|
||||
const unboundData = unboundPqDevList.value.map((i: Device.ReqPqDevParams) => ({
|
||||
const unboundData = unboundStandardDevList.value.map((i: StandardDevice.ResPqStandardDevice) => ({
|
||||
key: i.id,
|
||||
label: i.name,
|
||||
tips: i.description
|
||||
}))
|
||||
const boundData = boundPqDevList.value.map((i: Device.ReqPqDevParams) => ({
|
||||
const boundData = boundStandardDevList.value.map((i: StandardDevice.ResPqStandardDevice) => ({
|
||||
key: i.id,
|
||||
label: i.name,
|
||||
tips: i.description
|
||||
}))
|
||||
|
||||
return [...unboundData, ...boundData]
|
||||
@@ -65,20 +62,15 @@ const filterMethod = (query: string, item: { label?: string }) => {
|
||||
}
|
||||
|
||||
// 打开弹窗,可能是新增,也可能是编辑
|
||||
const open = async (data: Plan.ReqPlan) => {
|
||||
const open = async (data: Plan.ResPlan) => {
|
||||
dialogVisible.value = true
|
||||
planData.value = data
|
||||
console.log('planData.value',planData.value)
|
||||
const standardDevList_Result1 = await getUnboundStandardDevList(data);
|
||||
unboundStandardDevList.value = standardDevList_Result1.data as StandardDevice.ResPqStandardDevice[];
|
||||
|
||||
//console.log('123')
|
||||
|
||||
const pqDevList_Result1 = await getUnboundPqDevList(data);
|
||||
unboundPqDevList.value = pqDevList_Result1.data as Device.ReqPqDevParams[];
|
||||
|
||||
const pqDevList_Result2 = await getBoundPqDevList({'planId': data.id});
|
||||
boundPqDevList.value = pqDevList_Result2.data as Device.ReqPqDevParams[];
|
||||
|
||||
value.value = boundPqDevList.value.map((i: { id: { toString: () => any } }) => i.id.toString());
|
||||
//console.log('123',value.value)
|
||||
const standardDevList_Result2 = await getBoundStandardDevList(data);
|
||||
boundStandardDevList.value = standardDevList_Result2.data as StandardDevice.ResPqStandardDevice[];
|
||||
}
|
||||
const close = () => {
|
||||
dialogVisible.value = false
|
||||
@@ -87,15 +79,12 @@ const filterMethod = (query: string, item: { label?: string }) => {
|
||||
|
||||
const save = async () => {
|
||||
if (planData.value) {
|
||||
//await BindPqDevList({ 'planId': planData.value.id,'pqDevIds': value.value })
|
||||
ElMessage.success({ message: `设备绑定保存成功成功!` })
|
||||
ElMessage.success({ message: `标准设备绑定保存成功!` })
|
||||
}
|
||||
dialogVisible.value = false
|
||||
}
|
||||
|
||||
// 对外映射
|
||||
defineExpose({ open })
|
||||
const props = defineProps<{
|
||||
refreshTable: (() => Promise<void>) | undefined;
|
||||
}>()
|
||||
|
||||
</script>
|
||||
@@ -1,14 +1,34 @@
|
||||
<template>
|
||||
<!-- 基础信息弹出框 -->
|
||||
<el-dialog :title="dialogTitle" v-model='dialogVisible' @close="close" v-bind="dialogBig" align-center>
|
||||
<el-dialog :title="dialogTitle" v-model='dialogVisible' @close="close" v-bind="planType == 0 ? dialogBig : dialogMiddle" align-center>
|
||||
<div>
|
||||
<el-row :gutter="24">
|
||||
<el-col :span="12">
|
||||
<el-form :model="formContent" ref='dialogFormRef' :rules='rules'>
|
||||
<el-form-item label="名称" prop="name" :label-width="100">
|
||||
<el-col :span="planType == 0 ? 12 : 24">
|
||||
<el-form :model="formContent" ref='dialogFormRef' :rules='rules' >
|
||||
<el-form-item label="名称" prop="name" :label-width="110" >
|
||||
<el-input v-model="formContent.name" placeholder="请输入名称" autocomplete="off" maxlength="32" show-word-limit/>
|
||||
</el-form-item>
|
||||
<el-form-item label='检测源' prop='sourceIds' :label-width='100'>
|
||||
<el-form-item label='标准设备' prop='standardDevIdList' :label-width='110' v-if="selectByMode && planType == 0" >
|
||||
<el-select v-model="formContent.standardDevIdList" multiple collapse-tags :max-collapse-tags="2" :disabled="planType != 0" placeholder="请选择标准设备" clearable>
|
||||
<el-option
|
||||
v-for="option in pqStandardDevArray"
|
||||
:key="option.value"
|
||||
:label="option.label"
|
||||
:value="option.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label='测试项' prop='testItems' :label-width='110' v-if="selectByMode" >
|
||||
<el-select v-model="formContent.testItems" multiple collapse-tags :max-collapse-tags="3" :disabled="planType != 0" placeholder="请选择测试项" clearable>
|
||||
<el-option
|
||||
v-for="(option, index) in secondLevelOptions"
|
||||
:key="index"
|
||||
:label="option.label"
|
||||
:value="option.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label='检测源' prop='sourceIds' :label-width='110' v-if="!selectByMode">
|
||||
<el-select v-model="formContent.sourceIds" :multiple="selectByMode" collapse-tags placeholder="请选择检测源" clearable>
|
||||
<el-option
|
||||
v-for="(option, index) in pqSourceArray"
|
||||
@@ -18,8 +38,8 @@
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="数据源" prop="datasourceIds" :label-width="100">
|
||||
<el-select v-model="formContent.datasourceIds" :multiple="selectByMode" collapse-tags placeholder="请选择数据源" autocomplete="off" clearable>
|
||||
<el-form-item label="数据源" prop="datasourceIds" :label-width="110">
|
||||
<el-select v-model="formContent.datasourceIds" :multiple="selectByMode" :max-collapse-tags="2" :disabled="planType != 0" collapse-tags placeholder="请选择数据源" autocomplete="off" clearable @change="handleDataSourceChange">
|
||||
<el-option
|
||||
v-for="item in dictStore.getDictData(dataSourceType)"
|
||||
:key="item.id"
|
||||
@@ -28,7 +48,7 @@
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="检测脚本" prop="scriptId" :label-width="100">
|
||||
<el-form-item label="检测脚本" prop="scriptId" :label-width="110" v-if="!selectByMode">
|
||||
<el-select v-model="formContent.scriptId" placeholder="请选择检测脚本" autocomplete="off" :disabled="isSelectDisabled" clearable>
|
||||
<el-option
|
||||
v-for="(option, index) in pqScriptArray"
|
||||
@@ -38,7 +58,7 @@
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="误差体系" prop="errorSysId" :label-width="100">
|
||||
<el-form-item label="误差体系" prop="errorSysId" :label-width="110">
|
||||
<el-select v-model="formContent.errorSysId" placeholder="请选择误差体系" autocomplete="off" :disabled="isSelectDisabled" clearable>
|
||||
<el-option
|
||||
v-for="(option, index) in pqErrorArray"
|
||||
@@ -58,8 +78,8 @@
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="守时检测" :label-width="100" prop='timeCheck'>
|
||||
<el-radio-group v-model="formContent.timeCheck">
|
||||
<el-form-item label="守时检测" :label-width="110" prop='timeCheck' >
|
||||
<el-radio-group v-model="formContent.timeCheck" :disabled="planType != 0">
|
||||
<el-radio :value="1">是</el-radio>
|
||||
<el-radio :value="0">否</el-radio>
|
||||
</el-radio-group>
|
||||
@@ -70,8 +90,8 @@
|
||||
<el-radio :value="0">否</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item> -->
|
||||
<el-form-item label="模版名称" prop="reportTemplateName" :label-width="100" v-if="formContent.associateReport === 1">
|
||||
<el-select v-model="formContent.reportTemplateName" placeholder="请选择报告模版" autocomplete="off" >
|
||||
<el-form-item label="模版名称" prop="reportTemplateName" :label-width="110" v-if="formContent.associateReport === 1">
|
||||
<el-select v-model="formContent.reportTemplateName" placeholder="请选择报告模版" autocomplete="off" :disabled="planType != 0" >
|
||||
<el-option
|
||||
v-for="(option, index) in pqReportName"
|
||||
:key="index"
|
||||
@@ -80,10 +100,13 @@
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
</el-form>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-col :span="12" v-if="planType == 0">
|
||||
<div style="text-align: center; margin-bottom: -30px;">
|
||||
<el-button type='primary' v-auth.plan="'import'" :icon='Download'>导入</el-button>
|
||||
</div>
|
||||
|
||||
<el-transfer
|
||||
v-model="value"
|
||||
filterable
|
||||
@@ -108,20 +131,24 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import{ElMessage, type FormInstance,type FormItemRule}from'element-plus'
|
||||
import { defineProps, defineEmits, reactive,watch,ref, type Ref, computed } from 'vue';
|
||||
import { dialogBig} from '@/utils/elementBind'
|
||||
import{CascaderOption, ElMessage,type FormItemRule}from'element-plus'
|
||||
import { defineProps, reactive,ref, computed } from 'vue';
|
||||
import { dialogBig,dialogMiddle} from '@/utils/elementBind'
|
||||
import { type Plan } from '@/api/plan/interface';
|
||||
import { addPlan, updatePlan,getUnboundPqDevList,getBoundPqDevList,getPqErrSysList,getPqScriptList,getTestSourceList } from '@/api/plan/plan.ts'
|
||||
import { addPlan, updatePlan,getUnboundPqDevList,getBoundPqDevList,getPqErrSysList,getPqScriptList,getTestSourceList,updateSubPlanName } from '@/api/plan/plan.ts'
|
||||
import { useDictStore } from '@/stores/modules/dict'
|
||||
import { type TestSource } from '@/api/device/interface/testSource';
|
||||
import { type TestScript } from '@/api/device/interface/testScript';
|
||||
import { type ErrorSystem } from '@/api/device/interface/error';
|
||||
import { type Device } from '@/api/device/interface/device';
|
||||
import {getPqReportAllName,getPqReportAllVersion} from '@/api/device/report/index.ts'
|
||||
import {getPqReportAllName} from '@/api/device/report/index.ts'
|
||||
import {useAppSceneStore} from "@/stores/modules/mode";
|
||||
import { fromPairs } from 'lodash';
|
||||
import { el } from 'element-plus/es/locale';
|
||||
import {Download } from '@element-plus/icons-vue'
|
||||
import {getAllPqStandardDev} from '@/api/device/standardDevice/index.ts'
|
||||
import { StandardDevice } from '@/api/device/interface/standardDevice';
|
||||
import { Dict } from '@/api/system/dictionary/interface';
|
||||
import { getDictTreeByCode } from '@/api/system/dictionary/dictTree';
|
||||
import {getAllUser} from '@/api/user/user'
|
||||
|
||||
|
||||
const AppSceneStore = useAppSceneStore()
|
||||
@@ -131,25 +158,29 @@ import { el } from 'element-plus/es/locale';
|
||||
const mode = ref()
|
||||
const selectByMode = ref(true)
|
||||
const pqSourceList=ref<TestSource.ResTestSource[]>([])//获取指定模式下所有检测源
|
||||
const pqScriptList=ref<TestScript.ResTestScript[]>([])//获取指定模式下所有检测源
|
||||
const pqErrSysList=ref<ErrorSystem.ErrorSystemList[]>([])//获取指定模式下所有检测源
|
||||
const pqDevList=ref<Device.ResPqDev[]>([])//获取指定模式下所有检测源
|
||||
const pqScriptList=ref<TestScript.ResTestScript[]>([])//获取指定模式下所有检测脚本
|
||||
const pqErrSysList=ref<ErrorSystem.ErrorSystemList[]>([])//获取指定模式下所有误差体系
|
||||
const pqDevList=ref<Device.ResPqDev[]>([])//获取指定模式下所有被检设备
|
||||
const pqStandardDevList=ref<StandardDevice.ResPqStandardDevice[]>([])//获取指定模式下所有标准设备
|
||||
|
||||
const pqReportName = ref<{ name: string }[]>([])
|
||||
|
||||
|
||||
const pqSourceArray = ref<{ label: string; value: string; }[]>()
|
||||
const pqScriptArray = ref<{ label: string; value: string; }[]>()
|
||||
const pqErrorArray = ref<{ label: string; value: string; }[]>()
|
||||
const pqDevArray = ref<{ label: string; value: string; }[]>()
|
||||
|
||||
|
||||
const pqStandardDevArray = ref<{ label: string; value: string; }[]>()
|
||||
const secondLevelOptions: any[] = [];
|
||||
const userArray = ref<{ label: string; value: string; }[]>([])
|
||||
|
||||
const unboundPqDevList=ref<Device.ResPqDev[]>([])//指定模式下所有未绑定的设备
|
||||
const boundPqDevList=ref<Device.ResPqDev[]>([])//根据检测计划id查询出所有已绑定的设备
|
||||
const value = ref<string[]>([])
|
||||
const allData = computed(() => generateData())
|
||||
const isSelectDisabled = ref(false)
|
||||
const planType = ref<number>(0)
|
||||
|
||||
|
||||
const generateData = () => {
|
||||
const unboundData = unboundPqDevList.value.map((i: Device.ResPqDev) => ({
|
||||
key: i.id,
|
||||
@@ -160,7 +191,7 @@ const generateData = () => {
|
||||
key: i.id,
|
||||
label: i.name,
|
||||
//tips: i.description
|
||||
disabled:i.checkState != 0 ,
|
||||
disabled:i.checkState != 0 || i.assign == 1,
|
||||
}))
|
||||
return [...unboundData, ...boundData]
|
||||
}
|
||||
@@ -169,7 +200,6 @@ const filterMethod = (query: string, item: { label?: string }) => {
|
||||
return item.label?.toLowerCase().includes(query.toLowerCase()) ?? false
|
||||
}
|
||||
|
||||
|
||||
function useMetaInfo() {
|
||||
const dialogVisible = ref(false)
|
||||
const titleType = ref('add')
|
||||
@@ -198,6 +228,12 @@ const filterMethod = (query: string, item: { label?: string }) => {
|
||||
reportTemplateName:'',
|
||||
reportTemplateVersion:'',
|
||||
dataRule:'',
|
||||
standardDevNameStr:'',
|
||||
testItemNameStr:'',
|
||||
standardDevIdList:[],
|
||||
standardDevMap:new Map<string, number>(),
|
||||
testItems:[],
|
||||
Check_By:'',
|
||||
})
|
||||
return { dialogVisible, titleType, formContent }
|
||||
}
|
||||
@@ -232,17 +268,26 @@ const filterMethod = (query: string, item: { label?: string }) => {
|
||||
reportTemplateName:'',
|
||||
reportTemplateVersion:'',
|
||||
dataRule:'',
|
||||
standardDevNameStr:'',
|
||||
standardDevIdList:[],
|
||||
standardDevMap:new Map<string, number>(),
|
||||
testItemNameStr:'',
|
||||
testItems:[],
|
||||
Check_By:'',
|
||||
}
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
let dialogTitle = computed(() => {
|
||||
return titleType.value === 'add' ? '新增检测计划' : '编辑检测计划'
|
||||
})
|
||||
|
||||
|
||||
|
||||
let dialogTitle = computed(() => {
|
||||
if (planType.value === 1) {
|
||||
return '新增子计划'
|
||||
} else if (titleType.value === 'add') {
|
||||
return '新增检测计划'
|
||||
} else {
|
||||
return '编辑检测计划'
|
||||
}
|
||||
})
|
||||
|
||||
// 定义表单校验规则
|
||||
const baseRules: Record<string, Array<FormItemRule>> = {
|
||||
@@ -252,6 +297,8 @@ const baseRules: Record<string, Array<FormItemRule>> = {
|
||||
scriptId: [{ required: true, message: '检测脚本必选!', trigger: 'change' }],
|
||||
errorSysId: [{ required: true, message: '误差体系必选!', trigger: 'change' }],
|
||||
dataRule: [{ required: true, message: '数据处理原则必选!', trigger: 'change' }],
|
||||
standardDevIdList: [{ required: true, message: '标准设备必选!', trigger: 'change' }],
|
||||
testItems: [{ required: true, message: '测试项必选!', trigger: 'change' }],
|
||||
};
|
||||
|
||||
// 使用计算属性根据 scene 动态生成规则
|
||||
@@ -278,23 +325,13 @@ const rules = computed(() => {
|
||||
}
|
||||
|
||||
|
||||
const emit = defineEmits(['update:tab'])
|
||||
// 保存数据
|
||||
const save = () => {
|
||||
try {
|
||||
dialogFormRef.value?.validate(async (valid: boolean) => {
|
||||
if (valid) {
|
||||
formContent.devIds = value.value
|
||||
// 将 formContent.devIds 转换为 ReqPqDevParams 数组
|
||||
// boundPqDevList.value = pqDevList.value
|
||||
// .filter(device => formContent.devIds.includes(device.id))
|
||||
// .map(device => ({
|
||||
// id: device.id,
|
||||
// name: device.name,
|
||||
// devType: device.devType,
|
||||
// createTime: device.createDate,
|
||||
// pattern: device.pattern,
|
||||
// }));
|
||||
|
||||
|
||||
if (formContent.id) {
|
||||
// 把数据处理原则转成字典ID
|
||||
@@ -302,14 +339,28 @@ const rules = computed(() => {
|
||||
if (patternItem) {
|
||||
formContent.dataRule = patternItem.id;
|
||||
}
|
||||
|
||||
if( mode.value === '比对式'){
|
||||
if(planType.value == 1){
|
||||
formContent.fatherPlanId = formContent.id;
|
||||
formContent.id = '';
|
||||
formContent.devIds = []
|
||||
formContent.standardDevIdList = []
|
||||
formContent.standardDevMap = new Map<string, number>();
|
||||
await addPlan(formContent)
|
||||
emit('update:tab')
|
||||
}
|
||||
else if(planType.value == 2){
|
||||
await updateSubPlanName(formContent)
|
||||
emit('update:tab')
|
||||
console.log('更新子计划',formContent)
|
||||
}
|
||||
else{
|
||||
await updatePlan(formContent)
|
||||
}else{
|
||||
|
||||
await updatePlan({...formContent,'sourceIds':[formContent.sourceIds],'datasourceIds':[formContent.datasourceIds]});
|
||||
}
|
||||
|
||||
}else{
|
||||
await updatePlan({...formContent,'sourceIds':[formContent.sourceIds],'datasourceIds':[formContent.datasourceIds]});
|
||||
}
|
||||
ElMessage.success({ message: `${dialogTitle.value}成功!` })
|
||||
|
||||
} else {
|
||||
@@ -324,6 +375,7 @@ const rules = computed(() => {
|
||||
formContent.dataRule = patternItem2.id;
|
||||
}
|
||||
if( mode.value === '比对式'){
|
||||
formContent.sourceIds = null;
|
||||
await addPlan(formContent);
|
||||
}else{
|
||||
await addPlan({...formContent,'sourceIds':[formContent.sourceIds],'datasourceIds':[formContent.datasourceIds]});
|
||||
@@ -332,20 +384,20 @@ const rules = computed(() => {
|
||||
}
|
||||
close()
|
||||
// 刷新表格
|
||||
if(planType.value == 0){
|
||||
await props.refreshTable!()
|
||||
}
|
||||
|
||||
}
|
||||
})
|
||||
} catch (err) {
|
||||
console.error('验证过程中出现错误', err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 打开弹窗,可能是新增,也可能是编辑
|
||||
const open = async (sign: string,
|
||||
data: Plan.ReqPlan,
|
||||
currentMode: string,) => {
|
||||
const open = async (sign: string, data: Plan.ReqPlan,currentMode: string,plan:number) => {
|
||||
unboundPqDevList.value = []
|
||||
boundPqDevList.value = []
|
||||
//处理异步调用
|
||||
@@ -354,29 +406,71 @@ const open = async (sign: string,
|
||||
mode.value = currentMode
|
||||
titleType.value = sign
|
||||
isSelectDisabled.value = false
|
||||
planType.value = plan
|
||||
//比对式测试项下拉框
|
||||
if(mode.value == '比对式'){
|
||||
const dictCode = 'Script_Error';
|
||||
const resDictTree: Dict.ResDictTree = {
|
||||
name: '',
|
||||
id: '',
|
||||
pid: '',
|
||||
pids: '',
|
||||
code: dictCode,
|
||||
sort: 0
|
||||
};
|
||||
const result = await getDictTreeByCode(resDictTree)
|
||||
const allOptions = convertToOptions(result.data as Dict.ResDictTree[]);
|
||||
// 提取第二层节点
|
||||
allOptions.forEach(option => {
|
||||
if (option.children && option.children.length > 0) {
|
||||
secondLevelOptions.push(...option.children);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if(sign == 'add')
|
||||
{
|
||||
resetFormContent()
|
||||
const [pqSource_Result, PqScript_Result, PqErrSys_Result,pqDevList_Result,pqReportName_Result] = await Promise.all([
|
||||
|
||||
let pqSource_Result, PqScript_Result, PqErrSys_Result, pqDevList_Result, pqReportName_Result, pqStandardDev_Result;
|
||||
|
||||
if (mode.value === '比对式') {
|
||||
const commonResults = await Promise.all([
|
||||
getPqErrSysList(),
|
||||
getUnboundPqDevList(data),
|
||||
getPqReportAllName(),
|
||||
getAllPqStandardDev()
|
||||
]);
|
||||
[PqErrSys_Result, pqDevList_Result, pqReportName_Result, pqStandardDev_Result] = commonResults;
|
||||
|
||||
// 比对式下这两个接口不需要
|
||||
pqSource_Result = { data: [] };
|
||||
PqScript_Result = { data: [] };
|
||||
} else {
|
||||
const commonResults = await Promise.all([
|
||||
getTestSourceList(data),
|
||||
getPqScriptList(data),
|
||||
getPqErrSysList(),
|
||||
getUnboundPqDevList(data),
|
||||
getPqReportAllName(),
|
||||
|
||||
]);
|
||||
[pqSource_Result, PqScript_Result, PqErrSys_Result, pqDevList_Result, pqReportName_Result] = commonResults;
|
||||
}
|
||||
|
||||
if (Array.isArray(pqReportName_Result.data)) {
|
||||
pqReportName.value = pqReportName_Result.data.map(item => ({ name: item }));
|
||||
} else {
|
||||
pqReportName.value = [];
|
||||
console.error('pqReportName_Result.data is not an array:', pqReportName_Result.data);
|
||||
}
|
||||
pqSourceList.value = pqSource_Result.data as TestSource.ResTestSource[];
|
||||
pqScriptList.value = PqScript_Result.data as TestScript.ResTestScript[];
|
||||
pqErrSysList.value = PqErrSys_Result.data as unknown as ErrorSystem.ErrorSystemList[];
|
||||
pqDevList.value = pqDevList_Result.data as Device.ResPqDev[];
|
||||
if (pqStandardDev_Result && Array.isArray(pqStandardDev_Result.data)) {
|
||||
pqStandardDevList.value = pqStandardDev_Result.data as StandardDevice.ResPqStandardDevice[];
|
||||
} else {
|
||||
pqStandardDevList.value = [];
|
||||
}
|
||||
// 初始化 boundPqDevList 为空数组
|
||||
unboundPqDevList.value = pqDevList.value
|
||||
boundPqDevList.value = [];
|
||||
@@ -390,34 +484,59 @@ const open = async (sign: string,
|
||||
|
||||
}else{//编辑时先给表单赋值(这会没接收被检设备),需要手动再给被检设备复制后整体表单赋值
|
||||
|
||||
|
||||
if(plan == 1 || plan == 2){
|
||||
isSelectDisabled.value = true
|
||||
}else{
|
||||
if(data.testState === 0){
|
||||
isSelectDisabled.value = false
|
||||
}else{
|
||||
isSelectDisabled.value = true
|
||||
}
|
||||
}
|
||||
|
||||
Object.assign(formContent,{ ...data })
|
||||
|
||||
const [pqSource_Result, PqScript_Result, PqErrSys_Result,boundPqDevList_Result, unboundPqDevList_Result,pqReportName_Result] = await Promise.all([
|
||||
let pqSource_Result, PqScript_Result, PqErrSys_Result, boundPqDevList_Result, unboundPqDevList_Result, pqReportName_Result, pqStandardDev_Result;
|
||||
|
||||
if (mode.value === '比对式') {
|
||||
const commonResults = await Promise.all([
|
||||
getPqErrSysList(),
|
||||
getBoundPqDevList({ 'planIdList': [data.id] }),
|
||||
getUnboundPqDevList(data),
|
||||
getPqReportAllName(),
|
||||
getAllPqStandardDev()
|
||||
]);
|
||||
[PqErrSys_Result, boundPqDevList_Result, unboundPqDevList_Result, pqReportName_Result, pqStandardDev_Result] = commonResults;
|
||||
|
||||
// 比对式下这两个接口不需要
|
||||
pqSource_Result = { data: [] };
|
||||
PqScript_Result = { data: [] };
|
||||
} else {
|
||||
const commonResults = await Promise.all([
|
||||
getTestSourceList(data),
|
||||
getPqScriptList(data),
|
||||
getPqErrSysList(),
|
||||
getBoundPqDevList({ 'planId': data.id }),
|
||||
getBoundPqDevList({ 'planIdList': [data.id] }),
|
||||
getUnboundPqDevList(data),
|
||||
getPqReportAllName(),
|
||||
]);
|
||||
[pqSource_Result, PqScript_Result, PqErrSys_Result, boundPqDevList_Result, unboundPqDevList_Result, pqReportName_Result] = commonResults;
|
||||
}
|
||||
|
||||
if (Array.isArray(pqReportName_Result.data)) {
|
||||
pqReportName.value = pqReportName_Result.data.map(item => ({ name: item }));
|
||||
} else {
|
||||
pqReportName.value = [];
|
||||
console.error('pqReportName_Result.data is not an array:', pqReportName_Result.data);
|
||||
}
|
||||
|
||||
pqSourceList.value = pqSource_Result.data as TestSource.ResTestSource[];
|
||||
pqScriptList.value = PqScript_Result.data as TestScript.ResTestScript[];
|
||||
pqErrSysList.value = PqErrSys_Result.data as unknown as ErrorSystem.ErrorSystemList[];
|
||||
if (pqStandardDev_Result && Array.isArray(pqStandardDev_Result.data)) {
|
||||
pqStandardDevList.value = pqStandardDev_Result.data as StandardDevice.ResPqStandardDevice[];
|
||||
} else {
|
||||
pqStandardDevList.value = [];
|
||||
}
|
||||
const boundData = Array.isArray(boundPqDevList_Result.data) ? boundPqDevList_Result.data : [];
|
||||
const unboundData = Array.isArray(unboundPqDevList_Result.data) ? unboundPqDevList_Result.data : [];
|
||||
|
||||
@@ -432,7 +551,7 @@ const open = async (sign: string,
|
||||
|
||||
pqToArray();//将对象转为数组
|
||||
|
||||
if( mode.value != '比对式'){
|
||||
if(mode.value != '比对式'){
|
||||
selectByMode.value = false
|
||||
// 将 formContent.sourceIds 从数组转换为字符串
|
||||
if (Array.isArray(formContent.sourceIds)) {
|
||||
@@ -451,12 +570,31 @@ const open = async (sign: string,
|
||||
}else{
|
||||
formContent.associateReport = 1
|
||||
}
|
||||
|
||||
if(plan == 1)//新增子计划名称清空
|
||||
{
|
||||
formContent.name = ''
|
||||
const userList = await getAllUser()
|
||||
const sourceArray1 = Array.isArray(userList.data) ? userList.data : []
|
||||
// 将 pqSource_Result 转换成 { label, value } 数组
|
||||
userArray.value = sourceArray1.map(item => ({
|
||||
label: item.loginName || '',
|
||||
value: item.id
|
||||
}));
|
||||
}
|
||||
// 所有数据加载完成后显示对话框
|
||||
dialogVisible.value = true;
|
||||
}
|
||||
|
||||
|
||||
// 转换函数
|
||||
const convertToOptions = (dictTree: Dict.ResDictTree[]): CascaderOption[] => {
|
||||
return dictTree.map(item => ({
|
||||
value: item.id,
|
||||
label: item.name,
|
||||
code: item.code,
|
||||
children: item.children ? convertToOptions(item.children) : undefined,
|
||||
remark: item.remark
|
||||
}));
|
||||
};
|
||||
function pqToArray() {
|
||||
const sourceArray1 = Array.isArray(pqSourceList.value) ? pqSourceList.value : []
|
||||
// 将 pqSource_Result 转换成 { label, value } 数组
|
||||
@@ -482,8 +620,19 @@ function pqToArray() {
|
||||
label: item.name,
|
||||
value: item.id
|
||||
}))
|
||||
|
||||
const sourceArray5 = Array.isArray(pqStandardDevList.value) ? pqStandardDevList.value : []
|
||||
console.log('5',sourceArray5)
|
||||
pqStandardDevArray.value = sourceArray5.map(item => ({
|
||||
label: item.name,
|
||||
value: item.id
|
||||
}))
|
||||
console.log('25',pqStandardDevArray.value)
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
const dataSourceType = computed(() => {
|
||||
// switch (mode.value) {
|
||||
// case '模拟式':
|
||||
@@ -496,6 +645,35 @@ const dataSourceType = computed(() => {
|
||||
return 'Datasource'
|
||||
})
|
||||
|
||||
const handleDataSourceChange = () => {
|
||||
if(mode.value != '比对式')
|
||||
return
|
||||
// 获取当前选中的 datasourceIds,并确保为数组
|
||||
const values = Array.isArray(formContent.datasourceIds)
|
||||
? formContent.datasourceIds
|
||||
: [formContent.datasourceIds].filter(Boolean); // 转为数组并过滤空值
|
||||
|
||||
const selectedLabels = values.map(value => {
|
||||
const matched = dictStore.getDictData(dataSourceType.value).find(item => item.code === value);
|
||||
return matched ? matched.name : '';
|
||||
})
|
||||
|
||||
// 判断是否同时包含 '3s' 和 '分钟'
|
||||
const hasThreeSeconds = selectedLabels.some(label => label.includes('3s'));
|
||||
const hasMinuteStats = selectedLabels.some(label => label.includes('分钟'));
|
||||
|
||||
if (hasThreeSeconds && hasMinuteStats) {
|
||||
ElMessage.warning('3s实时数据与分钟统计数据不能同时选择');
|
||||
formContent.datasourceIds = '';
|
||||
}
|
||||
// 判断是否选择了多个“分钟统计数据”项
|
||||
const minuteStatLabels = selectedLabels.filter(label => label.includes('分钟'));
|
||||
if (minuteStatLabels.length > 1) {
|
||||
ElMessage.warning('分钟统计数据不能多选');
|
||||
formContent.datasourceIds = '';
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// 对外映射
|
||||
defineExpose({ open })
|
||||
|
||||
@@ -3,15 +3,17 @@
|
||||
<ProTable
|
||||
ref='proTable'
|
||||
:columns='columns'
|
||||
:data="currentPageData"
|
||||
:request-api='getTableList'
|
||||
:pagination="false"
|
||||
>
|
||||
<!-- 表格 header 按钮 -->
|
||||
<template #tableHeader='scope'>
|
||||
<el-button type='primary' v-auth.plan="'import'" :icon='Download' @click='importClick' v-if="modeStore.currentMode != '比对式'">导入</el-button>
|
||||
<el-button type='primary' v-auth.plan="'export'" :icon='Upload' @click='exportClick' v-if="modeStore.currentMode != '比对式'">导出</el-button>
|
||||
<el-button type='primary' v-auth.plan="'combine'" :icon='ScaleToOriginal' :disabled='!(scope.selectedList.length > 1)' @click='combineClick'>
|
||||
<!-- <el-button type='primary' v-auth.plan="'combine'" :icon='ScaleToOriginal' :disabled='!(scope.selectedList.length > 1)' @click='combineClick'>
|
||||
合并
|
||||
</el-button>
|
||||
</el-button> -->
|
||||
<el-button type='primary' v-auth.plan="'add'" :icon='CirclePlus' @click="openDialog('add')">新增</el-button>
|
||||
<el-button type='primary' v-auth.plan="'analysis'" :icon='List' :disabled='!scope.isSelected' @click='statisticalAnalysisMore(scope.selectedListIds,scope.selectedList)'>统计分析</el-button>
|
||||
<el-button type='danger' v-auth.plan="'delete'" :icon='Delete' plain :disabled='!scope.isSelected' @click='batchDelete(scope.selectedListIds)'>
|
||||
@@ -23,37 +25,50 @@
|
||||
<template #operation='scope'>
|
||||
<el-button type='primary' v-auth.plan="'edit'" link :icon='EditPen' @click="openDialog('edit',scope.row)">编辑</el-button>
|
||||
<el-button type='primary' v-auth.plan="'delete'" link :icon='Delete' @click='handleDelete(scope.row)'>删除</el-button>
|
||||
<el-button type='primary' link :icon='List' @click="openTestSource(scope.row)">子计划</el-button>
|
||||
<el-button type='primary' link :icon='List' @click="openChildrenPlan(scope.row)" v-if="modeStore.currentMode == '比对式' && scope.row.fatherPlanId == 0">子计划</el-button>
|
||||
<!-- <el-button type='primary' link :icon='List' @click='showDeviceOpen(scope.row)'>设备绑定</el-button> -->
|
||||
<el-button type='primary' v-auth.plan="'analysis'" link :icon='List' v-if="scope.row.testState == '2'" @click='statisticalAnalysis(scope.row)'>统计分析</el-button>
|
||||
</template>
|
||||
|
||||
<!-- 在此处新增 footer 插槽 -->
|
||||
<template #pagination ='scope'>
|
||||
<el-pagination
|
||||
:background="true"
|
||||
:current-page="currentPage"
|
||||
:page-size="pageSize"
|
||||
:page-sizes="[10, 25, 50, 100]"
|
||||
:total="pageTotal"
|
||||
layout="total, sizes, prev, pager, next, jumper"
|
||||
@size-change="handleSizeChange"
|
||||
@current-change="handleCurrentChange"
|
||||
/>
|
||||
</template>
|
||||
</ProTable>
|
||||
</div>
|
||||
|
||||
<!-- 向计划导入/导出设备对话框 -->
|
||||
<PlanPopup :refresh-table='proTable?.getTableList' ref='planPopup'/>
|
||||
<PlanPopup :refresh-table='refreshTable' ref='planPopup'/>
|
||||
<!-- 查看误差体系详细信息 -->
|
||||
<ErrorStandardPopup :refresh-table='proTable?.getTableList' ref="errorStandardPopup"/>
|
||||
<!-- 查看检测源 -->
|
||||
<TestSourcePopup :refresh-table='proTable?.getTableList' ref="testSourcePopup"/>
|
||||
<!-- 查看设备绑定
|
||||
<DevTransfer :refresh-table='proTable?.getTableList' ref='devTransferPopup'/> -->
|
||||
|
||||
<ImportExcel ref='planImportExcel' />
|
||||
<SourceOpen :refresh-table='proTable?.getTableList' ref='openSourceView' :width='viewWidth' :height='viewHeight'></SourceOpen>
|
||||
|
||||
<ChildrenPlan :refresh-table='refreshTable' ref='childrenPlanView' :width='viewWidth' :height='viewHeight'></ChildrenPlan>
|
||||
|
||||
</template>
|
||||
|
||||
<script setup lang='tsx' name='useProTable'>
|
||||
import ProTable from '@/components/ProTable/index.vue'
|
||||
import type { ProTableInstance, ColumnProps } from '@/components/ProTable/interface'
|
||||
import type { ProTableInstance, ColumnProps, RenderScope } from '@/components/ProTable/interface'
|
||||
import { ScaleToOriginal, CirclePlus, Delete, EditPen, View, Upload, Download, List, Tools } from '@element-plus/icons-vue'
|
||||
import {getPlanList,deletePlan,exportPlan,downloadTemplate,importPlan } from '@/api/plan/plan.ts'
|
||||
import { computed, onMounted, reactive, ref } from 'vue'
|
||||
import { computed, onMounted, reactive, ref, watch } from 'vue'
|
||||
import type { Plan } from '@/api/plan/interface'
|
||||
import PlanPopup from '@/views/plan/planList/components/planPopup.vue' // 导入子组件
|
||||
import DeviceOpen from '@/views/plan/planList/components/devPopup.vue'
|
||||
import SourceOpen from '@/views/plan/planList/components/chidrenPlan.vue'
|
||||
import DevTransfer from './components/devTransfer.vue'
|
||||
import ChildrenPlan from '@/views/plan/planList/components/childrenPlan.vue'
|
||||
import { useViewSize } from '@/hooks/useViewSize'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { useDictStore } from '@/stores/modules/dict'
|
||||
@@ -72,41 +87,135 @@ import {useDownload} from "@/hooks/useDownload";
|
||||
import {getTestConfig } from '@/api/system/base/index'
|
||||
import {type Base } from '@/api/system/base/interface'
|
||||
import { getBoundPqDevList ,staticsAnalyse} from '@/api/plan/plan.ts'
|
||||
import { kMaxLength } from 'buffer'
|
||||
|
||||
// defineOptions({
|
||||
// name: 'planList'
|
||||
// })
|
||||
const dictStore = useDictStore()
|
||||
const openDeviceView = ref()
|
||||
const openSourceView = ref()
|
||||
const devTransferVisible = ref(false)
|
||||
const sourceTransferVisible = ref(false)
|
||||
const childrenPlanView = ref()
|
||||
// ProTable 实例
|
||||
const proTable = ref<ProTableInstance>()
|
||||
const errorStandardPopup = ref()
|
||||
const testSourcePopup = ref()
|
||||
const planPopup = ref()
|
||||
const devTransferPopup = ref()
|
||||
|
||||
const modeStore = useModeStore();
|
||||
|
||||
const tableData = ref<any[]>([])
|
||||
const planImportExcel = ref<InstanceType<typeof ImportExcel> | null>(null)
|
||||
const planList = ref<Plan.ResPlan[]>([]);
|
||||
const getTableList = async(params: any) => {
|
||||
let newParams = JSON.parse(JSON.stringify(params))
|
||||
const patternId = dictStore.getDictData('Pattern').find(item=>item.name=== modeStore.currentMode)?.id//获取数据字典中对应的id
|
||||
newParams.patternId = patternId
|
||||
const { popupBaseView, viewWidth, viewHeight } = useViewSize()
|
||||
const pageTotal = ref(0)
|
||||
const currentPage = ref(1)
|
||||
const pageSize = ref(10)
|
||||
const currentPageData = ref<any[]>([])//当前页的数据
|
||||
const patternId = ref('')
|
||||
onMounted(async () => {
|
||||
refreshTable()
|
||||
|
||||
})
|
||||
//假分页后用data刷新
|
||||
const refreshTable = async () => {
|
||||
try {
|
||||
const result = await getPlanList(newParams);
|
||||
planList.value = result.data as Plan.ResPlan[];
|
||||
return result;
|
||||
console.log("表格刷新")
|
||||
patternId.value = dictStore.getDictData('Pattern').find(item => item.name === modeStore.currentMode)?.id;
|
||||
const result = await getPlanList({'patternId' : patternId.value});
|
||||
tableData.value = buildTree(result.data as any[]);
|
||||
pageTotal.value = tableData.value.length;
|
||||
updateCurrentPageData(tableData.value)
|
||||
console.log("表格刷新成功")
|
||||
} catch (error) {
|
||||
return { data: [] }; // 返回空数据或处理错误
|
||||
tableData.value = [];
|
||||
ElMessage.error('获取计划列表失败');
|
||||
}
|
||||
}
|
||||
|
||||
const { popupBaseView, viewWidth, viewHeight } = useViewSize()
|
||||
// 监听 tableData 变化
|
||||
watch(() => tableData.value, (newVal) => {
|
||||
if (childrenPlanView.value && newVal) {
|
||||
console.log('监听 tableData 变化', newVal)
|
||||
childrenPlanView.value.handleTableDataUpdate?.(newVal)
|
||||
updateCurrentPageData(newVal)
|
||||
}
|
||||
}, { deep: true, immediate: true })
|
||||
|
||||
//模糊查询计划列表
|
||||
const getTableList = async(params: any) => {
|
||||
let newParams = JSON.parse(JSON.stringify(params))
|
||||
// 从 newParams 中提取筛选条件
|
||||
const name = newParams.name
|
||||
const reportState = newParams.reportState
|
||||
const result = newParams.result
|
||||
const testState = newParams.testState
|
||||
|
||||
// 对 tableData.value 进行筛选
|
||||
const filteredData = tableData.value.filter(item => {
|
||||
let match = true
|
||||
|
||||
if (name) {
|
||||
match = item.name?.includes(name)
|
||||
}
|
||||
|
||||
if (reportState !== undefined && reportState !== null && reportState !== '') {
|
||||
match = item.reportState == (reportState)
|
||||
}
|
||||
|
||||
if (result !== undefined && result !== null && result !== '') {
|
||||
match = item.result == (result)
|
||||
}
|
||||
|
||||
if (testState !== undefined && testState !== null && testState !== '') {
|
||||
match = item.testState == (testState)
|
||||
}
|
||||
|
||||
return match
|
||||
})
|
||||
|
||||
|
||||
// 更新分页总数
|
||||
pageTotal.value = filteredData.length
|
||||
|
||||
// 更新当前页数据
|
||||
currentPage.value = 1
|
||||
updateCurrentPageData(filteredData)
|
||||
}
|
||||
|
||||
function buildTree(flatList: any[]): any[] {
|
||||
const map = new Map();
|
||||
const tree: any[] = [];
|
||||
|
||||
// First, create a map of all items by id for fast lookup
|
||||
flatList.forEach(item => {
|
||||
map.set(item.id, { ...item, children: [] });
|
||||
});
|
||||
|
||||
// Then, assign each item to its parent's children array
|
||||
flatList.forEach(item => {
|
||||
if (item.fatherPlanId && map.has(item.fatherPlanId)) {
|
||||
map.get(item.fatherPlanId).children.push(map.get(item.id));
|
||||
} else if (item.fatherPlanId === '0') {
|
||||
// Items with fatherPlanId '0' are root nodes
|
||||
tree.push(map.get(item.id));
|
||||
}
|
||||
});
|
||||
|
||||
return tree;
|
||||
}
|
||||
|
||||
const handleSizeChange = (size: number) => {
|
||||
pageSize.value = size
|
||||
updateCurrentPageData()
|
||||
}
|
||||
|
||||
const handleCurrentChange = (page: number) => {
|
||||
currentPage.value = page
|
||||
updateCurrentPageData()
|
||||
}
|
||||
|
||||
const updateCurrentPageData = (data = tableData.value) => {
|
||||
const start = (currentPage.value - 1) * pageSize.value
|
||||
const end = start + pageSize.value
|
||||
currentPageData.value = data.slice(start, end)
|
||||
console.log('currentPageData', currentPageData.value)
|
||||
}
|
||||
|
||||
const dataSourceType = computed(() => {
|
||||
// switch (modeStore.currentMode) {
|
||||
@@ -120,21 +229,20 @@ const dataSourceType = computed(() => {
|
||||
return 'Datasource'
|
||||
})
|
||||
|
||||
|
||||
// 表格配置项
|
||||
const columns = reactive<ColumnProps<Plan.ReqPlan>[]>([
|
||||
{ type: 'selection', fixed: 'left', minWidth: 70 },
|
||||
{ type: 'index', fixed: 'left', minWidth: 70, label: '序号' },
|
||||
{ type: 'index', fixed: 'left', minWidth: 70, label: '序号'},
|
||||
{
|
||||
prop: 'name',
|
||||
label: '名称',
|
||||
minWidth: 220,
|
||||
minWidth: 200,
|
||||
search: { el: 'input' },
|
||||
},
|
||||
{
|
||||
prop: 'testState',
|
||||
label: '检测状态',
|
||||
minWidth: 120,
|
||||
minWidth: 100,
|
||||
enum:dictTestState,
|
||||
search: { el:'select',props: { filterable: true }},
|
||||
fieldNames: { label: 'label', value: 'id' },
|
||||
@@ -149,14 +257,13 @@ const columns = reactive<ColumnProps<Plan.ReqPlan>[]>([
|
||||
{
|
||||
prop: 'progress',
|
||||
label: '检测进度',
|
||||
minWidth: 180,
|
||||
minWidth: 150,
|
||||
render: (scope) => {
|
||||
const randomPercentage = Math.floor(Math.random() * 101); // 生成 0 到 100 的随机整数
|
||||
return (
|
||||
<el-progress
|
||||
text-inside={true}
|
||||
stroke-width={20}
|
||||
percentage={randomPercentage}
|
||||
percentage={(scope.row.progress ?? 0) * 100}
|
||||
status='success'
|
||||
/>
|
||||
);
|
||||
@@ -178,12 +285,11 @@ const columns = reactive<ColumnProps<Plan.ReqPlan>[]>([
|
||||
{
|
||||
prop: 'result',
|
||||
label: '检测结果',
|
||||
minWidth: 120,
|
||||
minWidth: 100,
|
||||
enum:dictResult,
|
||||
search: { el: 'select', props: { filterable: true } },
|
||||
fieldNames: { label: 'label', value: 'id' },
|
||||
render: scope => {
|
||||
console.log('检测结果',scope.row.result)
|
||||
return (
|
||||
scope.row.result === 0 ? '不符合' : scope.row.result === 1 ? '符合' : '/'
|
||||
)
|
||||
@@ -192,7 +298,7 @@ const columns = reactive<ColumnProps<Plan.ReqPlan>[]>([
|
||||
{
|
||||
prop: 'createTime',
|
||||
label: '创建时间',
|
||||
minWidth: 200,
|
||||
minWidth: 180,
|
||||
render: scope => {
|
||||
if (scope.row.createTime) {
|
||||
const date = new Date(scope.row.createTime);
|
||||
@@ -210,7 +316,8 @@ const columns = reactive<ColumnProps<Plan.ReqPlan>[]>([
|
||||
{
|
||||
prop: 'sourceName',
|
||||
label: '检测源',
|
||||
minWidth: 400,
|
||||
minWidth: 300,
|
||||
isShow: modeStore.currentMode != "比对式",
|
||||
render: scope => {
|
||||
const sourceNames = Array.isArray(scope.row.sourceName) ? scope.row.sourceName : [];
|
||||
const sourceIds = Array.isArray(scope.row.sourceIds) ? scope.row.sourceIds : [];
|
||||
@@ -238,17 +345,30 @@ const columns = reactive<ColumnProps<Plan.ReqPlan>[]>([
|
||||
{
|
||||
prop: 'scriptId',
|
||||
label: '检测脚本',
|
||||
minWidth: 360,
|
||||
minWidth: 300,
|
||||
isShow: modeStore.currentMode != "比对式",
|
||||
render: scope => {
|
||||
return (
|
||||
<span>{scope.row.scriptName}</span>
|
||||
)
|
||||
},
|
||||
},
|
||||
{
|
||||
prop: 'standardDevNameStr',
|
||||
label: '标准设备',
|
||||
minWidth: 250,
|
||||
isShow: modeStore.currentMode == "比对式",
|
||||
|
||||
},
|
||||
{
|
||||
prop: 'testItemNameStr',
|
||||
label: '测试项',
|
||||
minWidth: 300,
|
||||
isShow: modeStore.currentMode == "比对式",
|
||||
},
|
||||
{
|
||||
prop: 'errorSysId',
|
||||
label: '误差体系',
|
||||
minWidth: 240,
|
||||
label: '误差体系', minWidth:300,
|
||||
render: scope => {
|
||||
return (
|
||||
<el-link type='primary' link onClick={() => showData(scope.row)}>
|
||||
@@ -257,12 +377,18 @@ const columns = reactive<ColumnProps<Plan.ReqPlan>[]>([
|
||||
)
|
||||
},
|
||||
},
|
||||
{
|
||||
prop: 'origin',//null 表示主计划 1表示子计划
|
||||
label: '来源',
|
||||
minWidth:200,
|
||||
isShow: modeStore.currentMode == "比对式",
|
||||
},
|
||||
{
|
||||
prop: 'datasourceIds',
|
||||
label: '数据源',
|
||||
enum: dictStore.getDictData(dataSourceType.value),
|
||||
fieldNames: { label: 'name', value: 'value' },
|
||||
minWidth: 250,
|
||||
minWidth: 230,
|
||||
render: (scope) => {
|
||||
const codes = scope.row.datasourceIds // 获取当前行的 datasourceIds 字段
|
||||
if (!codes) {
|
||||
@@ -295,7 +421,7 @@ const columns = reactive<ColumnProps<Plan.ReqPlan>[]>([
|
||||
minWidth: 120,
|
||||
},
|
||||
|
||||
{ prop: 'operation', label: '操作', fixed: 'right', minWidth: 300 },
|
||||
{ prop: 'operation', label: '操作', fixed: 'right', minWidth: 250 },
|
||||
])
|
||||
|
||||
|
||||
@@ -332,44 +458,6 @@ async function showTestSource(row:string) {
|
||||
|
||||
}
|
||||
|
||||
function showTestScript(row: string) {
|
||||
|
||||
}
|
||||
|
||||
function handleFiles(event: Event) {
|
||||
const target = event.target as HTMLInputElement
|
||||
const files = target.files
|
||||
if (files && files.length > 0) {
|
||||
// 处理文件
|
||||
// console.log(files)
|
||||
ElMessageBox.confirm(
|
||||
'导入的数据与当前数据有冲突,请选择以哪个数据为主进行覆盖',
|
||||
'数据冲突',
|
||||
{
|
||||
distinguishCancelAndClose: true,
|
||||
confirmButtonText: '以导入数据为主覆盖',
|
||||
cancelButtonText: '以当前数据为主覆盖',
|
||||
type: 'warning',
|
||||
},
|
||||
)
|
||||
.then(() => {
|
||||
ElMessage({
|
||||
type: 'info',
|
||||
message: '以导入数据为主完成数据覆盖',
|
||||
})
|
||||
})
|
||||
.catch((action: Action) => {
|
||||
ElMessage({
|
||||
type: 'info',
|
||||
message:
|
||||
action === 'cancel'
|
||||
? '以当前数据为主完成数据覆盖'
|
||||
: '取消本次导入操作',
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// 点击导入按钮
|
||||
const importClick = () => {
|
||||
const params = {
|
||||
@@ -378,7 +466,7 @@ const importClick = () => {
|
||||
patternId: dictStore.getDictData('Pattern').find(item=>item.name=== modeStore.currentMode)?.id ?? '',
|
||||
tempApi: downloadTemplate,
|
||||
importApi: importPlan,
|
||||
getTableList: proTable.value?.getTableList,
|
||||
getTableList: refreshTable(),
|
||||
}
|
||||
planImportExcel.value?.acceptParams(params)
|
||||
}
|
||||
@@ -391,51 +479,30 @@ const exportClick = () => {
|
||||
})
|
||||
}
|
||||
|
||||
// 点击合并按钮
|
||||
const combineClick = () => {
|
||||
ElMessageBox.prompt(
|
||||
'请输入合并后的计划名称',
|
||||
'检测计划合并',
|
||||
{
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
},
|
||||
)
|
||||
.then(({ value }) => {
|
||||
// console.log(`合并后的计划名为:`, value)
|
||||
proTable.value?.clearSelection()
|
||||
proTable.value?.getTableList()
|
||||
})
|
||||
}
|
||||
|
||||
// 打开 drawer(新增、编辑)
|
||||
const openDialog = (titleType: string, row: Partial<Plan.ReqPlan> = {}) => {
|
||||
planPopup.value?.open(titleType, row,modeStore.currentMode)
|
||||
planPopup.value?.open(titleType, row,modeStore.currentMode,0)//0主计划 1子计划 2修改子计划
|
||||
}
|
||||
|
||||
|
||||
// 批量删除设备
|
||||
const batchDelete = async (id: string[]) => {
|
||||
await useHandleData(deletePlan, id, '删除所选检测计划')
|
||||
await useHandleData(deletePlan, {'id':id, 'pattern':patternId.value},'删除所选检测计划')
|
||||
proTable.value?.clearSelection()
|
||||
proTable.value?.getTableList()
|
||||
await refreshTable()
|
||||
}
|
||||
|
||||
// 删除检测计划
|
||||
const handleDelete = async (params: Plan.ReqPlanParams) => {
|
||||
await useHandleData(deletePlan, [params.id], `删除【${params.name}】检测计划`)
|
||||
proTable.value?.getTableList()
|
||||
await useHandleData(deletePlan, {id: [params.id], 'pattern': patternId.value}, `删除【${params.name}】检测计划`)
|
||||
proTable.value?.clearSelection()
|
||||
await refreshTable()
|
||||
}
|
||||
|
||||
const openTestSource = (row: Partial<Plan.ReqPlan> = {}) => {
|
||||
openSourceView.value.open("检测计划详情",row.name)
|
||||
const openChildrenPlan = (row: Partial<Plan.ReqPlan> = {}) => {
|
||||
childrenPlanView.value.open("检测计划详情",row)
|
||||
}
|
||||
|
||||
const showDeviceOpen = (row: Partial<Plan.ReqPlan> = {}) => {
|
||||
devTransferPopup.value.open(row)
|
||||
}
|
||||
|
||||
const myDict = new Map<string, any[]>();
|
||||
|
||||
const statisticalAnalysisMore = async (ids: string[], rows: Plan.ReqPlan[]) => {
|
||||
const hasInvalidState = rows.some(row => row.testState != 2);
|
||||
@@ -452,39 +519,10 @@ const statisticalAnalysisMore = async (ids: string[], rows: Plan.ReqPlan[]) => {
|
||||
|
||||
const statisticalAnalysis = async (row: Partial<Plan.ReqPlan> = {}) => {
|
||||
useDownload(staticsAnalyse,'分析结果', [row.id], false,'.xlsx')
|
||||
|
||||
// const response = await getTestConfig() as unknown as Base.ResTestConfig
|
||||
// const maxTime= response.data.maxTime//检测最大次数
|
||||
// const dev = await getBoundPqDevList({ 'planId': row.id })
|
||||
// for (let i = 0; i <= maxTime; i++) {
|
||||
// dev.data.forEach((item: any) => {
|
||||
// if(item.reCheckNum === i){
|
||||
// // 向已有的数组中添加元素
|
||||
// if (myDict.has(i.toString())) {
|
||||
// myDict.get(i.toString())?.push(item.name);
|
||||
// }else{
|
||||
// myDict.set(i.toString(), [item.name]);
|
||||
// }
|
||||
// }
|
||||
|
||||
// })
|
||||
// }
|
||||
|
||||
// for (let i = 0; i <= maxTime; i++) {
|
||||
// if (myDict.has(i.toString())) {
|
||||
// const array = myDict.get(i.toString());
|
||||
// if (array) {
|
||||
// for (const value of array) {
|
||||
// console.log(i + '---'+value);
|
||||
// }
|
||||
// }
|
||||
|
||||
// }
|
||||
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
Reference in New Issue
Block a user