menuList.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  1. <template>
  2. <!-- 顶部路由 -->
  3. <div class='menu'>
  4. <div class='home' @click='$emit("update:modelNum", 0)'>
  5. <div class='downright'></div>
  6. <div class='home-box'>
  7. <img src='@/assets/imgs/logo.png' alt />
  8. <span>大连高新万达广场</span>
  9. <!-- <span v-if='plazas'>{{plazas.length>0?formatter(plazaId,plazas):'--'}}</span> -->
  10. </div>
  11. </div>
  12. <div>
  13. <div
  14. v-for='(item, index) in list'
  15. :key='index'
  16. :class='{ "is-active": item.state }'
  17. @click='clickEventAcitve(item, index)'
  18. >{{ item.name }}</div>
  19. </div>
  20. <div class='home-right'>
  21. <span @click='dumpLegend'>
  22. <img class='img1' src='../assets/imgs/scj.png' alt />
  23. <span class='span1'>图例库</span>
  24. </span>
  25. <span @click='toDrafts' class='span-out'>
  26. <img class='img2' src='../assets/imgs/cgx.png' alt />
  27. <span class='span2'>草稿箱</span>
  28. <span class='span2-num' v-if='draftNum && draftNum <= 99'>{{draftNum}}</span>
  29. <span class='span2-num' style='line-height:10px' v-else-if='draftNum && draftNum > 99'>...</span>
  30. </span>
  31. <span>
  32. <img class='img3' src='../assets/imgs/clock.png' alt />
  33. <span class='span3'>{{times}}</span>
  34. </span>
  35. </div>
  36. </div>
  37. </template>
  38. <script>
  39. import { formatTime } from '@/utils/format.js'
  40. import { mapGetters } from 'vuex'
  41. import moment from 'moment'
  42. import { queryDraftNum } from '../../src/api/public'
  43. export default {
  44. data() {
  45. return {
  46. state: '',
  47. list: [
  48. { name: '首页', state: false, route: 'homepage' },
  49. { name: '项目概况', state: false, route: 'overview' },
  50. { name: '楼层功能', state: false, route: 'floorFunc' }, //楼层功能
  51. { name: '设备设施', state: false, route: 'equipment' }, //设备设施
  52. { name: '其他事项', state: false, route: 'other' }, //其他
  53. { name: '分析|报表', state: false, route: 'analysis' }
  54. ],
  55. times: `${new Date().getFullYear()}.${formatTime(new Date().getMonth() + 1)}.${formatTime(new Date().getDate())} ${formatTime(
  56. new Date().getHours()
  57. )}:${formatTime(new Date().getMinutes())}`,
  58. draftNum: null, //草稿箱数量
  59. interval: 10 * 60 * 1000, //定时器时长,默认 10分钟
  60. timer: null, //保存定时器
  61. // 路由词典
  62. dict: {
  63. homepage: 1,
  64. overview: 2,
  65. floorFunc: 3,
  66. equipment: 4,
  67. other: 5,
  68. analysis: 6
  69. }
  70. }
  71. },
  72. computed: {
  73. ...mapGetters(['plazas', 'plazaId', 'fmapID'])
  74. },
  75. watch: {
  76. $route: 'handleRoute'
  77. },
  78. created() {
  79. this.currentTime()
  80. },
  81. mounted() {
  82. this.handleRoute(this.$route)
  83. // console.log(this.fmapID)
  84. // 定时查询草稿箱数量
  85. this.getDraftNum() //首次查询
  86. this.timer = setInterval(() => {
  87. this.getDraftNum()
  88. }, this.interval)
  89. // 页面销毁前,清除定时器
  90. this.$once('hook:beforeDestroy', () => {
  91. clearInterval(this.timer)
  92. })
  93. },
  94. methods: {
  95. /**
  96. * @name getDraftNum
  97. * @description 查询草稿箱数量
  98. */
  99. async getDraftNum() {
  100. let res = null,
  101. data = {
  102. Distinct: true,
  103. Filters: `projectId='${this.plazaId}';isPub=false`,
  104. PageNumber: 1,
  105. PageSize: 500,
  106. Projection: ['floorId']
  107. }
  108. try {
  109. // 调用接口
  110. // res = await queryDraftNum(data)
  111. } catch (error) {
  112. console.error(error)
  113. }
  114. if (!res) {
  115. this.draftNum = null
  116. return false
  117. }
  118. // 草稿箱总条数使用 res.Total, 不使用 Content数组的长度
  119. this.draftNum = res.Total || null
  120. },
  121. //入草稿箱
  122. toDrafts() {
  123. const { conf } = window.__systemConf,
  124. { editerUrl } = conf
  125. let data = `projectId=${this.plazaId}&fmapID=${this.fmapID}&token=${this.$store.state.ssoToken}`
  126. let url = editerUrl + 'drafts?' + encodeURIComponent(data)
  127. window.open(url, true)
  128. },
  129. currentTime() {
  130. this.times = moment().format('YYYY.MM.DD HH:mm')
  131. setTimeout(this.currentTime, 1000)
  132. },
  133. handleRoute(newRouter) {
  134. if (!newRouter) {
  135. return false
  136. }
  137. const { path } = newRouter
  138. let router = path.split('home/')[1]
  139. this.modelNum(this.dict[router])
  140. },
  141. formatter(str, arrv) {
  142. if (str && arrv) {
  143. const Objs = arrv.find(e => e && e.plazaid == str)
  144. return Objs ? Objs.plazaname : '--'
  145. } else {
  146. return ''
  147. }
  148. },
  149. modelNum(val) {
  150. this.list = this.list.map((item, index) => {
  151. if (val == index + 1) {
  152. item.state = true
  153. } else {
  154. item.state = false
  155. }
  156. return item
  157. })
  158. },
  159. clickEventAcitve(item) {
  160. if (item.name == '楼层功能') {
  161. this.$cookie.set('categoryId', 'LCGN', 3)
  162. } else {
  163. this.$cookie.set('categoryId', 'GDXT', 3)
  164. }
  165. this.list.forEach(ele => {
  166. ele.state = false
  167. })
  168. item.state = true
  169. this.state = item.state
  170. this.$router.push({ path: `/home/${item.route}` })
  171. },
  172. dumpLegend() {
  173. const { conf } = window.__systemConf,
  174. { wandaBmGuideUrl } = conf
  175. window.open(`${wandaBmGuideUrl}home/legendLibrary?token=${this.$store.state.ssoToken}`, true)
  176. }
  177. }
  178. }
  179. </script>
  180. <style scoped lang="less">
  181. .menu {
  182. height: 48px;
  183. min-width: 1366px;
  184. color: #1f2429;
  185. font-size: 16px;
  186. background: rgba(255, 255, 255, 1);
  187. box-shadow: 0px 2px 10px 0px rgba(31, 35, 41, 0.1);
  188. // overflow: hidden;
  189. .home {
  190. width: 265px;
  191. height: 48px;
  192. // line-height: 48px;
  193. text-align: center;
  194. cursor: pointer;
  195. color: #ffffff;
  196. float: left;
  197. margin-right: 83px;
  198. // background: linear-gradient(180deg, rgba(54, 156, 247, 1) 0%, rgba(2, 91, 170, 1) 100%);
  199. background: linear-gradient(180deg, rgba(54, 156, 247, 1) 0%, rgba(2, 91, 170, 1) 100%);
  200. position: relative;
  201. .downright {
  202. position: absolute;
  203. width: 0;
  204. height: 0;
  205. border-left: 20px solid transparent;
  206. border-bottom: 48px solid #fff;
  207. right: 0px;
  208. top: 0;
  209. }
  210. .home-box {
  211. height: 100%;
  212. display: flex;
  213. align-items: center;
  214. img {
  215. width: 28px;
  216. height: 28px;
  217. margin-left: 20px;
  218. margin-right: 24px;
  219. margin-top: -3px;
  220. }
  221. span {
  222. font-size: 20px;
  223. font-family: MicrosoftYaHei;
  224. height: 27px;
  225. line-height: 27px;
  226. margin-top: -4px;
  227. &:after {
  228. content: '|';
  229. position: absolute;
  230. left: 60px;
  231. }
  232. }
  233. }
  234. }
  235. & > div:nth-of-type(2) {
  236. & > div {
  237. line-height: 48px;
  238. text-align: center;
  239. //background: url('../assets/images/topbar1.png') no-repeat;
  240. float: left;
  241. width: 88px;
  242. height: 48px;
  243. margin: 0 8px;
  244. cursor: pointer;
  245. transition: all 0.2s;
  246. }
  247. .is-active {
  248. color: #025baa;
  249. font-weight: bolder;
  250. border-bottom: 2px solid #025baa;
  251. background: linear-gradient(180deg, rgba(2, 91, 170, 0) 0%, rgba(2, 91, 170, 0.2) 100%);
  252. }
  253. }
  254. .home-right {
  255. float: right;
  256. margin-right: 20px;
  257. line-height: 48px;
  258. color: #646c73;
  259. font-size: 14px;
  260. cursor: pointer;
  261. display: flex;
  262. align-content: center;
  263. img {
  264. margin-top: -2px;
  265. }
  266. .span-out {
  267. position: relative;
  268. margin: 0 16px;
  269. .span2-num {
  270. position: absolute;
  271. right: -5px;
  272. top: 5px;
  273. display: inline-block;
  274. width: 18px;
  275. height: 18px;
  276. background: red;
  277. border-radius: 90px;
  278. font-size: 12px;
  279. text-align: center;
  280. line-height: 18px;
  281. color: #ffffff;
  282. }
  283. }
  284. }
  285. .span1,
  286. .span2 {
  287. padding: 0 6px 0 3px;
  288. }
  289. .span3 {
  290. padding-left: 3px;
  291. }
  292. }
  293. </style>
  294. <style lang="less">
  295. .menu {
  296. .el-badge__content.is-fixed {
  297. top: 10px;
  298. }
  299. }
  300. </style>