menuList.vue 9.3 KB

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