Index.vue 11 KB

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