From a57ebbcc62614b3dfd536b8092cf309a4ded1f48 Mon Sep 17 00:00:00 2001 From: sjl <1716605279@qq.com> Date: Mon, 18 Nov 2024 16:02:19 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8F=9C=E5=8D=95=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/api/device/interface/testScript.ts | 5 + .../src/api/system/dictionary/dictData.ts | 518 +++++++++--------- .../api/system/dictionary/dictTree/index.ts | 3 +- frontend/src/api/user/function/index.ts | 5 +- frontend/src/api/user/role/index.ts | 4 +- .../resource/components/resourcePopup.vue | 46 +- .../src/views/authority/resource/index.vue | 19 +- .../authority/user/components/userPopup.vue | 9 +- .../machine/device/components/devicePopup.vue | 16 +- frontend/src/views/machine/device/index.vue | 4 +- .../src/views/machine/testScript/index.vue | 11 +- .../dictData/components/dataPopup.vue | 2 +- .../system/dictionary/dictData/index.vue | 4 +- .../system/dictionary/dictTree/index.vue | 1 + 14 files changed, 355 insertions(+), 292 deletions(-) diff --git a/frontend/src/api/device/interface/testScript.ts b/frontend/src/api/device/interface/testScript.ts index e7920f6..14843bb 100644 --- a/frontend/src/api/device/interface/testScript.ts +++ b/frontend/src/api/device/interface/testScript.ts @@ -12,6 +12,11 @@ export namespace TestScript { valueType: string;//脚本值类型(字典表Code字段,相对值脚本、绝对值脚本、无) standardName: string;//参照标准名称 standardTime: string;//标准推行时间 + state:number;// + createBy: string; + createTime: string; + updateBy: string; + updateTime: string; } // 检测脚本+分页 diff --git a/frontend/src/api/system/dictionary/dictData.ts b/frontend/src/api/system/dictionary/dictData.ts index 893e3c3..18ac6c1 100644 --- a/frontend/src/api/system/dictionary/dictData.ts +++ b/frontend/src/api/system/dictionary/dictData.ts @@ -1,264 +1,264 @@ -// /** -// * 模拟字典静态数据,有后端接口后,需要删除 todo... -// */ -// /** -// * 模拟字典静态数据,有后端接口后,需要删除 todo... -// */ -// import type { Dict } from '@/api/interface' +/** + * 模拟字典静态数据,有后端接口后,需要删除 todo... + */ +/** + * 模拟字典静态数据,有后端接口后,需要删除 todo... + */ +import type { Dict } from '@/api/interface' -// const dictData: Dict[] = [ -// { -// id: "1", -// code: 'sex', -// label: '性别', -// children: [ -// { -// id: "1", -// label: '男', -// code: '1', -// }, -// { -// id: "2", -// label: '女', -// code: 2, -// }, -// { -// id: "3", -// label: '未知', -// code: 3, -// }, -// ], -// }, -// { -// id: "2", -// code: 'status', -// label: '状态', -// children: [ -// { -// id: "123456789", -// label: '启用', -// code: 1, -// }, -// { -// id: "987654321", -// label: '禁用', -// code: 0, -// }, -// ], -// }, -// { -// id: "3", -// code: 'resourceType', -// label: '资源类型', -// children: [ -// { -// id: "0", -// label: '菜单', -// code: 0, -// }, -// { -// id: "1", -// label: '按钮', -// code: 1, -// }, -// { -// id: "2", -// label: '公共资源', -// code: 2, -// }, -// { -// id: "3", -// label: '服务间调用资源', -// code: 3, -// }, -// ], -// }, -// { -// id: "4", -// code: 'roleType', -// label: '角色类型', -// children: [ -// { -// id: "0", -// label: '超级管理员', -// code: 0, -// }, -// { -// id: "1", -// label: '管理员', -// code: 1, -// }, -// { -// id: "2", -// label: '普通角色', -// code: 2, -// }, -// ], -// }, -// { -// id: "5", -// code: 'planTestState', -// label: '检测状态', -// children: [ -// { -// id: "0", -// label: '未检', -// code: '未检', -// }, -// { -// id: "1", -// label: '检测中', -// code: '检测中', -// }, -// { -// id: "2", -// label: '检测完成', -// code: '检测完成', -// }, -// ], -// }, -// { -// id: "6", -// code: 'errorLevel', -// label: '适用设备等级', -// children: [ -// { -// id: "0", -// label: 'A级', -// code: "A级", -// }, -// { -// id: "1", -// label: 'S级', -// code: 'S级', -// }, -// ], -// }, -// { -// id: "7", -// code: 'planReportState', -// label: '报告生成状态', -// children: [ -// { -// id: "0", -// label: '未生成', -// code: "未生成", -// }, -// { -// id: "1", -// label: '部分生成', -// code: '部分生成', -// }, -// { -// id: "2", -// label: '全部生成', -// code: '全部生成', -// }, -// ], -// }, -// { -// id: "8", -// code: 'planResult', -// label: '检测结果', -// children: [ -// { -// id: "0", -// label: '符合', -// code: "符合", -// }, -// { -// id: "1", -// label: '不符合', -// code: '不符合', -// }, -// ], -// }, +const dictData: Dict[] = [ + { + id: "1", + code: 'sex', + label: '性别', + children: [ + { + id: "1", + label: '男', + code: 1, + }, + { + id: "2", + label: '女', + code: 2, + }, + { + id: "3", + label: '未知', + code: 3, + }, + ], + }, + { + id: "2", + code: 'status', + label: '状态', + children: [ + { + id: "123456789", + label: '启用', + code: 1, + }, + { + id: "987654321", + label: '禁用', + code: 0, + }, + ], + }, + { + id: "3", + code: 'resourceType', + label: '资源类型', + children: [ + { + id: "0", + label: '菜单', + code: 0, + }, + { + id: "1", + label: '按钮', + code: 1, + }, + { + id: "2", + label: '公共资源', + code: 2, + }, + { + id: "3", + label: '服务间调用资源', + code: 3, + }, + ], + }, + { + id: "4", + code: 'roleType', + label: '角色类型', + children: [ + { + id: "0", + label: '超级管理员', + code: 0, + }, + { + id: "1", + label: '管理员', + code: 1, + }, + { + id: "2", + label: '普通角色', + code: 2, + }, + ], + }, + { + id: "5", + code: 'planTestState', + label: '检测状态', + children: [ + { + id: "0", + label: '未检', + code: '未检', + }, + { + id: "1", + label: '检测中', + code: '检测中', + }, + { + id: "2", + label: '检测完成', + code: '检测完成', + }, + ], + }, + { + id: "6", + code: 'errorLevel', + label: '适用设备等级', + children: [ + { + id: "0", + label: 'A级', + code: "A级", + }, + { + id: "1", + label: 'S级', + code: 'S级', + }, + ], + }, + { + id: "7", + code: 'planReportState', + label: '报告生成状态', + children: [ + { + id: "0", + label: '未生成', + code: "未生成", + }, + { + id: "1", + label: '部分生成', + code: '部分生成', + }, + { + id: "2", + label: '全部生成', + code: '全部生成', + }, + ], + }, + { + id: "8", + code: 'planResult', + label: '检测结果', + children: [ + { + id: "0", + label: '符合', + code: "符合", + }, + { + id: "1", + label: '不符合', + code: '不符合', + }, + ], + }, -// { -// id: "9", -// code: 'testScriptValueType', -// label: '检测脚本值类型', -// children: [ -// { -// id: "0", -// label: '相对值', -// code: 0, -// }, -// { -// id: "1", -// label: '绝对值', -// code: 1, -// }, -// ], -// }, -// { -// id: "10", -// code: 'testScriptType', -// label: '检测脚本模板类型', -// children: [ -// { -// id: "0", -// label: '脚本', -// code: 0, -// }, -// { -// id: "1", -// label: '模板', -// code: 1, -// }, -// ], -// }, -// { -// id: "11", -// code: 'testSourceDevType', -// label: '检测源设备类型', -// children: [ -// { -// id: "0", -// label: 'FLUKE6100A电能功率标准源', -// code: 0, -// }, -// { -// id: "1", -// label: 'ANGLI-FP2高性能数字信号源', -// code: 1, -// }, -// { -// id: "2", -// label: 'DKLN-1电能质量测试分析仪智能检定装置', -// code: 2, -// }, -// { -// id: "3", -// label: 'PQC600A高精度电能功率标准源', -// code: 3, -// }, -// { -// id: "4", -// label: 'PQV-520电能质量检测装置', -// code: 4, -// }, -// ], -// }, -// { -// id: "12", -// code: 'testSourceType', -// label: '检测源类型', -// children: [ -// { -// id: "0", -// label: '标准源', -// code: 0, -// }, -// { -// id: "1", -// label: '高精度设备', -// code: 1, -// }, -// ], -// }, -// ] + { + id: "9", + code: 'testScriptValueType', + label: '检测脚本值类型', + children: [ + { + id: "0", + label: '相对值', + code: 0, + }, + { + id: "1", + label: '绝对值', + code: 1, + }, + ], + }, + { + id: "10", + code: 'testScriptType', + label: '检测脚本模板类型', + children: [ + { + id: "0", + label: '脚本', + code: 0, + }, + { + id: "1", + label: '模板', + code: 1, + }, + ], + }, + { + id: "11", + code: 'testSourceDevType', + label: '检测源设备类型', + children: [ + { + id: "0", + label: 'FLUKE6100A电能功率标准源', + code: 0, + }, + { + id: "1", + label: 'ANGLI-FP2高性能数字信号源', + code: 1, + }, + { + id: "2", + label: 'DKLN-1电能质量测试分析仪智能检定装置', + code: 2, + }, + { + id: "3", + label: 'PQC600A高精度电能功率标准源', + code: 3, + }, + { + id: "4", + label: 'PQV-520电能质量检测装置', + code: 4, + }, + ], + }, + { + id: "12", + code: 'testSourceType', + label: '检测源类型', + children: [ + { + id: "0", + label: '标准源', + code: 0, + }, + { + id: "1", + label: '高精度设备', + code: 1, + }, + ], + }, +] -// export default dictData \ No newline at end of file +export default dictData \ No newline at end of file diff --git a/frontend/src/api/system/dictionary/dictTree/index.ts b/frontend/src/api/system/dictionary/dictTree/index.ts index efc5d00..1b593e4 100644 --- a/frontend/src/api/system/dictionary/dictTree/index.ts +++ b/frontend/src/api/system/dictionary/dictTree/index.ts @@ -3,7 +3,8 @@ import { type Dict } from '@/api/system/dictionary/interface' //获取字典类型 export const getDictTreeList = (params: Dict.ResDictTree) => { - return http.get(`/dictTree/queryTree`, params) + const name = params.name || ''; + return http.get(`/dictTree/getTree?keyword=${name}`, params) } //添加字典类型 diff --git a/frontend/src/api/user/function/index.ts b/frontend/src/api/user/function/index.ts index c9b83a3..2acc0af 100644 --- a/frontend/src/api/user/function/index.ts +++ b/frontend/src/api/user/function/index.ts @@ -4,8 +4,9 @@ import type { Function } from "@/api/user/interface/function"; // 获取资源 -export const getFunctionList = () => { - return http.get(`/sysFunction/functionTree`) +export const getFunctionList = (params:Function.ResFunction) => { + const name = params.name || ''; + return http.get(`/sysFunction/getTree?keyword=${name}`) } diff --git a/frontend/src/api/user/role/index.ts b/frontend/src/api/user/role/index.ts index 877e760..0d8a594 100644 --- a/frontend/src/api/user/role/index.ts +++ b/frontend/src/api/user/role/index.ts @@ -31,13 +31,13 @@ export const deleteRole = (params: { id: string[] }) => { // 获取资源 export const getFunctionList = () => { - return http.get(`/sysFunction/functionTree`) + return http.get(`/sysFunction/getTree?keyword=`) } //获取角色id绑定的菜单 export const getRoleFunction = (params:Role.RoleBO) => { - return http.post(`/sysRole/getFunctionsByRoleId?id=${params.id}`) + return http.post(`/sysFunction/getFunctionsByRoleId?id=${params.id}`) } //角色分配菜单 diff --git a/frontend/src/views/authority/resource/components/resourcePopup.vue b/frontend/src/views/authority/resource/components/resourcePopup.vue index 886184d..8d142e6 100644 --- a/frontend/src/views/authority/resource/components/resourcePopup.vue +++ b/frontend/src/views/authority/resource/components/resourcePopup.vue @@ -3,11 +3,13 @@ @@ -20,7 +22,7 @@ @@ -37,8 +39,8 @@ - - + @@ -67,8 +69,9 @@ const defaultProps = { children: 'children', label: 'name', + value: 'id' }; - + const functionList = ref([]) const dictStore = useDictStore() // 定义弹出组件元信息 const dialogFormRef = ref() @@ -91,7 +94,7 @@ }) return { dialogVisible, titleType, formContent } } - + const { dialogVisible, titleType, formContent } = useMetaInfo() // 清空formContent const resetFormContent = () => { @@ -136,12 +139,29 @@ const close = () => { dialogFormRef.value?.resetFields() } + +// 计算属性,用于控制显示的 pid +const displayPid = computed({ + get: () => { + return formContent.value.pid === '0' ? '' : formContent.value.pid; + }, + set: (value) => { + formContent.value.pid = value; + } +}); + + // 保存数据 const save = () => { try { - console.log(formContent.value) dialogFormRef.value?.validate(async (valid: boolean) => { - + console.log(formContent.value) + if (formContent.value.pid === undefined || formContent.value.pid === null || formContent.value.pid === '') { + formContent.value.pid = '0'; + } + if (formContent.value.pids === undefined || formContent.value.pids === null || formContent.value.pids === '') { + formContent.value.pids = '0'; + } if (valid) { if (formContent.value.id) { await updateFunction(formContent.value); @@ -152,20 +172,26 @@ const close = () => { close() // 刷新表格 await props.refreshTable!() + } }) } catch (err) { - //console.error('验证过程中出现错误', err) + console.error('验证过程中出现错误', err) } } - const functionList = ref([]) + // 打开弹窗,可能是新增,也可能是编辑 const open = async (sign: string, data: Function.ResFunction) => { const response = await getFunctionListNoButton() functionList.value = response.data as unknown as Function.ResFunction[] titleType.value = sign dialogVisible.value = true + + if (formContent.value.pid ==='0') { + formContent.value.pid = ''; + } + if (data.id) { formContent.value = { ...data } } else { diff --git a/frontend/src/views/authority/resource/index.vue b/frontend/src/views/authority/resource/index.vue index 177602e..0fe1e6d 100644 --- a/frontend/src/views/authority/resource/index.vue +++ b/frontend/src/views/authority/resource/index.vue @@ -28,11 +28,12 @@ import { useHandleData } from '@/hooks/useHandleData' import type { Function } from "@/api/user/interface/function" import ProTable from '@/components/ProTable/index.vue' - import {CirclePlus, Delete, EditPen,HomeFilled} from '@element-plus/icons-vue' + import {Back, CirclePlus, Delete, EditPen,HomeFilled} from '@element-plus/icons-vue' import type { ColumnProps, ProTableInstance } from '@/components/ProTable/interface' import { useDictStore } from '@/stores/modules/dict' import ResourcePopup from './components/resourcePopup.vue' import {deleteFunction,getFunctionList} from '@/api/user/function/index' + import * as Icons from '@element-plus/icons-vue' const dictStore = useDictStore() const resourcePopup = ref() // ProTable 实例 @@ -45,6 +46,8 @@ prop: 'name', label: '名称', minWidth: 150, + align:'left', + headerAlign: 'center', search: { el: 'input' }, }, { @@ -73,7 +76,18 @@ prop: 'icon', label: '图标', minWidth: 100, - + render: scope => { + const customIcons: { [key: string]: any } = Icons + const iconKey = scope.row.icon; // + if (!iconKey || !customIcons[iconKey]) { + // 如果 iconKey 为空或未定义,或者 customIcons 中找不到对应的图标,返回一个空的 标签 + return ; + } + const icon = customIcons[iconKey]; // 如果找不到图标,使用默认图标 + return ( + + ); + }, }, { prop: 'path', @@ -97,6 +111,7 @@ minWidth: 70, render: scope => { return ( + {scope.row.state ? '正常' : '禁用'} ) }, diff --git a/frontend/src/views/authority/user/components/userPopup.vue b/frontend/src/views/authority/user/components/userPopup.vue index e7f4451..808675f 100644 --- a/frontend/src/views/authority/user/components/userPopup.vue +++ b/frontend/src/views/authority/user/components/userPopup.vue @@ -9,8 +9,8 @@ - - + + @@ -64,6 +64,7 @@ const dialogFormRef = ref() const IsPasswordShow = ref(false) const roleList = ref([]) + const LoginNameIsShow = ref(false) function useMetaInfo() { const dialogVisible = ref(false) const titleType = ref('add') @@ -112,7 +113,7 @@ // 指定正则,此处是数字正则 { pattern: /^[A-Za-z\u4e00-\u9fa5]{1,16}$/, message: '名称需1~16位的英文或汉字', trigger: 'blur' }], loginName: [{ required: true, message: '登录名必填!', trigger: 'blur' }, - { pattern: /^[a-zA-Z_.]{1}[a-zA-Z0-9_.]{2,15}$/, message: '登录名需2-15位的字母数字符号', trigger: 'blur' }], + { pattern: /^[a-zA-Z]{1}[a-zA-Z0-9]{2,15}$/, message: '格式错误,需以字母开头,长度为3-16位的字母或数字', trigger: 'blur' }], password: [{ required: true, message: '密码必填!', trigger: 'blur' }, { pattern: /^(?=.*[!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?]).{8,16}$/, message: '密码长度为8-16,需包含特殊字符', trigger: 'blur' }], }) @@ -156,9 +157,11 @@ dialogVisible.value = true if (data.id) { IsPasswordShow.value = false + LoginNameIsShow.value = true formContent.value = { ...data } } else { IsPasswordShow.value = true + LoginNameIsShow.value = false resetFormContent() } } diff --git a/frontend/src/views/machine/device/components/devicePopup.vue b/frontend/src/views/machine/device/components/devicePopup.vue index 6854f26..0a101f4 100644 --- a/frontend/src/views/machine/device/components/devicePopup.vue +++ b/frontend/src/views/machine/device/components/devicePopup.vue @@ -25,7 +25,14 @@ - + + + @@ -382,12 +389,17 @@ const disabledDate = (time: Date) => { } } + + + + // 打开弹窗,可能是新增,也可能是编辑 const open = (sign: string, data: Device.ResPqDev) => { titleType.value = sign dialogVisible.value = true - if(data.pattern ==='比对式'){ + const patternItem = dictStore.getDictData('Pattern').find(item => item.id === data.pattern) + if( patternItem && patternItem.name ==='比对式'){ DevIsShow.value = false MonIsShow.value = true }else{ diff --git a/frontend/src/views/machine/device/index.vue b/frontend/src/views/machine/device/index.vue index 7d6f708..097d3ae 100644 --- a/frontend/src/views/machine/device/index.vue +++ b/frontend/src/views/machine/device/index.vue @@ -41,7 +41,7 @@ import { CirclePlus, Delete, EditPen, Download, Upload } from '@element-plus/ico import { useDictStore } from '@/stores/modules/dict' import { getPqDevList, deletePqDev, exportPqDev, downloadTemplate, importPqDev } from '@/api/device/device/index.ts' import { ElMessageBox } from 'element-plus' -import { reactive, ref } from 'vue' +import { computed, reactive, ref } from 'vue' const dictStore = useDictStore() // ProTable 实例 @@ -134,6 +134,8 @@ const openDialog = (titleType: string, row: Partial = {}) => { devicePopup.value?.open(titleType, row) } + + // 批量删除设备 const batchDelete = async (id: string[]) => { await useHandleData(deletePqDev, id, '删除所选设备') diff --git a/frontend/src/views/machine/testScript/index.vue b/frontend/src/views/machine/testScript/index.vue index 876841f..07d049a 100644 --- a/frontend/src/views/machine/testScript/index.vue +++ b/frontend/src/views/machine/testScript/index.vue @@ -29,24 +29,21 @@