mirror of
https://gitee.com/beecue/fastbee.git
synced 2025-12-19 01:15:54 +08:00
更新
This commit is contained in:
19
vue/src/views/iot/business/index.vue
Normal file
19
vue/src/views/iot/business/index.vue
Normal file
@@ -0,0 +1,19 @@
|
||||
<template>
|
||||
<div style="padding-left:20px;">
|
||||
<el-row :gutter="10">
|
||||
<el-col :span="14">
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-tag type="danger" style="margin-left:15px;">开源版本不支持该功能,请前往购买商业版本</el-tag>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped lang="scss">
|
||||
|
||||
</style>
|
||||
<script>
|
||||
</script>
|
||||
@@ -1,67 +1,78 @@
|
||||
<template>
|
||||
<div style="padding:6px;">
|
||||
<el-card v-show="showSearch" style="margin-bottom:5px;">
|
||||
<el-form :model="queryParams" ref="queryForm" :inline="true" label-width="68px" style="margin-bottom:-20px;">
|
||||
<el-form-item label="分类名称" prop="categoryName">
|
||||
<el-input v-model="queryParams.categoryName" placeholder="请输入产品分类名称" clearable size="small" @keyup.enter.native="handleQuery" />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
||||
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
||||
</el-form-item>
|
||||
<el-form-item style="float:right;">
|
||||
<el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd" v-hasPermi="['iot:category:add']">新增</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-card>
|
||||
|
||||
<el-card style="padding-bottom:100px;">
|
||||
<el-table v-loading="loading" :data="categoryList" @selection-change="handleSelectionChange" border>
|
||||
<el-table-column label="产品分类名称" align="center" prop="categoryName" />
|
||||
<el-table-column label="备注" align="left" prop="remark" min-width="150" />
|
||||
<el-table-column label="系统定义" align="center" prop="isSys">
|
||||
<template slot-scope="scope">
|
||||
<dict-tag :options="dict.type.iot_yes_no" :value="scope.row.isSys" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="显示顺序" align="center" prop="orderNum" />
|
||||
<el-table-column label="创建时间" align="center" prop="createTime" width="180">
|
||||
<template slot-scope="scope">
|
||||
<span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="150">
|
||||
<template slot-scope="scope">
|
||||
<el-button size="small" type="primary" style="padding:5px;" icon="el-icon-edit" @click="handleUpdate(scope.row)" v-hasPermi="['iot:category:edit']" v-if="scope.row.isSys == '0'? true:!isTenant">修改</el-button>
|
||||
<el-button size="small" type="danger" style="padding:5px;" icon="el-icon-delete" @click="handleDelete(scope.row)" v-hasPermi="['iot:category:remove']" v-if="scope.row.isSys == '0'? true:!isTenant">删除</el-button>
|
||||
<span style="font-size:10px;color:#999;" v-if="scope.row.isSys == '1' && isTenant">系统定义,不能修改</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />
|
||||
|
||||
<!-- 添加或修改产品分类对话框 -->
|
||||
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
|
||||
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
||||
<div style="padding:6px;">
|
||||
<el-card v-show="showSearch" style="margin-bottom:5px;">
|
||||
<el-form :model="queryParams" ref="queryForm" :inline="true" label-width="68px" style="margin-bottom:-20px;">
|
||||
<el-form-item label="分类名称" prop="categoryName">
|
||||
<el-input v-model="form.categoryName" placeholder="请输入产品分类名称" />
|
||||
<el-input v-model="queryParams.categoryName" placeholder="请输入产品分类名称" clearable size="small"
|
||||
@keyup.enter.native="handleQuery" />
|
||||
</el-form-item>
|
||||
<el-form-item label="显示顺序" prop="orderNum">
|
||||
<el-input v-model="form.orderNum" type="number" placeholder="请输入显示顺序" />
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
||||
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
||||
</el-form-item>
|
||||
<el-form-item label="备注" prop="remark">
|
||||
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
|
||||
<el-form-item style="float:right;">
|
||||
<el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
|
||||
v-hasPermi="['iot:category:add']">新增</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button type="primary" @click="submitForm" >确 定</el-button>
|
||||
<el-button @click="cancel">取 消</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</el-card>
|
||||
|
||||
</el-card>
|
||||
</div>
|
||||
<el-card style="padding-bottom:100px;">
|
||||
<el-table v-loading="loading" :data="categoryList" @selection-change="handleSelectionChange" border>
|
||||
<el-table-column label="产品分类名称" align="center" prop="categoryName" />
|
||||
<el-table-column label="备注" align="left" header-align="center" prop="remark" min-width="150" />
|
||||
<el-table-column label="系统定义" align="center" prop="isSys">
|
||||
<template slot-scope="scope">
|
||||
<dict-tag :options="dict.type.iot_yes_no" :value="scope.row.isSys" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="显示顺序" align="center" prop="orderNum" />
|
||||
<el-table-column label="创建时间" align="center" prop="createTime" width="180">
|
||||
<template slot-scope="scope">
|
||||
<span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="150">
|
||||
<template slot-scope="scope">
|
||||
<el-button size="small" type="primary" style="padding:5px;" icon="el-icon-edit"
|
||||
@click="handleUpdate(scope.row)" v-hasPermi="['iot:category:query']"
|
||||
v-if="scope.row.isSys == '0' ? true : !isTenant">修改</el-button>
|
||||
<el-button size="small" type="danger" style="padding:5px;" icon="el-icon-delete"
|
||||
@click="handleDelete(scope.row)" v-hasPermi="['iot:category:remove']"
|
||||
v-if="scope.row.isSys == '0' ? true : !isTenant">删除</el-button>
|
||||
<span style="font-size:10px;color:#999;" v-if="scope.row.isSys == '1' && isTenant">系统定义,不能修改</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum"
|
||||
:limit.sync="queryParams.pageSize" @pagination="getList" />
|
||||
|
||||
<!-- 添加或修改产品分类对话框 -->
|
||||
<el-dialog title="产品分类" :visible.sync="open" width="500px" append-to-body>
|
||||
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
||||
<el-form-item label="分类名称" prop="categoryName">
|
||||
<el-input v-model="form.categoryName" placeholder="请输入产品分类名称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="显示顺序" prop="orderNum">
|
||||
<el-input-number controls-position="right" v-model="form.orderNum"
|
||||
placeholder="请输入显示顺序" style="width:100%" />
|
||||
</el-form-item>
|
||||
<el-form-item label="备注" prop="remark">
|
||||
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button type="primary" @click="submitForm" v-hasPermi="['iot:category:edit']"
|
||||
v-show="form.categoryId">修 改</el-button>
|
||||
<el-button type="primary" @click="submitForm" v-hasPermi="['iot:category:add']"
|
||||
v-show="!form.categoryId">新 增</el-button>
|
||||
<el-button @click="cancel">取 消</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
|
||||
</el-card>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
@@ -113,6 +124,29 @@ export default {
|
||||
required: true,
|
||||
message: "产品分类名称不能为空",
|
||||
trigger: "blur"
|
||||
}, {
|
||||
min: 1,
|
||||
max: 64,
|
||||
message: '产品分类不能少于1个字符和超过64字符',
|
||||
},
|
||||
],
|
||||
orderNum: [{
|
||||
required: true,
|
||||
message: '分类顺序不能为空',
|
||||
trigger: 'blur',
|
||||
}, {
|
||||
type: 'number',
|
||||
min: -2147483648,
|
||||
max: 2147483647,
|
||||
message: '顺序值不能超过int型的取值范围(-2^31——2^31-1)',
|
||||
trigger: 'blur',
|
||||
}],
|
||||
remark: [{
|
||||
required: false,
|
||||
min: 0,
|
||||
max: 500,
|
||||
message: '备注不能输入超过500个字符',
|
||||
trigger: 'blur',
|
||||
}],
|
||||
isSys: [{
|
||||
required: true,
|
||||
@@ -155,7 +189,7 @@ export default {
|
||||
tenantName: null,
|
||||
isSys: null,
|
||||
parentId: null,
|
||||
orderNum: null,
|
||||
orderNum: 0,
|
||||
delFlag: null,
|
||||
createBy: null,
|
||||
createTime: null,
|
||||
@@ -228,7 +262,7 @@ export default {
|
||||
}).then(() => {
|
||||
this.getList();
|
||||
this.$modal.msgSuccess(msg);
|
||||
}).catch(() => {});
|
||||
}).catch(() => { });
|
||||
},
|
||||
/** 导出按钮操作 */
|
||||
handleExport() {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
222
vue/src/views/iot/device/device-functionlog.vue
Normal file
222
vue/src/views/iot/device/device-functionlog.vue
Normal file
@@ -0,0 +1,222 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
|
||||
<el-form-item label="请选择设备从机:" label-width="120px" v-if="isSubDev">
|
||||
<el-select v-model="queryParams.slaveId" placeholder="请选择设备从机" @change="selectSlave">
|
||||
<el-option v-for="slave in slaveList" :key="slave.slaveId" :label="`${slave.deviceName} (从机地址:${slave.slaveId})`" :value="slave.slaveId"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="日志类型" prop="funType">
|
||||
<el-select v-model="queryParams.funType" placeholder="请选择类型" clearable size="small">
|
||||
<el-option v-for="dict in dict.type.iot_function_type" :key="dict.value" :label="dict.label" :value="dict.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="标识符" prop="identify">
|
||||
<el-input v-model="queryParams.identify" placeholder="请输入标识符" clearable size="small" @keyup.enter.native="handleQuery" />
|
||||
</el-form-item>
|
||||
<el-form-item label="时间范围">
|
||||
<el-date-picker v-model="daterangeTime" size="small" style="width: 240px" value-format="yyyy-MM-dd" type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期"></el-date-picker>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
||||
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<el-table v-loading="loading" :data="logList" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column :label="showName" align="center" prop="identify" />
|
||||
<el-table-column label="指令类型" align="center" prop="funType" width="120px">
|
||||
<template slot-scope="scope">
|
||||
<dict-tag :options="dict.type.iot_function_type" :value="scope.row.funType" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="设置值" align="center" prop="funValue" />
|
||||
<el-table-column label="设备编号" align="center" prop="serialNumber" />
|
||||
<el-table-column label="下发时间" align="center" prop="createTime" />
|
||||
<el-table-column label="下发结果描述" align="center" prop="resultMsg" />
|
||||
<el-table-column label="操作" align="center" width="80">
|
||||
<template slot-scope="scope">
|
||||
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)" v-hasPermi="['iot:device:remove']">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { listLog, delLog } from '@/api/iot/functionLog';
|
||||
|
||||
export default {
|
||||
name: 'device-func',
|
||||
dicts: ['iot_function_type', 'iot_yes_no'],
|
||||
props: {
|
||||
device: {
|
||||
type: Object,
|
||||
default: null,
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
// 获取到父组件传递的device后
|
||||
device: function (newVal) {
|
||||
this.deviceInfo = newVal;
|
||||
if (this.deviceInfo && this.deviceInfo.deviceId != 0) {
|
||||
this.isSubDev = this.deviceInfo.subDeviceList && this.deviceInfo.subDeviceList.length > 0;
|
||||
this.showName = this.isSubDev ? '寄存器地址' : '标识符';
|
||||
this.queryParams.deviceId = this.deviceInfo.deviceId;
|
||||
this.queryParams.slaveId = this.deviceInfo.slaveId;
|
||||
this.queryParams.serialNumber = this.deviceInfo.serialNumber;
|
||||
this.slaveList = newVal.subDeviceList;
|
||||
this.getList();
|
||||
}
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
// 遮罩层
|
||||
loading: true,
|
||||
// 选中数组
|
||||
ids: [],
|
||||
// 非单个禁用
|
||||
single: true,
|
||||
// 非多个禁用
|
||||
multiple: true,
|
||||
// 显示搜索条件
|
||||
showSearch: true,
|
||||
// 总条数
|
||||
total: 0,
|
||||
// 设备服务下发日志表格数据
|
||||
logList: [],
|
||||
// 弹出层标题
|
||||
title: '',
|
||||
// 是否显示弹出层
|
||||
open: false,
|
||||
//设备数据
|
||||
deviceInfo: {},
|
||||
// 时间范围
|
||||
daterangeTime: [],
|
||||
// 查询参数
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
identify: null,
|
||||
funType: null,
|
||||
funValue: null,
|
||||
messageId: null,
|
||||
deviceName: null,
|
||||
serialNumber: null,
|
||||
mode: null,
|
||||
userId: null,
|
||||
resultMsg: null,
|
||||
resultCode: null,
|
||||
slaveId: null,
|
||||
},
|
||||
// 表单参数
|
||||
form: {},
|
||||
//是否是modbus设备组
|
||||
isSubDev: false,
|
||||
showName: null,
|
||||
slaveList: [],
|
||||
// 表单校验
|
||||
rules: {
|
||||
identify: [{ required: true, message: '标识符不能为空', trigger: 'blur' }],
|
||||
funType: [{ required: true, message: '功能下发类型不能为空', trigger: 'change' }],
|
||||
funValue: [{ required: true, message: '日志值不能为空', trigger: 'blur' }],
|
||||
serialNumber: [{ required: true, message: '设备编号不能为空', trigger: 'blur' }],
|
||||
},
|
||||
};
|
||||
},
|
||||
created() {
|
||||
this.queryParams.serialNumber = this.device.serialNumber;
|
||||
this.getList();
|
||||
},
|
||||
methods: {
|
||||
/** 查询设备服务下发日志列表 */
|
||||
getList() {
|
||||
this.loading = true;
|
||||
if (null != this.daterangeTime && '' != this.daterangeTime) {
|
||||
this.queryParams.beginTime = this.daterangeTime[0];
|
||||
this.queryParams.endTime = this.daterangeTime[1];
|
||||
}
|
||||
if (this.queryParams.slaveId) {
|
||||
this.queryParams.serialNumber = this.queryParams.serialNumber + '_' + this.queryParams.slaveId;
|
||||
}
|
||||
listLog(this.queryParams).then((response) => {
|
||||
this.logList = response.rows;
|
||||
this.total = response.total;
|
||||
this.loading = false;
|
||||
});
|
||||
},
|
||||
// 取消按钮
|
||||
cancel() {
|
||||
this.open = false;
|
||||
this.reset();
|
||||
},
|
||||
// 表单重置
|
||||
reset() {
|
||||
this.form = {
|
||||
id: null,
|
||||
identify: null,
|
||||
funType: null,
|
||||
funValue: null,
|
||||
messageId: null,
|
||||
deviceName: null,
|
||||
serialNumber: null,
|
||||
mode: null,
|
||||
userId: null,
|
||||
resultMsg: null,
|
||||
resultCode: null,
|
||||
createBy: null,
|
||||
createTime: null,
|
||||
remark: null,
|
||||
};
|
||||
this.resetForm('form');
|
||||
},
|
||||
/** 搜索按钮操作 */
|
||||
handleQuery() {
|
||||
this.queryParams.pageNum = 1;
|
||||
this.getList();
|
||||
},
|
||||
/** 重置按钮操作 */
|
||||
resetQuery() {
|
||||
this.resetForm('queryForm');
|
||||
this.handleQuery();
|
||||
},
|
||||
// 多选框选中数据
|
||||
handleSelectionChange(selection) {
|
||||
this.ids = selection.map((item) => item.id);
|
||||
this.single = selection.length !== 1;
|
||||
this.multiple = !selection.length;
|
||||
},
|
||||
/** 删除按钮操作 */
|
||||
handleDelete(row) {
|
||||
const ids = row.id || this.ids;
|
||||
this.$modal
|
||||
.confirm('是否确认删除设备服务下发日志编号为"' + ids + '"的数据项?')
|
||||
.then(function () {
|
||||
return delLog(ids);
|
||||
})
|
||||
.then(() => {
|
||||
this.getList();
|
||||
this.$modal.msgSuccess('删除成功');
|
||||
})
|
||||
.catch(() => {});
|
||||
},
|
||||
/** 导出按钮操作 */
|
||||
handleExport() {
|
||||
this.download(
|
||||
'iot/log/export',
|
||||
{
|
||||
...this.queryParams,
|
||||
},
|
||||
`log_${new Date().getTime()}.xlsx`
|
||||
);
|
||||
},
|
||||
//选择从机
|
||||
selectSlave() {},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
@@ -3,22 +3,25 @@
|
||||
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
|
||||
<el-form-item label="日志类型" prop="logType">
|
||||
<el-select v-model="queryParams.logType" placeholder="请选择类型" clearable size="small">
|
||||
<el-option v-for="dict in dict.type.iot_device_log_type" :key="dict.value" :label="dict.label" :value="dict.value" />
|
||||
<el-option v-for="dict in dict.type.iot_event_type" :key="dict.value" :label="dict.label" :value="dict.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="标识符" prop="identity">
|
||||
<el-input v-model="queryParams.identity" placeholder="请输入标识符" clearable size="small" @keyup.enter.native="handleQuery" />
|
||||
</el-form-item>
|
||||
<el-form-item label="时间范围">
|
||||
<el-date-picker v-model="daterangeTime" size="small" style="width: 240px" value-format="yyyy-MM-dd" type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期"></el-date-picker>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
||||
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<el-table v-loading="loading" :data="deviceLogList" size="mini">
|
||||
<el-table v-loading="loading" :data="deviceLogList" size="mini">
|
||||
<el-table-column label="类型" align="center" prop="logType" width="120">
|
||||
<template slot-scope="scope">
|
||||
<dict-tag :options="dict.type.iot_device_log_type" :value="scope.row.logType" />
|
||||
<dict-tag :options="dict.type.iot_event_type" :value="scope.row.logType" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="模式" align="center" prop="logType" width="120">
|
||||
@@ -56,15 +59,12 @@
|
||||
|
||||
<script>
|
||||
import {
|
||||
listDeviceLog
|
||||
} from "@/api/iot/deviceLog";
|
||||
import {
|
||||
cacheJsonThingsModel
|
||||
} from "@/api/iot/model";
|
||||
listEventLog
|
||||
} from "../../../api/iot/eventLog";
|
||||
|
||||
export default {
|
||||
name: "DeviceLog",
|
||||
dicts: ['iot_device_log_type', "iot_yes_no"],
|
||||
dicts: ['iot_event_type', "iot_yes_no"],
|
||||
props: {
|
||||
device: {
|
||||
type: Object,
|
||||
@@ -76,10 +76,10 @@ export default {
|
||||
device: function (newVal, oldVal) {
|
||||
this.deviceInfo = newVal;
|
||||
if (this.deviceInfo && this.deviceInfo.deviceId != 0) {
|
||||
this.queryParams.deviceId = this.deviceInfo.deviceId;
|
||||
this.queryParams.serialNumber = this.deviceInfo.serialNumber;
|
||||
this.getList();
|
||||
// 获取物模型
|
||||
this.getCacheThingsModdel(this.deviceInfo.productId);
|
||||
// 解析缓存物模型
|
||||
this.thingsModel = this.deviceInfo.cacheThingsModel;
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -101,20 +101,24 @@ export default {
|
||||
logType: null,
|
||||
logValue: null,
|
||||
deviceId: null,
|
||||
serialNumber: null,
|
||||
deviceName: null,
|
||||
identity: null,
|
||||
isMonitor: null,
|
||||
},
|
||||
// 时间范围
|
||||
daterangeTime: [],
|
||||
};
|
||||
},
|
||||
created() {
|
||||
|
||||
this.queryParams.serialNumber = this.device.serialNumber;
|
||||
this.getList();
|
||||
},
|
||||
methods: {
|
||||
/** 查询设备日志列表 */
|
||||
getList() {
|
||||
this.loading = true;
|
||||
listDeviceLog(this.queryParams).then(response => {
|
||||
listEventLog(this.addDateRange(this.queryParams, this.daterangeTime)).then(response => {
|
||||
this.deviceLogList = response.rows;
|
||||
this.total = response.total;
|
||||
this.loading = false;
|
||||
@@ -128,20 +132,14 @@ export default {
|
||||
/** 重置按钮操作 */
|
||||
resetQuery() {
|
||||
this.resetForm("queryForm");
|
||||
this.daterangeTime=[];
|
||||
this.handleQuery();
|
||||
},
|
||||
/** 导出按钮操作 */
|
||||
handleExport() {
|
||||
this.download('iot/deviceLog/export', {
|
||||
this.download('iot/event/export', {
|
||||
...this.queryParams
|
||||
}, `deviceLog_${new Date().getTime()}.xlsx`)
|
||||
},
|
||||
/** 获取物模型*/
|
||||
getCacheThingsModdel(productId) {
|
||||
// 获取缓存的Json物模型
|
||||
cacheJsonThingsModel(productId).then(response => {
|
||||
this.thingsModel = JSON.parse(response.data);
|
||||
});
|
||||
}, `eventLog_${new Date().getTime()}.xlsx`)
|
||||
},
|
||||
/** 格式化显示数据定义 */
|
||||
formatValueDisplay(row) {
|
||||
@@ -149,17 +147,29 @@ export default {
|
||||
if (row.logType == 1) {
|
||||
let propertyItem = this.getThingsModelItem(1, row.identity);
|
||||
if (propertyItem != "") {
|
||||
return propertyItem.name + ': <span style="color:#409EFF;">' + this.getThingsModelItemValue(propertyItem, row.logValue) + ' ' + (propertyItem.datatype.unit != undefined ? propertyItem.datatype.unit : '') + '</span>';
|
||||
return (propertyItem.parentName ? '[' + propertyItem.parentName + (propertyItem.arrayIndex ? propertyItem.arrayIndex : '') + '] ' : '') +
|
||||
propertyItem.name +
|
||||
': <span style="color:#409EFF;">' + this.getThingsModelItemValue(propertyItem, row.logValue) + ' ' +
|
||||
(propertyItem.datatype.unit != undefined ? propertyItem.datatype.unit : '') + '</span>';
|
||||
}
|
||||
} else if (row.logType == 2) {
|
||||
let functionItem = this.getThingsModelItem(2, row.identity);
|
||||
if (functionItem != "") {
|
||||
return functionItem.name + ': <span style="color:#409EFF">' + this.getThingsModelItemValue(functionItem, row.logValue) + ' ' + (functionItem.datatype.unit != undefined ? functionItem.datatype.unit : '') + '</span>';
|
||||
return (functionItem.parentName ? '[' + functionItem.parentName + (functionItem.arrayIndex ? functionItem.arrayIndex : '') + '] ' : '') +
|
||||
functionItem.name +
|
||||
': <span style="color:#409EFF">' + this.getThingsModelItemValue(functionItem, row.logValue) + ' ' +
|
||||
(functionItem.datatype.unit != undefined ? functionItem.datatype.unit : '') + '</span>';
|
||||
}
|
||||
} else if (row.logType == 3) {
|
||||
let eventItem = this.getThingsModelItem(3, row.identity);
|
||||
if (eventItem != "") {
|
||||
return eventItem.name + ': <span style="color:#409EFF">' + this.getThingsModelItemValue(eventItem, row.logValue) + ' ' + (eventItem.datatype.unit != undefined ? eventItem.datatype.unit : '') + '</span>';
|
||||
return (eventItem.parentName ? '[' + eventItem.parentName + (eventItem.arrayIndex ? eventItem.arrayIndex : '') + '] ' : '') +
|
||||
eventItem.name +
|
||||
': <span style="color:#409EFF">' + this.getThingsModelItemValue(eventItem, row.logValue) + ' ' +
|
||||
(eventItem.datatype.unit != undefined ? eventItem.datatype.unit : '') + '</span>';
|
||||
}
|
||||
else {
|
||||
return row.logValue;
|
||||
}
|
||||
} else if (row.logType == 4) {
|
||||
return '<span style="font-weight:bold">设备升级</span>';
|
||||
@@ -172,6 +182,7 @@ export default {
|
||||
},
|
||||
/** 获取物模型项中的值*/
|
||||
getThingsModelItemValue(item, oldValue) {
|
||||
// 枚举和布尔转换为文字
|
||||
if (item.datatype.type == "bool") {
|
||||
if (oldValue == "0") {
|
||||
return item.datatype.falseText;
|
||||
@@ -191,15 +202,95 @@ export default {
|
||||
getThingsModelItem(type, identity) {
|
||||
if (type == 1 && this.thingsModel.properties) {
|
||||
for (let i = 0; i < this.thingsModel.properties.length; i++) {
|
||||
//普通类型 integer/decimal/string/emum//bool
|
||||
if (this.thingsModel.properties[i].id == identity) {
|
||||
return this.thingsModel.properties[i];
|
||||
}
|
||||
// 对象 object
|
||||
if (this.thingsModel.properties[i].datatype.type == "object") {
|
||||
for (let j = 0; j < this.thingsModel.properties[i].datatype.params.length; j++) {
|
||||
if (this.thingsModel.properties[i].datatype.params[j].id == identity) {
|
||||
this.thingsModel.properties[i].datatype.params[j].parentName = this.thingsModel.properties[i].name;
|
||||
return this.thingsModel.properties[i].datatype.params[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
// 数组 array
|
||||
if (this.thingsModel.properties[i].datatype.type == "array" && this.thingsModel.properties[i].datatype.arrayType) {
|
||||
if (this.thingsModel.properties[i].datatype.arrayType == "object") {
|
||||
// 数组元素格式:array_01_parentId_humidity,array_01_前缀终端上报时加上,物模型中没有
|
||||
let realIdentity = identity;
|
||||
let arrayIndex = 0;
|
||||
if (identity.indexOf("array_") > -1) {
|
||||
arrayIndex = identity.substring(6, 8);
|
||||
realIdentity = identity.substring(9);
|
||||
}
|
||||
for (let j = 0; j < this.thingsModel.properties[i].datatype.params.length; j++) {
|
||||
if (this.thingsModel.properties[i].datatype.params[j].id == realIdentity) {
|
||||
// 标注索引和父级名称
|
||||
this.thingsModel.properties[i].datatype.params[j].arrayIndex = Number(arrayIndex) + 1;
|
||||
this.thingsModel.properties[i].datatype.params[j].parentName = this.thingsModel.properties[i].name;
|
||||
return this.thingsModel.properties[i].datatype.params[j];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// 普通类型
|
||||
for (let j = 0; j < this.thingsModel.properties[i].datatype.arrayCount.length; j++) {
|
||||
if (this.thingsModel.properties[i].id == realIdentity) {
|
||||
this.thingsModel.properties[i].arrayIndex = Number(arrayIndex) + 1;
|
||||
this.thingsModel.properties[i].parentName = "元素";
|
||||
return this.thingsModel.properties[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
} else if (type == 2 && this.thingsModel.functions) {
|
||||
for (let i = 0; i < this.thingsModel.functions.length; i++) {
|
||||
//普通类型 integer/decimal/string/emum/bool
|
||||
if (this.thingsModel.functions[i].id == identity) {
|
||||
return this.thingsModel.functions[i];
|
||||
}
|
||||
// 对象 object
|
||||
if (this.thingsModel.functions[i].datatype.type == "object") {
|
||||
for (let j = 0; j < this.thingsModel.functions[i].datatype.params.length; j++) {
|
||||
if (this.thingsModel.functions[i].datatype.params[j].id == identity) {
|
||||
this.thingsModel.functions[i].datatype.params[j].parentName = this.thingsModel.functions[i].name;
|
||||
return this.thingsModel.functions[i].datatype.params[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
// 数组 array
|
||||
if (this.thingsModel.functions[i].datatype.type == "array" && this.thingsModel.functions[i].datatype.arrayType) {
|
||||
// 数组元素格式:array_01_parentId_humidity,array_01_前缀终端上报时加上,物模型中没有
|
||||
let realIdentity = identity;
|
||||
let arrayIndex = 0;
|
||||
if (identity.indexOf("array_") > -1) {
|
||||
arrayIndex = identity.substring(6, 8);
|
||||
realIdentity = identity.substring(9);
|
||||
}
|
||||
if (this.thingsModel.functions[i].datatype.arrayType == "object") {
|
||||
for (let j = 0; j < this.thingsModel.functions[i].datatype.params.length; j++) {
|
||||
if (this.thingsModel.functions[i].datatype.params[j].id == realIdentity) {
|
||||
// 标注索引和父级名称
|
||||
this.thingsModel.functions[i].datatype.params[j].arrayIndex = Number(arrayIndex) + 1;
|
||||
this.thingsModel.functions[i].datatype.params[j].parentName = this.thingsModel.functions[i].name;
|
||||
return this.thingsModel.functions[i].datatype.params[j];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// 普通类型
|
||||
for (let j = 0; j < this.thingsModel.functions[i].datatype.arrayCount.length; j++) {
|
||||
if (this.thingsModel.functions[i].id == realIdentity) {
|
||||
this.thingsModel.functions[i].arrayIndex = Number(arrayIndex) + 1;
|
||||
this.thingsModel.functions[i].parentName = "元素";
|
||||
return this.thingsModel.functions[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
} else if (type == 3 && this.thingsModel.events) {
|
||||
for (let i = 0; i < this.thingsModel.events.length; i++) {
|
||||
|
||||
296
vue/src/views/iot/device/device-monitor.vue
Normal file
296
vue/src/views/iot/device/device-monitor.vue
Normal file
@@ -0,0 +1,296 @@
|
||||
<template>
|
||||
<div style="padding-left: 20px">
|
||||
<el-form :inline="true" label-width="100px">
|
||||
<el-form-item label="监测间隔(ms)">
|
||||
<el-tooltip class="item" effect="light" content="取值范围500-10000毫秒" placement="top">
|
||||
<el-input v-model="monitorInterval" placeholder="请输入监测间隔" type="number" clearable size="small" style="width: 180px" />
|
||||
</el-tooltip>
|
||||
</el-form-item>
|
||||
<el-form-item label="监测次数">
|
||||
<el-tooltip class="item" effect="light" content="取值方位1-300" placement="top">
|
||||
<el-input v-model="monitorNumber" placeholder="请输入监测次数" type="number" clearable size="small" style="width: 180px" />
|
||||
</el-tooltip>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="success" icon="el-icon-video-play" size="mini" @click="beginMonitor()" style="margin-left: 30px">开始监测</el-button>
|
||||
<el-button type="danger" icon="el-icon-video-pause" size="mini" @click="stopMonitor()">停止监测</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<el-row :gutter="20" v-loading="chartLoading" element-loading-text="正在接收设备数据,请耐心等待......" element-loading-spinner="el-icon-loading" element-loading-background="rgba(0, 0, 0, 0.8)">
|
||||
<el-col :span="12" v-for="(item, index) in monitorThings" :key="index" style="margin-bottom: 20px">
|
||||
<el-card shadow="hover" :body-style="{ paddingTop: '10px', marginBottom: '-20px' }">
|
||||
<div ref="monitor" style="height: 210px; padding: 0"></div>
|
||||
</el-card>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'DeviceMonitor',
|
||||
props: {
|
||||
device: {
|
||||
type: Object,
|
||||
default: null,
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
// 获取到父组件传递的device后,刷新列表
|
||||
device: function (newVal, oldVal) {
|
||||
this.deviceInfo = newVal;
|
||||
if (this.deviceInfo && this.deviceInfo.deviceId != 0) {
|
||||
// 监测数据
|
||||
this.monitorThings = this.deviceInfo.monitorList;
|
||||
// 监测数据集合初始化
|
||||
this.dataList = [];
|
||||
for (let i = 0; i < this.monitorThings.length; i++) {
|
||||
this.dataList.push({
|
||||
id: this.monitorThings[i].id,
|
||||
name: this.monitorThings[i].name,
|
||||
data: [],
|
||||
});
|
||||
// this.dataList[i].data.push(["2022-03-14 23:32:09", "30"]);
|
||||
}
|
||||
// 绘制监测图表
|
||||
this.$nextTick(function () {
|
||||
this.getMonitorChart();
|
||||
});
|
||||
this.mqttCallback();
|
||||
}
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
// 实时监测间隔
|
||||
monitorInterval: 1000,
|
||||
// 实时监测次数
|
||||
monitorNumber: 60,
|
||||
// 图表集合
|
||||
chart: [],
|
||||
// 图表数据集合
|
||||
dataList: [],
|
||||
// 监测物模型
|
||||
monitorThings: [],
|
||||
// 图表遮罩层
|
||||
chartLoading: false,
|
||||
// 设备信息
|
||||
deviceInfo: {},
|
||||
};
|
||||
},
|
||||
created() {},
|
||||
methods: {
|
||||
/**
|
||||
* Mqtt发布消息
|
||||
* @device 设备
|
||||
* @model 物模型 ,type 类型(1=属性,2=功能,3=OTA升级(商业版支持),4=实时监测)
|
||||
* */
|
||||
mqttPublish(device, model) {
|
||||
let topic = '';
|
||||
let message = '';
|
||||
if (model.type == 4) {
|
||||
// 实时监测
|
||||
topic = '/' + device.productId + '/' + device.serialNumber + '/monitor/get';
|
||||
message = '{"count":' + model.value + ',"interval":' + this.monitorInterval + '}';
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
if (topic != '') {
|
||||
// 发布
|
||||
this.$mqttTool
|
||||
.publish(topic, message, model.name)
|
||||
.then((res) => {
|
||||
this.$modal.notifySuccess(res);
|
||||
})
|
||||
.catch((res) => {
|
||||
this.$modal.notifyError(res);
|
||||
});
|
||||
}
|
||||
},
|
||||
/* Mqtt回调处理 */
|
||||
mqttCallback() {
|
||||
this.$mqttTool.client.on('message', (topic, message, buffer) => {
|
||||
let topics = topic.split('/');
|
||||
let productId = topics[1];
|
||||
let deviceNum = topics[2];
|
||||
message = JSON.parse(message.toString());
|
||||
if (!message) {
|
||||
return;
|
||||
}
|
||||
if (topics[3] == 'status') {
|
||||
console.log('接收到【设备状态】主题:', topic);
|
||||
console.log('接收到【设备状态】内容:', message);
|
||||
// 更新列表中设备的状态
|
||||
if (this.deviceInfo.serialNumber == deviceNum) {
|
||||
this.deviceInfo.status = message.status;
|
||||
this.deviceInfo.isShadow = message.isShadow;
|
||||
this.deviceInfo.rssi = message.rssi;
|
||||
}
|
||||
}
|
||||
if (topics[3] == 'monitor') {
|
||||
console.log('接收到【实时监测】主题:', topic);
|
||||
console.log('接收到【实时监测】内容:', message);
|
||||
// 实时监测
|
||||
this.chartLoading = false;
|
||||
for (let k = 0; k < message.length; k++) {
|
||||
let value = message[k].value;
|
||||
let id = message[k].id;
|
||||
let remark = message[k].remark;
|
||||
// 数据加载到图表
|
||||
for (let i = 0; i < this.dataList.length; i++) {
|
||||
if (id == this.dataList[i].id) {
|
||||
// 普通类型匹配
|
||||
if (this.dataList[i].length > 50) {
|
||||
this.dataList[i].shift();
|
||||
}
|
||||
this.dataList[i].data.push([this.getTime(), value]);
|
||||
// 更新图表
|
||||
this.chart[i].setOption({
|
||||
series: [
|
||||
{
|
||||
data: this.dataList[i].data,
|
||||
},
|
||||
],
|
||||
});
|
||||
break;
|
||||
} else if (this.dataList[i].id.indexOf('array_') == 0) {
|
||||
// 数组类型匹配,例如:gateway_temperature,图表id去除前缀后匹配
|
||||
let index = this.dataList[i].id.substring(6, 8);
|
||||
let identity = this.dataList[i].id.substring(9);
|
||||
if (identity == id) {
|
||||
let values = value.split(',');
|
||||
if (this.dataList[i].length > 50) {
|
||||
this.dataList[i].shift();
|
||||
}
|
||||
this.dataList[i].data.push([this.getTime(), values[index]]);
|
||||
// 更新图表
|
||||
this.chart[i].setOption({
|
||||
series: [
|
||||
{
|
||||
data: this.dataList[i].data,
|
||||
},
|
||||
],
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
/** 更新实时监测参数*/
|
||||
beginMonitor() {
|
||||
if (this.deviceInfo.status != 3) {
|
||||
this.$modal.alertError('设备不在线,下发指令失败');
|
||||
return;
|
||||
}
|
||||
// 清空图表数据
|
||||
for (let i = 0; i < this.dataList.length; i++) {
|
||||
this.dataList[i].data = [];
|
||||
}
|
||||
if (this.monitorInterval < 500 || this.monitorInterval > 10000) {
|
||||
this.$modal.alertError('实时监测的间隔范围500-10000毫秒');
|
||||
}
|
||||
if (this.monitorNumber == 0 || this.monitorNumber > 300) {
|
||||
this.$modal.alertError('实时监测数量范围1-300');
|
||||
}
|
||||
// Mqtt发布实时监测消息
|
||||
let model = {};
|
||||
model.name = '更新实时监测';
|
||||
model.value = this.monitorNumber;
|
||||
model.type = 4;
|
||||
this.mqttPublish(this.deviceInfo, model);
|
||||
this.chartLoading = true;
|
||||
},
|
||||
/** 停止实时监测 */
|
||||
stopMonitor() {
|
||||
if (this.deviceInfo.status != 3) {
|
||||
this.$modal.alertError('设备不在线,下发指令失败');
|
||||
return;
|
||||
}
|
||||
this.chartLoading = false;
|
||||
// Mqtt发布实时监测
|
||||
let model = {};
|
||||
model.name = '关闭实时监测';
|
||||
model.value = 0;
|
||||
model.type = 4;
|
||||
this.mqttPublish(this.deviceInfo, model);
|
||||
},
|
||||
/**监测数据 */
|
||||
getMonitorChart() {
|
||||
let color = ['#1890FF', '#91CB74', '#FAC858', '#EE6666', '#73C0DE', '#3CA272', '#FC8452', '#9A60B4', '#ea7ccc'];
|
||||
for (let i = 0; i < this.monitorThings.length; i++) {
|
||||
// 设置宽度
|
||||
this.$refs.monitor[i].style.width = document.documentElement.clientWidth / 2 - 255 + 'px';
|
||||
this.chart[i] = this.$echarts.init(this.$refs.monitor[i]);
|
||||
var option;
|
||||
option = {
|
||||
title: {
|
||||
left: 'center',
|
||||
text: this.monitorThings[i].name + ' (单位 ' + (this.monitorThings[i].datatype.unit != undefined ? this.monitorThings[i].datatype.unit : '无') + ')',
|
||||
textStyle: {
|
||||
fontSize: 14,
|
||||
},
|
||||
},
|
||||
grid: {
|
||||
top: '50px',
|
||||
left: '20px',
|
||||
right: '20px',
|
||||
bottom: '10px',
|
||||
containLabel: true,
|
||||
},
|
||||
tooltip: {
|
||||
trigger: 'axis',
|
||||
axisPointer: {
|
||||
animation: true,
|
||||
},
|
||||
},
|
||||
xAxis: {
|
||||
type: 'time',
|
||||
show: false,
|
||||
splitLine: {
|
||||
show: false,
|
||||
},
|
||||
},
|
||||
yAxis: {
|
||||
type: 'value',
|
||||
boundaryGap: [0, '100%'],
|
||||
splitLine: {
|
||||
show: true,
|
||||
},
|
||||
},
|
||||
series: [
|
||||
{
|
||||
name: this.monitorThings[i].name,
|
||||
type: 'line',
|
||||
symbol: 'none',
|
||||
sampling: 'lttb',
|
||||
itemStyle: {
|
||||
color: i > 9 ? color[0] : color[i],
|
||||
},
|
||||
areaStyle: {},
|
||||
data: [],
|
||||
},
|
||||
],
|
||||
};
|
||||
option && this.chart[i].setOption(option);
|
||||
}
|
||||
},
|
||||
/* 获取当前时间*/
|
||||
getTime() {
|
||||
let date = new Date();
|
||||
let y = date.getFullYear();
|
||||
let m = date.getMonth() + 1;
|
||||
let d = date.getDate();
|
||||
let H = date.getHours();
|
||||
let mm = date.getMinutes();
|
||||
let s = date.getSeconds();
|
||||
m = m < 10 ? '0' + m : m;
|
||||
d = d < 10 ? '0' + d : d;
|
||||
H = H < 10 ? '0' + H : H;
|
||||
return y + '-' + m + '-' + d + ' ' + H + ':' + mm + ':' + s;
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
@@ -1,192 +1,225 @@
|
||||
<template>
|
||||
<div style="padding-left:20px;">
|
||||
<div style="padding-left: 20px">
|
||||
<el-row>
|
||||
<el-col :span="24">
|
||||
<el-form :model="queryParams" ref="queryForm" :inline="true" label-width="75px" style="">
|
||||
<el-form-item label="时间范围">
|
||||
<el-date-picker v-model="daterangeTime" size="small" style="width: 240px" value-format="yyyy-MM-dd" type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期"></el-date-picker>
|
||||
</el-form-item>
|
||||
<el-form-item label="最大数量">
|
||||
<el-input v-model="queryParams.total"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="el-icon-search" size="mini" @click="getStatisticData">查询</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-col>
|
||||
<el-col :span="23">
|
||||
<div v-for="(item,index) in monitorThings" :key="index" style="margin-bottom:30px;">
|
||||
<el-card shadow="hover" :body-style="{ padding: '10px 0px',overflow:'auto' }" v-loading="loading">
|
||||
<div ref="statisticMap" style="height:300px;width:1080px;"></div>
|
||||
</el-card>
|
||||
</div>
|
||||
</el-col>
|
||||
<el-col :span="24">
|
||||
<el-form :model="queryParams" ref="queryForm" :inline="true" label-width="75px">
|
||||
<el-form-item label="请选择设备从机:" label-width="120px" v-if="isSubDev">
|
||||
<el-select v-model="queryParams.slaveId" placeholder="请选择设备从机" @change="selectSlave">
|
||||
<el-option v-for="slave in slaveList" :key="slave.slaveId" :label="`${slave.deviceName} (${slave.slaveId})`"
|
||||
:value="slave.slaveId"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="时间范围">
|
||||
<el-date-picker v-model="daterangeTime" size="small" style="width: 240px" value-format="yyyy-MM-dd"
|
||||
type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期"></el-date-picker>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="el-icon-search" size="mini" @click="getListHistory">查询</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-col>
|
||||
<el-col :span="23">
|
||||
<div v-for="(item, index) in staticList" :key="index" style="margin-bottom: 30px">
|
||||
<el-card shadow="hover" :body-style="{ padding: '10px 0px', overflow: 'auto' }" v-loading="loading">
|
||||
<div ref="statisticMap" style="height: 300px; width: 1080px"></div>
|
||||
</el-card>
|
||||
</div>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import * as echarts from 'echarts';
|
||||
import {
|
||||
cacheJsonThingsModel
|
||||
} from "@/api/iot/model";
|
||||
import {
|
||||
listMonitor
|
||||
} from "@/api/iot/deviceLog";
|
||||
import { listHistory } from '@/api/iot/deviceLog';
|
||||
|
||||
export default {
|
||||
name: "device-statistic",
|
||||
props: {
|
||||
device: {
|
||||
type: Object,
|
||||
default: null
|
||||
}
|
||||
name: 'device-statistic',
|
||||
props: {
|
||||
device: {
|
||||
type: Object,
|
||||
default: null,
|
||||
},
|
||||
watch: {
|
||||
// 获取到父组件传递的device后
|
||||
device: function (newVal, oldVal) {
|
||||
this.deviceInfo = newVal;
|
||||
if (this.deviceInfo && this.deviceInfo.deviceId != 0) {
|
||||
this.getCacheThingsModdel(this.deviceInfo.productId);
|
||||
},
|
||||
watch: {
|
||||
// 获取到父组件传递的device后
|
||||
device: function (newVal, oldVal) {
|
||||
this.deviceInfo = newVal;
|
||||
if (this.deviceInfo && this.deviceInfo.deviceId != 0) {
|
||||
this.isSubDev = this.deviceInfo.subDeviceList && this.deviceInfo.subDeviceList.length > 0;
|
||||
this.queryParams.slaveId = this.deviceInfo.slaveId;
|
||||
this.queryParams.serialNumber = this.deviceInfo.serialNumber;
|
||||
this.slaveList = newVal.subDeviceList;
|
||||
// 监测数据
|
||||
if (this.isSubDev) {
|
||||
this.staticList = this.deviceInfo.cacheThingsModel['properties'].filter((item) => {
|
||||
return item.tempSlaveId == this.queryParams.slaveId;
|
||||
});
|
||||
} else {
|
||||
this.staticList = this.deviceInfo.staticList;
|
||||
}
|
||||
// 加载图表
|
||||
this.$nextTick(function () {
|
||||
// 绘制图表
|
||||
this.getStatistic();
|
||||
});
|
||||
}
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
loading: true,
|
||||
// 设备信息
|
||||
deviceInfo: {},
|
||||
// 统计物模型
|
||||
staticList: [],
|
||||
// 图表集合
|
||||
chart: [],
|
||||
// 激活时间范围
|
||||
daterangeTime: [this.getTime(), this.getTime()],
|
||||
// 查询参数
|
||||
queryParams: {
|
||||
serialNumber: null,
|
||||
identity: '',
|
||||
slaveId: undefined,
|
||||
},
|
||||
// 对象数组类型物模型暂存数据
|
||||
arrayData: [],
|
||||
// 子设备列表
|
||||
slaveList: [],
|
||||
isSubDev: false,
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
// 获取统计数据
|
||||
// this.getListHistory();
|
||||
},
|
||||
methods: {
|
||||
/** 获取当前日期 **/
|
||||
getTime() {
|
||||
let date = new Date();
|
||||
let y = date.getFullYear();
|
||||
let m = date.getMonth() + 1;
|
||||
let d = date.getDate();
|
||||
m = m < 10 ? '0' + m : m;
|
||||
d = d < 10 ? '0' + d : d;
|
||||
return y + '-' + m + '-' + d;
|
||||
},
|
||||
/* 获取监测历史数据*/
|
||||
getListHistory() {
|
||||
this.loading = true;
|
||||
this.queryParams.serialNumber = this.queryParams.slaveId ? this.deviceInfo.serialNumber + '_' + this.queryParams.slaveId : this.deviceInfo.serialNumber;
|
||||
if (null != this.daterangeTime && '' != this.daterangeTime) {
|
||||
this.queryParams.beginTime = this.daterangeTime[0];
|
||||
this.queryParams.endTime = this.daterangeTime[1] + ' 23:59';
|
||||
}
|
||||
listHistory(this.queryParams).then((res) => {
|
||||
for (let key in res.data) {
|
||||
for (let i = 0; i < this.staticList.length; i++) {
|
||||
if (key == this.staticList[i].id) {
|
||||
// 对象转数组
|
||||
let dataList = [];
|
||||
for (let j = 0; j < res.data[key].length; j++) {
|
||||
let item = [];
|
||||
item[0] = res.data[key][j].time;
|
||||
item[1] = res.data[key][j].value;
|
||||
dataList.push(item);
|
||||
}
|
||||
// 图表显示数据
|
||||
this.chart[i].setOption({
|
||||
series: [
|
||||
{
|
||||
data: dataList,
|
||||
},
|
||||
],
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
this.loading = false;
|
||||
});
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
loading: false,
|
||||
// 设备信息
|
||||
deviceInfo: {},
|
||||
// 监测物模型
|
||||
monitorThings: [],
|
||||
// 图表集合
|
||||
chart: [],
|
||||
// 激活时间范围
|
||||
daterangeTime: [],
|
||||
// 查询参数
|
||||
queryParams: {
|
||||
deviceId: 0,
|
||||
identity: "",
|
||||
total: 1000,
|
||||
|
||||
/**监测统计数据 */
|
||||
getStatistic() {
|
||||
let color = ['#1890FF', '#91CB74', '#FAC858', '#EE6666', '#73C0DE', '#3CA272', '#FC8452', '#9A60B4', '#ea7ccc'];
|
||||
for (let i = 0; i < this.staticList.length; i++) {
|
||||
// 设置宽度
|
||||
this.$refs.statisticMap[i].style.width = document.documentElement.clientWidth - 510 + 'px';
|
||||
this.chart[i] = this.$echarts.init(this.$refs.statisticMap[i]);
|
||||
var option;
|
||||
option = {
|
||||
animationDurationUpdate: 3000,
|
||||
tooltip: {
|
||||
trigger: 'axis',
|
||||
},
|
||||
title: {
|
||||
left: 'center',
|
||||
text: this.staticList[i].name + '统计 (单位 ' + (this.staticList[i].datatype && this.staticList[i].datatype.unit != undefined ? this.staticList[i].datatype.unit : '无') + ')',
|
||||
},
|
||||
grid: {
|
||||
top: '80px',
|
||||
left: '50px',
|
||||
right: '20px',
|
||||
bottom: '80px',
|
||||
// containLabel: true,
|
||||
},
|
||||
toolbox: {
|
||||
feature: {
|
||||
dataZoom: {
|
||||
yAxisIndex: 'none',
|
||||
},
|
||||
restore: {},
|
||||
saveAsImage: {},
|
||||
},
|
||||
},
|
||||
xAxis: {
|
||||
type: 'time',
|
||||
},
|
||||
yAxis: {
|
||||
type: 'value',
|
||||
},
|
||||
dataZoom: [
|
||||
{
|
||||
type: 'inside',
|
||||
start: 0,
|
||||
end: 100,
|
||||
},
|
||||
{
|
||||
start: 0,
|
||||
end: 100,
|
||||
},
|
||||
],
|
||||
series: [
|
||||
{
|
||||
name: this.staticList[i].name,
|
||||
type: 'line',
|
||||
symbol: 'none',
|
||||
sampling: 'lttb',
|
||||
itemStyle: {
|
||||
color: i > 9 ? color[0] : color[i],
|
||||
},
|
||||
areaStyle: {},
|
||||
data: [],
|
||||
},
|
||||
],
|
||||
};
|
||||
option && this.chart[i].setOption(option);
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
|
||||
/*选择从机*/
|
||||
selectSlave() {
|
||||
this.staticList = this.deviceInfo.cacheThingsModel['properties'].filter((item) => {
|
||||
return item.tempSlaveId == this.queryParams.slaveId;
|
||||
});
|
||||
// 加载图表
|
||||
this.$nextTick(function () {
|
||||
// 绘制图表
|
||||
this.getStatistic();
|
||||
// 获取统计数据
|
||||
this.getListHistory();
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
/** 获取物模型*/
|
||||
getCacheThingsModdel(productId) {
|
||||
// 获取缓存的Json物模型
|
||||
cacheJsonThingsModel(productId).then(response => {
|
||||
let thingsModel = JSON.parse(response.data);
|
||||
// 筛选监测数据
|
||||
this.monitorThings = thingsModel.properties.filter(item => item.isMonitor == 1);
|
||||
// 加载图表
|
||||
this.$nextTick(function () {
|
||||
// 绘制图表
|
||||
this.getStatistic();
|
||||
// 获取统计数据
|
||||
this.getStatisticData(this.monitorThings);
|
||||
});
|
||||
|
||||
});
|
||||
},
|
||||
/** 获取统计数据 */
|
||||
getStatisticData() {
|
||||
this.loading = true;
|
||||
for (let i = 0; i < this.monitorThings.length; i++) {
|
||||
this.queryParams.deviceId = this.deviceInfo.deviceId;
|
||||
this.queryParams.identity = this.monitorThings[i].id;
|
||||
if (null != this.daterangeTime && '' != this.daterangeTime) {
|
||||
this.queryParams.beginTime = this.daterangeTime[0];
|
||||
this.queryParams.endTime = this.daterangeTime[1]+" 23:59";
|
||||
}
|
||||
listMonitor(this.queryParams).then(response => {
|
||||
let data = response.rows;
|
||||
// 对象转数组
|
||||
let dataList = [];
|
||||
for (let j = 0; j < data.length; j++) {
|
||||
let item = [];
|
||||
item[0] = data[j].time;
|
||||
item[1] = data[j].value;
|
||||
dataList.push(item);
|
||||
}
|
||||
this.chart[i].setOption({
|
||||
series: [{
|
||||
data: dataList
|
||||
}]
|
||||
});
|
||||
this.loading = false;
|
||||
});
|
||||
}
|
||||
},
|
||||
/**监测统计数据 */
|
||||
getStatistic() {
|
||||
let color = ['#1890FF', '#91CB74', '#FAC858', '#EE6666', '#73C0DE', '#3CA272', '#FC8452', '#9A60B4', '#ea7ccc'];
|
||||
for (let i = 0; i < this.monitorThings.length; i++) {
|
||||
// 设置宽度
|
||||
this.$refs.statisticMap[i].style.width = (document.documentElement.clientWidth - 510) + "px";
|
||||
console.log(this.$refs.statisticMap[i]);
|
||||
|
||||
this.chart[i] = echarts.init(this.$refs.statisticMap[i]);
|
||||
var option;
|
||||
option = {
|
||||
animationDurationUpdate: 3000,
|
||||
tooltip: {
|
||||
trigger: 'axis',
|
||||
},
|
||||
title: {
|
||||
left: 'center',
|
||||
text: this.monitorThings[i].name + '统计 (单位 ' + (this.monitorThings[i].datatype.unit != undefined ? this.monitorThings[i].datatype.unit : "无") + ")",
|
||||
},
|
||||
grid: {
|
||||
top: '80px',
|
||||
left: '40px',
|
||||
right: '20px',
|
||||
bottom: '60px',
|
||||
containLabel: true
|
||||
},
|
||||
toolbox: {
|
||||
feature: {
|
||||
dataZoom: {
|
||||
yAxisIndex: 'none'
|
||||
},
|
||||
restore: {},
|
||||
saveAsImage: {}
|
||||
}
|
||||
},
|
||||
xAxis: {
|
||||
type: 'time',
|
||||
},
|
||||
yAxis: {
|
||||
type: 'value',
|
||||
},
|
||||
dataZoom: [{
|
||||
type: 'inside',
|
||||
start: 0,
|
||||
end: 100
|
||||
},
|
||||
{
|
||||
start: 0,
|
||||
end: 100
|
||||
}
|
||||
],
|
||||
series: [{
|
||||
name: this.monitorThings[i].name,
|
||||
type: 'line',
|
||||
symbol: 'none',
|
||||
sampling: 'lttb',
|
||||
itemStyle: {
|
||||
color: i > 9 ? color[0] : color[i]
|
||||
},
|
||||
areaStyle: {},
|
||||
data: []
|
||||
}]
|
||||
};
|
||||
option && this.chart[i].setOption(option);
|
||||
}
|
||||
},
|
||||
}
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,234 +1,348 @@
|
||||
<template>
|
||||
<div style="padding-left:20px;">
|
||||
<div style="padding-left: 20px">
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-button type="primary" plain icon="el-icon-share" size="mini" @click="selectUser" v-hasPermi="['iot:device:share']">分享设备</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="warning" plain icon="el-icon-refresh" size="mini" @click="getList">刷新</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="primary" plain icon="el-icon-share" size="mini" @click="shareDevice" v-hasPermi="['iot:device:share']">分享设备</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="warning" plain icon="el-icon-refresh" size="mini" @click="getList">刷新</el-button>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<el-table v-loading="loading" :data="deviceUserList" @selection-change="handleSelectionChange" size="mini">
|
||||
<el-table-column label="用户编号" align="center" prop="userId" width="100" />
|
||||
<el-table-column label="用户名称" align="center" prop="userName" />
|
||||
<el-table-column label="手机号码" align="center" prop="phonenumber" width="150" />
|
||||
<el-table-column label="用户类型" align="center" prop="isOwner" width="150">
|
||||
<template slot-scope="scope">
|
||||
<el-tag type="primary" v-if="scope.row.isOwner">主人</el-tag>
|
||||
<el-tag type="success" v-else>分享</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="分享时间" align="center" prop="createTime" width="150">
|
||||
<template slot-scope="scope">
|
||||
<span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="备注" align="left" prop="remark" header-align="center" min-width="150" />
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="150">
|
||||
<template slot-scope="scope">
|
||||
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)" v-hasPermi="['iot:device:share']" v-if="scope.row.isOwner==0">备注</el-button>
|
||||
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)" v-hasPermi="['iot:device:share']" v-if="scope.row.isOwner==0">取消分享</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="用户编号" align="center" prop="userId" width="100" />
|
||||
<el-table-column label="用户名称" align="center" prop="userName" />
|
||||
<el-table-column label="手机号码" align="center" prop="phonenumber" width="150" />
|
||||
<el-table-column label="用户类型" align="center" prop="isOwner" width="150">
|
||||
<template slot-scope="scope">
|
||||
<el-tag type="primary" v-if="scope.row.isOwner">主人</el-tag>
|
||||
<el-tag type="success" v-else>分享</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="分享时间" align="center" prop="createTime" width="150">
|
||||
<template slot-scope="scope">
|
||||
<span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="备注" align="left" prop="remark" header-align="center" min-width="150" />
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="180">
|
||||
<template slot-scope="scope">
|
||||
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)" v-hasPermi="['iot:device:share']" v-if="scope.row.isOwner == 0">编辑</el-button>
|
||||
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)" v-hasPermi="['iot:device:share']" v-if="scope.row.isOwner == 0">取消分享</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<!-- 添加或修改设备用户对话框 -->
|
||||
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
|
||||
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容" rows="4" />
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button type="primary" @click="submitForm">确 定</el-button>
|
||||
<el-button @click="cancel">取 消</el-button>
|
||||
<!--设备分享对话框-->
|
||||
<el-dialog title="设备分享" :visible.sync="open" width="800px">
|
||||
<div style="margin-top: -50px">
|
||||
<el-divider></el-divider>
|
||||
</div>
|
||||
<!--用户查询-->
|
||||
<el-form :model="permParams" ref="queryForm" :rules="rules" :inline="true" label-width="80px" v-if="type == 1">
|
||||
<el-form-item label="手机号码" prop="phonenumber">
|
||||
<el-input type="text" placeholder="请输入用户手机号码" v-model="permParams.phonenumber" minlength="10" clearable size="small" show-word-limit style="width: 240px" @keyup.enter.native="handleQuery"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="el-icon-search" size="mini" @click="userQuery">查询用户</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<!--用户信息和权限设置-->
|
||||
<div v-loading="permsLoading" style="background-color: #f8f8f9; line-height: 28px">
|
||||
<div v-if="message" style="padding: 20px">{{ message }}</div>
|
||||
<div v-if="form.userId" style="padding: 15px">
|
||||
<div style="font-weight: bold; line-height: 28px">用户信息</div>
|
||||
<span style="width: 80px; display: inline-block">用户ID:</span>
|
||||
<span>{{ form.userId }}</span>
|
||||
<br />
|
||||
<span style="width: 80px; display: inline-block">手机号码:</span>
|
||||
<span>{{ form.phonenumber }}</span>
|
||||
<br />
|
||||
<span style="width: 80px; display: inline-block">用户名称:</span>
|
||||
<span>{{ form.userName }}</span>
|
||||
<br />
|
||||
<!--选择权限-->
|
||||
<div style="font-weight: bold; margin: 15px 0 10px">设置用户权限</div>
|
||||
<el-table :data="sharePermissionList" highlight-current-row size="mini" ref="multipleTable" @select="handleSelectionChange" @select-all="handleSelectionAll">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="权限名称" align="center" key="modelName" prop="modelName" />
|
||||
<el-table-column label="权限标识" align="center" key="identifier" prop="identifier" />
|
||||
<el-table-column label="备注信息" align="left" min-width="100" header-align="center" key="remark" prop="remark" />
|
||||
</el-table>
|
||||
<!--选择权限-->
|
||||
<div style="font-weight: bold; margin: 15px 0 10px">备注信息</div>
|
||||
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容" rows="2" />
|
||||
</div>
|
||||
</div>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button type="primary" @click="submitForm" :disabled="!form.userId || !deviceInfo.deviceId">确定</el-button>
|
||||
<el-button @click="closeSelectUser">关 闭</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
|
||||
<!-- 选择用户 -->
|
||||
<user-list ref="userList" :device="devices" />
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import userList from "./user-list"
|
||||
import {
|
||||
listDeviceUser,
|
||||
getDeviceUser,
|
||||
delDeviceUser,
|
||||
updateDeviceUser
|
||||
} from "@/api/iot/deviceuser";
|
||||
import { addDeviceUser, listDeviceUser, getDeviceUser, delDeviceUser, updateDeviceUser, shareUser } from '@/api/iot/deviceuser';
|
||||
import { permListModel } from '@/api/iot/model';
|
||||
|
||||
export default {
|
||||
name: "device-user",
|
||||
dicts: ['iot_yes_no'],
|
||||
components: {
|
||||
userList
|
||||
name: 'device-user',
|
||||
dicts: ['iot_yes_no'],
|
||||
props: {
|
||||
device: {
|
||||
type: Object,
|
||||
default: null,
|
||||
},
|
||||
props: {
|
||||
device: {
|
||||
type: Object,
|
||||
default: null
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
// 获取到父组件传递的device后,刷新列表
|
||||
device: function (newVal, oldVal) {
|
||||
this.deviceInfo = newVal;
|
||||
this.devices = [newVal];
|
||||
if (this.deviceInfo && this.deviceInfo.deviceId != 0) {
|
||||
this.queryParams.deviceId = this.deviceInfo.deviceId;
|
||||
this.getList();
|
||||
}
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
// 设备列表
|
||||
devices: [],
|
||||
// 遮罩层
|
||||
loading: true,
|
||||
// 选中数组
|
||||
ids: [],
|
||||
// 非单个禁用
|
||||
single: true,
|
||||
// 非多个禁用
|
||||
multiple: true,
|
||||
// 总条数
|
||||
total: 0,
|
||||
// 设备用户表格数据
|
||||
deviceUserList: [],
|
||||
// 弹出层标题
|
||||
title: "",
|
||||
// 是否显示弹出层
|
||||
open: false,
|
||||
// 查询参数
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
deviceName: null,
|
||||
userName: null,
|
||||
userId: null,
|
||||
tenantName: null,
|
||||
isOwner: null,
|
||||
},
|
||||
// 表单参数
|
||||
form: {},
|
||||
// 表单校验
|
||||
rules: {
|
||||
deviceName: [{
|
||||
required: true,
|
||||
message: "设备名称不能为空",
|
||||
trigger: "blur"
|
||||
}],
|
||||
userName: [{
|
||||
required: true,
|
||||
message: "用户昵称不能为空",
|
||||
trigger: "blur"
|
||||
}],
|
||||
}
|
||||
};
|
||||
},
|
||||
created() {
|
||||
},
|
||||
watch: {
|
||||
// 获取到父组件传递的device后,刷新列表
|
||||
device: function (newVal, oldVal) {
|
||||
this.deviceInfo = newVal;
|
||||
if (this.deviceInfo && this.deviceInfo.deviceId != 0) {
|
||||
this.queryParams.deviceId = this.deviceInfo.deviceId;
|
||||
this.getList();
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
/** 查询设备用户列表 */
|
||||
getList() {
|
||||
this.loading = true;
|
||||
listDeviceUser(this.queryParams).then(response => {
|
||||
this.deviceUserList = response.rows;
|
||||
this.total = response.total;
|
||||
this.loading = false;
|
||||
});
|
||||
},
|
||||
// 取消按钮
|
||||
cancel() {
|
||||
this.open = false;
|
||||
this.reset();
|
||||
},
|
||||
// 表单重置
|
||||
reset() {
|
||||
this.form = {
|
||||
deviceId: null,
|
||||
userId: null,
|
||||
deviceName: null,
|
||||
userName: null,
|
||||
tenantId: null,
|
||||
tenantName: null,
|
||||
isOwner: null,
|
||||
limitNum: null,
|
||||
delFlag: null,
|
||||
createBy: null,
|
||||
createTime: null,
|
||||
updateBy: null,
|
||||
updateTime: null,
|
||||
remark: null
|
||||
};
|
||||
this.resetForm("form");
|
||||
},
|
||||
/** 搜索按钮操作 */
|
||||
handleQuery() {
|
||||
this.queryParams.pageNum = 1;
|
||||
this.getList();
|
||||
},
|
||||
/** 重置按钮操作 */
|
||||
resetQuery() {
|
||||
this.resetForm("queryForm");
|
||||
this.handleQuery();
|
||||
},
|
||||
// 多选框选中数据
|
||||
handleSelectionChange(selection) {
|
||||
this.ids = selection.map(item => item.deviceId)
|
||||
this.single = selection.length !== 1
|
||||
this.multiple = !selection.length
|
||||
},
|
||||
/** 新增按钮操作 */
|
||||
handleAdd() {
|
||||
this.reset();
|
||||
this.open = true;
|
||||
this.title = "添加设备用户";
|
||||
},
|
||||
/** 修改按钮操作 */
|
||||
handleUpdate(row) {
|
||||
this.reset();
|
||||
const deviceId = row.deviceId || this.ids
|
||||
getDeviceUser(deviceId, row.userId).then(response => {
|
||||
this.form = response.data;
|
||||
this.open = true;
|
||||
this.title = "用户备注";
|
||||
});
|
||||
},
|
||||
/** 提交按钮 */
|
||||
submitForm() {
|
||||
if (this.form.deviceId != null) {
|
||||
updateDeviceUser(this.form).then(response => {
|
||||
this.$modal.msgSuccess("备注成功");
|
||||
this.open = false;
|
||||
this.getList();
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
// 类型,1=新增,2=更新
|
||||
type: 1,
|
||||
// 消息提示
|
||||
message: '',
|
||||
// 权限遮罩层
|
||||
permsLoading: false,
|
||||
// 权限列表
|
||||
sharePermissionList: [],
|
||||
// 设备信息
|
||||
deviceInfo: {},
|
||||
// 是否显示选择用户弹出层
|
||||
open: false,
|
||||
// 查询参数
|
||||
permParams: {
|
||||
userName: undefined,
|
||||
phonenumber: undefined,
|
||||
deviceId: null,
|
||||
},
|
||||
// 查询表单验证
|
||||
rules: {
|
||||
phonenumber: [
|
||||
{
|
||||
required: true,
|
||||
message: '手机号码不能为空',
|
||||
trigger: 'blur',
|
||||
},
|
||||
{
|
||||
min: 11,
|
||||
max: 11,
|
||||
message: '手机号码长度为11位',
|
||||
trigger: 'blur',
|
||||
},
|
||||
],
|
||||
},
|
||||
// 遮罩层
|
||||
loading: true,
|
||||
// 总条数
|
||||
total: 0,
|
||||
// 设备用户表格数据
|
||||
deviceUserList: [],
|
||||
// 查询参数
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
deviceName: null,
|
||||
userName: null,
|
||||
userId: null,
|
||||
tenantName: null,
|
||||
isOwner: null,
|
||||
},
|
||||
// 表单参数
|
||||
form: {},
|
||||
};
|
||||
},
|
||||
created() {
|
||||
this.queryParams.deviceId = this.device.deviceId;
|
||||
this.getList();
|
||||
},
|
||||
methods: {
|
||||
/** 查询设备用户列表 */
|
||||
getList() {
|
||||
this.loading = true;
|
||||
listDeviceUser(this.queryParams).then((response) => {
|
||||
this.deviceUserList = response.rows;
|
||||
this.total = response.total;
|
||||
this.loading = false;
|
||||
});
|
||||
},
|
||||
// 表单重置
|
||||
reset() {
|
||||
this.form = {
|
||||
deviceId: null,
|
||||
userId: null,
|
||||
deviceName: null,
|
||||
userName: null,
|
||||
perms: null,
|
||||
phonenumber: null,
|
||||
remark: null,
|
||||
};
|
||||
this.sharePermissionList = [];
|
||||
this.message = '';
|
||||
this.resetForm('form');
|
||||
},
|
||||
/** 搜索按钮操作 */
|
||||
handleQuery() {
|
||||
this.queryParams.pageNum = 1;
|
||||
this.getList();
|
||||
},
|
||||
/** 修改按钮操作 */
|
||||
handleUpdate(row) {
|
||||
this.reset();
|
||||
this.type = 2; //更新
|
||||
getDeviceUser(row.deviceId, row.userId).then((response) => {
|
||||
this.form = response.data;
|
||||
// 查询物模型权限列表
|
||||
this.getPermissionList();
|
||||
this.open = true;
|
||||
});
|
||||
},
|
||||
// 设备分享
|
||||
shareDevice() {
|
||||
this.type = 1; // 新增
|
||||
this.open = true;
|
||||
},
|
||||
/** 删除按钮操作 */
|
||||
handleDelete(row) {
|
||||
const deviceUser = row;
|
||||
this.$modal
|
||||
.confirm('确认取消分享设备?')
|
||||
.then(function () {
|
||||
return delDeviceUser(deviceUser);
|
||||
})
|
||||
.then(() => {
|
||||
this.getList();
|
||||
this.$modal.msgSuccess('取消分享成功');
|
||||
})
|
||||
.catch(() => {});
|
||||
},
|
||||
/** 用户按钮操作 */
|
||||
userQuery() {
|
||||
this.$refs['queryForm'].validate((valid) => {
|
||||
if (valid) {
|
||||
this.reset();
|
||||
this.getShareUser();
|
||||
}
|
||||
});
|
||||
},
|
||||
/** 查询用户 */
|
||||
getShareUser() {
|
||||
this.permsLoading = true;
|
||||
if (!this.deviceInfo.deviceId) {
|
||||
this.$modal.alert('查询不到设备信息,请刷新后重试');
|
||||
return;
|
||||
}
|
||||
this.permParams.deviceId = this.deviceInfo.deviceId;
|
||||
shareUser(this.permParams).then((response) => {
|
||||
if (response.data) {
|
||||
this.form = response.data;
|
||||
// 查询物模型权限列表
|
||||
this.getPermissionList();
|
||||
} else {
|
||||
this.permsLoading = false;
|
||||
this.message = '查询不到用户信息,或者该用户已经是设备用户';
|
||||
}
|
||||
});
|
||||
},
|
||||
/** 查询产品物模型设备权限列表 */
|
||||
async getPermissionList() {
|
||||
let perms = [];
|
||||
if (this.form.perms) {
|
||||
perms = this.form.perms.split(',');
|
||||
}
|
||||
console.log('deviceInfo', this.deviceInfo);
|
||||
permListModel(this.deviceInfo.productId).then((response) => {
|
||||
// 固定增加设备系统相关权限
|
||||
this.sharePermissionList = [
|
||||
{
|
||||
identifier: 'timer',
|
||||
modelName: '设备定时',
|
||||
remark: '定时执行任务',
|
||||
},
|
||||
{
|
||||
identifier: 'log',
|
||||
modelName: '设备日志',
|
||||
remark: '包含事件日志和指令日志',
|
||||
},
|
||||
{
|
||||
identifier: 'monitor',
|
||||
modelName: '实时监测',
|
||||
remark: '下发实时监测指令后,图表实时显示设备上报数据',
|
||||
},
|
||||
{
|
||||
identifier: 'statistic',
|
||||
modelName: '监测统计',
|
||||
remark: '图表显示存储的历史监测数据',
|
||||
},
|
||||
];
|
||||
this.sharePermissionList = this.sharePermissionList.concat(response.data);
|
||||
|
||||
// 设置选中
|
||||
if (perms.length > 0) {
|
||||
for (let i = 0; i < this.sharePermissionList.length; i++) {
|
||||
for (let j = 0; j < perms.length; j++) {
|
||||
if (this.sharePermissionList[i].identifier == perms[j]) {
|
||||
this.$nextTick(() => {
|
||||
this.$refs.multipleTable.toggleRowSelection(this.sharePermissionList[i], true);
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
},
|
||||
/** 删除按钮操作 */
|
||||
handleDelete(row) {
|
||||
const deviceUser = row;
|
||||
this.$modal.confirm('确认取消分享设备?').then(function () {
|
||||
return delDeviceUser(deviceUser);
|
||||
}).then(() => {
|
||||
this.getList();
|
||||
this.$modal.msgSuccess("取消分享成功");
|
||||
}).catch(() => {});
|
||||
},
|
||||
/** 导出按钮操作 */
|
||||
handleExport() {
|
||||
this.download('iot/deviceUser/export', {
|
||||
...this.queryParams
|
||||
}, `deviceUser_${new Date().getTime()}.xlsx`)
|
||||
},
|
||||
// 选择用户
|
||||
selectUser() {
|
||||
this.devices = [this.device]
|
||||
this.$refs.userList.openSelectUser = true;
|
||||
},
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
this.permsLoading = false;
|
||||
});
|
||||
},
|
||||
// 重置查询
|
||||
resetUserQuery() {
|
||||
this.resetForm('queryForm');
|
||||
this.reset();
|
||||
},
|
||||
// 关闭选择用户
|
||||
closeSelectUser() {
|
||||
this.open = false;
|
||||
this.resetUserQuery();
|
||||
},
|
||||
// 多选框选中数据
|
||||
handleSelectionChange(selection) {
|
||||
this.form.perms = selection.map((x) => x.identifier).join(',');
|
||||
},
|
||||
// 全选事件处理
|
||||
handleSelectionAll(selection) {
|
||||
this.form.perms = selection.map((x) => x.identifier).join(',');
|
||||
},
|
||||
/** 提交按钮 */
|
||||
submitForm() {
|
||||
if (this.type == 2) {
|
||||
// 更新设备用户
|
||||
updateDeviceUser(this.form).then((response) => {
|
||||
this.$modal.msgSuccess('更新成功');
|
||||
this.resetUserQuery();
|
||||
this.open = false;
|
||||
this.getList();
|
||||
});
|
||||
} else if (this.type == 1) {
|
||||
// 添加设备用户
|
||||
this.form.deviceId = this.deviceInfo.deviceId;
|
||||
this.form.deviceName = this.deviceInfo.deviceName;
|
||||
addDeviceUser(this.form).then((response) => {
|
||||
this.$modal.msgSuccess('新增成功');
|
||||
this.resetUserQuery();
|
||||
this.open = false;
|
||||
this.getList();
|
||||
});
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -103,6 +103,10 @@ export default {
|
||||
getList() {
|
||||
this.loading = true;
|
||||
listProduct(this.queryParams).then(response => {
|
||||
//产品列表初始化isSelect值,用于单选
|
||||
for (let i = 0; i < response.rows.length; i++) {
|
||||
response.rows[i].isSelect = false;
|
||||
}
|
||||
this.productList = response.rows;
|
||||
this.total = response.total;
|
||||
if (this.productId != 0) {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,264 +1,289 @@
|
||||
<template>
|
||||
<div style="padding:6px;">
|
||||
<el-card v-show="showSearch" style="margin-bottom:6px;">
|
||||
<el-form :model="queryParams" ref="queryForm" :inline="true" label-width="68px" style="margin-bottom:-20px;">
|
||||
<el-form-item label="分组名称" prop="groupName">
|
||||
<el-input v-model="queryParams.groupName" placeholder="请输入分组名称" clearable size="small" @keyup.enter.native="handleQuery" />
|
||||
</el-form-item>
|
||||
<el-form-item label="我的分组" v-if="isAdmin" style="margin:0 20px;">
|
||||
<el-switch v-model="myGroup" @change="myGroupChange"></el-switch>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
||||
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
||||
</el-form-item>
|
||||
<el-form-item style="float:right;">
|
||||
<el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd" v-hasPermi="['iot:group:add']">新增</el-button>
|
||||
</el-form-item>
|
||||
<div style="padding: 6px">
|
||||
<el-card v-show="showSearch" style="margin-bottom: 6px">
|
||||
<el-form ref="queryForm" :model="queryParams" :inline="true" label-width="68px" style="margin-bottom: -20px">
|
||||
<el-form-item label="分组名称" prop="groupName">
|
||||
<el-input v-model="queryParams.groupName" placeholder="请输入分组名称" clearable size="small"
|
||||
@keyup.enter.native="handleQuery" />
|
||||
</el-form-item>
|
||||
<el-form-item v-if="isAdmin" label="我的分组" style="margin: 0 20px">
|
||||
<el-switch v-model="myGroup" @change="myGroupChange"></el-switch>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
||||
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
||||
</el-form-item>
|
||||
<el-form-item style="float: right">
|
||||
<el-button v-hasPermi="['iot:group:add']" type="primary" plain icon="el-icon-plus" size="mini"
|
||||
@click="handleAdd">新增</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-card>
|
||||
|
||||
<el-card style="padding-bottom: 100px">
|
||||
<el-table v-loading="loading" :data="groupList" border @selection-change="handleSelectionChange">
|
||||
<el-table-column label="分组名称" align="center" prop="groupName" width="200" />
|
||||
<el-table-column label="分组排序" align="center" prop="groupOrder" width="100" />
|
||||
<el-table-column label="创建时间" align="center" prop="createTime" width="180">
|
||||
<template slot-scope="scope">
|
||||
<span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column v-if="isAdmin" label="所属用户" align="center" prop="userName" width="100" />
|
||||
<el-table-column label="备注" align="left" header-align="center" prop="remark" />
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="320">
|
||||
<template slot-scope="scope">
|
||||
<el-button v-hasPermi="['iot:device:query']" size="small" type="warning" style="padding: 5px"
|
||||
icon="el-icon-search" @click="handleViewDevice(scope.row.groupId)">查看设备</el-button>
|
||||
<el-button v-hasPermi="['iot:group:add']" size="small" type="success" style="padding: 5px" icon="el-icon-edit"
|
||||
@click="selectDevice(scope.row)">添加设备</el-button>
|
||||
<el-button v-hasPermi="['iot:group:edit']" size="small" type="primary" style="padding: 5px"
|
||||
icon="el-icon-edit" @click="handleUpdate(scope.row)">修改</el-button>
|
||||
<el-button v-hasPermi="['iot:group:remove']" size="small" type="danger" style="padding: 5px"
|
||||
icon="el-icon-delete" @click="handleDelete(scope.row)">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
|
||||
@pagination="getList" />
|
||||
|
||||
<!-- 分组设备列表 -->
|
||||
<deviceList ref="groupDeviceList" :group="group"></deviceList>
|
||||
|
||||
<!-- 添加或修改设备分组对话框 -->
|
||||
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
|
||||
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
||||
<el-form-item label="分组名称" prop="groupName">
|
||||
<el-input v-model="form.groupName" placeholder="请输入分组名称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="分组排序" prop="groupOrder">
|
||||
<el-input v-model="form.groupOrder" type="number" placeholder="请输入分组排序" />
|
||||
</el-form-item>
|
||||
<el-form-item label="备注" prop="remark">
|
||||
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button type="primary" @click="submitForm">确 定</el-button>
|
||||
<el-button @click="cancel">取 消</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</el-card>
|
||||
|
||||
<el-card style="padding-bottom:100px;">
|
||||
<el-table v-loading="loading" :data="groupList" @selection-change="handleSelectionChange" border>
|
||||
<el-table-column label="分组名称" align="center" prop="groupName" width="200" />
|
||||
<el-table-column label="分组排序" align="center" prop="groupOrder" width="100" />
|
||||
<el-table-column label="创建时间" align="center" prop="createTime" width="180">
|
||||
<template slot-scope="scope">
|
||||
<span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="备注" align="left" prop="remark" />
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="320">
|
||||
<template slot-scope="scope">
|
||||
<el-button size="small" type="warning" style="padding:5px;" icon="el-icon-search" @click="handleViewDevice(scope.row.groupId)" v-hasPermi="['iot:device:query']">查看设备</el-button>
|
||||
<el-button size="small" type="success" style="padding:5px;" icon="el-icon-edit" @click="selectDevice(scope.row)" v-hasPermi="['iot:group:edit']">添加设备</el-button>
|
||||
<el-button size="small" type="primary" style="padding:5px;" icon="el-icon-edit" @click="handleUpdate(scope.row)" v-hasPermi="['iot:group:edit']">修改</el-button>
|
||||
<el-button size="small" type="danger" style="padding:5px;" icon="el-icon-delete" @click="handleDelete(scope.row)" v-hasPermi="['iot:group:remove']">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />
|
||||
|
||||
<!-- 分组设备列表 -->
|
||||
<deviceList ref="groupDeviceList" :group="group"></deviceList>
|
||||
|
||||
<!-- 添加或修改设备分组对话框 -->
|
||||
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
|
||||
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
||||
<el-form-item label="分组名称" prop="groupName">
|
||||
<el-input v-model="form.groupName" placeholder="请输入分组名称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="分组排序" prop="groupOrder">
|
||||
<el-input v-model="form.groupOrder" type="number" placeholder="请输入分组排序" />
|
||||
</el-form-item>
|
||||
<el-form-item label="备注" prop="remark">
|
||||
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button type="primary" @click="submitForm">确 定</el-button>
|
||||
<el-button @click="cancel">取 消</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
|
||||
</el-card>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import deviceList from "./device-list"
|
||||
import {
|
||||
listGroup,
|
||||
getGroup,
|
||||
delGroup,
|
||||
addGroup,
|
||||
updateGroup,
|
||||
} from "@/api/iot/group";
|
||||
import deviceList from './device-list'
|
||||
import { listGroup, getGroup, delGroup, addGroup, updateGroup } from '@/api/iot/group'
|
||||
import {getUserId} from "@/utils/auth";
|
||||
|
||||
export default {
|
||||
name: "Group",
|
||||
components: {
|
||||
deviceList
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
// 是否管理员
|
||||
isAdmin: false,
|
||||
// 我的分组
|
||||
myGroup: false,
|
||||
// 遮罩层
|
||||
loading: true,
|
||||
// 选中数组
|
||||
ids: [],
|
||||
// 非单个禁用
|
||||
single: true,
|
||||
// 非多个禁用
|
||||
multiple: true,
|
||||
// 显示搜索条件
|
||||
showSearch: true,
|
||||
// 总条数
|
||||
total: 0,
|
||||
// 设备分组表格数据
|
||||
groupList: [],
|
||||
// 弹出层标题
|
||||
title: "",
|
||||
// 是否显示弹出层
|
||||
open: false,
|
||||
// 查询参数
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
groupName: null,
|
||||
userId: null,
|
||||
},
|
||||
// 设备分组
|
||||
group: {},
|
||||
// 表单参数
|
||||
form: {},
|
||||
// 表单校验
|
||||
rules: {
|
||||
groupName: [{
|
||||
required: true,
|
||||
message: "分组名称不能为空",
|
||||
trigger: "blur"
|
||||
}],
|
||||
groupOrder: [{
|
||||
required: true,
|
||||
message: "分组排序不能为空,最大值为99",
|
||||
trigger: "blur"
|
||||
}],
|
||||
}
|
||||
};
|
||||
},
|
||||
created() {
|
||||
this.getList();
|
||||
this.init();
|
||||
},
|
||||
methods: {
|
||||
init() {
|
||||
if (this.$store.state.user.roles.indexOf("tenant") === -1 && this.$store.state.user.roles.indexOf("general") === -1) {
|
||||
this.isAdmin = true
|
||||
}
|
||||
},
|
||||
// 我的分组改变事件
|
||||
myGroupChange() {
|
||||
this.queryParams.userId = this.myGroup ? this.$store.state.user.userId : null;
|
||||
},
|
||||
/** 查看设备按钮操作 */
|
||||
handleViewDevice(groupId) {
|
||||
this.$router.push({
|
||||
path: '/iot/device',
|
||||
query: {
|
||||
t: Date.now(),
|
||||
groupId: groupId,
|
||||
}
|
||||
});
|
||||
},
|
||||
/** 查询设备分组列表 */
|
||||
getList() {
|
||||
this.loading = true;
|
||||
listGroup(this.queryParams).then(response => {
|
||||
this.groupList = response.rows;
|
||||
this.total = response.total;
|
||||
this.loading = false;
|
||||
});
|
||||
},
|
||||
// 取消按钮
|
||||
cancel() {
|
||||
this.open = false;
|
||||
this.reset();
|
||||
},
|
||||
// 表单重置
|
||||
reset() {
|
||||
this.form = {
|
||||
groupId: null,
|
||||
groupName: null,
|
||||
groupOrder: null,
|
||||
userId: null,
|
||||
userName: null,
|
||||
delFlag: null,
|
||||
createBy: null,
|
||||
createTime: null,
|
||||
updateBy: null,
|
||||
updateTime: null,
|
||||
remark: null
|
||||
};
|
||||
this.resetForm("form");
|
||||
},
|
||||
/** 搜索按钮操作 */
|
||||
handleQuery() {
|
||||
this.queryParams.pageNum = 1;
|
||||
this.getList();
|
||||
},
|
||||
/** 重置按钮操作 */
|
||||
resetQuery() {
|
||||
this.resetForm("queryForm");
|
||||
this.handleQuery();
|
||||
},
|
||||
// 多选框选中数据
|
||||
handleSelectionChange(selection) {
|
||||
this.ids = selection.map(item => item.groupId)
|
||||
this.single = selection.length !== 1
|
||||
this.multiple = !selection.length
|
||||
},
|
||||
/** 新增按钮操作 */
|
||||
handleAdd() {
|
||||
this.reset();
|
||||
this.open = true;
|
||||
this.title = "添加设备分组";
|
||||
},
|
||||
/** 修改按钮操作 */
|
||||
handleUpdate(row) {
|
||||
this.reset();
|
||||
const groupId = row.groupId || this.ids
|
||||
getGroup(groupId).then(response => {
|
||||
this.form = response.data;
|
||||
this.open = true;
|
||||
this.title = "修改设备分组";
|
||||
});
|
||||
},
|
||||
/** 选择设备 */
|
||||
selectDevice(row) {
|
||||
this.group = row;
|
||||
// 刷新子组件
|
||||
this.$refs.groupDeviceList.openDeviceList = true;
|
||||
},
|
||||
/** 提交按钮 */
|
||||
submitForm() {
|
||||
this.$refs["form"].validate(valid => {
|
||||
if (valid) {
|
||||
if (this.form.groupId != null) {
|
||||
updateGroup(this.form).then(response => {
|
||||
this.$modal.msgSuccess("修改成功");
|
||||
this.open = false;
|
||||
this.getList();
|
||||
});
|
||||
} else {
|
||||
addGroup(this.form).then(response => {
|
||||
this.$modal.msgSuccess("新增成功");
|
||||
this.open = false;
|
||||
this.getList();
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
/** 删除按钮操作 */
|
||||
handleDelete(row) {
|
||||
const groupIds = row.groupId || this.ids;
|
||||
this.$modal.confirm('是否确认删除设备分组编号为"' + groupIds + '"的数据项?').then(function () {
|
||||
return delGroup(groupIds);
|
||||
}).then(() => {
|
||||
this.getList();
|
||||
this.$modal.msgSuccess("删除成功");
|
||||
}).catch(() => {});
|
||||
},
|
||||
/** 导出按钮操作 */
|
||||
handleExport() {
|
||||
this.download('iot/group/export', {
|
||||
...this.queryParams
|
||||
}, `group_${new Date().getTime()}.xlsx`)
|
||||
},
|
||||
name: 'Group',
|
||||
components: {
|
||||
deviceList,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
// 是否管理员
|
||||
isAdmin: false,
|
||||
// 我的分组
|
||||
myGroup: false,
|
||||
// 遮罩层
|
||||
loading: true,
|
||||
// 选中数组
|
||||
ids: [],
|
||||
// 非单个禁用
|
||||
single: true,
|
||||
// 非多个禁用
|
||||
multiple: true,
|
||||
// 显示搜索条件
|
||||
showSearch: true,
|
||||
// 总条数
|
||||
total: 0,
|
||||
// 设备分组表格数据
|
||||
groupList: [],
|
||||
// 弹出层标题
|
||||
title: '',
|
||||
// 是否显示弹出层
|
||||
open: false,
|
||||
// 查询参数
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
groupName: null,
|
||||
userId: null,
|
||||
},
|
||||
// 设备分组
|
||||
group: {},
|
||||
// 表单参数
|
||||
form: {},
|
||||
// 表单校验
|
||||
rules: {
|
||||
groupName: [
|
||||
{
|
||||
required: true,
|
||||
message: '分组名称不能为空',
|
||||
trigger: 'blur',
|
||||
},
|
||||
{
|
||||
min: 1,
|
||||
max: 64,
|
||||
message: '分组名称不能少于1个字符和超过64字符',
|
||||
},
|
||||
],
|
||||
groupOrder: [
|
||||
{
|
||||
required: true,
|
||||
message: '分组排序不能为空,最大值为99',
|
||||
trigger: 'blur',
|
||||
},
|
||||
{
|
||||
max: 128,
|
||||
message: '分组排序不能少于1个位和超过10位',
|
||||
trigger: 'blur',
|
||||
},
|
||||
],
|
||||
},
|
||||
}
|
||||
};
|
||||
},
|
||||
created() {
|
||||
this.getList()
|
||||
this.init()
|
||||
},
|
||||
methods: {
|
||||
init() {
|
||||
if (this.$store.state.user.roles.indexOf('tenant') === -1 && this.$store.state.user.roles.indexOf('general') === -1) {
|
||||
this.isAdmin = true
|
||||
}
|
||||
},
|
||||
// 我的分组改变事件
|
||||
myGroupChange() {
|
||||
this.queryParams.userId = this.myGroup ? getUserId() : null;
|
||||
this.handleQuery();
|
||||
},
|
||||
/** 查看设备按钮操作 */
|
||||
handleViewDevice(groupId) {
|
||||
this.$router.push({
|
||||
path: '/iot/device',
|
||||
query: {
|
||||
t: Date.now(),
|
||||
groupId: groupId,
|
||||
},
|
||||
})
|
||||
},
|
||||
/** 查询设备分组列表 */
|
||||
getList() {
|
||||
this.loading = true
|
||||
listGroup(this.queryParams).then((response) => {
|
||||
this.groupList = response.rows
|
||||
this.total = response.total
|
||||
this.loading = false
|
||||
})
|
||||
},
|
||||
// 取消按钮
|
||||
cancel() {
|
||||
this.open = false
|
||||
this.reset()
|
||||
},
|
||||
// 表单重置
|
||||
reset() {
|
||||
this.form = {
|
||||
groupId: null,
|
||||
groupName: null,
|
||||
groupOrder: null,
|
||||
userId: null,
|
||||
userName: null,
|
||||
delFlag: null,
|
||||
createBy: null,
|
||||
createTime: null,
|
||||
updateBy: null,
|
||||
updateTime: null,
|
||||
remark: null,
|
||||
}
|
||||
this.resetForm('form')
|
||||
},
|
||||
/** 搜索按钮操作 */
|
||||
handleQuery() {
|
||||
this.queryParams.pageNum = 1
|
||||
this.getList()
|
||||
},
|
||||
/** 重置按钮操作 */
|
||||
resetQuery() {
|
||||
this.resetForm('queryForm')
|
||||
this.handleQuery()
|
||||
},
|
||||
// 多选框选中数据
|
||||
handleSelectionChange(selection) {
|
||||
this.ids = selection.map((item) => item.groupId)
|
||||
this.single = selection.length !== 1
|
||||
this.multiple = !selection.length
|
||||
},
|
||||
/** 新增按钮操作 */
|
||||
handleAdd() {
|
||||
this.reset()
|
||||
this.open = true
|
||||
this.title = '添加设备分组'
|
||||
},
|
||||
/** 修改按钮操作 */
|
||||
handleUpdate(row) {
|
||||
this.reset()
|
||||
const groupId = row.groupId || this.ids
|
||||
getGroup(groupId).then((response) => {
|
||||
this.form = response.data
|
||||
this.open = true
|
||||
this.title = '修改设备分组'
|
||||
})
|
||||
},
|
||||
/** 选择设备 */
|
||||
selectDevice(row) {
|
||||
this.group = row
|
||||
// 刷新子组件
|
||||
this.$refs.groupDeviceList.openDeviceList = true
|
||||
},
|
||||
/** 提交按钮 */
|
||||
submitForm() {
|
||||
this.$refs['form'].validate((valid) => {
|
||||
if (valid) {
|
||||
if (this.form.groupId != null) {
|
||||
updateGroup(this.form).then((response) => {
|
||||
this.$modal.msgSuccess('修改成功')
|
||||
this.open = false
|
||||
this.getList()
|
||||
})
|
||||
} else {
|
||||
addGroup(this.form).then((response) => {
|
||||
this.$modal.msgSuccess('新增成功')
|
||||
this.open = false
|
||||
this.getList()
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
/** 删除按钮操作 */
|
||||
handleDelete(row) {
|
||||
const groupIds = row.groupId || this.ids
|
||||
this.$modal
|
||||
.confirm('是否确认删除设备分组编号为"' + groupIds + '"的数据项?')
|
||||
.then(function () {
|
||||
return delGroup(groupIds)
|
||||
})
|
||||
.then(() => {
|
||||
this.getList()
|
||||
this.$modal.msgSuccess('删除成功')
|
||||
})
|
||||
.catch(() => { })
|
||||
},
|
||||
/** 导出按钮操作 */
|
||||
handleExport() {
|
||||
this.download(
|
||||
'iot/group/export',
|
||||
{
|
||||
...this.queryParams,
|
||||
},
|
||||
`group_${new Date().getTime()}.xlsx`
|
||||
)
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
324
vue/src/views/iot/netty/clients.vue
Normal file
324
vue/src/views/iot/netty/clients.vue
Normal file
@@ -0,0 +1,324 @@
|
||||
<template>
|
||||
<div style="padding: 6px">
|
||||
<el-card v-show="showSearch" style="margin-bottom: 6px">
|
||||
<el-form @submit.native.prevent :model="queryParams" ref="queryForm" :inline="true" label-width="68px" style="margin-bottom: -20px">
|
||||
<el-form-item label="客户端" prop="clientId">
|
||||
<el-input v-model="queryParams.clientId" placeholder="请输入客户端ID" clearable size="small" @keyup.enter.native="handleQuery" />
|
||||
</el-form-item>
|
||||
<el-form-item prop="isClient">
|
||||
<el-checkbox v-model="queryParams.isClient" true-label="1" false-label="0">只看设备端</el-checkbox>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
||||
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-card>
|
||||
|
||||
<el-tabs type="border-card" v-model="serverType" @tab-click="handleClick" style="flex: 1; height: 800px; margin-bottom: 5px">
|
||||
<el-tab-pane label="MQTT客户端" name="MQTT">
|
||||
<el-table v-loading="loading" :data="clientList">
|
||||
<el-table-column label="客户端ID" align="left" header-align="center" prop="clientId">
|
||||
<template slot-scope="scope">
|
||||
<el-link :underline="false" type="primary" @click.native="handleOpen(scope.row)">{{ scope.row.clientId }}</el-link>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="类型" align="center" prop="type">
|
||||
<template slot-scope="scope">
|
||||
<el-tag type="danger" v-if="scope.row.clientId.indexOf('server') == 0">服务端</el-tag>
|
||||
<el-tag type="success" v-else-if="scope.row.clientId.indexOf('web') == 0">Web端</el-tag>
|
||||
<el-tag type="warning" v-else-if="scope.row.clientId.indexOf('phone') == 0">移动端</el-tag>
|
||||
<el-tag type="info" v-else-if="scope.row.clientId.indexOf('test') == 0">测试端</el-tag>
|
||||
<el-tag type="primary" v-else>设备端</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="连接状态" align="center" prop="connected">
|
||||
<template slot-scope="scope">
|
||||
<el-tag type="success" v-if="scope.row.connected">已连接</el-tag>
|
||||
<el-tag type="info" v-else>已断开</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="心跳(秒)" align="center" prop="keepAlive" width="100" />
|
||||
<el-table-column label="账号" align="center" prop="username" width="100px" />
|
||||
<el-table-column label="当前订阅数量" align="center" prop="topicCount" width="100" />
|
||||
<el-table-column label="连接时间" align="center" prop="connected_at" />
|
||||
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||
<template #default="scope">
|
||||
<el-button link type="primary" icon="Edit" @click="clickClientOut(scope.row)">踢出</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />
|
||||
|
||||
<!-- MQTT客户端详细 -->
|
||||
<el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
|
||||
<el-tabs v-model="activeName" tab-position="top" style="padding: 10px">
|
||||
<el-tab-pane name="subscribe">
|
||||
<span slot="label">订阅列表</span>
|
||||
<el-row :gutter="10" class="mb8"></el-row>
|
||||
<el-table :data="subscribeList" size="mini">
|
||||
<el-table-column label="主题" align="center" prop="topicName" />
|
||||
<el-table-column label="QoS" align="center" prop="qos" />
|
||||
</el-table>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
</el-dialog>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane label="TCP客户端" name="TCP">
|
||||
<el-table v-loading="loading" :data="clientList">
|
||||
<el-table-column label="客户端ID" align="left" header-align="center" prop="clientId"></el-table-column>
|
||||
<el-table-column label="类型" align="center" prop="type">
|
||||
<template slot-scope="scope">
|
||||
<el-tag type="danger" v-if="scope.row.clientId.indexOf('server') == 0">服务端</el-tag>
|
||||
<el-tag type="success" v-else-if="scope.row.clientId.indexOf('web') == 0">Web端</el-tag>
|
||||
<el-tag type="warning" v-else-if="scope.row.clientId.indexOf('phone') == 0">移动端</el-tag>
|
||||
<el-tag type="info" v-else-if="scope.row.clientId.indexOf('test') == 0">测试端</el-tag>
|
||||
<el-tag type="primary" v-else>设备端</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="连接状态" align="center" prop="connected">
|
||||
<template slot-scope="scope">
|
||||
<el-tag type="success" v-if="scope.row.connected">已连接</el-tag>
|
||||
<el-tag type="info" v-else>已断开</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="心跳(秒)" align="center" prop="keepAlive" width="100" />
|
||||
<el-table-column label="连接时间" align="center" prop="connected_at" />
|
||||
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||
<template #default="scope">
|
||||
<el-button link type="primary" icon="Edit" @click="clickClientOut(scope.row)">踢出</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />
|
||||
|
||||
<!-- MQTT客户端详细 -->
|
||||
<el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
|
||||
<el-tabs v-model="activeName" tab-position="top" style="padding: 10px">
|
||||
<el-tab-pane name="subscribe">
|
||||
<span slot="label">订阅列表</span>
|
||||
<el-row :gutter="10" class="mb8"></el-row>
|
||||
<el-table :data="subscribeList" size="mini">
|
||||
<el-table-column label="主题" align="center" prop="topicName" />
|
||||
<el-table-column label="QoS" align="center" prop="qos" />
|
||||
</el-table>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
</el-dialog>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
|
||||
<!-- 添加或修改订阅对话框 -->
|
||||
<el-dialog title="添加订阅" :visible.sync="subscribeOpen" width="800px" append-to-body>
|
||||
<el-form ref="subscribeForm" :model="subscribeForm" :rules="rules" label-width="60px">
|
||||
<el-row :gutter="20">
|
||||
<el-col :span="12">
|
||||
<el-form-item label="主题" prop="topic">
|
||||
<el-input v-model="subscribeForm.topic" placeholder="请输入主题" />
|
||||
</el-form-item>
|
||||
<el-form-item label="Qos" prop="qos">
|
||||
<el-select v-model="subscribeForm.qos" placeholder="请选择消息类型">
|
||||
<el-option key="0" label="0" value="0"></el-option>
|
||||
<el-option key="1" label="1" value="1"></el-option>
|
||||
<el-option key="2" label="2" value="2"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button type="primary" @click="submitForm">添 加 订 阅</el-button>
|
||||
<el-button @click="cancelSubscribe">取 消</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { clientOut, listNettyMqttClient } from '@/api/iot/netty';
|
||||
|
||||
export default {
|
||||
name: 'Category',
|
||||
data() {
|
||||
return {
|
||||
// 非单个禁用
|
||||
single: true,
|
||||
// 遮罩层
|
||||
loading: true,
|
||||
loadSubscribeing: true,
|
||||
// 显示搜索条件
|
||||
showSearch: true,
|
||||
// 总条数
|
||||
total: 0,
|
||||
// 产品分类表格数据
|
||||
clientList: [],
|
||||
// 弹出层标题
|
||||
title: '',
|
||||
// 是否显示弹出层
|
||||
open: false,
|
||||
// 是否显示添加订阅弹出层
|
||||
subscribeOpen: false,
|
||||
// 查询参数
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
clientId: null,
|
||||
isClient: 0,
|
||||
serverCode: 'MQTT',
|
||||
},
|
||||
// 表单参数
|
||||
form: {},
|
||||
// 选中选项卡
|
||||
activeName: 'subscribe',
|
||||
//订阅列表数据
|
||||
subscribeList: [],
|
||||
//订阅数据
|
||||
subscribe: {
|
||||
topic: '',
|
||||
clientId: '',
|
||||
},
|
||||
//添加订阅表单参数
|
||||
subscribeForm: {
|
||||
qos: '0',
|
||||
},
|
||||
//客户端ID
|
||||
clientId: '',
|
||||
//服务协议类型
|
||||
serverType: 'MQTT',
|
||||
// 表单校验
|
||||
rules: {
|
||||
topic: [
|
||||
{
|
||||
required: true,
|
||||
message: '主题不能为空',
|
||||
trigger: 'blur',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
},
|
||||
created() {
|
||||
this.getList();
|
||||
},
|
||||
methods: {
|
||||
/** 查询客户端列表 */
|
||||
getList() {
|
||||
this.loading = true;
|
||||
listNettyMqttClient(this.queryParams).then((response) => {
|
||||
this.clientList = response.data;
|
||||
this.total = response.total;
|
||||
this.loading = false;
|
||||
});
|
||||
},
|
||||
|
||||
/*将客户端踢出*/
|
||||
clickClientOut(row) {
|
||||
const params = { clientId: row.clientId };
|
||||
clientOut(params).then((res) => {
|
||||
//刷新列表
|
||||
this.getList();
|
||||
});
|
||||
},
|
||||
|
||||
/*tabs切换*/
|
||||
handleClick() {
|
||||
this.queryParams.serverCode = this.serverType;
|
||||
this.getList();
|
||||
},
|
||||
|
||||
/** 查询客户端订阅列表 */
|
||||
getSubscribeList(clientId) {
|
||||
this.clientId = clientId;
|
||||
this.loadSubscribeing = true;
|
||||
getSubscriptionsByClientId(clientId).then((res) => {
|
||||
this.subscribeList = res.data.data;
|
||||
this.loadSubscribeing = false;
|
||||
});
|
||||
},
|
||||
|
||||
// 取消按钮
|
||||
cancel() {
|
||||
this.open = false;
|
||||
this.reset();
|
||||
},
|
||||
/** 搜索按钮操作 */
|
||||
handleQuery() {
|
||||
this.queryParams.pageNum = 1;
|
||||
this.getList();
|
||||
},
|
||||
/** 重置按钮操作 */
|
||||
resetQuery() {
|
||||
this.resetForm('queryForm');
|
||||
this.handleQuery();
|
||||
},
|
||||
/** 断开客户端连接 */
|
||||
handleDelete(row) {
|
||||
const clientId = row.clientId;
|
||||
this.$modal
|
||||
.confirm('是否确认删除MQTT客户端编号为"' + clientId + '"的数据项?')
|
||||
.then(function () {
|
||||
return eliminateClient(clientId);
|
||||
})
|
||||
.then(() => {
|
||||
this.getList();
|
||||
this.$modal.msgSuccess('删除成功');
|
||||
})
|
||||
.catch(() => {});
|
||||
},
|
||||
//取消主题订阅
|
||||
handleUnsubscribe(row) {
|
||||
const clientId = row.clientId;
|
||||
const topic = row.topic;
|
||||
this.$modal
|
||||
.confirm('是否确认取消订阅主题为"' + topic + '"的数据项?')
|
||||
.then(function () {
|
||||
const param = {};
|
||||
param.topic = topic;
|
||||
param.clientId = clientId;
|
||||
return unsubscribe(param);
|
||||
})
|
||||
.then(() => {
|
||||
this.getSubscribeList(clientId);
|
||||
this.$modal.msgSuccess('取消订阅成功');
|
||||
})
|
||||
.catch(() => {});
|
||||
},
|
||||
//查看客户端详情
|
||||
handleOpen(row) {
|
||||
this.open = true;
|
||||
this.title = '详情';
|
||||
this.subscribeList = row.topics;
|
||||
console.log(this.subscribeList);
|
||||
},
|
||||
|
||||
//添加订阅
|
||||
handleAdd() {
|
||||
this.subscribeOpen = true;
|
||||
},
|
||||
//提交添加订阅表单
|
||||
submitForm() {
|
||||
this.subscribeForm.clientId = this.clientId;
|
||||
console.log(this.subscribeForm);
|
||||
this.$refs['subscribeForm'].validate((valid) => {
|
||||
if (valid) {
|
||||
addSubscribe(this.subscribeForm).then((response) => {
|
||||
this.$modal.msgSuccess('新增订阅成功');
|
||||
this.subscribeOpen = false;
|
||||
this.getSubscribeList(this.clientId);
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
cancelSubscribe() {
|
||||
this.subscribeOpen = false;
|
||||
this.resetForm('subscribeForm');
|
||||
//刷新列表
|
||||
this.getSubscribeList(this.clientId);
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
346
vue/src/views/iot/netty/mqtt.vue
Normal file
346
vue/src/views/iot/netty/mqtt.vue
Normal file
@@ -0,0 +1,346 @@
|
||||
<template>
|
||||
<div style="padding: 6px">
|
||||
<el-card style="margin-bottom: 6px">
|
||||
<el-row :gutter="120">
|
||||
<el-col :xs="24" :sm="24" :md="24" :lg="8" :xl="8">
|
||||
<h3 style="font-weight: bold">Mqtt 统计指标</h3>
|
||||
<el-row :gutter="20" class="panel-group">
|
||||
<el-col :span="24" class="card-panel-col" style="margin-bottom: 17px">
|
||||
<div class="card-panel">
|
||||
<div class="card-panel-icon-wrapper icon-orange">
|
||||
<svg-icon icon-class="guide" class-name="card-panel-icon" />
|
||||
</div>
|
||||
<div class="card-panel-description">
|
||||
<div>
|
||||
<div class="card-panel-text">发送消息</div>
|
||||
<count-to :start-val="0" :end-val="this.static['send_total']" :duration="3000" class="card-panel-num" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</el-col>
|
||||
<el-col :span="24" class="card-panel-col" style="margin-bottom: 18px">
|
||||
<div class="card-panel">
|
||||
<div class="card-panel-icon-wrapper icon-green">
|
||||
<svg-icon icon-class="receiver" class-name="card-panel-icon" />
|
||||
</div>
|
||||
|
||||
<div class="card-panel-description">
|
||||
<div>
|
||||
<div class="card-panel-text">接收消息</div>
|
||||
<count-to :start-val="0" :end-val="this.static['receive_total']" :duration="3000" class="card-panel-num" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</el-col>
|
||||
<el-col :span="24" class="card-panel-col" style="margin-bottom: 17px">
|
||||
<div class="card-panel">
|
||||
<div class="card-panel-icon-wrapper icon-orange">
|
||||
<svg-icon icon-class="authenticate" class-name="card-panel-icon" />
|
||||
</div>
|
||||
<div class="card-panel-description">
|
||||
<div class="card-panel-text">认证次数</div>
|
||||
<count-to :start-val="0" :end-val="this.static['auth_total']" :duration="1000" class="card-panel-num" />
|
||||
</div>
|
||||
</div>
|
||||
</el-col>
|
||||
<el-col :span="24" class="card-panel-col" style="margin-bottom: 18px">
|
||||
<div class="card-panel">
|
||||
<div class="card-panel-icon-wrapper icon-green">
|
||||
<svg-icon icon-class="connect" class-name="card-panel-icon" />
|
||||
</div>
|
||||
<div class="card-panel-description">
|
||||
<div class="card-panel-text">连接次数</div>
|
||||
<count-to :start-val="0" :end-val="this.static['connect_total']" :duration="1000" class="card-panel-num" />
|
||||
</div>
|
||||
</div>
|
||||
</el-col>
|
||||
<el-col :span="24" class="card-panel-col" style="margin-bottom: 17px">
|
||||
<div class="card-panel">
|
||||
<div class="card-panel-icon-wrapper icon-orange">
|
||||
<svg-icon icon-class="subscribe1" class-name="card-panel-icon" />
|
||||
</div>
|
||||
<div class="card-panel-description">
|
||||
<div class="card-panel-text">订阅次数</div>
|
||||
<count-to :start-val="0" :end-val="this.static['subscribe_total']" :duration="2000" class="card-panel-num" />
|
||||
</div>
|
||||
</div>
|
||||
</el-col>
|
||||
|
||||
<el-col :span="24" class="card-panel-col" style="margin-bottom: 17px">
|
||||
<div class="card-panel">
|
||||
<div class="card-panel-icon-wrapper icon-green">
|
||||
<svg-icon icon-class="message" class-name="card-panel-icon" />
|
||||
</div>
|
||||
<div class="card-panel-description">
|
||||
<div>
|
||||
<div class="card-panel-text">今日接收</div>
|
||||
<count-to :start-val="0" :end-val="this.static['today_received']" :duration="3000" class="card-panel-num" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</el-col>
|
||||
<el-col :span="24" class="card-panel-col" style="margin-bottom: 17px">
|
||||
<div class="card-panel">
|
||||
<div class="card-panel-icon-wrapper icon-orange">
|
||||
<svg-icon icon-class="subscribe1" class-name="card-panel-icon" />
|
||||
</div>
|
||||
<div class="card-panel-description">
|
||||
<div class="card-panel-text">今日发送</div>
|
||||
<count-to :start-val="0" :end-val="this.static['today_send']" :duration="2000" class="card-panel-num" />
|
||||
</div>
|
||||
</div>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-col>
|
||||
|
||||
<el-col :xs="24" :sm="24" :md="24" :lg="15" :xl="15">
|
||||
<div style="padding: 30px 0 85px">
|
||||
<div ref="pieTotal" style="height: 230px"></div>
|
||||
</div>
|
||||
<div ref="statsChart" style="height: 275px; margin: 20px 0 40px 0"></div>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-card>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { getNettyMqttStats, statisticNettyMqtt } from '@/api/iot/netty';
|
||||
import CountTo from 'vue-count-to';
|
||||
|
||||
export default {
|
||||
name: 'Mqtt',
|
||||
components: {
|
||||
CountTo,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
// mqtt状态数据
|
||||
stats: {},
|
||||
// mqtt统计信息
|
||||
static: {},
|
||||
};
|
||||
},
|
||||
created() {
|
||||
this.getMqttStats();
|
||||
this.statisticMqtt();
|
||||
},
|
||||
methods: {
|
||||
/** 查询mqtt统计*/
|
||||
statisticMqtt() {
|
||||
statisticNettyMqtt().then((response) => {
|
||||
this.static = response.data;
|
||||
this.totalMqtt();
|
||||
});
|
||||
},
|
||||
/** 查询mqtt状态数据*/
|
||||
getMqttStats() {
|
||||
getNettyMqttStats().then((response) => {
|
||||
this.stats = response.data;
|
||||
this.drawStats();
|
||||
});
|
||||
},
|
||||
// 绘制mqtt饼图
|
||||
totalMqtt() {
|
||||
// 基于准备好的dom,初始化echarts实例
|
||||
let myChart = this.$echarts.init(this.$refs.pieTotal);
|
||||
var option;
|
||||
option = {
|
||||
title: {
|
||||
text: 'Mqtt消息',
|
||||
left: 'left',
|
||||
textStyle: {
|
||||
fontSize: 16,
|
||||
},
|
||||
},
|
||||
tooltip: {
|
||||
trigger: 'item',
|
||||
},
|
||||
legend: {
|
||||
orient: 'vertical',
|
||||
left: 'right',
|
||||
},
|
||||
color: ['#E6A23C', '#F56C6C', '#DDD'],
|
||||
series: [
|
||||
{
|
||||
name: 'Mqtt消息 %',
|
||||
type: 'pie',
|
||||
radius: '55%',
|
||||
label: {
|
||||
show: true,
|
||||
},
|
||||
labelLine: {
|
||||
normal: {
|
||||
position: 'inner',
|
||||
show: false,
|
||||
},
|
||||
},
|
||||
data: [
|
||||
{
|
||||
value: this.static['send_total'],
|
||||
name: '发送消息总数',
|
||||
},
|
||||
{
|
||||
value: this.static['receive_total'],
|
||||
name: '接收消息总数',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
option && myChart.setOption(option);
|
||||
},
|
||||
/** 绘制mqtt状态统计 */
|
||||
drawStats() {
|
||||
// 基于准备好的dom,初始化echarts实例
|
||||
let myChart = this.$echarts.init(this.$refs.statsChart);
|
||||
var option;
|
||||
|
||||
option = {
|
||||
title: {
|
||||
text: 'Mqtt 状态数据',
|
||||
textStyle: {
|
||||
fontSize: 18,
|
||||
color: '#000',
|
||||
fontWeight: 800,
|
||||
},
|
||||
},
|
||||
tooltip: {
|
||||
trigger: 'axis',
|
||||
axisPointer: {
|
||||
type: 'shadow',
|
||||
},
|
||||
},
|
||||
legend: {},
|
||||
grid: {
|
||||
left: '3%',
|
||||
right: '4%',
|
||||
bottom: '3%',
|
||||
containLabel: true,
|
||||
},
|
||||
xAxis: {
|
||||
type: 'value',
|
||||
boundaryGap: [0, 0.01],
|
||||
},
|
||||
yAxis: {
|
||||
type: 'category',
|
||||
axisLabel: {
|
||||
fontSize: 14,
|
||||
},
|
||||
data: ['连接数量', '会话数量', '订阅数量', '路由数量', '保留消息'],
|
||||
},
|
||||
series: [
|
||||
{
|
||||
name: '当前数量',
|
||||
type: 'bar',
|
||||
data: [this.stats['connection_count'], this.stats['session_count'], this.stats['subscription_count'], this.stats['retain_count'], this.stats['retain_count']],
|
||||
itemStyle: {
|
||||
color: '#67C23A',
|
||||
},
|
||||
},
|
||||
{
|
||||
name: '累计总数',
|
||||
type: 'bar',
|
||||
data: [this.stats['connection_total'], this.stats['session_total'], this.stats['subscription_total'], this.stats['retain_total'], this.stats['retain_total']],
|
||||
itemStyle: {
|
||||
color: '#409EFF',
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
option && myChart.setOption(option);
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.panel-group {
|
||||
.card-panel-col {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.card-panel {
|
||||
height: 68px;
|
||||
cursor: pointer;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
color: #666;
|
||||
border: 1px solid #eee;
|
||||
border-radius: 5px;
|
||||
//box-shadow: 0px 1px 2px rgba(0, 0, 0, 0.08);
|
||||
background-color: #fff;
|
||||
|
||||
&:hover {
|
||||
.card-panel-icon-wrapper {
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.icon-blue {
|
||||
background: #36a3f7;
|
||||
}
|
||||
|
||||
.icon-green {
|
||||
background: #34bfa3;
|
||||
}
|
||||
|
||||
.icon-red {
|
||||
background: #f56c6c;
|
||||
}
|
||||
|
||||
.icon-orange {
|
||||
background: #e6a23c;
|
||||
}
|
||||
}
|
||||
|
||||
.icon-blue {
|
||||
color: #36a3f7;
|
||||
}
|
||||
|
||||
.icon-green {
|
||||
color: #34bfa3;
|
||||
}
|
||||
|
||||
.icon-red {
|
||||
color: #f56c6c;
|
||||
}
|
||||
|
||||
.icon-orange {
|
||||
color: #e6a23c;
|
||||
}
|
||||
|
||||
.card-panel-icon-wrapper {
|
||||
float: left;
|
||||
margin: 10px;
|
||||
padding: 10px;
|
||||
transition: all 0.38s ease-out;
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
.card-panel-icon {
|
||||
float: left;
|
||||
font-size: 30px;
|
||||
}
|
||||
|
||||
.card-panel-description {
|
||||
float: right;
|
||||
font-weight: bold;
|
||||
margin: 15px;
|
||||
margin-left: 0px;
|
||||
|
||||
.card-panel-text {
|
||||
line-height: 14px;
|
||||
color: rgba(0, 0, 0, 0.45);
|
||||
font-size: 14px;
|
||||
margin-bottom: 12px;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.card-panel-num {
|
||||
font-size: 18px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -1,165 +1,185 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="60px" v-if="isAdmin">
|
||||
<el-form-item label="标题" prop="title">
|
||||
<el-input v-model="queryParams.title" placeholder="请输入标题" clearable size="small" @keyup.enter.native="handleQuery" />
|
||||
</el-form-item>
|
||||
<el-form-item label="分类" prop="categoryName">
|
||||
<el-input v-model="queryParams.categoryName" placeholder="请输入分类名称" clearable size="small" @keyup.enter.native="handleQuery" />
|
||||
</el-form-item>
|
||||
<el-form-item label="置顶" prop="isTop">
|
||||
<el-select v-model="queryParams.isTop" placeholder="是否置顶" clearable size="small" style="width:100px;">
|
||||
<el-option v-for="dict in dict.type.iot_yes_no" :key="dict.value" :label="dict.label" :value="dict.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="轮播" prop="isBanner">
|
||||
<el-select v-model="queryParams.isBanner" placeholder="是否轮播" clearable size="small" style="width:100px;">
|
||||
<el-option v-for="dict in dict.type.iot_yes_no" :key="dict.value" :label="dict.label" :value="dict.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<div class="app-container">
|
||||
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="60px" v-if="isAdmin">
|
||||
<el-form-item label="标题" prop="title">
|
||||
<el-input v-model="queryParams.title" placeholder="请输入标题" clearable size="small"
|
||||
@keyup.enter.native="handleQuery" />
|
||||
</el-form-item>
|
||||
<el-form-item label="分类" prop="categoryName">
|
||||
<el-input v-model="queryParams.categoryName" placeholder="请输入分类名称" clearable size="small"
|
||||
@keyup.enter.native="handleQuery" />
|
||||
</el-form-item>
|
||||
<el-form-item label="置顶" prop="isTop">
|
||||
<el-select v-model="queryParams.isTop" placeholder="是否置顶" clearable size="small" style="width:100px;">
|
||||
<el-option v-for="dict in dict.type.iot_yes_no" :key="dict.value" :label="dict.label"
|
||||
:value="dict.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="轮播" prop="isBanner">
|
||||
<el-select v-model="queryParams.isBanner" placeholder="是否轮播" clearable size="small" style="width:100px;">
|
||||
<el-option v-for="dict in dict.type.iot_yes_no" :key="dict.value" :label="dict.label"
|
||||
:value="dict.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="发布" prop="status">
|
||||
<el-select v-model="queryParams.status" placeholder="选择状态" clearable size="small" style="width:100px;">
|
||||
<el-option v-for="dict in dict.type.iot_yes_no" :key="dict.value" :label="dict.label" :value="dict.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
||||
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd" v-hasPermi="['iot:news:add']">新增</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="success" plain icon="el-icon-edit" size="mini" :disabled="single" @click="handleUpdate" v-hasPermi="['iot:news:edit']">修改</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete" v-hasPermi="['iot:news:remove']">删除</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport" v-hasPermi="['iot:news:export']">导出</el-button>
|
||||
</el-col>
|
||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
|
||||
<el-table v-loading="loading" :data="newsList" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="图片" align="center" prop="imgUrl" width="140px;">
|
||||
<template slot-scope="scope">
|
||||
<el-image style="border-radius:5px;height:80px;width:120px;margin-bottom:-5px;" lazy :preview-src-list="[baseUrl+scope.row.imgUrl]" :src="baseUrl+scope.row.imgUrl" fit="cover"></el-image>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="标题" align="center" prop="title" />
|
||||
<el-table-column label="分类" align="center" prop="categoryName">
|
||||
<template slot-scope="scope">
|
||||
<el-tag type="info">{{scope.row.categoryName}}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="作者" align="center" prop="author" width="100" />
|
||||
<el-table-column label="置顶" align="center" prop="isTop" width="80">
|
||||
<template slot-scope="scope">
|
||||
<dict-tag :options="dict.type.iot_yes_no" :value="scope.row.isTop" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="轮播" align="center" prop="isBanner" width="80">
|
||||
<template slot-scope="scope">
|
||||
<dict-tag :options="dict.type.iot_yes_no" :value="scope.row.isBanner" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="发布" align="center" prop="status" width="80">
|
||||
<template slot-scope="scope">
|
||||
<dict-tag :options="dict.type.iot_yes_no" :value="scope.row.status" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column label="创建时间" align="center" prop="createTime" width="120">
|
||||
<template slot-scope="scope">
|
||||
<span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="备注" align="center" prop="remark" />
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||
<template slot-scope="scope">
|
||||
<el-button size="mini" type="text" icon="el-icon-view" @click="openDetailDialog(scope.row.newsId)">查看</el-button>
|
||||
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)" v-hasPermi="['iot:news:edit']">修改</el-button>
|
||||
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)" v-hasPermi="['iot:news:remove']">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />
|
||||
|
||||
<!-- 添加或修改新闻资讯对话框 -->
|
||||
<el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
|
||||
<el-form ref="form" :model="form" :rules="rules" label-width="60px">
|
||||
<el-row :gutter="20">
|
||||
<el-col :span="12">
|
||||
<el-form-item label="标题" prop="title">
|
||||
<el-input v-model="form.title" placeholder="请输入标题" />
|
||||
</el-form-item>
|
||||
<el-form-item label="作者" prop="author">
|
||||
<el-input v-model="form.author" placeholder="请输入作者" />
|
||||
</el-form-item>
|
||||
<el-form-item label="摘要" prop="remark">
|
||||
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容" rows="3" />
|
||||
</el-form-item>
|
||||
<el-row>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="置顶" prop="isTop">
|
||||
<el-switch v-model="form.isTop" active-text="" inactive-text="" :active-value="1" :inactive-value="0"></el-switch>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="轮播" prop="isBanner">
|
||||
<el-switch v-model="form.isBanner" active-text="" inactive-text="" :active-value="1" :inactive-value="0"></el-switch>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="发布" prop="status">
|
||||
<el-switch v-model="form.status" active-text="" inactive-text="" :active-value="1" :inactive-value="0"></el-switch>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="分类" prop="categoryId">
|
||||
<el-select v-model="form.categoryId" placeholder="请选择分类" @change="selectCategory">
|
||||
<el-option v-for="category in categoryList" :key="category.id" :label="category.name" :value="category.id"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="图片">
|
||||
<imageUpload ref="image-upload" :value="form.imgUrl" :limit="1" :fileSize="1" @input="getImagePath($event)"></imageUpload>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-form-item label="内容">
|
||||
<editor v-model="form.content" :min-height="192" />
|
||||
<el-form-item label="发布" prop="status">
|
||||
<el-select v-model="queryParams.status" placeholder="选择状态" clearable size="small" style="width:100px;">
|
||||
<el-option v-for="dict in dict.type.iot_yes_no" :key="dict.value" :label="dict.label"
|
||||
:value="dict.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
||||
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button type="primary" @click="submitForm">确 定</el-button>
|
||||
<el-button @click="cancel">取 消</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
|
||||
<!--通知公告详情 -->
|
||||
<el-dialog :title="form.title" :visible.sync="openDetail" width="800px" append-to-body>
|
||||
<div style="margin-top:-20px;margin-bottom:10px;">
|
||||
<el-tag size="mini" effect="dark" type="success">{{form.categoryName}}</el-tag>
|
||||
<span style="margin-left:20px;">{{form.createTime}}</span>
|
||||
</div>
|
||||
<div v-loading="loadingDetail" class="content">
|
||||
<div v-html="form.content"></div>
|
||||
</div>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button type="primary" @click="closeDetail"> 关 闭 </el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
|
||||
v-hasPermi="['iot:news:add']">新增</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="success" plain icon="el-icon-edit" size="mini" :disabled="single" @click="handleUpdate"
|
||||
v-hasPermi="['iot:news:edit']">修改</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete"
|
||||
v-hasPermi="['iot:news:remove']">删除</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport"
|
||||
v-hasPermi="['iot:news:export']">导出</el-button>
|
||||
</el-col>
|
||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
|
||||
<el-table v-loading="loading" :data="newsList" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="图片" align="center" prop="imgUrl" width="140px;">
|
||||
<template slot-scope="scope">
|
||||
<el-image style="border-radius:5px;height:80px;width:120px;margin-bottom:-5px;" lazy
|
||||
:preview-src-list="[baseUrl + scope.row.imgUrl]" :src="baseUrl + scope.row.imgUrl"
|
||||
fit="cover"></el-image>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="标题" align="center" prop="title" />
|
||||
<el-table-column label="分类" align="center" prop="categoryName">
|
||||
<template slot-scope="scope">
|
||||
<el-tag type="info">{{ scope.row.categoryName }}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="作者" align="center" prop="author" width="100" />
|
||||
<el-table-column label="置顶" align="center" prop="isTop" width="80">
|
||||
<template slot-scope="scope">
|
||||
<dict-tag :options="dict.type.iot_yes_no" :value="scope.row.isTop" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="轮播" align="center" prop="isBanner" width="80">
|
||||
<template slot-scope="scope">
|
||||
<dict-tag :options="dict.type.iot_yes_no" :value="scope.row.isBanner" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="发布" align="center" prop="status" width="80">
|
||||
<template slot-scope="scope">
|
||||
<dict-tag :options="dict.type.iot_yes_no" :value="scope.row.status" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column label="创建时间" align="center" prop="createTime" width="120">
|
||||
<template slot-scope="scope">
|
||||
<span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="备注" align="center" prop="remark" />
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||
<template slot-scope="scope">
|
||||
<el-button size="mini" type="text" icon="el-icon-view"
|
||||
@click="openDetailDialog(scope.row.newsId)">查看</el-button>
|
||||
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
|
||||
v-hasPermi="['iot:news:edit']">修改</el-button>
|
||||
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
|
||||
v-hasPermi="['iot:news:remove']">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
|
||||
@pagination="getList" />
|
||||
|
||||
<!-- 添加或修改新闻资讯对话框 -->
|
||||
<el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
|
||||
<el-form ref="form" :model="form" :rules="rules" label-width="60px">
|
||||
<el-row :gutter="20">
|
||||
<el-col :span="12">
|
||||
<el-form-item label="标题" prop="title">
|
||||
<el-input v-model="form.title" placeholder="请输入标题" />
|
||||
</el-form-item>
|
||||
<el-form-item label="作者" prop="author">
|
||||
<el-input v-model="form.author" placeholder="请输入作者" />
|
||||
</el-form-item>
|
||||
<el-form-item label="摘要" prop="remark">
|
||||
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容" rows="3" />
|
||||
</el-form-item>
|
||||
<el-row>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="置顶" prop="isTop">
|
||||
<el-switch v-model="form.isTop" active-text="" inactive-text="" :active-value="1"
|
||||
:inactive-value="0"></el-switch>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="轮播" prop="isBanner">
|
||||
<el-switch v-model="form.isBanner" active-text="" inactive-text="" :active-value="1"
|
||||
:inactive-value="0"></el-switch>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="发布" prop="status">
|
||||
<el-switch v-model="form.status" active-text="" inactive-text="" :active-value="1"
|
||||
:inactive-value="0"></el-switch>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="分类" prop="categoryId">
|
||||
<el-select v-model="form.categoryId" placeholder="请选择分类" @change="selectCategory">
|
||||
<el-option v-for="category in categoryList" :key="category.id" :label="category.name"
|
||||
:value="category.id"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="图片">
|
||||
<imageUpload ref="image-upload" :value="form.imgUrl" :limit="1" :fileSize="1"
|
||||
@input="getImagePath($event)"></imageUpload>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-form-item label="内容">
|
||||
<editor v-model="form.content" :min-height="192" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button type="primary" @click="submitForm">确 定</el-button>
|
||||
<el-button @click="cancel">取 消</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
|
||||
<!--通知公告详情 -->
|
||||
<el-dialog :title="form.title" :visible.sync="openDetail" width="800px" append-to-body>
|
||||
<div style="margin-top:-20px;margin-bottom:10px;">
|
||||
<el-tag size="mini" effect="dark" type="success">{{ form.categoryName }}</el-tag>
|
||||
<span style="margin-left:20px;">{{ form.createTime }}</span>
|
||||
</div>
|
||||
<div v-loading="loadingDetail" class="content">
|
||||
<div v-html="form.content"></div>
|
||||
</div>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button type="primary" @click="closeDetail"> 关 闭 </el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
@@ -228,7 +248,13 @@ export default {
|
||||
required: true,
|
||||
message: "标题不能为空",
|
||||
trigger: "blur"
|
||||
}],
|
||||
},
|
||||
{
|
||||
min: 1,
|
||||
max: 64,
|
||||
message: '标题不能少于1个字符和超过64字符',
|
||||
},
|
||||
],
|
||||
content: [{
|
||||
required: true,
|
||||
message: "内容不能为空",
|
||||
@@ -243,7 +269,12 @@ export default {
|
||||
required: true,
|
||||
message: "作者不能为空",
|
||||
trigger: "blur"
|
||||
}],
|
||||
},
|
||||
{
|
||||
min: 1,
|
||||
max: 50,
|
||||
message: '作者名称不能少于1个字符和超过50字符',
|
||||
},],
|
||||
}
|
||||
};
|
||||
},
|
||||
@@ -367,7 +398,7 @@ export default {
|
||||
}).then(() => {
|
||||
this.getList();
|
||||
this.$modal.msgSuccess("删除成功");
|
||||
}).catch(() => {});
|
||||
}).catch(() => { });
|
||||
},
|
||||
/** 导出按钮操作 */
|
||||
handleExport() {
|
||||
@@ -404,11 +435,9 @@ export default {
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.content {
|
||||
<style lang="scss" scoped>.content {
|
||||
line-height: 24px;
|
||||
padding: 10px;
|
||||
border: 1px solid #eee;
|
||||
border-radius: 10px;
|
||||
}
|
||||
</style>
|
||||
}</style>
|
||||
|
||||
@@ -1,71 +1,83 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
|
||||
<el-form-item label="分类名称" prop="categoryName">
|
||||
<el-input v-model="queryParams.categoryName" placeholder="请输入分类名称" clearable size="small" @keyup.enter.native="handleQuery" />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
||||
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd" v-hasPermi="['iot:category:add']">新增</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="success" plain icon="el-icon-edit" size="mini" :disabled="single" @click="handleUpdate" v-hasPermi="['iot:category:edit']">修改</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete" v-hasPermi="['iot:category:remove']">删除</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport" v-hasPermi="['iot:category:export']">导出</el-button>
|
||||
</el-col>
|
||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
|
||||
<el-table v-loading="loading" :data="categoryList" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="分类编号" align="center" prop="categoryId" />
|
||||
<el-table-column label="分类名称" align="center" prop="categoryName" />
|
||||
<el-table-column label="显示顺序" align="center" prop="orderNum" />
|
||||
<el-table-column label="创建时间" align="center" prop="createTime" width="180">
|
||||
<template slot-scope="scope">
|
||||
<span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="备注" align="center" prop="remark" min-width="200" header-align="center" />
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||
<template slot-scope="scope">
|
||||
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)" v-hasPermi="['iot:category:edit']">修改</el-button>
|
||||
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)" v-hasPermi="['iot:category:remove']">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />
|
||||
|
||||
<!-- 添加或修改新闻分类对话框 -->
|
||||
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
|
||||
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
||||
<div class="app-container">
|
||||
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
|
||||
<el-form-item label="分类名称" prop="categoryName">
|
||||
<el-input v-model="form.categoryName" placeholder="请输入分类名称" />
|
||||
<el-input v-model="queryParams.categoryName" placeholder="请输入分类名称" clearable size="small"
|
||||
@keyup.enter.native="handleQuery" />
|
||||
</el-form-item>
|
||||
<el-form-item label="显示顺序" prop="orderNum">
|
||||
<el-input v-model="form.orderNum" placeholder="请输入显示顺序" />
|
||||
</el-form-item>
|
||||
<el-form-item label="备注" prop="remark">
|
||||
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
||||
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button type="primary" @click="submitForm">确 定</el-button>
|
||||
<el-button @click="cancel">取 消</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
|
||||
v-hasPermi="['iot:newsCategory:add']">新增</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="success" plain icon="el-icon-edit" size="mini" :disabled="single" @click="handleUpdate"
|
||||
v-hasPermi="['iot:newsCategory:edit']">修改</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete"
|
||||
v-hasPermi="['iot:newsCategory:remove']">删除</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport"
|
||||
v-hasPermi="['iot:newsCategory:export']">导出</el-button>
|
||||
</el-col>
|
||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
|
||||
<el-table v-loading="loading" :data="categoryList" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="分类编号" align="center" prop="categoryId" />
|
||||
<el-table-column label="分类名称" align="center" prop="categoryName" />
|
||||
<el-table-column label="显示顺序" align="center" prop="orderNum" />
|
||||
<el-table-column label="创建时间" align="center" prop="createTime" width="180">
|
||||
<template slot-scope="scope">
|
||||
<span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="备注" align="center" prop="remark" min-width="200" header-align="center" />
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||
<template slot-scope="scope">
|
||||
<el-button size="mini" type="text" icon="el-icon-view" @click="handleUpdate(scope.row)"
|
||||
v-hasPermi="['iot:newsCategory:add']">查看</el-button>
|
||||
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
|
||||
v-hasPermi="['iot:newsCategory:remove']">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
|
||||
@pagination="getList" />
|
||||
|
||||
<!-- 添加或修改新闻分类对话框 -->
|
||||
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
|
||||
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
||||
<el-form-item label="分类名称" prop="categoryName">
|
||||
<el-input v-model="form.categoryName" placeholder="请输入分类名称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="显示顺序" prop="orderNum">
|
||||
<el-input-number v-model="form.orderNum" placeholder="请输入显示顺序" type="number" controls-position="right"
|
||||
style="width: 100%" />
|
||||
</el-form-item>
|
||||
<el-form-item label="备注" prop="remark">
|
||||
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button type="primary" @click="submitForm" v-hasPermi="['iot:newsCategory:edit']"
|
||||
v-show="form.categoryId">修 改</el-button>
|
||||
<el-button type="primary" @click="submitForm" v-hasPermi="['iot:newsCategory:add']"
|
||||
v-show="!form.categoryId">新 增</el-button>
|
||||
<el-button @click="cancel">取 消</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
@@ -113,12 +125,19 @@ export default {
|
||||
required: true,
|
||||
message: "分类名字不能为空",
|
||||
trigger: "blur"
|
||||
}],
|
||||
},
|
||||
{
|
||||
min: 1,
|
||||
max: 64,
|
||||
message: '分类名字不能少于1个字符和超过64字符',
|
||||
},
|
||||
],
|
||||
orderNum: [{
|
||||
required: true,
|
||||
message: "显示顺序不能为空",
|
||||
trigger: "blur"
|
||||
}],
|
||||
}
|
||||
],
|
||||
}
|
||||
};
|
||||
},
|
||||
@@ -210,15 +229,15 @@ export default {
|
||||
/** 删除按钮操作 */
|
||||
handleDelete(row) {
|
||||
const categoryIds = row.categoryId || this.ids;
|
||||
let msg="";
|
||||
let msg = "";
|
||||
this.$modal.confirm('是否确认删除新闻分类编号为"' + categoryIds + '"的数据项?').then(function () {
|
||||
return delNewsCategory(categoryIds).then(response => {
|
||||
msg=response.msg;
|
||||
return delNewsCategory(categoryIds).then(response => {
|
||||
msg = response.msg;
|
||||
});
|
||||
}).then(() => {
|
||||
this.getList();
|
||||
this.$modal.msgSuccess(msg);
|
||||
}).catch(() => {});
|
||||
}).catch(() => { });
|
||||
},
|
||||
/** 导出按钮操作 */
|
||||
handleExport() {
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
</el-form>
|
||||
</el-card>
|
||||
<el-card style="padding-bottom:100px;">
|
||||
<el-row :gutter="30" v-loading="loading" >
|
||||
<el-row :gutter="30" v-loading="loading">
|
||||
<el-col :xs="24" :sm="12" :md="12" :lg="8" :xl="6" v-for="(item,index) in productList" :key="index" style="margin-bottom:30px;text-align:center;">
|
||||
<el-card :body-style="{ padding: '20px'}" shadow="always" class="card-item">
|
||||
<el-row type="flex" :gutter="10" justify="space-between">
|
||||
@@ -35,10 +35,10 @@
|
||||
</el-col>
|
||||
<el-col :span="4">
|
||||
<el-tooltip class="item" effect="dark" content="取消发布" placement="top-start" v-if="item.status==2">
|
||||
<el-button type="success" size="mini" style="padding:5px;" @click="changeProductStatus(item.productId,1)">已发布</el-button>
|
||||
<el-button type="success" size="mini" style="padding:5px;" @click="changeProductStatus(item.productId,1,item.deviceType)">已发布</el-button>
|
||||
</el-tooltip>
|
||||
<el-tooltip class="item" effect="dark" content="现在发布" placement="top-start" v-if="item.status==1">
|
||||
<el-button type="info" size="mini" style="padding:5px;" @click="changeProductStatus(item.productId,2)">未发布</el-button>
|
||||
<el-button type="info" size="mini" style="padding:5px;" @click="changeProductStatus(item.productId,2,item.deviceType)">未发布</el-button>
|
||||
</el-tooltip>
|
||||
</el-col>
|
||||
</el-row>
|
||||
@@ -63,12 +63,14 @@
|
||||
<el-col :span="10">
|
||||
<div style="margin-top:10px;">
|
||||
<el-image style="width:100%;height:100px;border-radius:10px;" lazy :preview-src-list="[baseUrl+item.imgUrl]" :src="baseUrl+item.imgUrl" fit="cover" v-if="item.imgUrl!=null && item.imgUrl!=''"></el-image>
|
||||
<el-image style="width:100%;height:100px;border-radius:10px;" :preview-src-list="[require('@/assets/images/product.jpg')]" :src="require('@/assets/images/product.jpg')" fit="cover" v-else></el-image>
|
||||
<el-image style="width:100%;height:100px;border-radius:10px;" :preview-src-list="[require('@/assets/images/gateway.png')]" :src="require('@/assets/images/gateway.png')" fit="cover" v-else-if="item.deviceType==2"></el-image>
|
||||
<el-image style="width:100%;height:100px;border-radius:10px;" :preview-src-list="[require('@/assets/images/video.png')]" :src="require('@/assets/images/video.png')" fit="cover" v-else-if="item.deviceType==3"></el-image>
|
||||
<el-image style="width:100%;height:100px;border-radius:10px;" :preview-src-list="[require('@/assets/images/product.png')]" :src="require('@/assets/images/product.png')" fit="cover" v-else></el-image>
|
||||
</div>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-button-group style="margin-top:15px;height:28px;">
|
||||
<el-button size="mini" type="primary" icon="el-icon-edit" @click="handleEditProduct(item)" v-hasPermi="['iot:product:edit']">详情</el-button>
|
||||
<el-button size="mini" type="primary" icon="el-icon-view" @click="handleEditProduct(item)" v-hasPermi="['iot:product:query']">详情</el-button>
|
||||
<el-button size="mini" type="danger" icon="el-icon-delete" @click="handleDelete(item)" v-hasPermi="['iot:product:remove']" v-if="item.status==1">删除</el-button>
|
||||
<el-button size="mini" type="success" icon="el-icon-s-check" @click="handleDeviceAuthorize(item)" v-hasPermi="['iot:product:edit']" v-if="item.status==2" :disabled="item.isAuthorize!=1">设备授权</el-button>
|
||||
<el-button size="mini" type="warning" icon="el-icon-search" @click="handleViewDevice(item.productId)" v-hasPermi="['iot:device:query']">查看设备</el-button>
|
||||
@@ -104,9 +106,14 @@
|
||||
import {
|
||||
listProduct,
|
||||
delProduct,
|
||||
changeProductStatus
|
||||
changeProductStatus,
|
||||
deviceCount,
|
||||
} from "@/api/iot/product";
|
||||
|
||||
import {
|
||||
checkPermi
|
||||
} from "@/utils/permission"
|
||||
|
||||
export default {
|
||||
name: "Product",
|
||||
dicts: ['iot_yes_no', 'iot_product_status', 'iot_device_type', 'iot_network_method', 'iot_vertificate_method', 'iot_device_chip'],
|
||||
@@ -162,13 +169,38 @@ export default {
|
||||
this.loading = false;
|
||||
});
|
||||
},
|
||||
/**同步获取产品下的设备数量**/
|
||||
getDeviceCountByProductId(productId) {
|
||||
return new Promise((resolve, reject) => {
|
||||
deviceCount(productId).then(res => {
|
||||
resolve(res);
|
||||
}).catch(error => {
|
||||
reject(error);
|
||||
})
|
||||
})
|
||||
},
|
||||
/** 更新产品状态 */
|
||||
changeProductStatus(productId,status) {
|
||||
let message="发生错误了";
|
||||
if(status==2){
|
||||
message="产品发布后不能再更改产品内容和对应物模型 !";
|
||||
}else if(status==1){
|
||||
message="产品下不能有已经创建的设备,才能取消发布哦 !"
|
||||
async changeProductStatus(productId, status, deviceType) {
|
||||
let message = "确定取消发布?";
|
||||
if (status == 2) {
|
||||
// 发布
|
||||
let hasPermission = checkPermi(['iot:product:add']);
|
||||
if (!hasPermission) {
|
||||
this.$modal.alertError("没有操作权限");
|
||||
return;
|
||||
}
|
||||
message = "产品发布后,可以创建对应的设备";
|
||||
} else if (status == 1) {
|
||||
// 取消发布
|
||||
let hasPermission = checkPermi(['iot:product:edit']);
|
||||
if (!hasPermission) {
|
||||
this.$modal.alertError("没有操作权限");
|
||||
return;
|
||||
}
|
||||
let result = await this.getDeviceCountByProductId(productId);
|
||||
if (result.data > 0) {
|
||||
message = "重要提示:产品下已有 " + result.data + " 个设备,取消发布可以修改产品信息和模型,重新发布后对应设备状态将会被重置!"
|
||||
}
|
||||
}
|
||||
this.$confirm(message, '提示', {
|
||||
confirmButtonText: '确定',
|
||||
@@ -178,6 +210,7 @@ export default {
|
||||
let data = {};
|
||||
data.productId = productId;
|
||||
data.status = status;
|
||||
data.deviceType = deviceType;
|
||||
changeProductStatus(data).then(response => {
|
||||
this.getList();
|
||||
this.$modal.alertSuccess(response.msg);
|
||||
@@ -217,16 +250,16 @@ export default {
|
||||
},
|
||||
/** 下载SDK */
|
||||
downloadSdk() {
|
||||
this.$download.zip("/iot/tool/genSdk?deviceChip=" + 1, "wumeismart-sdk");
|
||||
this.$download.zip("/iot/tool/genSdk?deviceChip=" + 1, "fastbee-sdk");
|
||||
},
|
||||
/** 删除按钮操作 */
|
||||
handleDelete(row) {
|
||||
const productIds = row.productId || this.ids;
|
||||
let msg = "";
|
||||
this.$modal.confirm('是否确认删除产品编号为"' + productIds + '"的数据项?').then(function () {
|
||||
return delProduct(productIds).then(response => {
|
||||
msg = response.msg;
|
||||
});
|
||||
// // 删除SIP配置
|
||||
// delSipconfigByProductId(productIds).then(response => {});
|
||||
return delProduct(productIds);
|
||||
}).then(() => {
|
||||
this.getList();
|
||||
this.$modal.msgSuccess(msg);
|
||||
@@ -246,14 +279,14 @@ export default {
|
||||
}
|
||||
});
|
||||
},
|
||||
/** 设备授权操作 */
|
||||
/** 设备授权操作 */
|
||||
handleDeviceAuthorize(row) {
|
||||
let productId = row.productId
|
||||
this.$router.push({
|
||||
path: '/iot/product-edit',
|
||||
query: {
|
||||
productId: productId,
|
||||
tabPanelName:'productAuthorize',
|
||||
tabPanelName: 'productAuthorize',
|
||||
pageNum: this.queryParams.pageNum
|
||||
}
|
||||
});
|
||||
@@ -264,6 +297,6 @@ export default {
|
||||
|
||||
<style scoped>
|
||||
.card-item {
|
||||
border-radius:15px;
|
||||
border-radius: 15px;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -108,7 +108,7 @@
|
||||
|
||||
<!-- 设备详情对话框 -->
|
||||
<el-dialog title="设备详情" :visible.sync="openDevice" width="600px" append-to-body>
|
||||
<div v-if="device==null" style="text-align:center;"><i class="el-icon-warning" style="color:#E6A23C;"></i> 提示:查找不到设备,可能已经被删除</div>
|
||||
<div v-if="device==null" style="text-align:center;"><i class="el-icon-warning" style="color:#E6A23C;"></i> 提示:查找不到设备,可能已经被删除</div>
|
||||
<el-descriptions border :column="2" size="medium" v-if="device!=null">
|
||||
<el-descriptions-item label="设备ID">{{device.deviceId}}</el-descriptions-item>
|
||||
<el-descriptions-item label="设备名称">{{device.deviceName}}</el-descriptions-item>
|
||||
@@ -277,7 +277,7 @@ export default {
|
||||
},
|
||||
/** 修改按钮操作 */
|
||||
goToEditDevice(deviceId) {
|
||||
this.openDevice=false;
|
||||
this.openDevice = false;
|
||||
this.$router.push({
|
||||
path: '/iot/device-edit',
|
||||
query: {
|
||||
@@ -290,6 +290,10 @@ export default {
|
||||
this.deviceLoading = true;
|
||||
this.deviceParams.params = {};
|
||||
listUnAuthDevice(this.deviceParams).then(response => {
|
||||
//设备列表初始化isSelect值,用于单选
|
||||
for (let i = 0; i < response.rows.length; i++) {
|
||||
response.rows[i].isSelect = false;
|
||||
}
|
||||
this.deviceList = response.rows;
|
||||
this.deviceTotal = response.total;
|
||||
this.deviceLoading = false;
|
||||
|
||||
@@ -1,136 +1,188 @@
|
||||
<template>
|
||||
<el-card style="margin:6px;padding-bottom:100px;">
|
||||
<el-tabs v-model="activeName" tab-position="left" style="padding:10px;">
|
||||
<el-tab-pane name="basic">
|
||||
<span slot="label"><span style="color:red;">* </span>基本信息</span>
|
||||
<el-form ref="form" :model="form" :rules="rules" label-width="100px">
|
||||
<el-row :gutter="100">
|
||||
<el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8">
|
||||
<el-form-item label="产品名称" prop="productName">
|
||||
<el-input v-model="form.productName" placeholder="请输入产品名称" :readonly="form.status==2" />
|
||||
</el-form-item>
|
||||
<el-form-item label="产品分类" prop="categoryId">
|
||||
<el-select v-model="form.categoryId" placeholder="请选择分类" @change="selectCategory" style="width:100%" :disabled="form.status==2">
|
||||
<el-option v-for="category in categoryShortList" :key="category.id" :label="category.name" :value="category.id"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="联网方式" prop="networkMethod">
|
||||
<el-select v-model="form.networkMethod" placeholder="请选择联网方式" style="width:100%;" :disabled="form.status==2">
|
||||
<el-option v-for="dict in dict.type.iot_network_method" :key="dict.value" :label="dict.label" :value="parseInt(dict.value)"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="启用授权" prop="networkMethod">
|
||||
<el-switch v-model="form.isAuthorize" @change="changeIsAuthorize(form.isAuthorize)" :active-value="1" :inactive-value="0" :disabled="form.status==2" />
|
||||
</el-form-item>
|
||||
<el-form-item label="备注信息" prop="remark">
|
||||
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容" rows="3" :readonly="form.status==2" />
|
||||
<el-card style="margin:6px;padding-bottom:100px;">
|
||||
<el-tabs v-model="activeName" tab-position="left" style="padding:10px;min-height:400px;" @tab-click="tabChange">
|
||||
<el-tab-pane name="basic">
|
||||
<span slot="label"><span style="color:red;">* </span>基本信息</span>
|
||||
<el-form ref="form" :model="form" :rules="rules" label-width="100px">
|
||||
<el-row :gutter="100">
|
||||
<el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8">
|
||||
<el-form-item label="产品名称" prop="productName">
|
||||
<el-input v-model="form.productName" placeholder="请输入产品名称" :readonly="form.status == 2" />
|
||||
</el-form-item>
|
||||
<el-form-item label="产品分类" prop="categoryId">
|
||||
<el-select v-model="form.categoryId" placeholder="请选择分类" @change="selectCategory"
|
||||
style="width:100%" :disabled="form.status == 2">
|
||||
<el-option v-for="category in categoryShortList" :key="category.id"
|
||||
:label="category.name" :value="category.id"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="设备类型" prop="deviceType">
|
||||
<el-select v-model="form.deviceType" placeholder="请选择设备类型" :disabled="form.status == 2"
|
||||
style="width:100%">
|
||||
<el-option v-for="dict in dict.type.iot_device_type" :key="dict.value"
|
||||
:label="dict.label" :value="parseInt(dict.value)"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="传输协议" prop="transport">
|
||||
<el-select v-model="form.transport" placeholder="请选择传输协议" style="width: 100%"
|
||||
:disabled="form.status == 2">
|
||||
<el-option v-for="dict in dict.type.iot_transport_type" :key="dict.value"
|
||||
:label="dict.label" :value="dict.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item v-if="form.deviceType !== 3" label="编码协议" prop="protocolCode">
|
||||
<el-select v-model="form.protocolCode" placeholder="请选择编码协议" style="width: 100%"
|
||||
:disabled="form.status == 2" @change="changeProductCode">
|
||||
<el-option v-for="p in protocolList" :key="p.protocolCode" :label="p.protocolName"
|
||||
:value="p.protocolCode" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="联网方式" prop="networkMethod">
|
||||
<el-select v-model="form.networkMethod" placeholder="请选择联网方式" style="width:100%;"
|
||||
:disabled="form.status == 2">
|
||||
<el-option v-for="dict in dict.type.iot_network_method" :key="dict.value"
|
||||
:label="dict.label" :value="parseInt(dict.value)"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="备注信息" prop="remark">
|
||||
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容" rows="3"
|
||||
:readonly="form.status == 2" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8">
|
||||
<el-form-item label="启用授权" prop="networkMethod">
|
||||
<el-switch v-model="form.isAuthorize" @change="changeIsAuthorize(form.isAuthorize)"
|
||||
:active-value="1" :inactive-value="0"
|
||||
:disabled="form.status == 2 || form.deviceType == 3" />
|
||||
</el-form-item>
|
||||
<el-form-item label="认证方式" prop="vertificateMethod">
|
||||
<el-select v-model="form.vertificateMethod" placeholder="请选择认证方式" style="width:100%"
|
||||
:disabled="form.status == 2 || form.deviceType == 3">
|
||||
<el-option v-for="dict in dict.type.iot_vertificate_method" :key="dict.value"
|
||||
:label="dict.label" :value="parseInt(dict.value)"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="产品编号" prop="productId">
|
||||
<el-input v-model="form.productId" placeholder="自动生成"
|
||||
:disabled="!form.mqttAccount || form.deviceType == 3" readonly />
|
||||
</el-form-item>
|
||||
<el-form-item label="Mqtt账号" prop="mqttAccount">
|
||||
<el-input v-model="form.mqttAccount" placeholder="不填自动生成" :disabled="form.deviceType == 3"
|
||||
:readonly="accountInputType == 'password'" :type="accountInputType">
|
||||
<el-button slot="append" icon="el-icon-view" style="font-size:18px;"
|
||||
@click="changeInputType('account')"></el-button>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="Mqtt密码" prop="mqttPassword">
|
||||
<el-input v-model="form.mqttPassword" placeholder="不填则自动生成" :disabled="form.deviceType == 3"
|
||||
:readonly="passwordInputType == 'password'" :type="passwordInputType">
|
||||
<el-button slot="append" icon="el-icon-view" style="font-size:18px;"
|
||||
@click="changeInputType('password')"></el-button>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="产品秘钥" prop="mqttSecret">
|
||||
<el-input v-model="form.mqttSecret" placeholder="自动生成"
|
||||
:disabled="!form.mqttAccount || form.deviceType == 3" readonly :type="keyInputType">
|
||||
<el-button slot="append" icon="el-icon-view" style="font-size:18px;"
|
||||
@click="changeInputType('key')"></el-button>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8">
|
||||
<el-form-item label="产品图片">
|
||||
<div v-if="form.status == 2 && form.imgUrl == null">
|
||||
<el-image style="height:145px;height:145px;border-radius:10px;"
|
||||
:preview-src-list="[require('@/assets/images/gateway.png')]"
|
||||
:src="require('@/assets/images/gateway.png')" fit="cover"
|
||||
v-if="form.deviceType == 2"></el-image>
|
||||
<el-image style="height:145px;height:145px;border-radius:10px;"
|
||||
:preview-src-list="[require('@/assets/images/video.png')]"
|
||||
:src="require('@/assets/images/video.png')" fit="cover"
|
||||
v-else-if="form.deviceType == 3"></el-image>
|
||||
<el-image style="height:145px;height:145px;border-radius:10px;"
|
||||
:preview-src-list="[require('@/assets/images/product.png')]"
|
||||
:src="require('@/assets/images/product.png')" fit="cover" v-else></el-image>
|
||||
</div>
|
||||
<div v-else>
|
||||
<imageUpload ref="image-upload" :disabled="true" :value="form.imgUrl"
|
||||
:limit="form.status == 2 ? 0 : 1" :fileSize="1" @input="getImagePath($event)">
|
||||
</imageUpload>
|
||||
</div>
|
||||
<div class="el-upload__tip" style="color:#f56c6c"
|
||||
v-if="form.productId == null || form.productId == 0">提示:上传后需要提交保存</div>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<el-col :span="20">
|
||||
<el-form-item style="text-align: center;margin:40px 0px;">
|
||||
<el-button type="primary" @click="submitForm" v-hasPermi="['iot:product:edit']"
|
||||
v-show="form.productId != 0 && form.status != 2">修 改</el-button>
|
||||
<el-button type="primary" @click="submitForm" v-hasPermi="['iot:product:add']"
|
||||
v-show="form.productId == 0 && form.status != 2">新 增</el-button>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8">
|
||||
<el-form-item label="设备类型" prop="deviceType">
|
||||
<el-select v-model="form.deviceType" placeholder="请选择设备类型" :disabled="form.status==2" style="width:100%">
|
||||
<el-option v-for="dict in dict.type.iot_device_type" :key="dict.value" :label="dict.label" :value="parseInt(dict.value)"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="认证方式" prop="vertificateMethod">
|
||||
<el-select v-model="form.vertificateMethod" placeholder="请选择认证方式" style="width:100%" :disabled="form.status==2">
|
||||
<el-option v-for="dict in dict.type.iot_vertificate_method" :key="dict.value" :label="dict.label" :value="parseInt(dict.value)"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="产品编号" prop="productId">
|
||||
<el-input v-model="form.productId" placeholder="自动生成" :disabled="!form.mqttAccount" readonly />
|
||||
</el-form-item>
|
||||
<el-form-item label="Mqtt账号" prop="mqttAccount">
|
||||
<el-input v-model="form.mqttAccount" placeholder="自动生成" :disabled="!form.mqttAccount" readonly :type="accountInputType">
|
||||
<el-button slot="append" icon="el-icon-view" style="font-size:18px;" @click="changeInputType('account')"></el-button>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="Mqtt密码" prop="mqttPassword">
|
||||
<el-input v-model="form.mqttPassword" placeholder="自动生成" :disabled="!form.mqttAccount" readonly :type="passwordInputType">
|
||||
<el-button slot="append" icon="el-icon-view" style="font-size:18px;" @click="changeInputType('password')"></el-button>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="产品秘钥" prop="mqttSecret">
|
||||
<el-input v-model="form.mqttSecret" placeholder="自动生成" :disabled="!form.mqttAccount" readonly :type="keyInputType">
|
||||
<el-button slot="append" icon="el-icon-view" style="font-size:18px;" @click="changeInputType('key')"></el-button>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8">
|
||||
<el-form-item label="产品图片">
|
||||
<div v-if="form.status==2 && form.imgUrl==null">
|
||||
<el-image style="height:145px;height:145px;border-radius:10px;" :preview-src-list="[require('@/assets/images/product.jpg')]" :src="require('@/assets/images/product.jpg')" fit="cover"></el-image>
|
||||
</div>
|
||||
<div v-else>
|
||||
<imageUpload ref="image-upload" :disabled="true" :value="form.imgUrl" :limit="form.status==2 ? 0 : 1" :fileSize="1" @input="getImagePath($event)"></imageUpload>
|
||||
</div>
|
||||
<div class="el-upload__tip" style="color:#f56c6c" v-if="form.productId==null || form.productId==0">提示:上传后需要提交保存</div>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
</el-tab-pane>
|
||||
|
||||
<el-col :span="20">
|
||||
<el-form-item style="text-align: center;margin:40px 0px;">
|
||||
<el-button type="primary" @click="submitForm()" v-if="form.status!=2">提交</el-button>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-form>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane label="" name="things" :disabled="form.productId == 0">
|
||||
<span slot="label"><span style="color:red;">* </span>产品模型</span>
|
||||
<product-things-model ref="productThingsModel" :product="form" />
|
||||
</el-tab-pane>
|
||||
|
||||
<el-tab-pane label="" name="things" :disabled="form.productId==0">
|
||||
<span slot="label"><span style="color:red;">* </span>产品模型</span>
|
||||
<product-things-model ref="productThingsModel" :product="form" />
|
||||
</el-tab-pane>
|
||||
<el-tab-pane label="" name="productFirmware" :disabled="form.productId==0">
|
||||
<span slot="label">固件管理</span>
|
||||
<product-firmware ref="productFirmware" :product="form" />
|
||||
</el-tab-pane>
|
||||
<el-tab-pane label="" name="productAuthorize" :disabled="form.productId == 0" v-if="form.deviceType !== 3">
|
||||
<span slot="label">设备授权</span>
|
||||
<product-authorize ref="productAuthorize" :product="form" />
|
||||
</el-tab-pane>
|
||||
|
||||
<el-tab-pane label="" name="productAuthorize" :disabled="form.productId==0 || form.isAuthorize==0">
|
||||
<span slot="label">设备授权</span>
|
||||
<product-authorize ref="productAuthorize" :product="form" />
|
||||
</el-tab-pane>
|
||||
<el-tab-pane label="" name="alert" :disabled="form.productId == 0" v-if="form.deviceType !== 3">
|
||||
<span slot="label"><span style="color:red;">¥ </span>告警配置</span>
|
||||
<business ref="business"/>
|
||||
</el-tab-pane>
|
||||
|
||||
<el-tab-pane label="" name="alert" :disabled="form.productId==0">
|
||||
<span slot="label"> 告警配置</span>
|
||||
<product-alert ref="productAlert" :product="form"></product-alert>
|
||||
</el-tab-pane>
|
||||
|
||||
<el-tab-pane label="" name="productApp" :disabled="form.productId==0">
|
||||
<span slot="label">控制界面</span>
|
||||
<product-app ref="productApp" :product="form" />
|
||||
</el-tab-pane>
|
||||
<div style="margin-top:200px;"></div>
|
||||
|
||||
<el-tab-pane label="" disabled name="product01" />
|
||||
<el-tab-pane label="" disabled name="product02" />
|
||||
<el-tab-pane label="" disabled name="product03" />
|
||||
<el-tab-pane v-if="form.status==1" name="product04">
|
||||
<span slot="label">
|
||||
<el-button type="success" size="mini" @click="changeProductStatus(2)">发布产品</el-button>
|
||||
</span>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane v-if="form.status==2" name="product05">
|
||||
<span slot="label">
|
||||
<el-button type="danger" size="mini" @click="changeProductStatus(1)">取消发布</el-button>
|
||||
</span>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane name="product06">
|
||||
<span slot="label">
|
||||
<el-button type="info" size="mini" @click="goBack()">返回列表</el-button>
|
||||
</span>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
<!-- 用于设置间距 -->
|
||||
<el-tab-pane>
|
||||
<span slot="label">
|
||||
<div style="margin-top:200px;"></div>
|
||||
</span>
|
||||
</el-tab-pane>
|
||||
|
||||
</el-card>
|
||||
<el-tab-pane v-if="form.status == 1" name="product04" disabled>
|
||||
<span slot="label">
|
||||
<el-button type="success" size="mini" @click="changeProductStatus(2)"
|
||||
v-hasPermi="['iot:product:add']">发布产品</el-button>
|
||||
</span>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane v-if="form.status == 2" name="product05" disabled>
|
||||
<span slot="label">
|
||||
<el-button type="danger" size="mini" @click="changeProductStatus(1)"
|
||||
v-hasPermi="['iot:product:edit']">取消发布</el-button>
|
||||
</span>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane name="product06" disabled>
|
||||
<span slot="label">
|
||||
<el-button type="info" size="mini" @click="goBack()">返回列表</el-button>
|
||||
</span>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
|
||||
</el-card>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import productThingsModel from "./product-things-model";
|
||||
import productFirmware from "./product-firmware";
|
||||
import productApp from "./product-app"
|
||||
import productAlert from "./product-alert"
|
||||
import productAuthorize from "./product-authorize"
|
||||
import imageUpload from "../../../components/ImageUpload/index"
|
||||
import business from "../business/index"
|
||||
import {
|
||||
listProtocol
|
||||
} from "@/api/iot/protocol";
|
||||
|
||||
import {
|
||||
listShortCategory,
|
||||
} from "@/api/iot/category";
|
||||
@@ -138,53 +190,106 @@ import {
|
||||
getProduct,
|
||||
addProduct,
|
||||
updateProduct,
|
||||
changeProductStatus
|
||||
changeProductStatus,
|
||||
deviceCount,
|
||||
} from "@/api/iot/product";
|
||||
|
||||
import {
|
||||
getAllPoints
|
||||
} from "@/api/iot/template";
|
||||
|
||||
export default {
|
||||
name: "ProductEdit",
|
||||
dicts: ['iot_device_type', 'iot_network_method', 'iot_vertificate_method'],
|
||||
dicts: ['iot_device_type', 'iot_network_method', 'iot_vertificate_method', 'iot_transport_type', 'data_collect_type'],
|
||||
components: {
|
||||
productThingsModel,
|
||||
productApp,
|
||||
productAlert,
|
||||
productAuthorize,
|
||||
productFirmware,
|
||||
imageUpload,
|
||||
business,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
// 输入框类型
|
||||
keyInputType: "password",
|
||||
accountInputType: "text",
|
||||
accountInputType: "password",
|
||||
passwordInputType: "password",
|
||||
// 选中选项卡
|
||||
activeName: 'basic',
|
||||
// 分类短列表
|
||||
categoryShortList: [],
|
||||
//协议列表
|
||||
protocolList: [],
|
||||
// 表单参数
|
||||
form: {
|
||||
networkMethod: 1,
|
||||
deviceType: 1,
|
||||
vertificateMethod: 3,
|
||||
transport: 'MQTT',
|
||||
imgUrl: "",
|
||||
},
|
||||
// 表单校验
|
||||
rules: {
|
||||
productName: [{
|
||||
required: true,
|
||||
message: "产品名称不能为空",
|
||||
trigger: "blur"
|
||||
}],
|
||||
trigger: "blur",
|
||||
|
||||
},
|
||||
{
|
||||
min: 1,
|
||||
max: 64,
|
||||
message: '产品名称不能少于1个字符和超过64字符',
|
||||
trigger: 'blur',
|
||||
},
|
||||
],
|
||||
categoryId: [{
|
||||
required: true,
|
||||
message: "产品分类ID不能为空",
|
||||
trigger: "blur"
|
||||
}],
|
||||
deviceType: [{
|
||||
required: true,
|
||||
message: "请选择设备类型",
|
||||
trigger: "blur"
|
||||
}],
|
||||
protocolCode: [{
|
||||
required: true,
|
||||
message: "设备协议不能为空",
|
||||
trigger: "blur"
|
||||
}],
|
||||
transport: [{
|
||||
required: true,
|
||||
message: "传输协议不能为空",
|
||||
trigger: 'blur'
|
||||
}]
|
||||
},
|
||||
// 查询参数
|
||||
queryParams: {
|
||||
tenantName: null,
|
||||
},
|
||||
pointList: [],
|
||||
open: false,
|
||||
// 弹出层标题
|
||||
title: "",
|
||||
loading: true,
|
||||
tempList: [],
|
||||
// 总条数
|
||||
total: 0,
|
||||
tempTotal: 0,
|
||||
// 查询参数
|
||||
pointsParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 8,
|
||||
templateId: 0,
|
||||
},
|
||||
tempParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
},
|
||||
currentRow: {},
|
||||
selectRowData: {},
|
||||
isModbus: false,
|
||||
|
||||
};
|
||||
},
|
||||
@@ -202,24 +307,31 @@ export default {
|
||||
}
|
||||
// 获取分类信息
|
||||
this.getShortCategory();
|
||||
// 设置账号密码输入框类型,新增时为text,查看时为password
|
||||
if (!this.form.productId || this.form.productId == 0) {
|
||||
this.accountInputType = "text";
|
||||
this.passwordInputType = "text";
|
||||
}
|
||||
this.getProtocol();
|
||||
},
|
||||
activated() {
|
||||
const time = this.$route.query.t;
|
||||
if (time != null && time != this.uniqueId) {
|
||||
this.uniqueId = time;
|
||||
// 获取产品信息
|
||||
let productId = this.$route.query.productId
|
||||
if (productId != null && productId != 0) {
|
||||
this.form.productId = Number(productId);
|
||||
this.getProduct();
|
||||
this.getShortCategory();
|
||||
}
|
||||
// 切换选项卡
|
||||
const tabPanelName = this.$route.query && this.$route.query.tabPanelName;
|
||||
if (tabPanelName != null && tabPanelName != '') {
|
||||
this.activeName = tabPanelName;
|
||||
}
|
||||
this.uniqueId = time;
|
||||
}
|
||||
// 获取产品信息
|
||||
let productId = this.$route.query.productId
|
||||
if (productId != null && productId != 0) {
|
||||
this.form.productId = Number(productId);
|
||||
this.getProduct();
|
||||
this.getShortCategory();
|
||||
}
|
||||
// 切换选项卡
|
||||
const tabPanelName = this.$route.query && this.$route.query.tabPanelName;
|
||||
if (tabPanelName != null && tabPanelName != '') {
|
||||
this.activeName = tabPanelName;
|
||||
}
|
||||
|
||||
},
|
||||
methods: {
|
||||
// 获取简短分类列表
|
||||
@@ -244,6 +356,7 @@ export default {
|
||||
getProduct() {
|
||||
getProduct(this.form.productId).then(response => {
|
||||
this.form = response.data;
|
||||
this.changeProductCode(this.form.protocolCode);
|
||||
});
|
||||
},
|
||||
// 表单重置
|
||||
@@ -262,7 +375,8 @@ export default {
|
||||
mqttAccount: null,
|
||||
mqttPassword: null,
|
||||
mqttSecret: null,
|
||||
remark: null
|
||||
remark: null,
|
||||
imgUrl: "",
|
||||
};
|
||||
this.resetForm("form");
|
||||
},
|
||||
@@ -272,25 +386,43 @@ export default {
|
||||
if (valid) {
|
||||
if (this.form.productId != null && this.form.productId != 0) {
|
||||
updateProduct(this.form).then(response => {
|
||||
this.changeProductCode(this.form.protocolCode);
|
||||
this.$modal.alertSuccess("修改成功");
|
||||
});
|
||||
} else {
|
||||
addProduct(this.form).then(response => {
|
||||
this.$modal.alertSuccess("添加成功,可以开始定义物模型了");
|
||||
if (!this.form.isModbus) {
|
||||
this.$modal.alertSuccess("添加成功,可以开始定义物模型或配置");
|
||||
} else {
|
||||
this.$modal.alertSuccess("物模型已经从采集点模板同步至产品")
|
||||
}
|
||||
this.form = response.data;
|
||||
this.activeName = "things";
|
||||
this.changeProductCode(this.form.protocolCode);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
/**同步获取产品下的设备数量**/
|
||||
getDeviceCountByProductId(productId) {
|
||||
return new Promise((resolve, reject) => {
|
||||
deviceCount(productId).then(res => {
|
||||
resolve(res);
|
||||
}).catch(error => {
|
||||
reject(error);
|
||||
})
|
||||
})
|
||||
},
|
||||
/** 更新产品状态 */
|
||||
changeProductStatus(status) {
|
||||
let message = "发生错误了";
|
||||
async changeProductStatus(status) {
|
||||
let message = "确定取消发布?";
|
||||
if (status == 2) {
|
||||
message = "产品发布后不能再更改产品内容和对应物模型";
|
||||
message = "产品发布后,可以创建对应的设备";
|
||||
} else if (status == 1) {
|
||||
message = "产品下不能有已经创建的设备,才能取消发布哦"
|
||||
let result = await this.getDeviceCountByProductId(this.form.productId);
|
||||
if (result.data > 0) {
|
||||
message = "重要提示:产品下已有 " + result.data + " 个设备,取消发布可以修改产品信息和模型,重新发布后对应设备状态将会被重置!"
|
||||
}
|
||||
}
|
||||
this.$confirm(message, '提示', {
|
||||
confirmButtonText: '确定',
|
||||
@@ -300,12 +432,14 @@ export default {
|
||||
let data = {};
|
||||
data.productId = this.form.productId;
|
||||
data.status = status;
|
||||
data.deviceType = this.form.deviceType;
|
||||
changeProductStatus(data).then(response => {
|
||||
this.$modal.alertSuccess(response.msg);
|
||||
this.goBack();
|
||||
this.activeName = "basic";
|
||||
this.getProduct();
|
||||
}).catch(() => {
|
||||
if (status == 2) {
|
||||
this.activeName = "things";
|
||||
this.activeName = "basic";
|
||||
} else {
|
||||
this.goBack();
|
||||
}
|
||||
@@ -349,7 +483,78 @@ export default {
|
||||
}).catch(() => {
|
||||
this.form.isAuthorize = 0;
|
||||
});
|
||||
}
|
||||
},
|
||||
//获取设备协议
|
||||
getProtocol() {
|
||||
const data = {
|
||||
protocolStatus: 1
|
||||
};
|
||||
listProtocol(data).then(res => {
|
||||
this.protocolList = res.rows;
|
||||
})
|
||||
},
|
||||
// 取消按钮
|
||||
cancel() {
|
||||
this.open = false;
|
||||
// this.reset();
|
||||
},
|
||||
getList() {
|
||||
getAllPoints(this.pointsParams).then(response => {
|
||||
this.pointList = response.rows;
|
||||
this.total = response.total;
|
||||
});
|
||||
},
|
||||
changeProductCode(val) {
|
||||
if (val && val.startsWith("MODBUS")) {
|
||||
this.form.deviceType = 2;
|
||||
this.form.isModbus = true;
|
||||
if (this.form.productId != 0 && this.form.productId != null) {
|
||||
//this.getTempDetail()
|
||||
}
|
||||
} else {
|
||||
this.form.isModbus = false;
|
||||
}
|
||||
},
|
||||
/**选项卡切换事件**/
|
||||
tabChange(tabItem) {
|
||||
// 切换到告警配置,获取物模型
|
||||
if (tabItem.paneName == "alert") {
|
||||
//this.$refs.productAlert.getCacheThingsModel(this.form.productId);
|
||||
}
|
||||
},
|
||||
|
||||
/*按照模板名查询*/
|
||||
queryTemp() {
|
||||
this.getTempList();
|
||||
},
|
||||
|
||||
/** 搜索按钮操作 */
|
||||
handleQuery() {
|
||||
this.tempParams.pageNum = 1
|
||||
this.getTempList()
|
||||
},
|
||||
|
||||
/** 重置按钮操作 */
|
||||
resetQuery() {
|
||||
this.resetForm('tempParams')
|
||||
this.handleQuery()
|
||||
},
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.el-aside {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
background-color: #fff;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.el-main {
|
||||
margin: 0;
|
||||
padding: 0 10px;
|
||||
background-color: #fff;
|
||||
color: #333;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,49 +1,63 @@
|
||||
<template>
|
||||
<div style="margin-top:-50px;">
|
||||
<el-divider></el-divider>
|
||||
<el-form :model="queryParams" ref="product-select-template" :inline="true" label-width="48px">
|
||||
<el-form-item label="名称" prop="templateName">
|
||||
<el-input v-model="queryParams.templateName" placeholder="请输入物模型名称" clearable size="small" @keyup.enter.native="handleQuery" />
|
||||
</el-form-item>
|
||||
<el-form-item label="类别" prop="type">
|
||||
<el-select v-model="queryParams.type" placeholder="请选择模型类别" clearable size="small">
|
||||
<el-option v-for="dict in dict.type.iot_things_type" :key="dict.value" :label="dict.label" :value="dict.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
||||
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div style="margin-top:-50px;">
|
||||
<el-divider></el-divider>
|
||||
<el-form :model="queryParams" ref="product-select-template" :inline="true" label-width="48px">
|
||||
<el-form-item label="名称" prop="templateName">
|
||||
<el-input v-model="queryParams.templateName" placeholder="请输入物模型名称" clearable size="small"
|
||||
@keyup.enter.native="handleQuery" />
|
||||
</el-form-item>
|
||||
<el-form-item label="类别" prop="type">
|
||||
<el-select v-model="queryParams.type" placeholder="请选择模型类别" clearable size="small">
|
||||
<el-option v-for="dict in dict.type.iot_things_type" :key="dict.value" :label="dict.label"
|
||||
:value="dict.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
||||
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<el-table v-loading="loading" :data="templateList" @selection-change="handleSelectionChange" ref="selectTemplateTable" size="small">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="名称" align="center" prop="templateName" />
|
||||
<el-table-column label="标识符" align="center" prop="identifier" />
|
||||
<el-table-column label="物模型类别" align="center" prop="type">
|
||||
<template slot-scope="scope">
|
||||
<dict-tag :options="dict.type.iot_things_type" :value="scope.row.type" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="首页显示" align="center" prop="isTop">
|
||||
<template slot-scope="scope">
|
||||
<dict-tag :options="dict.type.iot_yes_no" :value="scope.row.isTop" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="监测值" align="center" prop="isMonitor">
|
||||
<template slot-scope="scope">
|
||||
<dict-tag :options="dict.type.iot_yes_no" :value="scope.row.isMonitor" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="数据类型" align="center" prop="datatype">
|
||||
<template slot-scope="scope">
|
||||
<dict-tag :options="dict.type.iot_data_type" :value="scope.row.datatype" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<el-table v-loading="loading" :data="templateList" @selection-change="handleSelectionChange"
|
||||
ref="selectTemplateTable" size="small">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="名称" align="center" prop="templateName" />
|
||||
<el-table-column label="标识符" align="center" prop="identifier" />
|
||||
<el-table-column label="物模型类别" align="center" prop="type">
|
||||
<template slot-scope="scope">
|
||||
<dict-tag :options="dict.type.iot_things_type" :value="scope.row.type" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="图表展示" align="center" prop="isChart" width="75">
|
||||
<template slot-scope="scope">
|
||||
<dict-tag :options="dict.type.iot_yes_no" :value="scope.row.isChart" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="实时监测" align="center" prop="isMonitor" width="75">
|
||||
<template slot-scope="scope">
|
||||
<dict-tag :options="dict.type.iot_yes_no" :value="scope.row.isMonitor" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="只读" align="center" prop="isReadonly" width="75">
|
||||
<template slot-scope="scope">
|
||||
<dict-tag :options="dict.type.iot_yes_no" :value="scope.row.isReadonly" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="历史存储" align="center" prop="isHistory" width="75">
|
||||
<template slot-scope="scope">
|
||||
<dict-tag :options="dict.type.iot_yes_no" :value="scope.row.isHistory" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="数据类型" align="center" prop="datatype">
|
||||
<template slot-scope="scope">
|
||||
<dict-tag :options="dict.type.iot_data_type" :value="scope.row.datatype" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />
|
||||
</div>
|
||||
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
|
||||
@pagination="getList" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
@@ -95,7 +109,7 @@ export default {
|
||||
},
|
||||
/** 重置按钮操作 */
|
||||
resetQuery() {
|
||||
this.resetForm("queryForm");
|
||||
this.resetForm("product-select-template");
|
||||
this.handleQuery();
|
||||
},
|
||||
// 多选框选中数据
|
||||
@@ -104,9 +118,8 @@ export default {
|
||||
this.single = selection.length !== 1;
|
||||
this.multiple = !selection.length;
|
||||
// Id数组传递到父组件
|
||||
this.$emit('idsToParentEvent', this.ids)
|
||||
this.$emit('idsToParentEvent', this.ids);
|
||||
},
|
||||
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
234
vue/src/views/iot/protocol/index.vue
Normal file
234
vue/src/views/iot/protocol/index.vue
Normal file
@@ -0,0 +1,234 @@
|
||||
<template>
|
||||
<div style="padding:6px;">
|
||||
<el-card v-show="showSearch" style="margin-bottom:6px;">
|
||||
<el-form :model="queryParams" ref="queryForm" :inline="true" label-width="68px" style="margin-bottom:-20px;">
|
||||
<el-form-item label="协议名称" prop="protocolName">
|
||||
<el-input v-model="queryParams.protocolName" placeholder="请输入协议名称" clearable size="small" @keyup.enter.native="handleQuery" />
|
||||
</el-form-item>
|
||||
<el-form-item label="协议编码" prop="protocolCode">
|
||||
<el-input v-model="queryParams.protocolCode" placeholder="请输入协议编码" clearable size="small" @keyup.enter.native="handleQuery" />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
||||
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-card>
|
||||
|
||||
<el-card style="padding-bottom:100px;">
|
||||
<el-table v-loading="loading" :data="protocolList" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="协议名称" align="center" prop="protocolName" />
|
||||
<el-table-column label="协议编码" align="center" prop="protocolCode" />
|
||||
<el-table-column label="上传地址" align="center" prop="protocolFileUrl" />
|
||||
<el-table-column label="协议类型" align="center" prop="protocolType" />
|
||||
<el-table-column label="协议摘要" align="center" prop="jarSign" />
|
||||
</el-table>
|
||||
|
||||
<pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />
|
||||
|
||||
<!-- 添加或修改协议对话框 -->
|
||||
<el-dialog :title="title" :visible.sync="open" width="600px" append-to-body>
|
||||
<el-form ref="form" :model="form" :rules="rules" label-width="100px">
|
||||
<el-form-item label="协议名称" prop="protocolName">
|
||||
<el-input v-model="form.protocolName" placeholder="请输入协议名称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="协议编码" prop="protocolCode">
|
||||
<el-input v-model="form.protocolCode" placeholder="请输入协议编码" />
|
||||
</el-form-item>
|
||||
<el-form-item label="上传地址" prop="protocolFileUrl">
|
||||
<el-input v-model="form.protocolFileUrl" type="textarea" placeholder="请输入内容" />
|
||||
</el-form-item>
|
||||
<el-form-item label="协议摘要" prop="jarSign">
|
||||
<el-input v-model="form.jarSign" placeholder="请输入协议文件摘要(文件的md5)" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button type="primary" @click="submitForm">确 定</el-button>
|
||||
<el-button @click="cancel">取 消</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
|
||||
</el-card>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {
|
||||
listProtocol,
|
||||
getProtocol,
|
||||
delProtocol,
|
||||
addProtocol,
|
||||
updateProtocol
|
||||
} from "@/api/iot/protocol";
|
||||
|
||||
export default {
|
||||
name: "Protocol",
|
||||
data() {
|
||||
return {
|
||||
// 遮罩层
|
||||
loading: true,
|
||||
// 选中数组
|
||||
ids: [],
|
||||
// 非单个禁用
|
||||
single: true,
|
||||
// 非多个禁用
|
||||
multiple: true,
|
||||
// 显示搜索条件
|
||||
showSearch: true,
|
||||
// 总条数
|
||||
total: 0,
|
||||
// 协议表格数据
|
||||
protocolList: [],
|
||||
// 弹出层标题
|
||||
title: "",
|
||||
// 是否显示弹出层
|
||||
open: false,
|
||||
// 查询参数
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
protocolCode: null,
|
||||
protocolName: null,
|
||||
protocolFileUrl: null,
|
||||
protocolType: null,
|
||||
jarSign: null,
|
||||
protocolStatus: null,
|
||||
},
|
||||
// 表单参数
|
||||
form: {},
|
||||
// 表单校验
|
||||
rules: {
|
||||
protocolCode: [{
|
||||
required: true,
|
||||
message: "协议编码不能为空",
|
||||
trigger: "blur"
|
||||
}],
|
||||
protocolName: [{
|
||||
required: true,
|
||||
message: "协议名称不能为空",
|
||||
trigger: "blur"
|
||||
}],
|
||||
protocolFileUrl: [{
|
||||
required: true,
|
||||
message: "协议上传地址不能为空",
|
||||
trigger: "blur"
|
||||
}],
|
||||
protocolType: [{
|
||||
required: true,
|
||||
message: "协议类型不能为空",
|
||||
trigger: "change"
|
||||
}],
|
||||
jarSign: [{
|
||||
required: true,
|
||||
message: "协议摘要不能为空",
|
||||
trigger: "blur"
|
||||
}]
|
||||
}
|
||||
};
|
||||
},
|
||||
created() {
|
||||
this.getList();
|
||||
},
|
||||
methods: {
|
||||
/** 查询协议列表 */
|
||||
getList() {
|
||||
this.loading = true;
|
||||
listProtocol(this.queryParams).then(response => {
|
||||
this.protocolList = response.rows;
|
||||
this.total = response.total;
|
||||
this.loading = false;
|
||||
});
|
||||
},
|
||||
// 取消按钮
|
||||
cancel() {
|
||||
this.open = false;
|
||||
this.reset();
|
||||
},
|
||||
// 表单重置
|
||||
reset() {
|
||||
this.form = {
|
||||
id: null,
|
||||
protocolCode: null,
|
||||
protocolName: null,
|
||||
protocolFileUrl: null,
|
||||
protocolType: null,
|
||||
jarSign: null,
|
||||
createTime: null,
|
||||
updateTime: null,
|
||||
protocolStatus: 0,
|
||||
delFlag: null
|
||||
};
|
||||
this.resetForm("form");
|
||||
},
|
||||
/** 搜索按钮操作 */
|
||||
handleQuery() {
|
||||
this.queryParams.pageNum = 1;
|
||||
this.getList();
|
||||
},
|
||||
/** 重置按钮操作 */
|
||||
resetQuery() {
|
||||
this.resetForm("queryForm");
|
||||
this.handleQuery();
|
||||
},
|
||||
// 多选框选中数据
|
||||
handleSelectionChange(selection) {
|
||||
this.ids = selection.map(item => item.id)
|
||||
this.single = selection.length !== 1
|
||||
this.multiple = !selection.length
|
||||
},
|
||||
/** 新增按钮操作 */
|
||||
handleAdd() {
|
||||
this.reset();
|
||||
this.open = true;
|
||||
this.title = "添加协议";
|
||||
},
|
||||
/** 修改按钮操作 */
|
||||
handleUpdate(row) {
|
||||
this.reset();
|
||||
const id = row.id || this.ids
|
||||
getProtocol(id).then(response => {
|
||||
this.form = response.data;
|
||||
this.open = true;
|
||||
this.title = "修改协议";
|
||||
});
|
||||
},
|
||||
/** 提交按钮 */
|
||||
submitForm() {
|
||||
this.$refs["form"].validate(valid => {
|
||||
if (valid) {
|
||||
if (this.form.id != null) {
|
||||
updateProtocol(this.form).then(response => {
|
||||
this.$modal.msgSuccess("修改成功");
|
||||
this.open = false;
|
||||
this.getList();
|
||||
});
|
||||
} else {
|
||||
addProtocol(this.form).then(response => {
|
||||
this.$modal.msgSuccess("新增成功");
|
||||
this.open = false;
|
||||
this.getList();
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
/** 删除按钮操作 */
|
||||
handleDelete(row) {
|
||||
const ids = row.id || this.ids;
|
||||
this.$modal.confirm('是否确认删除协议编号为"' + ids + '"的数据项?').then(function () {
|
||||
return delProtocol(ids);
|
||||
}).then(() => {
|
||||
this.getList();
|
||||
this.$modal.msgSuccess("删除成功");
|
||||
}).catch(() => {});
|
||||
},
|
||||
/** 导出按钮操作 */
|
||||
handleExport() {
|
||||
this.download('iot/protocol/export', {
|
||||
...this.queryParams
|
||||
}, `protocol_${new Date().getTime()}.xlsx`)
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
File diff suppressed because it is too large
Load Diff
440
vue/src/views/iot/template/parameter.vue
Normal file
440
vue/src/views/iot/template/parameter.vue
Normal file
@@ -0,0 +1,440 @@
|
||||
<template>
|
||||
<div style="padding: 6px">
|
||||
<!-- 添加或修改通用物模型对话框 -->
|
||||
<el-dialog title="编辑参数" :visible.sync="openEdit" width="900px" append-to-body>
|
||||
<div style="margin: -30px 0 30px; background-color: #ddd; height: 1px"></div>
|
||||
<el-row>
|
||||
<el-col :span="12" style="border: 1px solid #ddd; border-radius: 5px; padding: 10px; background-color: #eee">
|
||||
<el-form :model="queryParams" :inline="true" label-width="48px" size="small">
|
||||
<el-form-item label="" prop="templateName">
|
||||
<el-input v-model="queryParams.templateName" placeholder="请输入物模型名称" style="width: 160px" clearable size="mini" @keyup.enter.native="handleQuery" />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="info" icon="el-icon-search" size="mini" @click="handleQuery" style="padding: 5px">搜索</el-button>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-link :underline="false" icon="el-icon-info" type="primary" style="margin-left: 20px">单击应用模板</el-link>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<el-table v-loading="loading" :data="templateList" size="mini" @row-click="rowClick" highlight-current-row :border="false" :show-header="false" :row-style="{ backgroundColor: '#eee' }">
|
||||
<el-table-column label="选择" width="30" align="center">
|
||||
<template slot-scope="scope">
|
||||
<input type="radio" :checked="scope.row.isSelect" :disabled="scope.row.datatype == 'array' || scope.row.datatype == 'object'" name="template" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="名称" align="left" prop="templateName" />
|
||||
<el-table-column label="标识符" align="left" prop="identifier" />
|
||||
<el-table-column label="数据类型" align="center" prop="datatype" width="60">
|
||||
<template slot-scope="scope">
|
||||
<dict-tag :options="dict.type.iot_data_type" :value="scope.row.datatype" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<pagination
|
||||
v-show="total > 0"
|
||||
small
|
||||
style="margin: 0 0 10px; background-color: #eee"
|
||||
layout="prev, pager, next"
|
||||
:total="total"
|
||||
:page.sync="queryParams.pageNum"
|
||||
:limit.sync="queryParams.pageSize"
|
||||
@pagination="getList"
|
||||
/>
|
||||
</el-col>
|
||||
|
||||
<el-col :span="11" :offset="1">
|
||||
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
||||
<el-form-item label="参数名称" prop="name">
|
||||
<el-input v-model="form.name" placeholder="例如:温度" style="width: 270px" size="small" />
|
||||
</el-form-item>
|
||||
<el-form-item label="参数标识" prop="id">
|
||||
<el-input v-model="form.id" placeholder="例如:temperature" style="width: 270px" size="small"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="参数排序" prop="order">
|
||||
<el-input-number controls-position="right" v-model="form.order" placeholder="请输入排序" type="number" style="width: 270px" size="small" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="参数特性" prop="property">
|
||||
<el-checkbox name="isChart" label="图表展示" @change="isChartChange" v-model="form.isChart" :true-label="1" :false-label="0"></el-checkbox>
|
||||
<el-checkbox name="isMonitor" label="实时监测" @change="isMonitorChange" v-model="form.isMonitor" :true-label="1" :false-label="0"></el-checkbox>
|
||||
<el-checkbox name="isReadonly" label="只读数据" @change="isReadonlyChange" v-model="form.isReadonly" :true-label="1" :false-label="0"></el-checkbox>
|
||||
<el-checkbox name="isHistory" label="历史存储" v-model="form.isHistory" :true-label="1" :false-label="0"></el-checkbox>
|
||||
<el-checkbox name="isSharePerm" label="分享权限" v-model="form.isSharePerm" :true-label="1" :false-label="0"></el-checkbox>
|
||||
</el-form-item>
|
||||
|
||||
<div style="margin-bottom: 20px; background-color: #ddd; height: 1px"></div>
|
||||
<el-form-item label="数据类型" prop="datatype">
|
||||
<el-select v-model="form.datatype" placeholder="请选择数据类型" style="width: 125px" size="small">
|
||||
<el-option key="integer" label="整数" value="integer"></el-option>
|
||||
<el-option key="decimal" label="小数" value="decimal"></el-option>
|
||||
<el-option key="bool" label="布尔" value="bool" :disabled="form.isChart == 1"></el-option>
|
||||
<el-option key="enum" label="枚举" value="enum" :disabled="form.isChart == 1"></el-option>
|
||||
<el-option key="string" label="字符串" value="string" :disabled="form.isChart == 1"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<div v-if="form.datatype == 'integer' || form.datatype == 'decimal'">
|
||||
<el-form-item label="取值范围">
|
||||
<el-row>
|
||||
<el-col :span="10">
|
||||
<el-input v-model="form.specs.min" placeholder="最小值" type="number" size="small" />
|
||||
</el-col>
|
||||
<el-col :span="4" align="center">到</el-col>
|
||||
<el-col :span="10">
|
||||
<el-input v-model="form.specs.max" placeholder="最大值" type="number" size="small" />
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form-item>
|
||||
<el-form-item label="单位">
|
||||
<el-input v-model="form.specs.unit" placeholder="例如:℃" style="width: 308px" size="small" />
|
||||
</el-form-item>
|
||||
<el-form-item label="步长">
|
||||
<el-input-number controls-position="right" v-model="form.specs.step" placeholder="例如:1" type="number" style="width: 308px" size="small" />
|
||||
</el-form-item>
|
||||
</div>
|
||||
<div v-if="form.datatype == 'bool'">
|
||||
<el-form-item label="布尔值" prop="">
|
||||
<el-row style="margin-bottom: 10px">
|
||||
<el-col :span="10">
|
||||
<el-input v-model="form.specs.falseText" placeholder="例如:关闭" size="small" />
|
||||
</el-col>
|
||||
<el-col :span="10" :offset="1">(0 值对应文本)</el-col>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<el-col :span="10">
|
||||
<el-input v-model="form.specs.trueText" placeholder="例如:打开" size="small" />
|
||||
</el-col>
|
||||
<el-col :span="10" :offset="1">(1 值对应文本)</el-col>
|
||||
</el-row>
|
||||
</el-form-item>
|
||||
</div>
|
||||
<div v-if="form.datatype == 'enum'">
|
||||
<el-form-item label="展示方式">
|
||||
<el-select v-model="form.specs.showWay" placeholder="请选择展示方式" style="width: 175px">
|
||||
<el-option key="select" label="下拉框" value="select"></el-option>
|
||||
<el-option key="button" label="按钮" value="button"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="枚举项" prop="">
|
||||
<el-row v-for="(item, index) in form.specs.enumList" :key="'enum' + index" style="margin-bottom: 10px">
|
||||
<el-col :span="8">
|
||||
<el-input v-model="item.value" placeholder="例如:0" size="small" />
|
||||
</el-col>
|
||||
<el-col :span="11" :offset="1">
|
||||
<el-input v-model="item.text" placeholder="例如:中速挡位" size="small" />
|
||||
</el-col>
|
||||
<el-col :span="3" :offset="1" v-if="index != 0"><a style="color: #f56c6c" @click="removeEnumItem(index)">删除</a></el-col>
|
||||
</el-row>
|
||||
<div>
|
||||
+
|
||||
<a style="color: #409eff" @click="addEnumItem()">添加枚举项</a>
|
||||
</div>
|
||||
</el-form-item>
|
||||
</div>
|
||||
<div v-if="form.datatype == 'string'">
|
||||
<el-form-item label="最大长度" prop="">
|
||||
<el-row>
|
||||
<el-col :span="10">
|
||||
<el-input v-model="form.specs.maxLength" placeholder="例如:1024" type="number" size="small" />
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form-item>
|
||||
</div>
|
||||
</el-form>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button type="primary" @click="submitForm">确 定</el-button>
|
||||
<el-button @click="cancel">取 消</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style>
|
||||
.specsColor {
|
||||
background-color: #fcfcfc;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script>
|
||||
import { listTemplate } from '@/api/iot/template';
|
||||
export default {
|
||||
name: 'things_parameter',
|
||||
dicts: ['iot_things_type', 'iot_data_type', 'iot_yes_no'],
|
||||
props: {
|
||||
data: {
|
||||
type: Object,
|
||||
default: null,
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
data: function (newVal, oldVal) {
|
||||
this.index = newVal.index;
|
||||
if (newVal && newVal.parameter.name && newVal.parameter.name != '') {
|
||||
this.form.name = newVal.parameter.name;
|
||||
this.form.id = newVal.parameter.id;
|
||||
this.form.order = newVal.parameter.order;
|
||||
this.form.isChart = newVal.parameter.isChart ? newVal.parameter.isChart : 0;
|
||||
this.form.isHistory = newVal.parameter.isHistory ? newVal.parameter.isHistory : 1;
|
||||
this.form.isSharePerm = newVal.parameter.isSharePerm ? newVal.parameter.isSharePerm : 0;
|
||||
this.form.isMonitor = newVal.parameter.isMonitor ? newVal.parameter.isMonitor : 0;
|
||||
this.form.isReadonly = newVal.parameter.isReadonly ? newVal.parameter.isReadonly : 0;
|
||||
this.form.specs = newVal.parameter.datatype;
|
||||
this.form.datatype = this.form.specs.type;
|
||||
if (!this.form.specs.enumList) {
|
||||
this.form.specs.enumList = [
|
||||
{
|
||||
value: '',
|
||||
text: '',
|
||||
},
|
||||
];
|
||||
}
|
||||
if (!this.form.specs.arrayType) {
|
||||
this.form.specs.arrayType = 'int';
|
||||
}
|
||||
}
|
||||
this.openEdit = true;
|
||||
this.getList();
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
// 遮罩层
|
||||
loading: true,
|
||||
// 总条数
|
||||
total: 0,
|
||||
// 通用物模型表格数据
|
||||
templateList: [],
|
||||
// 是否显示弹出层
|
||||
openEdit: false,
|
||||
// 查询参数
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
name: null,
|
||||
type: null,
|
||||
},
|
||||
// 参数索引
|
||||
index: -1,
|
||||
// 表单参数
|
||||
form: {},
|
||||
// 表单校验
|
||||
rules: {
|
||||
name: [
|
||||
{
|
||||
required: true,
|
||||
message: '参数名称不能为空',
|
||||
trigger: 'blur',
|
||||
},
|
||||
],
|
||||
id: [
|
||||
{
|
||||
required: true,
|
||||
message: '参数标识符不能为空',
|
||||
trigger: 'blur',
|
||||
},
|
||||
],
|
||||
order: [
|
||||
{
|
||||
required: true,
|
||||
message: '模型排序不能为空',
|
||||
trigger: 'blur',
|
||||
},
|
||||
],
|
||||
datatype: [
|
||||
{
|
||||
required: true,
|
||||
message: '数据类型不能为空',
|
||||
trigger: 'change',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
},
|
||||
created() {
|
||||
this.getList();
|
||||
this.reset();
|
||||
},
|
||||
methods: {
|
||||
/** 查询通用物模型列表 */
|
||||
getList() {
|
||||
this.loading = true;
|
||||
listTemplate(this.queryParams).then((response) => {
|
||||
//模板列表初始化isSelect值,用于单选
|
||||
for (let i = 0; i < response.rows.length; i++) {
|
||||
response.rows[i].isSelect = false;
|
||||
}
|
||||
this.templateList = response.rows;
|
||||
this.total = response.total;
|
||||
this.setRadioSelected(this.productId);
|
||||
this.loading = false;
|
||||
});
|
||||
},
|
||||
/** 单选数据 */
|
||||
rowClick(item) {
|
||||
if (item != null && item.datatype != 'array' && item.datatype != 'object') {
|
||||
this.form.name = item.templateName;
|
||||
this.form.id = item.identifier;
|
||||
this.form.order = item.modelOrder;
|
||||
this.form.isChart = item.isChart ? item.isChart : 0;
|
||||
this.form.isHistory = item.isHistory ? item.isHistory : 1;
|
||||
this.form.isSharePerm = item.isSharePerm ? item.isSharePerm : 0;
|
||||
this.form.isReadonly = item.isReadonly ? item.isReadonly : 0;
|
||||
this.form.isMonitor = item.isMonitor ? item.isMonitor : 0;
|
||||
this.form.datatype = item.datatype;
|
||||
// Json转对象
|
||||
this.form.specs = JSON.parse(item.specs);
|
||||
if (!this.form.specs.enumList) {
|
||||
this.form.specs.enumList = [
|
||||
{
|
||||
value: '',
|
||||
text: '',
|
||||
},
|
||||
];
|
||||
}
|
||||
if (!this.form.specs.arrayType) {
|
||||
this.form.specs.arrayType = 'int';
|
||||
}
|
||||
this.setRadioSelected(item.templateId);
|
||||
}
|
||||
},
|
||||
/** 设置单选按钮选中 */
|
||||
setRadioSelected(templateId) {
|
||||
for (let i = 0; i < this.templateList.length; i++) {
|
||||
if (this.templateList[i].templateId == templateId) {
|
||||
this.templateList[i].isSelect = true;
|
||||
} else {
|
||||
this.templateList[i].isSelect = false;
|
||||
}
|
||||
}
|
||||
},
|
||||
// 取消按钮
|
||||
cancel() {
|
||||
this.openEdit = false;
|
||||
this.reset();
|
||||
},
|
||||
// 表单重置
|
||||
reset() {
|
||||
this.index = -1;
|
||||
this.form = {
|
||||
name: null,
|
||||
id: null,
|
||||
order: 0,
|
||||
datatype: 'integer',
|
||||
isChart: 0,
|
||||
isHistory: 1,
|
||||
isSharePerm: 0,
|
||||
isMonitor: 0,
|
||||
isReadonly: 0,
|
||||
specs: {
|
||||
enumList: [
|
||||
{
|
||||
value: '',
|
||||
text: '',
|
||||
},
|
||||
],
|
||||
showWay: 'select', // 显示方式select=下拉选择框,button=按钮
|
||||
},
|
||||
};
|
||||
this.resetForm('form');
|
||||
},
|
||||
/** 搜索按钮操作 */
|
||||
handleQuery() {
|
||||
this.queryParams.pageNum = 1;
|
||||
this.getList();
|
||||
},
|
||||
/** 提交按钮 */
|
||||
submitForm() {
|
||||
this.$refs['form'].validate((valid) => {
|
||||
if (valid) {
|
||||
// 格式化datatype
|
||||
this.form.datatype = this.formatThingsSpecs();
|
||||
// 清空不需要存储数据
|
||||
delete this.form.specs;
|
||||
this.openEdit = false;
|
||||
// 返回参数对象
|
||||
let data = {
|
||||
parameter: JSON.parse(JSON.stringify(this.form)),
|
||||
index: this.index,
|
||||
};
|
||||
console.log('data', data);
|
||||
this.$emit('dataEvent', data);
|
||||
this.reset();
|
||||
}
|
||||
});
|
||||
},
|
||||
// 是否图表展示改变
|
||||
isChartChange() {
|
||||
if (this.form.isChart == 1) {
|
||||
this.form.isReadonly = 1;
|
||||
} else {
|
||||
this.form.isMonitor = 0;
|
||||
}
|
||||
},
|
||||
// 是否实时监测改变
|
||||
isMonitorChange() {
|
||||
if (this.form.isMonitor == 1) {
|
||||
this.form.isReadonly = 1;
|
||||
this.form.isChart = 1;
|
||||
}
|
||||
},
|
||||
// 是否只读数据改变
|
||||
isReadonlyChange() {
|
||||
if (this.form.isReadonly == 0) {
|
||||
this.form.isMonitor = 0;
|
||||
this.form.isChart = 0;
|
||||
}
|
||||
},
|
||||
// 格式化物模型
|
||||
formatThingsSpecs() {
|
||||
var data = {};
|
||||
data.type = this.form.datatype;
|
||||
if (this.form.datatype == 'integer' || this.form.datatype == 'decimal') {
|
||||
data.min = Number(this.form.specs.min ? this.form.specs.min : 0);
|
||||
data.max = Number(this.form.specs.max ? this.form.specs.max : 100);
|
||||
data.unit = this.form.specs.unit ? this.form.specs.unit : '';
|
||||
data.step = Number(this.form.specs.step ? this.form.specs.step : 1);
|
||||
} else if (this.form.datatype == 'string') {
|
||||
data.maxLength = Number(this.form.specs.maxLength ? this.form.specs.maxLength : 1024);
|
||||
} else if (this.form.datatype == 'bool') {
|
||||
data.falseText = this.form.specs.falseText ? this.form.specs.falseText : '关闭';
|
||||
data.trueText = this.form.specs.trueText ? this.form.specs.trueText : '打开';
|
||||
} else if (this.form.datatype == 'array') {
|
||||
data.arrayType = this.form.specs.arrayType;
|
||||
} else if (this.form.datatype == 'enum') {
|
||||
data.showWay = this.form.specs.showWay;
|
||||
if (this.form.specs.enumList && this.form.specs.enumList[0].text != '') {
|
||||
data.enumList = this.form.specs.enumList;
|
||||
} else {
|
||||
data.showWay = 'select';
|
||||
data.enumList = [
|
||||
{
|
||||
value: '0',
|
||||
text: '低',
|
||||
},
|
||||
{
|
||||
value: '1',
|
||||
text: '高',
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
||||
return data;
|
||||
},
|
||||
/** 添加枚举项 */
|
||||
addEnumItem() {
|
||||
this.form.specs.enumList.push({
|
||||
value: '',
|
||||
text: '',
|
||||
});
|
||||
},
|
||||
/** 删除枚举项 */
|
||||
removeEnumItem(index) {
|
||||
this.form.specs.enumList.splice(index, 1);
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
Reference in New Issue
Block a user