Bladeren bron

修改页面

yangxiaokun 3 jaren geleden
bovenliggende
commit
6bdb17436d
4 gewijzigde bestanden met toevoegingen van 351 en 243 verwijderingen
  1. 66 53
      src/static/js/global.js
  2. 95 107
      src/views/devices/lp.vue
  3. 1 1
      src/views/layout/layout.vue
  4. 189 82
      src/views/system/users.vue

+ 66 - 53
src/static/js/global.js

@@ -1,62 +1,75 @@
 const server = "http://localhost:8081/bms/api/operate/";
 
 const URL = {
-    //登录
-    login: server + "admin/login.do",
-    //验证token
-    verify: server + "admin/verify.do",
+	//登录
+	login: server + "admin/login.do",
+	//验证token
+	verify: server + "admin/verify.do",
 
-    //用户
-    users: {
-        //列表
-        listPage: server + "user/listPage.do",
-        //提交审核
-        audit: server + "privilegeApply/audit.do",
-        //获取某用户没有权限的设备组
-        getNoPrivGroups: server + "privilegeApply/getNoPrivGroups.do",
-    },
-    //mqtt日志
-    logs: {
-        //列表
-        listPage: server + "logs/listPage.do",
-        //全部指令
-        instructions: server + "logs/getAllInstruction.do",
-    },
-    //项目管理
-    item: {
-        //列表
-        listPage: server + "item/listPage.do",
-        //全部的项目列表
-        allList: server + "item/listAll.do",
-        //增
-        save: server + "item/save.do",
-        //禁用
-        forbidden: server + "item/forbidden.do",
-        //启用
-        permit: server + "item/permit.do",
-        //更新
-        update: server + "item/update.do",
-    },
-    //项目组管理
-    group: {
-        //列表
-        listPage: server + "group/listPage.do",
-        //增
-        save: server + "group/save.do",
-        //查重
-        isRepeat: server + "group/isRepeat.do",
-        //禁用
-        forbidden: server + "group/forbidden.do",
-        //启用
-        permit: server + "group/permit.do",
-        //更新
-        update: server + "group/update.do",
-    },
+	//用户
+	users: {
+		//列表
+		listPage: server + "user/listPage.do",
+		//管理员权限
+		adminAccess: server + "user/adminAccess.do",
+		//获取某用户没有权限的设备组
+		getNoAccessGroups: server + "user/getNoAccessGroups.do",
+		//保存设备组权限
+		saveGroupAccess: server + "user/saveGroupAccess.do",
+	},
+	//路牌
+	lp: {
+		//分页列表
+		listPage: server + "device/lp/listPage.do",
+		//分布图-列表
+		list: server + "device/lp/list.do",
+		//设备详情
+		detail: server + "device/lp/detail.do",
+	},
+	//mqtt日志
+	logs: {
+		//列表
+		listPage: server + "logs/listPage.do",
+		//全部指令
+		instructions: server + "logs/getAllInstruction.do",
+	},
 
-    //webSocket 地址
-    webSocket: "wss://www.mang406.top/webSocket/",
+	//项目管理
+	item: {
+		//列表
+		listPage: server + "item/listPage.do",
+		//全部的项目列表
+		allList: server + "item/listAll.do",
+		//增
+		save: server + "item/save.do",
+		//禁用
+		forbidden: server + "item/forbidden.do",
+		//启用
+		permit: server + "item/permit.do",
+		//更新
+		update: server + "item/update.do",
+	},
+
+	//项目组管理
+	group: {
+		//列表
+		listPage: server + "group/listPage.do",
+		//增
+		save: server + "group/save.do",
+		//查重
+		isRepeat: server + "group/isRepeat.do",
+		//禁用
+		forbidden: server + "group/forbidden.do",
+		//启用
+		permit: server + "group/permit.do",
+		//更新
+		update: server + "group/update.do",
+	},
+
+	//webSocket 地址
+	webSocket: "wss://www.mang406.top/webSocket/",
 };
 
 export default {
-    URL
+	URL
 };

