MenuCard.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496
  1. <template>
  2. <!-- 外边框 -->
  3. <div
  4. :class="$ifLeftMenu(menuData.index) ? 'menuMainBoxA' : 'menuMainBox'"
  5. :style="{
  6. width: menuData.boxWidth ? menuData.boxWidth + 'px' : '410px',
  7. height: menuData.boxHeight ? menuData.boxHeight + 'px' : 'auto',
  8. border: menuData.type !== 'chart' ? '' : '1px solid #2FB8FF',
  9. background: menuData.boxBackground ? menuData.boxBackground : ''
  10. }"
  11. @click="changeLeftMenuIndex()"
  12. >
  13. <!-- 头部 -->
  14. <div class="menuMainBox_top" v-if="menuData.type !== 'chart'">
  15. <!-- 头部左侧 -->
  16. <div class="menuMainBox_top_left" :style="{ width: menuData.titleWidth ? menuData.titleWidth + '%' : '50%' }">
  17. <!-- 左侧箭头图标 -->
  18. <div class="menuMainBox_top_left_iconS" v-if="menuData.type !== 'imageMenu'"></div>
  19. <div class="menuMainBox_top_left_iconR" v-if="menuData.type === 'imageMenu'">
  20. <div class="menuMainBox_top_left_iconR_active" v-if="$ifLeftMenu(menuData.index)"></div>
  21. </div>
  22. <!-- 标题 -->
  23. <div class="menuMainBox_top_left_title">{{ menuData.title }}</div>
  24. <!-- 右侧倾斜图标1 -->
  25. <div class="menuMainBox_top_left_iconE menuMainBox_top_left_iconE1"></div>
  26. <!-- 右侧倾斜图标2 -->
  27. <div class="menuMainBox_top_left_iconE menuMainBox_top_left_iconE2"></div>
  28. </div>
  29. <!-- 头部右侧 -->
  30. <div class="menuMainBox_top_right" :style="{ width: menuData.titleWidth ? 110 - menuData.titleWidth + '%' : '60%' }">
  31. <!-- 方块1 -->
  32. <div class="menuMainBox_top_right_d1"></div>
  33. <!-- 方块2 -->
  34. <div class="menuMainBox_top_right_d2"></div>
  35. </div>
  36. <!-- 右上角三个点 -->
  37. <div class="menuMainBox_top_topRight">
  38. <div></div>
  39. <div></div>
  40. <div></div>
  41. </div>
  42. </div>
  43. <!-- 折线 -->
  44. <div
  45. class="menuMainBox_topBottom"
  46. v-if="menuData.type !== 'chart'"
  47. :style="{ left: menuData.titleWidth ? menuData.titleWidth - 40 + '%' : '10%' }"
  48. >
  49. <!-- 圆球 -->
  50. <div></div>
  51. </div>
  52. <div class="menuMainBox_topChart" v-if="menuData.type === 'chart'">
  53. <div class="menuMainBox_topChart_title">
  54. {{ menuData.title }}
  55. </div>
  56. </div>
  57. <!-- 主题 -->
  58. <div class="menuMainBox_main" v-if="menuData.type === 'card'">
  59. <!-- 上部 -->
  60. <div class="menuMainBox_main_top">
  61. <slot name="top"></slot>
  62. </div>
  63. <!-- 下部 -->
  64. <div class="menuMainBox_main_bottom">
  65. <slot name="bottom"></slot>
  66. </div>
  67. </div>
  68. <div class="menuMainBox_main" v-if="menuData.type === 'chart'">
  69. <div class="menuMainBox_main_all">
  70. <slot></slot>
  71. </div>
  72. </div>
  73. <div class="menuMainBox_main_image" v-if="menuData.type === 'imageMenu'">
  74. <div class="menuMainBox_main_image_box" :style="returnImageUrl(menuData.imageUrl, menuData.boxHeight)"></div>
  75. </div>
  76. </div>
  77. </template>
  78. <script>
  79. export default {
  80. name: "menuCard",
  81. components: {},
  82. data() {
  83. return {};
  84. },
  85. mounted() {},
  86. /**
  87. * menuData =>
  88. * type: 类型【card:卡片;chart:echart组件;imageMenu:图片菜单;legend:图例】(必填)
  89. * index: 子菜单index(当type为imageMenu时有效)
  90. * imageUrl: 菜单图片地址(当type为imageMenu时有效)
  91. * title: 标题(必填)
  92. * boxWidth: 宽,默认为410px(非必填)
  93. * boxHeight: 高,默认为auto(非必填)
  94. * boxBackground: 背景色,默认为渐变蓝色(非必填)
  95. * titleWidth: 标题宽度,默认为50(非必填)
  96. */
  97. props: ["menuData"],
  98. methods: {
  99. changeLeftMenuIndex() {
  100. if (this.menuData.index != undefined) {
  101. this.$store.commit("changeLeftMenuIndex", this.menuData.index);
  102. }
  103. },
  104. returnImageUrl(imageUrl, boxHeight) {
  105. let returnStyle = "";
  106. if (boxHeight) {
  107. returnStyle += "heihgt:" + (boxHeight - 36) + "px;";
  108. }
  109. returnStyle += "background-image: url('" + imageUrl + "');";
  110. return returnStyle;
  111. }
  112. },
  113. watch: {}
  114. };
  115. </script>
  116. <style lang="less" scoped>
  117. @borderColor: #00aaff;
  118. @borderColor32: #00aaff32;
  119. @borderColor64: #00aaff64;
  120. @topTitleBgLeft: #00244d;
  121. @topTitleMinLeft: #002f56;
  122. @lightColor: #74ffff;
  123. .menuMainBox {
  124. position: relative;
  125. z-index: 999;
  126. margin: 10px 5px;
  127. min-height: 60px;
  128. border: 2px solid transparent;
  129. border-image: --webkit-linear-gradient(to top, @borderColor, transparent) 1;
  130. border-image: --moz-linear-gradient(to top, @borderColor, transparent) 1;
  131. border-image: linear-gradient(to top, @borderColor, transparent) 1;
  132. opacity: 0.9;
  133. cursor: pointer;
  134. -moz-user-select: none;
  135. -webkit-user-select: none;
  136. -ms-user-select: none;
  137. -khtml-user-select: none;
  138. user-select: none;
  139. // type !== chart
  140. &_top {
  141. position: relative;
  142. width: 100%;
  143. height: 36px;
  144. display: flex;
  145. align-items: center;
  146. flex-wrap: nowrap;
  147. align-content: center;
  148. overflow: hidden;
  149. background-color: @topTitleMinLeft;
  150. &_left {
  151. position: relative;
  152. display: flex;
  153. align-items: center;
  154. flex-wrap: nowrap;
  155. align-content: center;
  156. height: 100%;
  157. background-image: --webkit-linear-gradient(to left, @topTitleMinLeft, @borderColor, @topTitleMinLeft);
  158. background-image: --moz-linear-gradient(to left, @topTitleMinLeft, @borderColor, @topTitleMinLeft);
  159. background-image: linear-gradient(to left, @topTitleMinLeft, @borderColor, @topTitleMinLeft);
  160. border-bottom: 2px solid @borderColor;
  161. &_iconS {
  162. margin: 10px;
  163. width: 20px;
  164. height: 20px;
  165. background-image: linear-gradient(to top, #0071b2, #1deef5);
  166. clip-path: polygon(0 0, 100% 50%, 0 100%, 30% 50%, 0 0);
  167. }
  168. &_iconR {
  169. position: relative;
  170. margin: 15px;
  171. width: 10px;
  172. height: 10px;
  173. background-image: transparent;
  174. border: 1px solid #1deef5;
  175. border-radius: 20px;
  176. &_active {
  177. position: absolute;
  178. transform: translate(-50%, -50%);
  179. top: 50%;
  180. left: 50%;
  181. width: 5px;
  182. height: 5px;
  183. background-color: #1deef5;
  184. border-radius: 20px;
  185. }
  186. }
  187. &_title {
  188. font-size: 28px;
  189. font-family: YouSheBiaoTiHei;
  190. font-weight: 400;
  191. color: #ffffff;
  192. }
  193. &_iconE {
  194. position: absolute;
  195. margin-left: 10px;
  196. width: 15px;
  197. height: 30px;
  198. background-image: linear-gradient(to bottom, transparent, transparent, #00a6c0);
  199. transform: skew(-45deg);
  200. }
  201. &_iconE1 {
  202. right: 27px;
  203. }
  204. &_iconE2 {
  205. right: 7px;
  206. }
  207. }
  208. &_right {
  209. position: absolute;
  210. right: -10%;
  211. height: 100%;
  212. border-top: 2px solid @borderColor;
  213. border-left: 2px solid @borderColor;
  214. transform: skew(-45deg);
  215. background-color: @topTitleBgLeft;
  216. border-image: --webkit-linear-gradient(to right, @borderColor, transparent) 1;
  217. border-image: --moz-linear-gradient(to right, @borderColor, transparent) 1;
  218. border-image: linear-gradient(to right, @borderColor, transparent) 1;
  219. &_d1 {
  220. position: absolute;
  221. left: 10px;
  222. width: 50px;
  223. height: 20px;
  224. background-color: @borderColor64;
  225. }
  226. &_d2 {
  227. position: absolute;
  228. left: 70px;
  229. width: 80px;
  230. height: 10px;
  231. background-color: @borderColor32;
  232. }
  233. }
  234. &_topRight {
  235. position: absolute;
  236. top: 0;
  237. right: 0;
  238. display: flex;
  239. div:nth-child(1) {
  240. width: 5px;
  241. height: 2px;
  242. background-color: @borderColor;
  243. }
  244. div:nth-child(2) {
  245. margin: 0 1px;
  246. width: 5px;
  247. height: 2px;
  248. background-color: #f19b56;
  249. }
  250. div:nth-child(3) {
  251. width: 5px;
  252. height: 2px;
  253. background-color: @borderColor;
  254. }
  255. }
  256. }
  257. }
  258. // 选中后的样式
  259. .menuMainBoxA {
  260. position: relative;
  261. z-index: 999;
  262. margin: 10px 5px;
  263. min-height: 60px;
  264. border: 2px solid transparent;
  265. border-image: --webkit-linear-gradient(to top, @lightColor, transparent) 1;
  266. border-image: --moz-linear-gradient(to top, @lightColor, transparent) 1;
  267. border-image: linear-gradient(to top, @lightColor, transparent) 1;
  268. opacity: 0.9;
  269. cursor: pointer;
  270. -moz-user-select: none;
  271. -webkit-user-select: none;
  272. -ms-user-select: none;
  273. -khtml-user-select: none;
  274. user-select: none;
  275. // type !== chart
  276. .menuMainBox_top {
  277. position: relative;
  278. width: 100%;
  279. height: 36px;
  280. display: flex;
  281. align-items: center;
  282. flex-wrap: nowrap;
  283. align-content: center;
  284. overflow: hidden;
  285. background-color: @lightColor;
  286. &_left {
  287. position: relative;
  288. display: flex;
  289. align-items: center;
  290. flex-wrap: nowrap;
  291. align-content: center;
  292. height: 100%;
  293. border-bottom: 2px solid @borderColor;
  294. background-image: --webkit-linear-gradient(to left, @lightColor, #007dff);
  295. background-image: --moz-linear-gradient(to left, @lightColor, #007dff);
  296. background-image: linear-gradient(to left, @lightColor, #007dff);
  297. &_iconS {
  298. margin: 10px;
  299. width: 20px;
  300. height: 20px;
  301. background-image: linear-gradient(to top, #0071b2, #1deef5);
  302. clip-path: polygon(0 0, 100% 50%, 0 100%, 30% 50%, 0 0);
  303. }
  304. &_iconR {
  305. position: relative;
  306. margin: 15px;
  307. width: 10px;
  308. height: 10px;
  309. background-image: transparent;
  310. border: 1px solid #1deef5;
  311. border-radius: 20px;
  312. &_active {
  313. position: absolute;
  314. transform: translate(-50%, -50%);
  315. top: 50%;
  316. left: 50%;
  317. width: 5px;
  318. height: 5px;
  319. background-color: #1deef5;
  320. border-radius: 20px;
  321. }
  322. }
  323. &_title {
  324. font-size: 28px;
  325. font-family: YouSheBiaoTiHei;
  326. font-weight: 400;
  327. color: #ffffff;
  328. }
  329. &_iconE {
  330. position: absolute;
  331. margin-left: 10px;
  332. width: 15px;
  333. height: 30px;
  334. background-image: linear-gradient(to bottom, transparent, transparent, #00a6c0);
  335. transform: skew(-45deg);
  336. }
  337. &_iconE1 {
  338. right: 27px;
  339. }
  340. &_iconE2 {
  341. right: 7px;
  342. }
  343. }
  344. &_right {
  345. position: absolute;
  346. right: -10%;
  347. height: 100%;
  348. border-top: 2px solid @borderColor;
  349. border-left: 2px solid @borderColor;
  350. transform: skew(-45deg);
  351. background-color: @topTitleBgLeft;
  352. border-image: --webkit-linear-gradient(to right, @borderColor, transparent) 1;
  353. border-image: --moz-linear-gradient(to right, @borderColor, transparent) 1;
  354. border-image: linear-gradient(to right, @borderColor, transparent) 1;
  355. &_d1 {
  356. position: absolute;
  357. left: 10px;
  358. width: 50px;
  359. height: 20px;
  360. background-color: @borderColor64;
  361. }
  362. &_d2 {
  363. position: absolute;
  364. left: 70px;
  365. width: 80px;
  366. height: 10px;
  367. background-color: @borderColor32;
  368. }
  369. }
  370. &_topRight {
  371. position: absolute;
  372. top: 0;
  373. right: 0;
  374. display: flex;
  375. div:nth-child(1) {
  376. width: 5px;
  377. height: 2px;
  378. background-color: @borderColor;
  379. }
  380. div:nth-child(2) {
  381. margin: 0 1px;
  382. width: 5px;
  383. height: 2px;
  384. background-color: #f19b56;
  385. }
  386. div:nth-child(3) {
  387. width: 5px;
  388. height: 2px;
  389. background-color: @borderColor;
  390. }
  391. }
  392. }
  393. }
  394. // 公共样式
  395. .menuMainBox_topBottom {
  396. position: absolute;
  397. top: 20px;
  398. width: 38%;
  399. height: 20px;
  400. border-bottom: 2px solid @borderColor;
  401. border-right: 2px solid @borderColor;
  402. transform: skew(-45deg);
  403. border-image: --webkit-linear-gradient(to left, @borderColor, transparent) 1;
  404. border-image: --moz-linear-gradient(to left, @borderColor, transparent) 1;
  405. border-image: linear-gradient(to left, @borderColor, transparent) 1;
  406. z-index: 9999;
  407. div {
  408. position: absolute;
  409. top: -2px;
  410. right: -2px;
  411. width: 4px;
  412. height: 4px;
  413. border-radius: 4px;
  414. background-color: @borderColor;
  415. transform: skew(45deg);
  416. }
  417. }
  418. // type === chart
  419. .menuMainBox_topChart {
  420. width: 100%;
  421. height: 30px;
  422. position: relative;
  423. display: flex;
  424. align-items: center;
  425. flex-wrap: nowrap;
  426. justify-content: center;
  427. align-content: center;
  428. background-image: --webkit-linear-gradient(to left, @topTitleMinLeft, @borderColor, @topTitleMinLeft);
  429. background-image: --moz-linear-gradient(to left, @topTitleMinLeft, @borderColor, @topTitleMinLeft);
  430. background-image: linear-gradient(to left, @topTitleMinLeft, @borderColor, @topTitleMinLeft);
  431. &_title {
  432. font-size: 18px;
  433. font-family: PingFang SC;
  434. font-weight: 300;
  435. color: #e6e6e6;
  436. line-height: 60px;
  437. }
  438. }
  439. // 卡片主题
  440. .menuMainBox_main {
  441. position: relative;
  442. padding-top: 10px;
  443. width: 100%;
  444. height: calc(100% - 30px);
  445. background-image: --webkit-linear-gradient(to top, @topTitleMinLeft, @topTitleBgLeft);
  446. background-image: --moz-linear-gradient(to top, @topTitleMinLeft, @topTitleBgLeft);
  447. background-image: linear-gradient(to top, @topTitleMinLeft, @topTitleBgLeft);
  448. box-sizing: border-box;
  449. overflow-x: hidden;
  450. overflow-y: auto;
  451. scrollbar-width: none; /* Firefox */
  452. -ms-overflow-style: none; /* IE 10+ */
  453. &::-webkit-scrollbar {
  454. display: none; /* Chrome Safari */
  455. }
  456. &_top {
  457. margin: 0 10px;
  458. width: calc(100% - 20px);
  459. }
  460. &_bottom {
  461. margin: 0 10px;
  462. width: calc(100% - 20px);
  463. }
  464. &_all {
  465. margin: 0 10px;
  466. width: calc(100% - 20px);
  467. height: calc(100% - 10px);
  468. }
  469. &_image {
  470. margin: 0px 10px;
  471. width: calc(100% - 20px);
  472. height: 210px;
  473. background-size: 100% 200px;
  474. background-repeat: no-repeat;
  475. }
  476. }
  477. // 卡片主题
  478. .menuMainBox_main_image {
  479. position: relative;
  480. margin: 0;
  481. width: 100%;
  482. height: calc(100% - 30px);
  483. background-image: --webkit-linear-gradient(to top, @topTitleMinLeft, @topTitleBgLeft);
  484. background-image: --moz-linear-gradient(to top, @topTitleMinLeft, @topTitleBgLeft);
  485. background-image: linear-gradient(to top, @topTitleMinLeft, @topTitleBgLeft);
  486. &_box {
  487. width: 100%;
  488. height: 200px;
  489. background-size: 100% 200px;
  490. background-repeat: no-repeat;
  491. }
  492. }
  493. </style>