登陆网络配置

main
wangqiujuan0808 2024-04-14 21:34:35 +08:00
parent 2c5212574e
commit 70f2a79ad2
11 changed files with 259 additions and 301 deletions

View File

@ -1,142 +1,140 @@
// import {
// getRequest,
// postJsonRequest,
// deleteRequest,
// putRequest,
// } from "@/utils/axios";
// const infoApi = {
// //
// getSys(params) {
// return getRequest("/info", params);
// },
// //
// getNet(params) {
// return getRequest("/net", params);
// },
// saveNet(params) {
// return putRequest("/net", params);
// },
// reboot() {
// return postJsonRequest("/reboot",);
// },
// //
// getTc(params) {
// return getRequest('/tc', params)
// },
// //
// getSupport(params) {
// return getRequest('/tc/support', params)
// },
// //
// getFree(params) {
// return getRequest('/com/free', params)
// },
// //
// getTxSupport(params) {
// return getRequest('/tx/support', params)
// },
import {
postPBRequest
} from "@/utils/axios";
const infoApi = {
//
getSys() {
return postPBRequest("/info", null, 51000);
},
// //
getNet(params) {
return postPBRequest("/net", params, 52000);
},
saveNet(params) {
return postPBRequest("/net", params, 52200);
},
//
reboot() {
return postPBRequest("/user", null, 50003);
},
// //
// getTc(params) {
// return getRequest('/tc', params)
// },
// //
// getSupport(params) {
// return getRequest('/tc/support', params)
// },
// //
// getFree(params) {
// return getRequest('/com/free', params)
// },
//
getTxSupport() {
return postPBRequest('/driver', null,53001)
},
// // api/com
// getCom(params) {
// return getRequest('/com', params)
// },
// saveTx(params) {
// return postJsonRequest("/tx", params);
// },
// editTx(params) {
// return putRequest("/tx", params);
// },
// //
// stopTc(params) {
// return putRequest("/tc", params);
// },
// //
// delTc(params) {
// return deleteRequest("/tc", params);
// },
// //
// getMb(params) {
// return getRequest('/tx/mb/list', params)
// },
// //
// addMb(params) {
// return postJsonRequest('/tx/mb', params)
// },
// //
// editMb(params) {
// return putRequest('/tx/mb', params)
// },
// //
// delMb(params) {
// return deleteRequest('/tx/mb', params)
// },
// //
// addP(params) {
// return putRequest('/tx/mb', params)
// },
// //
// getP(params) {
// return postJsonRequest('/tx/mb/info', params)
// },
// //
// getSet(params) {
// return postJsonRequest('/tx/info', params)
// },
// //
// addSet(params) {
// return putRequest('/tx/device', params)
// },
// //
// getTx(params) {
// return getRequest('/tx/list', params)
// },
// //
// saveTx(params) {
// return postJsonRequest("/tx", params);
// },
// // ,
// changeStatus(params) {
// return postJsonRequest(`/tx/${params.url}/${params.name}`, params);
// },
// // api/com
// getCom(params) {
// return getRequest('/com', params)
// },
// //
// delTx(params) {
// return deleteRequest(`/tx`, params);
// },
// //
// getSc(params) {
// return getRequest('/sb/list', params)
// },
// //
// getQuDong(params) {
// return getRequest('/sb/support', params)
// },
// //
// saveTx(params) {
// return postJsonRequest("/sb", params);
// },
// //
// updateTx(params) {
// return putRequest('/sb', params);
// },
// //
// stopSc(params) {
// return putRequest("/sc", params);
// },
// //
// delSc(params) {
// return deleteRequest("/sb", params);
// },
// //
// getRules(params) {
// return getRequest('/rule', params);
// },
// //
// postRules(params) {
// return postJsonRequest('/rule', params)
// },
// };
// export default infoApi;
// saveTx(params) {
// return postJsonRequest("/tx", params);
// },
// editTx(params) {
// return putRequest("/tx", params);
// },
// //
// stopTc(params) {
// return putRequest("/tc", params);
// },
// //
// delTc(params) {
// return deleteRequest("/tc", params);
// },
// //
// getMb(params) {
// return getRequest('/tx/mb/list', params)
// },
// //
// addMb(params) {
// return postJsonRequest('/tx/mb', params)
// },
// //
// editMb(params) {
// return putRequest('/tx/mb', params)
// },
// //
// delMb(params) {
// return deleteRequest('/tx/mb', params)
// },
// //
// addP(params) {
// return putRequest('/tx/mb', params)
// },
// //
// getP(params) {
// return postJsonRequest('/tx/mb/info', params)
// },
// //
// getSet(params) {
// return postJsonRequest('/tx/info', params)
// },
// //
// addSet(params) {
// return putRequest('/tx/device', params)
// },
//
getTx(params) {
return postPBRequest('/driver', params, 53000)
},
// //
// saveTx(params) {
// return postJsonRequest("/tx", params);
// },
// // ,
// changeStatus(params) {
// return postJsonRequest(`/tx/${params.url}/${params.name}`, params);
// },
// //
// delTx(params) {
// return deleteRequest(`/tx`, params);
// },
// //
// getSc(params) {
// return getRequest('/sb/list', params)
// },
// //
// getQuDong(params) {
// return getRequest('/sb/support', params)
// },
// //
// saveTx(params) {
// return postJsonRequest("/sb", params);
// },
// //
// updateTx(params) {
// return putRequest('/sb', params);
// },
// //
// stopSc(params) {
// return putRequest("/sc", params);
// },
// //
// delSc(params) {
// return deleteRequest("/sb", params);
// },
// //
// getRules(params) {
// return getRequest('/rule', params);
// },
// //
// postRules(params) {
// return postJsonRequest('/rule', params)
// },
};
export default infoApi;

