0.0.1 • Published 3 years ago
enniot-cloud-self v0.0.1
目录结构
── enniot-cloud-self
├── OwnPlatform.vue
├── README.md
├── OwnPlatform.json
└── package.json
Props
参数 | 说明 | 类型 | 可选值 | 默认值 |
---|---|---|---|---|
schema | 规定 form 格式的 json 文件 | json | — | — |
data | 用于将后台读取的数据填入 form 组件;以及获取 form 中数据,并将这些数据打包作为参数提交。 | object | — | — |
Data
参数 | 说明 | 类型 | 可选值 | 默认值 |
---|---|---|---|---|
status | 启用 | Boolean | true/false | — |
protocol | 通信协议 | string | HTTP/MQTT | — |
service_address | 服务器地址 | string | — | — |
service_port | 端口号 | string | — | — |
heart_interval | 心跳包间隔(秒) | int | — | — |
product_id | 产品编号 | string | — | — |
device_eui | 设备编号 | string | — | — |
username | 用户名 | string | — | — |
password | 密码 | string | — | — |
Usage
<template>
<el-row>
<!-- 自有平台设置界面-->
<el-tab-pane
label="自有平台设置"
name="self"
ref="selfTab"
v-loading="loading"
>
<OwnPlatform ref="selfPlatform" :data="this.selfForm" style="width: 60%"> </OwnPlatform>
<el-button
type="primary"
style="margin-left: 900px"
@click="onOwnSubmit()"
>
保存
</el-button>
</el-tab-pane>
</el-tabs>
</el-row>
</template>
<script>
import baseUrl from "@/service/api";
import IoTPlarform from '@/views/components/IoTPlatform/IoTPlatform.vue';
export default {
components: {
IoTPlatform,
},
data() {
return {
iotForm: {
type: 'IoT',
},
}
},
methods: {
// 自有平台查询
async onGetOwnForm() {
const api = `${baseUrl}/api/cloud/self`;
const res = await this.$api.get(api);
this.selfForm = res;
},
// 自有平台修改
async onOwnSubmit() {
const isValid = await this.$refs.selfPlatform.validate();
if (isValid) {
const api = `${baseUrl}/api/cloud/self`;
await this.$api.post(api, this.selfForm, {target: this.$refs.selfTab});
await this.onGetOwnForm();
}
},
}
0.0.1
3 years ago