fast(扫码录入): 添加扫码枪串口录入
This commit is contained in:
parent
6c6a3ba4e7
commit
d36ad16535
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "gateway-app",
|
||||
"version": "1.0.8",
|
||||
"version": "1.0.9",
|
||||
"description": "An Electron application with Vue",
|
||||
"main": "./out/main/index.js",
|
||||
"author": "example.com",
|
||||
|
@ -21,10 +21,11 @@
|
|||
"@electron-toolkit/preload": "^3.0.1",
|
||||
"@electron-toolkit/utils": "^3.0.0",
|
||||
"axios": "^1.7.2",
|
||||
"dayjs": "^1.11.11",
|
||||
"dayjs": "^1.11.13",
|
||||
"electron-updater": "^6.1.7",
|
||||
"element-plus": "^2.7.6",
|
||||
"file-saver": "^2.0.5",
|
||||
"gateway-app": "file:",
|
||||
"pinia": "^2.1.7",
|
||||
"vue-router": "^4.4.0",
|
||||
"xlsx": "^0.18.5"
|
||||
|
|
|
@ -12,7 +12,7 @@ const settings = defineProps({
|
|||
<el-menu-item index="/system/switch"> <span class="iconfont icon-icon_duanluqi"></span> 断路器调试</el-menu-item>
|
||||
<!-- <el-menu-item index="/system/videoplayer"><span class="iconfont icon-icon_jiankong"></span> 视频监控</el-menu-item>-->
|
||||
<el-menu-item index="/system/serialport"><span class="iconfont icon-chuankou2"></span> 设备参数读写</el-menu-item>
|
||||
<el-menu-item index="/system/devicestandard"><span class="iconfont icon-icon_chajian"></span> 空开标定</el-menu-item>
|
||||
<el-menu-item index="/system/devicestandard"><span class="iconfont icon-icon_chajian"></span> 断路器标定</el-menu-item>
|
||||
<el-menu-item index="/system/scancodewrite"><span class="iconfont icon-chuankou2"></span> 扫码录入</el-menu-item>
|
||||
<!-- <el-menu-item index="/gateway/southdirection"><span class="iconfont icon-icon_chajian"></span> 南向采集配置</el-menu-item>-->
|
||||
<!-- <el-menu-item index="/gateway/northboundtask"><span class="iconfont icon-icon_chajian"></span> 北向任务配置</el-menu-item>-->
|
||||
|
|
|
@ -2,6 +2,7 @@ import '@renderer/assets/main.css'
|
|||
|
||||
import { createPinia } from 'pinia'
|
||||
import { createApp } from 'vue'
|
||||
import dayjs from 'dayjs'
|
||||
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
|
||||
import ElementPlus from 'element-plus'
|
||||
import 'element-plus/dist/index.css'
|
||||
|
@ -10,6 +11,7 @@ import App from '@renderer/App.vue'
|
|||
import router from '@renderer/router'
|
||||
|
||||
const app = createApp(App)
|
||||
app.config.globalProperties.$dayjs = dayjs
|
||||
|
||||
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
|
||||
app.component(key, component)
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -440,6 +440,7 @@ const analysisData = (hexData, data) => {
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
const sendDeviceAttr = (data, type, index) => {
|
||||
if (!serialportForm.port) {
|
||||
ElMessage.error('请先打开串口');
|
||||
|
@ -486,10 +487,10 @@ const sendDeviceAttr = (data, type, index) => {
|
|||
// 成功响应后的处理
|
||||
console.log('串口请求', response); // 打印响应数据
|
||||
if (response.data.code === 0) {
|
||||
ElMessage.success('操作成功');
|
||||
if (type === 'output') {
|
||||
deviceAttrList.value[index].outputValue = analysisData(response.data.data.hex || '', data);
|
||||
}
|
||||
ElMessage.success('操作成功');
|
||||
if (type === 'output') {
|
||||
deviceAttrList.value[index].outputValue = analysisData(response.data.data.hex || '', data);
|
||||
}
|
||||
} else {
|
||||
ElMessage.error(response.data.message);
|
||||
}
|
||||
|
@ -553,27 +554,32 @@ const allReadDeviceAttr = () => {
|
|||
// 成功响应后的处理
|
||||
console.log('串口请求', response); // 打印响应数据
|
||||
if (response.data.code === 0) {
|
||||
ElMessage.success('操作成功');
|
||||
let hexValue = response.data.data.hex.substring(24, 392);
|
||||
let startValue = 0;
|
||||
deviceAttrList.value.forEach((item, index) => {
|
||||
if (startValue === 0) {
|
||||
startValue = item.startValue;
|
||||
}
|
||||
let value = hexValue.substring(startValue, item.lengthValue * 4 * 2 + startValue);
|
||||
startValue = startValue + item.lengthValue * 4 * 2;
|
||||
console.log('value', value);
|
||||
if (item.dataType === 'str') {
|
||||
deviceAttrList.value[index].outputValue = hexToString(value).trim();
|
||||
deviceAttrList.value[index].inputValue = hexToString(value).trim();
|
||||
} else if (item.dataType === 'hex') {
|
||||
deviceAttrList.value[index].outputValue = rearrangeHexStr(value);
|
||||
deviceAttrList.value[index].inputValue = rearrangeHexStr(value);
|
||||
} else {
|
||||
deviceAttrList.value[index].outputValue = value;
|
||||
deviceAttrList.value[index].inputValue = value;
|
||||
}
|
||||
});
|
||||
if (response.data.data.hex !== '') {
|
||||
ElMessage.success('操作成功');
|
||||
let hexValue = response.data.data.hex.substring(24, 392);
|
||||
let startValue = 0;
|
||||
deviceAttrList.value.forEach((item, index) => {
|
||||
if (startValue === 0) {
|
||||
startValue = item.startValue;
|
||||
}
|
||||
let value = hexValue.substring(startValue, item.lengthValue * 4 * 2 + startValue);
|
||||
startValue = startValue + item.lengthValue * 4 * 2;
|
||||
console.log('value', value);
|
||||
if (item.dataType === 'str') {
|
||||
deviceAttrList.value[index].outputValue = hexToString(value).trim();
|
||||
deviceAttrList.value[index].inputValue = hexToString(value).trim();
|
||||
} else if (item.dataType === 'hex') {
|
||||
deviceAttrList.value[index].outputValue = rearrangeHexStr(value);
|
||||
deviceAttrList.value[index].inputValue = rearrangeHexStr(value);
|
||||
} else {
|
||||
deviceAttrList.value[index].outputValue = value;
|
||||
deviceAttrList.value[index].inputValue = value;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
ElMessage.error('获取数据为空');
|
||||
}
|
||||
|
||||
// deviceAttrList.value[index].outputValue = analysisData(response.data.data.hex || '', data);
|
||||
} else {
|
||||
ElMessage.error(response.data.message);
|
||||
|
|
Loading…
Reference in New Issue