0.0.7 • Published 3 years ago
enniot-serial-conf v0.0.7
目录结构
── enniot-serial-conf
├── interface_com.vue
├── README.md
├── com-model.json
└── package.json
Props
参数 | 说明 | 类型 | 可选值 | 默认值 |
---|---|---|---|---|
schema | 规定 form 格式的 json 文件 | json | — | — |
data | 用于将后台读取的数据填入 form 组件;以及获取 form 中数据,并将这些数据打包作为参数提交。 | object | — | — |
config | 用于根据传入参数控制 form 中组件的显示与隐藏 | object | { dynamicComType: false/true } | { dynamicComType: false } |
Fields
参数 | 说明 | 类型 | 可选值 | 默认值 |
---|---|---|---|---|
enabled | 是否启用 | boolean | true/false | — |
type | 类型 | string | 485/232 | — |
baud_rate | 波特率 | string | 1200B-230400B | 1200B |
factor_name | 因子名称 | string | — | — |
data_bit | 数据位 | int | 7-16 | 8 |
parity | 校验位 | string | None/Odd/Even | Even |
stop_bit | 停止位 | int | 1/2 | 8 |
data_type | 数据类型 | string | "int"/"float"/"byte"/"double" | "int" |
heart_interval | 帧间隔 | int | 100-1000 | — |
config 对象中的 dynamicComType,当 { dynamicComType : true } 时,data 中可以设置 type,而当 { dynamicComType : false } 时,data 中没有 type字段
Model
用法示例
<template>
<el-row>
<el-tabs
v-model="comActiveName"
:tab-position="apiTabPosition"
@tab-click="handleComClick"
>
<el-tab-pane
v-for="index in serial.length"
:key="index"
:label="'COM'+ index + '(' + serial[index-1].type + ')'"
:name="String(index-1)"
>
<COM
v-if="comType==='fourth'"
ref="COMData"
:data="comForm"
:config="{is_dynamic: serial[index-1].is_dynamic}"
style="width: 60%"
/>
<el-button
type="primary"
style="margin-left: 585px"
@click="onInterfaceSubmit(index-1)"
>
保存
</el-button>
</el-tab-pane>
</el-tabs>
</el-row>
</template>
<script>
import COM from 'enniot-serial-conf';
import deviceConf from '../../../../device-conf.js';
import axios from "axios";
export default {
data() {
const {lan, serial} = deviceConf;
return {
comForm: {},
}
},
methods: {
// 接口设置查询
async onGetCOMForm(id) {
const api = `${baseUrl}/api/serial/${id}`;
const res = await this.$api.get(api);
res.is_dynamic = res.is_dynamic || false;
res.type = this.serial[id].type;
this.comForm = res;
},
// 接口设置修改
async onInterfaceSubmit(id) {
const api = `${baseUrl}/api/serial/${id}`;
const res = await this.$api.post(api, this.$refs.COMData[id].data);
this.comForm = res;
},
}