Index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474
  1. <template>
  2. <el-container style="height: 100%">
  3. <el-header>
  4. <div v-if="userinfo.logo">
  5. <img :src="userinfo.logo" alt="" style="position: absolute;left: 20px;top: 20px;width: 136px;">
  6. </div>
  7. <div class="navbarBtn">
  8. <!-- 用户 -->
  9. <div class="userinfo">
  10. <img :src="userphoto" class="userheadImg" alt="" />{{ username }}
  11. </div>
  12. <!-- 标题 -->
  13. <div class="caption">
  14. <div v-if="userinfo.user_header" class="tit">{{userinfo.user_header}}</div>
  15. <div v-else class="tit">农业植保监测系统 智慧农业信息化</div>
  16. <div>
  17. Agricultural plant protection monitoring system intelligent
  18. agricultural informatization
  19. </div>
  20. </div>
  21. </div>
  22. </el-header>
  23. <div class="site" v-if="userinfo.site">
  24. <i class="iconfont icon-jidi"></i>
  25. <span>{{userinfo.site}}</span>
  26. </div>
  27. <el-container style="overflow: auto">
  28. <!-- 菜单 -->
  29. <el-aside width="200px">
  30. <el-menu
  31. default-active="/index/xycb"
  32. :collapse-transition="false"
  33. class="el-menu-vertical-demo"
  34. unique-opened
  35. :router="isRouter"
  36. text-color="#333"
  37. active-text-color="#fff"
  38. >
  39. <el-menu-item
  40. :index="'/index/'+item.menu"
  41. v-for="item in menuList1"
  42. :key="item.pur_id"
  43. >
  44. <i :class="iconObj[item.pur_id]"></i>
  45. <span slot="title">{{ item.purview_name }}</span>
  46. </el-menu-item>
  47. </el-menu>
  48. </el-aside>
  49. <el-container>
  50. <el-main>
  51. <router-view></router-view>
  52. </el-main>
  53. </el-container>
  54. </el-container>
  55. </el-container>
  56. </template>
  57. <script>
  58. export default {
  59. data() {
  60. var validateNewPass = (rule, value, callback) => {
  61. if (value === '') {
  62. callback(new Error('请输入新密码'))
  63. } else {
  64. if (this.resetPassForm.checkPass !== '') {
  65. this.$refs.resetPassFormRef.validateField('checkNewPass')
  66. }
  67. callback()
  68. }
  69. }
  70. var validateCheckPass = (rule, value, callback) => {
  71. if (value === '') {
  72. callback(new Error('请再次输入密码'))
  73. } else if (value !== this.resetPassForm.newPass) {
  74. callback(new Error('两次输入密码不一致!'))
  75. } else {
  76. callback()
  77. }
  78. }
  79. return {
  80. isRouter: true,
  81. // 被激活导航地址
  82. // activePath:this.$store.state.activePath,
  83. changeHomedialogVisible: false,
  84. iconObj: {
  85. 1: 'iconfont icon-chouchongbug',
  86. 2: 'iconfont icon-weimingming-34',
  87. 3: 'iconfont icon-cebaoguanli',
  88. 4: 'iconfont icon-fangzhi',
  89. 5: 'iconfont icon-shebei',
  90. 6: 'iconfont icon-xitong'
  91. },
  92. userinfo:'',
  93. menuList1: [{
  94. "purview_name": "智能性诱测报",
  95. "menu": "xycb",
  96. "parent_perm_id": 1,
  97. "pur_id": 1
  98. },
  99. {
  100. "purview_name": "植物孢子捕捉仪",
  101. "menu": "bzy",
  102. "parent_perm_id": 2,
  103. "pur_id": 2
  104. },
  105. {
  106. "purview_name": "物联网虫情测报",
  107. "menu": "cbd",
  108. "parent_perm_id": 3,
  109. "pur_id": 3
  110. },
  111. {
  112. "purview_name": "物联网杀虫灯",
  113. "menu": "scd",
  114. "parent_perm_id": 4,
  115. "pur_id": 4
  116. },
  117. {
  118. "purview_name": "设备管理",
  119. "menu": "equipList",
  120. "parent_perm_id": 5,
  121. "pur_id": 5
  122. },{
  123. "purview_name": "用户列表",
  124. "menu": "userManger",
  125. "parent_perm_id": 6,
  126. "pur_id": 6
  127. },], //首页菜单
  128. // activePath:'',
  129. username: '',
  130. userphoto:'',
  131. userHeadImg: '',
  132. resetPassDialogVisible: false,
  133. resetPassForm: {
  134. oldPass: '',
  135. newPass: '',
  136. checkNewPass: ''
  137. },
  138. resetPassFormRules: {
  139. oldPass: [
  140. { required: true, message: '请输入原始密码', trigger: 'blur' }
  141. ],
  142. newPass: [{ validator: validateNewPass, trigger: 'blur' }],
  143. checkNewPass: [{ validator: validateCheckPass, trigger: 'blur' }]
  144. },
  145. }
  146. },
  147. created: function () {
  148. this.getuserinfo()
  149. // this.$router.push('xycb')
  150. },
  151. computed: {
  152. },
  153. watch: {
  154. },
  155. mounted() {
  156. },
  157. methods: {
  158. dropdownHandle(command) {
  159. if (command == 'editPwd') {
  160. this.changePass()
  161. } else if (command == 'outSys') {
  162. this.outSys()
  163. } else {
  164. this.$router.push({ path: command })
  165. }
  166. },
  167. getuserinfo() {
  168. this.$axios({
  169. method: 'post',
  170. url: '/userinfo_'
  171. }).then((res) => {
  172. this.username = res.data.username
  173. this.userphoto = res.data.userphoto
  174. localStorage.setItem('username', res.data.username) // 0管理员 1用户
  175. })
  176. this.$axios({
  177. method: 'get',
  178. url: '/user_detail'
  179. }).then((res) => {
  180. this.userinfo = res.data
  181. localStorage.setItem('have_type', this.userinfo.have_type) // 0管理员 1用户
  182. localStorage.setItem('staff', this.userinfo.staff) // 1是admin
  183. })
  184. },
  185. getNavList() {
  186. this.$axios({
  187. method: 'GET',
  188. url: '/home'
  189. }).then((res) => {
  190. let navList = res.data
  191. this.menuList1 = navList
  192. })
  193. },
  194. dropdownHandle(command) {
  195. if (command == 'editPwd') {
  196. this.changePass()
  197. } else if (command == 'outSys') {
  198. this.outSys()
  199. } else {
  200. this.$router.push({ path: command })
  201. }
  202. },
  203. handleCommand(command) {
  204. // this.$message('click on item ' + command);
  205. document.body.className = 'custom-' + command
  206. window.sessionStorage.setItem('bodyCalss', 'custom-' + command)
  207. },
  208. outSys() {
  209. this.$axios({
  210. method: 'POST',
  211. url: '/api_gateway?method=user.login.logout_user'
  212. }).then((res) => {
  213. if (res.data.message == '') {
  214. window.localStorage.removeItem('isLogin')
  215. window.localStorage.removeItem('session')
  216. this.$router.push('/login')
  217. // window.sessionStorage.setItem('activePath', '/index/home')
  218. }
  219. })
  220. },
  221. changePass() {
  222. this.resetPassDialogVisible = true
  223. },
  224. resetPassDialogClosed() {},
  225. resetPassSubm() {
  226. this.$refs.resetPassFormRef.validate((valid) => {
  227. if (!valid) return
  228. this.$axios({
  229. method: 'POST',
  230. url: '/api_gateway?method=user.login.changepwd',
  231. data: this.qs.stringify({
  232. old_password: this.resetPassForm.oldPass,
  233. new_password: this.resetPassForm.newPass,
  234. confirm_password: this.resetPassForm.checkNewPass
  235. })
  236. }).then((res) => {
  237. if (res.data.message == '') {
  238. this.$message({
  239. message: '密码修改成功!',
  240. type: 'success'
  241. })
  242. this.resetPassDialogVisible = false
  243. }
  244. })
  245. })
  246. },
  247. menuIndex(menu) {
  248. if (menu == 'bFourSituations') {
  249. return ''
  250. } else if (menu == 'equipDistribute') {
  251. return ''
  252. } else if (menu == 'bCbd') {
  253. return ''
  254. } else if (menu == 'bQxz') {
  255. return ''
  256. } else if (menu == 'bSy') {
  257. return ''
  258. } else if (menu == 'bBzy') {
  259. return ''
  260. } else {
  261. return '/index/' + menu
  262. }
  263. },
  264. //保存菜单的激活地址
  265. saveNavState(activePath) {
  266. // let path='/'+activePath.split('/')[activePath.split('/').length-1]
  267. let path = activePath.slice(6)
  268. // console.log(path)
  269. // console.log(activePath)
  270. if (activePath == '/index/bFourSituations') {
  271. // this.$router.replace('/index/home')
  272. this.BFourSituations(path) //跳转到大数据平台
  273. } else if (activePath == '/index/equipDistribute') {
  274. // this.$router.push('/index/home')
  275. this.BFourSituations(path) //跳转到大数据平台
  276. } else if (activePath == '/index/bCbd') {
  277. this.BFourSituations(path) //跳转到大数据平台
  278. // this.$router.push('/index/home')
  279. } else if (activePath == '/index/bQxz') {
  280. // this.$router.push('/index/home')
  281. this.BFourSituations(path) //跳转到大数据平台
  282. } else if (activePath == '/index/bSy') {
  283. // this.$router.push('/index/home')
  284. this.BFourSituations(path) //跳转到大数据平台
  285. } else if (activePath == '/index/bBzy') {
  286. // this.$router.push('/index/home')
  287. this.BFourSituations(path) //跳转到大数据平台
  288. }
  289. },
  290. BFourSituations(path) {
  291. const { href } = this.$router.resolve({
  292. path: path
  293. })
  294. window.open(href, '_blank')
  295. },
  296. goBD(path) {
  297. const { href } = this.$router.resolve({
  298. path: path
  299. })
  300. window.open(href, '_blank')
  301. }
  302. }
  303. }
  304. </script>
  305. <style scoped lang="less">
  306. @keyframes ringing {
  307. 0% {
  308. transform: rotate(-15deg);
  309. }
  310. 2% {
  311. transform: rotate(15deg);
  312. }
  313. 12%,
  314. 4% {
  315. transform: rotate(-18deg);
  316. }
  317. 14%,
  318. 6% {
  319. transform: rotate(18deg);
  320. }
  321. 8% {
  322. transform: rotate(-22deg);
  323. }
  324. 10% {
  325. transform: rotate(22deg);
  326. }
  327. 16% {
  328. transform: rotate(-12deg);
  329. }
  330. 18% {
  331. transform: rotate(12deg);
  332. }
  333. 20% {
  334. transform: rotate(0);
  335. }
  336. }
  337. .el-header {
  338. height: 189px !important;
  339. background: url(../assets/images/headBj.png) no-repeat center;
  340. background-size: 100% 100%;
  341. .navbarBtn {
  342. color: #fff;
  343. .userinfo {
  344. text-align: right;
  345. margin-top: 10px;
  346. .userheadImg {
  347. width: 35px;
  348. height: 35px;
  349. border-radius: 50%;
  350. vertical-align: middle;
  351. margin-right: 6px;
  352. }
  353. }
  354. .caption {
  355. margin-top: 7px;
  356. text-align: center;
  357. font-size: 16px;
  358. letter-spacing: 0.5px;
  359. .tit {
  360. font-size: 20px;
  361. line-height: 46px;
  362. font-weight: 700;
  363. letter-spacing: 7px;
  364. }
  365. }
  366. }
  367. }
  368. .site{
  369. position: absolute;
  370. right: 10px;
  371. top: 199px;
  372. z-index: 888;
  373. font-size: 14px;
  374. color: #226a4d;
  375. span{
  376. color: #333;
  377. letter-spacing: 1px;
  378. font-size: 13px;
  379. }
  380. }
  381. /deep/.el-dropdown-menu__item {
  382. padding: 0 10px;
  383. }
  384. .el-popper.newsDropdown {
  385. padding: 0;
  386. margin: 0;
  387. h5 {
  388. background: #35a478;
  389. color: #fff;
  390. padding: 15px;
  391. text-transform: uppercase;
  392. font-size: 11px;
  393. margin: 0;
  394. }
  395. /deep/.popper__arrow {
  396. border-bottom-color: #35a478;
  397. &::after {
  398. border-bottom-color: #35a478;
  399. }
  400. }
  401. ul {
  402. border: 1px solid #ddd;
  403. border-top: 0;
  404. padding: 0 10px;
  405. .news {
  406. display: block;
  407. margin: 0;
  408. float: none;
  409. background: none;
  410. padding: 5px 5px;
  411. border-bottom: 1px solid #eee;
  412. .txtContent {
  413. max-width: 250px;
  414. white-space: nowrap;
  415. overflow: hidden;
  416. text-overflow: ellipsis;
  417. display: inline-block;
  418. min-width: 250px;
  419. // display: flex;
  420. a {
  421. color: #333;
  422. font-size: 12px;
  423. padding: 7px 10px;
  424. -moz-border-radius: 2px;
  425. -webkit-border-radius: 2px;
  426. border-radius: 2px;
  427. -moz-transition: all 0.2s ease-out 0s;
  428. -webkit-transition: all 0.2s ease-out 0s;
  429. transition: all 0.2s ease-out 0s;
  430. }
  431. a:hover {
  432. background: none;
  433. color: #428bca;
  434. text-decoration: none;
  435. }
  436. }
  437. }
  438. }
  439. }
  440. .sysAside {
  441. position: absolute;
  442. z-index: 999;
  443. left: 0;
  444. top: 60px;
  445. bottom: 0;
  446. z-index: 999;
  447. transition: all 0.5s;
  448. }
  449. .el-aside {
  450. // background-color: #3D4C5A;
  451. color: #333;
  452. // line-height: 200px;
  453. // .el-menu-item.is-active{background:#17BB89!important}
  454. // .el-submenu__title i{color:#fff}
  455. .el-menu {
  456. border: none;
  457. }
  458. .iconfont {font-size:18px;margin-right:10px;}
  459. .icon-chouchongbug{font-size:22px;}
  460. }
  461. .changeHomeItem {
  462. text-align: center;
  463. img {
  464. width: 100%;
  465. height: 110px;
  466. }
  467. .tit {
  468. margin-top: 10px;
  469. }
  470. }
  471. </style>