menu.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  1. <template>
  2. <div id="menu">
  3. <div style="width: 100%; height: 100%; display: flex;flex-direction: row">
  4. <div style="height: 100vh;background-color: rgb(84,92,100); ">
  5. <el-menu
  6. class="el-menu-vertical-demo"
  7. :collapse="isCollapse"
  8. background-color="#545c64"
  9. text-color="#fff"
  10. active-text-color="#993333"
  11. :router=true
  12. :default-active="$route.name"
  13. @open="handleOpen"
  14. @close="handleClose">
  15. <div class="logo" style="height: 50px; background-color:rgb(84,92,100)">
  16. <div class="img">
  17. <img src="" alt="" style="height: 100%">
  18. </div>
  19. </div>
  20. <el-menu-item index="/">
  21. <i class="el-icon-location"></i>
  22. <span slot="title">数据可视化大屏</span>
  23. </el-menu-item>
  24. <el-menu-item index="/operator">
  25. <i class="el-icon-location"></i>
  26. <span slot="title">运营商管理</span>
  27. </el-menu-item>
  28. <el-menu-item index="/project">
  29. <i class="el-icon-location"></i>
  30. <span slot="title">项目管理</span>
  31. </el-menu-item>
  32. <el-menu-item index="/gateway">
  33. <i class="el-icon-location"></i>
  34. <span slot="title">网关管理</span>
  35. </el-menu-item>
  36. <el-submenu index="3-2" style="display: flex;flex-direction:column">
  37. <template slot="title">
  38. <i class="el-icon-location"></i>
  39. <span @click="device(index)">设备管理</span>
  40. </template>
  41. <el-menu-item-group>
  42. <el-menu-item index="/">运行状态</el-menu-item>
  43. <el-menu-item index="/">数据曲线</el-menu-item>
  44. <el-menu-item index="/">参数设定</el-menu-item>
  45. <el-menu-item index="/">系统参数</el-menu-item>
  46. <el-menu-item index="/deviceAlarmConfig">报警设置</el-menu-item>
  47. <el-menu-item index="/detail">报警记录</el-menu-item>
  48. <el-menu-item index="/deviceAlarmRepairRecord">维保记录</el-menu-item>
  49. </el-menu-item-group>
  50. </el-submenu>
  51. <el-menu-item index="/deviceAlarmRecord">
  52. <i class="el-icon-location"></i>
  53. <span slot="title">报警管理</span>
  54. </el-menu-item>
  55. <el-menu-item index="/operatorLog">
  56. <i class="el-icon-location"></i>
  57. <span slot="title">操作日志</span>
  58. </el-menu-item>
  59. <el-menu-item index="/user">
  60. <i class="el-icon-location"></i>
  61. <span slot="title">用户管理</span>
  62. </el-menu-item>
  63. <el-submenu index="7" style="display: flex;flex-direction:column">
  64. <template slot="title">
  65. <i class="el-icon-location"></i>
  66. <span>权限设置</span>
  67. </template>
  68. <el-menu-item-group>
  69. <el-menu-item index="/role">角色管理</el-menu-item>
  70. <el-menu-item index="/power">权限管理</el-menu-item>
  71. <el-menu-item index="/rolePower">关联角色权限</el-menu-item>
  72. </el-menu-item-group>
  73. </el-submenu>
  74. </el-menu>
  75. </div>
  76. <div style="width: 90% ; float: right">
  77. <el-header class="header" style="height: 80px;">
  78. <!-- 点击展开收起导航和切换对应图标 -->
  79. <i class="el-icon-s-fold" @click="isC" v-show="block"></i>
  80. <i class="el-icon-s-unfold" @click="isC" v-show="toggle"></i>
  81. <!-- <el-radio-group v-model="isCollapse" style="margin-top: 15px;">-->
  82. <!-- <el-radio-button :label="false">展开</el-radio-button>-->
  83. <!-- <el-radio-button :label="true">收起</el-radio-button>-->
  84. <!-- </el-radio-group>-->
  85. <el-dropdown style="margin-right: 20px;float: right;margin-top: 10px">
  86. <i class="el-icon-setting"></i>
  87. <el-dropdown-menu slot="dropdown">
  88. <el-dropdown-item @click.native="userInfo">个人中心</el-dropdown-item>
  89. <el-dropdown-item @click.native="showUpdatePassword">修改密码</el-dropdown-item>
  90. <el-dropdown-item @click.native="logout">退出登录</el-dropdown-item>
  91. </el-dropdown-menu>
  92. </el-dropdown>
  93. <el-dialog title="修改密码" :visible.sync="dialogFormVisible" style="width: 71% ; margin-left: 300px ;">
  94. <el-form label-position="left" :model="formData" :rules="rules" ref="formData">
  95. <el-row style="margin-left: 15px">
  96. <el-form-item label="原密码" style="margin-left: 0px" prop="oldPassword">
  97. <el-input v-model="formData.oldPassword"></el-input>
  98. </el-form-item>
  99. <el-form-item label="新密码" style="" prop="newPassword">
  100. <el-input v-model="formData.newPassword"></el-input>
  101. </el-form-item>
  102. </el-row>
  103. </el-form>
  104. <div slot="footer" class="dialog-footer" style="text-align: center">
  105. <el-button @click="cancel()">取 消</el-button>
  106. <el-button type="primary" @click="updatePassword('formData')">确 定</el-button>
  107. </div>
  108. </el-dialog>
  109. <span style="float: right; margin-right: 20px; margin-top: 10px">用户名:{{ realname }}</span>
  110. </el-header>
  111. <el-main style="background-color: rgb(245,247,249);height: 100vh">
  112. <router-view></router-view>
  113. </el-main>
  114. </div>
  115. </div>
  116. </div>
  117. </template>
  118. <script>
  119. export default {
  120. name: "menu",
  121. data() {
  122. return {
  123. realname: '',
  124. dialogFormVisible: false,
  125. index: '1',
  126. isCollapse: false,
  127. toggle: false,//第二个图标默认隐藏
  128. block: true,//默认显示第一个图标
  129. formData: {
  130. oldPassword: '',
  131. newPassword: ''
  132. },
  133. rules: {
  134. oldPassword: [
  135. {required: true, message: '请输入原密码', trigger: 'blur'}
  136. ],
  137. newPassword: [
  138. {required: true, message: '请输入新密码', trigger: 'blur'}
  139. ],
  140. },
  141. }
  142. },
  143. created: function () {
  144. let vm = this;
  145. var userBean = this.$route.query.userBean
  146. this.realname = userBean.realname
  147. console.log(this.realname)
  148. if (this.realname) {
  149. vm.$router.push('/operator')
  150. }
  151. },
  152. methods: {
  153. isC() {
  154. this.isCollapse = !this.isCollapse;
  155. this.toggle = !this.toggle;
  156. this.block = !this.block;
  157. },
  158. handleOpen(key, keyPath) {
  159. console.log(key, keyPath);
  160. }
  161. ,
  162. handleClose(key, keyPath) {
  163. console.log(key, keyPath);
  164. },
  165. device() {
  166. let vm = this;
  167. vm.$router.push('/device')
  168. },
  169. logout() {
  170. const vm = this;
  171. vm.$http.get(vm.$api.auth.logout).then((resp) => {
  172. console.log(resp)
  173. vm.$router.push('/login')
  174. this.$message({
  175. type: 'success',
  176. showClose: true,
  177. message: resp.data.desc
  178. })
  179. })
  180. },
  181. userInfo() {
  182. const vm = this;
  183. vm.$http.get(vm.$api.auth.userInfo).then((resp) => {
  184. vm.$router.push({
  185. path: '/userInfo',
  186. query: {data: resp.data.data}
  187. })
  188. })
  189. },
  190. showUpdatePassword() {
  191. this.dialogFormVisible = true;
  192. },
  193. updatePassword(formName) {
  194. this.$refs[formName].validate((valid) => {
  195. if (valid) {
  196. const vm = this;
  197. vm.$http.get(vm.$api.auth.updateUserPassword, {
  198. params: {
  199. oldPassword: '',
  200. newPassword: ''
  201. }
  202. }).then((resp) => {
  203. console.log(resp)
  204. })
  205. } else {
  206. console.log('error submit!!');
  207. return false;
  208. }
  209. });
  210. },
  211. cancel() {
  212. this.$message({
  213. message: '操作取消',
  214. showClose: true,
  215. type: 'info'
  216. });
  217. this.$refs.formData.clearValidate();
  218. this.dialogFormVisible = false;
  219. },
  220. }
  221. }
  222. </script>
  223. <style>
  224. .img {
  225. background-color: darkgrey;
  226. height: 40px;
  227. width: 40px;
  228. margin: auto;
  229. text-align: center;
  230. line-height: 100px;
  231. align-items: center;
  232. }
  233. .header {
  234. height: 64px;
  235. line-height: 64px;
  236. /*background-color: darkgrey;*/
  237. padding: 0 20px;
  238. position: relative
  239. }
  240. /*.el-aside {*/
  241. /* float: left;*/
  242. /* background-color: #545c64;*/
  243. /* text-color: #fff;*/
  244. /* active-text-color: #993333*/
  245. /*}*/
  246. .el-menu {
  247. float: left;
  248. background-color: #545c64;
  249. text-color: #fff;
  250. }
  251. .el-menu-vertical-demo:not(.el-menu--collapse) {
  252. width: 240px;
  253. }
  254. .el-main {
  255. padding: 5px 5px 5px 5px
  256. }
  257. .logo {
  258. margin-top: 20px;
  259. margin-bottom: 10px;
  260. }
  261. .el-icon-s-fold {
  262. margin-top: 30px;
  263. width: 20px;
  264. height: 20px;
  265. }
  266. .el-icon-s-unfold {
  267. margin-top: 30px;
  268. width: 20px;
  269. height: 20px;
  270. }
  271. .el-button {
  272. color: black;
  273. }
  274. </style>