华西海圻ELN前端工程
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

461 lines
8.6 KiB

  1. <template>
  2. <div id="app">
  3. <router-view />
  4. <theme-picker />
  5. </div>
  6. </template>
  7. <script>
  8. import ThemePicker from "@/components/ThemePicker"
  9. import { checkStatus } from "@/api/system/user"
  10. export default {
  11. name: "App",
  12. components: { ThemePicker },
  13. data() {
  14. return {
  15. statusCheckTimer: null
  16. }
  17. },
  18. computed: {
  19. // // 监听登录状态
  20. // isLoggedIn() {
  21. // return this.$store.getters.token && this.$store.getters.token !== ''
  22. // }
  23. },
  24. watch: {
  25. // // 监听登录状态变化
  26. // isLoggedIn(newVal, oldVal) {
  27. // console.log('登录状态变化:', newVal, oldVal)
  28. // if (newVal) {
  29. // // 用户已登录,启动轮询
  30. // this.startStatusCheck()
  31. // } else {
  32. // // 用户已退出,停止轮询
  33. // this.stopStatusCheck()
  34. // }
  35. // },
  36. // 监听token
  37. '$store.getters.token': {
  38. handler(newToken, oldToken) {
  39. console.log('token变化:', newToken, oldToken)
  40. if (newToken) {
  41. // 有token,启动轮询
  42. this.startStatusCheck()
  43. } else {
  44. // token为空,停止轮询
  45. this.stopStatusCheck()
  46. }
  47. },
  48. immediate: true // 立即执行一次,这样在页面刷新时,如果已经有token,就会启动轮询
  49. }
  50. },
  51. mounted() {
  52. // // 页面加载时检查当前登录状态
  53. // if (this.isLoggedIn) {
  54. // this.startStatusCheck()
  55. // }
  56. },
  57. beforeDestroy() {
  58. this.stopStatusCheck()
  59. },
  60. methods: {
  61. startStatusCheck() {
  62. // 先停止可能存在的定时器
  63. this.stopStatusCheck()
  64. console.log('启动状态检查轮询')
  65. // 立即执行一次检查
  66. this.checkStatusImmediate()
  67. // 设置定时器每秒检查一次
  68. this.statusCheckTimer = setInterval(() => {
  69. this.checkStatus()
  70. }, 10000)
  71. },
  72. stopStatusCheck() {
  73. if (this.statusCheckTimer) {
  74. console.log('停止状态检查轮询')
  75. clearInterval(this.statusCheckTimer)
  76. this.statusCheckTimer = null
  77. }
  78. },
  79. // 立即检查(不等待)
  80. async checkStatusImmediate() {
  81. await this.checkStatus()
  82. },
  83. // 定时检查
  84. async checkStatus() {
  85. // 再次确认登录状态
  86. // if (!this.isLoggedIn) {
  87. // this.stopStatusCheck()
  88. // return
  89. // }
  90. try {
  91. console.log('开始checkStatus')
  92. checkStatus().then(response => {
  93. console.log(JSON.stringify(response))
  94. }).catch(err => {
  95. console.log(JSON.stringify(err))
  96. // if (err === '无效的会话,或者会话已过期,请重新登录。') {
  97. if (err === this.$t('system.timeOutTip')) {
  98. this.stopStatusCheck()
  99. }
  100. })
  101. } catch (error) {
  102. }
  103. },
  104. }
  105. }
  106. </script>
  107. <style rel="stylesheet/scss" lang="scss">
  108. #app .theme-picker {
  109. display: none;
  110. }
  111. .el-dialog__header {
  112. box-shadow: 0 2px 12px 0 rgba(0, 0, 0, .1) !important;
  113. }
  114. .el-dialog__footer {
  115. box-shadow: 0 2px 12px 0 rgba(0, 0, 0, .1) !important;
  116. }
  117. .el-dialog__body {
  118. padding: 10px 10px;
  119. }
  120. /*搜索区域样式 */
  121. .search-area {
  122. input {
  123. width: 150px;
  124. }
  125. }
  126. .el-tabs--border-card>.el-tabs__content {
  127. padding: 0px 0px;
  128. }
  129. /*详情 */
  130. .detail-container {
  131. background: #ffffff !important;
  132. .detail-top {
  133. background: #fff;
  134. padding: 10px 20px;
  135. margin-bottom: 10px;
  136. display: flex;
  137. flex-direction: row;
  138. align-items: center;
  139. justify-content: space-between;
  140. box-shadow: 0 2px 12px 0 rgba(0, 0, 0, .1);
  141. .left-top {
  142. flex-shrink: 0;
  143. display: flex;
  144. flex-direction: row;
  145. align-items: center;
  146. img {
  147. height: 16px;
  148. margin-right: 10px;
  149. cursor: pointer;
  150. }
  151. .right-top {}
  152. }
  153. }
  154. .detail-title {
  155. line-height: 60px;
  156. font-size: 16px;
  157. font-weight: bold;
  158. width: 100%;
  159. margin-top: 10px;
  160. display: flex;
  161. justify-content: center;
  162. }
  163. .detail-content {
  164. padding: 10px 10px;
  165. display: flex;
  166. justify-content: space-between;
  167. .content-right {
  168. width: 33%;
  169. margin-left: 2%;
  170. padding: 0px 10px;
  171. border-left: 1px solid #d0d0d0;
  172. }
  173. .content-left {
  174. width: 65%;
  175. }
  176. .content {
  177. width: 100%;
  178. }
  179. .content-title {
  180. width: 100%;
  181. background: #f9f9ff;
  182. font-size: 0.96rem;
  183. font-weight: bold;
  184. padding-left: 10px;
  185. height: 40px;
  186. line-height: 40px;
  187. display: flex;
  188. justify-content: flex-start;
  189. text-align: left;
  190. .line {
  191. width: 2px;
  192. float: left;
  193. height: 16px;
  194. margin-top: 12px;
  195. margin-right: 8px;
  196. border-left: #3178ff 3px solid;
  197. }
  198. .subtitle {
  199. height: 40px;
  200. line-height: 40px;
  201. color: #464647 !important;
  202. }
  203. }
  204. .pal {
  205. display: flex;
  206. justify-content: space-between;
  207. margin: 10px 0px;
  208. .left {
  209. box-shadow: 0 2px 12px 0 rgba(0, 0, 0, .1);
  210. margin: 5px 5px 5px 0px;
  211. width: 50%;
  212. padding: 10px 10px;
  213. border-radius: 5px 5px;
  214. .left-title {
  215. height: 40px;
  216. line-height: 40px;
  217. }
  218. }
  219. .right {
  220. box-shadow: 0 2px 12px 0 rgba(0, 0, 0, .1);
  221. margin: 5px 0px 5px 5px;
  222. width: 50%;
  223. padding: 10px 10px;
  224. border-radius: 5px 5px;
  225. .right-title {
  226. height: 40px;
  227. line-height: 40px;
  228. }
  229. }
  230. }
  231. }
  232. }
  233. /*稽查轨迹list */
  234. .jcgjList {
  235. padding: 20px 0px;
  236. .jcgjList-keywords {
  237. width: 100%;
  238. }
  239. .jcgjList-jcgjlx {
  240. height: 50px;
  241. margin: 10px 0px;
  242. }
  243. .jcgjList-content {
  244. width: 100%;
  245. }
  246. .jcgjList-title {
  247. display: flex;
  248. justify-content: space-between;
  249. margin-top: -15px;
  250. .jcgjList-jcmc {
  251. font-size: 16px;
  252. font-weight: bold;
  253. }
  254. }
  255. .jcglList-jcnr {
  256. line-height: 25x;
  257. box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
  258. padding: 10px 10px;
  259. margin-top: 10px;
  260. }
  261. }
  262. /** 基础信息设置tab **/
  263. .edit-container {
  264. .edit-top {
  265. background: #fff;
  266. padding: 10px 20px;
  267. margin-bottom: 10px;
  268. display: flex;
  269. flex-direction: row;
  270. align-items: center;
  271. justify-content: space-between;
  272. box-shadow: 0 2px 12px 0 rgba(0, 0, 0, .1);
  273. .left-top {
  274. flex-shrink: 0;
  275. display: flex;
  276. flex-direction: row;
  277. align-items: center;
  278. img {
  279. height: 16px;
  280. margin-right: 10px;
  281. cursor: pointer;
  282. }
  283. }
  284. .center-top {
  285. display: flex;
  286. justify-content: space-between;
  287. height: 24px;
  288. .is-finish {
  289. background: #409eff;
  290. border: 1px solid #409eff;
  291. color: #fff;
  292. }
  293. .is-info {
  294. border: 1px solid #d0d0d0;
  295. }
  296. .line {
  297. height: 0px;
  298. width: 100px;
  299. margin-top: 12px;
  300. margin-left: 5px;
  301. margin-right: 5px;
  302. border-top: 1px solid #d0d0d0;
  303. }
  304. }
  305. .right-top {}
  306. }
  307. .edit-content {
  308. background: #ffffff;
  309. padding: 10px 10px;
  310. margin-top: 10px;
  311. display: flex;
  312. justify-content: center;
  313. .content-right {
  314. width: 33%;
  315. margin-left: 2%;
  316. padding: 0px 10px;
  317. border-left: 1px solid #d0d0d0;
  318. }
  319. .content-left {
  320. width: 65%;
  321. }
  322. .content {
  323. width: 100%;
  324. }
  325. .content-title {
  326. width: 100%;
  327. background: #f9f9ff;
  328. font-size: 0.96rem;
  329. font-weight: bold;
  330. padding-left: 10px;
  331. height: 40px;
  332. line-height: 40px;
  333. display: flex;
  334. justify-content: flex-start;
  335. text-align: left;
  336. .line {
  337. width: 2px;
  338. float: left;
  339. height: 16px;
  340. margin-top: 12px;
  341. margin-right: 8px;
  342. border-left: #3178ff 3px solid;
  343. }
  344. .subtitle {
  345. height: 40px;
  346. line-height: 40px;
  347. color: #464647 !important;
  348. }
  349. }
  350. .pal {
  351. display: flex;
  352. justify-content: space-between;
  353. margin: 10px 0px;
  354. .left {
  355. box-shadow: 0 2px 12px 0 rgba(0, 0, 0, .1);
  356. margin: 5px 5px 5px 0px;
  357. width: 50%;
  358. padding: 10px 10px;
  359. border-radius: 5px 5px;
  360. .left-title {
  361. height: 40px;
  362. line-height: 40px;
  363. }
  364. }
  365. .right {
  366. box-shadow: 0 2px 12px 0 rgba(0, 0, 0, .1);
  367. margin: 5px 0px 5px 5px;
  368. width: 50%;
  369. padding: 10px 10px;
  370. border-radius: 5px 5px;
  371. .right-title {
  372. height: 40px;
  373. line-height: 40px;
  374. }
  375. }
  376. }
  377. }
  378. }
  379. .template-form-item {
  380. background: #fff;
  381. padding: 20px;
  382. border-radius: 8px;
  383. box-shadow: 0 2px 12px 0 rgba(0, 0, 0, .1);
  384. margin-top: 24px;
  385. padding: 24px;
  386. }
  387. </style>