main
parent
88bcff5741
commit
972993be58
|
@ -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)
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
</el-form-item>
|
||||
<el-form-item label="模板类型:" prop="type">
|
||||
|
||||
<el-select v-model="addForm.type" clearable placeholder="请选择模板类型" @change="driveChange" :disabled="type!=='I'">
|
||||
<el-select v-model="addForm.type" clearable placeholder="请选择模板类型" @change="driveChange" :disabled="type !== 'I'">
|
||||
<el-option v-for="(item, index) of typeOptions" :key="index" :label="item.name" :value="item.key" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
@ -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");
|
||||
};
|
||||
|
|
|
@ -3,17 +3,17 @@
|
|||
<el-card class="top-title">
|
||||
<span>模板名称:{{ addForm.name }}</span>
|
||||
<span>模板描述:{{ addForm.description }}</span>
|
||||
<span>模板类型:{{ addForm.type == 1 ? 'MODBUS' : 'PLC' }}</span>
|
||||
<span>模板类型:{{ templateData[1] }}</span>
|
||||
</el-card>
|
||||
<div class="btns">
|
||||
<div>
|
||||
<el-button type="primary" @click="saveP"> 保存 </el-button>
|
||||
<el-button @click="closeDialog">取消</el-button>
|
||||
</div>
|
||||
<div>
|
||||
<!-- <div>
|
||||
<el-button type="primary" @click="importData"> 导入 </el-button>
|
||||
<el-button type="primary" @click="exportData"> 导出 </el-button>
|
||||
</div>
|
||||
</div> -->
|
||||
</div>
|
||||
<div>
|
||||
<el-table :data="propertiesData" height="230" style="width: 100%" border stripe
|
||||
|
@ -28,18 +28,18 @@
|
|||
<el-input v-model="scope.row.address" clearable />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="datatype" label="点位类型" align="center" show-overflow-tooltip>
|
||||
<el-table-column prop="type" label="点位类型" align="center" show-overflow-tooltip>
|
||||
<template #default="scope">
|
||||
<el-select v-model="scope.row.datatype" size="mini">
|
||||
<el-select v-model="scope.row.type" size="mini">
|
||||
<el-option v-for="item in datatypeArr" :key="item.value" :label="item.label" :value="item.value" />
|
||||
</el-select>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column prop="byteorder" label="字节顺序" align="center" show-overflow-tooltip>
|
||||
<el-table-column prop="byte_order" label="字节顺序" align="center" show-overflow-tooltip>
|
||||
<template #default="scope">
|
||||
<el-select v-model="scope.row.byteorder" size="mini">
|
||||
<el-option v-for="item in byteorderArr" :key="item.value" :label="item.label" :value="item.value" />
|
||||
<el-select v-model="scope.row.byte_order" size="mini">
|
||||
<el-option v-for="item in byte_orderArr" :key="item.value" :label="item.label" :value="item.value" />
|
||||
</el-select>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
@ -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: ''
|
||||
|
|
|
@ -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异常,请重新登录");
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
<el-table-column prop="name" label="模板名称" width="240" align="center" show-overflow-tooltip />
|
||||
<el-table-column prop="type" label="模板类型" width="240" align="center" show-overflow-tooltip>
|
||||
<template #default="scope">
|
||||
<span>{{ scope.row.type === 1 ? 'MODBUS' : 'PLC' }}</span>
|
||||
<span>{{ templateData[scope.row.type]}}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="description" label="模板描述" width="600" align="center" show-overflow-tooltip />
|
||||
|
@ -29,10 +29,10 @@
|
|||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
<AddMb :type="type" :formData="formData" :dialogVisible="dialogVisible" v-if="dialogVisible"
|
||||
<AddMb :type="type" :formData="formData" :dialogVisible="dialogVisible" v-if="dialogVisible"
|
||||
@dialogClose="dialogClose" @dialogSuccess="dialogSuccess">
|
||||
</AddMb>
|
||||
<AddPoint :formData="formData1" :dialogVisible="dialogVisible1" v-if="dialogVisible1" @dialogClose="dialogClose"
|
||||
<AddPoint :formData="formData1" :templateData="templateData" :dialogVisible="dialogVisible1" v-if="dialogVisible1" @dialogClose="dialogClose"
|
||||
@dialogSuccess="dialogSuccess">
|
||||
</AddPoint>
|
||||
</el-card>
|
||||
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue