From dbddfcb547d3992d3f882145631eb5ad1ea7d145 Mon Sep 17 00:00:00 2001 From: wangqiujuan0808 <578331299@qq.com> Date: Wed, 23 Oct 2024 00:09:00 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=82=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/infoApi.js | 32 +---------------- src/components/PzSet.vue | 44 ++++++++++++------------ src/views/Data.vue | 13 +++++-- src/views/Model.vue | 10 +++--- src/views/Page.vue | 74 +++++++++++++++++----------------------- 5 files changed, 68 insertions(+), 105 deletions(-) diff --git a/src/api/infoApi.js b/src/api/infoApi.js index 5d01ff2..31b926d 100644 --- a/src/api/infoApi.js +++ b/src/api/infoApi.js @@ -17,36 +17,6 @@ const infoApi = { reboot() { return postPBRequest("/system", null, 57202); }, - // // 透传列表 - // getTc(params) { - // return getRequest('/tc', params) - // }, - // // 获取透传类型 - // getSupport(params) { - // return getRequest('/tc/support', params) - // }, - // // 获取可用串口列表 - // getFree(params) { - // return getRequest('/com/free', params) - // }, - - // // 获取所有串口列表api/com - // getCom(params) { - // return getRequest('/com', params) - // }, - - // saveTx(params) { - // return postJsonRequest("/tx", params); - // }, - - // // 透传服务启停 - // stopTc(params) { - // return putRequest("/tc", params); - // }, - // // 透传服务删除 - // delTc(params) { - // return deleteRequest("/tc", params); - // }, // 模板列表 getMb(params) { return postPBRequest('/template', params, 53000) @@ -170,7 +140,7 @@ const infoApi = { }, // 获取com getCom(params) { - return postPBRequest("/info", null, 51001, params.name); + return postPBRequest("/system", null, 57002, params.name); }, // 实时数据 // 获取驱动 diff --git a/src/components/PzSet.vue b/src/components/PzSet.vue index 293b2b0..62551f2 100644 --- a/src/components/PzSet.vue +++ b/src/components/PzSet.vue @@ -44,7 +44,7 @@
通用配置 - + 毫秒 @@ -283,7 +283,7 @@ export default { var header = { driver_name: props.formData.driver_name } - if (props.pztypecode === 2) { + if (props.pztypecode === 2) { //modbus_tcp await ruleFormRef.value.validate(async (valid) => { if (valid) { var param = { @@ -295,27 +295,17 @@ export default { } const res = await infoApi.addPz(param, header); if (res.code == 0) { - ElMessage.success(res.message || "请求成功"); + ElMessage.success(res.data || "请求成功"); ctx.emit("dialogClose"); } else { - ElMessage.error(res.message); + ElMessage.error(res.data); } } else { } }); - } else if (props.pztypecode === 1) { + } else if (props.pztypecode === 1) { // modbus_rtu await ruleFormRef2.value.validate(async (valid) => { if (valid) { - // var param = { - // polling_time:Number(state.form2.polling_time), - // faile_retry_time: Number(state.form2.faile_retry_time), - // dataBits: Number(state.form2.dataBits), - // baudRate: Number(state.form2.baudRate), - // stopBits: Number(state.form2.stopBits), - // driver_name: state.form2.driver_name, - // parity: state.form2.parity, - // id: Number(state.form2.id) - // } var param = { name: props.formData.name, polling_time: Number(state.form2.polling_time), @@ -330,10 +320,10 @@ export default { } const res = await infoApi.addPz(param, header); if (res.code == 0) { - ElMessage.success(res.message || "请求成功"); + ElMessage.success(res.data || "请求成功"); ctx.emit("dialogClose"); } else { - ElMessage.error(res.message); + ElMessage.error(res.data); } } else { } @@ -351,10 +341,10 @@ export default { } const res = await infoApi.addPz(param, header); if (res.code == 0) { - ElMessage.success(res.message || "请求成功"); + ElMessage.success(res.data || "请求成功"); ctx.emit("dialogClose"); } else { - ElMessage.error(res.message); + ElMessage.error(res.data); } } else { } @@ -368,7 +358,7 @@ export default { onMounted(() => { getD(); - // getCom(); + getCom(); }); const getD = async () => { const parm = { @@ -376,8 +366,17 @@ export default { } const res = await infoApi.getD(parm); if (res.code == 0) { - state.form = res.data; - console.log(state.form); + if (props.pztypecode === 2) { + state.form = res.data; + } + if (props.pztypecode === 1) { + state.form2 = res.data; + state.form2.com_name = res.data.com.name; + state.form2.dataBits = Number(res.data.com.dataBits); + state.form2.baudRate = Number(res.data.com.baudRate); + state.form2.stopBits = Number(res.data.com.stopBits); + state.form2.parity = res.data.com.parity; + } } }; const getCom = async () => { @@ -389,7 +388,6 @@ export default { state.comArr = res.data.sort((a, b) => { return (a.name > b.name ? 1 : -1) }); - state.form2.com_name = state.comArr[0].name; } }; const closeDialog = () => { diff --git a/src/views/Data.vue b/src/views/Data.vue index c71997c..9f53c4a 100644 --- a/src/views/Data.vue +++ b/src/views/Data.vue @@ -117,7 +117,7 @@