statisticsTabs.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328
  1. <template>
  2. <div class="statistics-tabs">
  3. <el-row
  4. :gutter="16"
  5. type="flex"
  6. >
  7. <el-col
  8. v-for="(tab, index) in newTabList"
  9. :key="index"
  10. :span="4"
  11. >
  12. <el-dropdown
  13. v-if="tab.children && tab.children.length"
  14. placement="bottom"
  15. @command="commandHandler"
  16. >
  17. <div :class="['tab-bar', { 'tab-active': activeIndex === index }]">
  18. <img
  19. class="tab-icon"
  20. :src="activeIndex === index ? activeIcon : defaultIcon"
  21. :alt="tab.title"
  22. />
  23. <el-tooltip
  24. :content="tab.title"
  25. placement="top"
  26. >
  27. <span class="tab-title">{{ tab.title }}</span>
  28. </el-tooltip>
  29. <i class="icon-arrow el-icon-caret-bottom" />
  30. </div>
  31. <el-dropdown-menu slot="dropdown">
  32. <el-dropdown-item
  33. v-for="(childTab, childIndex) in tab.children"
  34. :key="childIndex"
  35. :command="[tab.path, childTab.path]"
  36. >{{ childTab.title }}</el-dropdown-item>
  37. </el-dropdown-menu>
  38. </el-dropdown>
  39. <div
  40. v-else
  41. :class="['tab-bar tab-bar-single', { 'tab-active': activeIndex === index }]"
  42. @click="clickHandler(tab.path)"
  43. >
  44. <img
  45. class="tab-icon"
  46. :src="activeIndex === index ? activeIcon : defaultIcon"
  47. :alt="tab.title"
  48. />
  49. <el-tooltip
  50. :content="tab.title"
  51. placement="top"
  52. >
  53. <span class="tab-title">{{ tab.title }}</span>
  54. </el-tooltip>
  55. </div>
  56. </el-col>
  57. </el-row>
  58. </div>
  59. </template>
  60. <script>
  61. export default {
  62. name: 'StatisticsTabs',
  63. data() {
  64. return {
  65. defaultIcon: require('@/assets/nav/ic_statistical_top_default.png'),
  66. activeIcon: require('@/assets/nav/ic_statistical_top_check.png'),
  67. tabList: [
  68. {
  69. title: '航司行李相关统计',
  70. path: '/statisticsCharts/airlineCompany',
  71. roles: ['airline_baggage_statistics'],
  72. children: [
  73. {
  74. path: 'flight',
  75. title: '航班量统计'
  76. },
  77. {
  78. path: 'baggage',
  79. title: '行李量统计'
  80. },
  81. {
  82. path: 'baggagePassenger',
  83. title: '行李旅客量统计'
  84. },
  85. {
  86. path: 'specialBaggage',
  87. title: '特殊行李量统计'
  88. },
  89. {
  90. path: 'baggageAverage',
  91. title: '平均行李量统计'
  92. },
  93. {
  94. path: 'abnormalBaggage',
  95. title: '异常行李量统计'
  96. },
  97. {
  98. path: 'complaintBaggage',
  99. title: '投诉行李量统计'
  100. },
  101. {
  102. path: 'compensationBaggage',
  103. title: '赔偿行李量统计'
  104. },
  105. {
  106. path: 'compensation',
  107. title: '赔偿金额统计'
  108. }
  109. ]
  110. },
  111. {
  112. path: '/statisticsCharts/passengerClassification',
  113. title: '旅客分类统计',
  114. roles: ['passenger_luggage_classification_statistics'],
  115. children: [
  116. {
  117. path: 'baggage',
  118. title: '行李量统计'
  119. },
  120. {
  121. path: 'baggagePassenger',
  122. title: '行李旅客量统计'
  123. },
  124. {
  125. path: 'specialBaggage',
  126. title: '特殊行李量统计'
  127. },
  128. {
  129. path: 'abnormalBaggage',
  130. title: '异常行李量统计'
  131. },
  132. {
  133. path: 'complaintBaggage',
  134. title: '投诉行李量统计'
  135. },
  136. {
  137. path: 'compensationBaggage',
  138. title: '赔偿行李量统计'
  139. },
  140. {
  141. path: 'compensation',
  142. title: '赔偿金额统计'
  143. }
  144. ]
  145. },
  146. {
  147. path: '/statisticsCharts/flightClassification',
  148. title: '航班分类相关统计',
  149. roles: ['statistics_related_to_flight_classification'],
  150. children: [
  151. {
  152. path: 'flight',
  153. title: '航班量统计'
  154. },
  155. {
  156. path: 'baggage',
  157. title: '行李量统计'
  158. },
  159. {
  160. path: 'passenger',
  161. title: '行李旅客量统计'
  162. }
  163. ]
  164. },
  165. {
  166. path: '/statisticsCharts/node',
  167. title: '扫描节点与位置分析',
  168. roles: ['scanning_node_and_location_analysis']
  169. },
  170. {
  171. title: '报表统计',
  172. path: '/statisticsCharts/report',
  173. roles: ['report_statistics'],
  174. children: [
  175. {
  176. path: 'reportStatistics',
  177. title: '运送效率报表统计'
  178. },
  179. {
  180. path: 'transitTable',
  181. title: '中转专项报表统计'
  182. },
  183. {
  184. path: 'ScanningStatistics',
  185. title: '航站BRS扫描统计'
  186. }
  187. ]
  188. },
  189. {
  190. title: '特殊赔偿异常分类统计',
  191. path: '/statisticsCharts/specialClassification',
  192. roles: ['special_compensation_exception_classification_statistics'],
  193. children: [
  194. {
  195. path: 'special',
  196. title: '特殊行李分类统计'
  197. },
  198. {
  199. path: 'abnormal',
  200. title: '异常行李分类统计'
  201. },
  202. {
  203. path: 'compensationBaggage',
  204. title: '赔偿行李分类统计'
  205. },
  206. {
  207. path: 'compensation',
  208. title: '赔偿金额分类统计'
  209. }
  210. ]
  211. },
  212. {
  213. path: '/statisticsCharts/statisticalAnalysis',
  214. title: '统计分析',
  215. roles: ['statistical_analysis']
  216. }
  217. ],
  218. activeIndex: null
  219. }
  220. },
  221. computed: {
  222. newTabList() {
  223. const auths = JSON.parse(sessionStorage.getItem('userAuthList'))
  224. return this.tabList.filter(tab => !tab.roles || tab.roles.every(role => auths.includes(role)))
  225. }
  226. },
  227. watch: {
  228. '$route.path': {
  229. handler(path) {
  230. let activeIndex = null
  231. this.tabList.some((tab, index) => {
  232. if (path.includes(tab.path)) {
  233. activeIndex = index
  234. return true
  235. }
  236. })
  237. this.activeIndex = activeIndex
  238. },
  239. immediate: true
  240. }
  241. },
  242. methods: {
  243. commandHandler(pathArray) {
  244. if (pathArray.some(path => !path)) {
  245. this.$message.info('开发中')
  246. return
  247. }
  248. this.$router.push({
  249. path: pathArray.join('/')
  250. })
  251. },
  252. clickHandler(path) {
  253. if (!path) {
  254. this.$message.info('开发中')
  255. return
  256. }
  257. this.$router.push({
  258. path
  259. })
  260. }
  261. }
  262. }
  263. </script>
  264. <style lang="scss" scoped>
  265. .statistics-tabs {
  266. > .el-row > .el-col {
  267. max-width: 232px;
  268. min-width: 175px;
  269. .el-dropdown {
  270. width: 100%;
  271. }
  272. .tab-bar {
  273. width: 100%;
  274. height: 56px;
  275. background-color: #ffffff;
  276. padding-left: 16px;
  277. padding-right: 16px;
  278. display: flex;
  279. align-items: center;
  280. box-shadow: 0px 6px 7px 0px rgba(0, 0, 0, 0.06);
  281. border-radius: 4px;
  282. &-single {
  283. cursor: pointer;
  284. }
  285. &:not(:last-child) {
  286. margin-right: 16px;
  287. }
  288. .tab-icon {
  289. width: 14px;
  290. height: 14px;
  291. }
  292. .tab-title {
  293. padding-left: 12px;
  294. padding-right: 8px;
  295. font-size: 14px;
  296. font-family: Helvetica, 'Microsoft YaHei';
  297. font-weight: bold;
  298. color: #101116;
  299. letter-spacing: 0;
  300. overflow: hidden;
  301. white-space: nowrap;
  302. text-overflow: ellipsis;
  303. }
  304. &.tab-active {
  305. background-color: #2d67e3;
  306. .tab-title {
  307. color: #ffffff;
  308. }
  309. }
  310. .icon-arrow {
  311. position: absolute;
  312. right: 16px;
  313. color: #101116;
  314. font-size: 14px;
  315. transition: transform 0.3s;
  316. }
  317. &.tab-active .icon-arrow {
  318. color: #ffffff;
  319. }
  320. &:hover .icon-arrow {
  321. transform: rotate(180deg);
  322. }
  323. }
  324. }
  325. }
  326. </style>