+ 95 - 107
src/views/devices/lp.vue

@@ -1,119 +1,107 @@
 <template>
-    <div class="zy-template">
-        <div class="zy-main-title">设备列表</div>
-        <div class="zy-module">
-            <el-form ref="form" :model="query" label-width="60px">
-                <el-form-item label="设备码:" class="zy-search-form-item">
-                    <el-input v-model="query.openNum" size="mini" clearable></el-input>
-                </el-form-item>
+	<div class="zy-template">
+		<div class="zy-main-title">设备列表</div>
+		<div class="zy-module">
+			<el-form ref="form" :model="query" label-width="60px">
+				<el-form-item label="设备码:" class="zy-search-form-item">
+					<el-input v-model="query.openNum" size="mini" clearable></el-input>
+				</el-form-item>
 
-                <el-form-item label="类型:" class="zy-search-form-item">
-                    <el-select v-model="query.type" size="mini" value="" placeholder=" " clearable>
-                        <el-option value="0" label="服务器接收"/>
-                        <el-option value="1" label="服务器发送"/>
-                    </el-select>
-                </el-form-item>
+				<el-form-item label="设备组:" class="zy-search-form-item">
+					<el-select v-model="query.groupId" filterable clearable placeholder="请输入设备号"
+						:filter-method="remoteMethod" size="mini">
+						<el-option v-for="item in groups" :key="item" :value="item" />
+					</el-select>
+				</el-form-item>
 
-                <el-form-item label="指令:" class="zy-search-form-item">
-                    <el-select v-model="query.m" size="mini" value="" placeholder=" " clearable>
-                        <el-option :value="item.code" :label="item.remark" v-for="item in mList"/>
-                    </el-select>
-                </el-form-item>
+				<el-button type="primary" size="mini" @click="submit">查询</el-button>
+			</el-form>
+		</div>
 
-                <el-button type="primary" size="mini" @click="submit">查询</el-button>
-            </el-form>
-        </div>
+		<div class="zy-module">
+			<el-table :data="page.records" header-cell-class-name="zy-table-header-cell" cell-class-name='zy-table-cell'
+				stripe>
+				<el-table-column prop="openNum" label="设备码" width="180" min-width="10%" />
+				<el-table-column prop="username" label="MQTT用户名" width="180" min-width="10%" />
+				<el-table-column prop="groupId" label="设备组" width="120" min-width="10%" />
+				<el-table-column prop="createTime" label="创建时间" width="180" min-width="10%" />
+				<el-table-column prop="battery" label="电量" width="80" min-width="10%" />
+				<el-table-column prop="s4g" label="信号" width="80" min-width="10%" />
+				<el-table-column label="状态" width="100" min-width="10%">
+					<template #default="scope">
+						<el-tag type="success" v-if="scope.row.status===1" size="small">在线</el-tag>
+						<el-tag type="danger" v-if="scope.row.status===0" size="small">离线</el-tag>
+					</template>
+				</el-table-column>
+				<el-table-column prop="updateTime" label="最近通讯时间" width="180" />
+				<el-table-column label="操作" width="80">
+					<template #default="scope">
+						<el-button @click="setGroups(scope.row.id)" type="text" size="small">详情</el-button>
+					</template>
+				</el-table-column>
+			</el-table>
+			<el-pagination class="zy-table-pagination" background layout="prev, pager, next"
+				:current-page="page.current" :total="page.total" :page-size="page.size" @current-change="pagination" />
+		</div>
 
