mqtt新增站点、qos
This commit is contained in:
@ -149,9 +149,9 @@ export function importPointList(data) {
|
||||
|
||||
|
||||
//mqtt
|
||||
export function getMqttList({pageSize,pageNum,mqttTopic,topicName}) {
|
||||
export function getMqttList({pageSize,pageNum,mqttTopic,topicName,siteId}) {
|
||||
return request({
|
||||
url: `/ems/mqttConfig/list?pageSize=${pageSize}&pageNum=${pageNum}&mqttTopic=${mqttTopic}&topicName=${topicName}`,
|
||||
url: `/ems/mqttConfig/list?pageSize=${pageSize}&pageNum=${pageNum}&mqttTopic=${mqttTopic}&topicName=${topicName}&siteId=${siteId}`,
|
||||
method: 'get',
|
||||
})
|
||||
}
|
||||
@ -180,4 +180,4 @@ export function deleteMqtt(id) {
|
||||
url: `/ems/mqttConfig/${id}`,
|
||||
method: 'delete',
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,11 +1,23 @@
|
||||
<template>
|
||||
<el-dialog :visible.sync="dialogTableVisible" :close-on-press-escape="false" :close-on-click-modal="false" :show-close="false" destroy-on-close lock-scroll append-to-body width="400px" class="ems-dialog" :title="mode === 'add'?'新增配置':`编辑配置` " >
|
||||
<el-form v-loading="loading>0" ref="addTempForm" :model="formData" :rules="rules" size="medium" label-width="140px">
|
||||
<el-form-item label="订阅topic" prop="deviceName">
|
||||
<el-form-item label="站点" prop="siteId">
|
||||
<el-select v-model="formData.siteId" :disabled="mode === 'edit'" placeholder="请选择站点" :loading="searchLoading" loading-text="正在加载数据">
|
||||
<el-option v-for="(item,index) in siteList" :key="index+'zdxeSelect'" :label="item.siteName" :value="item.siteId" ></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="消息等级" prop="qos">
|
||||
<el-select v-model="formData.qos" placeholder="请选择消息等级">
|
||||
<el-option :value="1">1</el-option>
|
||||
<el-option :value="2">2</el-option>
|
||||
<el-option :value="3">3</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="订阅topic" prop="mqttTopic">
|
||||
<el-input v-model="formData.mqttTopic" placeholder="请输入" clearable :style="{width: '100%'}">
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="topic描述" prop="description">
|
||||
<el-form-item label="topic描述" prop="topicName">
|
||||
<el-input v-model="formData.topicName" type="textarea" placeholder="请输入" clearable :style="{width: '100%'}">
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
@ -18,18 +30,29 @@
|
||||
</template>
|
||||
<script>
|
||||
import {editMqtt,addMqtt,getMqttDetail} from "@/api/ems/site";
|
||||
import {getAllSites} from '@/api/ems/zddt'
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
loading:0,
|
||||
siteList:[],
|
||||
searchLoading:false,
|
||||
dialogTableVisible:false,
|
||||
mode:'',
|
||||
formData: {
|
||||
id:'',//设备唯一标识
|
||||
siteId:'',
|
||||
qos:'',
|
||||
topicName:'',
|
||||
mqttTopic:''
|
||||
},
|
||||
rules: {
|
||||
siteId:[
|
||||
{ required: true, message: '请选择站点', trigger: 'blur'},
|
||||
],
|
||||
qos:[
|
||||
{ required: true, message: '请选择消息等级', trigger: 'blur'},
|
||||
],
|
||||
mqttTopic:[
|
||||
{ required: true, message: '请输入订阅topic', trigger: 'blur'},
|
||||
],
|
||||
@ -42,6 +65,7 @@ export default {
|
||||
methods: {
|
||||
showDialog(id){
|
||||
this.dialogTableVisible = true
|
||||
this.getZdList()
|
||||
if(id){
|
||||
this.mode = 'edit'
|
||||
this.formData.id = id
|
||||
@ -49,12 +73,21 @@ export default {
|
||||
}else{
|
||||
this.mode = 'add'
|
||||
}
|
||||
},
|
||||
//获取站点列表
|
||||
getZdList(){
|
||||
this.searchLoading=true
|
||||
getAllSites().then(response => {
|
||||
this.siteList = response?.data || []
|
||||
}).finally(() => {this.searchLoading=false})
|
||||
},
|
||||
getDetail(id){
|
||||
getMqttDetail(id).then(response => {
|
||||
const {topicName='',mqttTopic=''} = JSON.parse(JSON.stringify(response?.data || {}));
|
||||
const {topicName='',mqttTopic='',qos='',siteId=''} = JSON.parse(JSON.stringify(response?.data || {}));
|
||||
this.formData.mqttTopic=mqttTopic;
|
||||
this.formData.topicName=topicName;
|
||||
this.formData.qos=qos;
|
||||
this.formData.siteId=siteId;
|
||||
})
|
||||
},
|
||||
saveDialog() {
|
||||
@ -63,11 +96,13 @@ export default {
|
||||
this.loading+=1
|
||||
const {
|
||||
id='',
|
||||
siteId='',
|
||||
qos='',
|
||||
mqttTopic='',//站点ID
|
||||
topicName='',//设备id
|
||||
}= this.formData;
|
||||
if(this.mode === 'add'){
|
||||
addMqtt( {mqttTopic,topicName}).then(response => {
|
||||
addMqtt( {mqttTopic,topicName,siteId,qos}).then(response => {
|
||||
if(response.code === 200){
|
||||
//新增成功
|
||||
// 关闭弹窗 更新表格
|
||||
@ -78,7 +113,7 @@ export default {
|
||||
this.loading-=1
|
||||
})
|
||||
}else{
|
||||
editMqtt({mqttTopic,topicName,id}).then(response => {
|
||||
editMqtt({mqttTopic,topicName,id,siteId,qos}).then(response => {
|
||||
if(response.code === 200){
|
||||
//新增成功
|
||||
// 关闭弹窗 更新表格
|
||||
|
||||
@ -1,6 +1,11 @@
|
||||
<template>
|
||||
<div class="ems-dashboard-editor-container" style="background-color: #ffffff" v-loading="loading">
|
||||
<el-form :inline="true" class="select-container">
|
||||
<el-form-item label="站点选择">
|
||||
<el-select v-model="form.siteId" placeholder="请选择换电站名称" :loading="searchLoading" loading-text="正在加载数据" clearable>
|
||||
<el-option :label="item.siteName" :value="item.siteId" v-for="(item,index) in siteList" :key="index+'zdxeSelect'"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="订阅topic">
|
||||
<el-input
|
||||
v-model="form.mqttTopic"
|
||||
@ -29,6 +34,14 @@
|
||||
max-height="600px"
|
||||
stripe
|
||||
style="width: 100%;margin-top: 25px">
|
||||
<el-table-column
|
||||
label="站点"
|
||||
prop="siteId">
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
label="消息等级"
|
||||
prop="qos">
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
label="订阅topic"
|
||||
prop="mqttTopic">
|
||||
@ -77,6 +90,7 @@
|
||||
|
||||
<script>
|
||||
import {deleteMqtt,getMqttList} from '@/api/ems/site'
|
||||
import {getAllSites} from '@/api/ems/zddt'
|
||||
import AddMqtt from './AddMqtt.vue'
|
||||
export default {
|
||||
name: "Mqtt",
|
||||
@ -85,9 +99,12 @@ export default {
|
||||
data() {
|
||||
return {
|
||||
form:{
|
||||
siteId:"",
|
||||
topicName:'',
|
||||
mqttTopic:''
|
||||
},
|
||||
siteList:[],
|
||||
searchLoading:false,
|
||||
loading:false,
|
||||
tableData:[],
|
||||
pageSize:10,//分页栏当前每个数据总数
|
||||
@ -116,17 +133,26 @@ export default {
|
||||
},
|
||||
onReset(){
|
||||
this.form={
|
||||
siteId:'',
|
||||
topicName:'',
|
||||
mqttTopic:''
|
||||
}
|
||||
this.pageNum =1//每次搜索从1开始搜索
|
||||
this.getData()
|
||||
},
|
||||
//获取站点列表
|
||||
getZdList(){
|
||||
this.searchLoading=true
|
||||
return getAllSites().then(response => {
|
||||
this.siteList = response?.data || []
|
||||
// if( this.siteList.length>0 ) this.siteId = this.siteList[0].siteId
|
||||
}).finally(() => {this.searchLoading=false})
|
||||
},
|
||||
getData(){
|
||||
this.loading=true;
|
||||
const {mqttTopic,topicName} = this.form;
|
||||
const {mqttTopic,topicName,siteId} = this.form;
|
||||
const {pageNum,pageSize} = this;
|
||||
getMqttList({pageNum,pageSize,mqttTopic,topicName}).then(response => {
|
||||
getMqttList({pageNum,pageSize,mqttTopic,topicName,siteId}).then(response => {
|
||||
this.tableData=response?.rows || [];
|
||||
this.totalSize = response?.total || 0
|
||||
}).finally(() => {this.loading=false})
|
||||
@ -168,6 +194,7 @@ export default {
|
||||
},
|
||||
mounted() {
|
||||
this.loading=true
|
||||
this.getZdList()
|
||||
this.getData()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user