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) {
|
export function listDeviceShort(query) {
|
||||||
return request({
|
return request({
|
||||||
|
|||||||
@@ -390,7 +390,7 @@ export default {
|
|||||||
// 信息详情
|
// 信息详情
|
||||||
notice: {},
|
notice: {},
|
||||||
// 是否为管理员
|
// 是否为管理员
|
||||||
isAdmin: true,
|
isAdmin: false,
|
||||||
// 设备列表
|
// 设备列表
|
||||||
deviceList: [],
|
deviceList: [],
|
||||||
// 设备总数
|
// 设备总数
|
||||||
@@ -433,11 +433,8 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
init() {
|
init() {
|
||||||
// 设置用户的角色 用以区分自己创建的设备
|
if (this.$store.state.user.roles.indexOf("tenant") === -1 && this.$store.state.user.roles.indexOf("general") === -1) {
|
||||||
// 由于admin可以看所有数据所以判断
|
this.isAdmin = true
|
||||||
if (this.$store.state.user.roles.indexOf("admin") === -1) {
|
|
||||||
this.isAdmin = false
|
|
||||||
} else {
|
|
||||||
this.getServer();
|
this.getServer();
|
||||||
this.getMqttStats();
|
this.getMqttStats();
|
||||||
this.statisticMqtt();
|
this.statisticMqtt();
|
||||||
|
|||||||
@@ -237,6 +237,7 @@ export default {
|
|||||||
deviceName: null,
|
deviceName: null,
|
||||||
productId: null,
|
productId: null,
|
||||||
groupId: null,
|
groupId: null,
|
||||||
|
groupId: null,
|
||||||
productName: null,
|
productName: null,
|
||||||
userId: null,
|
userId: null,
|
||||||
userName: null,
|
userName: null,
|
||||||
@@ -250,6 +251,18 @@ export default {
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
created() {
|
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();
|
this.getList();
|
||||||
|
|
||||||
},
|
},
|
||||||
@@ -257,12 +270,18 @@ export default {
|
|||||||
const time = this.$route.query.t;
|
const time = this.$route.query.t;
|
||||||
if (time != null && time != this.uniqueId) {
|
if (time != null && time != this.uniqueId) {
|
||||||
this.uniqueId = time;
|
this.uniqueId = time;
|
||||||
|
// 页码筛选
|
||||||
this.queryParams.pageNum = Number(this.$route.query.pageNum);
|
this.queryParams.pageNum = Number(this.$route.query.pageNum);
|
||||||
// 产品筛选
|
// 产品筛选
|
||||||
let productId = this.$route.query.productId
|
let productId = this.$route.query.productId
|
||||||
if (productId != null) {
|
if (productId != null) {
|
||||||
this.queryParams.productId = Number(productId);
|
this.queryParams.productId = Number(productId);
|
||||||
}
|
}
|
||||||
|
// 分组筛选
|
||||||
|
let groupId = this.$route.query.groupId
|
||||||
|
if (groupId != null) {
|
||||||
|
this.queryParams.groupId = Number(groupId);
|
||||||
|
}
|
||||||
this.getList();
|
this.getList();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -470,6 +489,7 @@ export default {
|
|||||||
resetQuery() {
|
resetQuery() {
|
||||||
this.daterangeActiveTime = [];
|
this.daterangeActiveTime = [];
|
||||||
this.queryParams.productId = null;
|
this.queryParams.productId = null;
|
||||||
|
this.queryParams.groupId = null;
|
||||||
this.resetForm("queryForm");
|
this.resetForm("queryForm");
|
||||||
this.handleQuery();
|
this.handleQuery();
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -32,24 +32,24 @@ import {
|
|||||||
getDeviceIds
|
getDeviceIds
|
||||||
} from "@/api/iot/group"
|
} from "@/api/iot/group"
|
||||||
import {
|
import {
|
||||||
listDeviceShort,
|
listDeviceByGroup,
|
||||||
} from "@/api/iot/device";
|
} from "@/api/iot/device";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "device-list",
|
name: "device-list",
|
||||||
dicts: ['iot_device_status'],
|
dicts: ['iot_device_status'],
|
||||||
props: {
|
props: {
|
||||||
groupId: {
|
group: {
|
||||||
type: Number,
|
type: Object,
|
||||||
default: null
|
default: null
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
// 设备分组
|
||||||
|
deviceGroup:{},
|
||||||
// 遮罩层
|
// 遮罩层
|
||||||
loading: true,
|
loading: true,
|
||||||
// 分组信息
|
|
||||||
parentGroupId:0,
|
|
||||||
// 选中数组
|
// 选中数组
|
||||||
ids: [],
|
ids: [],
|
||||||
// 显示搜索条件
|
// 显示搜索条件
|
||||||
@@ -62,6 +62,7 @@ export default {
|
|||||||
queryParams: {
|
queryParams: {
|
||||||
pageNum: 1,
|
pageNum: 1,
|
||||||
pageSize: 10,
|
pageSize: 10,
|
||||||
|
userId:null,
|
||||||
deviceName: null,
|
deviceName: null,
|
||||||
productId: null,
|
productId: null,
|
||||||
productName: null,
|
productName: null,
|
||||||
@@ -78,10 +79,11 @@ export default {
|
|||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
// 获取到父组件传递的group后,刷新列表
|
// 获取到父组件传递的group后,刷新列表
|
||||||
groupId: {
|
group: {
|
||||||
handler(newVal, oldVal) {
|
handler(newVal, oldVal) {
|
||||||
this.parentGroupId = newVal;
|
this.deviceGroup = newVal;
|
||||||
// 获取分组下的设备
|
// 获取分组下的设备
|
||||||
|
this.queryParams.userId=this.deviceGroup.userId;
|
||||||
this.queryParams.pageNum = 1;
|
this.queryParams.pageNum = 1;
|
||||||
this.getDeviceIdsByGroupId();
|
this.getDeviceIdsByGroupId();
|
||||||
},
|
},
|
||||||
@@ -94,7 +96,7 @@ export default {
|
|||||||
methods: {
|
methods: {
|
||||||
// 获取分组下关联的设备ID数组
|
// 获取分组下关联的设备ID数组
|
||||||
getDeviceIdsByGroupId() {
|
getDeviceIdsByGroupId() {
|
||||||
getDeviceIds(this.parentGroupId).then(response => {
|
getDeviceIds(this.deviceGroup.groupId).then(response => {
|
||||||
this.ids = response.data;
|
this.ids = response.data;
|
||||||
this.getList();
|
this.getList();
|
||||||
});
|
});
|
||||||
@@ -107,7 +109,7 @@ export default {
|
|||||||
this.queryParams.params["beginActiveTime"] = this.daterangeActiveTime[0];
|
this.queryParams.params["beginActiveTime"] = this.daterangeActiveTime[0];
|
||||||
this.queryParams.params["endActiveTime"] = this.daterangeActiveTime[1];
|
this.queryParams.params["endActiveTime"] = this.daterangeActiveTime[1];
|
||||||
}
|
}
|
||||||
listDeviceShort(this.queryParams).then(response => {
|
listDeviceByGroup(this.queryParams).then(response => {
|
||||||
this.deviceList = response.rows;
|
this.deviceList = response.rows;
|
||||||
this.total = response.total;
|
this.total = response.total;
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
|
|||||||
@@ -25,8 +25,9 @@
|
|||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="备注" align="left" prop="remark" />
|
<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">
|
<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="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="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>
|
<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" />
|
<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>
|
<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">
|
<div slot="footer" class="dialog-footer">
|
||||||
<el-button type="primary" @click="handleDeviceSelected">确 定</el-button>
|
<el-button type="primary" @click="handleDeviceSelected">确 定</el-button>
|
||||||
<el-button @click="closeSelectDeviceList">取 消</el-button>
|
<el-button @click="closeSelectDeviceList">取 消</el-button>
|
||||||
@@ -112,7 +113,7 @@ export default {
|
|||||||
userName: null,
|
userName: null,
|
||||||
},
|
},
|
||||||
// 设备分组
|
// 设备分组
|
||||||
deviceGroup: {},
|
group: {},
|
||||||
// 表单参数
|
// 表单参数
|
||||||
form: {},
|
form: {},
|
||||||
// 表单校验
|
// 表单校验
|
||||||
@@ -141,6 +142,16 @@ export default {
|
|||||||
this.getList();
|
this.getList();
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
/** 查看设备按钮操作 */
|
||||||
|
handleViewDevice(groupId) {
|
||||||
|
this.$router.push({
|
||||||
|
path: '/iot/device',
|
||||||
|
query: {
|
||||||
|
t: Date.now(),
|
||||||
|
groupId: groupId,
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
/** 查询设备分组列表 */
|
/** 查询设备分组列表 */
|
||||||
getList() {
|
getList() {
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
@@ -211,9 +222,9 @@ export default {
|
|||||||
},
|
},
|
||||||
/** 选择设备 */
|
/** 选择设备 */
|
||||||
selectDevice(row) {
|
selectDevice(row) {
|
||||||
this.deviceGroup.groupId = row.groupId;
|
this.group = row;
|
||||||
this.openDeviceList = true;
|
this.openDeviceList = true;
|
||||||
this.$refs.deviceList.getDeviceIdsByGroupId();
|
// this.$refs.deviceList.getDeviceIdsByGroupId(row.groupId);
|
||||||
},
|
},
|
||||||
/** 提交按钮 */
|
/** 提交按钮 */
|
||||||
submitForm() {
|
submitForm() {
|
||||||
@@ -253,11 +264,11 @@ export default {
|
|||||||
},
|
},
|
||||||
// 获取子组件选中的ID数组
|
// 获取子组件选中的ID数组
|
||||||
getChildData(data) {
|
getChildData(data) {
|
||||||
this.deviceGroup.deviceIds = data;
|
this.group.deviceIds = data;
|
||||||
},
|
},
|
||||||
// 更新分组下的设备
|
// 更新分组下的设备
|
||||||
handleDeviceSelected() {
|
handleDeviceSelected() {
|
||||||
updateDeviceGroups(this.deviceGroup).then(response => {
|
updateDeviceGroups(this.group).then(response => {
|
||||||
this.$modal.msgSuccess("更新分组下的设备成功");
|
this.$modal.msgSuccess("更新分组下的设备成功");
|
||||||
this.openDeviceList = false;
|
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="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="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="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-button-group>
|
||||||
</el-card>
|
</el-card>
|
||||||
</el-col>
|
</el-col>
|
||||||
@@ -183,7 +183,7 @@ export default {
|
|||||||
}).catch(() => {});
|
}).catch(() => {});
|
||||||
}).catch(() => {});
|
}).catch(() => {});
|
||||||
},
|
},
|
||||||
/** 修改按钮操作 */
|
/** 查看设备按钮操作 */
|
||||||
handleViewDevice(productId) {
|
handleViewDevice(productId) {
|
||||||
this.$router.push({
|
this.$router.push({
|
||||||
path: '/iot/device',
|
path: '/iot/device',
|
||||||
|
|||||||
Reference in New Issue
Block a user