jc.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483
  1. <template>
  2. <div
  3. style="height: 100%; width: 100%;"
  4. @click="checkTimeOut()"
  5. @mouseenter="checkTimeOut()"
  6. @mousemove="checkTimeOut()"
  7. >
  8. <el-container class="admin-container">
  9. <!--页面头部(上边)-->
  10. <el-header>
  11. <div class="admin-logo-container">
  12. <!-- <img
  13. class="admin-logo"
  14. src="../assets/img/admin.jpg"
  15. alt=""
  16. > -->
  17. <span >安徽省农产品质量安全监测系统—检测平台</span>
  18. </div>
  19. <div class="right-function-container">
  20. <el-button @click="logout">
  21. 退出
  22. </el-button>
  23. </div>
  24. </el-header>
  25. <div class="admin-wel">
  26. <span>您好!检测单位--{{dwname}}</span>
  27. <!-- <el-button @click="logout" style="float:right">
  28. 退出
  29. </el-button> -->
  30. </div>
  31. <!--页面主体部分-->
  32. <el-container>
  33. <!--页面侧边栏(左边)-->
  34. <el-aside style="width: 13.125rem;">
  35. <!-- 页面左侧菜单区域-->
  36. <el-menu
  37. :default-active="$route.path"
  38. background-color="#EEF1F6"
  39. text-color="#48576a"
  40. active-text-color="#187bdd"
  41. :collapse-transition="false"
  42. :router="true"
  43. >
  44. <!-- <el-menu-item index="/jc/workbench">
  45. <span slot="title">系统首页</span>
  46. </el-menu-item> -->
  47. <!-- 一级菜单-->
  48. <el-submenu
  49. :index="index+''"
  50. v-for="(item, index) in menuList"
  51. :key="index"
  52. >
  53. <!-- 一级菜单模板区-->
  54. <template slot="title">
  55. <!-- 图标-->
  56. <i :class="item.icon" />
  57. <!-- 文本-->
  58. <span>{{ item.subMenuName }}</span>
  59. </template>
  60. <!-- 二级菜单-->
  61. <el-menu-item
  62. :index="subItem.path+''"
  63. v-for="subItem in item.children"
  64. :key="subItem.id"
  65. @click="addTab(subItem.subMenuName, subItem.path)"
  66. >
  67. <!-- 二级菜单模板区-->
  68. <template slot="title">
  69. <!-- 图标-->
  70. <i class="el-icon-bangzhu" />
  71. <!-- 文本-->
  72. <span>{{ subItem.subMenuName }}</span>
  73. </template>
  74. </el-menu-item>
  75. </el-submenu>
  76. </el-menu>
  77. </el-aside>
  78. <!-- 页面主内容(右边)-->
  79. <el-main>
  80. <el-tabs
  81. v-model="activeTabas"
  82. type="card"
  83. @tab-remove="removeTab"
  84. @tab-click="tabClick"
  85. >
  86. <el-tab-pane
  87. v-for="item in Tabs"
  88. :key="item.name"
  89. :label="item.title"
  90. :name="item.name"
  91. :closable="item.isClose"
  92. >
  93. <el-container>
  94. <el-main>
  95. <el-card shadow="always">
  96. <!-- 内容显示-->
  97. <router-view :key="item.name" />
  98. </el-card>
  99. </el-main>
  100. </el-container>
  101. </el-tab-pane>
  102. </el-tabs>
  103. </el-main>
  104. </el-container>
  105. <el-footer id="footer">
  106. <p>主办单位:安徽省农业农村厅</p>
  107. <p>技术支持:安徽省北斗精准农业信息工程实验室 农产品安全安徽省重点实验室</p>
  108. </el-footer>
  109. </el-container>
  110. </div>
  111. </template>
  112. <script>
  113. export default {
  114. name: 'jc',
  115. data () {
  116. return {
  117. lastTime: null, // 最后一次点击的时间
  118. currentTime: null, // 当前点击的时间
  119. timeOut: 30 * 60 * 1000, // 设置超时时间: 30分钟
  120. /** tabs标签相关属性 */
  121. // 当前打开的tabs名称
  122. activeTabas: '/jc',
  123. Tabs: [],
  124. // 左侧菜单数据
  125. menuList: [],
  126. dwname:''//账户名称
  127. }
  128. },
  129. watch: {
  130. /** 监听,当路由发生变化的时候执行(防止用户手动更换地址导致tabs的面板变动却不切换相应的tabs) */
  131. // '$route.path': function () {
  132. // var iindex = -1
  133. // var jindex = -1
  134. // for (let i = 0; i < this.menuList.length; i++) {
  135. // for (let j = 0; j < this.menuList[i].children.length; j++) {
  136. // if (this.menuList[i].children[j].path == this.$route.path) {
  137. // iindex = i
  138. // jindex = j
  139. // break
  140. // }
  141. // }
  142. // }
  143. // this.addTab(this.menuList[iindex].children[jindex].subMenuName, this.$route.path)
  144. // }
  145. },
  146. created () {
  147. this.lastTime = new Date().getTime() // 网页第一次打开时,记录当前时间
  148. // 保证admin中的页面刷新后重置到/admin路由下
  149. if (this.$route.path !== '/jc/workbench') this.$router.push('/jc/workbench')
  150. let groupname = window.sessionStorage.getItem('groupname')
  151. let data1 = []
  152. let data = [
  153. {
  154. subMenuName: '首页',
  155. children: [{
  156. id: '7-1',
  157. subMenuName: '控制台',
  158. path: '/jc/workbench'
  159. }
  160. ]
  161. },
  162. {
  163. subMenuName: '主体信息',
  164. children: [{
  165. id: '1-1',
  166. subMenuName: '信息维护',
  167. path: '/jc/subjectInformation'
  168. }
  169. ]
  170. },
  171. // {
  172. // // icon: 'el-icon-s-custom',
  173. // subMenuName: '牵头单位',
  174. // children: [
  175. // // {
  176. // // id: '2-1',
  177. // // subMenuName: '退回任务',
  178. // // path: '/admin/'
  179. // // },
  180. // {
  181. // id: '2-2',
  182. // subMenuName: '例行监测',
  183. // path: '/jc/routineMonitorqt'
  184. // }
  185. // ,{
  186. // id: '2-3',
  187. // subMenuName: '专项监测',
  188. // path: '/jc/specialMonitorqt'
  189. // },
  190. // // {
  191. // // id: '2-5',
  192. // // subMenuName: '监测信息汇总',
  193. // // path: '/admin/'
  194. // // },{
  195. // // id: '2-6',
  196. // // subMenuName: '承担任务报告下载',
  197. // // path: '/admin/'
  198. // // },{
  199. // // id: '2-7',
  200. // // subMenuName: '项目总结报告上传',
  201. // // path: '/admin/'
  202. // // },{
  203. // // id: '2-8',
  204. // // subMenuName: '项目总结报告管理',
  205. // // path: '/admin/'
  206. // // },{
  207. // // id: '2-9',
  208. // // subMenuName: '系统报表',
  209. // // path: '/admin/'
  210. // // }
  211. // ]
  212. // },
  213. {
  214. // icon: 'el-icon-s-data',
  215. subMenuName: '承担单位',
  216. children: [
  217. // {
  218. // id: '3-1',
  219. // subMenuName: '退回任务',
  220. // path: '/admin/'
  221. // },
  222. // {
  223. // id: '3-2',
  224. // subMenuName: '抽样计划',
  225. // path: '/admin/'
  226. // },
  227. {
  228. id: '3-3',
  229. subMenuName: '例行监测',
  230. path: '/jc/routineMonitor'
  231. },
  232. {
  233. id: '3-4',
  234. subMenuName: '专项监测',
  235. path: '/jc/specialMonitorcd'
  236. }
  237. ,
  238. // {
  239. // id: '3-5',
  240. // subMenuName: '退回任务',
  241. // path: '/jc/returnTaskcd'
  242. // },
  243. //{
  244. // id: '3-6',
  245. // subMenuName: '报告汇总',
  246. // path: '/admin/'
  247. // },{
  248. // id: '3-7',
  249. // subMenuName: '问题单据',
  250. // path: '/admin/'
  251. // },{
  252. // id: '3-8',
  253. // subMenuName: '委托检测',
  254. // path: '/admin/'
  255. // },{
  256. // id: '3-9',
  257. // subMenuName: '复检任务',
  258. // path: '/admin/'
  259. // },
  260. ]
  261. },]
  262. this.menuList = data
  263. this.getOrganization()
  264. },
  265. mounted:function(){
  266. this.addTab("首页",'/jc/workbench')
  267. this.getOrganization()
  268. },
  269. methods: {
  270. async getOrganization() {
  271. const result = await this.$http.post('getOrganization')
  272. this.dwname = result.data.data.user_id.name
  273. console.log(this.dwname)
  274. },
  275. handleOpen (index) {
  276. console.log(index)
  277. },
  278. /** tabs标签相关函数 */
  279. // tab切换时,动态的切换路由
  280. tabClick (tab) {
  281. if (this.$route.path == tab.name) return
  282. this.$router.push(tab.name)
  283. },
  284. addTab (title, name) {
  285. for (let i = 0; i < this.Tabs.length; i++) {
  286. if (this.Tabs[i].name == name) {
  287. this.activeTabas = name
  288. return
  289. }
  290. }
  291. this.Tabs.push({
  292. title: title,
  293. name: name,
  294. isClose: 'closable'
  295. })
  296. this.activeTabas = name
  297. },
  298. removeTab (targetName) {
  299. const tabs = this.Tabs
  300. let activeName = this.activeTabas
  301. if (activeName == targetName) {
  302. tabs.forEach((tab, index) => {
  303. if (tab.name == targetName) {
  304. const nextTab = tabs[index + 1] || tabs[index - 1]
  305. if (nextTab) {
  306. activeName = nextTab.name
  307. }
  308. }
  309. })
  310. }
  311. this.activeTabas = activeName
  312. this.$router.push(activeName)
  313. this.Tabs = tabs.filter(tab => tab.name !== targetName)
  314. },
  315. /** 设置用户为登出状态 */
  316. async logout () {
  317. // const formData = { 'token': window.sessionStorage.getItem('token') }
  318. // // 提交登出请求
  319. // const result = await this.$http.post('/loginOut', formData)
  320. // if (result.data.code == 0) {
  321. // 清除seesion信息
  322. window.sessionStorage.clear()
  323. this.$router.push('/login')
  324. // }
  325. },
  326. async checkTimeOut () {
  327. this.currentTime = new Date().getTime() // 记录这次点击的时间
  328. // 如果当前页面不是登录,初始化界面就可以执行是否退出
  329. if (!(this.$route.path == '/login')) {
  330. /** 判断是否因为超时可以退出 */
  331. // 判断时间是否过期(判断上次最后一次点击的时间和这次点击的时间间隔是否大于10分钟)
  332. var isExit = this.currentTime - this.lastTime > this.timeOut
  333. if (isExit) {
  334. isExit = false
  335. // 这里写状态已过期后执行的操作
  336. this.lastTime = new Date().getTime() // 如果在10分钟内点击,则把这次点击的时间记录覆盖掉之前存的最后一次点击的时间
  337. this.$router.push('/login')
  338. // 设置用户为登出状态
  339. // const formData = {
  340. // 'token': window.sessionStorage.getItem('token')
  341. // }
  342. // 提交登出请求
  343. // const result = await this.$http.post('login_out', formData)
  344. // if (result.data.code == 0) {
  345. // // 清除seesion信息
  346. // window.sessionStorage.removeItem('token')
  347. // }
  348. // this.$message({
  349. // message: '长时间未操作,请重新登录',
  350. // type: 'warning',
  351. // showClose: true,
  352. // center: true
  353. // })
  354. } else {
  355. /** 判断是否因为用户未登录可以退出 */
  356. // const token = window.sessionStorage.getItem('token')
  357. // if (token == null || token == undefined || token == '') {
  358. // this.$router.push('/login')
  359. // this.$message({
  360. // message: '用户未登录,请重新登录',
  361. // type: 'warning',
  362. // showClose: true,
  363. // center: true
  364. // })
  365. // }
  366. this.lastTime = new Date().getTime() // 如果在10分钟内点击,则把这次点击的时间记录覆盖掉之前存的最后一次点击的时间
  367. }
  368. } else {
  369. this.lastTime = new Date().getTime() // 如果在10分钟内点击,则把这次点击的时间记录覆盖掉之前存的最后一次点击的时间
  370. }
  371. }
  372. }
  373. }
  374. </script>
  375. <style lang="less" scoped>
  376. .admin-container {
  377. height: 100%;
  378. // overflow: hidden;
  379. }
  380. .el-main {
  381. padding-top: 8px !important;
  382. }
  383. // .el-menu-item.is-active {
  384. // // background-color: #3ace04 !important;
  385. // }
  386. // .admin-logo-container {
  387. // // border-color: #5EB9DE;
  388. // // border-right-width: 1px;
  389. // // border-right-style: solid;
  390. // }
  391. .admin-logo {
  392. margin-left: 5px;
  393. height: 55px;
  394. width: 55px;
  395. /*自动等比缩放*/
  396. background-size: 100% 100%;
  397. }
  398. .el-header {
  399. background-color: #145faa;
  400. width: 100%;
  401. color: white;
  402. font-size: 25px;
  403. display: flex;
  404. padding-left: 0;
  405. }
  406. .admin-logo-container {
  407. display: flex;
  408. align-items: center;
  409. span {
  410. margin-left: 15px;
  411. }
  412. }
  413. .el-aside {
  414. // width: 200px;
  415. background-color: #EEF1F6;
  416. }
  417. .toggle-button-container {
  418. width: 180px;
  419. display: flex;
  420. justify-content: left;
  421. }
  422. // .toggle-button {
  423. // width: 50px;
  424. // line-height: 60px;
  425. // color: #fff;
  426. // text-align: center;
  427. // cursor: pointer;
  428. // }
  429. .right-function-container {
  430. width: 400px;
  431. line-height: 50px;
  432. text-align: right;
  433. position: absolute;
  434. right: 15px;
  435. }
  436. .admin-wel{
  437. display:flex;
  438. margin: .625rem ;
  439. margin-left: .9375rem;
  440. font-size: .9375rem;
  441. font-weight: 600;
  442. }
  443. /deep/ .el-menu-item is-active{
  444. color: #3a8ee6;
  445. }
  446. /deep/ #footer {
  447. // display: flex;
  448. // flex-direction: row;
  449. // position: absolute;
  450. // bottom: 0px;
  451. // background-color: #5087bd;
  452. color: #413b3b;
  453. width: 100%;
  454. text-align: center;
  455. font-size: .875rem;
  456. // height: 6.25rem;
  457. // // padding-top: 5px;
  458. // // opacity: 0.6;
  459. font-weight: 550;
  460. margin-bottom: 1%;
  461. // font: 24px bold #0055ff;
  462. }
  463. </style>