Compare commits
15 Commits
NPQS9100V1
...
2025-08
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
83998f88ac | ||
|
|
9c5e54507b | ||
|
|
15689b5284 | ||
|
|
00893d2d1f | ||
|
|
0079f7415e | ||
| 327801d040 | |||
|
|
6e22c01dd8 | ||
|
|
bccb4b1f17 | ||
|
|
1f37cc567c | ||
|
|
f81503091d | ||
|
|
e29f25653e | ||
|
|
9e8e44b886 | ||
|
|
6e10b0c645 | ||
|
|
c8f3b4eddc | ||
|
|
cc848b1ffb |
@@ -14,6 +14,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@element-plus/icons-vue": "^2.3.1",
|
||||
"@vue-flow/core": "^1.45.0",
|
||||
"@vueuse/core": "^10.4.1",
|
||||
"axios": "^1.7.3",
|
||||
"crypto-js": "^4.2.0",
|
||||
@@ -72,7 +73,7 @@
|
||||
"unplugin-auto-import": "^0.18.3",
|
||||
"unplugin-vue-components": "^0.27.4",
|
||||
"unplugin-vue-setup-extend-plus": "^1.0.0",
|
||||
"vite": "^5.3.1",
|
||||
"vite": "^5.4.19",
|
||||
"vite-plugin-compression": "^0.5.1",
|
||||
"vite-plugin-eslint": "^1.8.1",
|
||||
"vite-plugin-html": "^3.2.0",
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { pa } from 'element-plus/es/locale/index.mjs';
|
||||
import type {Device} from '@/api/device/interface/device'
|
||||
import http from '@/api'
|
||||
|
||||
@@ -30,8 +31,8 @@ export const exportPqDev = (params: Device.ReqPqDevParams) => {
|
||||
return http.download(`/pqDev/export`, params)
|
||||
}
|
||||
// 下载导入文件模板
|
||||
export const downloadTemplate = () => {
|
||||
return http.download(`/pqDev/downloadTemplate`)
|
||||
export const downloadTemplate = (params: { pattern: string }) => {
|
||||
return http.download(`/pqDev/downloadTemplate`,params)
|
||||
}
|
||||
|
||||
//导入被检设备
|
||||
@@ -59,8 +60,15 @@ export const importContrastPqDev = (params: Device.ReqPqDevParams) => {
|
||||
// return http.uploadExcel(`/pqDev/importCNDev`, params)
|
||||
// }
|
||||
|
||||
export const getPqDevById = (params: Device.ReqPqDevParams) => {
|
||||
return http.get(`/pqDev/getById?id=${params.id}`)
|
||||
}
|
||||
|
||||
//根据设备类型决定(电源、icd、模板、通道数、额定电压、额定电流);
|
||||
export const getPqDev = () => {
|
||||
return http.get(`/devType/listAll`)
|
||||
}
|
||||
|
||||
export const getSelectOptions = (params:{ pattern: string }) => {
|
||||
return http.get(`/pqDev/getSelectOptions`, params)
|
||||
}
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import { getPqDevById } from './../device/index';
|
||||
import type {ReqPage, ResPage} from '@/api/interface'
|
||||
import type { Monitor } from './monitor';
|
||||
|
||||
// 被检设备模块
|
||||
export namespace Device {
|
||||
@@ -33,9 +35,6 @@ export namespace Device {
|
||||
name: string; //设备名称
|
||||
pattern: string; //设备模式 模拟 数字 比对
|
||||
devType: string;//设备类型
|
||||
devChns: number; //设备通道数
|
||||
devVolt: number; //额定电压(V)
|
||||
devCurr: number; //额定电流(A)
|
||||
manufacturer?: string | null;//生产厂家
|
||||
createDate: string; //生产日期
|
||||
createId: string; //出厂编号
|
||||
@@ -50,29 +49,57 @@ export namespace Device {
|
||||
sampleId?: string | null; //样品编号
|
||||
arrivedDate?: string; //送样日期
|
||||
cityName?: string | null; //所属地市名称
|
||||
gDName?: string | null; //所属供电公司名称
|
||||
gdName?: string | null; //所属供电公司名称
|
||||
subName?: string | null; //所属电站名称
|
||||
checkState?: number | null; //检测状态
|
||||
checkResult?: number | null; //检测结果
|
||||
reportState?: number | null; //报告状态
|
||||
reportPath?: string | null; //报告路径
|
||||
qRCode?: string | null; //设备关键信息二维码
|
||||
reCheckNum: number; //复检次数
|
||||
planId?: string;//检测计划Id
|
||||
timeCheckResult?: number;//守时检测结果(0:不符合1:符合)
|
||||
factorFlag?: number;//是否支持系数校准(0:不支持,1:支持)
|
||||
factorCheckResult?: number;//系数校准结果(0:不合格,1:合格,2:/表示没有做系数校准)
|
||||
preinvestmentPlan: string | null;//预投计划
|
||||
delegate: string | null; //委托方
|
||||
inspectChannel?: string[] | string;//被检通道
|
||||
inspectDate?: string | null;//定检日期
|
||||
harmSysId?: string | null;//谐波系统设备id
|
||||
importFlag?: number;//是否为导入设备 0否 1是
|
||||
state: number; //状态
|
||||
createBy?: string | null; //创建用户
|
||||
createTime?: string | null; //创建时间
|
||||
updateBy?: string | null; //更新用户
|
||||
updateTime?: string | null; //更新时间
|
||||
|
||||
devChns: number; //设备通道数
|
||||
devVolt: number; //额定电压(V)
|
||||
devCurr: number; //额定电流(A)
|
||||
icdId: string | null;
|
||||
power: string | null;//工作电源
|
||||
preinvestmentPlan: string | null;
|
||||
delegate: string | null; //委托方
|
||||
|
||||
devId?: number;
|
||||
checkState?: number | null; //检测状态(0:未检,1:检测中,2:检测完成 3:归档)
|
||||
checkResult?: number | null; //检测结果(0:不符合,1:符合,2:未检)
|
||||
reportState?: number | null; //报告状态(0:未生成,1:已生成,2:未检)
|
||||
recheckNum: number; //复检次数
|
||||
timeCheckResult?: number;//守时检测结果(0:不符合1:符合)
|
||||
factorCheckResult?: number;//系数校准结果(0:不合格,1:合格,2:未检)
|
||||
realtimeResult?: number;//实时数据结论(0:不符合,1:符合,2:未检)
|
||||
statisticsResult?: number;//统计数据结论(0:不符合,1:符合,2:未检)
|
||||
recordedResult?: number;//录波数据结论(0:不符合,1:符合,2:未检)
|
||||
checkBy?: string | null;//检测人
|
||||
checkTime?: string | null;//检测时间
|
||||
preDetectTime?: number;//预检测耗时
|
||||
coefficientTime?: number;//系数校准耗时
|
||||
formalCheckTime?: number;//正式检测耗时
|
||||
|
||||
boundPlanName?: string| null;
|
||||
assign?: number;////是否分配给检测人员 0否 1是
|
||||
monitorList: Monitor.ResPqMon[] ;
|
||||
}
|
||||
|
||||
export interface SelectOption {
|
||||
label: string;
|
||||
value: string | number;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
export interface ResDev {
|
||||
id: string;
|
||||
|
||||
@@ -1,33 +1,35 @@
|
||||
import type { ReqPage, ResPage } from '@/api/interface'
|
||||
|
||||
// 被检设备模块
|
||||
// 监测点模块
|
||||
export namespace Monitor {
|
||||
|
||||
/**
|
||||
* 电能质量指标字典数据表格分页查询参数
|
||||
* 监测点表格分页查询参数
|
||||
*/
|
||||
export interface ReqPqMonParams extends ReqPage {
|
||||
id: string; // 装置序号id 必填
|
||||
devType?: string; // 设备名称
|
||||
createTime?: string; //创建时间
|
||||
name?: string; // 设备名称
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 被检设备新增、修改、根据id查询返回的对象
|
||||
* 监测点新增、修改、根据id查询返回的对象
|
||||
*/
|
||||
export interface ResPqMon {
|
||||
id: string; //监测点ID
|
||||
code: string; //默认与谐波系统监测点ID相同
|
||||
devId: string; //所属设备ID
|
||||
name: string; //所属母线
|
||||
num: number; //监测点序号
|
||||
pt: number; //PT变比
|
||||
ct: number; //CT变比
|
||||
ptType: string; //接线方式,字典表
|
||||
busbar: string;//所属母线
|
||||
name: string; //监测点名称
|
||||
num: number; //线路号,监测点序号
|
||||
pt: string; //PT变比
|
||||
ct: string; //CT变比
|
||||
connection: string; //接线方式,字典表
|
||||
statInterval: number; //统计间隔
|
||||
harmSysId: string; //默认与谐波系统监测点ID相同
|
||||
}
|
||||
|
||||
/**
|
||||
* 被检设备表格查询分页返回的对象;
|
||||
* 监测点表格查询分页返回的对象;
|
||||
*/
|
||||
export interface ResPqMonPage extends ResPage<ResPqMon> {
|
||||
|
||||
|
||||
46
frontend/src/api/device/interface/standardDevice.ts
Normal file
46
frontend/src/api/device/interface/standardDevice.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
import type {ReqPage, ResPage} from '@/api/interface'
|
||||
|
||||
// 标准设备模块
|
||||
export namespace StandardDevice {
|
||||
|
||||
/**
|
||||
* 标准设备表格分页查询参数
|
||||
*/
|
||||
export interface ReqPqStandardDeviceParams extends ReqPage {
|
||||
id: string; // 装置序号id 必填
|
||||
name: string; //设备名称
|
||||
devType?: string; // 设备名称
|
||||
createTime?: string; //创建时间
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 标准设备新增、修改、根据id查询返回的对象
|
||||
*/
|
||||
export interface ResPqStandardDevice {
|
||||
id: string; //装置序号ID
|
||||
name: string; //设备名称
|
||||
devType: string;//设备类型
|
||||
manufacturer?: string | null;//生产厂家
|
||||
protocol: string;//通讯协议
|
||||
ip: string; //IP地址
|
||||
port: number; //端口号
|
||||
inspectChannel:string[] |string;//可检通道数
|
||||
encryptionFlag: number; //装置是否为加密版本
|
||||
series?: string | null; //装置识别码(3ds加密)
|
||||
devKey?: string | null; //装置秘钥(3ds加密)
|
||||
state: number; //状态
|
||||
createBy?: string | null; //创建用户
|
||||
createTime?: string | null; //创建时间
|
||||
updateBy?: string | null; //更新用户
|
||||
updateTime?: string | null; //更新时间
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 标准设备表格查询分页返回的对象;
|
||||
*/
|
||||
export interface ResPqStandardDevicePage extends ResPage<ResPqStandardDevice> {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -44,3 +44,8 @@ export const getPqReportAllVersion = (params:any) => {
|
||||
export const documentedPqDev = (ids: string[]) => {
|
||||
return http.post(`/report/documented`, ids)
|
||||
}
|
||||
|
||||
//上传报告到云端
|
||||
export const uploadReportToCloud = (deviceIds: string[]) => {
|
||||
return http.post(`/report/uploadReportToCloud`, deviceIds)
|
||||
}
|
||||
51
frontend/src/api/device/standardDevice/index.ts
Normal file
51
frontend/src/api/device/standardDevice/index.ts
Normal file
@@ -0,0 +1,51 @@
|
||||
import type {StandardDevice} from '@/api/device/interface/standardDevice'
|
||||
import http from '@/api'
|
||||
|
||||
/**
|
||||
* @name 标准设备管理模块
|
||||
*/
|
||||
|
||||
//获取标准设备
|
||||
export const getPqStandardDevList = (params: StandardDevice.ReqPqStandardDeviceParams) => {
|
||||
return http.post(`/pqStandardDev/list`, params)
|
||||
}
|
||||
|
||||
//根据id查询标准设备
|
||||
export const getPqStandardDevById = (params: StandardDevice.ReqPqStandardDeviceParams) => {
|
||||
return http.get(`/pqStandardDev/getById?id=${params.id}`)
|
||||
}
|
||||
|
||||
//添加标准设备
|
||||
export const addPqStandardDev = (params: StandardDevice.ResPqStandardDevice) => {
|
||||
return http.post(`/pqStandardDev/add`, params)
|
||||
}
|
||||
|
||||
//编辑标准设备
|
||||
export const updatePqStandardDev = (params: StandardDevice.ResPqStandardDevice) => {
|
||||
return http.post(`/pqStandardDev/update`, params)
|
||||
}
|
||||
|
||||
//删除标准设备
|
||||
export const deletePqStandardDev = (params: string[]) => {
|
||||
return http.post(`/pqStandardDev/delete`, params)
|
||||
}
|
||||
|
||||
|
||||
//导出标准设备
|
||||
export const exportPqStandardDev = (params: StandardDevice.ReqPqStandardDeviceParams) => {
|
||||
return http.download(`/pqStandardDev/export`, params)
|
||||
}
|
||||
// 下载导入文件模板
|
||||
export const downloadTemplate = () => {
|
||||
return http.download(`/pqStandardDev/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;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,14 @@ export namespace Plan {
|
||||
associateReport:number;//是否关联报告模板 0否 1是
|
||||
reportTemplateName:string;
|
||||
reportTemplateVersion:string;
|
||||
dataRule:string //数据处理原则
|
||||
dataRule:string;//数据处理原则
|
||||
|
||||
standardDevIds:string[];
|
||||
standardDevMap:Map<string,number>;//标准设备
|
||||
testItems:string[];//测试项
|
||||
Check_By?:string;//计划检测人
|
||||
progress?: number; // 进度百分比,例如 75
|
||||
children?: ResPlan[];
|
||||
}
|
||||
|
||||
// 检测计划 + 分页
|
||||
@@ -37,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,32 @@ 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 subPlanBindStandardDevList = (params:Plan.ReqPlan) => {
|
||||
return http.post(`/adPlan/updateBindStandardDev`, params)
|
||||
}
|
||||
|
||||
//子计划绑定/解绑被检设备
|
||||
export const subPlanBindDev = (params:Plan.ReqPlan) => {
|
||||
return http.post(`/adPlan/updateBindDev`, params)
|
||||
}
|
||||
|
||||
//根据父计划ID获取未被子计划绑定的标准设备
|
||||
export const getUnboundStandardDevList = (params:Plan.ResPlan) => {
|
||||
return http.get(`/adPlan/getUnBoundStandardDev?fatherPlanId=${params.fatherPlanId}`)
|
||||
}
|
||||
|
||||
//根据计划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
|
||||
@@ -77,7 +78,7 @@ const acceptParams = (params: ExcelParameterProps) => {
|
||||
// Excel 导入模板下载
|
||||
const downloadTemp = () => {
|
||||
if (!parameter.value.tempApi) return
|
||||
useDownload(parameter.value.tempApi, `${parameter.value.title}模板`, {'patternId':parameter.value.patternId}, false)
|
||||
useDownload(parameter.value.tempApi, `${parameter.value.title}模板`, {'pattern':parameter.value.patternId}, false)
|
||||
}
|
||||
|
||||
// 文件上传
|
||||
@@ -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);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
>数字式模块</el-dropdown-item
|
||||
>
|
||||
<el-dropdown-item @click="handelOpen('比对式')"
|
||||
disabled>比对式模块</el-dropdown-item
|
||||
>比对式模块</el-dropdown-item
|
||||
>
|
||||
</el-dropdown-menu>
|
||||
</template>
|
||||
|
||||
@@ -48,6 +48,7 @@
|
||||
active: item.value === appSceneStore.currentScene
|
||||
}"
|
||||
@click="changeScene(item.value?? '')"
|
||||
:disabled = "item.value === appSceneStore.currentScene"
|
||||
>
|
||||
{{ item.name }}
|
||||
</el-dropdown-item>
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -140,3 +140,9 @@ body,
|
||||
:-webkit-any(article, aside, nav, section) h1 {
|
||||
font-size: 2em;
|
||||
}
|
||||
|
||||
@import 'https://cdn.jsdelivr.net/npm/@vue-flow/core@1.45.0/dist/style.css';
|
||||
@import 'https://cdn.jsdelivr.net/npm/@vue-flow/core@1.45.0/dist/theme-default.css';
|
||||
@import 'https://cdn.jsdelivr.net/npm/@vue-flow/controls@latest/dist/style.css';
|
||||
@import 'https://cdn.jsdelivr.net/npm/@vue-flow/minimap@latest/dist/style.css';
|
||||
@import 'https://cdn.jsdelivr.net/npm/@vue-flow/node-resizer@latest/dist/style.css';
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import mitt from "mitt";
|
||||
|
||||
const mittBus = mitt();
|
||||
|
||||
export default mittBus;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<el-dialog :title="dialogTitle" :model-value="dialogVisible" @close="close" v-bind="dialogMiddle">
|
||||
<el-dialog :title="dialogTitle" :model-value="dialogVisible" @close="close" v-bind="dialogMiddle" align-center>
|
||||
<el-form :model="formContent" ref='dialogFormRef' :rules='rules' class="form-two">
|
||||
<el-form-item label="上级菜单" prop="pid" :label-width="100">
|
||||
<el-tree-select
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<!-- 基础信息弹出框 -->
|
||||
<el-dialog :model-value="dialogVisible" :title="dialogTitle" v-bind="dialogSmall" @close="close" >
|
||||
<el-dialog :model-value="dialogVisible" :title="dialogTitle" v-bind="dialogSmall" @close="close" align-center>
|
||||
<div>
|
||||
|
||||
<el-form :model="formContent"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<!-- 基础信息弹出框 -->
|
||||
<el-dialog :model-value="dialogVisible" :title="dialogTitle" v-bind="dialogMiddle" @close="close" >
|
||||
<el-dialog :model-value="dialogVisible" :title="dialogTitle" v-bind="dialogMiddle" @close="close" align-center>
|
||||
<div>
|
||||
<el-form :model="formContent" ref='dialogFormRef'>
|
||||
<el-tree
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<!-- 基础信息弹出框 -->
|
||||
<el-dialog v-model='dialogVisible' :title="dialogTitle" v-bind="dialogSmall" @close="close">
|
||||
<el-dialog v-model='dialogVisible' :title="dialogTitle" v-bind="dialogSmall" @close="close" align-center>
|
||||
<div>
|
||||
<el-form :model="formContent"
|
||||
ref='dialogFormRef'
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<!-- 基础信息弹出框 -->
|
||||
<el-dialog v-model='dialogVisible' :title="dialogTitle" v-bind="dialogSmall" @close="close" >
|
||||
<el-dialog v-model='dialogVisible' :title="dialogTitle" v-bind="dialogSmall" @close="close" align-center>
|
||||
<div>
|
||||
<el-form :model="formContent"
|
||||
ref='dialogFormRef'
|
||||
|
||||
85
frontend/src/views/home/components/RemoveableEdge.vue
Normal file
85
frontend/src/views/home/components/RemoveableEdge.vue
Normal file
@@ -0,0 +1,85 @@
|
||||
<script setup>
|
||||
import { BaseEdge, EdgeLabelRenderer, getBezierPath, useVueFlow } from '@vue-flow/core'
|
||||
import { computed } from 'vue'
|
||||
|
||||
const props = defineProps({
|
||||
id: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
sourceX: {
|
||||
type: Number,
|
||||
required: true,
|
||||
},
|
||||
sourceY: {
|
||||
type: Number,
|
||||
required: true,
|
||||
},
|
||||
targetX: {
|
||||
type: Number,
|
||||
required: true,
|
||||
},
|
||||
targetY: {
|
||||
type: Number,
|
||||
required: true,
|
||||
},
|
||||
sourcePosition: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
targetPosition: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
markerEnd: {
|
||||
type: String,
|
||||
required: false,
|
||||
},
|
||||
style: {
|
||||
type: Object,
|
||||
required: false,
|
||||
},
|
||||
})
|
||||
|
||||
const { removeEdges } = useVueFlow()
|
||||
|
||||
const path = computed(() => getBezierPath(props))
|
||||
</script>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
inheritAttrs: false,
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<BaseEdge :id="id" :style="style" :path="path[0]" :marker-end="markerEnd" />
|
||||
<EdgeLabelRenderer>
|
||||
<div
|
||||
:style="{
|
||||
pointerEvents: 'all',
|
||||
position: 'absolute',
|
||||
transform: `translate(-50%, -50%) translate(${path[1]}px,${path[2]}px)`,
|
||||
}"
|
||||
class="nodrag nopan"
|
||||
>
|
||||
<el-popconfirm
|
||||
title="确定要删除这条连线吗?"
|
||||
@confirm="removeEdges(id)"
|
||||
>
|
||||
<template #reference>
|
||||
<el-icon class="edge-icon"><Delete/></el-icon>
|
||||
</template>
|
||||
</el-popconfirm>
|
||||
</div>
|
||||
</EdgeLabelRenderer>
|
||||
</template>
|
||||
<style scoped>
|
||||
.edge-icon {
|
||||
background: white;
|
||||
border-radius: 50%;
|
||||
padding: 2px;
|
||||
cursor: pointer;
|
||||
box-shadow: 0 0 4px rgba(0, 0, 0, 0.2);
|
||||
}
|
||||
</style>
|
||||
657
frontend/src/views/home/components/comparePreTest.vue
Normal file
657
frontend/src/views/home/components/comparePreTest.vue
Normal file
@@ -0,0 +1,657 @@
|
||||
<template>
|
||||
<div>
|
||||
<el-tabs type="border-card">
|
||||
<el-tab-pane label="预检测项目">
|
||||
<div class="form-grid">
|
||||
<el-checkbox v-for="(item, index) in detectionOptions" v-model="item.selected" :key="index"
|
||||
:label="item.name" disabled></el-checkbox>
|
||||
</div>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
|
||||
<div class="test-dialog">
|
||||
<div class="dialog-left">
|
||||
<el-steps direction="vertical" :active="activeIndex" :process-status="currentStepStatus"
|
||||
finish-status="success">
|
||||
<el-step :status="step1" title="设备通讯校验"/>
|
||||
<el-step :status="step2" title="协议校验"/>
|
||||
<el-step :status="step3" title="模型一致性校验"/>
|
||||
<el-step :status="step4" title="实时数据对齐验证"/>
|
||||
<el-step :status="step5" title="相序校验"/>
|
||||
<!-- <el-step :status="step6" title="遥控录波功能验证"/> -->
|
||||
<el-step :status="step6" :title="ts === 'error'? '检测失败':ts === 'process'? '检测中':ts === 'success'? '检测成功':'待检测'"/>
|
||||
</el-steps>
|
||||
</div>
|
||||
<div class="dialog-right">
|
||||
<el-collapse v-model="collapseActiveName" accordion>
|
||||
<el-collapse-item title="设备通讯校验" name="1">
|
||||
<div class="div-log">
|
||||
<p v-for="(item, index) in step1InitLog" :key="index"
|
||||
:style="{ color: item.type === 'error' ? '#F56C6C' : 'var(--el-text-color-regular)' }">
|
||||
{{ item.log }} <br/>
|
||||
</p>
|
||||
</div>
|
||||
</el-collapse-item>
|
||||
<el-collapse-item title="协议校验" name="2">
|
||||
<div class="div-log">
|
||||
<p v-for="(item, index) in step2InitLog" :key="index"
|
||||
:style="{ color: item.type === 'error' ? '#F56C6C' : 'var(--el-text-color-regular)' }">
|
||||
{{ item.log }} <br/>
|
||||
</p>
|
||||
</div>
|
||||
</el-collapse-item>
|
||||
<el-collapse-item title="模型一致性校验" name="3">
|
||||
<div class="div-log">
|
||||
<p v-for="(item, index) in step3InitLog" :key="index"
|
||||
:style="{ color: item.type === 'error' ? '#F56C6C' : 'var(--el-text-color-regular)' }">
|
||||
{{ item.log }} <br/>
|
||||
</p>
|
||||
</div>
|
||||
</el-collapse-item>
|
||||
<el-collapse-item name="4">
|
||||
<template #title>
|
||||
实时数据对齐验证
|
||||
<el-icon class="title-icon" @click="openDialog"><InfoFilled/></el-icon>
|
||||
</template>
|
||||
<div class="div-log">
|
||||
<p v-for="(item, index) in step4InitLog" :key="index"
|
||||
:style="{ color: item.type === 'error' ? '#F56C6C' : 'var(--el-text-color-regular)' }">
|
||||
{{ item.log }}
|
||||
<br/>
|
||||
</p>
|
||||
</div>
|
||||
</el-collapse-item>
|
||||
<el-collapse-item title="相序校验" name="5">
|
||||
<div class="div-log">
|
||||
<p v-for="(item, index) in step5InitLog" :key="index"
|
||||
:style="{ color: item.type === 'error' ? '#F56C6C' : 'var(--el-text-color-regular)' }">
|
||||
{{ item.log }} <br/>
|
||||
</p>
|
||||
</div>
|
||||
</el-collapse-item>
|
||||
<!-- <el-collapse-item title="遥控录波功能验证" name="3">
|
||||
<div class="div-log">
|
||||
<p v-for="(item, index) in step3InitLog" :key="index"
|
||||
:style="{ color: item.type === 'error' ? '#F56C6C' : 'var(--el-text-color-regular)' }">
|
||||
{{ item.log.split('&&')[0] }}
|
||||
<br v-if="item.log.includes('&&')"/>
|
||||
{{ item.log.split('&&')[1] }}
|
||||
|
||||
<br v-if="item.log.includes('&&')"/>
|
||||
{{ item.log.split('&&')[2] }}
|
||||
|
||||
</p>
|
||||
</div>
|
||||
</el-collapse-item> -->
|
||||
</el-collapse>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<RealTimeData ref="realTimeDataRef"/>
|
||||
</template>
|
||||
<script lang="tsx" setup name="preTest">
|
||||
import {ElMessage, ElMessageBox, StepProps} from "element-plus";
|
||||
import {defineExpose, ref, toRef, watch} from 'vue';
|
||||
import RealTimeData from './realTimeDataAlign.vue'
|
||||
|
||||
const realTimeDataRef = ref()
|
||||
|
||||
|
||||
const step1InitLog = ref([
|
||||
{
|
||||
type: 'info',
|
||||
log: '暂无数据,等待检测开始',
|
||||
},
|
||||
])
|
||||
|
||||
const step2InitLog = ref([
|
||||
{
|
||||
type: 'info',
|
||||
log: '暂无数据,等待检测开始',
|
||||
},
|
||||
])
|
||||
|
||||
const step3InitLog = ref([
|
||||
{
|
||||
type: 'info',
|
||||
log: '暂无数据,等待检测开始',
|
||||
},
|
||||
])
|
||||
|
||||
const step4InitLog = ref([
|
||||
{
|
||||
type: 'info',
|
||||
log: '暂无数据,等待检测开始',
|
||||
},
|
||||
])
|
||||
|
||||
const step5InitLog = ref([
|
||||
{
|
||||
type: 'info',
|
||||
log: '暂无数据,等待检测开始',
|
||||
},
|
||||
])
|
||||
|
||||
|
||||
|
||||
const collapseActiveName = ref('1')
|
||||
const activeIndex = ref(0)
|
||||
const activeTotalNum = ref(5)
|
||||
const step1 = ref<StepProps['status']>('wait')
|
||||
const step2 = ref<StepProps['status']>('wait')
|
||||
const step3 = ref<StepProps['status']>('wait')
|
||||
const step4 = ref<StepProps['status']>('wait')
|
||||
const step5 = ref<StepProps['status']>('wait')
|
||||
const step6 = ref<StepProps['status']>('wait')
|
||||
|
||||
//定义与预检测配置数组
|
||||
const detectionOptions = ref([
|
||||
{
|
||||
id: 0,
|
||||
name: "设备通讯校验",
|
||||
selected: true,
|
||||
},
|
||||
{
|
||||
id: 1,
|
||||
name: "协议校验",
|
||||
selected: true,
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: "模型一致性校验",
|
||||
selected: true,
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
name: "实时数据对齐验证",
|
||||
selected: true,
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
name: "相序校验",
|
||||
selected: true,
|
||||
},
|
||||
]);
|
||||
|
||||
const currentStepStatus = ref<'error' | 'finish' | 'wait' | 'success' | 'process'>('finish');
|
||||
|
||||
const props = defineProps({
|
||||
testStatus: {
|
||||
type: String,
|
||||
default: 'wait'
|
||||
},
|
||||
webMsgSend: {
|
||||
type: Object,
|
||||
default: () => ({})
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
const testStatus = toRef(props, 'testStatus');
|
||||
const webMsgSend = toRef(props, 'webMsgSend');
|
||||
const ts = ref('');
|
||||
|
||||
watch(webMsgSend, function (newValue, oldValue) {
|
||||
if (testStatus.value !== 'waiting') {
|
||||
switch (newValue.requestId) {
|
||||
case 'yjc_sbtxjy':
|
||||
|
||||
switch (newValue.operateCode) {
|
||||
case 'INIT_GATHER$01':
|
||||
if (newValue.code == 10200) {
|
||||
step1InitLog.value.push({
|
||||
type: 'info',
|
||||
log: newValue.data + '设备通讯校验成功!',
|
||||
})
|
||||
|
||||
} else if (newValue.code == 10201) {
|
||||
step1.value = 'process'
|
||||
step1InitLog.value = [{
|
||||
type: 'wait',
|
||||
log: '正在进行设备通讯校验.....',
|
||||
}];
|
||||
} else if (newValue.code == 10550) {
|
||||
step1InitLog.value.push({
|
||||
type: 'error',
|
||||
log: newValue.data + '设备连接异常!',
|
||||
})
|
||||
step1.value = 'error'
|
||||
// ts.value = 'error'
|
||||
// step6.value = 'error'
|
||||
} else if (newValue.code == 10551) {
|
||||
step1InitLog.value.push({
|
||||
type: 'error',
|
||||
log: newValue.data + '设备触发报告异常!',
|
||||
})
|
||||
step1.value = 'error'
|
||||
ts.value = 'error'
|
||||
step6.value = 'error'
|
||||
} else if (newValue.code == 10552) {
|
||||
//ElMessage.error("存在已经初始化步骤,已经自动关闭,请重新发起检测!")
|
||||
step2InitLog.value = [{
|
||||
type: 'wait',
|
||||
log: '存在已经初始化步骤,执行自动关闭,请重新发起检测!',
|
||||
}];
|
||||
step1.value = 'error'
|
||||
ts.value = 'error'
|
||||
step6.value = 'error'
|
||||
} else if (newValue.code == 25001) {
|
||||
activeIndex.value = 1
|
||||
step1.value = 'success'
|
||||
step3.value = 'process'
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
case 'yjc_xyjy':
|
||||
switch (newValue.operateCode) {
|
||||
case 'INIT_GATHER$01':
|
||||
if (newValue.code == 10200) {
|
||||
step2InitLog.value.push({
|
||||
type: 'info',
|
||||
log: '统计数据协议校验:' + newValue.data + '通讯协议校验成功!',
|
||||
})
|
||||
|
||||
} else if (newValue.code == 10201) {
|
||||
step2.value = 'process'
|
||||
step2InitLog.value = [{
|
||||
type: 'wait',
|
||||
log: '正在进行通讯协议校验.....',
|
||||
}];
|
||||
} else if (newValue.code == 10550) {
|
||||
step2InitLog.value.push({
|
||||
type: 'error',
|
||||
log: newValue.data + '设备连接异常!',
|
||||
})
|
||||
step2.value = 'error'
|
||||
// ts.value = 'error'
|
||||
// step5.value = 'error'
|
||||
} else if (newValue.code == 10551) {
|
||||
step3InitLog.value.push({
|
||||
type: 'error',
|
||||
log: newValue.data + '设备触发报告异常!',
|
||||
})
|
||||
step3.value = 'error'
|
||||
ts.value = 'error'
|
||||
step5.value = 'error'
|
||||
} else if (newValue.code == 10552) {
|
||||
step3.value = 'error'
|
||||
//ElMessage.error("存在已经初始化步骤,已经自动关闭,请重新发起检测!")
|
||||
step3InitLog.value = [{
|
||||
type: 'wait',
|
||||
log: '存在已经初始化步骤,执行自动关闭,请重新发起检测!',
|
||||
}];
|
||||
ts.value = 'error'
|
||||
step5.value = 'error'
|
||||
}
|
||||
break;
|
||||
case 'INIT_GATHER$02':
|
||||
if (newValue.code == 10200) {
|
||||
step3InitLog.value.push({
|
||||
type: 'info',
|
||||
log: '实时数据协议校验:' + newValue.data + '通讯协议校验成功!',
|
||||
})
|
||||
|
||||
} else if (newValue.code == 10201) {
|
||||
step3.value = 'process'
|
||||
step3InitLog.value = [{
|
||||
type: 'wait',
|
||||
log: '正在进行通讯协议校验.....',
|
||||
}];
|
||||
} else if (newValue.code == 10550) {
|
||||
step3InitLog.value.push({
|
||||
type: 'error',
|
||||
log: newValue.data + '设备连接异常!',
|
||||
})
|
||||
step3.value = 'error'
|
||||
// ts.value = 'error'
|
||||
// step5.value = 'error'
|
||||
} else if (newValue.code == 10551) {
|
||||
step3InitLog.value.push({
|
||||
type: 'error',
|
||||
log: newValue.data + '设备触发报告异常!',
|
||||
})
|
||||
step3.value = 'error'
|
||||
ts.value = 'error'
|
||||
step5.value = 'error'
|
||||
} else if (newValue.code == 10552) {
|
||||
step3.value = 'error'
|
||||
//ElMessage.error("存在已经初始化步骤,已经自动关闭,请重新发起检测!")
|
||||
step3InitLog.value = [{
|
||||
type: 'wait',
|
||||
log: '存在已经初始化步骤,执行自动关闭,请重新发起检测!',
|
||||
}];
|
||||
ts.value = 'error'
|
||||
step5.value = 'error'
|
||||
}
|
||||
break;
|
||||
case 'INIT_GATHER$03':
|
||||
if (newValue.code == 10200) {
|
||||
step3InitLog.value.push({
|
||||
type: 'info',
|
||||
log: '暂态数据协议校验:' + newValue.data + '通讯协议校验成功!',
|
||||
})
|
||||
|
||||
} else if (newValue.code == 10201) {
|
||||
step3.value = 'process'
|
||||
} else if (newValue.code == 10550) {
|
||||
step3InitLog.value.push({
|
||||
type: 'error',
|
||||
log: newValue.data + '设备连接异常!',
|
||||
})
|
||||
step3.value = 'error'
|
||||
// ts.value = 'error'
|
||||
// step5.value = 'error'
|
||||
} else if (newValue.code == 10551) {
|
||||
step3InitLog.value.push({
|
||||
type: 'error',
|
||||
log: newValue.data + '设备触发报告异常!',
|
||||
})
|
||||
step3.value = 'error'
|
||||
ts.value = 'error'
|
||||
step5.value = 'error'
|
||||
} else if (newValue.code == 10552) {
|
||||
//ElMessage.error("当前步骤已经初始化,执行自动关闭,请重新发起检测!")
|
||||
step3.value = 'error'
|
||||
step3InitLog.value = [{
|
||||
type: 'wait',
|
||||
log: '存在已经初始化步骤,执行自动关闭,请重新发起检测!',
|
||||
}];
|
||||
ts.value = 'error'
|
||||
step5.value = 'error'
|
||||
}
|
||||
break;
|
||||
case 'VERIFY_MAPPING$01':
|
||||
if (newValue.code == 25001) {
|
||||
activeIndex.value = 3
|
||||
step3.value = 'success'
|
||||
step4.value = 'process'
|
||||
} else if (newValue.code == 10200) {
|
||||
let data = JSON.parse(newValue.data)
|
||||
step3InitLog.value.push({
|
||||
type: 'error',
|
||||
log: `脚本与icd检验失败! icd名称:${data['icdType']} -> 校验项:${data['dataType']}`,
|
||||
})
|
||||
step3.value = 'error'
|
||||
ts.value = 'error'
|
||||
step5.value = 'error'
|
||||
} else if (newValue.code == 10500) {
|
||||
step3InitLog.value.push({
|
||||
type: 'error',
|
||||
log: `装置中未找到该icd!`,
|
||||
})
|
||||
step3.value = 'error'
|
||||
ts.value = 'error'
|
||||
step5.value = 'error'
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'YJC_xujy':
|
||||
switch (newValue.operateCode) {
|
||||
case 'OPER_GATHER':
|
||||
if (newValue.code == 10200) {
|
||||
step4InitLog.value.push({
|
||||
type: 'info',
|
||||
log: '源参数下发成功,等待校验中.....',
|
||||
})
|
||||
|
||||
} else if (newValue.code == 10201) {
|
||||
step4.value = 'process'
|
||||
step4InitLog.value = [{
|
||||
type: 'wait',
|
||||
log: '源参数下发中.....',
|
||||
}];
|
||||
} else if (newValue.code == 10552) {
|
||||
ElMessage.error("存在已经初始化步骤,已经自动关闭,请重新发起检测!")
|
||||
step4.value = 'error'
|
||||
ts.value = 'error'
|
||||
step5.value = 'error'
|
||||
} else if (newValue.code == 10520) {
|
||||
step4.value = 'error'
|
||||
step4InitLog.value.push({
|
||||
type: 'error',
|
||||
log: '解析报文异常',
|
||||
})
|
||||
ts.value = 'error'
|
||||
step5.value = 'error'
|
||||
}
|
||||
break;
|
||||
|
||||
case 'DATA_REQUEST$02':
|
||||
if (newValue.code == 10200) {
|
||||
let type = 'info'
|
||||
if (newValue.data.includes('不合格')) {
|
||||
type = 'error'
|
||||
}
|
||||
|
||||
newValue.data.split('<br/>')
|
||||
step4InitLog.value.push({
|
||||
type: type,
|
||||
log: newValue.data,
|
||||
})
|
||||
|
||||
} else if (newValue.code == 10201) {
|
||||
step4.value = 'process'
|
||||
step4InitLog.value = [{
|
||||
type: 'wait',
|
||||
log: '获取数据相序校验数据!',
|
||||
}];
|
||||
} else if (newValue.code == 25003) {
|
||||
step4.value = 'error'
|
||||
step4InitLog.value.push({
|
||||
type: 'error',
|
||||
log: '相序校验未通过!',
|
||||
})
|
||||
ts.value = 'error'
|
||||
step5.value = 'error'
|
||||
} else if (newValue.code == 25001) {
|
||||
step4.value = 'success'
|
||||
step5.value = 'success'
|
||||
step4InitLog.value.push({
|
||||
type: 'wait',
|
||||
log: '相序校验成功!',
|
||||
})
|
||||
ts.value = 'success'
|
||||
}
|
||||
activeIndex.value = 5
|
||||
console.log("@@@@", ts.value)
|
||||
break
|
||||
}
|
||||
|
||||
break;
|
||||
case 'quit':
|
||||
break;
|
||||
case 'connect':
|
||||
switch (newValue.operateCode) {
|
||||
case "Source":
|
||||
step1.value = 'error'
|
||||
step1InitLog.value = [{
|
||||
type: 'error',
|
||||
log: '源服务端连接失败!',
|
||||
}];
|
||||
ts.value = 'error'
|
||||
step5.value = 'error'
|
||||
break;
|
||||
case "Dev":
|
||||
step2.value = 'error'
|
||||
step2InitLog.value = [{
|
||||
type: 'error',
|
||||
log: '设备服务端连接失败!',
|
||||
}];
|
||||
ts.value = 'error'
|
||||
step5.value = 'error'
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'unknown_operate':
|
||||
|
||||
break;
|
||||
case 'error_flow_end':
|
||||
ElMessageBox.alert(`设备连接异常,请检查设备连接情况!`, '检测失败', {
|
||||
confirmButtonText: '确定',
|
||||
type: 'error',
|
||||
})
|
||||
ts.value = 'error'
|
||||
step5.value = 'error'
|
||||
break;
|
||||
case 'socket_timeout':
|
||||
ElMessageBox.alert(`设备连接异常,请检查设备连接情况!`, '检测失败', {
|
||||
confirmButtonText: '确定',
|
||||
type: 'error',
|
||||
})
|
||||
ts.value = 'error'
|
||||
step5.value = 'error'
|
||||
break;
|
||||
case 'server_error':
|
||||
ElMessageBox.alert('服务端主动关闭连接!', '初始化失败', {
|
||||
confirmButtonText: '确定',
|
||||
type: 'error',
|
||||
})
|
||||
ts.value = 'error'
|
||||
step5.value = 'error'
|
||||
break;
|
||||
case 'device_error':
|
||||
ElMessageBox.alert('设备主动关闭连接!', '初始化失败', {
|
||||
confirmButtonText: '确定',
|
||||
type: 'error',
|
||||
})
|
||||
ts.value = 'error'
|
||||
step5.value = 'error'
|
||||
break;
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
watch(activeIndex, function (newValue, oldValue) {
|
||||
if (newValue <= activeTotalNum.value - 2) {
|
||||
collapseActiveName.value = (newValue + 1).toString()
|
||||
} else {
|
||||
collapseActiveName.value = (newValue - 1).toString()
|
||||
}
|
||||
})
|
||||
|
||||
//监听goods_sn的变化
|
||||
watch(testStatus, function (newValue, oldValue) {
|
||||
ts.value = props.testStatus;
|
||||
if (ts.value === 'start') {
|
||||
ts.value = 'process'
|
||||
} else if (ts.value === 'waiting') {
|
||||
activeIndex.value = 0
|
||||
step1InitLog.value = [
|
||||
{
|
||||
type: 'info',
|
||||
log: '暂无数据,等待检测开始',
|
||||
},
|
||||
]
|
||||
step1.value = 'finish'
|
||||
step2.value = 'wait'
|
||||
step3.value = 'wait'
|
||||
step4.value = 'wait'
|
||||
step5.value = 'wait'
|
||||
}
|
||||
})
|
||||
|
||||
const emit = defineEmits(['update:testStatus']);
|
||||
//监听sn
|
||||
watch(ts, function (newValue, oldValue) {
|
||||
//修改父组件
|
||||
emit('update:testStatus', ts.value)
|
||||
})
|
||||
|
||||
|
||||
// 定义一个初始化参数的方法
|
||||
function initializeParameters() {
|
||||
activeIndex.value = 0
|
||||
step1.value = 'process'
|
||||
step2.value = 'wait'
|
||||
step3.value = 'wait'
|
||||
step4.value = 'wait'
|
||||
step5.value = 'wait'
|
||||
|
||||
step1InitLog.value = [
|
||||
{
|
||||
type: 'info',
|
||||
log: '暂无数据,等待检测开始',
|
||||
},
|
||||
]
|
||||
step2InitLog.value = [
|
||||
{
|
||||
type: 'info',
|
||||
log: '暂无数据,等待检测开始',
|
||||
},
|
||||
]
|
||||
step3InitLog.value = [
|
||||
{
|
||||
type: 'info',
|
||||
log: '暂无数据,等待检测开始',
|
||||
},
|
||||
]
|
||||
step4InitLog.value = [
|
||||
{
|
||||
type: 'info',
|
||||
log: '暂无数据,等待检测开始',
|
||||
},
|
||||
]
|
||||
step5InitLog.value = [
|
||||
{
|
||||
type: 'info',
|
||||
log: '暂无数据,等待检测开始',
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
const openDialog = () => {
|
||||
realTimeDataRef.value.open()
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
initializeParameters,
|
||||
});
|
||||
</script>
|
||||
<style scoped lang="scss">
|
||||
|
||||
|
||||
.title-icon {
|
||||
margin-left: 10px;
|
||||
cursor: pointer;
|
||||
font-size: 16px;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.test-dialog {
|
||||
height: 350px;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
/* 横向排列 */
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
.dialog-left {
|
||||
width: 15%;
|
||||
margin-left: 20px;
|
||||
}
|
||||
|
||||
.dialog-right {
|
||||
margin-left: 20px;
|
||||
width: 80%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.dialog-right :deep(.el-collapse-item__header) {
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.div-log {
|
||||
height: 145px;
|
||||
overflow-y: auto;
|
||||
padding-left: 10px;
|
||||
|
||||
p {
|
||||
margin: 5px 0;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
}
|
||||
</style>
|
||||
470
frontend/src/views/home/components/compareTestPopup.vue
Normal file
470
frontend/src/views/home/components/compareTestPopup.vue
Normal file
@@ -0,0 +1,470 @@
|
||||
<template>
|
||||
<el-dialog :title="dialogTitle" width="1550px" :model-value="dialogVisible" :before-close="beforeClose" @close="handleClose" height="1000px" draggable>
|
||||
|
||||
<div class="steps-container">
|
||||
<el-steps v-if="showSteps" class="test-head-steps" simple :active="stepsActiveIndex" process-status="finish" finish-status="success">
|
||||
<el-step v-if="preTestSelected" title="预检测" :icon="stepsActive > 1 || stepsActiveIndex > stepsTotalNum - 1? SuccessFilled :Edit" @click="handleStepClick(1)"/>
|
||||
|
||||
<el-step v-if="testSelected" title="正式检测" :icon="stepsActive > 2 || stepsActiveIndex > stepsTotalNum - 1? SuccessFilled :Coin" @click="handleStepClick(2)"/>
|
||||
<el-step title="检测完成" :icon="stepsActiveIndex > stepsTotalNum-1 ? SuccessFilled :Key"/>
|
||||
</el-steps>
|
||||
</div>
|
||||
|
||||
<ComparePreTest v-if="showComponent&&preTestSelected" v-show="preTestSelected && stepsActiveView==1" ref="preTestRef" v-model:testStatus="preTestStatus"
|
||||
:webMsgSend="webMsgSend"/>
|
||||
<test v-if="showComponent&&testSelected" ref="testRef" v-show="testSelected && stepsActiveView==2" v-model:testStatus="TestStatus" :webMsgSend="webMsgSend"
|
||||
@update:webMsgSend="webMsgSend=$event" @sendPause="sendPause" @sendResume="sendResume" @sendReCheck="sendReCheck" @closeWebSocket="closeWebSocket"
|
||||
:stepsActive="stepsActive"/>
|
||||
|
||||
<template #footer>
|
||||
<div>
|
||||
<el-button type="primary" :icon="VideoPlay" v-if="ActiveStatue === 'waiting'" @click="handleSubmitFast">开始检测</el-button>
|
||||
<el-button type="primary" v-if="TestStatus === 'test_init'" disabled>
|
||||
<el-icon class="loading-box" style="color: #fff;margin-right: 8px;">
|
||||
<component :is="Refresh"/>
|
||||
</el-icon>
|
||||
初始化中
|
||||
</el-button>
|
||||
<el-button
|
||||
type="primary"
|
||||
v-if="TestStatus=='process'"
|
||||
:icon="VideoPause"
|
||||
@click="handlePause()">停止检测
|
||||
</el-button>
|
||||
<el-button type="warning" v-if="TestStatus === 'paused_ing'" disabled>
|
||||
<el-icon class="loading-box" style="color: #fff;margin-right: 8px;">
|
||||
<component :is="Refresh"/>
|
||||
</el-icon>
|
||||
暂停中
|
||||
</el-button>
|
||||
<el-button
|
||||
type="warning"
|
||||
v-if="(TestStatus =='paused')"
|
||||
:icon="VideoPlay"
|
||||
@click="sendResume"
|
||||
>继续检测
|
||||
</el-button>
|
||||
|
||||
<el-button :type="ActiveStatue==='success'?'primary':'danger'" :icon="Right"
|
||||
v-if="nextStepText !== '下一步' && (ActiveStatue === 'success'||ActiveStatue==='error'||ActiveStatue==='test_init_fail'||ActiveStatue==='connect_timeout'||ActiveStatue==='pause_timeout')"
|
||||
@click="nextStep">
|
||||
{{ nextStepText }}
|
||||
</el-button>
|
||||
<el-button type="primary" @click="handleQuit" v-else>
|
||||
退出检测
|
||||
</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
|
||||
</template>
|
||||
|
||||
<script lang="tsx" setup name="testPopup">
|
||||
import {reactive, ref, watch} from 'vue';
|
||||
import {ElMessage, ElMessageBox} from 'element-plus'
|
||||
import {Coin, Edit, Key, Odometer, Refresh, Right, SuccessFilled, UploadFilled, VideoPause, VideoPlay} from '@element-plus/icons-vue'
|
||||
import ComparePreTest from './comparePreTest.vue'
|
||||
import test from './test.vue'
|
||||
import socketClient from '@/utils/webSocketClient';
|
||||
import {useCheckStore} from "@/stores/modules/check";
|
||||
import {pauseTest, resumeTest, startPreTest} from '@/api/socket/socket'
|
||||
import {useUserStore} from "@/stores/modules/user";
|
||||
|
||||
|
||||
const userStore = useUserStore()
|
||||
const checkStore = useCheckStore();
|
||||
const nextStepText = ref('下一步');
|
||||
const dialogVisible = ref(false)
|
||||
|
||||
const showSteps = ref(false)
|
||||
const stepsTotalNum = ref(-1);//步骤总数
|
||||
const stepsActiveIndex = ref(1); //当前正在执行的步骤索引
|
||||
const stepsActiveView = ref(-1); //当前正在执行的步骤在(预处理、守时校验、系数校准、正式检测)中的排序,仅用于页面显示
|
||||
const stepsActive = ref(-1); //当前正在执行的步骤在(预处理、守时校验、系数校准、正式检测)中的排序,实际记录步骤的状态,用于切换步骤
|
||||
const ActiveStatue = ref('waiting');//当前步骤状态
|
||||
const preTestStatus = ref('waiting');//预检测执行状态
|
||||
const TestStatus = ref('waiting');//正式检测执行状态
|
||||
const webMsgSend = ref();//webSocket推送的数据
|
||||
|
||||
|
||||
const dialogTitle = ref('')
|
||||
const showComponent = ref(true)
|
||||
const preTestRef = ref(null)
|
||||
const testRef = ref(null)
|
||||
|
||||
const dataSocket = reactive({
|
||||
socketServe: socketClient.Instance,
|
||||
});
|
||||
|
||||
// 勾选的检测内容
|
||||
const preTestSelected = ref(false)
|
||||
const testSelected = ref(false)
|
||||
|
||||
const initOperate = () => {
|
||||
ActiveStatue.value = 'waiting'
|
||||
preTestStatus.value = 'waiting'
|
||||
|
||||
TestStatus.value = 'waiting'
|
||||
|
||||
stepsActiveIndex.value = 1
|
||||
showComponent.value = true
|
||||
// 初始化勾选的检测内容
|
||||
preTestSelected.value = checkStore.selectTestItems.preTest
|
||||
testSelected.value = checkStore.selectTestItems.test
|
||||
|
||||
let count = 0
|
||||
for (let key in checkStore.selectTestItems) {
|
||||
if (checkStore.selectTestItems[key]) {
|
||||
count++
|
||||
}
|
||||
}
|
||||
stepsTotalNum.value = count + 1
|
||||
|
||||
if (preTestSelected.value) {
|
||||
stepsActiveView.value = 1
|
||||
stepsActive.value = 1
|
||||
return
|
||||
}
|
||||
if (testSelected.value) {
|
||||
stepsActiveView.value = 2
|
||||
stepsActive.value = 2
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
const open = (title: string,sourceIds: string[]) => {
|
||||
|
||||
showSteps.value = true
|
||||
initOperate()
|
||||
dialogTitle.value = title;
|
||||
dialogVisible.value = true;
|
||||
|
||||
if (preTestRef.value) {
|
||||
preTestRef.value.initializeParameters();
|
||||
}
|
||||
|
||||
//开始创建webSocket客户端
|
||||
socketClient.Instance.connect();
|
||||
dataSocket.socketServe = socketClient.Instance;
|
||||
dataSocket.socketServe.registerCallBack('aaa', (res: { code: number; }) => {
|
||||
// 处理来自服务器的消息
|
||||
// console.log('Received message:', res);
|
||||
if (res.code === 20000) {
|
||||
//ElMessage.error(message.message)
|
||||
// loading.close()
|
||||
} else {
|
||||
webMsgSend.value = res
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
const handleSubmitFast = () => {
|
||||
let deviceIds = checkStore.devices.map((item) => item.deviceId)
|
||||
let planId = checkStore.plan.id
|
||||
|
||||
if (!dataSocket.socketServe.connected) {
|
||||
ElMessage.error('webSocket连接中断!')
|
||||
return
|
||||
}
|
||||
console.log("handleSubmit", stepsActive.value, TestStatus.value)
|
||||
switch (stepsActive.value) {
|
||||
case 1:
|
||||
if (preTestStatus.value == 'waiting') {
|
||||
if (checkStore.selectTestItems.preTest) {
|
||||
startPreTest({
|
||||
userPageId: "cdf",
|
||||
devIds: deviceIds,
|
||||
planId: planId,
|
||||
operateType: checkStore.reCheckType == 1 ? '1' : '2',
|
||||
userId: userStore.userInfo.id,
|
||||
temperature: checkStore.temperature,
|
||||
humidity: checkStore.humidity,
|
||||
testItemList: [checkStore.selectTestItems.preTest, checkStore.selectTestItems.channelsTest, checkStore.selectTestItems.test]
|
||||
}).then(res => {
|
||||
if (res.code === 'A001014') {
|
||||
ElMessageBox.alert('装置配置异常', '检测失败', {
|
||||
confirmButtonText: '确定',
|
||||
type: 'error',
|
||||
})
|
||||
preTestStatus.value = 'error'
|
||||
}
|
||||
})
|
||||
preTestStatus.value = 'start'
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if (TestStatus.value == "waiting") {
|
||||
if (!checkStore.selectTestItems.preTest && !checkStore.selectTestItems.channelsTest && checkStore.selectTestItems.test) {
|
||||
startPreTest({
|
||||
userPageId: "cdf",
|
||||
devIds: deviceIds,
|
||||
planId: planId,
|
||||
operateType: checkStore.reCheckType == 1 ? '1' : '2',
|
||||
userId: userStore.userInfo.id,
|
||||
temperature: checkStore.temperature,
|
||||
humidity: checkStore.humidity,
|
||||
testItemList: [checkStore.selectTestItems.preTest, checkStore.selectTestItems.channelsTest, checkStore.selectTestItems.test]
|
||||
}).then(res => {
|
||||
if (res.code === 'A001014') {
|
||||
ElMessageBox.alert('装置配置异常', '初始化失败', {
|
||||
confirmButtonText: '确定',
|
||||
type: 'error',
|
||||
})
|
||||
TestStatus.value = 'test_init_fail'
|
||||
}
|
||||
})
|
||||
}
|
||||
TestStatus.value = 'start'
|
||||
} else if (TestStatus.value == 'paused') {
|
||||
// 发送继续指令
|
||||
sendResume()
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'quitClicked'): void;
|
||||
}>();
|
||||
|
||||
watch(preTestStatus, function (newValue, oldValue) {
|
||||
console.log('预检测',newValue, oldValue);
|
||||
|
||||
ActiveStatue.value = newValue
|
||||
})
|
||||
|
||||
watch(TestStatus, function (newValue, oldValue) {
|
||||
console.log(newValue, oldValue);
|
||||
|
||||
ActiveStatue.value = newValue
|
||||
})
|
||||
|
||||
watch(ActiveStatue, function (newValue, oldValue) {
|
||||
if (newValue === 'error') {
|
||||
stepsActiveIndex.value = stepsTotalNum.value + 1
|
||||
nextStepText.value = '检测失败'
|
||||
}
|
||||
if (newValue === 'success' && stepsActiveIndex.value === stepsTotalNum.value - 1) {
|
||||
stepsActiveIndex.value += 2
|
||||
nextStepText.value = '检测完成'
|
||||
}
|
||||
if (newValue === 'test_init_fail') {
|
||||
stepsActiveIndex.value += 2
|
||||
nextStepText.value = '初始化失败'
|
||||
}
|
||||
if (newValue === 'connect_timeout') {
|
||||
stepsActiveIndex.value += 2
|
||||
nextStepText.value = '连接超时'
|
||||
}
|
||||
if (newValue === 'pause_timeout') {
|
||||
stepsActiveIndex.value += 2
|
||||
// nextStepText.value = '结束测试'
|
||||
nextStepText.value = '暂停超时'
|
||||
}
|
||||
if (newValue === 'success' && stepsActiveIndex.value < stepsTotalNum.value - 1) {
|
||||
nextStep() // 实现自动点击,进入下一个测试内容
|
||||
//handleSubmit()
|
||||
handleSubmitFast()
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
const handleQuit = () => {
|
||||
console.log('handleQuit', ActiveStatue.value)
|
||||
if (ActiveStatue.value !== 'success' && ActiveStatue.value !== 'waiting' && ActiveStatue.value !== 'paused' && ActiveStatue.value !== 'test_init_fail' && ActiveStatue.value !== 'connect_timeout' && ActiveStatue.value !== 'pause_timeout') {
|
||||
beforeClose(() => {
|
||||
})
|
||||
} else {
|
||||
handleClose()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const handlePause = () => {
|
||||
sendPause()
|
||||
testRef.value?.handlePause()
|
||||
}
|
||||
const sendPause = () => {
|
||||
console.log('发起暂停请求')
|
||||
|
||||
TestStatus.value = 'paused_ing'
|
||||
pauseTest()
|
||||
}
|
||||
const sendResume = () => {
|
||||
console.log('发起继续检测请求')
|
||||
|
||||
resumeTest({
|
||||
userPageId: "cdf",
|
||||
devIds: checkStore.devices.map((item) => item.deviceId),
|
||||
planId: checkStore.plan.id,
|
||||
operateType: '2', // 0:'系数校验','1'为预检测、‘2‘为正式检测、'8'为不合格项复检
|
||||
userId: userStore.userInfo.id,
|
||||
temperature: checkStore.temperature,
|
||||
humidity: checkStore.humidity
|
||||
})
|
||||
Object.assign(webMsgSend.value, {
|
||||
requestId: 'Resume_Success'
|
||||
})
|
||||
}
|
||||
|
||||
const sendReCheck = () => {
|
||||
console.log('发送重新检测指令')
|
||||
startPreTest({
|
||||
userPageId: "cdf",
|
||||
devIds: checkStore.devices.map((item) => item.deviceId),
|
||||
planId: checkStore.plan.id,
|
||||
operateType: '2', // 0:'系数校验','1'为预检测、‘2‘为正式检测、'8'为不合格项复检
|
||||
userId: userStore.userInfo.id,
|
||||
temperature: checkStore.temperature,
|
||||
humidity: checkStore.humidity,
|
||||
testItemList: [checkStore.selectTestItems.preTest, checkStore.selectTestItems.channelsTest, checkStore.selectTestItems.test]
|
||||
}).then(res => {
|
||||
console.log(res)
|
||||
if (res.code === 'A001014') {
|
||||
ElMessageBox.alert('装置配置异常', '初始化失败', {
|
||||
confirmButtonText: '确定',
|
||||
type: 'error',
|
||||
})
|
||||
TestStatus.value = 'test_init_fail'
|
||||
}
|
||||
})
|
||||
TestStatus.value = 'start'
|
||||
}
|
||||
|
||||
const closeWebSocket = () => {
|
||||
dataSocket.socketServe.closeWs()
|
||||
}
|
||||
|
||||
const nextStep = () => {
|
||||
if (stepsActiveIndex.value == stepsTotalNum.value + 1 || ActiveStatue.value === 'error' || ActiveStatue.value === 'test_init_fail' || ActiveStatue.value === 'connect_timeout' || ActiveStatue.value === 'pause_timeout') {
|
||||
handleClose()
|
||||
return
|
||||
}
|
||||
if (ActiveStatue.value != 'error') {
|
||||
ActiveStatue.value = 'waiting'
|
||||
let tempStep = stepsActiveIndex.value
|
||||
let idx = 1
|
||||
stepsActiveIndex.value++
|
||||
for (let selectTestItemsKey in checkStore.selectTestItems) {
|
||||
if (tempStep == 0 && checkStore.selectTestItems[selectTestItemsKey]) {
|
||||
stepsActiveView.value = idx
|
||||
stepsActive.value = idx
|
||||
return
|
||||
}
|
||||
if (checkStore.selectTestItems[selectTestItemsKey] && tempStep != 0) {
|
||||
tempStep--
|
||||
}
|
||||
idx++
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const handleStepClick = (step: number) => {
|
||||
if (step > stepsActive.value) {
|
||||
return
|
||||
} else {
|
||||
stepsActiveView.value = step
|
||||
}
|
||||
}
|
||||
|
||||
function clearData() {
|
||||
stepsTotalNum.value = -1
|
||||
stepsActiveIndex.value = 1
|
||||
stepsActiveView.value = -1
|
||||
preTestStatus.value = "waiting"
|
||||
TestStatus.value = "waiting"
|
||||
ActiveStatue.value = "waiting"
|
||||
nextStepText.value = "下一步"
|
||||
}
|
||||
|
||||
const beforeClose = (done: () => void) => {
|
||||
if (stepsActiveIndex.value < stepsTotalNum.value && ActiveStatue.value != 'error') {
|
||||
ElMessageBox.confirm('检测未完成,是否退出当前检测流程?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning',
|
||||
}
|
||||
).then(() => {
|
||||
handleClose()
|
||||
})
|
||||
} else {
|
||||
handleClose()
|
||||
}
|
||||
}
|
||||
|
||||
const handleClose = () => {
|
||||
showSteps.value = false
|
||||
dataSocket.socketServe.closeWs()
|
||||
dialogVisible.value = false;
|
||||
clearData()
|
||||
showComponent.value = false;
|
||||
|
||||
emit('quitClicked'); // 触发事件
|
||||
}
|
||||
|
||||
// 对外映射
|
||||
defineExpose({open})
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
|
||||
.test-head-steps {
|
||||
::v-deep .el-step {
|
||||
.el-step__head.is-success {
|
||||
color: #91cc75;
|
||||
}
|
||||
|
||||
.el-step__title.is-success {
|
||||
color: #91cc75;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
:deep(.dialog-big .el-dialog__body) {
|
||||
max-height: 840px !important;
|
||||
}
|
||||
|
||||
.steps-container :deep(.test-head-steps) {
|
||||
height: 80px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.steps-container :deep(.el-step__title) {
|
||||
font-size: 20px !important; /* 设置标题字体大小 */
|
||||
vertical-align: baseline !important;
|
||||
display: inline-block; /* 确保文字和图标在同一行 */
|
||||
line-height: 1; /* 调整行高以确保底部对齐 */
|
||||
}
|
||||
|
||||
.steps-container :deep(.el-step__icon-inner) {
|
||||
font-size: 18px !important;
|
||||
vertical-align: baseline !important;
|
||||
display: inline-block; /* 确保文字和图标在同一行 */
|
||||
line-height: 1; /* 调整行高以确保底部对齐 */
|
||||
}
|
||||
|
||||
.steps-container :deep(.el-step__icon) {
|
||||
font-size: 18px !important;
|
||||
vertical-align: baseline !important;
|
||||
display: inline-block; /* 确保文字和图标在同一行 */
|
||||
line-height: 1; /* 调整行高以确保底部对齐 */
|
||||
}
|
||||
|
||||
.loading-box {
|
||||
animation: loading 1.5s linear infinite;
|
||||
}
|
||||
|
||||
@keyframes loading {
|
||||
from {
|
||||
transform: rotate(0deg);
|
||||
}
|
||||
to {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
362
frontend/src/views/home/components/deviceConnectionPopup.vue
Normal file
362
frontend/src/views/home/components/deviceConnectionPopup.vue
Normal file
@@ -0,0 +1,362 @@
|
||||
<template>
|
||||
<el-dialog title="设备通道配对" v-model='dialogVisible' v-bind="dialogBig">
|
||||
<div class="flow-container" style="overflow: hidden; position: relative;">
|
||||
<el-button @click="logConnections">打印当前配对</el-button>
|
||||
<VueFlow
|
||||
:nodes="nodes"
|
||||
:edges="edges"
|
||||
:connection-radius="30"
|
||||
:nodes-draggable="false"
|
||||
:dragging="false"
|
||||
:zoom-on-scroll="false"
|
||||
:pan-on-drag="false"
|
||||
:disable-zoom-pan-on-connect="true"
|
||||
:prevent-scrolling="true"
|
||||
:fit-view="true"
|
||||
:min-zoom="1"
|
||||
:max-zoom="1"
|
||||
:elements-selectable="false"
|
||||
auto-connect
|
||||
@connect="handleConnect"
|
||||
@connect-start="handleConnectStart"
|
||||
@connect-end="handleConnectEnd"
|
||||
@pane-ready="onPaneReady"
|
||||
v-on:pane-mouse-move="false"
|
||||
>
|
||||
</VueFlow>
|
||||
</div>
|
||||
|
||||
<!-- 底部操作按钮 -->
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button @click="dialogVisible = false">取消</el-button>
|
||||
<el-button type="primary" @click="handleNext">下一步</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<!-- 手动检测-勾选检测项弹窗 -->
|
||||
<SelectTestItemPopup ref="selectTestItemPopupRef" @openTestDialog="openTestDialog"></SelectTestItemPopup>
|
||||
<CompareTestPopup ref='testPopup'></CompareTestPopup>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { h, ref } from 'vue'
|
||||
import { VueFlow, useVueFlow } from '@vue-flow/core'
|
||||
import { dialogBig } from "@/utils/elementBind";
|
||||
import { Platform, Flag } from '@element-plus/icons-vue'
|
||||
import { Device } from '@/api/device/interface/device';
|
||||
import { StandardDevice } from '@/api/device/interface/standardDevice';
|
||||
import SelectTestItemPopup from "@/views/home/components/selectTestItemPopup.vue";
|
||||
import CompareTestPopup from './compareTestPopup.vue'
|
||||
import { ElMessage } from 'element-plus';
|
||||
import CustomEdge from './RemoveableEdge.vue' // 导入自定义连接线组件
|
||||
|
||||
const dialogVisible = ref(false)
|
||||
const selectTestItemPopupRef = ref<InstanceType<typeof SelectTestItemPopup>>()
|
||||
const testPopup = ref()
|
||||
const dialogTitle = ref('手动检测')
|
||||
|
||||
// 初始化 VueFlow,注册自定义连线类型
|
||||
const { edges, setViewport } = useVueFlow({
|
||||
edgeTypes: {
|
||||
default: CustomEdge
|
||||
}
|
||||
})
|
||||
|
||||
// 初始化时锁定画布位置
|
||||
const onPaneReady = () => {
|
||||
setViewport({ x: 0, y: 0, zoom: 1 })
|
||||
}
|
||||
|
||||
// 提取公共的label渲染函数
|
||||
const createLabel = (text: string, type: string) => {
|
||||
return h('div', {
|
||||
style: {
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
alignItems: 'center',
|
||||
fontSize: '15px',
|
||||
textAlign: 'center',
|
||||
border: '1px solid #ccc',
|
||||
borderRadius: '8px',
|
||||
padding: '8px',
|
||||
backgroundColor: '#f9f9f9'
|
||||
}
|
||||
}, [
|
||||
h(Platform, {
|
||||
style: {
|
||||
width: '20px',
|
||||
marginBottom: '4px',
|
||||
color: '#526ade'
|
||||
}
|
||||
}),
|
||||
h('div', null, '设备名称:' + text),
|
||||
h('div', null, '设备类型:' + type)
|
||||
]) as any
|
||||
}
|
||||
|
||||
const createLabel3 = (text: string) => {
|
||||
return h('div', {
|
||||
style: {
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
fontSize: '15px',
|
||||
textAlign: 'center',
|
||||
border: '1px solid #ccc',
|
||||
borderRadius: '8px',
|
||||
padding: '8px',
|
||||
backgroundColor: '#f9f9f9'
|
||||
}
|
||||
}, [
|
||||
h(Flag, {
|
||||
style: {
|
||||
width: '20px',
|
||||
marginRight: '4px',
|
||||
color: '#526ade'
|
||||
}
|
||||
}),
|
||||
text
|
||||
]) as any
|
||||
}
|
||||
|
||||
|
||||
const handleConnectStart = (params: any) => {
|
||||
onPaneReady()
|
||||
}
|
||||
|
||||
const handleConnectEnd = (params: any) => {
|
||||
onPaneReady()
|
||||
}
|
||||
|
||||
const handleConnect = (params: any) => {
|
||||
console.log('连接信息:', params);
|
||||
const sourceNode = nodes.value.find(node => node.id === params.source)
|
||||
const targetNode = nodes.value.find(node => node.id === params.target)
|
||||
|
||||
// 连接规则验证
|
||||
const isValidConnection =
|
||||
sourceNode?.type === 'input' &&
|
||||
targetNode?.type === 'output'
|
||||
|
||||
if (!isValidConnection) {
|
||||
removeEdge(params)
|
||||
ElMessage.warning('只能从被检通道连接到标准通道')
|
||||
return
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 删除不合法连接
|
||||
const removeEdge = (params: any) => {
|
||||
const edgeIndex = edges.value.findIndex(edge =>
|
||||
edge.source === params.source && edge.target === params.target
|
||||
)
|
||||
if (edgeIndex !== -1) {
|
||||
edges.value.splice(edgeIndex, 1)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 打印当前节点和连线信息
|
||||
function logConnections() {
|
||||
console.log('当前节点:', nodes.value);
|
||||
console.log('当前连线:', edges.value);
|
||||
|
||||
const connections = edges.value.map(edge => ({
|
||||
source: edge.source,
|
||||
target: edge.target,
|
||||
label: `${edge.source} → ${edge.target}`
|
||||
}));
|
||||
|
||||
console.table(connections);
|
||||
}
|
||||
|
||||
const nodes = ref([])
|
||||
const sourceIdArray = ref<string[]>()
|
||||
const open = async (device: Device.ResPqDev[], standardDev: StandardDevice.ResPqStandardDevice[],sourceIds: string[]) => {
|
||||
edges.value = []
|
||||
sourceIdArray.value = sourceIds
|
||||
nodes.value = createNodes(device, standardDev)
|
||||
dialogVisible.value = true
|
||||
onPaneReady()
|
||||
}
|
||||
|
||||
const handleNext = () => {
|
||||
if (edges.value.length === 0) {
|
||||
ElMessage.warning('请先完成通道配对')
|
||||
return
|
||||
}
|
||||
dialogVisible.value = false
|
||||
selectTestItemPopupRef.value?.open(sourceIdArray.value)
|
||||
}
|
||||
|
||||
const openTestDialog = () => {
|
||||
testPopup.value?.open(dialogTitle.value,sourceIdArray.value)
|
||||
}
|
||||
|
||||
const createNodes = (device: Device.ResPqDev[], standardDev: StandardDevice.ResPqStandardDevice[]) => {
|
||||
const channelCounts: Record<string, number> = {}
|
||||
device.forEach(device => {
|
||||
channelCounts[device.id] = device.devChns || 0
|
||||
})
|
||||
|
||||
const inspectionDevices = device.map(d => ({
|
||||
id: d.id,
|
||||
name: d.name,
|
||||
type: 'normal',
|
||||
deviceType: d.devType
|
||||
}))
|
||||
|
||||
const channelCounts2: Record<string, number> = {}
|
||||
standardDev.forEach(dev => {
|
||||
const channelList = dev.inspectChannel ? dev.inspectChannel.split(',') : []
|
||||
channelCounts2[dev.id] = channelList.length
|
||||
})
|
||||
|
||||
const standardDevices = standardDev.map(d => ({
|
||||
id: d.id,
|
||||
name: d.name,
|
||||
type: 'normal',
|
||||
deviceType: d.devType
|
||||
}))
|
||||
|
||||
const newNodes: any[] = []
|
||||
const deviceChannelGroups: { deviceId: string; centerY: number; }[] = []
|
||||
const standardChannelGroups: any[] = []
|
||||
|
||||
const deviceWidth = 0
|
||||
const inputChannelX = 200
|
||||
const outputChannelX = 800
|
||||
const standardWidth = 950
|
||||
|
||||
const yPosition = ref(25)
|
||||
const yPosition2 = ref(25)
|
||||
|
||||
// 添加被检通道
|
||||
Object.entries(channelCounts).forEach(([deviceId, count]) => {
|
||||
for (let i = 1; i <= count; i++) {
|
||||
const channelId = `被检通道-${deviceId}-${i}`
|
||||
newNodes.push({
|
||||
id: channelId,
|
||||
type: 'input',
|
||||
data: { label: createLabel3(`被检通道${i}`) },
|
||||
position: { x: inputChannelX, y: yPosition.value },
|
||||
sourcePosition: 'right',
|
||||
style: { width: '150px', border: 'none', boxShadow: 'none' }
|
||||
})
|
||||
|
||||
// 计算设备节点Y坐标(居中显示)
|
||||
if(i == 1 && count == 1){
|
||||
deviceChannelGroups.push({
|
||||
deviceId,
|
||||
centerY: yPosition.value - 25
|
||||
})
|
||||
}else if(i == 2 && count == 2){
|
||||
deviceChannelGroups.push({
|
||||
deviceId,
|
||||
centerY: yPosition.value - 50
|
||||
})
|
||||
}else if(i == 3 && count == 3){
|
||||
deviceChannelGroups.push({
|
||||
deviceId,
|
||||
centerY: yPosition.value - 75
|
||||
})
|
||||
}else if(i == 4 && count == 4){
|
||||
deviceChannelGroups.push({
|
||||
deviceId,
|
||||
centerY: yPosition.value - 100
|
||||
})
|
||||
}
|
||||
|
||||
yPosition.value += 50
|
||||
}
|
||||
yPosition.value += 50
|
||||
})
|
||||
|
||||
// 添加标准通道
|
||||
Object.entries(channelCounts2).forEach(([deviceId, count]) => {
|
||||
for (let i = 1; i <= count; i++) {
|
||||
const channelId = `标准通道-${deviceId}-${i}`
|
||||
newNodes.push({
|
||||
id: channelId,
|
||||
type: 'output',
|
||||
data: { label: createLabel3(`标准通道${i}`) },
|
||||
position: { x: outputChannelX, y: yPosition2.value },
|
||||
targetPosition: 'left',
|
||||
style: { width: '150px', border: 'none', boxShadow: 'none' }
|
||||
})
|
||||
|
||||
// 计算设备节点Y坐标(居中显示)
|
||||
if(i == 1 && count == 1){
|
||||
standardChannelGroups.push({
|
||||
deviceId,
|
||||
centerY: yPosition2.value - 25
|
||||
})
|
||||
}else if(i == 2 && count == 2){
|
||||
standardChannelGroups.push({
|
||||
deviceId,
|
||||
centerY: yPosition2.value - 50
|
||||
})
|
||||
}else if(i == 3 && count == 3){
|
||||
standardChannelGroups.push({
|
||||
deviceId,
|
||||
centerY: yPosition2.value - 100
|
||||
})
|
||||
}else if(i == 4 && count == 4){
|
||||
standardChannelGroups.push({
|
||||
deviceId,
|
||||
centerY: yPosition2.value - 100
|
||||
})
|
||||
}
|
||||
|
||||
yPosition2.value += 50
|
||||
}
|
||||
yPosition2.value += 50
|
||||
})
|
||||
|
||||
// 添加被检设备
|
||||
deviceChannelGroups.forEach(({ deviceId, centerY }) => {
|
||||
const device = inspectionDevices.find(d => d.id === deviceId)
|
||||
if (device) {
|
||||
newNodes.push({
|
||||
id: device.id,
|
||||
data: { label: createLabel(device.name, device.deviceType) },
|
||||
position: { x: deviceWidth, y: centerY },
|
||||
class: 'no-handle-node',
|
||||
style: { width: '200px', border: 'none', boxShadow: 'none' }
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
// 添加标准设备
|
||||
standardChannelGroups.forEach(({ deviceId, centerY }) => {
|
||||
const device = standardDevices.find(d => d.id === deviceId)
|
||||
if (device) {
|
||||
newNodes.push({
|
||||
id: device.id,
|
||||
data: { label: createLabel(device.name, device.deviceType) },
|
||||
position: { x: standardWidth, y: centerY },
|
||||
class: 'no-handle-node',
|
||||
style: { width: '200px', border: 'none', boxShadow: 'none' }
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
return newNodes
|
||||
}
|
||||
|
||||
defineExpose({ open })
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.flow-container {
|
||||
height: 600px;
|
||||
width: 100%;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.vue-flow__node.no-handle-node .vue-flow__handle {
|
||||
display: none !important;
|
||||
}
|
||||
</style>
|
||||
@@ -68,7 +68,7 @@
|
||||
</template>
|
||||
<script lang="tsx" setup name="preTest">
|
||||
import {ElMessage, ElMessageBox} from "element-plus";
|
||||
import {defineExpose, toRef} from 'vue';
|
||||
import {defineExpose, ref, toRef, watch} from 'vue';
|
||||
|
||||
const step1InitLog = ref([
|
||||
{
|
||||
|
||||
134
frontend/src/views/home/components/realTimeDataAlign.vue
Normal file
134
frontend/src/views/home/components/realTimeDataAlign.vue
Normal file
@@ -0,0 +1,134 @@
|
||||
<template>
|
||||
<el-dialog title="实时数据详情" v-model='dialogVisible' @close="handleClose" v-bind="dialogBig" >
|
||||
<el-tabs v-model="activeTab" type="card">
|
||||
<el-tab-pane label="被检设备1" name="channel1">
|
||||
<div class="table-toolbar">
|
||||
<el-form-item label="被检设备通道号" prop="createId">
|
||||
<el-select v-model="timeRange" placeholder="选择时间范围" style="width: 150px;">
|
||||
<el-option label="通道1" value="1"></el-option>
|
||||
<el-option label="通道2" value="2"></el-option>
|
||||
<el-option label="通道3" value="3"></el-option>
|
||||
<el-option label="通道4" value="4"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-button type="primary" @click="exportData">导出数据</el-button>
|
||||
</div>
|
||||
<el-table
|
||||
:data="tableData"
|
||||
:header-cell-style="{ textAlign: 'center',backgroundColor: 'var(--el-color-primary)',color: '#fff' } "
|
||||
:cell-style="{ textAlign: 'center' }"
|
||||
style="width: 100%"
|
||||
:style="{ height: '400px',maxHeight: '400px',overflow:'hidden'}">
|
||||
<el-table-column prop="monitorNum" label="数据时标" width="180"/>
|
||||
<el-table-column label="被检设备1-通道1">
|
||||
<el-table-column prop="Ua" label="A相(V)">
|
||||
</el-table-column>
|
||||
<el-table-column prop="Ub" label="B相(V)">
|
||||
</el-table-column>
|
||||
<el-table-column prop="Uc" label="C相(V)">
|
||||
</el-table-column>
|
||||
</el-table-column>
|
||||
<el-table-column label="标准设备-通道1">
|
||||
<el-table-column prop="Ua" label="A相(V)">
|
||||
</el-table-column>
|
||||
<el-table-column prop="Ub" label="B相(V)">
|
||||
</el-table-column>
|
||||
<el-table-column prop="Uc" label="C相(V)">
|
||||
</el-table-column>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane label="被检设备2" name="channel2"></el-tab-pane>
|
||||
</el-tabs>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup lang='tsx' name='realTimeDataAlign'>
|
||||
import { dialogBig } from "@/utils/elementBind";
|
||||
import { ref, reactive } from "vue";
|
||||
import { ElMessage } from "element-plus";
|
||||
|
||||
const dialogVisible = ref(false);
|
||||
const activeTab = ref('channel1');
|
||||
const timeRange = ref('1');
|
||||
|
||||
|
||||
// 表格数据示例
|
||||
const tableData = ref([
|
||||
{
|
||||
monitorNum: '2023-05-20 10:30:01',
|
||||
Ua: '220.5V',
|
||||
Ub: '219.8V',
|
||||
Uc: '220.2V',
|
||||
Ia: '4.98A',
|
||||
Ib: '5.01A',
|
||||
Ic: '4.99A'
|
||||
},
|
||||
{
|
||||
monitorNum: '2023-05-20 10:30:04',
|
||||
Ua: '220.3V',
|
||||
Ub: '220.1V',
|
||||
Uc: '219.9V',
|
||||
Ia: '5.02A',
|
||||
Ib: '4.99A',
|
||||
Ic: '5.00A'
|
||||
},
|
||||
{
|
||||
monitorNum: '2023-05-20 10:30:07',
|
||||
Ua: '220.5V',
|
||||
Ub: '219.8V',
|
||||
Uc: '220.2V',
|
||||
Ia: '4.98A',
|
||||
Ib: '5.01A',
|
||||
Ic: '4.99A'
|
||||
},
|
||||
{
|
||||
monitorNum: '2023-05-20 10:30:10',
|
||||
Ua: '220.3V',
|
||||
Ub: '220.1V',
|
||||
Uc: '219.9V',
|
||||
Ia: '5.02A',
|
||||
Ib: '4.99A',
|
||||
Ic: '5.00A'
|
||||
}
|
||||
]);
|
||||
|
||||
const open = async () => {
|
||||
dialogVisible.value = true;
|
||||
};
|
||||
|
||||
// 刷新数据
|
||||
const refreshData = () => {
|
||||
ElMessage.info('正在刷新数据...');
|
||||
// 这里可以添加实际的数据刷新逻辑
|
||||
};
|
||||
|
||||
// 导出数据
|
||||
const exportData = () => {
|
||||
ElMessage.success('数据导出成功');
|
||||
// 这里可以添加实际的数据导出逻辑
|
||||
};
|
||||
|
||||
// 关闭弹窗
|
||||
const handleClose = () => {
|
||||
dialogVisible.value = false;
|
||||
};
|
||||
|
||||
defineExpose({ open });
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.table-toolbar {
|
||||
display: flex;
|
||||
justify-content: space-between; // 关键修改:将子元素分布到两端
|
||||
}
|
||||
|
||||
// 移除这个样式,避免影响布局
|
||||
// .table-toolbar .el-button {
|
||||
// margin-right: 10px;
|
||||
// }
|
||||
|
||||
:deep(.el-dialog__body) {
|
||||
padding: 10px 20px 20px 20px;
|
||||
}
|
||||
</style>
|
||||
@@ -8,7 +8,7 @@
|
||||
<el-form-item v-if="checkStore.plan.timeCheck===1" prop="timeTest" :label-width="100">
|
||||
<el-checkbox v-model="formContent.timeTest" label="守时检测"/>
|
||||
</el-form-item>
|
||||
<el-form-item v-if="AppSceneStore.currentScene === '1'" prop="channelsTest" :label-width="100">
|
||||
<el-form-item v-if="channelsTestShow" prop="channelsTest" :label-width="100">
|
||||
<el-checkbox v-model="formContent.channelsTest" label="系数校准"/>
|
||||
</el-form-item>
|
||||
<el-form-item prop="test" :label-width="100">
|
||||
@@ -28,25 +28,36 @@
|
||||
|
||||
<script setup lang='tsx' name='selectTestItemPopup'>
|
||||
import {dialogSmall} from "@/utils/elementBind";
|
||||
import {ref} from "vue";
|
||||
import {reactive, ref} from "vue";
|
||||
import {useCheckStore} from "@/stores/modules/check";
|
||||
import type {CheckData} from "@/api/check/interface";
|
||||
import {ElMessageBox} from "element-plus";
|
||||
import {useAppSceneStore} from "@/stores/modules/mode";
|
||||
import {useAppSceneStore,useModeStore} from "@/stores/modules/mode";
|
||||
const AppSceneStore = useAppSceneStore()
|
||||
const emit = defineEmits(['openTestDialog'])
|
||||
const checkStore = useCheckStore();
|
||||
|
||||
const modeStore = useModeStore()
|
||||
const dialogFormRef = ref()
|
||||
|
||||
const channelsTestShow = ref(false)
|
||||
|
||||
const dialogVisible = ref(false)
|
||||
const formContent = reactive<CheckData.SelectTestItem>({preTest: true, timeTest: false, channelsTest: false, test: false})
|
||||
const sourceIdArray = ref<string[]>()
|
||||
const open = async (sourcesIds: string[]) => {
|
||||
|
||||
const open = async () => {
|
||||
sourceIdArray.value = sourcesIds
|
||||
resetFormContent()
|
||||
checkStore.setSelectTestItems(formContent)
|
||||
dialogVisible.value = true
|
||||
if(modeStore.currentMode === '比对式'){
|
||||
channelsTestShow.value = false
|
||||
}else{
|
||||
if(AppSceneStore.currentScene === '1'){
|
||||
channelsTestShow.value = true
|
||||
}else{
|
||||
channelsTestShow.value = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 清空表单内容
|
||||
|
||||
@@ -64,6 +64,10 @@
|
||||
>重置
|
||||
</el-button
|
||||
>
|
||||
<el-button
|
||||
type='primary'
|
||||
:icon='Clock' @click="handleTest2">通道配对
|
||||
</el-button>
|
||||
<!-- :disabled='!scope.isSelected' -->
|
||||
<el-button
|
||||
type='primary'
|
||||
@@ -136,7 +140,7 @@
|
||||
link
|
||||
:icon='Download'
|
||||
@click="openDrawer('报告下载', scope.row)"
|
||||
v-if='form.activeTabs === 3 && form.activeChildTabs === 0 && scope.row.reportState === 1'
|
||||
v-if='form.activeTabs === 3 && form.activeChildTabs === 0 && (scope.row.reportState === 1 ||scope.row.reportState === 3)'
|
||||
>报告下载
|
||||
</el-button>
|
||||
|
||||
@@ -233,6 +237,8 @@
|
||||
<SelectTestItemPopup ref="selectTestItemPopupRef" @openTestDialog="openTestDialog"></SelectTestItemPopup>
|
||||
<!-- 省平台-填写温度湿度弹窗 -->
|
||||
<WriteTHPopup ref="writeTHPopupRef" @openTestDialog2="openTestDialog2"></WriteTHPopup>
|
||||
<!-- 比对模式-通道配对弹窗 -->
|
||||
<DeviceConnectionPopup ref="deviceConnectionPopupRef" ></DeviceConnectionPopup>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
@@ -261,18 +267,16 @@ import {
|
||||
CirclePlus,
|
||||
Odometer,
|
||||
} from '@element-plus/icons-vue'
|
||||
import {getPlanList} from '@/api/plan/planList'
|
||||
import deviceDataList from '@/api/device/device/deviceData'
|
||||
import TestPopup from './testPopup.vue'
|
||||
import reportPopup from './reportPopup.vue'
|
||||
import dataCheckPopup from './dataCheckSingleChannelSingleTestPopup.vue'
|
||||
import dataCheckChangeErrSysPopup from './dataCheckChangeErrSysPopup.vue'
|
||||
import {generateDevReport, getBoundPqDevList} from '@/api/plan/plan.ts'
|
||||
import {onBeforeMount, onMounted, reactive, ref, watch} from 'vue'
|
||||
import {onBeforeMount, onMounted, PropType, provide, reactive, ref, watch} from 'vue'
|
||||
import {useDictStore} from '@/stores/modules/dict'
|
||||
import ChannelsTest from './channelsTest.vue'
|
||||
import {useModeStore,useAppSceneStore} from '@/stores/modules/mode' // 引入模式 store
|
||||
|
||||
import {useCheckStore} from '@/stores/modules/check'
|
||||
import {CheckData} from '@/api/check/interface'
|
||||
import socketClient from '@/utils/webSocketClient'
|
||||
@@ -285,7 +289,11 @@ import {getPqDev} from '@/api/device/device/index.ts'
|
||||
import {ResultEnum} from '@/enums/httpEnum'
|
||||
import SelectTestItemPopup from "@/views/home/components/selectTestItemPopup.vue";
|
||||
import WriteTHPopup from "@/views/home/components/writeTHPopup.vue";
|
||||
import { fa } from 'element-plus/es/locale'
|
||||
import DeviceConnectionPopup from '@/views/home/components/deviceConnectionPopup.vue'
|
||||
import { Plan } from '@/api/plan/interface'
|
||||
import { StandardDevice } from '@/api/device/interface/standardDevice'
|
||||
import {getPlanList } from '@/api/plan/plan.ts'
|
||||
import { mount } from 'sortablejs'
|
||||
|
||||
const dictStore = useDictStore()
|
||||
const checkStore = useCheckStore()
|
||||
@@ -303,7 +311,7 @@ const reportDialogVisible = ref(false)
|
||||
const dataCheckPopupRef = ref<InstanceType<typeof dataCheckPopup>>()
|
||||
const selectTestItemPopupRef = ref<InstanceType<typeof SelectTestItemPopup>>()
|
||||
const writeTHPopupRef = ref<InstanceType<typeof WriteTHPopup>>()
|
||||
|
||||
const deviceConnectionPopupRef = ref<InstanceType<typeof DeviceConnectionPopup>>()
|
||||
const matchDialogVisible = ref(false)
|
||||
const dialogTitle = ref('手动检测')
|
||||
const checkStateTable = ref<number[]>([0, 1, 2])
|
||||
@@ -358,8 +366,14 @@ const props = defineProps({
|
||||
type: Object,
|
||||
default: null,
|
||||
},
|
||||
planArray: {
|
||||
type: Array as PropType<Plan.ReqPlan[]>,
|
||||
default: null,
|
||||
},
|
||||
})
|
||||
const appSceneStore = useAppSceneStore()
|
||||
const planTable = ref<any[]>([])
|
||||
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'batchGenerateClicked'): void;
|
||||
@@ -478,7 +492,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,
|
||||
@@ -517,12 +531,46 @@ const columns = reactive<ColumnProps<Device.ResPqDev>[]>([
|
||||
{
|
||||
prop: 'devType',
|
||||
label: '设备类型',
|
||||
minWidth: 100,
|
||||
render: (scope) => {
|
||||
// 查找设备类型名称
|
||||
const name = devTypeOptions.value.find(option => option.id === scope.row.devType)
|
||||
return <span>{name?.name}</span>
|
||||
minWidth: 150,
|
||||
// render: (scope) => {
|
||||
// // 查找设备类型名称
|
||||
// const name = devTypeOptions.value.find(option => option.id === scope.row.devType)
|
||||
// return <span>{name?.name}</span>
|
||||
// },
|
||||
},
|
||||
{
|
||||
prop: 'boundPlanName',
|
||||
label: '来源计划名称',
|
||||
minWidth: 200,
|
||||
isShow:modeStore.currentMode === '比对式',
|
||||
render(scope) {
|
||||
return scope.row.boundPlanName ? scope.row.boundPlanName : props.plan.name
|
||||
}
|
||||
},
|
||||
{
|
||||
prop: 'standardDevs',
|
||||
label: '标准设备',
|
||||
minWidth: 200,
|
||||
isShow:modeStore.currentMode === '比对式',
|
||||
render(scope) {
|
||||
const boundPlanName = ref('')
|
||||
if(scope.row.boundPlanName){
|
||||
boundPlanName.value = scope.row.boundPlanName
|
||||
}else{
|
||||
boundPlanName.value = props.plan.name
|
||||
}
|
||||
const standardDevNames = props.planArray.flatMap(item => {
|
||||
if (item.children) {
|
||||
return item.children
|
||||
.filter(child => child.name === boundPlanName.value)
|
||||
.flatMap(child =>
|
||||
child.standardDevs.map(dev => dev.name)
|
||||
)
|
||||
}
|
||||
return []
|
||||
})
|
||||
return standardDevNames.length > 0 ? standardDevNames.join(',') : '/'
|
||||
}
|
||||
},
|
||||
{
|
||||
prop: 'devChns',
|
||||
@@ -531,7 +579,7 @@ const columns = reactive<ColumnProps<Device.ResPqDev>[]>([
|
||||
sortable: true,
|
||||
},
|
||||
{
|
||||
prop: 'reCheckNum',
|
||||
prop: 'recheckNum',
|
||||
label: '检测次数',
|
||||
minWidth: 100,
|
||||
sortable: true,
|
||||
@@ -582,6 +630,8 @@ const columns = reactive<ColumnProps<Device.ResPqDev>[]>([
|
||||
return '已生成'
|
||||
} else if (scope.row.reportState === 2) {
|
||||
return '未检'
|
||||
}else if(scope.row.reportState === 3){
|
||||
return '已上传'
|
||||
}
|
||||
return ''
|
||||
},
|
||||
@@ -591,16 +641,16 @@ 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 '不合格'
|
||||
} else if (scope.row.factorCheckResult === 1) {
|
||||
return '合格'
|
||||
} else if (scope.row.factorCheckResult === 2) {
|
||||
return '/'
|
||||
} else {
|
||||
return '未检'
|
||||
}
|
||||
return ''
|
||||
|
||||
},
|
||||
},
|
||||
{prop: 'operation', label: '操作', fixed: 'right', minWidth: 200, isShow: operationShow},
|
||||
@@ -626,6 +676,7 @@ const resetSearchForm = () => {
|
||||
let testType = 'test'//检测还是复检
|
||||
|
||||
const handleSelectionChange = (selection: any[]) => {
|
||||
|
||||
channelsSelection.value = selection
|
||||
devNum = selection.length
|
||||
devChannelsNum = 0
|
||||
@@ -845,6 +896,74 @@ const addDevice = (val: string) => {
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
const handleTest2 = () => {
|
||||
if (devNum == 0) {
|
||||
ElMessageBox.confirm(
|
||||
'请先选择被检设备',
|
||||
'提示',
|
||||
{
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning',
|
||||
},
|
||||
)
|
||||
return
|
||||
}
|
||||
const planName = channelsSelection.value.map(item => item.boundPlanName)
|
||||
const isPlanConsistent = new Set(planName).size === 1
|
||||
if (!isPlanConsistent) {
|
||||
ElMessageBox.confirm(
|
||||
'所勾选被检设备所属计划名称不一致,请重新选择',
|
||||
'提示',
|
||||
{
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning',
|
||||
},
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
const boundPlanName = ref('')
|
||||
if(channelsSelection.value[0].boundPlanName){
|
||||
boundPlanName.value = channelsSelection.value[0].boundPlanName
|
||||
}else{
|
||||
boundPlanName.value = props.plan.name
|
||||
}
|
||||
const pqStandardDevList=ref<StandardDevice.ResPqStandardDevice[]>([])
|
||||
pqStandardDevList.value = props.planArray.flatMap(item => {
|
||||
if (item.children) {
|
||||
return item.children
|
||||
.filter(child => child.name === boundPlanName.value)
|
||||
.flatMap(child =>
|
||||
child.standardDevs
|
||||
)
|
||||
}
|
||||
return []
|
||||
})
|
||||
|
||||
if(pqStandardDevList.value.length==0){
|
||||
ElMessageBox.confirm(
|
||||
'所勾选被检设备所属计划无标准设备,请重新选择',
|
||||
'提示',
|
||||
{
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning',
|
||||
},
|
||||
)
|
||||
return
|
||||
}
|
||||
//选中计划的数据源
|
||||
const dataSources = ref([])
|
||||
const matchedItem = planTable.value.data.find(item => item.name === props.plan.name)
|
||||
if (matchedItem) {
|
||||
dataSources.value = matchedItem.datasourceIds
|
||||
}
|
||||
deviceConnectionPopupRef.value?.open(channelsSelection.value,pqStandardDevList.value,dataSources.value)
|
||||
}
|
||||
|
||||
const handleTest = async (val: string) => {
|
||||
|
||||
if (devNum == 0) {
|
||||
@@ -965,7 +1084,7 @@ const handleTest = async (val: string) => {
|
||||
if(appSceneStore.currentScene === '0'){
|
||||
writeTHPopupRef.value?.open()
|
||||
}else{
|
||||
selectTestItemPopupRef.value?.open()
|
||||
selectTestItemPopupRef.value?.open([])
|
||||
//openTestDialog(true)
|
||||
}
|
||||
})
|
||||
@@ -977,7 +1096,7 @@ const handleTest = async (val: string) => {
|
||||
if(appSceneStore.currentScene === '0'){
|
||||
writeTHPopupRef.value?.open()
|
||||
}else{
|
||||
selectTestItemPopupRef.value?.open()
|
||||
selectTestItemPopupRef.value?.open([])
|
||||
//openTestDialog(true)
|
||||
}
|
||||
}
|
||||
@@ -985,7 +1104,7 @@ const handleTest = async (val: string) => {
|
||||
|
||||
checkStore.setSelectTestItems({preTest: false, timeTest: false, channelsTest: false, test: true})
|
||||
} else {
|
||||
selectTestItemPopupRef.value?.open()
|
||||
selectTestItemPopupRef.value?.open([])
|
||||
checkStore.setReCheckType(1)
|
||||
}
|
||||
} else if (val === '系数校准') {
|
||||
@@ -1052,6 +1171,7 @@ const handleTest = async (val: string) => {
|
||||
})
|
||||
checkStore.setSelectTestItems({preTest: false, timeTest: false, channelsTest: false, test: true})
|
||||
} else {
|
||||
checkStore.setReCheckType(1)
|
||||
openTestDialog(true)
|
||||
}
|
||||
}
|
||||
@@ -1191,7 +1311,6 @@ watch(
|
||||
)
|
||||
|
||||
onBeforeMount(async () => {
|
||||
|
||||
const response = await getPqDev()
|
||||
devTypeOptions.value = response.data.map(item => ({
|
||||
id: item.id,
|
||||
@@ -1204,6 +1323,16 @@ onBeforeMount(async () => {
|
||||
}))
|
||||
})
|
||||
|
||||
onMounted(async () => {
|
||||
if(modeStore.currentMode != '比对式')
|
||||
return;
|
||||
const patternId2 = dictStore.getDictData('Pattern').find(item => item.name === modeStore.currentMode)?.id;
|
||||
|
||||
if (patternId2 !== undefined) {
|
||||
planTable.value = await getPlanList({ 'patternId': patternId2 });
|
||||
}
|
||||
})
|
||||
|
||||
const handleQuitClicked = () => {
|
||||
//console.log('handleQuitClicked')
|
||||
dataSocket.socketServe.closeWs()
|
||||
|
||||
@@ -730,7 +730,7 @@ const initScriptData = async () => {
|
||||
|
||||
let response: any = await getBigTestItem({reCheckType: checkStore.reCheckType, planId: checkStore.plan.id, devIds: checkStore.devices.map(item => item.deviceId)})
|
||||
|
||||
let temp = response.data.map(item => {
|
||||
let temp = response.data.map((item: any) => {
|
||||
return {
|
||||
...item,
|
||||
scriptName: item.scriptName
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<el-dialog :title="dialogTitle" width="1550px" :model-value="dialogVisible" :before-close="beforeClose" @close="handleClose" height="1000px" draggable>
|
||||
|
||||
<div class="steps-container">
|
||||
<el-steps class="test-head-steps" simple :active="stepsActiveIndex" process-status="finish" finish-status="success">
|
||||
<el-steps v-if="showSteps" class="test-head-steps" simple :active="stepsActiveIndex" process-status="finish" finish-status="success">
|
||||
<el-step v-if="preTestSelected" title="预检测" :icon="stepsActive > 1 || stepsActiveIndex > stepsTotalNum-1? SuccessFilled :Edit" @click="handleStepClick(1)"/>
|
||||
<el-step v-if="timeTestSelected" title="守时检测" :icon="stepsActive > 2 || stepsActiveIndex > stepsTotalNum-1? SuccessFilled :UploadFilled"
|
||||
@click="handleStepClick(2)"/>
|
||||
@@ -86,6 +86,7 @@ const checkStore = useCheckStore();
|
||||
const nextStepText = ref('下一步');
|
||||
const dialogVisible = ref(false)
|
||||
|
||||
const showSteps = ref(false)
|
||||
const stepsTotalNum = ref(-1);//步骤总数
|
||||
const stepsActiveIndex = ref(1); //当前正在执行的步骤索引
|
||||
const stepsActiveView = ref(-1); //当前正在执行的步骤在(预处理、守时校验、系数校准、正式检测)中的排序,仅用于页面显示
|
||||
@@ -159,6 +160,7 @@ const initOperate = () => {
|
||||
}
|
||||
|
||||
const open = (title: string) => {
|
||||
showSteps.value = true
|
||||
initOperate()
|
||||
dialogTitle.value = title;
|
||||
dialogVisible.value = true;
|
||||
@@ -488,6 +490,7 @@ const beforeClose = (done: () => void) => {
|
||||
}
|
||||
|
||||
const handleClose = () => {
|
||||
showSteps.value = false
|
||||
dataSocket.socketServe.closeWs()
|
||||
dialogVisible.value = false;
|
||||
clearData()
|
||||
|
||||
@@ -28,29 +28,47 @@
|
||||
>
|
||||
<template #default='{ node, data }'>
|
||||
<span class='custom-tree-node' style='display: flex;align-items: center;'>
|
||||
<!-- 父节点图标 -->
|
||||
<Platform v-if='!data.pid' style='width:18px;height: 18px;margin-right:8px;'
|
||||
:style="{color:node.label=='未检'?'#fac858':node.label=='检测中'?'#ee6666':'#91cc75'}" />
|
||||
<!-- 节点名称 -->
|
||||
<span>{{ node.label }}</span>
|
||||
<!-- <Menu v-if="data.pid" @click.stop="detail(data)" style="width: 12px;margin-left: 8px;"/> -->
|
||||
<!-- 子节点右侧图标 + tooltip -->
|
||||
<el-tooltip
|
||||
v-if="node.label!='未检' && node.label!='检测中' && node.label!='检测完成'"
|
||||
placement="top"
|
||||
:manual="true"
|
||||
content="子计划信息">
|
||||
<Menu
|
||||
@click.stop="childDetail(node.data)"
|
||||
style="width: 16px; height: 16px; margin-left: 8px; cursor: pointer; color: var(--el-color-primary)"
|
||||
/>
|
||||
</el-tooltip>
|
||||
</span>
|
||||
</template>
|
||||
</el-tree>
|
||||
</div>
|
||||
</div>
|
||||
<SourceOpen ref='openSourceView' :width="width" :height="height + 175"></SourceOpen>
|
||||
|
||||
</template>
|
||||
<script lang='ts' setup>
|
||||
import { type Plan } from '@/api/plan/interface';
|
||||
import { Menu, Platform, CircleCheck,Loading } from '@element-plus/icons-vue'
|
||||
import { nextTick, onMounted, ref, watch } from 'vue';
|
||||
import { nextTick, onMounted, PropType, 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('')
|
||||
const treeRef = ref()
|
||||
const data: any = ref([])
|
||||
|
||||
const defaultProps = {
|
||||
children: 'children',
|
||||
label: 'name',
|
||||
@@ -63,8 +81,8 @@ const defaultChecked = ref<string[]>([]) // 明确类型为 number[]
|
||||
const tree = ref(false)//确保左侧树高凉只执行一次
|
||||
const getTreeData = (val: any) => {
|
||||
defaultChecked.value = [];
|
||||
data.value = val;
|
||||
|
||||
// 遍历 val 的每个 children,过滤掉 pid !== '0'
|
||||
data.value = val
|
||||
for (let item of data.value) {
|
||||
if (item.children.length > 0) {
|
||||
let node = item.children[0];
|
||||
@@ -84,7 +102,6 @@ const getTreeData = (val: any) => {
|
||||
|
||||
//点击表格后左侧树刷新,高亮显示对应节点
|
||||
const clickTableToTree = (val: any,id:any) => {
|
||||
|
||||
defaultChecked.value = []
|
||||
data.value = val
|
||||
let node = ref('')
|
||||
@@ -107,9 +124,13 @@ const clickTableToTree = (val: any,id:any) => {
|
||||
}
|
||||
}
|
||||
|
||||
const {updateSelectedTreeNode} = defineProps<{
|
||||
const {updateSelectedTreeNode,width,height,planArray} = defineProps<{
|
||||
updateSelectedTreeNode:Function;
|
||||
width: number;
|
||||
height: number;
|
||||
planArray?: Plan.ReqPlan[];
|
||||
}>();
|
||||
|
||||
watch(
|
||||
() => searchForm.value.planName,
|
||||
(val) => {
|
||||
@@ -143,11 +164,18 @@ const filterNode = (value: string, data: any) => {
|
||||
return data.name.includes(value)
|
||||
}
|
||||
|
||||
|
||||
// 点击详情
|
||||
const detail = () => {
|
||||
router.push('/plan/planList')
|
||||
}
|
||||
|
||||
|
||||
|
||||
const childDetail = (data: Plan.ResPlan) => {
|
||||
console.log('planArray',planArray)
|
||||
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" :planArray = 'planList2?.data'/>
|
||||
</div>
|
||||
</el-col>
|
||||
<el-col :lg='20' :xl='20' :md='20' :sm='20'>
|
||||
@@ -95,7 +95,7 @@
|
||||
<el-tab-pane :label='tabLabel1' :style='{ height: tabPaneHeight}'>
|
||||
<!-- 列表数据 -->
|
||||
<div class='container_table' :style='{ height: tableHeight }'>
|
||||
<Table ref='tableRef1' :id='currentId' :plan = 'select_Plan' @batchGenerateClicked="handleBatchGenerate"></Table>
|
||||
<Table ref='tableRef1' :id='currentId' :plan ='select_Plan' :planArray = 'planList2?.data' @batchGenerateClicked="handleBatchGenerate"></Table>
|
||||
</div>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
@@ -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()
|
||||
@@ -146,8 +148,10 @@ const tabPaneHeight = ref('calc(100% - 5px)') // 初始高度
|
||||
const tableHeight = ref('calc(100% - 50px)') // 初始高度
|
||||
|
||||
const planList = ref<ResultData<Plan.ReqPlan[]>>()
|
||||
const planList2 = ref<ResultData<Plan.ReqPlan[]>>()//备份含子计划的结构
|
||||
const select_Plan = ref<Plan.ReqPlan>()
|
||||
const isLabelLineShow = ref(true)
|
||||
const { popupBaseView,viewWidth, viewHeight } = useViewSize()
|
||||
const handleCollapseChange = (val: CollapseModelValue) => {
|
||||
|
||||
// 计算新的高度
|
||||
@@ -202,7 +206,6 @@ const tableRef1 = ref()
|
||||
const tableRef2 = ref()
|
||||
const currentId = ref('')
|
||||
|
||||
|
||||
watch(
|
||||
() => form.value,
|
||||
(val, oldVal) => {
|
||||
@@ -241,8 +244,6 @@ watch(
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
|
||||
const pieRef1 = ref(),
|
||||
pieRef2 = ref(),
|
||||
pieRef3 = ref()
|
||||
@@ -297,12 +298,14 @@ const getPieData = async (id: string) => {
|
||||
const reportStateCount: { [key: number]: number } = { 0: 0, 1: 0, 2: 0 }
|
||||
if (id) {
|
||||
const boundPqDevList = ref<Device.ResPqDev[]>([])//根据检测计划id查询出所有已绑定的设备
|
||||
const plan = findPlanById(planList.value?.data || [], id)
|
||||
const plan = findPlanById(planList.value, id)
|
||||
|
||||
planName.value = '所选计划:' + plan.name
|
||||
|
||||
select_Plan.value = plan
|
||||
console.log('所选计划:',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 => {
|
||||
@@ -321,7 +324,6 @@ const getPieData = async (id: string) => {
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
// 检查 checkStateCount 是否全为 0
|
||||
if(boundPqDevList.value.length != 0){
|
||||
|
||||
@@ -375,12 +377,7 @@ const getPieData = async (id: string) => {
|
||||
{ value: 0 , itemStyle: { color: '#eeeeee' } },
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}else{
|
||||
|
||||
planName.value = '所选计划:'
|
||||
}
|
||||
|
||||
@@ -409,7 +406,6 @@ const planDetail = () => {
|
||||
|
||||
//功能选择css切换
|
||||
const handleCheckFunction = (val: any) => {
|
||||
|
||||
editableTabsValue.value = '0'
|
||||
form.value.activeChildTabs = 0
|
||||
tabsList.value.map((item: any, index: any) => {
|
||||
@@ -454,7 +450,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,19 +480,37 @@ const initPlan = async () => {
|
||||
result: 0,
|
||||
code: 0,
|
||||
state: 0,
|
||||
standardDevNameStr: '',
|
||||
associateReport: 0,
|
||||
reportTemplateName: '',
|
||||
reportTemplateVersion: '',
|
||||
dataRule: '',
|
||||
testItemNameStr:'',
|
||||
testItems: [],
|
||||
standardDevIds:[],
|
||||
standardDevMap: new Map<string, number>(),
|
||||
}
|
||||
planList.value = (await getPlanListByPattern(reqPlan)) as ResultData<Plan.ReqPlan[]>
|
||||
planList2.value = (await getPlanListByPattern(reqPlan)) as ResultData<Plan.ReqPlan[]>
|
||||
planList.value = JSON.parse(JSON.stringify(planList2.value));
|
||||
planList.value = planList.value.data.map((item: any) => {
|
||||
if (item.children) {
|
||||
item.children = item.children.filter(child => child.pid === '0');
|
||||
}
|
||||
return item;
|
||||
});
|
||||
}
|
||||
|
||||
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) {
|
||||
currentId.value = planList.value.data[i].children[0].id; // 直接赋值第一个 children 的 id
|
||||
console.log(planList.value)
|
||||
for (let i = 0; i < planList.value.length; i++) {
|
||||
if (Array.isArray(planList.value[i].children) && planList.value[i].children.length > 0) {
|
||||
currentId.value = planList.value[i].children[0].id; // 直接赋值第一个 children 的 id
|
||||
break; // 确保只执行一次
|
||||
}
|
||||
}
|
||||
|
||||
console.log('planList.valuecurrentId.value', currentId.value)
|
||||
// if (planList.value.data[0].children[0]) {
|
||||
// currentId.value = planList.value.data[0].children[0].id
|
||||
// console.log('currentId.value',planList.value.data[0])
|
||||
@@ -506,8 +519,7 @@ onBeforeMount(async () => {
|
||||
if (chartsInfoRef.value) {
|
||||
resizeObserver.observe(chartsInfoRef.value)
|
||||
}
|
||||
getTree(planList.value.data)
|
||||
|
||||
getTree(planList.value)
|
||||
getPieData(currentId.value)
|
||||
})
|
||||
|
||||
@@ -521,7 +533,7 @@ const handleBatchGenerate = async () => {
|
||||
// console.log('批量生成按钮被点击了');
|
||||
// 在这里添加其他逻辑,比如显示对话框、更新状态等
|
||||
await initPlan()
|
||||
treeRef.value.clickTableToTree(planList.value.data,currentId.value)
|
||||
treeRef.value.clickTableToTree(planList.value,currentId.value)
|
||||
getPieData(currentId.value)
|
||||
|
||||
if (form.value.activeTabs === 0)//设备检测
|
||||
@@ -646,7 +658,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();
|
||||
@@ -78,7 +79,7 @@ const modeList = [
|
||||
code: "比对式",
|
||||
subName: "启用比对式检测计划",
|
||||
img: new URL('/src/assets/images/dashboard/3.svg', import.meta.url).href,
|
||||
isActive: false,
|
||||
isActive: true,
|
||||
},
|
||||
];
|
||||
const handelOpen = async (item: any) => {
|
||||
@@ -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" });
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<!-- 基础信息弹出框 -->
|
||||
<el-dialog :model-value="dialogVisible" :title="dialogTitle" v-bind="dialogMiddle" @close="close" >
|
||||
<el-dialog :model-value="dialogVisible" :title="dialogTitle" v-bind="dialogMiddle" @close="close" align-center>
|
||||
<div>
|
||||
<el-form :model="formContent" ref='dialogFormRef' :rules='rules' class="form-two">
|
||||
<el-form-item label="名称" prop="name" >
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
<template>
|
||||
<el-dialog :title="dialogTitle" v-model='dialogVisible' @close="close" v-bind="dialogBig">
|
||||
<el-tabs type="border-card">
|
||||
<el-dialog :title="dialogTitle" v-model='dialogVisible' @close="close" v-bind="dialogBig" align-center >
|
||||
<el-tabs type="border-card" v-model="activeTab" @tab-change="onTabChange">
|
||||
<el-tab-pane label="设备台账信息">
|
||||
<div>
|
||||
<el-form :model='formContent' ref='dialogFormRef' :rules='rules' :disabled="false" label-width="auto" class="form-three">
|
||||
<div ref="deviceInfoContainer">
|
||||
<el-form :model='formContent' ref='dialogFormRef' :rules='rules' :disabled="false" label-width="auto" class="form-three" :validate-on-rule-change="false">
|
||||
<el-divider>设备信息</el-divider>
|
||||
<el-form-item label="装置编号" prop="createId">
|
||||
<el-input v-model="formContent.createId" placeholder="请输入装置编号" @input="handleInput" maxlength="32" show-word-limit/>
|
||||
</el-form-item>
|
||||
<el-form-item label="设备名称" prop="name">
|
||||
<el-input v-model='formContent.name' placeholder="请输入设备名称" :disabled="scene === '1'" maxlength="32" show-word-limit/>
|
||||
<el-input v-model='formContent.name' placeholder="请输入设备名称" :disabled="scene === '1' || formContent.importFlag == 1" maxlength="32" show-word-limit />
|
||||
</el-form-item>
|
||||
<el-form-item label='设备类型' prop='devType'>
|
||||
<el-select v-model="formContent.devType" filterable clearable placeholder="请选择设备类型" @change="handleDevTypeChange">
|
||||
<el-select v-model="formContent.devType" filterable clearable placeholder="请选择设备类型" @change="handleDevTypeChange" :disabled="formContent.importFlag == 1">
|
||||
<el-option
|
||||
v-for="item in devTypeOptions"
|
||||
:key="item.id"
|
||||
@@ -31,18 +31,8 @@
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<!-- <el-form-item label='设备模式' prop='pattern' >-->
|
||||
<!-- <el-select v-model="formContent.pattern" clearable placeholder="请选择设备模式" disabled>-->
|
||||
<!-- <el-option -->
|
||||
<!-- v-for="item in dictStore.getDictData('Pattern')"-->
|
||||
<!-- :key="item.id"-->
|
||||
<!-- :label="item.name"-->
|
||||
<!-- :value="item.id"-->
|
||||
<!-- />-->
|
||||
<!-- </el-select>-->
|
||||
<!-- </el-form-item> -->
|
||||
<el-form-item label='设备厂家' prop='manufacturer' v-if="scene != '1'">
|
||||
<el-select v-model="formContent.manufacturer" clearable placeholder="请选择设备厂家">
|
||||
<el-select v-model="formContent.manufacturer" clearable placeholder="请选择设备厂家" :disabled="formContent.importFlag == 1">
|
||||
<el-option
|
||||
v-for="item in dictStore.getDictData('Dev_Manufacturers')"
|
||||
:key="item.id"
|
||||
@@ -51,60 +41,90 @@
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="出厂日期" prop="createDate" v-if="scene === '0'">
|
||||
<el-form-item :label="createDateTitle" prop="createDate" v-if="scene === '0'" >
|
||||
<el-date-picker
|
||||
v-model="formContent.createDate"
|
||||
placeholder="请选择出厂日期"
|
||||
:placeholder="`请选择${createDateTitle}`"
|
||||
:disabled-date="disabledDate"
|
||||
: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
|
||||
v-model="formContent.inspectDate"
|
||||
placeholder="请选择定检日期"
|
||||
:disabled-date="disabledDate"
|
||||
:disabled="formContent.importFlag == 1"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-divider>参数信息</el-divider>
|
||||
<el-form-item label="通道数" prop="devChns">
|
||||
<el-form-item label="通道数" prop="devChns" v-if="DevIsShow">
|
||||
<el-input v-model='formContent.devChns' :disabled="true"/>
|
||||
</el-form-item>
|
||||
<el-form-item label="额定电压(V)" prop="devVolt">
|
||||
<el-form-item label="额定电压(V)" prop="devVolt" v-if="DevIsShow">
|
||||
<el-input v-model='formContent.devVolt' :disabled="true"/>
|
||||
</el-form-item>
|
||||
<el-form-item label="额定电流(A)" prop="devCurr">
|
||||
<el-form-item label="额定电流(A)" prop="devCurr" v-if="DevIsShow">
|
||||
<el-input v-model='formContent.devCurr' :disabled="true"/>
|
||||
</el-form-item>
|
||||
<el-form-item label='被检通道' prop='inspectChannel' v-if="MonIsShow">
|
||||
<el-select v-model="formContent.inspectChannel" multiple collapse-tags :disabled="true" :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-select v-model="formContent.protocol" clearable placeholder="请选择通讯协议" :disabled="formContent.importFlag == 1">
|
||||
<el-option
|
||||
v-for="item in dictStore.getDictData('Protocol')"
|
||||
:key="item.id"
|
||||
:label="item.name"
|
||||
:value="item.id"
|
||||
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<!-- <el-form-item label="IP地址" prop="ip">
|
||||
<IPAddress v-model:value="formContent.ip"/>
|
||||
</el-form-item> -->
|
||||
<el-form-item label="IP地址" prop="ip" placeholder="请输入IP地址">
|
||||
<el-input v-model="formContent.ip"/>
|
||||
<el-input v-model="formContent.ip" :disabled="formContent.importFlag == 1"/>
|
||||
</el-form-item>
|
||||
<el-form-item label="端口号" prop="port" placeholder="请输入端口号">
|
||||
<el-input v-model="formContent.port"/>
|
||||
<el-input v-model="formContent.port" :disabled="formContent.importFlag == 1"/>
|
||||
</el-form-item>
|
||||
<el-form-item label='是否加密' prop='encryptionFlag'>
|
||||
<el-select v-model="formContent.encryptionFlag" clearable placeholder="请选择是否加密">
|
||||
<el-select v-model="formContent.encryptionFlag" clearable placeholder="请选择是否加密" :disabled="formContent.importFlag == 1">
|
||||
<el-option label="是" :value="1"></el-option>
|
||||
<el-option label="否" :value="0"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label='识别码' prop='series' clearable v-if="formContent.encryptionFlag">
|
||||
<el-input v-model='formContent.series' placeholder="请输入识别码" show-password/>
|
||||
<el-input v-model='formContent.series' placeholder="请输入识别码" show-password :disabled="formContent.importFlag == 1"/>
|
||||
</el-form-item>
|
||||
<el-form-item label='密钥' prop='devKey' clearable v-if="formContent.encryptionFlag">
|
||||
<el-input v-model='formContent.devKey' placeholder="请输入密钥" show-password/>
|
||||
<el-input v-model='formContent.devKey' placeholder="请输入密钥" show-password :disabled="formContent.importFlag == 1"/>
|
||||
</el-form-item>
|
||||
<el-form-item label='样品编号' prop='sampleId' clearable v-if="DevIsShow && scene === '0'">
|
||||
<el-input v-model='formContent.sampleId' placeholder="请输入样品编号"/>
|
||||
@@ -126,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'/>
|
||||
<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'/>
|
||||
<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'/>
|
||||
<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">
|
||||
@@ -144,9 +185,10 @@
|
||||
</el-form>
|
||||
</div>
|
||||
</el-tab-pane>
|
||||
|
||||
<el-tab-pane label="监测点台账信息" v-if="MonIsShow">
|
||||
<!-- 监测点台账信息 tab pane -->
|
||||
<MonitorTable :MonIsShow="MonIsShow"/>
|
||||
<MonitorTable @getParameter="getParameter" :DevFormContent = "formContent" :tableHeight="monitorTableHeight" :selectOptions = "selectOptions"></MonitorTable>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
<template #footer>
|
||||
<div >
|
||||
@@ -158,39 +200,62 @@
|
||||
|
||||
</template>
|
||||
<script setup lang='ts'>
|
||||
|
||||
import IPAddress from '@/components/IpAddress/index.vue'
|
||||
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 {computed, reactive, type Ref, ref} from 'vue'
|
||||
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'
|
||||
// 使用 dayjs 库格式化
|
||||
import dayjs from 'dayjs'
|
||||
import MonitorTable from '@/views/machine/device/components/monitorTab.vue';
|
||||
import {useAppSceneStore} from "@/stores/modules/mode";
|
||||
import { generateUUID } from '@/utils'
|
||||
import { Monitor } from '@/api/device/interface/monitor'
|
||||
import { el } from 'element-plus/es/locale'
|
||||
|
||||
|
||||
const AppSceneStore = useAppSceneStore()
|
||||
const MonIsShow = ref(false)
|
||||
const DevIsShow = ref(false)
|
||||
// 存储设备类型选项
|
||||
const devTypeOptions = ref<Device.ResDev[]>([])
|
||||
const monitor = ref<Monitor.ResPqMon[]>([])
|
||||
// const IsPasswordShow = ref(false)
|
||||
const dictStore = useDictStore()
|
||||
const mode = ref()
|
||||
const scene = ref('')
|
||||
// 定义弹出组件元信息
|
||||
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',
|
||||
label: '1',
|
||||
}
|
||||
])
|
||||
const disabledDate = (time: Date) => {
|
||||
return time.getTime() > Date.now()
|
||||
}
|
||||
const onTabChange = (tabName: string | number) => {
|
||||
const name = tabName.toString(); // 统一转为字符串处理
|
||||
if (name === '1') {
|
||||
const formElement = dialogFormRef.value.$el as HTMLElement
|
||||
const formHeight = formElement.offsetHeight
|
||||
monitorTableHeight.value = formHeight - 88
|
||||
}
|
||||
}
|
||||
|
||||
function useMetaInfo() {
|
||||
const dialogVisible = ref(false)
|
||||
const titleType = ref('add')
|
||||
const formContent = ref<Device.ResPqDev>({
|
||||
const formContent = reactive<Device.ResPqDev>({
|
||||
id: '',
|
||||
name: '',
|
||||
pattern: mode.value,
|
||||
@@ -207,13 +272,20 @@ function useMetaInfo() {
|
||||
ip: '',
|
||||
port: 102,
|
||||
encryptionFlag: 0,
|
||||
reCheckNum: 0,
|
||||
recheckNum: 0,
|
||||
state: 1,
|
||||
factorFlag: 1,
|
||||
icdId: '',
|
||||
power: '',
|
||||
preinvestmentPlan: '',
|
||||
delegate:''
|
||||
delegate:'',
|
||||
inspectDate:dayjs().format('YYYY-MM-DD'),
|
||||
cityName: '',
|
||||
gdName: '',
|
||||
subName: '',
|
||||
importFlag:0,
|
||||
inspectChannel:[],
|
||||
monitorList:[]
|
||||
})
|
||||
return {dialogVisible, titleType, formContent}
|
||||
}
|
||||
@@ -221,7 +293,8 @@ function useMetaInfo() {
|
||||
const {dialogVisible, titleType, formContent} = useMetaInfo()
|
||||
// 清空formContent
|
||||
const resetFormContent = () => {
|
||||
formContent.value = {
|
||||
Object.assign(
|
||||
formContent,{
|
||||
id: '',
|
||||
name: '',
|
||||
pattern: mode.value,
|
||||
@@ -238,22 +311,29 @@ const resetFormContent = () => {
|
||||
ip: '',
|
||||
port: 102,
|
||||
encryptionFlag: 0,
|
||||
reCheckNum: 0,
|
||||
recheckNum: 0,
|
||||
state: 1,
|
||||
factorFlag: 1,
|
||||
icdId: '',
|
||||
power: '',
|
||||
preinvestmentPlan: '',
|
||||
delegate:''
|
||||
}
|
||||
delegate:'',
|
||||
inspectDate:dayjs().format('YYYY-MM-DD'),
|
||||
cityName: '',
|
||||
gdName: '',
|
||||
subName: '',
|
||||
importFlag:0,
|
||||
inspectChannel:[],
|
||||
monitorList:[]
|
||||
}
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
let dialogTitle = computed(() => {
|
||||
return titleType.value === 'add' ? '新增被检设备' : '编辑被检设备'
|
||||
})
|
||||
|
||||
|
||||
// 定义表单校验规则
|
||||
const baseRules: Record<string, Array<FormItemRule>> = {
|
||||
devType: [{required: true, message: '设备类型必选!', trigger: 'change'}],
|
||||
@@ -291,7 +371,7 @@ const rules = computed(() => {
|
||||
const dynamicRules = {...baseRules};
|
||||
|
||||
if (scene.value === '0') {//只有电科院需要展示
|
||||
dynamicRules.createDate = [{required: true, message: '出厂日期必填!', trigger: 'blur'}];
|
||||
dynamicRules.createDate = [{required: true, message: createDateTitle.value + '必填!', trigger: 'blur'}];
|
||||
}
|
||||
if (scene.value === '1') {//只有楼下出厂需要展示
|
||||
dynamicRules.preinvestmentPlan = [{required: true, message: '预投计划必选!', trigger: 'change'}];
|
||||
@@ -301,8 +381,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'}];
|
||||
|
||||
}
|
||||
@@ -310,7 +390,13 @@ const rules = computed(() => {
|
||||
if (scene.value !== '2') {
|
||||
dynamicRules.name = [{required: true, message: '设备名称必填!', trigger: 'blur'}];
|
||||
dynamicRules.manufacturer = [{required: true, message: '生产厂家必选!', trigger: 'change'}];
|
||||
}
|
||||
|
||||
if(mode.value === '比对式'){
|
||||
dynamicRules.inspectDate = [{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'}];
|
||||
}
|
||||
|
||||
|
||||
@@ -324,7 +410,15 @@ const close = () => {
|
||||
resetFormContent()
|
||||
// 重置表单
|
||||
dialogFormRef.value?.resetFields()
|
||||
}
|
||||
|
||||
//子组件监测点变化通知父组件设备台账
|
||||
const getParameter = (data: Monitor.ResPqMon[]) => {
|
||||
monitor.value = data
|
||||
//保存监测点信息自动更新设备台账的被检通道
|
||||
formContent.inspectChannel = monitor.value
|
||||
.map(item => item.num.toString())
|
||||
.sort((a, b) => parseFloat(a) - parseFloat(b));
|
||||
}
|
||||
|
||||
// 保存数据
|
||||
@@ -332,41 +426,61 @@ const save = () => {
|
||||
try {
|
||||
dialogFormRef.value?.validate(async (valid: boolean) => {
|
||||
|
||||
if (formContent.value.encryptionFlag === 0) {
|
||||
formContent.value.series = ''
|
||||
formContent.value.devKey = ''
|
||||
if (formContent.encryptionFlag === 0) {
|
||||
formContent.series = ''
|
||||
formContent.devKey = ''
|
||||
}
|
||||
if (valid) {
|
||||
formContent.value.createDate = dayjs(formContent.value.createDate).format('YYYY-MM-DD');
|
||||
formContent.createDate = dayjs(formContent.createDate).format('YYYY-MM-DD');
|
||||
if (AppSceneStore.currentScene === '1') {
|
||||
formContent.value.name = formContent.value.createId
|
||||
formContent.name = formContent.createId
|
||||
}
|
||||
|
||||
if (formContent.value.arrivedDate) {
|
||||
formContent.value.arrivedDate = dayjs(formContent.value.arrivedDate).format('YYYY-MM-DD');
|
||||
if (formContent.arrivedDate) {
|
||||
formContent.arrivedDate = dayjs(formContent.arrivedDate).format('YYYY-MM-DD');
|
||||
}
|
||||
|
||||
if(mode.value == '比对式'){
|
||||
if (formContent.inspectDate) {
|
||||
formContent.inspectDate = dayjs(formContent.inspectDate).format('YYYY-MM-DD');
|
||||
}
|
||||
|
||||
//可检通道转为字符串逗号分隔
|
||||
// 确保 inspectChannel 是数组再执行 join
|
||||
if (Array.isArray(formContent.inspectChannel)) {
|
||||
formContent.inspectChannel = formContent.inspectChannel
|
||||
.map(Number) // 将值转为数字以保证正确排序
|
||||
.sort((a, b) => a - b) // 数字升序排序
|
||||
.map(String) // 恢复为字符串用于保存
|
||||
.join(',');
|
||||
}
|
||||
}else{
|
||||
formContent.inspectChannel = null;
|
||||
}
|
||||
|
||||
|
||||
//保存时判是否加密,把识别码密钥字段清空
|
||||
if (formContent.value.encryptionFlag === 0) {
|
||||
formContent.value.series = null
|
||||
formContent.value.devKey = null
|
||||
if (formContent.encryptionFlag === 0) {
|
||||
formContent.series = null
|
||||
formContent.devKey = null
|
||||
}
|
||||
formContent.monitorList = monitor.value
|
||||
|
||||
if (formContent.value.id) {
|
||||
await updatePqDev(formContent.value);
|
||||
if (titleType.value != 'add') {
|
||||
await updatePqDev(formContent);
|
||||
ElMessage.success({message: `${dialogTitle.value}成功!`})
|
||||
} else {
|
||||
// 新增需要把设备模式转成字典ID
|
||||
const patternItem = dictStore.getDictData('Pattern').find(item => item.name === formContent.value.pattern);
|
||||
const patternItem = dictStore.getDictData('Pattern').find(item => item.name === formContent.pattern);
|
||||
if (patternItem) {
|
||||
formContent.value.pattern = patternItem.id;
|
||||
formContent.pattern = patternItem.id;
|
||||
}
|
||||
// 新增需要把通讯协议转成字典ID
|
||||
const protocolItem = dictStore.getDictData('Protocol').find(item => item.name === formContent.value.protocol);
|
||||
const protocolItem = dictStore.getDictData('Protocol').find(item => item.name === formContent.protocol);
|
||||
if (protocolItem) {
|
||||
formContent.value.protocol = protocolItem.id;
|
||||
formContent.protocol = protocolItem.id;
|
||||
}
|
||||
await addPqDev(formContent.value);
|
||||
await addPqDev(formContent);
|
||||
ElMessage.success({message: `${dialogTitle.value}成功!`})
|
||||
|
||||
}
|
||||
@@ -385,92 +499,115 @@ const save = () => {
|
||||
|
||||
// 打开弹窗,可能是新增,也可能是编辑
|
||||
const open = async (sign: string, data: Device.ResPqDev, currentMode: string, currentScene: string, devType: Device.ResDev[]) => {
|
||||
dialogFormRef.value?.resetFields()
|
||||
devTypeOptions.value = devType
|
||||
mode.value = currentMode
|
||||
scene.value = currentScene
|
||||
titleType.value = sign
|
||||
dialogVisible.value = true
|
||||
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
|
||||
} else {
|
||||
createDateTitle.value = '出厂日期'
|
||||
DevIsShow.value = true
|
||||
MonIsShow.value = false
|
||||
}
|
||||
|
||||
if (data.encryptionFlag === 1) {
|
||||
//handleEncryptionChange(1)
|
||||
} else {
|
||||
//handleEncryptionChange(0)
|
||||
}
|
||||
|
||||
if (data.id) {
|
||||
formContent.value = {...data}
|
||||
updateDeviceByType(data.devType)
|
||||
Object.assign(formContent,{ ...data })
|
||||
if (typeof formContent.inspectChannel === 'string') {
|
||||
formContent.inspectChannel = formContent.inspectChannel.split(',').filter(Boolean)
|
||||
}
|
||||
|
||||
} else {
|
||||
resetFormContent()
|
||||
//只有比对式设备ID由前端传
|
||||
if(currentMode === '比对式')
|
||||
formContent.id = generateUUID().replaceAll("-","")
|
||||
|
||||
if(scene.value === '2'){
|
||||
const manufacturers = dictStore.getDictData('Dev_Manufacturers');
|
||||
const nanjingCanxuan = manufacturers.find(item => item.name === '南京灿能');
|
||||
if (nanjingCanxuan) {
|
||||
formContent.value.manufacturer = nanjingCanxuan.id;
|
||||
formContent.manufacturer = nanjingCanxuan.id;
|
||||
}
|
||||
}
|
||||
// 设置默认设备参数
|
||||
updateDeviceByType('') // 可传空或默认类型
|
||||
}
|
||||
|
||||
//handleEncryptionChange(1)
|
||||
}
|
||||
|
||||
// 重置表单
|
||||
dialogFormRef.value?.resetFields()
|
||||
|
||||
|
||||
const updateDeviceByType = (devTypeId: string) => {
|
||||
const dev = devTypeOptions.value.find(t => t.id === devTypeId)
|
||||
if (dev) {
|
||||
formContent.devChns = dev.devChns
|
||||
formContent.devCurr = dev.devCurr
|
||||
formContent.devVolt = dev.devVolt
|
||||
formContent.icdId = dev.icd
|
||||
formContent.power = dev.power
|
||||
|
||||
// 动态设置 pqChannelArray 从 1 到 dev.devChns.length
|
||||
pqChannelArray.value = Array.from({ length: dev.devChns }, (_, i) => ({
|
||||
value: String(i + 1),
|
||||
label: String(i + 1),
|
||||
}))
|
||||
} else {
|
||||
// 默认值处理
|
||||
formContent.devChns = 1
|
||||
formContent.devCurr = 1
|
||||
formContent.devVolt = 57.74
|
||||
pqChannelArray.value = [{ value: '1', label: '1' }]
|
||||
}
|
||||
}
|
||||
// const handleEncryptionChange = (value: number) => {
|
||||
// // 根据是否加密来显示或隐藏识别码和密钥
|
||||
// if(value === 1){
|
||||
// IsPasswordShow.value = true
|
||||
//
|
||||
// }else
|
||||
// {
|
||||
// IsPasswordShow.value = false
|
||||
// // formContent.value.series = ''
|
||||
// // formContent.value.devKey = ''
|
||||
// // rules.value.series = [];
|
||||
// // rules.value.devKey = [];
|
||||
// }
|
||||
// }
|
||||
|
||||
const handleDevTypeChange = (value: string) => {
|
||||
// 在这里处理选中事件的逻辑
|
||||
const dev = devTypeOptions.value.find(t => t.id === value)
|
||||
if (dev) {
|
||||
formContent.value.devChns = dev.devChns; // 默认值为1
|
||||
formContent.value.devCurr = dev.devCurr; // 默认值为1
|
||||
formContent.value.devVolt = dev.devVolt; // 默认值为1
|
||||
formContent.value.icdId = dev.icd
|
||||
formContent.value.power = dev.power
|
||||
// if (dev.name.includes('882B')) {
|
||||
// formContent.value.ip = '172.17.102.220'
|
||||
// } else if (dev.name.includes('882A')) {
|
||||
// formContent.value.ip = '172.17.102.221'
|
||||
// } else {
|
||||
// formContent.value.ip = '172.17.102.200'
|
||||
// }
|
||||
updateDeviceByType(value)
|
||||
const maxChannel = formContent.devChns
|
||||
|
||||
|
||||
} else {
|
||||
formContent.value.devChns = 1; // 默认值为1
|
||||
formContent.value.devCurr = 1; // 默认值为1
|
||||
formContent.value.devVolt = 57.74; // 默认值为1
|
||||
//formContent.value.ip = '172.17.102.200'
|
||||
// 过滤掉超出新通道数范围的选项
|
||||
if (Array.isArray(formContent.inspectChannel)) {
|
||||
formContent.inspectChannel = formContent.inspectChannel.filter(
|
||||
(channel) => parseInt(channel, 10) <= maxChannel
|
||||
)
|
||||
}
|
||||
//切换设备类型时,删除超出最大通道数的监测点台账
|
||||
monitor.value = monitor.value.filter(
|
||||
(monitor) => parseInt(monitor.num.toString(), 10) <= maxChannel
|
||||
)
|
||||
formContent.monitorList = monitor.value
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
const handleInput = (value: string) => {
|
||||
// 在这里处理选中事件的逻辑
|
||||
if (scene.value === '1') {
|
||||
formContent.value.name = value
|
||||
}
|
||||
|
||||
//if (scene.value === '1') {
|
||||
formContent.name = value
|
||||
//}
|
||||
}
|
||||
|
||||
|
||||
|
||||
265
frontend/src/views/machine/device/components/monitorPopup.vue
Normal file
265
frontend/src/views/machine/device/components/monitorPopup.vue
Normal file
@@ -0,0 +1,265 @@
|
||||
<template>
|
||||
<!-- 基础信息弹出框 -->
|
||||
<el-dialog :model-value="dialogVisible" :title="dialogTitle" v-bind="dialogMiddle" @close="close" align-center>
|
||||
<div>
|
||||
<el-form :model="formContent" ref='dialogFormRef' :rules='rules' class="form-two">
|
||||
<el-form-item label="名称" prop="name" >
|
||||
<el-input v-model='formContent.name' placeholder="请输入监测点名称"/>
|
||||
</el-form-item>
|
||||
<el-form-item label="线路号" prop="num" >
|
||||
<el-select v-model="formContent.num" clearable placeholder="请选择线路号" @change="handleMonNumChange">
|
||||
<el-option
|
||||
v-for="item in lineNum"
|
||||
:key="item.id"
|
||||
:label="item.name"
|
||||
:value="item.id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<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">
|
||||
<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">
|
||||
<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="请选择接线方式">
|
||||
<el-option
|
||||
v-for="item in dictStore.getDictData('Dev_Connect')"
|
||||
:key="item.id"
|
||||
:label="item.name"
|
||||
:value="item.id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label='统计间隔' prop='statInterval' >
|
||||
<el-select v-model="formContent.statInterval" clearable placeholder="请选择统计间隔" >
|
||||
<el-option
|
||||
v-for="item in dictStore.getDictData('Dev_Chns')"
|
||||
:key="item.id"
|
||||
:label="item.name"
|
||||
:value="item.code"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="谐波系统检测点id" prop="harmSysId" placeholder="请输入谐波系统检测点id" >
|
||||
<el-input v-model="formContent.harmSysId" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</div>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button @click="close()">取消</el-button>
|
||||
<el-button type="primary" @click="save()" >
|
||||
保存
|
||||
</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import{ ElMessage, type FormInstance,type FormItemRule } from 'element-plus'
|
||||
import type { ProTableInstance } from '@/components/ProTable/interface'
|
||||
import { ref,computed, Ref, toRaw } from 'vue'
|
||||
import { type Monitor } from '@/api/device/interface/monitor'
|
||||
import {dialogMiddle} from '@/utils/elementBind'
|
||||
import { useDictStore } from '@/stores/modules/dict'
|
||||
import { generateUUID } from '@/utils'
|
||||
import { Device } from '@/api/device/interface/device'
|
||||
|
||||
const dictStore = useDictStore()
|
||||
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() {
|
||||
const dialogVisible = ref(false)
|
||||
const titleType = ref('add')
|
||||
const formContent = ref<Monitor.ResPqMon>({
|
||||
id: '',
|
||||
devId: '',
|
||||
busbar: '',
|
||||
name: '',
|
||||
num: 1,
|
||||
pt: '',
|
||||
ct: '',
|
||||
connection: '',
|
||||
statInterval: 1,
|
||||
harmSysId: '',
|
||||
})
|
||||
return { dialogVisible, titleType, formContent }
|
||||
}
|
||||
|
||||
const { dialogVisible, titleType, formContent } = useMetaInfo()
|
||||
|
||||
|
||||
const emit = defineEmits(['get-parameter'])
|
||||
// 清空formContent
|
||||
const resetFormContent = () => {
|
||||
formContent.value = {
|
||||
id: '',
|
||||
devId: '',
|
||||
busbar: '',
|
||||
name: '',
|
||||
num: 1,
|
||||
pt: '',
|
||||
ct: '',
|
||||
connection: '',
|
||||
statInterval: 1,
|
||||
harmSysId: '',
|
||||
}
|
||||
}
|
||||
|
||||
let dialogTitle = computed(() => {
|
||||
return titleType.value === 'add' ? '新增监测点台账' : '编辑监测点台账'
|
||||
})
|
||||
|
||||
// 关闭弹窗
|
||||
const close = () => {
|
||||
dialogVisible.value = false
|
||||
}
|
||||
|
||||
|
||||
//定义校验规则
|
||||
const rules: Ref<Record<string, Array<FormItemRule>>> = ref({
|
||||
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: 'change' }
|
||||
],
|
||||
ct: [
|
||||
{ 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: 'change' }],
|
||||
harmSysId : [{ required: true, message: '谐波系统检测点id必填!', trigger: 'blur' }],
|
||||
})
|
||||
|
||||
|
||||
// 保存数据
|
||||
const save = () => {
|
||||
try {
|
||||
dialogFormRef.value?.validate(async (valid: boolean) => {
|
||||
if (valid) {
|
||||
// 校验名称是否重复
|
||||
const isNameDuplicate = monitorTable.value.some(
|
||||
item => item.name === formContent.value.name && item.id !== formContent.value.id
|
||||
)
|
||||
if (isNameDuplicate) {
|
||||
ElMessage.error({ message: '监测点名称已存在,请重新输入!' })
|
||||
return
|
||||
}
|
||||
|
||||
if (titleType.value != 'edit')
|
||||
{
|
||||
formContent.value.id = generateUUID().replaceAll("-","")
|
||||
}
|
||||
emit('get-parameter', formContent.value)
|
||||
//ElMessage.success({ message: `${dialogTitle.value}成功!` })
|
||||
close()
|
||||
}
|
||||
})
|
||||
} catch (err) {
|
||||
console.error('验证过程中出现错误', err)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 打开弹窗,可能是新增,也可能是编辑
|
||||
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|| []
|
||||
// 提取 table 中已使用的 num(安全处理)
|
||||
const usedNums = new Set<number>()
|
||||
if (table && table.length > 0) {
|
||||
table.forEach(item => {
|
||||
if (item.num != null) {
|
||||
usedNums.add(Number(item.num))
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
lineNum.value = Array.from({ length: device.devChns }, (_, i) => {
|
||||
const id = i + 1;
|
||||
return {
|
||||
id,
|
||||
name: id.toString()
|
||||
};
|
||||
}).filter(item => !usedNums.has(item.id)); // 过滤掉已被使用的线路号
|
||||
|
||||
|
||||
if (sign == 'edit') {
|
||||
formContent.value = { ...data }
|
||||
originalNum.value = data.num // 记录原始线路号
|
||||
} else {
|
||||
resetFormContent()
|
||||
originalNum.value = null
|
||||
// 设置默认选中第一个线路号
|
||||
if (lineNum.value.length > 0) {
|
||||
formContent.value.num = lineNum.value[0].id
|
||||
}
|
||||
}
|
||||
formContent.value.devId = device.id
|
||||
}
|
||||
|
||||
|
||||
|
||||
const handleMonNumChange = (value: string) => {
|
||||
const newValue = parseInt(value)
|
||||
if (originalNum.value && originalNum.value !== newValue) {
|
||||
// 将原来的 num 添加回 lineNum(表示释放)
|
||||
lineNum.value.push({
|
||||
id: originalNum.value,
|
||||
name: originalNum.value.toString()
|
||||
})
|
||||
//移除新选择的 num(因为已被占用)
|
||||
lineNum.value = lineNum.value.filter(item => item.id !== newValue).sort((a, b) => a.id - b.id)
|
||||
|
||||
// 更新 originalNum 为最新值,以便下次修改
|
||||
originalNum.value = newValue
|
||||
}
|
||||
}
|
||||
|
||||
// 对外映射
|
||||
defineExpose({ open })
|
||||
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
@@ -1,78 +1,191 @@
|
||||
<!-- components/MonitorPointTable.vue -->
|
||||
<template>
|
||||
<el-tab-pane label="监测点台账信息" v-if="MonIsShow">
|
||||
<div class='table-box' ref='popupBaseView'>
|
||||
<div class='table-box'>
|
||||
<ProTable
|
||||
ref='proTable'
|
||||
:pagination="false"
|
||||
:toolButton="false"
|
||||
:columns='columns'
|
||||
:style="{ height: '326px',maxHeight: '400px',overflow:'hidden'}"
|
||||
:data="tableData"
|
||||
:style="{ height: tableHeight + 'px',overflow:'hidden'}"
|
||||
>
|
||||
<!-- 表格 header 按钮 -->
|
||||
<template #tableHeader='scope'>
|
||||
<el-button type='primary' :icon='CirclePlus'>新增</el-button>
|
||||
<el-button type='danger' :icon='Delete' plain :disabled='!scope.isSelected'>删除</el-button>
|
||||
<el-button type='primary' :icon='CirclePlus' @click="openDialog('add')" :disabled="props.DevFormContent.importFlag == 1">新增</el-button>
|
||||
<el-button v-auth.device="'delete'" type='danger' :icon='Delete' plain :disabled='!scope.isSelected'
|
||||
@click='batchDelete(scope.selectedListIds)'>
|
||||
删除
|
||||
</el-button>
|
||||
</template>
|
||||
<!-- 表格操作 -->
|
||||
<template #operation>
|
||||
<el-button type='primary' link :icon='EditPen'>复制</el-button>
|
||||
<el-button type='primary' link :icon='EditPen'>编辑</el-button>
|
||||
<el-button type='primary' link :icon='Delete'>删除</el-button>
|
||||
<template #operation="scope">
|
||||
<el-button v-auth.device="'edit'" type='primary' link :icon='EditPen' :model-value='false' :disabled="props.DevFormContent.importFlag == 1"
|
||||
@click="openDialog('edit', scope.row)">编辑
|
||||
</el-button>
|
||||
<el-button v-auth.device="'delete'" type='primary' link :icon='Delete' @click='handleDelete(scope.row.id)' >删除
|
||||
</el-button>
|
||||
</template>
|
||||
</ProTable>
|
||||
</div>
|
||||
</el-tab-pane>
|
||||
<MonitorPopup @getParameter="getParameter" ref='monitorPopup'/>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, defineProps, reactive } from 'vue';
|
||||
import { ref, defineProps, reactive, watch } from 'vue';
|
||||
import ProTable from '@/components/ProTable/index.vue'; // 假设 ProTable 是自定义组件
|
||||
import { CirclePlus, Delete, EditPen } from '@element-plus/icons-vue';
|
||||
import { getPqMonList } from '@/api/device/monitor'
|
||||
import { type ColumnProps } from '@/components/ProTable/interface'
|
||||
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'
|
||||
import { useDictStore } from '@/stores/modules/dict';
|
||||
import { useHandleData } from '@/hooks/useHandleData';
|
||||
import { Device } from '@/api/device/interface/device';
|
||||
import { ElMessage, ElMessageBox } from 'element-plus';
|
||||
|
||||
// 定义 props
|
||||
const props = defineProps<{
|
||||
MonIsShow: boolean;
|
||||
DevFormContent:Device.ResPqDev,
|
||||
tableHeight?: number, // 接收外部传入的高度
|
||||
selectOptions: Record<string, Device.SelectOption[]>,
|
||||
}>();
|
||||
|
||||
// ProTable 实例
|
||||
const proTable = ref<ProTableInstance>()
|
||||
const dictStore = useDictStore()
|
||||
const monitorPopup = ref()
|
||||
const tableData = ref<any[]>([])
|
||||
const title_Type = ref('add')
|
||||
|
||||
// 表格配置项
|
||||
const columns = reactive<ColumnProps<Monitor.ResPqMon>[]>([
|
||||
{ type: 'selection', fixed: 'left', width: 70 },
|
||||
{ type: 'index', fixed: 'left', width: 70, label: '序号' },
|
||||
{
|
||||
prop: '',
|
||||
prop: 'name',
|
||||
label: '名称',
|
||||
width: 200,
|
||||
},
|
||||
{
|
||||
prop: 'busbar',
|
||||
label: '所属母线',
|
||||
width: 200,
|
||||
},
|
||||
{
|
||||
prop: '',
|
||||
label: '被检通道',
|
||||
prop: 'num',
|
||||
label: '线路号',
|
||||
width: 200,
|
||||
},
|
||||
{
|
||||
prop: '',
|
||||
prop: 'pt',
|
||||
label: 'PT变比',
|
||||
width: 110,
|
||||
},
|
||||
{
|
||||
prop: '',
|
||||
prop: 'ct',
|
||||
label: 'CT变比',
|
||||
width: 130,
|
||||
},
|
||||
{
|
||||
prop: '',
|
||||
prop: 'connection',
|
||||
label: '接线方式',
|
||||
enum: dictStore.getDictData('Dev_Connect'),
|
||||
fieldNames: {label: 'name', value: 'id'},
|
||||
width: 130,
|
||||
|
||||
},
|
||||
{
|
||||
prop: '',
|
||||
label: '谐波系统监测点ID',
|
||||
minWidth: 250,
|
||||
prop: 'statInterval',
|
||||
label: '统计间隔',
|
||||
width: 130,
|
||||
},
|
||||
{ prop: 'operation', label: '操作', fixed: 'right', width: 200 },
|
||||
])
|
||||
|
||||
|
||||
const emit = defineEmits(['get-parameter'])
|
||||
|
||||
const getParameter = (data: Monitor.ResPqMon) => {
|
||||
console.log('data', data)
|
||||
if (title_Type.value === 'edit') {
|
||||
// 编辑:替换已有的数据
|
||||
const index = tableData.value.findIndex(item => item.id === data.id)
|
||||
if (index > -1) {
|
||||
tableData.value = [
|
||||
...tableData.value.slice(0, index),
|
||||
data,
|
||||
...tableData.value.slice(index + 1)
|
||||
]
|
||||
}
|
||||
} else {
|
||||
// 新增:追加数据
|
||||
tableData.value = [...tableData.value, data]
|
||||
|
||||
}
|
||||
emit('get-parameter', tableData.value)
|
||||
}
|
||||
|
||||
|
||||
// 打开 drawer(新增、编辑)
|
||||
const openDialog = (titleType: string, row: Partial<Monitor.ResPqMon> = {}) => {
|
||||
if(props.DevFormContent.devType == '' || props.DevFormContent.devType == undefined){
|
||||
ElMessageBox.confirm(
|
||||
'请先选择被检设备类型',
|
||||
'提示',
|
||||
{
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning',
|
||||
},
|
||||
)
|
||||
return
|
||||
}
|
||||
title_Type.value = titleType
|
||||
monitorPopup.value?.open(titleType, row,props.DevFormContent,tableData.value,props.selectOptions)
|
||||
}
|
||||
|
||||
|
||||
// 批量删除监测点台账
|
||||
const batchDelete = (ids: string[]) => {
|
||||
ElMessageBox.confirm(`是否批量删除监测点?`, "温馨提示", {
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
draggable: true
|
||||
}).then(async () => {
|
||||
tableData.value = tableData.value.filter(item => !ids.includes(item.id));
|
||||
proTable.value?.clearSelection()
|
||||
emit('get-parameter', tableData.value)
|
||||
ElMessage({
|
||||
type: "success",
|
||||
message: `批量删除监测点成功!`
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
// 删除监测点台账
|
||||
const handleDelete = (id: string) => {
|
||||
ElMessageBox.confirm(`是否删除监测点?`, "温馨提示", {
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
draggable: true
|
||||
}).then(async () => {
|
||||
tableData.value = tableData.value.filter(item => item.id !== id)
|
||||
proTable.value?.clearSelection()
|
||||
emit('get-parameter', tableData.value)
|
||||
ElMessage({
|
||||
type: "success",
|
||||
message: `删除监测点成功!`
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
watch(
|
||||
() => props.DevFormContent.monitorList,
|
||||
(newVal) => {
|
||||
tableData.value = newVal|| []
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
|
||||
</script>
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
<el-button v-auth.device="'import'" type='primary' :icon='Download' plain @click="importFile('比对式')"
|
||||
v-if='modeStore.currentMode === "比对式"'>导入
|
||||
</el-button>
|
||||
<el-button type='primary' :icon='Upload' plain @click='uploadFile()' v-if='appSceneStore.currentScene === "1"'>报告上传</el-button>
|
||||
<el-button v-auth.device="'delete'" type='danger' :icon='Delete' plain :disabled='!scope.isSelected'
|
||||
@click='batchDelete(scope.selectedListIds)'>
|
||||
删除
|
||||
@@ -28,6 +29,8 @@
|
||||
</el-button>
|
||||
<el-button v-auth.device="'delete'" type='primary' link :icon='Delete' @click='handleDelete(scope.row)'>删除
|
||||
</el-button>
|
||||
|
||||
|
||||
</template>
|
||||
|
||||
</ProTable>
|
||||
@@ -38,7 +41,7 @@
|
||||
|
||||
<script setup lang='tsx' name='useRole'>
|
||||
import TimeControl from '@/components/TimeControl/index.vue'
|
||||
import {type Device} from '@/api/device/interface/device.ts'
|
||||
import {type Device} from '@/api/device/interface/device'
|
||||
import {useHandleData} from '@/hooks/useHandleData'
|
||||
import {useDownload} from '@/hooks/useDownload'
|
||||
import ProTable from '@/components/ProTable/index.vue'
|
||||
@@ -47,8 +50,9 @@ import {type ColumnProps, type ProTableInstance} from '@/components/ProTable/int
|
||||
import DevicePopup from '@/views/machine/device/components/devicePopup.vue'
|
||||
import {CirclePlus, Delete, Download, EditPen, Upload} from '@element-plus/icons-vue'
|
||||
import {useDictStore} from '@/stores/modules/dict'
|
||||
import {deletePqDev, downloadTemplate, exportPqDev, getPqDev, getPqDevList, importPqDev} from '@/api/device/device/index.ts'
|
||||
import {ElMessageBox} from 'element-plus'
|
||||
import {deletePqDev, downloadTemplate, exportPqDev, getPqDev, getPqDevList, importPqDev} from '@/api/device/device/index'
|
||||
import {uploadReportToCloud} from '@/api/device/report/index'
|
||||
import {ElMessage, ElMessageBox} from 'element-plus'
|
||||
import {onBeforeMount, reactive, ref} from 'vue'
|
||||
import {useAppSceneStore, useModeStore} from '@/stores/modules/mode'
|
||||
|
||||
@@ -65,11 +69,10 @@ const boundPqDevList = ref<Device.ReqPqDevParams[]>([])//根据检测计划id查
|
||||
// 存储设备类型选项
|
||||
const devTypeOptions = ref<Device.ResDev[]>([])
|
||||
|
||||
|
||||
const getTableList = async (params: any) => {
|
||||
let newParams = JSON.parse(JSON.stringify(params))
|
||||
newParams.searchEndTime = endDate.value
|
||||
newParams.searchBeginTime = startDate.value
|
||||
// newParams.searchEndTime = endDate.value
|
||||
// newParams.searchBeginTime = startDate.value
|
||||
const patternId = dictStore.getDictData('Pattern').find(item => item.name === modeStore.currentMode)?.id//获取数据字典中对应的id
|
||||
newParams.pattern = patternId
|
||||
return getPqDevList(newParams)
|
||||
@@ -94,33 +97,15 @@ 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',
|
||||
label: '出厂日期',
|
||||
label: modeStore.currentMode === '比对式' ? '投运日期' : '出厂日期',
|
||||
minWidth: 200,
|
||||
isShow: appSceneStore.currentScene === '0',
|
||||
...(appSceneStore.currentScene === '0' ? {
|
||||
search: {
|
||||
render: () => {
|
||||
return (
|
||||
<div class='flx-flex-start'>
|
||||
<TimeControl
|
||||
default={'月'}
|
||||
onUpdate-dates={handleDateChange}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
},
|
||||
},
|
||||
} : {}),
|
||||
// ...(appSceneStore.currentScene === '0' ? {
|
||||
// search: {
|
||||
// span: 2,
|
||||
// render: () => {
|
||||
// return (
|
||||
// <div class='flx-flex-start'>
|
||||
@@ -132,24 +117,25 @@ const columns = reactive<ColumnProps<Device.ResPqDev>[]>([
|
||||
// )
|
||||
// },
|
||||
// },
|
||||
// } : {}),
|
||||
},
|
||||
{
|
||||
prop: 'devChns',
|
||||
label: '通道数',
|
||||
minWidth: 110,
|
||||
|
||||
isShow: modeStore.currentMode != '比对式',
|
||||
},
|
||||
{
|
||||
prop: 'devVolt',
|
||||
label: '额定电压(V)',
|
||||
minWidth: 130,
|
||||
|
||||
isShow: modeStore.currentMode != '比对式',
|
||||
},
|
||||
{
|
||||
prop: 'devCurr',
|
||||
label: '额定电流(A)',
|
||||
minWidth: 130,
|
||||
|
||||
isShow: modeStore.currentMode != '比对式',
|
||||
},
|
||||
{
|
||||
prop: 'ip',
|
||||
@@ -167,6 +153,20 @@ const columns = reactive<ColumnProps<Device.ResPqDev>[]>([
|
||||
} : {}),
|
||||
minWidth: 200,
|
||||
},
|
||||
{
|
||||
prop: 'gdName',
|
||||
label: '供电公司',
|
||||
isShow: modeStore.currentMode === '比对式',
|
||||
search: {el: 'input'},
|
||||
minWidth: 200,
|
||||
},
|
||||
{
|
||||
prop: 'subName',
|
||||
label: '变电站',
|
||||
isShow: modeStore.currentMode === '比对式',
|
||||
search: {el: 'input'},
|
||||
minWidth: 200,
|
||||
},
|
||||
{
|
||||
prop: 'createTime',
|
||||
label: '创建时间',
|
||||
@@ -197,8 +197,14 @@ const handleDateChange = (startDateTemp: string, endDateTemp: string) => {
|
||||
endDate.value = endDateTemp
|
||||
}
|
||||
// 打开 drawer(新增、编辑)
|
||||
const openDialog = (titleType: string, row: Partial<Device.ResPqDev> = {}) => {
|
||||
const openDialog = async (titleType: string, row: Partial<Device.ResPqDev> = {}) => {
|
||||
if(titleType === 'add'){
|
||||
devicePopup.value?.open(titleType, row, modeStore.currentMode, appSceneStore.currentScene, devTypeOptions.value)
|
||||
}else{
|
||||
row = await getPqDevById(row)
|
||||
devicePopup.value?.open(titleType, row.data, modeStore.currentMode, appSceneStore.currentScene, devTypeOptions.value)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -238,29 +244,53 @@ const downloadFile = async () => {
|
||||
const deviceImportExcel = ref<InstanceType<typeof ImportExcel> | null>(null)
|
||||
|
||||
const importFile = async (pattern: string) => {
|
||||
|
||||
if (pattern === '比对式') {
|
||||
// const params = {
|
||||
// title: '被检设备',
|
||||
// showCover: false,
|
||||
// tempApi: downloadTemplate,
|
||||
// importApi: importPqDev,
|
||||
// getTableList: proTable.value?.getTableList,
|
||||
// }
|
||||
// deviceImportExcel.value?.acceptParams(params)
|
||||
} else {
|
||||
const params = {
|
||||
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,
|
||||
getTableList: proTable.value?.getTableList,
|
||||
}
|
||||
deviceImportExcel.value?.acceptParams(params)
|
||||
|
||||
|
||||
}
|
||||
|
||||
// 报告上传
|
||||
const uploadFile = async () => {
|
||||
const selectedRows = proTable.value?.selectedList || []
|
||||
|
||||
if (selectedRows.length === 0) {
|
||||
// 没有选择设备,弹出确认框询问是否处理全部
|
||||
ElMessageBox.confirm('未选择被检设备,是否对全部设备进行报告上传?', '提示', {
|
||||
type: 'warning',
|
||||
confirmButtonText: '全部上传',
|
||||
cancelButtonText: '取消'
|
||||
}).then(() => {
|
||||
// 用户确认全部上传,传递空数组或特殊标识
|
||||
handleReportUpload([])
|
||||
}).catch(() => {
|
||||
// 用户取消
|
||||
})
|
||||
} else {
|
||||
// 有选择设备,使用选中的设备ID
|
||||
const selectedIds = selectedRows.map(row => row.id)
|
||||
handleReportUpload(selectedIds)
|
||||
}
|
||||
}
|
||||
|
||||
// 处理报告上传
|
||||
const handleReportUpload = async (deviceIds: string[]) => {
|
||||
try {
|
||||
await uploadReportToCloud(deviceIds)
|
||||
ElMessage.success('报告上传成功')
|
||||
} catch (error) {
|
||||
ElMessage.error('报告上传失败')
|
||||
console.error('报告上传错误:', error)
|
||||
}
|
||||
}
|
||||
|
||||
onBeforeMount(async () => {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
|
||||
<el-dialog :title="dialogTitle" v-model='dialogVisible' @close="close" v-bind="dialogBig">
|
||||
<el-dialog :title="dialogTitle" v-model='dialogVisible' @close="close" v-bind="dialogBig" align-center>
|
||||
<div class="table-container">
|
||||
<el-table :data="errorData.value"
|
||||
height="500"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<el-dialog :title="dialogTitle" v-model='dialogVisible' @close="close" v-bind="dialogBig" width="1660px">
|
||||
<el-dialog :title="dialogTitle" v-model='dialogVisible' @close="close" v-bind="dialogBig" width="1660px" align-center>
|
||||
<el-tabs type="border-card">
|
||||
<el-tab-pane label="基础信息">
|
||||
<div>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<!-- 基础信息弹出框 -->
|
||||
<el-dialog :model-value="dialogVisible" :title="dialogTitle" v-bind="dialogSmall" @close="close" >
|
||||
<el-dialog :model-value="dialogVisible" :title="dialogTitle" v-bind="dialogSmall" @close="close" align-center>
|
||||
<div>
|
||||
<el-form :model="formContent" ref='dialogFormRef' :rules='rules'>
|
||||
<el-form-item label="名称" prop="name" >
|
||||
|
||||
@@ -0,0 +1,319 @@
|
||||
<template>
|
||||
<el-dialog :title="dialogTitle" v-model='dialogVisible' @close="close" v-bind="dialogBig" align-center>
|
||||
<el-tabs type="border-card">
|
||||
<el-tab-pane label="设备台账信息">
|
||||
<div >
|
||||
<el-form :model='formContent' ref='dialogFormRef' :rules='rules' :disabled="false" label-width="auto" class="form-three">
|
||||
<el-divider >设备信息</el-divider>
|
||||
|
||||
<el-form-item label="设备名称" prop="name" >
|
||||
<el-input v-model='formContent.name' placeholder="请输入设备名称" maxlength="32" show-word-limit/>
|
||||
</el-form-item>
|
||||
<el-form-item label='设备类型' prop='devType' >
|
||||
<el-select v-model="formContent.devType" filterable clearable placeholder="请选择设备类型" @change="handleDevTypeChange">
|
||||
<el-option
|
||||
v-for="item in devTypeOptions"
|
||||
:key="item.id"
|
||||
:label="item.name"
|
||||
:value="item.id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label='设备厂家' prop='manufacturer'>
|
||||
<el-select v-model="formContent.manufacturer" clearable placeholder="请选择设备厂家">
|
||||
<el-option
|
||||
v-for="item in dictStore.getDictData('Dev_Manufacturers')"
|
||||
:key="item.id"
|
||||
:label="item.name"
|
||||
:value="item.id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-divider >参数信息</el-divider>
|
||||
<el-form-item label='通讯协议' prop='protocol'>
|
||||
<el-select v-model="formContent.protocol" clearable placeholder="请选择通讯协议">
|
||||
<el-option
|
||||
v-for="item in dictStore.getDictData('Protocol')"
|
||||
:key="item.id"
|
||||
:label="item.name"
|
||||
:value="item.id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="IP地址" prop="ip" placeholder="请输入IP地址">
|
||||
<el-input v-model="formContent.ip"/>
|
||||
</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="请选择是否加密">
|
||||
<el-option label="是" :value="1"></el-option>
|
||||
<el-option label="否" :value="0"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label='识别码' prop='series' clearable v-if="formContent.encryptionFlag">
|
||||
<el-input v-model='formContent.series' placeholder="请输入识别码" show-password/>
|
||||
</el-form-item>
|
||||
<el-form-item label='密钥' prop='devKey' clearable v-if="formContent.encryptionFlag">
|
||||
<el-input v-model='formContent.devKey' placeholder="请输入密钥" show-password/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</div>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
<template #footer>
|
||||
<div >
|
||||
<el-button @click='close()'>取 消</el-button>
|
||||
<el-button type="primary" @click='save()'>保存</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
</template>
|
||||
<script setup lang='ts'>
|
||||
|
||||
import IPAddress from '@/components/IpAddress/index.vue'
|
||||
import { dialogBig } from '@/utils/elementBind'
|
||||
import {type StandardDevice} from '@/api/device/interface/standardDevice.ts'
|
||||
import { ElMessage, type FormItemRule } from 'element-plus'
|
||||
import { addPqStandardDev, updatePqStandardDev} from '@/api/device/standardDevice/index.ts'
|
||||
import { computed, reactive, type Ref, ref } from 'vue'
|
||||
import { useDictStore } from '@/stores/modules/dict'
|
||||
import { CirclePlus, Delete, EditPen } from '@element-plus/icons-vue'
|
||||
import {type Device} from '@/api/device/interface/device.ts'
|
||||
// 使用 dayjs 库格式化
|
||||
import dayjs from 'dayjs'
|
||||
|
||||
// 存储设备类型选项
|
||||
const devTypeOptions = ref<Device.ResDev[]>([])
|
||||
const dictStore = useDictStore()
|
||||
// 定义弹出组件元信息
|
||||
const dialogFormRef = ref()
|
||||
|
||||
const pqChannelArray = ref([
|
||||
{
|
||||
value: '1',
|
||||
label: '1',
|
||||
},
|
||||
{
|
||||
value: '2',
|
||||
label: '2',
|
||||
},
|
||||
{
|
||||
value: '3',
|
||||
label: '3',
|
||||
},
|
||||
{
|
||||
value: '4',
|
||||
label: '4',
|
||||
},
|
||||
])
|
||||
|
||||
function useMetaInfo() {
|
||||
const dialogVisible = ref(false)
|
||||
const titleType = ref('add')
|
||||
const formContent = reactive<StandardDevice.ResPqStandardDevice>({
|
||||
id: '',
|
||||
name: '',
|
||||
devType:'',
|
||||
manufacturer:'',
|
||||
protocol: 'MMS',
|
||||
ip: '',
|
||||
port: 102,
|
||||
inspectChannel:'',
|
||||
encryptionFlag: 0,
|
||||
state: 1,
|
||||
})
|
||||
return { dialogVisible, titleType, formContent }
|
||||
}
|
||||
|
||||
const { dialogVisible, titleType, formContent } = useMetaInfo()
|
||||
// 清空formContent
|
||||
const resetFormContent = () => {
|
||||
Object.assign(
|
||||
formContent,{
|
||||
id: '',
|
||||
name: '',
|
||||
devType:'',
|
||||
manufacturer:'',
|
||||
protocol: 'MMS',
|
||||
ip: '',
|
||||
port: 102,
|
||||
inspectChannel:'',
|
||||
encryptionFlag: 0,
|
||||
state: 1,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
let dialogTitle = computed(() => {
|
||||
return titleType.value === 'add' ? '新增标准设备' : '编辑标准设备'
|
||||
})
|
||||
|
||||
|
||||
//定义校验规则
|
||||
const rules: Ref<Record<string, Array<FormItemRule>>> = ref({
|
||||
name : [{ required: true, message: '设备名称必填!', trigger: 'blur' }],
|
||||
devType: [{ required: true, message: '设备类型必选!', trigger: 'change' }],
|
||||
manufacturer:[{ required: true, message: '生产厂家必选!', trigger: 'change' }],
|
||||
ip: [
|
||||
{ required: true, message: 'IP地址必填!', trigger: 'blur' },
|
||||
{ pattern: /^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/, message: 'IP地址格式错误', trigger: 'blur' }
|
||||
],
|
||||
port: [
|
||||
{ required: true, message: '端口号必填!', trigger: 'blur' },
|
||||
{ pattern: /^(6553[0-5]|655[0-2][0-9]|64[0-9]{3}|[1-5]?[0-9]{1,4})$/, message: '端口号范围0到65535的整数', trigger: 'blur' }
|
||||
],
|
||||
inspectChannel:[ { required: true, message: '可检通道数必选', trigger: 'change' }],
|
||||
encryptionFlag: [{ required: true, message: '是否加密必选!', trigger: 'change' }],
|
||||
series: [{ required: true, message: '请输入识别码', trigger: 'blur' }],
|
||||
devKey: [{ required: true, message: '请输入密钥', trigger: 'blur' }],
|
||||
protocol: [{required: true, message: '通讯协议必选!', trigger: 'change'}],
|
||||
})
|
||||
|
||||
// 关闭弹窗
|
||||
const close = () => {
|
||||
dialogVisible.value = false
|
||||
// 清空dialogForm中的值
|
||||
resetFormContent()
|
||||
// 重置表单
|
||||
dialogFormRef.value?.resetFields()
|
||||
|
||||
}
|
||||
|
||||
// 保存数据
|
||||
const save = () => {
|
||||
try {
|
||||
dialogFormRef.value?.validate(async (valid: boolean) => {
|
||||
if (formContent.encryptionFlag === 0) {
|
||||
formContent.series = ''
|
||||
formContent.devKey = ''
|
||||
}
|
||||
if (valid) {
|
||||
//保存时判是否加密,把识别码密钥字段清空
|
||||
if(formContent.encryptionFlag === 0){
|
||||
formContent.series = null
|
||||
formContent.devKey = null
|
||||
}
|
||||
|
||||
// 可检通道转为字符串逗号分隔(保存前临时转换)
|
||||
let originalInspectChannel = formContent.inspectChannel; // 保存原始值
|
||||
//可检通道转为字符串逗号分隔
|
||||
// 确保 inspectChannel 是数组再执行 join
|
||||
if (Array.isArray(formContent.inspectChannel)) {
|
||||
formContent.inspectChannel = formContent.inspectChannel
|
||||
.map(Number) // 将值转为数字以保证正确排序
|
||||
.sort((a, b) => a - b) // 数字升序排序
|
||||
.map(String) // 恢复为字符串用于保存
|
||||
.join(',');
|
||||
}
|
||||
|
||||
try {
|
||||
if (formContent.id) {
|
||||
await updatePqStandardDev(formContent);
|
||||
ElMessage.success({ message: `${dialogTitle.value}成功!` })
|
||||
} else {
|
||||
// 新增需要把通讯协议转成字典ID
|
||||
const protocolItem = dictStore.getDictData('Protocol').find(item => item.name === formContent.protocol);
|
||||
if (protocolItem) {
|
||||
formContent.protocol = protocolItem.id;
|
||||
}
|
||||
|
||||
await addPqStandardDev(formContent);
|
||||
ElMessage.success({ message: `${dialogTitle.value}成功!` })
|
||||
}
|
||||
close()
|
||||
// 刷新表格
|
||||
await props.refreshTable!()
|
||||
} catch (error) {
|
||||
// 如果保存失败,恢复原始的 inspectChannel 值
|
||||
formContent.inspectChannel = originalInspectChannel;
|
||||
throw error;
|
||||
}
|
||||
} else {
|
||||
// 验证失败也需要恢复原始 inspectChannel 格式(如果之前被转换过)
|
||||
if (typeof formContent.inspectChannel === 'string' && formContent.inspectChannel.includes(',')) {
|
||||
formContent.inspectChannel = formContent.inspectChannel.split(',').filter(Boolean);
|
||||
}
|
||||
|
||||
}
|
||||
})
|
||||
} catch (err) {
|
||||
console.error('验证过程中出现错误', err)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 打开弹窗,可能是新增,也可能是编辑
|
||||
const open = async (sign: string, data: StandardDevice.ResPqStandardDevice,devType:Device.ResDev[]) => {
|
||||
// 重置表单
|
||||
dialogFormRef.value?.resetFields()
|
||||
devTypeOptions.value = devType
|
||||
titleType.value = sign
|
||||
if (data.id) {
|
||||
Object.assign(formContent,{ ...data })
|
||||
if (typeof formContent.inspectChannel === 'string') {
|
||||
formContent.inspectChannel = formContent.inspectChannel.split(',').filter(Boolean)
|
||||
}
|
||||
//handleDevTypeChange(data.devType)
|
||||
} else {
|
||||
resetFormContent()
|
||||
}
|
||||
|
||||
|
||||
dialogVisible.value = true
|
||||
}
|
||||
|
||||
|
||||
const handleDevTypeChange = (value: string) => {
|
||||
console.log('handleDevTypeChange', value)
|
||||
// 在这里处理选中事件的逻辑
|
||||
const dev = devTypeOptions.value.find(t =>t.id === value)
|
||||
if (dev) {
|
||||
const maxChannel = dev.devChns
|
||||
// 动态设置 pqChannelArray 从 1 到 dev.devChns.length
|
||||
pqChannelArray.value = Array.from({ length: dev.devChns }, (_, i) => ({
|
||||
value: String(i + 1),
|
||||
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(
|
||||
(channel) => parseInt(channel, 10) <= maxChannel
|
||||
)
|
||||
}
|
||||
} else {
|
||||
// 可选:恢复默认值
|
||||
pqChannelArray.value = [
|
||||
{ value: '1', label: '1' },
|
||||
{ value: '2', label: '2' },
|
||||
{ value: '3', label: '3' },
|
||||
{ value: '4', label: '4' },
|
||||
]
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// 对外映射
|
||||
defineExpose({ open })
|
||||
const props = defineProps<{
|
||||
refreshTable: (() => Promise<void>) | undefined;
|
||||
}>()
|
||||
</script>
|
||||
228
frontend/src/views/machine/standardDevice/index.vue
Normal file
228
frontend/src/views/machine/standardDevice/index.vue
Normal file
@@ -0,0 +1,228 @@
|
||||
<template>
|
||||
<div class='table-box' ref='popupBaseView'>
|
||||
<ProTable
|
||||
ref='proTable'
|
||||
:columns='columns'
|
||||
:request-api='getTableList'
|
||||
>
|
||||
<!-- :requestApi="getRoleList" -->
|
||||
<!-- 表格 header 按钮 -->
|
||||
<template #tableHeader='scope'>
|
||||
<el-button v-auth.device="'add'" type='primary' :icon='CirclePlus' @click="openDialog('add')">新增</el-button>
|
||||
<el-button v-auth.device="'delete'" type='danger' :icon='Delete' plain :disabled='!scope.isSelected'
|
||||
@click='batchDelete(scope.selectedListIds)'>
|
||||
删除
|
||||
</el-button>
|
||||
<el-button v-auth.device="'export'" type='primary' :icon='Upload' plain @click='downloadFile()'>导出</el-button>
|
||||
<el-button v-auth.device="'import'" type='primary' :icon='Download' plain @click="importFile()">导入
|
||||
</el-button>
|
||||
</template>
|
||||
<!-- 表格操作 -->
|
||||
<template #operation='scope'>
|
||||
<el-button v-auth.device="'edit'" type='primary' link :icon='EditPen' :model-value='false'
|
||||
@click="openDialog('edit', scope.row)">编辑
|
||||
</el-button>
|
||||
<el-button v-auth.device="'delete'" type='primary' link :icon='Delete' @click='handleDelete(scope.row)'>删除
|
||||
</el-button>
|
||||
</template>
|
||||
|
||||
</ProTable>
|
||||
</div>
|
||||
<StandardDevicePopup :refresh-table='proTable?.getTableList' ref='standardDevicePopup'/>
|
||||
<ImportExcel ref='deviceImportExcel'/>
|
||||
</template>
|
||||
|
||||
<script setup lang='tsx' name='useRole'>
|
||||
import {type StandardDevice} from '@/api/device/interface/standardDevice.ts'
|
||||
import {useHandleData} from '@/hooks/useHandleData'
|
||||
import {useDownload} from '@/hooks/useDownload'
|
||||
import ProTable from '@/components/ProTable/index.vue'
|
||||
import {type ColumnProps, type ProTableInstance} from '@/components/ProTable/interface'
|
||||
import StandardDevicePopup from '@/views/machine/standardDevice/components/standardDevicePopup.vue'
|
||||
import {CirclePlus, Delete, Download, EditPen, Upload} from '@element-plus/icons-vue'
|
||||
import {deletePqStandardDev, getPqStandardDevList,getPqStandardDevById,exportPqStandardDev,downloadTemplate,importPqStandardDev} from '@/api/device/standardDevice/index.ts'
|
||||
import {computed, onBeforeMount, reactive, ref} from 'vue'
|
||||
import { getPqDev} from '@/api/device/device/index.ts'
|
||||
import {type Device} from '@/api/device/interface/device.ts'
|
||||
import {useDictStore} from '@/stores/modules/dict'
|
||||
import { ElMessageBox } from 'element-plus'
|
||||
import ImportExcel from '@/components/ImportExcel/index.vue'
|
||||
// ProTable 实例
|
||||
const proTable = ref<ProTableInstance>()
|
||||
const standardDevicePopup = ref()
|
||||
// 存储设备类型选项
|
||||
const devTypeOptions = ref<Device.ResDev[]>([])
|
||||
const dictStore = useDictStore()
|
||||
|
||||
|
||||
const getTableList = async (params: any) => {
|
||||
let newParams = JSON.parse(JSON.stringify(params))
|
||||
|
||||
return getPqStandardDevList(newParams)
|
||||
}
|
||||
|
||||
// 表格配置项
|
||||
const columns = reactive<ColumnProps<StandardDevice.ResPqStandardDevice>[]>([
|
||||
{type: 'selection', fixed: 'left', width: 70},
|
||||
{type: 'index', fixed: 'left', width: 70, label: '序号'},
|
||||
{
|
||||
prop: 'name',
|
||||
label: '名称',
|
||||
search: {el: 'input'},
|
||||
minWidth: 200,
|
||||
},
|
||||
{
|
||||
prop: 'devType',
|
||||
label: '设备类型',
|
||||
enum:computed(() => {
|
||||
return devTypeOptions.value.map(item => ({
|
||||
id: item.id,
|
||||
name: item.name,
|
||||
icd: item.icd,
|
||||
power: item.power,
|
||||
devVolt: item.devVolt,
|
||||
devCurr: item.devCurr,
|
||||
devChns: item.devChns,
|
||||
}))
|
||||
}),
|
||||
search: {el: 'select', props: {filterable: true}, order: 1},
|
||||
fieldNames: {label: 'name', value: 'id'},
|
||||
render: (scope) => {
|
||||
// 查找设备类型名称
|
||||
const name = devTypeOptions.value.find(option => option.id === scope.row.devType)
|
||||
return <span>{name?.name}</span>
|
||||
},
|
||||
minWidth: 200,
|
||||
},
|
||||
{
|
||||
prop: 'inspectChannel',
|
||||
label: '可检通道',
|
||||
minWidth: 150,
|
||||
render: (scope) => {
|
||||
const codes = scope.row.inspectChannel // 获取当前行的 datasourceIds 字段
|
||||
if (!codes) {
|
||||
return '/'
|
||||
}
|
||||
// 确保 codes 是一个字符串
|
||||
const codeString = Array.isArray(codes) ? codes.join(',') : codes
|
||||
const codeArray = codeString.split(',')
|
||||
return codeArray.length > 1 ? codeArray.join(', ') : codeArray[0]
|
||||
},
|
||||
},
|
||||
{
|
||||
prop: 'ip',
|
||||
label: 'IP地址',
|
||||
minWidth: 110,
|
||||
},
|
||||
{
|
||||
prop: 'manufacturer',
|
||||
label: '设备厂家',
|
||||
enum: dictStore.getDictData('Dev_Manufacturers'),
|
||||
search: {el: 'select', props: {filterable: true}, order: 1},
|
||||
fieldNames: {label: 'name', value: 'id'},
|
||||
minWidth: 200,
|
||||
},
|
||||
{
|
||||
prop: 'createTime',
|
||||
label: '创建时间',
|
||||
minWidth: 200,
|
||||
render: scope => {
|
||||
if (scope.row.createTime) {
|
||||
const date = new Date(scope.row.createTime);
|
||||
const year = date.getFullYear();
|
||||
const month = String(date.getMonth() + 1).padStart(2, '0');
|
||||
const day = String(date.getDate()).padStart(2, '0');
|
||||
const hours = String(date.getHours()).padStart(2, '0');
|
||||
const minutes = String(date.getMinutes()).padStart(2, '0');
|
||||
const seconds = String(date.getSeconds()).padStart(2, '0');
|
||||
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
|
||||
}
|
||||
return '';
|
||||
}
|
||||
},
|
||||
{prop: 'operation', label: '操作', fixed: 'right', width: 200},
|
||||
])
|
||||
|
||||
|
||||
|
||||
|
||||
const formContent = reactive<StandardDevice.ResPqStandardDevice>({
|
||||
id: '',
|
||||
name: '',
|
||||
devType:'',
|
||||
manufacturer:'',
|
||||
hardwareVersion: '',
|
||||
softwareVersion: '',
|
||||
ip: '172.17.102.200',
|
||||
port: 102,
|
||||
inspectChannel:'',
|
||||
encryptionFlag: 0,
|
||||
state: 1,
|
||||
})
|
||||
|
||||
// 打开 drawer(新增、编辑)
|
||||
const openDialog = async (titleType: string, row: Partial<StandardDevice.ResPqStandardDevice> = {}) => {
|
||||
if(titleType === 'add'){
|
||||
row = formContent
|
||||
standardDevicePopup.value?.open(titleType, row,devTypeOptions.value)
|
||||
}else{
|
||||
row = await getPqStandardDevById(row)
|
||||
standardDevicePopup.value?.open(titleType, row.data,devTypeOptions.value)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// 批量删除设备
|
||||
const batchDelete = async (id: string[]) => {
|
||||
await useHandleData(deletePqStandardDev, id, '删除所选设备')
|
||||
proTable.value?.clearSelection()
|
||||
proTable.value?.getTableList()
|
||||
}
|
||||
|
||||
// 删除设备
|
||||
const handleDelete = async (params: StandardDevice.ResPqStandardDevice) => {
|
||||
await useHandleData(deletePqStandardDev, [params.id] , `删除【${params.name}】设备`)
|
||||
proTable.value?.getTableList()
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 导出设备
|
||||
const downloadFile = async () => {
|
||||
ElMessageBox.confirm('确认导出标准设备?', '温馨提示', {type: 'warning'}).then(() => {
|
||||
useDownload(exportPqStandardDev, '标准设备导出数据', {...proTable.value?.searchParam}, false, '.xlsx')
|
||||
})
|
||||
}
|
||||
|
||||
//导入设备
|
||||
const deviceImportExcel = ref<InstanceType<typeof ImportExcel> | null>(null)
|
||||
|
||||
const importFile = async () => {
|
||||
const params = {
|
||||
title: '标准设备',
|
||||
showCover: false,
|
||||
tempApi: downloadTemplate,
|
||||
importApi: importPqStandardDev,
|
||||
getTableList: proTable.value?.getTableList,
|
||||
}
|
||||
deviceImportExcel.value?.acceptParams(params)
|
||||
}
|
||||
|
||||
|
||||
onBeforeMount(async () => {
|
||||
const response = await getPqDev()
|
||||
devTypeOptions.value = (response.data as Device.ResDev[]).map(item => ({
|
||||
id: item.id,
|
||||
name: item.name,
|
||||
icd: item.icd,
|
||||
power: item.power,
|
||||
devVolt: item.devVolt,
|
||||
devCurr: item.devCurr,
|
||||
devChns: item.devChns,
|
||||
}))
|
||||
|
||||
})
|
||||
|
||||
</script>
|
||||
|
||||
@@ -204,6 +204,10 @@ const waveList = [
|
||||
{
|
||||
fchagFre: '2400',
|
||||
fchagValue: '0.77'
|
||||
},
|
||||
{
|
||||
fchagFre: '4000',
|
||||
fchagValue: '2.4'
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<el-dialog v-model="dialogVisible" :title="dialogTitle"
|
||||
v-bind="dialogSmall" @close="close">
|
||||
v-bind="dialogSmall" @close="close" align-center>
|
||||
<div>
|
||||
<el-form :model="formContent" ref="dialogFormRef" :rules="rules">
|
||||
<el-form-item label="参数所属" prop="pId" :label-width="100">
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<el-dialog :title="dialogTitle" v-model='dialogVisible' @close="close" v-bind="dialogBig">
|
||||
<el-dialog :title="dialogTitle" v-model='dialogVisible' @close="close" v-bind="dialogBig" align-center>
|
||||
<div >
|
||||
<el-form :model="formContent" ref='dialogFormRef' :rules='rules' :disabled="tableIsDisable" label-width="auto" class="form-three">
|
||||
<el-form-item label="设备类型" prop="devType" >
|
||||
|
||||
547
frontend/src/views/plan/planList/components/childrenPlan.vue
Normal file
547
frontend/src/views/plan/planList/components/childrenPlan.vue
Normal file
@@ -0,0 +1,547 @@
|
||||
<!--单列-->
|
||||
<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" v-if="isTabPlanFather" @click="subBatchRemove(scope.selectedListIds)">
|
||||
批量移除
|
||||
</el-button>
|
||||
<el-dropdown trigger="hover" placement="right-start" :disabled="!scope.isSelected">
|
||||
<el-button type="primary" :icon="ScaleToOriginal" style="margin-left: 10px;" v-if="!isTabPlanFather" :disabled="!scope.isSelected">
|
||||
分配被检设备
|
||||
</el-button>
|
||||
<template #dropdown >
|
||||
<el-dropdown-menu>
|
||||
<el-dropdown-item
|
||||
v-for="child in planFormContent?.children"
|
||||
:key="child.id"
|
||||
@click="distribute(child,scope)"
|
||||
>
|
||||
{{ 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="scope">
|
||||
<el-button type="primary" link :icon="Delete" v-if="!isTabPlanFather" :disabled="scope.row.checkState != 0" @click="handleRemove(scope.row)">删除</el-button>
|
||||
<el-button type="primary" link :icon="Delete" v-if="isTabPlanFather" @click="subHandleRemove(scope.row)">移除</el-button>
|
||||
</template>
|
||||
</ProTable>
|
||||
</div>
|
||||
</el-dialog>
|
||||
<!-- 向计划导入/导出设备对话框 -->
|
||||
<PlanPopup :refresh-table='proTable?.getTableList' ref='planPopup' @update:tab="addNewChildTab"/>
|
||||
<DevTransfer ref='devTransfer' @update:table="addNewChildTab"/>
|
||||
</template>
|
||||
<script setup lang="tsx">
|
||||
import { ElMessage, ElMessageBox, TabPaneName } from 'element-plus'
|
||||
import { ref, computed, watch, reactive } from 'vue'
|
||||
import { ScaleToOriginal, CirclePlus, Delete, Upload, Download } from '@element-plus/icons-vue'
|
||||
import 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,deletePlan} from '@/api/plan/plan'
|
||||
import { Device } from '@/api/device/interface/device'
|
||||
import { useDictStore } from '@/stores/modules/dict'
|
||||
import DevTransfer from '@/views/plan/planList/components/devTransfer.vue'
|
||||
import { useHandleData } from '@/hooks/useHandleData'
|
||||
|
||||
|
||||
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 planTabDevList = ref<any[]>([])
|
||||
const patternId = ref('')
|
||||
|
||||
const getTableList = async (params: any) => {
|
||||
if (!planFormContent.value) {
|
||||
return Promise.resolve({ data: [], total: 0 });
|
||||
}
|
||||
let newParams = JSON.parse(JSON.stringify(params));
|
||||
newParams.pattern = patternId.value
|
||||
if(!isTabPlanFather.value)
|
||||
newParams.planId = planFormContent.value.id
|
||||
else
|
||||
newParams.planId = planId.value
|
||||
newParams.planIdList = [newParams.planId];
|
||||
proTable.value?.clearSelection()
|
||||
planTabDevList.value = await getDevListByPlanId(newParams);
|
||||
return planTabDevList.value;
|
||||
}
|
||||
|
||||
|
||||
const columns = reactive<ColumnProps<Device.ResPqDev>[]>([
|
||||
{ type: 'selection', fixed: 'left', width: 70,selectable: (row) => row.checkState == 0 },
|
||||
{ type: 'index', fixed: 'left', width: 70, label: '序号' },
|
||||
{
|
||||
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,
|
||||
|
||||
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 () => {
|
||||
if(row.checkState != 0){
|
||||
ElMessage.warning(`当前设备已检,无法解除绑定!`);
|
||||
return
|
||||
}
|
||||
await subPlanBindDev({'planId': row.planId, 'devIds': [row.id] ,'bindFlag': 0}) //解绑 0 绑定 1
|
||||
// 👇 更新数据(例如清空 state 字段)
|
||||
row.state = '/'
|
||||
proTable.value?.getTableList()
|
||||
// 可选:刷新表格或提交接口
|
||||
ElMessage.success('解绑成功')
|
||||
}).catch(() => {
|
||||
// 用户取消操作
|
||||
})
|
||||
}
|
||||
|
||||
// 新增 tab 方法
|
||||
const addTab = (type: string) => {
|
||||
if(type === "add"){
|
||||
planPopup.value?.open("edit", planFormContent.value,modeStore.currentMode,1)
|
||||
}else {
|
||||
const subPlanFormContent = ref<Plan.ReqPlan>()
|
||||
// 从 planFormContent.value?.children 中找到 id 与 item.name 匹配的子计划
|
||||
subPlanFormContent.value = planFormContent.value?.children?.find(
|
||||
(child: Plan.ReqPlan) => child.id === planId.value
|
||||
)
|
||||
console.log('0000---',subPlanFormContent.value)
|
||||
planPopup.value?.open("edit", subPlanFormContent.value,modeStore.currentMode,2)
|
||||
}
|
||||
}
|
||||
|
||||
//收到子组件回复后新增子计划tab
|
||||
const addNewChildTab = async () => {
|
||||
await props.refreshTable!()//刷新检测计划列表
|
||||
}
|
||||
|
||||
//分配被检设备
|
||||
const distribute = (childPlan: Plan.ResPlan, scope: any) => {
|
||||
|
||||
// 获取当前选中的设备对象
|
||||
const selectedDevices = planTabDevList.value.data.records.filter((dev: { id: any }) =>
|
||||
scope.selectedListIds.includes(dev.id)
|
||||
);
|
||||
// 找出不符合条件的设备
|
||||
const invalidDevices = selectedDevices.filter(
|
||||
(dev: { checkState: number; assign: number }) => dev.checkState !== 0 || dev.assign === 1
|
||||
);
|
||||
if (invalidDevices.length > 0) {
|
||||
const names = invalidDevices.map((dev: { name: any }) => dev.name).join('、');
|
||||
ElMessage.warning(`以下设备不可分配:${names}`);
|
||||
proTable.value?.clearSelection()
|
||||
return;
|
||||
}
|
||||
ElMessageBox.confirm(`确定将以下被检设备分配给 ${childPlan.name} 吗?`, '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning',
|
||||
}).then(async () => {
|
||||
await subPlanBindDev({'planId': childPlan.id, 'devIds': scope.selectedListIds ,'bindFlag': 1}) //解绑 0 绑定 1
|
||||
proTable.value?.getTableList()
|
||||
ElMessage.success('分配成功')
|
||||
}).catch(() => {
|
||||
// 用户取消操作
|
||||
})
|
||||
}
|
||||
|
||||
const allotStandardDev = (childPlan: Plan.ResPlan) => {
|
||||
devTransfer.value.open(childPlan)
|
||||
}
|
||||
|
||||
// 删除 tab 方法
|
||||
const removeTab = async (targetName: TabPaneName) => {
|
||||
// 找到匹配的 tab
|
||||
const tab = editableTabs.value.find(item => item.name === targetName);
|
||||
const tabTitle = tab?.title || '未知计划'; // 获取 tab 的标题,若不存在则默认为 '未知计划'
|
||||
|
||||
await useHandleData(deletePlan, { id: [targetName], pattern: patternId.value }, `删除【${tabTitle}】检测计划`);
|
||||
await props.refreshTable!()//刷新检测计划列表
|
||||
}
|
||||
|
||||
|
||||
// 弹窗打开方法
|
||||
const open = async (textTitle: string,data: Plan.ReqPlan,pattern: string) => {
|
||||
console.log('open',data)
|
||||
dialogVisible.value = true
|
||||
title.value = textTitle
|
||||
planTitle.value = data.name
|
||||
planId.value = data.id
|
||||
planFormContent.value = data
|
||||
editableTabsValue.value = planFormContent.value.id//默认tab第一个
|
||||
proTable.value?.getTableList()
|
||||
isTabPlanFather.value = false//子计划页面按钮默认展示主计划的
|
||||
patternId.value = pattern
|
||||
columns.forEach(item => {//刚进去子计划页面隐藏主计划的操作列
|
||||
if (item.prop === 'operation') {
|
||||
item.isShow = false;
|
||||
}
|
||||
});
|
||||
console.log('弹窗打开方法',planFormContent.value)
|
||||
|
||||
}
|
||||
|
||||
const handleTabClick = (tab:any) => {
|
||||
if(tab.props.closable){
|
||||
columns.forEach(item => {//隐藏子计划名称
|
||||
if (item.prop === 'boundPlanName') {
|
||||
item.isShow = false;
|
||||
}
|
||||
if (item.prop === 'operation') {
|
||||
item.isShow = true;
|
||||
}
|
||||
});
|
||||
isTabPlanFather.value = true
|
||||
}else{
|
||||
columns.forEach(item => {
|
||||
if (item.prop === 'boundPlanName') {
|
||||
item.isShow = true;
|
||||
}
|
||||
if (item.prop === 'operation') {
|
||||
item.isShow = false;
|
||||
}
|
||||
});
|
||||
isTabPlanFather.value = false
|
||||
}
|
||||
planId.value = tab.props.name
|
||||
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; // 未找到匹配项
|
||||
};
|
||||
|
||||
|
||||
|
||||
//主计划下移除被检设备
|
||||
const handleRemove = async (row: any) => {
|
||||
ElMessageBox.confirm(`确定要移除计划【${row.name}】吗?`, '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(async () => {
|
||||
if(row.assign != 0){
|
||||
ElMessage.warning(`当前设备已被子计划绑定,无法删除!`);
|
||||
return
|
||||
}
|
||||
console.log('shcn',planFormContent.value)
|
||||
proTable.value?.getTableList(); // 刷新当前表格
|
||||
}).catch(() => {
|
||||
// 用户取消操作
|
||||
});
|
||||
}
|
||||
|
||||
//子计划下移除被检设备
|
||||
const subHandleRemove = async (row: any) => {
|
||||
ElMessageBox.confirm(`确定要移除计划【${row.name}】吗?`, '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(async () => {
|
||||
if(row.checkState != 0){
|
||||
ElMessage.warning(`当前设备已检,无法移除!`);
|
||||
return
|
||||
}
|
||||
await subPlanBindDev({'planId': row.planId, 'devIds': [row.id] ,'bindFlag': 0}) //解绑 0 绑定 1
|
||||
ElMessage.success('移除成功');
|
||||
proTable.value?.getTableList(); // 刷新当前表格
|
||||
}).catch(() => {
|
||||
// 用户取消操作
|
||||
});
|
||||
}
|
||||
|
||||
// 子计划下批量移除被检设备
|
||||
const subBatchRemove = async (selectedListIds: string[]) => {
|
||||
|
||||
|
||||
const selectedDevices = planTabDevList.value.data.records.filter((dev: { id: any }) =>
|
||||
selectedListIds.includes(dev.id)
|
||||
);
|
||||
|
||||
const invalidDevices = selectedDevices.filter(
|
||||
(dev: { checkState: number }) => dev.checkState !== 0
|
||||
);
|
||||
|
||||
if (invalidDevices.length > 0) {
|
||||
const names = invalidDevices.map((dev: { name: any }) => dev.name).join('、');
|
||||
ElMessage.warning(`以下设备不可移除(已检):${names}`);
|
||||
proTable.value?.clearSelection();
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await ElMessageBox.confirm(`确定要批量移除选中的 ${selectedListIds.length} 个设备吗?`, '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
});
|
||||
|
||||
await subPlanBindDev({ planId: planId.value, devIds: selectedListIds, bindFlag: 0 });
|
||||
ElMessage.success('批量移除成功');
|
||||
proTable.value?.getTableList(); // 刷新表格
|
||||
} catch (error) {
|
||||
// 用户取消或接口异常
|
||||
console.error('批量移除失败:', error);
|
||||
}
|
||||
};
|
||||
|
||||
defineExpose({ open,handleTableDataUpdate })
|
||||
|
||||
interface ChildrenPlanProps {
|
||||
refreshTable?: () => Promise<void>
|
||||
width?: number
|
||||
height?: number
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<ChildrenPlanProps>(), {
|
||||
width: 800,
|
||||
height: 744
|
||||
})
|
||||
// const props = defineProps<{
|
||||
// refreshTable: (() => Promise<void>) | undefined;
|
||||
// width: {
|
||||
// type: Number,
|
||||
// default: 800,
|
||||
// },
|
||||
// height: {
|
||||
// type: Number,
|
||||
// default: 744,
|
||||
// },
|
||||
// }>()
|
||||
</script>
|
||||
@@ -1,13 +1,13 @@
|
||||
<template>
|
||||
<!-- 权限信息弹出框 -->
|
||||
<el-dialog title="设备绑定" v-model='dialogVisible' @close="close" v-bind="dialogBig" width="600" draggable>
|
||||
<el-dialog title="标准设备绑定" v-model='dialogVisible' @close="close" v-bind="dialogBig" width="600" draggable>
|
||||
<div>
|
||||
<el-transfer v-model="value"
|
||||
filterable
|
||||
:filter-method="filterMethod"
|
||||
filter-placeholder="请输入内容搜索"
|
||||
:data="allData"
|
||||
:titles="['未绑定设备', '已绑定设备']">
|
||||
:titles="['未绑定标准设备', '已绑定标准设备']">
|
||||
<template #default="{ option }">
|
||||
<el-tooltip :content="option.tips" placement="top" :show-after=1000>
|
||||
<span>{{ option.label }}</span>
|
||||
@@ -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,subPlanBindStandardDevList } 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 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]
|
||||
@@ -68,34 +65,35 @@ const filterMethod = (query: string, item: { label?: string }) => {
|
||||
const open = async (data: Plan.ReqPlan) => {
|
||||
dialogVisible.value = true
|
||||
planData.value = data
|
||||
console.log('planData.value',planData.value)
|
||||
const standardDevList_Result1 = await getUnboundStandardDevList(data);
|
||||
unboundStandardDevList.value = standardDevList_Result1.data as StandardDevice.ResPqStandardDevice[];
|
||||
|
||||
//console.log('123')
|
||||
const standardDevList_Result2 = await getBoundStandardDevList(data);
|
||||
boundStandardDevList.value = standardDevList_Result2.data as StandardDevice.ResPqStandardDevice[];
|
||||
|
||||
const pqDevList_Result1 = await getUnboundPqDevList(data);
|
||||
unboundPqDevList.value = pqDevList_Result1.data as Device.ReqPqDevParams[];
|
||||
value.value = boundStandardDevList.value.map((i: { id: { toString: () => any } }) => i.id.toString());
|
||||
|
||||
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 close = () => {
|
||||
dialogVisible.value = false
|
||||
|
||||
}
|
||||
|
||||
|
||||
const emit = defineEmits(['update:table'])
|
||||
|
||||
const save = async () => {
|
||||
if (planData.value) {
|
||||
//await BindPqDevList({ 'planId': planData.value.id,'pqDevIds': value.value })
|
||||
ElMessage.success({ message: `设备绑定保存成功成功!` })
|
||||
planData.value.planId = planData.value.id
|
||||
planData.value.devIds = value.value
|
||||
await subPlanBindStandardDevList(planData.value)
|
||||
emit('update:table')
|
||||
ElMessage.success({ message: `标准设备绑定保存成功!` })
|
||||
}
|
||||
dialogVisible.value = false
|
||||
}
|
||||
|
||||
// 对外映射
|
||||
defineExpose({ open })
|
||||
const props = defineProps<{
|
||||
refreshTable: (() => Promise<void>) | undefined;
|
||||
}>()
|
||||
|
||||
</script>
|
||||
@@ -1,14 +1,35 @@
|
||||
<template>
|
||||
<!-- 基础信息弹出框 -->
|
||||
<el-dialog :title="dialogTitle" v-model='dialogVisible' @close="close" v-bind="dialogBig">
|
||||
<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-col :span="planType == 0 ? 12 : 24">
|
||||
<el-form :model="formContent" ref='dialogFormRef' :rules='rules' >
|
||||
<el-form-item label="名称" prop="name" :label-width="100">
|
||||
<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='standardDevIds' :label-width='110' v-if="selectByMode && planType == 0" >
|
||||
<el-select v-model="formContent.standardDevIds" 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"
|
||||
:disabled="subPlanBindStandardDev.includes(option.label)"
|
||||
/>
|
||||
</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 +39,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 +49,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 +59,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 +79,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 +91,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,17 +101,20 @@
|
||||
/>
|
||||
</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
|
||||
:filter-method="filterMethod"
|
||||
filter-placeholder="请输入内容搜索"
|
||||
:data="allData"
|
||||
:titles="['未绑定设备', '已绑定设备']">
|
||||
:titles="['未绑定被检设备', '已绑定被检设备']">
|
||||
<template #default="{ option }">
|
||||
<span>{{ option.label }}</span>
|
||||
</template>
|
||||
@@ -108,20 +132,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 +159,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 subPlanBindStandardDev = ref<any>([])//哪些标准设备已经被子计划绑定
|
||||
|
||||
const generateData = () => {
|
||||
const unboundData = unboundPqDevList.value.map((i: Device.ResPqDev) => ({
|
||||
key: i.id,
|
||||
@@ -160,7 +192,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 +201,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 +229,12 @@ const filterMethod = (query: string, item: { label?: string }) => {
|
||||
reportTemplateName:'',
|
||||
reportTemplateVersion:'',
|
||||
dataRule:'',
|
||||
standardDevNameStr:'',
|
||||
testItemNameStr:'',
|
||||
standardDevIds:[],
|
||||
standardDevMap:new Map<string, number>(),
|
||||
testItems:[],
|
||||
Check_By:'',
|
||||
})
|
||||
return { dialogVisible, titleType, formContent }
|
||||
}
|
||||
@@ -232,18 +269,27 @@ const filterMethod = (query: string, item: { label?: string }) => {
|
||||
reportTemplateName:'',
|
||||
reportTemplateVersion:'',
|
||||
dataRule:'',
|
||||
standardDevNameStr:'',
|
||||
standardDevIds:[],
|
||||
standardDevMap:new Map<string, number>(),
|
||||
testItemNameStr:'',
|
||||
testItems:[],
|
||||
Check_By:'',
|
||||
}
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
let dialogTitle = computed(() => {
|
||||
return titleType.value === 'add' ? '新增检测计划' : '编辑检测计划'
|
||||
if (planType.value === 1) {
|
||||
return '新增子计划'
|
||||
} else if (titleType.value === 'add') {
|
||||
return '新增检测计划'
|
||||
} else {
|
||||
return '编辑检测计划'
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
// 定义表单校验规则
|
||||
const baseRules: Record<string, Array<FormItemRule>> = {
|
||||
name: [{ required: true, message: '检测计划名称必填!', trigger: 'blur' }],
|
||||
@@ -252,6 +298,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' }],
|
||||
standardDevIds: [{ required: true, message: '标准设备必选!', trigger: 'change' }],
|
||||
testItems: [{ required: true, message: '测试项必选!', trigger: 'change' }],
|
||||
};
|
||||
|
||||
// 使用计算属性根据 scene 动态生成规则
|
||||
@@ -278,23 +326,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 +340,29 @@ 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.standardDevIds = []
|
||||
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{
|
||||
formContent.sourceIds = null
|
||||
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 +377,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,7 +386,9 @@ const rules = computed(() => {
|
||||
}
|
||||
close()
|
||||
// 刷新表格
|
||||
if(planType.value == 0){
|
||||
await props.refreshTable!()
|
||||
}
|
||||
|
||||
}
|
||||
})
|
||||
@@ -343,9 +399,7 @@ const rules = computed(() => {
|
||||
|
||||
|
||||
// 打开弹窗,可能是新增,也可能是编辑
|
||||
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 +408,72 @@ const open = async (sign: string,
|
||||
mode.value = currentMode
|
||||
titleType.value = sign
|
||||
isSelectDisabled.value = false
|
||||
planType.value = plan
|
||||
console.log('planType.value',planType.value)
|
||||
//比对式测试项下拉框
|
||||
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 +487,72 @@ 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: [] };
|
||||
|
||||
//编辑时,把标准设备map赋值给数组
|
||||
formContent.standardDevIds = Object.keys(formContent.standardDevMap)
|
||||
//哪些标准设备已经被子计划绑定
|
||||
subPlanBindStandardDev.value = Object.entries(formContent.standardDevMap)
|
||||
.filter(([key, value]) => value === 1)
|
||||
.map(([key]) => {
|
||||
const matched = pqStandardDev_Result.data?.find(
|
||||
(item: StandardDevice.ResPqStandardDevice) => item.id === key
|
||||
);
|
||||
return matched ? matched.name : key;
|
||||
});
|
||||
|
||||
} else {
|
||||
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 : [];
|
||||
|
||||
@@ -451,12 +586,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 +636,18 @@ function pqToArray() {
|
||||
label: item.name,
|
||||
value: item.id
|
||||
}))
|
||||
|
||||
const sourceArray5 = Array.isArray(pqStandardDevList.value) ? pqStandardDevList.value : []
|
||||
pqStandardDevArray.value = sourceArray5.map(item => ({
|
||||
label: item.name,
|
||||
value: item.id
|
||||
}))
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
const dataSourceType = computed(() => {
|
||||
// switch (mode.value) {
|
||||
// case '模拟式':
|
||||
@@ -496,6 +660,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'>导入</el-button>
|
||||
<el-button type='primary' v-auth.plan="'export'" :icon='Upload' @click='exportClick'>导出</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="'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>
|
||||
</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,36 +25,49 @@
|
||||
<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="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'/>
|
||||
|
||||
|
||||
<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/sourcePopup.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'
|
||||
@@ -62,7 +77,7 @@ import type { ErrorSystem } from '@/api/error/interface'
|
||||
import ErrorStandardPopup from '@/views/machine/errorSystem/components/errorStandardPopup.vue' // 导入子组件
|
||||
import TestSourcePopup from '@/views/machine/testSource/components/testSourcePopup.vue' // 导入子组件
|
||||
import { type TestSource } from '@/api/device/interface/testSource'
|
||||
import { useModeStore } from '@/stores/modules/mode'; // 引入模式 store
|
||||
import { useAppSceneStore, useModeStore } from '@/stores/modules/mode'; // 引入模式 store
|
||||
import { useHandleData } from '@/hooks/useHandleData'
|
||||
import { dictTestState,dictReportState,dictResult } from '@/api/plan/planData.ts'
|
||||
import {getTestSourceById} from '@/api/device/testSource/index'
|
||||
@@ -71,40 +86,138 @@ 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 modeStore = useModeStore();
|
||||
const tableData = ref<any[]>([])
|
||||
const planImportExcel = ref<InstanceType<typeof ImportExcel> | null>(null)
|
||||
const planList = ref<Plan.ResPlan[]>([]);
|
||||
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 {
|
||||
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) {
|
||||
tableData.value = [];
|
||||
ElMessage.error('获取计划列表失败');
|
||||
}
|
||||
}
|
||||
|
||||
// 监听 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))
|
||||
const patternId = dictStore.getDictData('Pattern').find(item=>item.name=== modeStore.currentMode)?.id//获取数据字典中对应的id
|
||||
newParams.patternId = patternId
|
||||
// 从 newParams 中提取筛选条件
|
||||
const name = newParams.name
|
||||
const reportState = newParams.reportState
|
||||
const result = newParams.result
|
||||
const testState = newParams.testState
|
||||
|
||||
try {
|
||||
const result = await getPlanList(newParams);
|
||||
planList.value = result.data as Plan.ResPlan[];
|
||||
return result;
|
||||
} catch (error) {
|
||||
return { data: [] }; // 返回空数据或处理错误
|
||||
}
|
||||
// 对 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) {
|
||||
@@ -118,7 +231,6 @@ const dataSourceType = computed(() => {
|
||||
return 'Datasource'
|
||||
})
|
||||
|
||||
|
||||
// 表格配置项
|
||||
const columns = reactive<ColumnProps<Plan.ReqPlan>[]>([
|
||||
{ type: 'selection', fixed: 'left', minWidth: 70 },
|
||||
@@ -126,22 +238,39 @@ const columns = reactive<ColumnProps<Plan.ReqPlan>[]>([
|
||||
{
|
||||
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' },
|
||||
render: scope => {
|
||||
return (
|
||||
scope.row.testState === 0 ? '未检' : scope.row.testState === 1 ? '检测中' : '检测完成'
|
||||
scope.row.testState === 0 ? <el-tag type='warning' effect="dark">未检</el-tag> :
|
||||
scope.row.testState === 1 ? <el-tag type='danger' effect="dark">检测中</el-tag> :
|
||||
<el-tag type='success' effect="dark">检测完成</el-tag>
|
||||
)
|
||||
},
|
||||
},
|
||||
{
|
||||
prop: 'progress',
|
||||
label: '检测进度',
|
||||
minWidth: 150,
|
||||
render: (scope) => {
|
||||
return (
|
||||
<el-progress
|
||||
text-inside={true}
|
||||
stroke-width={20}
|
||||
percentage={(scope.row.progress ?? 0) * 100}
|
||||
status='success'
|
||||
/>
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
prop: 'reportState',
|
||||
label: '检测报告状态',
|
||||
@@ -158,12 +287,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 ? '符合' : '/'
|
||||
)
|
||||
@@ -172,7 +300,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);
|
||||
@@ -190,7 +318,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 : [];
|
||||
@@ -218,17 +347,36 @@ 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 == "比对式",
|
||||
render: scope => {
|
||||
const standardDevNameStr = scope.row.standardDevNameStr
|
||||
if (!standardDevNameStr) {
|
||||
return '/'
|
||||
}
|
||||
return standardDevNameStr
|
||||
}
|
||||
},
|
||||
{
|
||||
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)}>
|
||||
@@ -237,12 +385,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) {
|
||||
@@ -275,7 +429,7 @@ const columns = reactive<ColumnProps<Plan.ReqPlan>[]>([
|
||||
minWidth: 120,
|
||||
},
|
||||
|
||||
{ prop: 'operation', label: '操作', fixed: 'right', minWidth: 300 },
|
||||
{ prop: 'operation', label: '操作', fixed: 'right', minWidth: 250 },
|
||||
])
|
||||
|
||||
|
||||
@@ -312,44 +466,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 = {
|
||||
@@ -358,60 +474,62 @@ 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)
|
||||
}
|
||||
// 点击导出按钮
|
||||
const exportClick = () => {
|
||||
|
||||
ElMessageBox.confirm('确认导出检测计划?', '温馨提示', { type: 'warning' }).then(() =>{
|
||||
const patternId = dictStore.getDictData('Pattern').find(item=>item.name=== modeStore.currentMode)?.id//获取数据字典中对应的id
|
||||
useDownload(exportPlan,'检测计划导出数据', {...proTable.value?.searchParam,patternId:patternId}, false,'.xlsx')
|
||||
})
|
||||
}
|
||||
|
||||
// 点击合并按钮
|
||||
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)
|
||||
let planType = 0; // 0主计划 1子计划 2修改子计划
|
||||
|
||||
if (modeStore.currentMode === '比对式') {
|
||||
if (titleType === 'add') {
|
||||
// 新增只能是主计划
|
||||
planType = 0;
|
||||
} else {
|
||||
// 编辑情况
|
||||
if (row.children?.length > 0) {
|
||||
// 有子计划 -> 主计划
|
||||
planType = 0;
|
||||
} else if (row.origin == null) {
|
||||
// 没有来源 -> 主计划
|
||||
planType = 0;
|
||||
} else {
|
||||
// 其他 -> 修改子计划
|
||||
planType = 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
planPopup.value?.open(titleType, row, modeStore.currentMode, planType);
|
||||
}
|
||||
|
||||
|
||||
// 批量删除设备
|
||||
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 showDeviceOpen = (row: Partial<Plan.ReqPlan> = {}) => {
|
||||
devTransferPopup.value.open(row)
|
||||
const openChildrenPlan = (row: Partial<Plan.ReqPlan> = {}) => {
|
||||
childrenPlanView.value.open("检测计划详情",row,patternId.value)
|
||||
}
|
||||
|
||||
const myDict = new Map<string, any[]>();
|
||||
|
||||
const statisticalAnalysisMore = async (ids: string[], rows: Plan.ReqPlan[]) => {
|
||||
const hasInvalidState = rows.some(row => row.testState != 2);
|
||||
@@ -428,39 +546,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>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<el-dialog v-model="dialogVisible" :title="dialogTitle"
|
||||
v-bind="dialogSmall" @close="close">
|
||||
v-bind="dialogSmall" @close="close" align-center>
|
||||
<div>
|
||||
<el-form :model="formContent" ref="dialogFormRef" :rules="rules">
|
||||
<el-form-item label="字典类型" :label-width="100">
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<el-dialog v-model='dialogVisible' :title='dialogTitle' v-bind="dialogBig" @close="close">
|
||||
<el-dialog v-model='dialogVisible' :title='dialogTitle' v-bind="dialogBig" @close="close" align-center>
|
||||
<el-form :model='formContent' ref='dialogFormRef' :rules='rules' label-width="auto" class="form-three">
|
||||
<el-divider>基础数据</el-divider>
|
||||
<el-form-item label='数据模型' prop='dataType'>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<el-dialog v-model='dialogVisible' :title='dialogTitle' v-bind='dialogSmall' @close="close">
|
||||
<el-dialog v-model='dialogVisible' :title='dialogTitle' v-bind='dialogSmall' @close="close" align-center>
|
||||
<el-form :model='formContent' ref='dialogFormRef' :rules='rules' >
|
||||
<el-form-item label='字典名称' :label-width='100' prop='name'>
|
||||
<el-input v-model='formContent.name' placeholder='请输入字典名称' autocomplete='off' maxlength="32" show-word-limit/>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<el-dialog v-model='dialogVisible' :title='dialogTitle' v-bind='dialogSmall' @close="close">
|
||||
<el-dialog v-model='dialogVisible' :title='dialogTitle' v-bind='dialogSmall' @close="close" align-center>
|
||||
<div>
|
||||
<el-form :model='formContent' ref='dialogFormRef' :rules='rules'>
|
||||
<el-form-item label='类型名称' :label-width='100' prop='name'>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<el-dialog :title="dialogTitle" v-model="dialogVisible" @close="close" v-bind="dialogSmall">
|
||||
<el-dialog :title="dialogTitle" v-model="dialogVisible" @close="close" v-bind="dialogSmall" align-center>
|
||||
<div>
|
||||
<el-form ref="dialogFormRef" :model="formContent" :rules="rules">
|
||||
<el-form-item label="名称" prop="name">
|
||||
|
||||
Reference in New Issue
Block a user