diff --git a/src/api/infoApi.js b/src/api/infoApi.js
index 2547ffc..96adab6 100644
--- a/src/api/infoApi.js
+++ b/src/api/infoApi.js
@@ -55,29 +55,33 @@ const infoApi = {
// },
// 模板列表
getMb(params) {
- return postPBRequest('/template', params, 54000)
+ return postPBRequest('/template', params, 55000)
},
// 新增模板
addMb(params) {
- return postPBRequest('/template', params, 54100)
+ return postPBRequest('/template', params, 55100)
},
- // 编辑模板
+ // 更新模板
editMb(params) {
- return postPBRequest('/template', params, 54200)
+ return postPBRequest('/template', params, 55200)
},
// 删除模板
delMb(params) {
- return postPBRequest('/template', params, 54300)
+ return postPBRequest('/template', params, 55300)
},
// 新增点位
addP(params) {
- return postPBRequest('/tx/mb', params)
+ return postPBRequest('/template', params, 56100)
+ },
+ // 获取模板支持类型
+ getTemplateType(params) {
+ return postPBRequest('/template', params, 55001)
},
- // // 获取点位
- // getP(params) {
- // return postJsonRequest('/tx/mb/info', params)
- // },
+ // 获取点位
+ getP(params) {
+ return postPBRequest('/template', params, 56000)
+ },
// // 获取设备列表
// getSet(params) {
// return postJsonRequest('/tx/info', params)
diff --git a/src/components/AddMb.vue b/src/components/AddMb.vue
index e8e3fcc..dcec09d 100644
--- a/src/components/AddMb.vue
+++ b/src/components/AddMb.vue
@@ -9,7 +9,7 @@
-
+
@@ -28,7 +28,7 @@ import infoApi from "@/api/infoApi.js";
import { ElMessage, ElMessageBox } from "element-plus";
// import { mb_list, mb_info, response} from '../proto/data/pd'
export default {
- props: ["formData", "dialogVisible", "type"],
+ props: ["formData", "dialogVisible", "type", "templateData"],
emits: ["dialogClose", "dialogSuccess"],
setup(props, ctx) {
const ruleFormRef = ref(null);
@@ -45,17 +45,10 @@ export default {
{ required: true, message: "请选择类型", trigger: "blur" }
],
},
- typeOptions: [
- {
- key: 1,
- name: 'MODBUS'
- },
- {
- key: 2,
- name: 'PLC'
- }
- ]
+ typeOptions: []
});
+
+
const visible = computed(() => {
return props.dialogVisible;
});
@@ -64,8 +57,22 @@ export default {
});
onMounted(() => {
state.addForm = props.formData;
+ getTypeOptions();
});
+ const getTypeOptions = () => {
+ console.log(11,props.templateData)
+ state.typeOptions = [];
+ for (let i in props.templateData) {
+ let obj = {
+ key: Number(i),
+ name: props.templateData[i]
+ }
+ state.typeOptions.push(obj);
+ console.log(33,state.typeOptions);
+ }
+ }
+
const closeDialog = () => {
ctx.emit("dialogClose");
};
diff --git a/src/components/AddPoint.vue b/src/components/AddPoint.vue
index 65caf2f..65f707a 100644
--- a/src/components/AddPoint.vue
+++ b/src/components/AddPoint.vue
@@ -3,17 +3,17 @@
模板名称:{{ addForm.name }}
模板描述:{{ addForm.description }}
- 模板类型:{{ addForm.type == 1 ? 'MODBUS' : 'PLC' }}
+ 模板类型:{{ templateData[1] }}
保存
取消
-
+
-
+
-
+
-
+
-
-
+
+
@@ -78,7 +78,7 @@ import infoApi from "@/api/infoApi.js";
import { ElMessage, ElMessageBox } from "element-plus";
// import { m_point, m_properties, mb_info, response} from '../proto/data/pd'
export default {
- props: ["formData", "dialogVisible"],
+ props: ["formData", "dialogVisible","templateData"],
emits: ["dialogClose", "dialogSuccess"],
setup(props, ctx) {
const state = reactive({
@@ -106,7 +106,7 @@ export default {
label: 'float64',
value: 'float64'
}],
- byteorderArr: [{
+ byte_orderArr: [{
label: 'null',
value: 'null'
}, {
@@ -135,27 +135,23 @@ export default {
onMounted(() => {
state.addForm = props.formData;
- console.log(123, props.formData)
// 获取点位列表
getPointList();
});
const getPointList = async () => {
- const parm = mb_info.encode({
+ const parm = {
name: state.addForm.name
- }).finish();
- // 截取有效长度
- const parm_data = parm.slice(0, parm.length);
- const res = await infoApi.getP(parm_data);
- const ret = response.decode(new Uint8Array(res));
- if (ret.code == 0) {
- const propArr = mb_info.decode(ret.data).points;
+ }
+ const res = await infoApi.getP(parm);
+ if (res.code == 0) {
+ const propArr = res.data || [];
state.propertiesData = [];
propArr.forEach(v => {
state.propertiesData.push({
name: v.name,
address: v.properties[0].value,
- datatype: v.properties[1].value,
- byteorder: v.properties[2].value,
+ type: v.properties[1].value,
+ byte_order: v.properties[2].value,
multplier: v.properties[3].value,
unit: v.properties[4].value,
description: v.properties[5].value,
@@ -177,38 +173,16 @@ export default {
if (state.propertiesData.length < 1) {
return ElMessage.error("请添加一条点位");
}
- const newArr = [];
- state.propertiesData.forEach(item => {
- newArr.push(m_point.create({
- name: item.name,
- properties: [
- m_properties.create({
- name: 'address', value: item.address
- }),
- m_properties.create({
- name: 'datatype', value: item.datatype
- }),
- m_properties.create({
- name: 'byteorder', value: item.byteorder
- }),
- m_properties.create({
- name: 'multplier', value: item.multplier
- }),
- m_properties.create({
- name: 'unit', value: item.unit
- }),
- m_properties.create({
- name: 'description', value: item.description
- })
- ]
- }))
- })
- console.log(123, newArr)
+ // const newArr = [];
+ // state.propertiesData.forEach(item => {
+
+ // })
+ // console.log(123, newArr)
const param = {
name: state.addForm.name,
type: state.addForm.type,
description: state.addForm.description,
- points: newArr
+ points: state.propertiesData
}
const res = await infoApi.addP(param);
if (res.code == 0) {
@@ -224,8 +198,8 @@ export default {
let newRow = {
name: '',
address: '',
- datatype: 'bool',
- byteorder: 'null',
+ type: 'bool',
+ byte_order: 'null',
multplier: '',
unit: '',
description: ''
diff --git a/src/utils/axios.js b/src/utils/axios.js
index 54b5c9f..a7d7583 100644
--- a/src/utils/axios.js
+++ b/src/utils/axios.js
@@ -35,7 +35,7 @@ axios.interceptors.response.use(
}
const ret = res.data;
// token过期
- if (ret.code === 2003) {
+ if (ret.code === 3004) {
localRemove("token");
ElMessage.closeAll();
ElMessage.error(ret.message || "Token异常,请重新登录");
diff --git a/src/views/Model.vue b/src/views/Model.vue
index 687f1db..2edd2fc 100644
--- a/src/views/Model.vue
+++ b/src/views/Model.vue
@@ -10,7 +10,7 @@
- {{ scope.row.type === 1 ? 'MODBUS' : 'PLC' }}
+ {{ templateData[scope.row.type]}}
@@ -29,10 +29,10 @@
-
-
@@ -59,15 +59,28 @@ export default {
formData: {
name: '',
description: '',
- type: 'modbus'
+ type: '1'
},
formData1: {},
- type: 'I'
+ type: 'I',
+ templateData: {}
});
onMounted(() => {
+ getTemplateType();
getTableData();
});
+
+
+ const getTemplateType = async () => {
+ const res = await infoApi.getTemplateType();
+ if (res.code == 0) {
+ // 获取数据
+ state.templateData = res.data;
+ } else {
+ console.log(res);
+ }
+ }
const getTableData = async () => {
const res = await infoApi.getMb();
if (res.code == 0) {