View File

@ -2,15 +2,21 @@ import {
postPBRequest,
} from '@/utils/axios';
const myApi = {
//
//
loginStatus() {
return postPBRequest('/login', null, 1000);
return postPBRequest('/user', null, 50000);
},
//
login(params = {}) {
return postPBRequest('/login', params, 1001);
return postPBRequest('/login', params, 50001);
},
// 退
logout() {
return postPBRequest('/login', null, 1002);
return postPBRequest('/user', null, 50002);
},
//
editPass(params = {}) {
return postPBRequest('/user', params, 90201);
}
}
export default myApi;

View File

@ -12,9 +12,9 @@
:rules="rules"
ref="ruleFormRef"
>
<el-form-item label="通讯名称:" prop="name">
<el-form-item label="通讯名称:" prop="index">
<el-input
v-model="formData.name"
v-model="formData.index"
placeholder="请输入驱动名称"
clearable
:disabled="type == '1'"
@ -37,9 +37,9 @@
/>
</el-select>
</el-form-item>
<el-form-item label="驱动描述:" prop="description">
<el-form-item label="驱动描述:" prop="Description">
<el-input
v-model="formData.description"
v-model="formData.Description"
placeholder="请输入描述"
clearable
></el-input>
@ -165,7 +165,7 @@
import { onMounted, reactive, ref, toRefs, computed, nextTick } from "vue";
import infoApi from "@/api/infoApi.js";
import { ElMessage, ElMessageBox } from "element-plus";
import { response, tx_list, com_info, com_list, tx_drive_list, tx_add, tx_info, tx_drive_config_modbusTCP } from '../proto/data/pd'
// import { response, tx_list, com_info, com_list, tx_drive_list, tx_add, tx_info, tx_drive_config_modbusTCP } from '../proto/data/pd'
export default {
props: ["formData", "dialogVisible", "type", "qudongOptions"],
emits: ["dialogClose", "dialogSuccess"],
@ -254,30 +254,30 @@ export default {
await ruleFormRef.value.validate(async (valid) => {
if (valid) {
let req_configbuf;
if (props.type==='0') {
if (props.type==='0') { //
if (props.formData.drive.serial) {
req_configbuf = com_info.encode(state.configData).finish();
req_configbuf = state.configData
} else {
if (props.formData.drive.name == "modbusTCP") {
req_configbuf = tx_drive_config_modbusTCP.encode(state.configData1).finish();
req_configbuf = state.configData1;
}
}
var obj = {
name: props.formData.name,
index: props.formData.index,
drive: props.formData.drive.name,
description: props.formData.description,
Description: props.formData.Description,
serial: props.formData.drive.serial,
config: req_configbuf.slice(0, req_configbuf.length),
config: req_configbuf,
};
console.log('编辑数据3', obj);
} else {
} else { //
console.log('编辑数据1', state.configData)
console.log('编辑数据2', state.configData1)
if (props.formData.serial) {
req_configbuf = com_info.encode(state.configData).finish();
req_configbuf = state.configData
} else {
if (props.formData.drive == "modbusTCP") {
req_configbuf = tx_drive_config_modbusTCP.encode(state.configData1).finish();
req_configbuf = state.configData1;
}
}
obj = {
@ -285,22 +285,18 @@ export default {
drive: props.formData.drive,
description: props.formData.description,
serial: props.formData.serial,
config: req_configbuf.slice(0, req_configbuf.length),
config: req_configbuf,
};
console.log('编辑数据3', obj);
}
const req_databuf = tx_add.encode(obj).finish();
//
const req_data = req_databuf.slice(0, req_databuf.length);
const res = props.type === '0' ? await infoApi.saveTx(req_data) : await infoApi.editTx(req_data);
const ret = response.decode(new Uint8Array(res));
if (ret.code == 0) {
ElMessage.success(res.msg || "请求成功");
const res = props.type === '0' ? await infoApi.saveTx(obj) : await infoApi.editTx(obj);
if (res.code == 0) {
ElMessage.success(res.message || "请求成功");
ctx.emit("dialogSuccess");
} else {
ElMessage.error(res.msg || "请求失败");
ElMessage.error(res.message || "请求失败");
}
} else {
console.log("error submit!");

View File

@ -105,7 +105,7 @@
import { onMounted, reactive, ref, toRefs, computed, nextTick } from "vue";
import infoApi from "@/api/infoApi.js";
import { ElMessage, ElMessageBox } from "element-plus";
import { mb_list, tx_info, response, m_device, m_properties, tx_add_device} from '../proto/data/pd'
// import { mb_list, tx_info, response, m_device, m_properties, tx_add_device} from '../proto/data/pd'
export default {
props: ["formData", "dialogVisible"],
emits: ["dialogClose", "dialogSuccess"],

View File

@ -1,40 +1,14 @@
<template>
<el-dialog
v-model="visible"
title="修改密码"
width="35%"
:before-close="closeDialog"
>
<el-form
label-position="top"
:model="formData"
label-width="150px"
:rules="rules"
ref="ruleFormRef"
>
<el-dialog v-model="visible" title="修改密码" width="35%" :before-close="closeDialog">
<el-form label-position="top" :model="formData" label-width="150px" :rules="rules" ref="ruleFormRef">
<el-form-item label="原密码:" prop="oldPass">
<el-input
type="password"
v-model="formData.oldPass"
placeholder="请输入原密码"
clearable
/>
<el-input type="password" v-model="formData.oldPass" placeholder="请输入原密码" clearable />
</el-form-item>
<el-form-item label="新密码:" prop="newPass">
<el-input
type="password"
v-model="formData.newPass"
placeholder="请输入新密码"
clearable
/>
<el-input type="password" v-model="formData.newPass" placeholder="请输入新密码" clearable />
</el-form-item>
<el-form-item label="确认密码:" prop="confirmPass">
<el-input
type="password"
v-model="formData.confirmPass"
placeholder="请再次输入新密码"
clearable
/>
<el-input type="password" v-model="formData.confirmPass" placeholder="请再次输入新密码" clearable />
</el-form-item>
</el-form>
<template #footer>
@ -103,7 +77,7 @@ export default {
return props.dialogVisible;
});
onMounted(() => {});
onMounted(() => { });
const closeDialog = () => {
ctx.emit("dialogClose");
@ -113,23 +87,18 @@ export default {
await ruleFormRef.value.validate(async (valid) => {
if (valid) {
//
const req_databuf = passwd.encode({
name: store.state.userInfo.nickName,
oldPassword: md5(state.formData.oldPass).toUpperCase(),
newPassword: md5(state.formData.newPass).toUpperCase(),
}).finish();
//
const req_data = req_databuf.slice(0, req_databuf.length);
const res = await myApi.editPass(req_data);
const ret = response.decode(new Uint8Array(res));
if (ret.code == 0) {
//
console.log(new TextDecoder().decode(ret.data));
ElMessage.success(new TextDecoder().decode(ret.data) || "请求成功");
const param = {
name: store.state.userInfo.nickName,
password: md5(state.formData.oldPass).toUpperCase(),
new_password: md5(state.formData.newPass).toUpperCase()
}
const res = await myApi.editPass(param);
if (res.code == 0) {
ElMessage.success(res.message|| "请求成功");
//
ctx.emit("dialogSuccess");
} else {
console.log(ret);
ElMessage.error(res.message );
}
} else {
console.log("error submit!");

View File

@ -46,10 +46,12 @@
<script>
import { onMounted, reactive, toRefs } from "vue";
import { useRouter } from "vue-router";
import { pathMap } from "@/utils";
import { pathMap,localRemove } from "@/utils";
import EditPass from "@/components/EditPass.vue";
import { useStore } from "vuex";
import myApi from "@/api/myApi.js";
import infoApi from "@/api/infoApi.js";
import { ElMessage } from "element-plus";
export default {
name: "Header",
components: {
@ -91,26 +93,21 @@ export default {
};
const reStart = async () => {
// const res = await infoApi.reboot();
// if (res.code == 0) {
// ElMessage.success(res.msg || "");
// } else {
// ElMessage.error(res.msg || "");
// }
const res = await infoApi.reboot();
if (res.code == 0) {
ElMessage.success(res.message || "请求成功");
} else {
ElMessage.error(res.message || "请求失败");
}
};
const logout = async () => {
const res = await myApi.logout();
console.log("666",res);
//
// const ret = response.decode(new Uint8Array(res));
// if (ret.code == 0) {
// //
// console.log(new TextDecoder().decode(ret.data));
// localRemove("token");
// window.location.reload();
// } else {
// console.log(ret);
// }
if (res.code == 0) {
localRemove("token");
window.location.reload();
} else {
console.log(res);
}
};
const editPass = () => {

View File

@ -33,25 +33,25 @@ axios.interceptors.response.use(
if (typeof (token) != "undefined") {
localSet("token", token);
}
const ret = response.decode(new Uint8Array(res.data));
const ret = res.data;
// token
if (ret.code === 2003) {
localRemove("token");
ElMessage.closeAll();
ElMessage.error(ret.msg + "[" + new TextDecoder().decode(res.data) + "]" || "Token异常,请重新登录");
ElMessage.error(ret.message || "Token异常,请重新登录");
router.push({
path: "/login"
});
return Promise.reject(ret);
}
return ret
}
return ret;
},
(error) => {
ElMessage.closeAll();
ElMessage.error(error);
router.push({
path: "/login"
});
// router.push({
// path: "/login"
// });
return Promise.reject(error);
}
);
@ -61,7 +61,6 @@ export function postPBRequest(url, params, actionNum) {
method: "post",
url: url,
data: params,
responseType: 'arraybuffer',
headers: {
"action": actionNum,
},

View File

@ -70,7 +70,7 @@
<script>
import { onMounted, reactive, ref, toRefs, nextTick } from "vue";
// import infoApi from "@/api/infoApi.js";
import infoApi from "@/api/infoApi.js";
import { ElMessage } from "element-plus";
import * as echarts from "echarts";
import { user, token, response, info } from '../proto/data/pd';
@ -92,29 +92,22 @@ export default {
getSys();
});
const getSys = async () => {
// const res = await infoApi.getSys();
// //
// const ret = response.decode(new Uint8Array(res));
// console.log(ret)
// if (ret.code == 0) {
// //
// state.deviceData = info.decode(ret.data);
// console.log(44, state.deviceData);
// nextTick(() => {
// drawEchart();
// });
// }
const res = await infoApi.getSys();
if (res.code == 0) {
state.deviceData = res.data;
console.log(44, state.deviceData);
nextTick(() => {
drawEchart();
});
}
};
const drawEchart = () => {
let dom = document.getElementById("echartDiv");
let data = {
name: "内存使用比",
usedPercent: state.deviceData.meminfo.usedPercent.toFixed(2),
used: state.deviceData.meminfo.usedPercent.toFixed(2),
usedPercent: state.deviceData.meminfo.used_percent.toFixed(2),
used: state.deviceData.meminfo.used_percent.toFixed(2),
total: 100,
};
getEchart(dom, data);
@ -122,8 +115,8 @@ export default {
let domItem = document.getElementById("echartDiv" + index);
let dataItem = {
name: ele.name.split("/")[2],
usedPercent: ele.usedPercent.toFixed(2),
used: ele.usedPercent.toFixed(2),
usedPercent: ele.used_percent.toFixed(2),
used: ele.used_percent.toFixed(2),
total: 100,
};
getEchart(domItem, dataItem);

View File

@ -102,7 +102,7 @@
import { onMounted, reactive, ref, toRefs } from "vue";
import infoApi from "@/api/infoApi.js";
import { ElMessage } from "element-plus";
import { user, response, token, info,passwd, net_info,ip_info } from '../proto/data/pd'
// import { user, response, token, info,passwd, net_info,ip_info } from '../proto/data/pd'
export default {
name: "level",
setup() {
@ -169,13 +169,12 @@ export default {
});
const getNet = async () => {
const res = await infoApi.getNet();
const ret = response.decode(new Uint8Array(res));
if (ret.code == 0) {
if (res.code == 0) {
//
state.formData = net_info.decode(ret.data);
state.formData = res.data;
console.log(666, state.formData.ip);
} else {
console.log(ret);
console.log(res);
}
};
@ -189,16 +188,12 @@ export default {
const saveData = () => {
ruleFormRef.value.validate(async (valid) => {
if (valid) {
const req_databuf = net_info.encode(state.formData).finish();
//
const req_data = req_databuf.slice(0, req_databuf.length);
const res = await infoApi.saveNet(req_data);
const ret = response.decode(new Uint8Array(res));
if (ret.code == 0) {
ElMessage.success(res.msg || "请求成功");
const res = await infoApi.saveNet(state.formData);
if (res.code == 0) {
ElMessage.success(res.message || "请求成功");
getNet();
} else {
ElMessage.error(res.msg);
ElMessage.error(res.message);
}
} else {
console.log("error submit!");

View File

@ -66,35 +66,42 @@ export default {
},
});
onMounted(() => {
localRemove("token");
localRemove("token");
});
const submitForm = async () => {
loginForm.value.validate(async (valid) => {
if (valid) {
// 1.
const userInfo = user.encode({
name: state.ruleForm.username,
const userInfo = {
username: state.ruleForm.username,
password: md5(state.ruleForm.password).toUpperCase(),
// timestamp: new Date().getTime()
}).finish()
// 2.
const send_userInfo = userInfo.slice(0, userInfo.length);
const res = await myApi.login(send_userInfo);
// console.log("===",res);
console.log("===",new TextDecoder().decode(res.data));
if (res.code == 0){
const res2 = await myApi.loginStatus();
console.log("===",new TextDecoder().decode(res2.data));
window.location.href = '/';
}
// 2.
// const send_userInfo = userInfo.slice(0, userInfo.length);
myApi.login(userInfo).then(async (res) => {
if (res.code == 0) {
getLoginStatus();
} else {
ElMessage.error(res.message);
}
})
} else {
console.log("error submit!!");
return false;
}
})
};
const getLoginStatus = async () => {
const res = await myApi.loginStatus();
if (res.code == 0) {
window.location.href = '/';
} else {
ElMessage.error(res.message);
}
}
const resetForm = () => {
loginForm.value.resetFields();
};

View File

@ -14,14 +14,14 @@
>
<el-table-column type="index" label="序号" width="80" align="center" />
<el-table-column
prop="name"
prop="index"
label="通讯名称"
width="200"
align="center"
show-overflow-tooltip
/>
<el-table-column
prop="description"
prop="Description"
label="通讯描述"
width="200"
align="center"
@ -118,7 +118,6 @@ import infoApi from "@/api/infoApi.js";
import { ElMessage, ElMessageBox } from "element-plus";
import AddData from "@/components/AddData.vue";
import AddSet from "@/components/AddSet.vue";
import { response, tx_list, com_info, com_list, tx_drive_list, tx_add, tx_drive_config_modbusTCP, tx_info } from '../proto/data/pd'
export default {
name: "page",
components: {
@ -141,22 +140,21 @@ export default {
});
//
const getTxSupport = async () => {
const res = await infoApi.getTxSupport();
const ret = response.decode(new Uint8Array(res));
console.log('通讯驱动', ret)
if (ret.code == 0) {
state.qudongOptions = tx_drive_list.decode(ret.data).txDrive;
console.log('通讯驱动', tx_drive_list.decode(ret.data).txDrive);
if (res.code == 0) {
state.qudongOptions = res.data;
}
};
const getTableData = async () => {
const res = await infoApi.getTx();
const ret = response.decode(new Uint8Array(res));
if (ret.code == 0) {
state.tableData = tx_list.decode(ret.data).tx;
console.log('保存成功后获取到的列表', tx_list.decode(ret.data).tx);
const param = {
type: 0
}
const res = await infoApi.getTx(param);
if (res.code == 0) {
state.tableData = res.data;
}
};
const dialogClose = () => {