-        <div class="zy-module">
-            <el-table :data="page.records" header-cell-class-name="zy-table-header-cell" cell-class-name='zy-table-cell'
-                      stripe>
-                <el-table-column prop="openNum" label="设备ID" width="180"/>
-                <el-table-column label="类型" width="80">
-                    <template #default="scope">{{scope.row.type==0?'接收':'发送'}}</template>
-                </el-table-column>
-                <el-table-column label="类型" width="180">
-                    <template #default="scope">{{scope.row.m}} ({{scope.row.remark}})</template>
-                </el-table-column>
-                <el-table-column prop="content" label="内容" min-width="10%"/>
-                <el-table-column prop="createTime" label="时间" width="180"/>
-            </el-table>
-
-            <el-pagination class="zy-table-pagination" background layout="prev, pager, next"
-                           :current-page="page.current" :total="page.total" :page-size="page.size"
-                           @current-change="pagination"/>
-        </div>
-
-    </div>
+	</div>
 </template>
 
 <script>
-    export default {
-        data() {
-            return {
-                query: {
-                    openNum: "",
-                    type: null,
-                    m: null
-                },
-                mList: null, //指令列表
-                page: {
-                    current: 1,
-                    size: 20,
-                },
-            };
-        },
-        mounted() {
-            this.getAllInstruction();
-            this.getListPage();
-        },
-        methods: {
-            /**
-             * 提交查询条件
-             */
-            submit: function () {
-                const param = {
-                    current: 1,
-                    size: this.page.size,
-                    openNum: this.query.openNum,
-                    type: this.query.type,
-                    m: this.query.m,
-                };
-                this.getListPage(param);
-            },
-            /**
-             * 分页点击事件
-             */
-            pagination: function (current) {
-                const param = {
-                    current: current,
-                    size: this.page.size,
-                    openNum: this.query.openNum,
-                    type: this.query.type,
-                    m: this.query.m,
-                };
-                this.getListPage(param);
-            },
+	export default {
+		data() {
+			return {
+				query: {
+					openNum: "",
+					type: null,
+				},
+				page: {
+					current: 1,
+					size: 20,
+				},
+			};
+		},
+		mounted() {
+			this.getList();
+		},
+		methods: {
+			/**
+			 * 提交查询条件
+			 */
+			submit: function() {
+				const param = {
+					current: 1,
+					size: this.page.size,
+					groupId: this.query.groupId,
+					openNum: this.query.openNum,
+				};
+				this.getList(param);
+			},
+			/**
+			 * 分页点击事件
+			 */
+			pagination: function(current) {
+				const param = {
+					current: current,
+					size: this.page.size,
+					openNum: this.query.openNum,
+					type: this.query.type,
+					m: this.query.m,
+				};
+				this.getListPage(param);
+			},
 
-            /**
-             * 获取日志列表
-             */
-            getListPage: function (params) {
-                this.$http.Post(this.$global.logs.listPage, params).then(res => {
-                    this.page = res.data;
-                    console.log(res.data)
-                })
-            },
-            /**
-             * 获取全部的指令
-             */
-            getAllInstruction() {
-                this.$http.Get(this.$global.logs.instructions, {}).then(res => {
-                    this.mList = res.data;
-                    console.log(res.data)
-                })
-            }
-        }
-    };
+			/**
+			 * 获取日志列表
+			 */
+			getList: function(params) {
+				this.$http.Get(this.$global.lp.listPage, params).then(res => {
+					console.log(res.data)
+					this.page = res.data;
+				})
+			},
+		}
+	};
 </script>
 
 <style lang="scss">

+ 1 - 1
src/views/layout/layout.vue

