menuList.vue 9.8 KB

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