diff --git a/vue/src/api/iot/device.js b/vue/src/api/iot/device.js index 4ca47c8c..633608e4 100644 --- a/vue/src/api/iot/device.js +++ b/vue/src/api/iot/device.js @@ -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({ diff --git a/vue/src/views/index.vue b/vue/src/views/index.vue index 0b7e1d3d..5a478241 100644 --- a/vue/src/views/index.vue +++ b/vue/src/views/index.vue @@ -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(); diff --git a/vue/src/views/iot/device/index.vue b/vue/src/views/iot/device/index.vue index 821dbbdc..35139520 100644 --- a/vue/src/views/iot/device/index.vue +++ b/vue/src/views/iot/device/index.vue @@ -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: [] }] diff --git a/vue/src/views/iot/group/device-list.vue b/vue/src/views/iot/group/device-list.vue index 0f0e6ec6..100d7621 100644 --- a/vue/src/views/iot/group/device-list.vue +++ b/vue/src/views/iot/group/device-list.vue @@ -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; diff --git a/vue/src/views/iot/group/index.vue b/vue/src/views/iot/group/index.vue index 39d02ee5..d7cbaf86 100644 --- a/vue/src/views/iot/group/index.vue +++ b/vue/src/views/iot/group/index.vue @@ -25,8 +25,9 @@ - +