index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557
  1. /*layout模板*/
  2. <template>
  3. <div>
  4. <div :class="['header', fixedHeader ? 'fixed-header' : '']">
  5. <div class="logo">
  6. <router-link to="/indexLayout/workbench"
  7. ><el-image v-show="xglogo" :src="qylogo" fit="cover"
  8. />
  9. </router-link>
  10. <el-image v-show="qylogos" :src="qylogo" fit="cover"
  11. @click="routerclik()" />
  12. </div>
  13. <div class="count">
  14. <div class="item">
  15. <el-image class="icon" :src="count" fit="cover" alt="icon" />
  16. <span
  17. >注册用户数<span
  18. ><countTo :start-val="0" :end-val="user" :duration="3000" /></span
  19. >个,当前活跃用户<span
  20. ><countTo
  21. :start-val="0"
  22. :end-val="activeUser"
  23. :duration="3000" /></span
  24. >个</span
  25. >
  26. </div>
  27. <div class="item">
  28. <el-image class="icon" :src="count" fit="cover" alt="icon" />
  29. <span
  30. >总项目数<span
  31. ><countTo
  32. :start-val="0"
  33. :end-val="totalProject"
  34. :duration="3000" /></span
  35. >个,运行项目数<span
  36. ><countTo
  37. :start-val="0"
  38. :end-val="runProject"
  39. :duration="3000" /></span
  40. >个</span
  41. >
  42. </div>
  43. </div>
  44. <div
  45. v-if="
  46. $route.path !== '/login' &&
  47. $route.path !== '/register' &&
  48. $route.path !== '/forget' &&
  49. $route.path !== '/protocol'
  50. "
  51. class="nav"
  52. >
  53. <el-menu
  54. mode="horizontal"
  55. :unique-opened="true"
  56. text-color="#333"
  57. active-text-color="#333"
  58. background-color="#fff"
  59. :default-active="activeMenu"
  60. >
  61. <!-- <menu-item
  62. v-for="route in routes"
  63. :key="route.path"
  64. :item="route"
  65. :base-path="route.path"
  66. />-->
  67. <!-- <el-menu-item
  68. v-if="$route.path.indexOf('/indexLayout') == -1"
  69. index="/indexLayout"
  70. >
  71. <router-link to="/indexLayout">首页</router-link>
  72. </el-menu-item> -->
  73. <!-- <router-link to="/matchLayout" v-show="yingyong" class="yingyong">应用大赛</router-link> -->
  74. <el-menu-item
  75. v-if="loginStatus && userType != 1"
  76. :class="currentMenu == 'my-workbench' ? 'itemOn' : ''"
  77. >
  78. <!-- <router-link to="/indexLayout/my-workbench" v-show="yingyong" >我的工作台</router-link> -->
  79. </el-menu-item>
  80. <el-menu-item
  81. v-if="loginStatus"
  82. :class="currentMenu == 'user' ? 'itemOn' : ''"
  83. >
  84. <router-link to="/userLayout">
  85. <div class="user">
  86. <el-dropdown>
  87. <div>
  88. <span :title="name">{{ name }}</span>
  89. <i class="el-icon-arrow-down" />
  90. </div>
  91. <el-dropdown-menu slot="dropdown">
  92. <el-dropdown-item @click.native="logout"
  93. >退出登录</el-dropdown-item
  94. >
  95. </el-dropdown-menu>
  96. </el-dropdown>
  97. </div>
  98. </router-link>
  99. </el-menu-item>
  100. <el-menu-item v-else>
  101. <p @click="toLogin">登录/注册</p>
  102. </el-menu-item>
  103. </el-menu>
  104. </div>
  105. </div>
  106. <section class="app-main">
  107. <transition name="fade-transform" mode="out-in">
  108. <router-view :key="key" />
  109. </transition>
  110. </section>
  111. <div
  112. :class="[
  113. 'footer',
  114. fixedHeader ? 'fixed-footer' : '',
  115. /^\/indexLayout([\/][\D]+)?$/.test($route.path)|| /^\/matchLayout([\/][\D]+)?$/.test($route.path)
  116. ? 'footer-index'
  117. : /^\/login\/index$/.test($route.path)
  118. ? 'footer-login'
  119. : '',
  120. ]"
  121. >
  122. <a href="https://www.xichain.com.cn/xichain/" target="_blank"
  123. >Copyright ©2015-2018 西安前沿动力有限公司All Rights Reserved</a
  124. >
  125. <a href="http://www.beian.miit.gov.cn/" target="_blank"
  126. >版权所有:西安前沿动力科技有限公司 陕ICP备13000621号</a
  127. >
  128. <!-- <img class="police" src="../assets/img/police.png" />
  129. <a
  130. href="http://www.beian.gov.cn/portal/registerSystemInfo?recordcode=50010302003067"
  131. target="_blank"
  132. >渝公网安备 50010302003067号</a
  133. > -->
  134. <!-- <span v-show="xglogo">服务热线:023-63410620</span> -->
  135. </div>
  136. <Login :loginShow="loginShow" @putLogin="getLogin" />
  137. <Register :registerShow="registerShow" @putRegister="getRegister" />
  138. <Forget :forgetShow="forgetShow" @putForget="getForget" />
  139. </div>
  140. </template>
  141. <script>
  142. import { parseTime } from '@/utils/index'
  143. import { request } from '@/utils/request'
  144. import { resetRouter } from '@/router'
  145. import { mapGetters } from 'vuex'
  146. import { MenuItem } from './components'
  147. import countTo from 'vue-count-to'
  148. import logo from '@/assets/index/logo.png'
  149. import qylogo from '@/assets/index/qylogo.png'
  150. import count from '@/assets/index/count.png'
  151. import Login from '@/components/Login'
  152. import Register from '@/components/Register'
  153. import Forget from '@/components/Forget'
  154. export default {
  155. name: 'Layout',
  156. components: {
  157. MenuItem,
  158. countTo,
  159. Login,
  160. Register,
  161. Forget,
  162. },
  163. data() {
  164. return {
  165. logo:logo,
  166. qylogo:qylogo,
  167. yingyong:false,
  168. xglogo: false,
  169. qylogos:false,
  170. count: count,
  171. runProject: 0,
  172. totalProject: 0,
  173. user: 0,
  174. activeUser: 0,
  175. redirect: undefined,
  176. loginShow: false,
  177. registerShow: false,
  178. forgetShow: false,
  179. currentMenu: '',
  180. }
  181. },
  182. watch: {
  183. $route: {
  184. handler: function (route) {
  185. this.redirect = route.query && route.query.redirect
  186. this.getCount() // 获取统计信息
  187. //判断是否是前沿的logo;
  188. if(route.path=="/indexLayout/workbench"){
  189. this.qylogos=true;
  190. this.xglogo=false;
  191. this.yingyong=false;
  192. }else{
  193. this.xglogo=true;
  194. this.qylogos=false;
  195. this.yingyong=true;
  196. }
  197. },
  198. immediate: true,
  199. },
  200. },
  201. mounted(){
  202. },
  203. created() {
  204. // if(path.indexOf('workbench')>0 || path.indexOf('design')>0 ){
  205. // console.log(1111)
  206. // this.xglogo=false;
  207. // this.qylogos=true;
  208. // } else{
  209. // console.log(222)
  210. // this.xglogo=true;
  211. // this.qylogos=false;
  212. // }
  213. // this.getCount() // 获取统计信息
  214. // console.log('1586966400 ->' + parseTime('1586966400'))
  215. // console.log('1586966400000 ->' + parseTime('1586966400000'))
  216. // console.log('2020-12-14 ->' + parseTime('2020-12-14'))
  217. // console.log('2020-12-14 +0800 ->' + parseTime('2020-12-14 +0800'))
  218. // console.log('2020-12-14 -0800 ->' + parseTime('2020-12-14 -0800'))
  219. // console.log('2020-12-14 13:14:23 ->' + parseTime('2020-12-14 13:14:23'))
  220. // console.log(
  221. // '2020-12-14 13:14:23 +0800 ->' + parseTime('2020-12-14 13:14:23 +0800')
  222. // )
  223. // console.log(
  224. // '2020-12-14 13:14:23 -0800 ->' + parseTime('2020-12-14 13:14:23 -0800')
  225. // )
  226. // console.log('2020/12/14 ->' + parseTime('2020/12/14'))
  227. // console.log('2020/12/14 +0800 ->' + parseTime('2020/12/14 +0800'))
  228. // console.log('2020/12/14 -0800 ->' + parseTime('2020/12/14 -0800'))
  229. // console.log('2020/12/14 13:14:23 ->' + parseTime('2020/12/14 13:14:23'))
  230. // console.log(
  231. // '2020/12/14 13:14:23 +0800 ->' + parseTime('2020/12/14 13:14:23 +0800')
  232. // )
  233. // console.log(
  234. // '2020/12/14 13:14:23 -0800 ->' + parseTime('2020/12/14 13:14:23 -0800')
  235. // )
  236. },
  237. // 父组件中返回要传给下级的数据
  238. provide() {
  239. return {
  240. toLogin: this.toLogin,
  241. getCount: this.getCount,
  242. }
  243. },
  244. computed: {
  245. fixedHeader() {
  246. return this.$store.getters.fixedHeader
  247. },
  248. ...mapGetters(['name', 'userType', 'loginStatus']),
  249. key() {
  250. return this.$route.path
  251. },
  252. routes() {
  253. return this.$router.options.routes // 导航栏是使用 router.options.routes来遍历生成
  254. },
  255. activeMenu() {
  256. const route = this.$route
  257. const { meta, path } = route
  258. let pathArr = path.split('/')
  259. if (pathArr.length == 3 && pathArr[1] == 'userLayout') {
  260. this.currentMenu = 'user'
  261. } else if (
  262. pathArr.length == 3 &&
  263. pathArr[1] == 'indexLayout' &&
  264. pathArr[2] == 'my-workbench'
  265. ) {
  266. this.currentMenu = pathArr[2]
  267. } else {
  268. this.currentMenu = ''
  269. }
  270. // 如果设置了路径,侧边栏将突出显示您设置的路径
  271. if (meta.activeMenu) {
  272. return meta.activeMenu
  273. }
  274. return path
  275. },
  276. },
  277. methods: {
  278. routerclik(){
  279. const path=this.$route.path
  280. let id= sessionStorage.getItem("id",id);
  281. let pretreatment= sessionStorage.getItem("pretreatment",pretreatment);
  282. let solver= sessionStorage.getItem("pretreatment",solver);
  283. this.$router.replace({
  284. path: '/indexLayout/workbench',
  285. query: {id, pretreatment, solver },
  286. })
  287. // if(path=="/indexLayout/design"){
  288. // }else{
  289. // this.$router.replace({
  290. // path: '/indexLayout',
  291. // })
  292. // }
  293. },
  294. toLogin() {
  295. this.loginShow = true
  296. },
  297. getLogin(data) {
  298. this.loginShow = false
  299. if (data) {
  300. if (data.type == 'register') {
  301. this.registerShow = true
  302. } else if (data.type == 'forget') {
  303. this.forgetShow = true
  304. }
  305. }
  306. },
  307. getRegister(data) {
  308. this.registerShow = false
  309. if (data && data.type == 'login') {
  310. this.loginShow = true
  311. }
  312. },
  313. getForget(data) {
  314. this.forgetShow = false
  315. if (data && data.type == 'login') {
  316. this.loginShow = true
  317. }
  318. },
  319. quit() {
  320. this.$store.dispatch('user/changeState', {
  321. key: 'token',
  322. value: '',
  323. })
  324. this.$store.dispatch('user/changeState', {
  325. key: 'name',
  326. value: '',
  327. })
  328. this.$store.dispatch('user/changeState', {
  329. key: 'userId',
  330. value: '',
  331. })
  332. this.$store.dispatch('user/changeState', {
  333. key: 'userRole',
  334. value: '',
  335. })
  336. this.$store.dispatch('user/changeState', {
  337. key: 'cfdUrl',
  338. value: '',
  339. })
  340. this.$store.dispatch('user/changeState', {
  341. key: 'loginStatus',
  342. value: false,
  343. })
  344. resetRouter()
  345. this.$message.success('退出成功!')
  346. setTimeout(() => {
  347. // this.$router.replace(`/login?redirect=${this.$route.fullPath}`)
  348. this.$router.replace(`/indexLayout/workbench`)
  349. }, 1000)
  350. },
  351. logout() {
  352. this.$confirm('此操作将退出登录, 是否继续?', '提示', {
  353. confirmButtonText: '确定',
  354. cancelButtonText: '取消',
  355. center: true,
  356. type: 'warning',
  357. })
  358. .then(() => {
  359. request({ transCode: 'A00004' })
  360. .then(() => {
  361. this.quit()
  362. })
  363. .catch((err) => {
  364. this.quit()
  365. })
  366. })
  367. .catch(() => {
  368. this.$message.info('已取消')
  369. })
  370. },
  371. getCount() {
  372. this.runProject = 0
  373. this.totalProject = 0
  374. this.user = 0
  375. this.activeUser = 0
  376. request({ transCode: 'C00005' })
  377. .then((res) => {
  378. this.runProject = parseInt(res.runProject)
  379. this.totalProject = parseInt(res.totalProject)
  380. this.user = parseInt(res.user)
  381. this.activeUser = parseInt(res.activeUser)
  382. })
  383. .catch((err) => {})
  384. },
  385. },
  386. }
  387. </script>
  388. <style lang="scss" scoped>
  389. @import '@/styles/variables.scss';
  390. @import '@/styles/mixin.scss';
  391. // @import '@/styles/transition.scss';
  392. .fixed {
  393. &-header {
  394. // @include position(fixed, 0, auto, 0, 0, 9);
  395. @include w_h();
  396. }
  397. &-footer {
  398. // @include position(fixed, auto, 0, 0, 0, 9);
  399. @include w_h();
  400. }
  401. }
  402. .yingyong{
  403. font-size: 14px;
  404. color: #303133;
  405. &:hover {
  406. cursor: pointer;
  407. }
  408. }
  409. .header {
  410. padding: 0 $pad;
  411. @include flex();
  412. @include w_h(100%, 50px);
  413. min-width: 1000px;
  414. background: $color_f;
  415. box-shadow: 0px 1px 7px 0px rgba(0, 0, 0, 0.04);
  416. .logo {
  417. @include w_h(100px);
  418. &:hover {
  419. cursor: pointer;
  420. }
  421. }
  422. .count {
  423. @include flex(flex-start);
  424. @include w_h(auto, 35px);
  425. padding: 0 $pad;
  426. font-size: 12px;
  427. color: $color_3;
  428. .item {
  429. margin: 0 20px;
  430. }
  431. .icon {
  432. @include w_h(14px);
  433. margin-right: 3px;
  434. vertical-align: bottom;
  435. }
  436. span {
  437. span {
  438. color: $color_on;
  439. }
  440. }
  441. }
  442. .nav {
  443. @include flex();
  444. height: 100%;
  445. font-size: 12px;
  446. .el-menu {
  447. height: 100%;
  448. border: none;
  449. background: $color_f;
  450. color: #0470cc;
  451. .itemOn {
  452. color: $color_on !important;
  453. border-bottom: 2px solid $color_on !important;
  454. }
  455. }
  456. .user {
  457. color: inherit;
  458. span {
  459. display: inline-block;
  460. max-width: 100px;
  461. font-size: 14px;
  462. white-space: nowrap;
  463. text-overflow: ellipsis;
  464. overflow: hidden;
  465. }
  466. .el-icon-arrow-down {
  467. font-size: 12px;
  468. }
  469. }
  470. }
  471. }
  472. .app-main {
  473. padding: 0;
  474. width: 100%;
  475. // height: calc(100vh - 85px);
  476. // min-height: 580px;
  477. }
  478. // .fixed-header + .app-main {
  479. // // padding: 40px 0 0;
  480. // }
  481. .footer {
  482. @include w_h(100%, 35px);
  483. line-height: 35px;
  484. font-size: 12px;
  485. text-align: center;
  486. color: #747474;
  487. background: $color_f2;
  488. .police {
  489. vertical-align: sub;
  490. }
  491. a {
  492. padding-right: 10px;
  493. }
  494. a:hover {
  495. color: $color_9;
  496. }
  497. &-login {
  498. background: $color_f;
  499. }
  500. &-index {
  501. background: #2b2828;
  502. }
  503. }
  504. </style>
  505. <style lang="scss">
  506. @import '@/styles/variables.scss';
  507. .el-image__inner--center {
  508. left: 0 !important;
  509. transform: translate(0) !important;
  510. }
  511. .nav {
  512. .el-dropdown {
  513. color: inherit;
  514. }
  515. .el-menu-item,
  516. .el-submenu__title,
  517. .el-menu--horizontal > .el-menu-item {
  518. height: 40px;
  519. line-height: 40px;
  520. color: $color_3;
  521. border: none;
  522. padding: 0 5px;
  523. margin: 0 15px;
  524. a {
  525. display: block;
  526. }
  527. &.is-active {
  528. border: none;
  529. }
  530. }
  531. }
  532. </style>