@@ -77,7 +77,7 @@
             };
         },
         mounted() {
-            this.initToken();
+            //this.initToken();
         },
         methods: {
             /**

+ 189 - 82
src/views/system/users.vue

@@ -1,90 +1,197 @@
 <template>
-    <div class="zy-template">
-        <div class="zy-module">
-            <el-form ref="form" :model="query" label-width="60px">
-                <el-form-item label="关键字:" class="zy-search-form-item">
-                    <el-input v-model="query.key" size="mini" placeholder="用户名/昵称/手机号/随机码"></el-input>
-                </el-form-item>
-                <el-button type="primary" size="mini" @click="submit">查询</el-button>
-            </el-form>
-        </div>
+	<div class="zy-template">
+		<div class="zy-main-title">用户管理</div>
+		<div class="zy-module">
+			<el-form ref="form" :model="query" label-width="60px">
+				<el-form-item label="关键字:" class="zy-search-form-item">
+					<el-input v-model="query.key" size="mini" placeholder="用户名/昵称/手机号/随机码"></el-input>
+				</el-form-item>
+				<el-button type="primary" size="mini" @click="submit">查询</el-button>
+			</el-form>
+		</div>
 
-        <div class="zy-module">
-            <el-table :data="page.records" stripe header-cell-class-name="zy-table-header-cell"
-                      cell-class-name='zy-table-cell'>
-                <el-table-column prop="openId" label="微信open-id" width="300"/>
-                <el-table-column prop="randomCode" label="随机码" width="180"/>
-                <el-table-column label="管理员权限" width="120">
-                    <template #default="scope">
-                        <el-tag type="success" v-if="scope.row.admin===1">是</el-tag>
-                        <el-tag v-if="scope.row.admin===0">否</el-tag>
-                    </template>
-                </el-table-column>
-                <el-table-column prop="createTime" label="注册时间" min-width="10%"/>
-                <el-table-column label="操作" width="150" min-width="10%">
-                    <template #default="scope">
-                        <el-button @click="setAdmin(scope.row)" type="text" size="small"
-                                   :class="scope.row.admin===0?'':'red'">
-                            {{scope.row.admin===0?'设为管理员':'取消管理员'}}
-                        </el-button>
-                    </template>
-                </el-table-column>
-            </el-table>
+		<div class="zy-module">
+			<el-table :data="page.records" stripe header-cell-class-name="zy-table-header-cell"
+				cell-class-name='zy-table-cell'>
+				<el-table-column prop="openId" label="微信open-id" width="300" />
+				<el-table-column prop="randomCode" label="随机码" width="180" />
+				<el-table-column label="管理员权限" width="120">
+					<template #default="scope">
+						<el-tag type="success" v-if="scope.row.admin===1">是</el-tag>
+						<el-tag v-if="scope.row.admin===0">否</el-tag>
+					</template>
+				</el-table-column>
+				<el-table-column prop="createTime" label="注册时间" min-width="10%" />
+				<el-table-column label="操作" width="200" min-width="10%">
+					<template #default="scope">
+						<el-button @click="setGroups(scope.row.id)" type="text" size="small">配置设备组</el-button>
+						<el-button @click="setAdmin(scope.row)" type="text" size="small"
+							:class="scope.row.admin===0?'':'red'">
+							{{scope.row.admin===0?'设为管理员':'取消管理员'}}
+						</el-button>
+					</template>
+				</el-table-column>
+			</el-table>
 
-            <el-pagination class="zy-table-pagination" background layout="prev, pager, next"
-                           :total="page.total" :page-size="page.size" @current-change="pagination"
-                           :current-page="page.current"/>
-        </div>
-    </div>
+			<el-pagination class="zy-table-pagination" background layout="prev, pager, next" :total="page.total"
+				:page-size="page.size" @current-change="pagination" :current-page="page.current" />
+		</div>
+
+		<el-dialog title="配置权限" v-model="groupDialog" width="500px">
+			<el-form label-width="100px">
+				<el-form-item label="配置组:">
+					<el-tree :data="groupList" show-checkbox node-key="code" ref="tree" highlight-current
+						:props="defaultProps" accordion>
+					</el-tree>
+				</el-form-item>
+			</el-form>
+			<template #footer>
+				<span class="dialog-footer">
+					<el-button @click="groupDialog = false" size="small">取 消</el-button>
+					<el-button type="success" @click="setGroupSubmit" size="small">提 交</el-button>
+				</span>
+			</template>
+		</el-dialog>
+	</div>
 </template>
 
 <script>
-    export default {
-        data() {
-            return {
-                query: {
-                    key: ''
-                },
-                page: {
-                    current: 1,
-                    size: 20,
-                },
-            };
-        },
-        mounted() {
-            this.getUserList(this.page);
-        },
-        methods: {
+	export default {
+		data() {
+			return {
+				query: {
+					key: ''
+				},
+				page: {
+					current: 1,
+					size: 20,
+				},
+				defaultProps: {
+					children: 'children',
+					label: 'name'
+				},
+				groupDialog: false, //配置设备组权限弹出框
+				selUserId: null, //选中的用户的ID
+				groupList: null, //设备组权限列表
+			};
+		},
+		mounted() {
+			this.getUserList(this.page);
+		},
+		methods: {
+
+			/**
+			 * 提交查询条件
+			 */
+			submit: function() {
+				const param = {
+					key: this.query.key
+				};
+				this.getUserList(param);
+			},
+
+			/**
+			 * 分页点击事件
+			 */
+			pagination: function(current) {
+				const param = {
+					key: this.query.key,
+					current: current,
+					size: this.page.size,
+				};
+				this.getUserList(param);
+			},
+
+			/**
+			 * 获取用户列表
+			 */
+			getUserList: function(params) {
+				const that = this;
+				this.$http.Get(this.$global.users.listPage, params).then(res => {
+					that.page = res.data;
+				})
+			},
+
+			/**
+			 * 设置设备组权限
+			 */
+			setGroups: function(id) {
+				this.groupDialog = true;
+				this.selUserId = id;
+				this.getGroupList(id);
+			},
+
+			/**
+			 * 设置管理员权限
+			 */
+			setAdmin: function(obj) {
+				const param = {
+					userId: obj.id,
+					admin: obj.admin == 1 ? 0 : 1
+				}
+				this.$http.Post(this.$global.users.adminAccess, param).then(res => {
+					this.$message.success("设置成功!");
+					this.refresh();
+				})
+			},
+
+			/**
+			 * 获取权限列表
+			 */
+			getGroupList: function(userId) {
+				const param = {
+					userId: userId
+				}
+				this.$http.Get(this.$global.users.getNoAccessGroups, param).then(res => {
+					const arr = [];
+					for (let key in res.data) {
+						arr.push({
+							name: key,
+							children: res.data[key]
+						})
+					}
+					console.log(arr);
+					this.groupList = arr;
+				})
+			},
+
+			/**
+			 * 提交设备组权限配置
+			 */
+			setGroupSubmit: function() {
+				const arr = this.$refs.tree.getCheckedKeys(true);
+				console.log(arr)
+				if (arr == null || arr.length <= 0) {
+					this.$message.error("至少配置一个组!");
+					return;
+				}
+				let groups = "";
+				arr.forEach(item => {
+					groups += (item + ",")
+				})
+				groups = groups.substr(0, groups.length - 1)
+				const params = {
+					userId: this.selUserId,
+					groups: groups
+				}
+				this.$http.Post(this.$global.users.saveGroupAccess, params).then(res => {
+					this.$message.success("配置成功!");
+					this.groupDialog = false;
+				})
+			},
+
+			/**
+			 * 刷新列表
+			 */
+			refresh: function() {
+				const params = {
+					key: this.query.key,
+					current: this.page.current,
+					size: this.page.size,
+				}
+				this.getUserList(params);
+			},
 
-            /**
-             * 提交查询条件
-             */
-            submit: function () {
-                const param = {
-                    key: this.query.key
-                };
-                this.getUserList(param);
-            },
-            /**
-             * 分页点击事件
-             */
-            pagination: function (current) {
-                const param = {
-                    key: this.query.key,
-                    current: current,
-                    size: this.page.size,
-                };
-                this.getUserList(param);
-            },
-            /**
-             * 获取用户列表
-             */
-            getUserList: function (params) {
-                const that = this;
-                this.$http.Get(this.$global.users.listPage, params).then(res => {
-                    that.page = res.data;
-                })
-            }
-        }
-    };
+		}
+	};
 </script>