Commit 652a017c by YG8999

设备门店房间绑定

parent 80a5695d
...@@ -52,3 +52,21 @@ export function openOrClose(data) { ...@@ -52,3 +52,21 @@ export function openOrClose(data) {
}) })
} }
// 查询设备信息列表
export function listByRoom(query) {
return request({
url: '/system/device/listByRoom',
method: 'get',
params: query
})
}
// 查询设备信息列表
export function notRoomIdList(query) {
return request({
url: '/system/device/notRoomIdList',
method: 'get',
params: query
})
}
...@@ -49,3 +49,21 @@ export function getRoomPack(id) { ...@@ -49,3 +49,21 @@ export function getRoomPack(id) {
method: 'get' method: 'get'
}) })
} }
// 添加房间设备
export function addRoomDevice(data) {
return request({
url: '/system/room/addRoomDevice',
method: 'put',
params: data
})
}
// 删除房间设备
export function deleteRoomDevice(data) {
return request({
url: '/system/room/deleteRoomDevice',
method: 'put',
data: data
})
}
...@@ -8,14 +8,14 @@ ...@@ -8,14 +8,14 @@
<div class="right-menu"> <div class="right-menu">
<template v-if="device!=='mobile'"> <template v-if="device!=='mobile'">
<search id="header-search" class="right-menu-item" /> <search id="header-search" class="right-menu-item" />
<el-tooltip content="源码地址" effect="dark" placement="bottom">
<ruo-yi-git id="ruoyi-git" class="right-menu-item hover-effect" />
</el-tooltip>
<el-tooltip content="文档地址" effect="dark" placement="bottom"> <!-- <el-tooltip content="源码地址" effect="dark" placement="bottom">-->
<ruo-yi-doc id="ruoyi-doc" class="right-menu-item hover-effect" /> <!-- <ruo-yi-git id="ruoyi-git" class="right-menu-item hover-effect" />-->
</el-tooltip> <!-- </el-tooltip>-->
<!-- <el-tooltip content="文档地址" effect="dark" placement="bottom">-->
<!-- <ruo-yi-doc id="ruoyi-doc" class="right-menu-item hover-effect" />-->
<!-- </el-tooltip>-->
<screenfull id="screenfull" class="right-menu-item hover-effect" /> <screenfull id="screenfull" class="right-menu-item hover-effect" />
......
...@@ -6,6 +6,7 @@ import user from './modules/user' ...@@ -6,6 +6,7 @@ import user from './modules/user'
import tagsView from './modules/tagsView' import tagsView from './modules/tagsView'
import permission from './modules/permission' import permission from './modules/permission'
import settings from './modules/settings' import settings from './modules/settings'
import room from './modules/room'
import getters from './getters' import getters from './getters'
Vue.use(Vuex) Vue.use(Vuex)
...@@ -17,7 +18,8 @@ const store = new Vuex.Store({ ...@@ -17,7 +18,8 @@ const store = new Vuex.Store({
user, user,
tagsView, tagsView,
permission, permission,
settings settings,
room
}, },
getters getters
}) })
......
import Cookies from "js-cookie";
const state = {
showDeviceList: false,
roomId: ''
}
const mutations = {
SHOW_DEVICE_LIST: (state, showDeviceList) => {
state.showDeviceList = showDeviceList
},
ROOM_ID: (state, roomId) => {
state.roomId = roomId
},
}
const actions = {
setShowDeviceList({ commit }, showDeviceList) {
commit('SHOW_DEVICE_LIST', showDeviceList)
},
setRoomId({ commit }, roomId) {
commit('ROOM_ID', roomId)
},
}
export default {
namespaced: true,
state,
mutations,
actions
}
...@@ -150,6 +150,13 @@ ...@@ -150,6 +150,13 @@
@click="handleDelete(scope.row)" @click="handleDelete(scope.row)"
v-hasPermi="['system:room:remove']" v-hasPermi="['system:room:remove']"
>删除</el-button> >删除</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-tree-table"
@click="handleDevice(scope.row)"
v-hasPermi="['system:room:edit']"
>设备配置</el-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
...@@ -258,7 +265,7 @@ ...@@ -258,7 +265,7 @@
<el-button @click="packCancel">取 消</el-button> <el-button @click="packCancel">取 消</el-button>
</div> </div>
</el-dialog> </el-dialog>
<roomDevice/>
</div> </div>
</template> </template>
...@@ -266,9 +273,13 @@ ...@@ -266,9 +273,13 @@
import { listRoom, getRoom, delRoom, addRoom, updateRoom } from "@/api/system/room"; import { listRoom, getRoom, delRoom, addRoom, updateRoom } from "@/api/system/room";
import { allList } from '@/api/system/store' import { allList } from '@/api/system/store'
import {insertPack, query} from '@/api/system/pack' import {insertPack, query} from '@/api/system/pack'
import RoomDevice from './roomDevice'
export default { export default {
name: "Room", name: "Room",
components: {
RoomDevice,
},
dicts: ['store_room_status', 'store_room_type','indoor_facilities'], dicts: ['store_room_status', 'store_room_type','indoor_facilities'],
data() { data() {
return { return {
...@@ -336,6 +347,14 @@ export default { ...@@ -336,6 +347,14 @@ export default {
this.onGetAllStoreList() this.onGetAllStoreList()
this.onPackList() this.onPackList()
}, },
computed: {
get() {
return this.$store.state.room.showDeviceList
},
set(val) {
this.$store.dispatch('room/setShowDeviceList', val)
}
},
methods: { methods: {
onChange(e){ onChange(e){
this.form.facilities = e.join() this.form.facilities = e.join()
...@@ -523,6 +542,10 @@ export default { ...@@ -523,6 +542,10 @@ export default {
...this.queryParams ...this.queryParams
}, `room_${new Date().getTime()}.xlsx`) }, `room_${new Date().getTime()}.xlsx`)
}, },
handleDevice(row) {
this.$store.dispatch('room/setRoomId', row.id);
this.$store.dispatch('room/setShowDeviceList', true);
},
submitPackForm() { submitPackForm() {
this.$refs["packForm"].validate(valid => { this.$refs["packForm"].validate(valid => {
if (valid) { if (valid) {
......
<template>
<el-drawer title="房间设备信息" size="60%" :visible.sync="visible" :append-to-body="true">
<div class="drawer-container">
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="100px">
<el-form-item label="设备名称" prop="devName">
<el-input
v-model="queryParams.devName"
placeholder="请输入设备名称"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="设备ID" prop="devId">
<el-input
v-model="queryParams.devId"
placeholder="请输入设备ID"
clearable
@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="['system:room:edit']"
>新增
</el-button>
</el-col>
</el-row>
<el-table v-loading="loading" :data="deviceList" >
<!-- <el-table-column type="selection" width="70" align="center"/>-->
<!-- <el-table-column label="${comment}" align="center" prop="id" />-->
<el-table-column label="设备名称" align="center" prop="devName"/>
<!-- <el-table-column label="设备MAC" align="center" prop="devMac"/>-->
<el-table-column label="设备ID" align="center" prop="devId"/>
<el-table-column label="设备密码" align="center" prop="devPsw"/>
<!-- <el-table-column label="版本号" align=align"center" prop="devVer"/>-->
<el-table-column label="设备类型" align="center" prop="devType">
<template slot-scope="scope">
<dict-tag :options="dict.type.device_type" :value="scope.row.devType"/>
</template>
</el-table-column>
<el-table-column label="分组" align="center" prop="group"/>
<el-table-column label="设备状态" align="center" prop="status">
<template slot-scope="scope">
<dict-tag :options="dict.type.device_status" :value="scope.row.status"/>
</template>
</el-table-column>
<el-table-column label="电量" align="center" prop="voltage"/>
<el-table-column label="信号值" align="center" prop="signalValue"/>
<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-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['system:room:edit']"
>删除
</el-button>
<el-button v-if="scope.row.devType=='CCEE'"
size="mini"
type="text"
icon="el-icon-switch"
@click="openOrClose(scope.row, '10')"
v-hasPermi="['system:device:edit']"
>开门
</el-button>
<el-button v-if="scope.row.devType=='CCEE'"
size="mini"
type="text"
icon="el-icon-switch"
@click="openOrClose(scope.row, '30')"
v-hasPermi="['system:device:edit']"
>关门
</el-button>
<el-button v-if="scope.row.devType=='0001'"
size="mini"
type="text"
icon="el-icon-switch"
@click="openOrClose(scope.row, '20')"
v-hasPermi="['system:device:edit']"
>取电
</el-button>
<el-button v-if="scope.row.devType=='0001'"
size="mini"
type="text"
icon="el-icon-switch"
@click="openOrClose(scope.row, '40')"
v-hasPermi="['system:device:edit']"
>断电
</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>
<selectDevice ref="select" :roomId="roomId" @ok="handleQuery"/>
</div>
</el-drawer>
</template>
<script>
import {listByRoom, openOrClose} from "@/api/system/device";
import { deleteRoomDevice } from "@/api/system/room";
import selectDevice from "./selectDevice";
export default {
name: "RoomDevice",
dicts: ['device_ver_type', 'device_type','device_status'],
components: {selectDevice},
data() {
return {
// 遮罩层
loading: true,
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 总条数
total: 0,
// 设备信息表格数据
deviceList: [],
// 弹出层标题
title: "",
// 是否显示弹出层
open: false,
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
devName: null,
devId: null,
devVer: null,
devType: null,
status: null,
roomId: this.$store.state.room.roomId
},
// 表单参数
form: {},
};
},
created() {
this.getList();
},
computed: {
visible: {
get() {
return this.$store.state.room.showDeviceList
},
set(val) {
this.$store.dispatch('room/setShowDeviceList', val);
}
},
roomId: {
get() {
return this.$store.state.room.roomId
},
set(val) {
this.$store.dispatch('room/setRoomId', val);
}
},
},
watch: {
roomId(value) {
if (value) {
this.getList()
}
}
},
methods: {
/** 查询设备信息列表 */
getList() {
this.queryParams.roomId = this.roomId || 0;
this.loading = true;
listByRoom(this.queryParams).then(response => {
this.deviceList = response.rows;
this.total = response.total;
this.loading = false;
});
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
/** 新增按钮操作 */
handleAdd() {
this.$refs.select.show();
},
handleDelete(row) {
this.$modal.confirm('确认要删除设备ID为"' + row.devId + '"吗?').then(function() {
return deleteRoomDevice(row);
}).then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {});
},
/** 开门、关门、取电、断电 */
openOrClose(row, opType) {
let data = {devId: row.devId, opType: opType};
openOrClose(data).then(response => {
let msg = '操作成功';
if (opType === '10') {
msg = '开门成功';
}
if (opType === '20') {
msg = '取电成功';
}
if (opType === '30') {
msg = '关门成功';
}
if (opType === '40') {
msg = '断电成功';
}
this.$modal.msgSuccess(msg);
});
},
}
}
</script>
<style scoped>
</style>
<template>
<el-dialog title="选择设备" :visible.sync="visible" width="75%" top="5vh" append-to-body>
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="100px">
<el-form-item label="设备名称" prop="devName">
<el-input
v-model="queryParams.devName"
placeholder="请输入设备名称"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="设备ID" prop="devId">
<el-input
v-model="queryParams.devId"
placeholder="请输入设备ID"
clearable
@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>
<el-table v-loading="loading" ref="table" :data="deviceList" @selection-change="handleSelectionChange"
@row-click="clickRow" >
<el-table-column type="selection" width="70" align="center"/>
<!-- <el-table-column label="${comment}" align="center" prop="id" />-->
<el-table-column label="设备名称" align="center" prop="devName"/>
<!-- <el-table-column label="设备MAC" align="center" prop="devMac"/>-->
<el-table-column label="设备ID" align="center" prop="devId"/>
<el-table-column label="设备密码" align="center" prop="devPsw"/>
<!-- <el-table-column label="版本号" align="center" prop="devVer"/>-->
<el-table-column label="设备类型" align="center" prop="devType">
<template slot-scope="scope">
<dict-tag :options="dict.type.device_type" :value="scope.row.devType"/>
</template>
</el-table-column>
<el-table-column label="分组" align="center" prop="group"/>
<el-table-column label="设备状态" align="center" prop="status">
<template slot-scope="scope">
<dict-tag :options="dict.type.device_status" :value="scope.row.status"/>
</template>
</el-table-column>
<el-table-column label="电量" align="center" prop="voltage"/>
<el-table-column label="信号值" align="center" prop="signalValue"/>
</el-table>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
</el-row>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="handleSelectDevice">确 定</el-button>
<el-button @click="visible = false">取 消</el-button>
</div>
</el-dialog>
</template>
<script>
import { notRoomIdList } from "@/api/system/device";
import { addRoomDevice } from "@/api/system/room";
export default {
name: "selectDevice",
dicts: ['device_ver_type', 'device_type','device_status'],
props: {
// 角色编号
roomId: {
type: [Number, String]
}
},
data() {
return {
// 遮罩层
visible: false,
// 遮罩层
loading: true,
// 选中数组
devIds: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 总条数
total: 0,
// 设备信息表格数据
deviceList: [],
// 弹出层标题
title: "",
// 是否显示弹出层
open: false,
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
devName: null,
devMac: null,
devId: null,
devPsw: null,
devVer: null,
devType: null,
roomId: null
},
};
},
created() {
this.getList();
},
methods: {
// 显示弹框
show() {
this.queryParams.roomId = this.roomId;
this.getList();
this.visible = true;
},
/** 查询设备信息列表 */
getList() {
this.loading = true;
notRoomIdList(this.queryParams).then(response => {
this.deviceList = response.rows;
this.total = response.total;
this.loading = false;
});
},
clickRow(row) {
this.$refs.table.toggleRowSelection(row);
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
// 多选框选中数据
handleSelectionChange(selection) {
this.devIds = selection.map(item => item.devId)
this.single = selection.length !== 1
this.multiple = !selection.length
},
/** 选择授权用户操作 */
handleSelectDevice() {
const roomId = this.queryParams.roomId;
const devIds = this.devIds.join(",");
if (devIds == "") {
this.$modal.msgError("请选择绑定设备");
return;
}
addRoomDevice({ roomId: roomId, devIds: devIds }).then(res => {
this.$modal.msgSuccess(res.msg);
if (res.code === 200) {
this.visible = false;
this.$emit("ok");
}
});
}
}
};
</script>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment