Index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596
  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. 欢迎您,{{ 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 Products Traceability System
  18. </div>
  19. </div>
  20. </div>
  21. </el-header>
  22. <div class="site" v-if="userinfo.site">
  23. <i class="iconfont icon-jidi"></i>
  24. <span>{{userinfo.site}}</span>
  25. </div>
  26. <!-- 修改密码对话框 -->
  27. <el-dialog
  28. title="重置密码"
  29. :visible.sync="resetPassDialogVisible"
  30. width="500px"
  31. @close="resetPassDialogClosed"
  32. >
  33. <el-form
  34. ref="resetPassFormRef"
  35. :model="resetPassForm"
  36. label-width="90px"
  37. :rules="resetPassFormRules"
  38. >
  39. <el-form-item label="原始密码 : " prop="oldPass">
  40. <el-input type="password" v-model="resetPassForm.oldPass"></el-input>
  41. </el-form-item>
  42. <el-form-item label="新密码 : " prop="newPass">
  43. <el-input type="password" v-model="resetPassForm.newPass"></el-input>
  44. </el-form-item>
  45. <el-form-item label="确认新密码 : " prop="checkNewPass">
  46. <el-input
  47. type="password"
  48. v-model="resetPassForm.checkNewPass"
  49. ></el-input>
  50. </el-form-item>
  51. </el-form>
  52. <span slot="footer" class="dialog-footer">
  53. <el-button @click="resetPassDialogVisible = false">取 消</el-button>
  54. <el-button type="primary" @click="resetPassSubm">确认</el-button>
  55. </span>
  56. </el-dialog>
  57. <el-container style="overflow: auto">
  58. <!-- 菜单 -->
  59. <el-aside width="200px">
  60. <el-menu
  61. :default-openeds="menuOpeneds"
  62. :default-active="$route.path"
  63. :collapse-transition="false"
  64. class="el-menu-vertical-demo"
  65. unique-opened
  66. :router="isRouter"
  67. active-text-color="rgb(57, 249, 190)"
  68. >
  69. <el-submenu
  70. :index="item.pur_id.toString()"
  71. v-for="item in menuList1"
  72. :key="item.pur_id"
  73. >
  74. <template slot="title">
  75. <i :class="iconObj[item.pur_id]"></i>
  76. <span>{{ item.purview_name }}</span>
  77. </template>
  78. <el-menu-item
  79. :index="menuIndex(subItem.menu)"
  80. v-for="subItem in item.children"
  81. :key="subItem.pur_id"
  82. @click="saveNavState('/index/' + subItem.menu)"
  83. >
  84. <template slot="title">
  85. <span>{{ subItem.purview_name }}</span>
  86. </template>
  87. </el-menu-item>
  88. </el-submenu>
  89. <el-menu-item
  90. :index="'/index/'+item.menu"
  91. v-for="item in menuList"
  92. :key="item.pur_id"
  93. >
  94. <i :class="iconObj[item.pur_id]"></i>
  95. <span slot="title">{{ item.purview_name }}</span>
  96. </el-menu-item>
  97. </el-menu>
  98. </el-aside>
  99. <el-container>
  100. <el-main>
  101. <router-view></router-view>
  102. </el-main>
  103. </el-container>
  104. </el-container>
  105. </el-container>
  106. </template>
  107. <script>
  108. export default {
  109. data() {
  110. var validateNewPass = (rule, value, callback) => {
  111. if (value === '') {
  112. callback(new Error('请输入新密码'))
  113. } else {
  114. if (this.resetPassForm.checkPass !== '') {
  115. this.$refs.resetPassFormRef.validateField('checkNewPass')
  116. }
  117. callback()
  118. }
  119. }
  120. var validateCheckPass = (rule, value, callback) => {
  121. if (value === '') {
  122. callback(new Error('请再次输入密码'))
  123. } else if (value !== this.resetPassForm.newPass) {
  124. callback(new Error('两次输入密码不一致!'))
  125. } else {
  126. callback()
  127. }
  128. }
  129. return {
  130. isRouter: true,
  131. // 被激活导航地址
  132. // activePath:this.$store.state.activePath,
  133. changeHomedialogVisible: false,
  134. iconObj: {
  135. 20: 'iconfont icon-shujuzhanshi',
  136. 22: 'iconfont icon-shebei',
  137. 25: 'iconfont icon-jidi',
  138. 28: 'iconfont icon-xitong',
  139. 36: 'iconfont icon-cebaoguanli',
  140. 40: 'iconfont icon-huanjingjiance',
  141. 42: 'iconfont icon-jiankong',
  142. 44: 'iconfont icon-fangzhi',
  143. 46: 'iconfont icon-nongchangguanli',
  144. 48: 'iconfont icon-nongshiguanli',
  145. 58: 'iconfont icon-suyuan',
  146. 124: 'iconfont icon-zhuanjia',
  147. 129: 'iconfont icon-shouhou',
  148. 6: 'iconfont icon-xitong'
  149. },
  150. menuOpeneds:['/index/farmBaseManger'],
  151. userinfo:'',
  152. menuList1: [{
  153. menu: "",
  154. parent_perm_id: 0,
  155. pur_id: 46,
  156. purview_name: "农场管理",
  157. children:[
  158. {
  159. menu: "farmBaseManger",
  160. parent_perm_id: 46,
  161. pur_id: 80,
  162. purview_name: "基地列表",
  163. },
  164. {
  165. menu: "farmFieldsManger",
  166. parent_perm_id: 46,
  167. pur_id: 47,
  168. purview_name: "地块管理",
  169. }
  170. ]
  171. },
  172. {
  173. menu: "",
  174. parent_perm_id: 0,
  175. pur_id: 48,
  176. purview_name: "农事管理",
  177. children:[
  178. {
  179. menu: "farmThingPlant",
  180. parent_perm_id: 48,
  181. pur_id: 49,
  182. purview_name: "种植",
  183. },
  184. {
  185. menu: "farmThingApplyFerti",
  186. parent_perm_id: 48,
  187. pur_id: 50,
  188. purview_name: "施肥",
  189. },
  190. {
  191. menu: "farmThingspray",
  192. parent_perm_id: 48,
  193. pur_id: 51,
  194. purview_name: "喷药",
  195. },
  196. {
  197. menu: "farmThingWatering",
  198. parent_perm_id: 48,
  199. pur_id: 52,
  200. purview_name: "灌溉",
  201. },
  202. {
  203. menu: "farmThingMore",
  204. parent_perm_id: 48,
  205. pur_id: 57,
  206. purview_name: "更多",
  207. },
  208. {
  209. menu: "farmThingHarvest",
  210. parent_perm_id: 48,
  211. pur_id: 53,
  212. purview_name: "采收",
  213. },
  214. {
  215. menu: "farmThingSale",
  216. parent_perm_id: 48,
  217. pur_id: 141,
  218. purview_name: "销售",
  219. },
  220. {
  221. menu: "farmThingTransport",
  222. parent_perm_id: 48,
  223. pur_id: 142,
  224. purview_name: "运输",
  225. }
  226. ]
  227. },
  228. {
  229. menu: "",
  230. parent_perm_id: 0,
  231. pur_id: 58,
  232. purview_name: "溯源系统",
  233. children:[
  234. {
  235. menu: "resultInfoList",
  236. parent_perm_id: 58,
  237. pur_id: 59,
  238. purview_name: "溯源信息",
  239. },
  240. ]
  241. },], //首页菜单
  242. menuList: [{
  243. "purview_name": "用户列表",
  244. "menu": "userManger",
  245. "parent_perm_id": 6,
  246. "pur_id": 6
  247. },],
  248. // activePath:'',
  249. username: '',
  250. userphoto:'',
  251. userHeadImg: '',
  252. resetPassDialogVisible: false,
  253. resetPassForm: {
  254. oldPass: '',
  255. newPass: '',
  256. checkNewPass: ''
  257. },
  258. resetPassFormRules: {
  259. oldPass: [
  260. { required: true, message: '请输入原始密码', trigger: 'blur' }
  261. ],
  262. newPass: [{ validator: validateNewPass, trigger: 'blur' }],
  263. checkNewPass: [{ validator: validateCheckPass, trigger: 'blur' }]
  264. },
  265. }
  266. },
  267. created: function () {
  268. this.getuserinfo()
  269. // this.$router.push('xycb')
  270. },
  271. computed: {
  272. },
  273. watch: {
  274. },
  275. mounted() {
  276. },
  277. methods: {
  278. dropdownHandle(command) {
  279. if (command == 'editPwd') {
  280. this.changePass()
  281. } else if (command == 'outSys') {
  282. this.outSys()
  283. } else {
  284. this.$router.push({ path: command })
  285. }
  286. },
  287. getuserinfo() {
  288. this.$axios({
  289. method: 'post',
  290. url: '/userinfo_'
  291. }).then((res) => {
  292. this.username = res.data.username
  293. this.userphoto = res.data.userphoto
  294. localStorage.setItem('username', res.data.username) // 0管理员 1用户
  295. })
  296. this.$axios({
  297. method: 'get',
  298. url: '/user_detail'
  299. }).then((res) => {
  300. this.userinfo = res.data
  301. localStorage.setItem('have_type', this.userinfo.have_type) // 0管理员 1用户
  302. localStorage.setItem('staff', this.userinfo.staff) // 1是admin
  303. })
  304. },
  305. getNavList() {
  306. this.$axios({
  307. method: 'GET',
  308. url: '/home'
  309. }).then((res) => {
  310. let navList = res.data
  311. this.menuList1 = navList
  312. })
  313. },
  314. dropdownHandle(command) {
  315. if (command == 'editPwd') {
  316. this.changePass()
  317. } else if (command == 'outSys') {
  318. this.outSys()
  319. } else {
  320. this.$router.push({ path: command })
  321. }
  322. },
  323. handleCommand(command) {
  324. // this.$message('click on item ' + command);
  325. document.body.className = 'custom-' + command
  326. window.sessionStorage.setItem('bodyCalss', 'custom-' + command)
  327. },
  328. outSys() {
  329. this.$axios({
  330. method: 'POST',
  331. url: '/logout_user'
  332. }).then((res) => {
  333. if (res.data.message == '') {
  334. window.localStorage.removeItem('isLogin')
  335. window.localStorage.removeItem('session')
  336. this.$router.push('/login')
  337. // window.sessionStorage.setItem('activePath', '/index/home')
  338. }
  339. })
  340. },
  341. changePass() {
  342. this.resetPassDialogVisible = true
  343. },
  344. resetPassDialogClosed() {},
  345. resetPassSubm() {
  346. this.$refs.resetPassFormRef.validate((valid) => {
  347. if (!valid) return
  348. this.$axios({
  349. method: 'POST',
  350. url: '/changepwd',
  351. data: this.qs.stringify({
  352. old_password: this.resetPassForm.oldPass,
  353. new_password: this.resetPassForm.newPass,
  354. confirm_password: this.resetPassForm.checkNewPass
  355. })
  356. }).then((res) => {
  357. if (res.data.message == '') {
  358. this.$message({
  359. message: '密码修改成功!',
  360. type: 'success'
  361. })
  362. this.resetPassDialogVisible = false
  363. }
  364. })
  365. })
  366. },
  367. menuIndex(menu) {
  368. if (menu == 'bFourSituations') {
  369. return ''
  370. } else if (menu == 'equipDistribute') {
  371. return ''
  372. } else if (menu == 'bCbd') {
  373. return ''
  374. } else if (menu == 'bQxz') {
  375. return ''
  376. } else if (menu == 'bSy') {
  377. return ''
  378. } else if (menu == 'bBzy') {
  379. return ''
  380. } else {
  381. return '/index/' + menu
  382. }
  383. },
  384. //保存菜单的激活地址
  385. saveNavState(activePath) {
  386. // let path='/'+activePath.split('/')[activePath.split('/').length-1]
  387. let path = activePath.slice(6)
  388. // console.log(path)
  389. // console.log(activePath)
  390. if (activePath == '/index/bFourSituations') {
  391. // this.$router.replace('/index/home')
  392. this.BFourSituations(path) //跳转到大数据平台
  393. } else if (activePath == '/index/equipDistribute') {
  394. // this.$router.push('/index/home')
  395. this.BFourSituations(path) //跳转到大数据平台
  396. } else if (activePath == '/index/bCbd') {
  397. this.BFourSituations(path) //跳转到大数据平台
  398. // this.$router.push('/index/home')
  399. } else if (activePath == '/index/bQxz') {
  400. // this.$router.push('/index/home')
  401. this.BFourSituations(path) //跳转到大数据平台
  402. } else if (activePath == '/index/bSy') {
  403. // this.$router.push('/index/home')
  404. this.BFourSituations(path) //跳转到大数据平台
  405. } else if (activePath == '/index/bBzy') {
  406. // this.$router.push('/index/home')
  407. this.BFourSituations(path) //跳转到大数据平台
  408. }
  409. },
  410. BFourSituations(path) {
  411. const { href } = this.$router.resolve({
  412. path: path
  413. })
  414. window.open(href, '_blank')
  415. },
  416. goBD(path) {
  417. const { href } = this.$router.resolve({
  418. path: path
  419. })
  420. window.open(href, '_blank')
  421. }
  422. }
  423. }
  424. </script>
  425. <style scoped lang="less">
  426. @keyframes ringing {
  427. 0% {
  428. transform: rotate(-15deg);
  429. }
  430. 2% {
  431. transform: rotate(15deg);
  432. }
  433. 12%,
  434. 4% {
  435. transform: rotate(-18deg);
  436. }
  437. 14%,
  438. 6% {
  439. transform: rotate(18deg);
  440. }
  441. 8% {
  442. transform: rotate(-22deg);
  443. }
  444. 10% {
  445. transform: rotate(22deg);
  446. }
  447. 16% {
  448. transform: rotate(-12deg);
  449. }
  450. 18% {
  451. transform: rotate(12deg);
  452. }
  453. 20% {
  454. transform: rotate(0);
  455. }
  456. }
  457. .el-header {
  458. height: 189px !important;
  459. background: url(../assets/images/headBj.jpg) no-repeat center;
  460. background-size: 100% 100%;
  461. .navbarBtn {
  462. color: #fff;
  463. .userinfo {
  464. font-size: 12px;
  465. text-align: right;
  466. margin-top: 10px;
  467. .userheadImg {
  468. width: 35px;
  469. height: 35px;
  470. border-radius: 50%;
  471. vertical-align: middle;
  472. margin-right: 6px;
  473. }
  474. }
  475. .caption {
  476. margin-top: 7px;
  477. text-align: center;
  478. font-size: 16px;
  479. letter-spacing: 0.5px;
  480. .tit {
  481. font-size: 20px;
  482. line-height: 46px;
  483. font-weight: 700;
  484. letter-spacing: 7px;
  485. }
  486. }
  487. }
  488. }
  489. .site{
  490. position: absolute;
  491. right: 10px;
  492. top: 199px;
  493. z-index: 888;
  494. font-size: 14px;
  495. color: #226a4d;
  496. span{
  497. color: #333;
  498. letter-spacing: 1px;
  499. font-size: 13px;
  500. }
  501. }
  502. /deep/.el-dropdown-menu__item {
  503. padding: 0 10px;
  504. }
  505. .el-popper.newsDropdown {
  506. padding: 0;
  507. margin: 0;
  508. h5 {
  509. background: #35a478;
  510. color: #fff;
  511. padding: 15px;
  512. text-transform: uppercase;
  513. font-size: 11px;
  514. margin: 0;
  515. }
  516. /deep/.popper__arrow {
  517. border-bottom-color: #35a478;
  518. &::after {
  519. border-bottom-color: #35a478;
  520. }
  521. }
  522. ul {
  523. border: 1px solid #ddd;
  524. border-top: 0;
  525. padding: 0 10px;
  526. .news {
  527. display: block;
  528. margin: 0;
  529. float: none;
  530. background: none;
  531. padding: 5px 5px;
  532. border-bottom: 1px solid #eee;
  533. .txtContent {
  534. max-width: 250px;
  535. white-space: nowrap;
  536. overflow: hidden;
  537. text-overflow: ellipsis;
  538. display: inline-block;
  539. min-width: 250px;
  540. // display: flex;
  541. a {
  542. color: #333;
  543. font-size: 12px;
  544. padding: 7px 10px;
  545. -moz-border-radius: 2px;
  546. -webkit-border-radius: 2px;
  547. border-radius: 2px;
  548. -moz-transition: all 0.2s ease-out 0s;
  549. -webkit-transition: all 0.2s ease-out 0s;
  550. transition: all 0.2s ease-out 0s;
  551. }
  552. a:hover {
  553. background: none;
  554. color: #428bca;
  555. text-decoration: none;
  556. }
  557. }
  558. }
  559. }
  560. }
  561. .sysAside {
  562. position: absolute;
  563. z-index: 999;
  564. left: 0;
  565. top: 60px;
  566. bottom: 0;
  567. z-index: 999;
  568. transition: all 0.5s;
  569. }
  570. .el-aside {
  571. // background-color: #3D4C5A;
  572. color: #333;
  573. // line-height: 200px;
  574. // .el-menu-item.is-active{background:#17BB89!important}
  575. // .el-submenu__title i{color:#fff}
  576. .el-menu {
  577. border: none;
  578. }
  579. .iconfont {font-size:18px;margin-right:10px;}
  580. .icon-chouchongbug{font-size:22px;}
  581. }
  582. .changeHomeItem {
  583. text-align: center;
  584. img {
  585. width: 100%;
  586. height: 110px;
  587. }
  588. .tit {
  589. margin-top: 10px;
  590. }
  591. }
  592. </style>