From 2730102450bc56ad742a902cb873126e26b529ab Mon Sep 17 00:00:00 2001 From: wangqiujuan0808 <578331299@qq.com> Date: Tue, 15 Oct 2024 15:18:03 +0800 Subject: [PATCH] =?UTF-8?q?=E7=82=B9=E4=BD=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/infoApi.js | 4 + src/components/AddData.vue | 2 +- src/components/AddMb.vue | 2 +- src/components/AddPoint.vue | 152 +++++++++++++++++++++-------------- src/components/ViewPoint.vue | 38 +++++---- src/views/Home.vue | 3 +- src/views/Level.vue | 3 +- 7 files changed, 119 insertions(+), 85 deletions(-) diff --git a/src/api/infoApi.js b/src/api/infoApi.js index 6e0667b..5d01ff2 100644 --- a/src/api/infoApi.js +++ b/src/api/infoApi.js @@ -88,6 +88,10 @@ const infoApi = { importP(params,template_name) { return postPBRequest('/template', params, 53212,template_name) }, + // 获取模板点位类型 + getPointType(params) { + return postPBRequest('/template', params, 53011) + }, // 点位导出 exportP(params) { diff --git a/src/components/AddData.vue b/src/components/AddData.vue index 1006c65..b4edd30 100644 --- a/src/components/AddData.vue +++ b/src/components/AddData.vue @@ -93,7 +93,7 @@ export default { template_name: [ { required: true, message: "请选择通讯模板", trigger: "blur" }, ], - driver_description: [{ required: true, message: "请输入驱动描述", trigger: "blur" }], + driver_description: [{ required: false, message: "请输入驱动描述", trigger: "blur" }], driver_type: [{ required: true, message: "请选择通讯驱动", trigger: "change" }] }, }); diff --git a/src/components/AddMb.vue b/src/components/AddMb.vue index 63ea785..4dca75d 100644 --- a/src/components/AddMb.vue +++ b/src/components/AddMb.vue @@ -49,7 +49,7 @@ export default { { required: true, validator: validName, trigger: "blur" }, ], template_description: [ - { required: true, message: "请输入模板描述", trigger: "blur" } + { required: false, message: "请输入模板描述", trigger: "blur" } ], template_type: [ { required: true, message: "请选择类型", trigger: "blur" } diff --git a/src/components/AddPoint.vue b/src/components/AddPoint.vue index f4d8001..2c399ea 100644 --- a/src/components/AddPoint.vue +++ b/src/components/AddPoint.vue @@ -7,22 +7,23 @@ - - - - - - + + + + + + - + - + @@ -45,7 +46,7 @@ import { onMounted, reactive, ref, toRefs, computed, nextTick } from "vue"; import infoApi from "@/api/infoApi.js"; import { ElMessage, ElMessageBox } from "element-plus"; export default { - props: ["formData", "dialogVisible", "pointData", "type"], + props: ["formData", "dialogVisible", "pointData", "type", "pointTypeOptions"], emits: ["dialogClose", "dialogSuccess"], setup(props, ctx) { const checkAddress = (rule, value, callback) => { @@ -68,54 +69,25 @@ export default { const state = reactive({ addForm: { }, - datatypeArr: [{ - label: 'bool', - value: 1 - }, { - label: 'int16', - value: 2 - }, { - label: 'int32', - value: 3 - }, { - label: 'int64', - value: 4 - }, - { - label: 'unit16', - value: 5 - }, { - label: 'unit32', - value: 6 - }, - { - label: 'unit64', - value: 7 - }, { - label: 'float32', - value: 8 - }, { - label: 'float64', - value: 9 - }], + datatypeArr: [], registerArr: [ - { - label: 'coil_status', - value: 1 - }, - { - label: 'input_status', - value: 2 - }, - { - label: 'input_register', - value: 3 - }, - { - label: 'holding_register', - value: 4 - }], - + { + label: 'coil_status', + value: 1 + }, + { + label: 'input_status', + value: 2 + }, + { + label: 'input_register', + value: 3 + }, + { + label: 'holding_register', + value: 4 + }], + byte_orderArr: [{ label: 'null', value: 1 @@ -165,7 +137,7 @@ export default { }], perOptions: [ { - label: '只读', + label: '可读', value: 1 }, { @@ -184,10 +156,10 @@ export default { point_type: [{ required: true, message: "请选择点位类型", trigger: "blur" }], register: [{ required: true, message: "请输入寄存器", trigger: "blur" }], multiplier: [{ required: true, message: "请输入缩放系数", trigger: "blur" }], - point_unit: [{ required: true, message: "请输入点位单位", trigger: "blur" }], + point_unit: [{ required: false, message: "请输入点位单位", trigger: "blur" }], point_permissions: [{ required: true, message: "请输入读写权限", trigger: "blur" }], point_description: [ - { required: true, message: "请输入点位描述", trigger: "blur" } + { required: false, message: "请输入点位描述", trigger: "blur" } ], }, }); @@ -196,8 +168,65 @@ export default { }); onMounted(() => { - state.addForm = props.pointData + state.addForm = props.pointData; + getPointData(); + changeRegister(); }); + + const getPointData = () => { + state.datatypeArr = []; + for (let i in props.pointTypeOptions) { + let obj = { + value: Number(i), + label: props.pointTypeOptions[i], + disabled: (Number(i) === 2 || Number(i) === 6 || Number(i) === 12) && (props.formData.template_type === 1) + } + state.datatypeArr.push(obj); + } + } + + const changeRegister = () => { + if(state.addForm.register === 1) { + state.datatypeArr.forEach(ele => { // 只能选择bool + ele.disabled1 = ele.value!== 1 + }) + state.perOptions.forEach(ele => {// 可读可写 + ele.disabled = false; + }) + state.addForm.point_type = 1; + state.addForm.point_permissions = 1; + } + if(state.addForm.register === 2) { + state.datatypeArr.forEach(ele => {// 只能选择bool + ele.disabled1 = ele.value!== 1 + }) + state.perOptions.forEach(ele => {// 只能可读 + ele.disabled = ele.value === 2; + }) + state.addForm.point_type = 1; + state.addForm.point_permissions = 1; + } + if(state.addForm.register === 3) { + state.datatypeArr.forEach(ele => {// 不支持bool + ele.disabled1 = ele.value === 1 + }) + state.perOptions.forEach(ele => {// 只能可读 + ele.disabled = ele.value === 2; + }) + state.addForm.point_type = 3; + state.addForm.point_permissions = 1; + } + if(state.addForm.register === 4) { + state.datatypeArr.forEach(ele => {// 不支持bool + ele.disabled1 = ele.value === 1 + }) + state.perOptions.forEach(ele => {// 可读可写 + ele.disabled = false; + }) + state.addForm.point_type = 3; + state.addForm.point_permissions = 1; + } + } const closeDialog = () => { ctx.emit("dialogClose"); }; @@ -230,7 +259,8 @@ export default { visible, closeDialog, saveP, - ruleFormRef + ruleFormRef, + changeRegister }; }, }; diff --git a/src/components/ViewPoint.vue b/src/components/ViewPoint.vue index c4278b1..e33898b 100644 --- a/src/components/ViewPoint.vue +++ b/src/components/ViewPoint.vue @@ -3,8 +3,6 @@ v-model="visible" title="点位管理"> 模板名称:{{ formData.template_name }} - 点位数量:{{ propertiesData.length }}
@@ -25,7 +23,7 @@ @@ -42,7 +40,7 @@ @@ -56,7 +54,7 @@ - { return props.dialogVisible; }); onMounted(() => { + getPointType(); getPointList(); }); + const getPointType = async () => { + const parm = {}; + const res = await infoApi.getPointType(parm); + + if (res.code == 0) { + state.pointTypeOptions = res.data; + } + } + const getPointList = async () => { const parm = { template_name: props.formData.template_name @@ -178,12 +176,12 @@ export default { state.type = 'I'; state.pointData = { point_name: '', - address: 36, + address: null, point_type: 1, point_permissions: 1, multiplier: 1, - point_unit: 'on', - register: 1 + point_unit: '', + register: 3 } } diff --git a/src/views/Home.vue b/src/views/Home.vue index 1735886..311de8f 100644 --- a/src/views/Home.vue +++ b/src/views/Home.vue @@ -47,7 +47,8 @@
网卡信息
-

网卡{{ item.name }}的使用情况

+

网卡A

+

网卡B

字节 diff --git a/src/views/Level.vue b/src/views/Level.vue index d02e259..a72cc74 100644 --- a/src/views/Level.vue +++ b/src/views/Level.vue @@ -10,7 +10,8 @@ size="large" >
-

{{ item.name || "网卡" }}

+

{{ "网卡A【最外侧网口】" }}

+

{{ "网卡B【靠近电源侧网口】" }}