mirror of
https://gitee.com/beecue/fastbee.git
synced 2025-12-17 16:36:03 +08:00
分组中添加设备前端
This commit is contained in:
@@ -9,6 +9,15 @@ export function listDevice(query) {
|
||||
})
|
||||
}
|
||||
|
||||
// 查询分组可添加设备分页列表
|
||||
export function listDeviceByGroup(query) {
|
||||
return request({
|
||||
url: '/iot/device/listByGroup',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
// 查询设备简短列表
|
||||
export function listDeviceShort(query) {
|
||||
return request({
|
||||
|
||||
@@ -390,7 +390,7 @@ export default {
|
||||
// 信息详情
|
||||
notice: {},
|
||||
// 是否为管理员
|
||||
isAdmin: true,
|
||||
isAdmin: false,
|
||||
// 设备列表
|
||||
deviceList: [],
|
||||
// 设备总数
|
||||
@@ -433,11 +433,8 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
init() {
|
||||
// 设置用户的角色 用以区分自己创建的设备
|
||||
// 由于admin可以看所有数据所以判断
|
||||
if (this.$store.state.user.roles.indexOf("admin") === -1) {
|
||||
this.isAdmin = false
|
||||
} else {
|
||||
if (this.$store.state.user.roles.indexOf("tenant") === -1 && this.$store.state.user.roles.indexOf("general") === -1) {
|
||||
this.isAdmin = true
|
||||
this.getServer();
|
||||
this.getMqttStats();
|
||||
this.statisticMqtt();
|
||||
|
||||
@@ -192,7 +192,7 @@ import {
|
||||
|
||||
export default {
|
||||
name: "Device",
|
||||
dicts: ['iot_device_status', 'iot_is_enable','iot_location_way'],
|
||||
dicts: ['iot_device_status', 'iot_is_enable', 'iot_location_way'],
|
||||
components: {
|
||||
mqttClient
|
||||
},
|
||||
@@ -237,6 +237,7 @@ export default {
|
||||
deviceName: null,
|
||||
productId: null,
|
||||
groupId: null,
|
||||
groupId: null,
|
||||
productName: null,
|
||||
userId: null,
|
||||
userName: null,
|
||||
@@ -250,6 +251,18 @@ export default {
|
||||
};
|
||||
},
|
||||
created() {
|
||||
// 页码筛选
|
||||
this.queryParams.pageNum = Number(this.$route.query.pageNum);
|
||||
// 产品筛选
|
||||
let productId = this.$route.query.productId
|
||||
if (productId != null) {
|
||||
this.queryParams.productId = Number(productId);
|
||||
}
|
||||
// 分组筛选
|
||||
let groupId = this.$route.query.groupId
|
||||
if (groupId != null) {
|
||||
this.queryParams.groupId = Number(groupId);
|
||||
}
|
||||
this.getList();
|
||||
|
||||
},
|
||||
@@ -257,12 +270,18 @@ export default {
|
||||
const time = this.$route.query.t;
|
||||
if (time != null && time != this.uniqueId) {
|
||||
this.uniqueId = time;
|
||||
// 页码筛选
|
||||
this.queryParams.pageNum = Number(this.$route.query.pageNum);
|
||||
// 产品筛选
|
||||
let productId = this.$route.query.productId
|
||||
if (productId != null) {
|
||||
this.queryParams.productId = Number(productId);
|
||||
}
|
||||
// 分组筛选
|
||||
let groupId = this.$route.query.groupId
|
||||
if (groupId != null) {
|
||||
this.queryParams.groupId = Number(groupId);
|
||||
}
|
||||
this.getList();
|
||||
}
|
||||
},
|
||||
@@ -443,7 +462,7 @@ export default {
|
||||
/** 查询所有简短设备列表 */
|
||||
getList() {
|
||||
this.loading = true;
|
||||
this.queryParams.params={};
|
||||
this.queryParams.params = {};
|
||||
if (null != this.daterangeActiveTime && '' != this.daterangeActiveTime) {
|
||||
this.queryParams.params['beginActiveTime'] = this.daterangeActiveTime[0];
|
||||
this.queryParams.params['endActiveTime'] = this.daterangeActiveTime[1];
|
||||
@@ -470,6 +489,7 @@ export default {
|
||||
resetQuery() {
|
||||
this.daterangeActiveTime = [];
|
||||
this.queryParams.productId = null;
|
||||
this.queryParams.groupId = null;
|
||||
this.resetForm("queryForm");
|
||||
this.handleQuery();
|
||||
},
|
||||
@@ -513,7 +533,7 @@ export default {
|
||||
// 筛选监测数据
|
||||
this.monitorThings = thingsModel.properties.filter(item => item.isMonitor == 1);
|
||||
// 监测数据集合初始化
|
||||
this.dataList=[];
|
||||
this.dataList = [];
|
||||
for (let i = 0; i < this.monitorThings.length; i++) {
|
||||
this.dataList.push({
|
||||
id: this.monitorThings[i].id,
|
||||
@@ -575,10 +595,10 @@ export default {
|
||||
symbol: 'none',
|
||||
sampling: 'lttb',
|
||||
itemStyle: {
|
||||
color: i>9? color[0]:color[i]
|
||||
color: i > 9 ? color[0] : color[i]
|
||||
},
|
||||
areaStyle: {
|
||||
|
||||
|
||||
},
|
||||
data: []
|
||||
}]
|
||||
|
||||
@@ -32,24 +32,24 @@ import {
|
||||
getDeviceIds
|
||||
} from "@/api/iot/group"
|
||||
import {
|
||||
listDeviceShort,
|
||||
listDeviceByGroup,
|
||||
} from "@/api/iot/device";
|
||||
|
||||
export default {
|
||||
name: "device-list",
|
||||
dicts: ['iot_device_status'],
|
||||
props: {
|
||||
groupId: {
|
||||
type: Number,
|
||||
group: {
|
||||
type: Object,
|
||||
default: null
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
// 设备分组
|
||||
deviceGroup:{},
|
||||
// 遮罩层
|
||||
loading: true,
|
||||
// 分组信息
|
||||
parentGroupId:0,
|
||||
// 选中数组
|
||||
ids: [],
|
||||
// 显示搜索条件
|
||||
@@ -62,6 +62,7 @@ export default {
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
userId:null,
|
||||
deviceName: null,
|
||||
productId: null,
|
||||
productName: null,
|
||||
@@ -78,11 +79,12 @@ export default {
|
||||
},
|
||||
watch: {
|
||||
// 获取到父组件传递的group后,刷新列表
|
||||
groupId: {
|
||||
group: {
|
||||
handler(newVal, oldVal) {
|
||||
this.parentGroupId = newVal;
|
||||
this.deviceGroup = newVal;
|
||||
// 获取分组下的设备
|
||||
this.queryParams.pageNum=1;
|
||||
this.queryParams.userId=this.deviceGroup.userId;
|
||||
this.queryParams.pageNum = 1;
|
||||
this.getDeviceIdsByGroupId();
|
||||
},
|
||||
immediate: true
|
||||
@@ -94,7 +96,7 @@ export default {
|
||||
methods: {
|
||||
// 获取分组下关联的设备ID数组
|
||||
getDeviceIdsByGroupId() {
|
||||
getDeviceIds(this.parentGroupId).then(response => {
|
||||
getDeviceIds(this.deviceGroup.groupId).then(response => {
|
||||
this.ids = response.data;
|
||||
this.getList();
|
||||
});
|
||||
@@ -107,7 +109,7 @@ export default {
|
||||
this.queryParams.params["beginActiveTime"] = this.daterangeActiveTime[0];
|
||||
this.queryParams.params["endActiveTime"] = this.daterangeActiveTime[1];
|
||||
}
|
||||
listDeviceShort(this.queryParams).then(response => {
|
||||
listDeviceByGroup(this.queryParams).then(response => {
|
||||
this.deviceList = response.rows;
|
||||
this.total = response.total;
|
||||
this.loading = false;
|
||||
|
||||
@@ -25,8 +25,9 @@
|
||||
</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="230">
|
||||
<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>
|
||||
@@ -36,7 +37,7 @@
|
||||
<pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />
|
||||
|
||||
<el-dialog title="选择设备" :visible.sync="openDeviceList" width="800px" append-to-body>
|
||||
<device-list ref="deviceList" :groupId="deviceGroup.groupId" @idsToParentEvent="getChildData($event)"></device-list>
|
||||
<device-list ref="deviceList" :group="group" @idsToParentEvent="getChildData($event)"></device-list>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button type="primary" @click="handleDeviceSelected">确 定</el-button>
|
||||
<el-button @click="closeSelectDeviceList">取 消</el-button>
|
||||
@@ -112,7 +113,7 @@ export default {
|
||||
userName: null,
|
||||
},
|
||||
// 设备分组
|
||||
deviceGroup: {},
|
||||
group: {},
|
||||
// 表单参数
|
||||
form: {},
|
||||
// 表单校验
|
||||
@@ -141,6 +142,16 @@ export default {
|
||||
this.getList();
|
||||
},
|
||||
methods: {
|
||||
/** 查看设备按钮操作 */
|
||||
handleViewDevice(groupId) {
|
||||
this.$router.push({
|
||||
path: '/iot/device',
|
||||
query: {
|
||||
t: Date.now(),
|
||||
groupId: groupId,
|
||||
}
|
||||
});
|
||||
},
|
||||
/** 查询设备分组列表 */
|
||||
getList() {
|
||||
this.loading = true;
|
||||
@@ -211,9 +222,9 @@ export default {
|
||||
},
|
||||
/** 选择设备 */
|
||||
selectDevice(row) {
|
||||
this.deviceGroup.groupId = row.groupId;
|
||||
this.group = row;
|
||||
this.openDeviceList = true;
|
||||
this.$refs.deviceList.getDeviceIdsByGroupId();
|
||||
// this.$refs.deviceList.getDeviceIdsByGroupId(row.groupId);
|
||||
},
|
||||
/** 提交按钮 */
|
||||
submitForm() {
|
||||
@@ -253,11 +264,11 @@ export default {
|
||||
},
|
||||
// 获取子组件选中的ID数组
|
||||
getChildData(data) {
|
||||
this.deviceGroup.deviceIds = data;
|
||||
this.group.deviceIds = data;
|
||||
},
|
||||
// 更新分组下的设备
|
||||
handleDeviceSelected() {
|
||||
updateDeviceGroups(this.deviceGroup).then(response => {
|
||||
updateDeviceGroups(this.group).then(response => {
|
||||
this.$modal.msgSuccess("更新分组下的设备成功");
|
||||
this.openDeviceList = false;
|
||||
})
|
||||
|
||||
@@ -70,7 +70,7 @@
|
||||
<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="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="info" icon="el-icon-download" @click="handleGeneratorSDK(item)" v-hasPermi="['iot:product:edit']" v-if="item.status==2">下载SDK</el-button>
|
||||
<el-button size="mini" type="warning" icon="el-icon-search" @click="handleViewDevice(item.productId)" v-hasPermi="['tool:gen:edit']">查看设备</el-button>
|
||||
<el-button size="mini" type="warning" icon="el-icon-search" @click="handleViewDevice(item.productId)" v-hasPermi="['iot:device:query']">查看设备</el-button>
|
||||
</el-button-group>
|
||||
</el-card>
|
||||
</el-col>
|
||||
@@ -183,7 +183,7 @@ export default {
|
||||
}).catch(() => {});
|
||||
}).catch(() => {});
|
||||
},
|
||||
/** 修改按钮操作 */
|
||||
/** 查看设备按钮操作 */
|
||||
handleViewDevice(productId) {
|
||||
this.$router.push({
|
||||
path: '/iot/device',
|
||||
|
||||
Reference in New Issue
Block a user