MenuCard.vue 38 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058
  1. <template>
  2. <!-- 外边框 -->
  3. <div
  4. ref="menuCard"
  5. v-loading="dataInitLoading"
  6. element-loading-spinner="el-icon-loading"
  7. element-loading-background="rgba(0, 0, 0, 0.8)"
  8. :class="$ifLeftMenu(menuData.title != undefined ? menuData.title : '') ? 'menuMainBoxA' : 'menuMainBox'"
  9. :style="{
  10. width: menuData.boxWidth ? menuData.boxWidth + 'px' : '410px',
  11. height: menuData.boxHeight ? menuData.boxHeight + 'px' : 'auto',
  12. border: menuData.type !== 'chart' && menuData.type !== 'legend' ? '' : '1px solid #2FB8FF',
  13. background: menuData.boxBackground ? menuData.boxBackground : ''
  14. }"
  15. @click="changeMenu()"
  16. >
  17. <!-- 头部 -->
  18. <div class="menuMainBox_top" v-if="menuData.type !== 'chart' && menuData.type !== 'legend'">
  19. <!-- 头部左侧 -->
  20. <div
  21. class="menuMainBox_top_left"
  22. :style="{
  23. width: menuData.titleWidth ? menuData.titleWidth + '%' : '50%'
  24. }"
  25. >
  26. <!-- 左侧箭头图标 -->
  27. <div class="menuMainBox_top_left_iconS" v-if="menuData.type !== 'imageMenu'"></div>
  28. <div class="menuMainBox_top_left_iconR" v-if="menuData.type === 'imageMenu'">
  29. <div
  30. class="menuMainBox_top_left_iconR_active"
  31. v-if="$ifLeftMenu(menuData.index != undefined ? menuData.title : '')"
  32. ></div>
  33. </div>
  34. <!-- 标题 -->
  35. <div class="menuMainBox_top_left_title">{{ menuData.title }}</div>
  36. <!-- 右侧倾斜图标1 -->
  37. <div class="menuMainBox_top_left_iconE menuMainBox_top_left_iconE1"></div>
  38. <!-- 右侧倾斜图标2 -->
  39. <div class="menuMainBox_top_left_iconE menuMainBox_top_left_iconE2"></div>
  40. </div>
  41. <!-- 右侧两个倾斜方框 -->
  42. <div
  43. class="menuMainBox_top_right"
  44. :style="{
  45. width: menuData.titleWidth ? 110 - menuData.titleWidth + '%' : '60%'
  46. }"
  47. >
  48. <!-- 方块1 -->
  49. <div class="menuMainBox_top_right_d1"></div>
  50. <!-- 方块2 -->
  51. <div class="menuMainBox_top_right_d2"></div>
  52. </div>
  53. <!-- 右上角三个点(蓝橙蓝) -->
  54. <div class="menuMainBox_top_topRight">
  55. <div></div>
  56. <div></div>
  57. <div></div>
  58. </div>
  59. </div>
  60. <!-- 头部下的折线 -->
  61. <div
  62. class="menuMainBox_topBottom"
  63. v-if="menuData.type !== 'chart' && menuData.type !== 'legend'"
  64. :style="{
  65. left: menuData.titleWidth
  66. ? (menuData.titleWidth <= 40 ? menuData.titleWidth - 39 : menuData.titleWidth - 40) + '%'
  67. : '10%'
  68. }"
  69. >
  70. <!-- 折线右上角圆球 -->
  71. <div></div>
  72. </div>
  73. <div class="menuMainBox_topChart" v-if="menuData.type === 'chart' || menuData.type === 'legend'">
  74. <div class="menuMainBox_topChart_title">
  75. {{ menuData.title }}
  76. </div>
  77. </div>
  78. <!-- -------------------------------------------------主题------------------------------------------ -->
  79. <div class="menuMainBox_main" v-if="menuData.type === 'card'">
  80. <!-- 上部 -->
  81. <div class="menuMainBox_main_top" v-if="!menuData.topSolt">
  82. <slot name="top"> </slot>
  83. <TopCard v-if="menuData.commonName == 'TOP'" :dataList="menuData.topData" :columnName="menuData.field" />
  84. </div>
  85. <div class="menuMainBox_main_top" v-if="menuData.topSolt">
  86. <TagTableCard
  87. v-if="menuData.topSolt.commonName == 'TagTableCard'"
  88. :echartData="menuData.topSolt.commonData"
  89. @changeMousemoveIndex="changeMousemoveIndex"
  90. />
  91. <div
  92. class="menuCardFlex"
  93. v-if="menuData.topSolt.commonName == 'TagCard'"
  94. :style="{
  95. justifyContent: menuData.topSolt.commonData.length > 1 ? 'space-between' : 'center'
  96. }"
  97. >
  98. <TagCard
  99. v-for="(item, index) in menuData.topSolt.commonData"
  100. :data="item"
  101. :index="index"
  102. :chartCardDataIndex="chartCardDataIndex"
  103. :key="item.title"
  104. @changeMousemoveIndex="changeMousemoveIndex"
  105. />
  106. </div>
  107. </div>
  108. <!-- 下部 -->
  109. <div class="menuMainBox_main_bottom" v-if="!menuData.bottomSolt">
  110. <slot name="bottom"></slot>
  111. </div>
  112. <div class="menuMainBox_main_bottom" v-if="menuData.bottomSolt">
  113. <ChartCard
  114. v-if="menuData.bottomSolt.commonName == 'ChartCard'"
  115. :title="menuData.topSolt.commonData[chartCardDataIndex].title"
  116. :categoryData="menuData.topSolt.commonData[chartCardDataIndex].categoryData"
  117. :valueData="menuData.topSolt.commonData[chartCardDataIndex].valueData"
  118. :unit="menuData.topSolt.commonData[chartCardDataIndex].unit"
  119. />
  120. </div>
  121. </div>
  122. <div class="menuMainBox_main" v-if="menuData.type === 'chart' || menuData.type === 'legend'">
  123. <div class="menuMainBox_main_all" v-if="!menuData.topSolt && !menuData.bottomSolt">
  124. <slot></slot>
  125. </div>
  126. </div>
  127. <div class="menuMainBox_main_image" v-if="menuData.type === 'imageMenu'">
  128. <div class="menuMainBox_main_image_box" :style="returnImageUrl(menuData.imageUrl, menuData.boxHeight)"></div>
  129. </div>
  130. <!-- 图例属性显示区域 -->
  131. <div v-if="menuData.type === 'legend'" class="legend"></div>
  132. </div>
  133. </template>
  134. <script>
  135. /**
  136. * 模块通用组件(首页和其他页面都有用到,由于综合功能和适配场景较多,配置组合可以联系开发人员:LiuMengxiang)
  137. * @author: LiuMengxiang
  138. * @Date: 2022年11月14-18日
  139. */
  140. import TagTableCard from "@/components/common/TagTableCard.vue";
  141. import ChartCard from "@/components/common/ChartCard.vue";
  142. import TagCard from "@/components/common/TagCard.vue";
  143. import TopCard from "@/components/common/TopCard.vue";
  144. export default {
  145. name: "menuCard",
  146. components: { TagTableCard, ChartCard, TagCard, TopCard },
  147. data() {
  148. return {
  149. dataInitLoading: false,
  150. resData: [],
  151. chartCardDataIndex: 0
  152. };
  153. },
  154. mounted() {
  155. this.$nextTick(() => {
  156. if (this.menuData && this.menuData.topSolt && this.menuData.topSolt.commonDataGetUrl) {
  157. this.dataInitLoading = true;
  158. this.$Get("/static/json/home/" + this.menuData.topSolt.commonDataGetUrl).then(
  159. res => {
  160. let listMap = {};
  161. let tableData = res;
  162. tableData.forEach(item => {
  163. if (!listMap[item.name]) {
  164. // type,data
  165. let listMap2 = {};
  166. if (item.data) {
  167. item.data.forEach(item2 => {
  168. if (listMap2[item2.type]) {
  169. listMap2[item2.type]["categoryData"].push(item2.year);
  170. listMap2[item2.type]["valueData"].push(item2.area);
  171. } else {
  172. let listMapItem = {};
  173. listMapItem["categoryData"] = [item2.year];
  174. listMapItem["valueData"] = [item2.area];
  175. listMap2[item2.type] = listMapItem;
  176. }
  177. });
  178. }
  179. listMap[item.name] = listMap2;
  180. } else {
  181. console.error("json文件内容重复,重复街镇:", item.name);
  182. }
  183. });
  184. if (listMap) {
  185. let categoryData = [];
  186. for (let listMapKeys in listMap) {
  187. // type,data
  188. categoryData = listMap[listMapKeys];
  189. if (categoryData) {
  190. if (!listMap["全部"]) {
  191. listMap["全部"] = {};
  192. }
  193. for (let categoryDataKeys in categoryData) {
  194. if (categoryData[categoryDataKeys]) {
  195. let categoryDataItemData = categoryData[categoryDataKeys];
  196. if (listMap["全部"][categoryDataKeys]) {
  197. categoryDataItemData.valueData.forEach((valueIndexItem, index) => {
  198. if (listMap["全部"][categoryDataKeys].valueData[index]) {
  199. listMap["全部"][categoryDataKeys].valueData[index] += Number(valueIndexItem);
  200. } else {
  201. listMap["全部"][categoryDataKeys].valueData[index] = Number(valueIndexItem);
  202. }
  203. });
  204. } else {
  205. listMap["全部"][categoryDataKeys] = categoryDataItemData;
  206. }
  207. }
  208. }
  209. }
  210. }
  211. }
  212. this.resData = listMap;
  213. if (this.resData["全部"]) {
  214. let _index = 0;
  215. let sum = 0;
  216. for (let keys in this.resData["全部"]) {
  217. this.menuData.topSolt.commonData[_index].title = keys;
  218. this.menuData.topSolt.commonData[_index].categoryData = this.resData["全部"][keys].categoryData;
  219. this.menuData.topSolt.commonData[_index].valueData = this.resData["全部"][keys].valueData;
  220. this.menuData.topSolt.commonData[_index].value =
  221. this.resData["全部"][keys].valueData[this.resData["全部"][keys].valueData.length - 1];
  222. sum += this.menuData.topSolt.commonData[_index].value;
  223. _index++;
  224. }
  225. if (this.menuData.topSolt.commonData[4]) {
  226. this.menuData.topSolt.commonData[4].valueData = [sum];
  227. }
  228. }
  229. this.dataInitLoading = false;
  230. },
  231. error => {
  232. console.log("error:", error, this.menuData);
  233. this.dataInitLoading = false;
  234. }
  235. );
  236. } else if (this.menuData && this.menuData.columnId && this.menuData.commonName !== "SUM") {
  237. this.dataInitLoading = true;
  238. let params = new FormData();
  239. params.append("columnId", this.menuData.columnId);
  240. if (this.menuData.field) {
  241. params.append("field", this.menuData.field);
  242. }
  243. params.append("states", "2,3");
  244. params.append("pageSize", this.menuData.pageSize ? this.menuData.pageSize : 999);
  245. params.append("page", 0);
  246. if (this.menuData.paramJson) {
  247. params.append("paramJson", JSON.stringify(this.menuData.paramJson));
  248. }
  249. if (this.menuData.sortField) {
  250. let sortparam = [
  251. {
  252. field: this.menuData.sortField.field,
  253. orderByType: this.menuData.sortField.orderByType
  254. }
  255. ];
  256. params.append("orderBy", JSON.stringify(sortparam));
  257. }
  258. this.$Post(this.menuData.getUrl ? this.menuData.getUrl : this.urlsCollection.selectContentList, params).then(
  259. res => {
  260. if (this.menuData.commonName && this.menuData.commonName === "TOP" && res.code === 200 && res.content.length > 0) {
  261. res.content.forEach((item, index) => {
  262. if (this.menuData.dataSize > index) {
  263. this.resData[index] = item;
  264. }
  265. });
  266. this.changeHomeSpecialTown();
  267. } else if (res.code === 200 && res.content.data && res.content.data.length > 0) {
  268. let listMap = {};
  269. let tableData = res.content.data;
  270. tableData.forEach(item => {
  271. if (listMap[item.street]) {
  272. listMap[item.street]["categoryData"].push(item.c_years);
  273. listMap[item.street]["valueData"].push((item.c_float_num / 10000).toFixed(2));
  274. } else {
  275. let listMapItem = {};
  276. listMapItem["categoryData"] = [item.c_years];
  277. listMapItem["valueData"] = [(item.c_float_num / 10000).toFixed(2)];
  278. listMap[item.street] = listMapItem;
  279. }
  280. });
  281. if (listMap) {
  282. let categoryData = [];
  283. for (let listMapKeys in listMap) {
  284. categoryData = listMap[listMapKeys].categoryData;
  285. if (listMap[listMapKeys].valueData) {
  286. if (!listMap["全部"]) {
  287. listMap["全部"] = { valueData: [], categoryData: [] };
  288. }
  289. listMap[listMapKeys].valueData.forEach((valueIndexItem, index) => {
  290. if (listMap["全部"].valueData[index]) {
  291. listMap["全部"].valueData[index] += Number(valueIndexItem);
  292. } else {
  293. listMap["全部"].valueData[index] = Number(valueIndexItem);
  294. }
  295. });
  296. }
  297. }
  298. if (listMap["全部"].categoryData.length == 0 && categoryData.length > 0) {
  299. listMap["全部"].categoryData = categoryData;
  300. }
  301. }
  302. if (listMap["全部"] && listMap["全部"].valueData) {
  303. listMap["全部"].valueData.forEach((item, index) => {
  304. listMap["全部"].valueData[index] = item.toFixed(2);
  305. });
  306. }
  307. this.resData = listMap;
  308. this.changeHomeSpecialTown();
  309. } else {
  310. this.resData = [];
  311. this.changeHomeSpecialTown();
  312. }
  313. this.dataInitLoading = false;
  314. },
  315. error => {
  316. this.resData = [];
  317. this.changeHomeSpecialTown();
  318. console.log("error:", error, this.menuData);
  319. this.dataInitLoading = false;
  320. }
  321. );
  322. } else if (this.menuData.commonName && this.menuData.commonName === "SUM") {
  323. this.sumData();
  324. }
  325. // 只有第一次创建该页面,或刷新页面时。
  326. if (this.menuData.menuIndex) {
  327. if (this.$ifMenu(this.menuData.menuIndex, this.menuData.subMenuIndex)) {
  328. // 立即修改display为block
  329. this.$refs.menuCard.style.display = "block";
  330. setTimeout(() => {
  331. this.$refs.menuCard.style.transform = "translate(0,0)";
  332. this.$refs.menuCard.style.opacity = "0.9";
  333. });
  334. } else {
  335. // 如果不符合,页面创建时就直接隐藏
  336. this.$refs.menuCard.style.display = "none";
  337. }
  338. }
  339. // 当容器创建完成时,监听窗口改变大小时间
  340. this.$bus.$off("windowOnresize");
  341. this.$bus.$on("windowOnresize", this.windowOnresize);
  342. });
  343. },
  344. destroy() {
  345. // 当容器销毁时,需要停止监听该事件
  346. this.$bus.$off("windowOnresize");
  347. },
  348. /**
  349. * 公共card组件,接收参数如下:
  350. * menuData =>
  351. * type: 类型【card:卡片;chart:echart组件;imageMenu:图片菜单;legend:图例】(必填)
  352. * title: 标题(必填)
  353. *
  354. * getUrl: DMS数据请求路径
  355. * columnId:DMS数据请求columnId
  356. * pageSize:DMS数据请求个数
  357. * field:DMS数据请求field
  358. * sortField=>:DMS数据请求排序配置
  359. * field:排序字段
  360. * orderByType:排序类型【1:正序,2:倒序】
  361. *
  362. * index: 子菜单index(只有当type为imageMenu时有效)(只有type为imageMenu时为必填)
  363. * imageUrl: 菜单图片地址(只有当type为imageMenu时有效)(只有type为imageMenu时为必填)
  364. *
  365. * menuIndex: 显示头部菜单对应index(显示隐藏优化,组合属性)
  366. * subMenuIndex: 显示头部菜单对应subIndex(显示隐藏优化,组合属性)
  367. * minDomWidth: 最小屏幕宽度自动隐藏【单位:Number】(显示隐藏优化,组合属性)
  368. * position: 动画位置【left\right\top\bottom】(显示隐藏优化,组合属性)
  369. *
  370. * boxWidth: 宽,默认为410px【单位:Number】(非必填)
  371. * boxHeight: 高,默认为auto【单位:Number】(非必填)
  372. * boxBackground: 背景色,默认为渐变蓝色【支持#\rgba】(非必填)
  373. * titleWidth: 标题宽度,默认为50【单位:%】(非必填)
  374. * gotoPageInfo: 动态跳转页面信息(非必填)=>{index:要跳转的菜单index,subIndex:要跳转的子菜单index,name:菜单名称}
  375. *
  376. * topSolt: 头部替换插槽组件信息(非必填)=>{commonName:组件名称,commonData:组件支撑数据,commonDataGetUrl:本地静态数据文件名,columnId:DMS远程数据columnId}
  377. * bottomSolt: 底部替换插槽组件信息(非必填)=>{commonName:组件名称,commonData:组件支撑数据}
  378. *
  379. */
  380. props: ["menuData"],
  381. methods: {
  382. sumData() {
  383. this.dataInitLoading = true;
  384. let params = new FormData();
  385. params.append("columnId", this.menuData.columnId);
  386. if (this.menuData.field) {
  387. params.append("field", this.menuData.field);
  388. }
  389. params.append("states", "2,3");
  390. params.append("pageSize", this.menuData.pageSize ? this.menuData.pageSize : 999);
  391. params.append("page", 0);
  392. if (this.menuData.paramJson) {
  393. if (this.menuData.categoryData) {
  394. let pramJson = {};
  395. this.menuData.categoryData.forEach((item,_index) => {
  396. pramJson.c_new_date = item;
  397. pramJson.sj_select = this.menuData.paramJson.sj_select;
  398. params.append("paramJson", JSON.stringify(pramJson));
  399. if (this.menuData.sortField) {
  400. let sortparam = [
  401. {
  402. field: this.menuData.sortField.field,
  403. orderByType: this.menuData.sortField.orderByType
  404. }
  405. ];
  406. params.append("orderBy", JSON.stringify(sortparam));
  407. }
  408. this.$Post(this.menuData.getUrl ? this.menuData.getUrl : this.urlsCollection.selectContentList, params).then(
  409. res => {
  410. if (res.code === 200 && res.content.length > 0) {
  411. this.menuData.topSolt.commonData[0].categoryData[_index] = item;
  412. let sumField = 0;
  413. res.content.forEach(contentItem => {
  414. sumField += Number(contentItem.number);
  415. });
  416. this.menuData.topSolt.commonData[0].valueData[_index] = sumField;
  417. } else {
  418. this.menuData.topSolt.commonData[0].categoryData = [];
  419. this.menuData.topSolt.commonData[0].valueData = [];
  420. }
  421. this.dataInitLoading = false;
  422. },
  423. error => {
  424. this.menuData.topSolt.commonData[0].categoryData = [];
  425. this.menuData.topSolt.commonData[0].valueData = [];
  426. console.log("error:", error, this.menuData);
  427. this.dataInitLoading = false;
  428. }
  429. );
  430. });
  431. }
  432. }
  433. },
  434. // 切换街镇时
  435. changeHomeSpecialTown() {
  436. if (this.resData[this.$store.state.homeSpecialTown] && this.menuData.topSolt.commonData) {
  437. if (this.resData[this.$store.state.homeSpecialTown].categoryData) {
  438. this.menuData.topSolt.commonData[0].categoryData = this.resData[this.$store.state.homeSpecialTown].categoryData;
  439. this.menuData.topSolt.commonData[0].valueData = this.resData[this.$store.state.homeSpecialTown].valueData;
  440. } else {
  441. let _index = 0;
  442. let sum = 0;
  443. for (let keys in this.resData["全部"]) {
  444. this.menuData.topSolt.commonData[_index].title = keys;
  445. this.menuData.topSolt.commonData[_index].categoryData =
  446. this.resData[this.$store.state.homeSpecialTown][keys].categoryData;
  447. this.menuData.topSolt.commonData[_index].valueData =
  448. this.resData[this.$store.state.homeSpecialTown][keys].valueData;
  449. this.menuData.topSolt.commonData[_index].value =
  450. this.resData[this.$store.state.homeSpecialTown][keys].valueData[
  451. this.resData[this.$store.state.homeSpecialTown][keys].valueData.length - 1
  452. ];
  453. sum += this.menuData.topSolt.commonData[_index].value;
  454. _index++;
  455. }
  456. if (this.menuData.topSolt.commonData[4]) {
  457. this.menuData.topSolt.commonData[4].valueData = [sum];
  458. }
  459. }
  460. } else if (this.menuData && this.menuData.topSolt && this.menuData.topSolt.commonData) {
  461. this.menuData.topSolt.commonData.forEach((item, index) => {
  462. this.menuData.topSolt.commonData[index].categoryData = [];
  463. this.menuData.topSolt.commonData[index].valueData = [];
  464. if (this.menuData.topSolt.commonData[index].valueData) {
  465. this.menuData.topSolt.commonData[index].valueData = 0;
  466. }
  467. if (this.menuData.topSolt.commonData[index].value) {
  468. this.menuData.topSolt.commonData[index].value = 0;
  469. }
  470. });
  471. } else if (this.menuData && this.menuData.commonName && this.menuData.commonName === "TOP") {
  472. this.menuData.topData = this.resData;
  473. } else if (this.menuData && this.menuData.commonName && this.menuData.commonName === "SUM") {
  474. this.sumData(this.$store.state.homeSpecialTown);
  475. }
  476. },
  477. // 当用户使用光标切换交互组件时触发
  478. changeMousemoveIndex(index) {
  479. if (this.chartCardDataIndex != index) {
  480. this.chartCardDataIndex = index;
  481. }
  482. },
  483. // 用户点击菜单标题时,调用全局函数,根据全局暂存对象
  484. changeMenu() {
  485. if (this.menuData != undefined && this.menuData.index != undefined && this.menuData.title != undefined) {
  486. this.$store.commit("changeLeftMenuTitle", this.menuData.title);
  487. if (this.menuData.menuIndex != undefined && this.menuData.subMenuIndex != undefined) {
  488. this.$store.commit("changeBackMenu", {
  489. index: this.menuData.menuIndex,
  490. subIndex: this.menuData.subMenuIndex,
  491. name: this.menuData.menuName ? this.menuData.menuName : ""
  492. });
  493. }
  494. }
  495. if (this.menuData != undefined && this.menuData.gotoPageInfo != undefined) {
  496. this.$store.commit("changeNavSelect", this.menuData.gotoPageInfo);
  497. // // 暂未开发页面集合
  498. // let notFound = [
  499. // { index: "2", subIndex: "2" },
  500. // { index: "2", subIndex: "3" }
  501. // ];
  502. // // 是否跳转暂存变量
  503. // let notFoundState = true;
  504. // // 遍历未开发页面index信息
  505. // notFound.forEach(item => {
  506. // // 如果要跳转的页面存在未开发页面集合中
  507. // if (item.index == this.menuData.gotoPageInfo.index && item.subIndex == this.menuData.gotoPageInfo.subIndex) {
  508. // this.$message.info("页面开发中,敬请期待!");
  509. // notFoundState = false;
  510. // }
  511. // });
  512. // if (notFoundState) {
  513. // this.$store.commit("changeNavSelect", this.menuData.gotoPageInfo);
  514. // }
  515. }
  516. },
  517. // 根据菜单imageURL和boxHeight对象自动生成元素的样式(背景以及高度)
  518. returnImageUrl(imageUrl, boxHeight) {
  519. let returnStyle = "";
  520. if (boxHeight) {
  521. returnStyle += "heihgt:" + (boxHeight - 36) + "px;";
  522. }
  523. returnStyle += "background-image: url('" + imageUrl + "');";
  524. return returnStyle;
  525. },
  526. // 组件显示隐藏时,动画样式返回。
  527. showChange() {
  528. if (this.menuData != undefined && this.menuData.menuIndex != undefined) {
  529. if (this.$ifMenu(this.menuData.menuIndex, this.menuData.subMenuIndex)) {
  530. // 立即修改display为block
  531. this.$refs.menuCard.style.display = "block";
  532. this.$refs.menuCard.style.opacity = "0";
  533. setTimeout(() => {
  534. this.$refs.menuCard.style.transform = "translate(0,0)";
  535. this.$refs.menuCard.style.opacity = "0.9";
  536. }, 300);
  537. } else {
  538. // 延迟0.3s后修改display为none
  539. this.$refs.menuCard.style.transform = this.positionTotransform();
  540. this.$refs.menuCard.style.opacity = "0";
  541. setTimeout(() => {
  542. this.$refs.menuCard.style.display = "none";
  543. }, 300);
  544. }
  545. }
  546. },
  547. // 根据组件定位,返回不同的显示隐藏动画位置
  548. positionTotransform() {
  549. switch (this.menuData.position) {
  550. case "left":
  551. return "translate(-50%,0)";
  552. case "right":
  553. return "translate(50%,0)";
  554. case "top":
  555. return "translate(0,-50%)";
  556. case "bottom":
  557. return "translate(0,50%)";
  558. default:
  559. return "translate(0,0)";
  560. }
  561. },
  562. windowOnresize(windowClient) {
  563. // console.log("windowOnresize", windowClient);
  564. try {
  565. if (
  566. windowClient.windowsWidth != undefined &&
  567. this.$ifMenu(this.menuData.menuIndex, this.menuData.subMenuIndex) &&
  568. this.menuData.minDomWidth != null
  569. ) {
  570. if (
  571. this.menuData.minDomWidth < windowClient.windowsWidth &&
  572. this.$refs.menuCard != undefined &&
  573. this.$refs.menuCard.style.display == "none"
  574. ) {
  575. // 立即修改display为block
  576. this.$refs.menuCard.style.display = "block";
  577. setTimeout(() => {
  578. this.$refs.menuCard.style.transform = "translate(0,0)";
  579. this.$refs.menuCard.style.opacity = "0.9";
  580. }, 300);
  581. } else if (
  582. this.menuData.minDomWidth > windowClient.windowsWidth &&
  583. this.$refs.menuCard != undefined &&
  584. this.$refs.menuCard.style.display == "block"
  585. ) {
  586. // 延迟0.3s后修改display为none
  587. this.$refs.menuCard.style.transform = this.positionTotransform();
  588. this.$refs.menuCard.style.opacity = "0";
  589. setTimeout(() => {
  590. this.$refs.menuCard.style.display = "none";
  591. }, 300);
  592. }
  593. }
  594. } catch (error) {
  595. console.error("MenuCard组件出现异常:", error);
  596. }
  597. }
  598. },
  599. watch: {
  600. "$store.state.navSelect": {
  601. handler() {
  602. this.$nextTick(() => {
  603. this.showChange();
  604. });
  605. },
  606. deep: true
  607. },
  608. "$store.state.homeSpecialTown": {
  609. handler() {
  610. this.$nextTick(() => {
  611. this.changeHomeSpecialTown();
  612. });
  613. },
  614. deep: true
  615. }
  616. }
  617. };
  618. </script>
  619. <style lang="less" scoped>
  620. @borderColor: #00aaff;
  621. @borderColor32: #00aaff32;
  622. @borderColor64: #00aaff64;
  623. @topTitleBgLeft: #002645;
  624. @topTitleMinLeft: #002f56;
  625. @lightColor: #74ffff;
  626. .menuMainBox,
  627. .menuMainBoxA {
  628. transition: all 0.3s;
  629. }
  630. .menuMainBox {
  631. position: relative;
  632. z-index: 999;
  633. margin: 10px 5px;
  634. min-height: 60px;
  635. border: 2px solid transparent;
  636. border-image: --webkit-linear-gradient(to top, @borderColor, transparent) 1;
  637. border-image: --moz-linear-gradient(to top, @borderColor, transparent) 1;
  638. border-image: linear-gradient(to top, @borderColor, transparent) 1;
  639. &:hover {
  640. border-image: --webkit-linear-gradient(to top, @lightColor, transparent) 1;
  641. border-image: --moz-linear-gradient(to top, @lightColor, transparent) 1;
  642. border-image: linear-gradient(to top, @lightColor, transparent) 1;
  643. .menuMainBox_top {
  644. background-color: @lightColor;
  645. &_left {
  646. background-image: --webkit-linear-gradient(to left, @lightColor, #007dff);
  647. background-image: --moz-linear-gradient(to left, @lightColor, #007dff);
  648. background-image: linear-gradient(to left, @lightColor, #007dff);
  649. }
  650. }
  651. }
  652. cursor: pointer;
  653. -moz-user-select: none;
  654. -webkit-user-select: none;
  655. -ms-user-select: none;
  656. -khtml-user-select: none;
  657. user-select: none;
  658. // type !== chart
  659. &_top {
  660. position: relative;
  661. width: 100%;
  662. height: 36px;
  663. display: flex;
  664. align-items: center;
  665. flex-wrap: nowrap;
  666. align-content: center;
  667. overflow: hidden;
  668. background-color: @topTitleMinLeft;
  669. &_left {
  670. position: relative;
  671. display: flex;
  672. align-items: center;
  673. flex-wrap: nowrap;
  674. align-content: center;
  675. height: 100%;
  676. background-image: --webkit-linear-gradient(to left, @topTitleMinLeft, @borderColor, @topTitleMinLeft);
  677. background-image: --moz-linear-gradient(to left, @topTitleMinLeft, @borderColor, @topTitleMinLeft);
  678. background-image: linear-gradient(to left, @topTitleMinLeft, @borderColor, @topTitleMinLeft);
  679. border-bottom: 2px solid @borderColor;
  680. &_iconS {
  681. margin: 10px;
  682. width: 20px;
  683. height: 20px;
  684. background-image: linear-gradient(to top, #0071b2, #1deef5);
  685. clip-path: polygon(0 0, 100% 50%, 0 100%, 30% 50%, 0 0);
  686. }
  687. &_iconR {
  688. position: relative;
  689. margin: 15px;
  690. width: 10px;
  691. height: 10px;
  692. background-image: transparent;
  693. border: 1px solid #1deef5;
  694. border-radius: 20px;
  695. &_active {
  696. position: absolute;
  697. transform: translate(-50%, -50%);
  698. top: 50%;
  699. left: 50%;
  700. width: 5px;
  701. height: 5px;
  702. background-color: #1deef5;
  703. border-radius: 20px;
  704. }
  705. }
  706. &_title {
  707. font-size: 28px;
  708. font-family: YouSheBiaoTiHei;
  709. font-weight: 400;
  710. color: #ffffff;
  711. }
  712. &_iconE {
  713. position: absolute;
  714. margin-left: 10px;
  715. width: 15px;
  716. height: 30px;
  717. background-image: linear-gradient(to bottom, transparent, transparent, #00a6c0);
  718. transform: skew(-45deg);
  719. }
  720. &_iconE1 {
  721. right: 27px;
  722. }
  723. &_iconE2 {
  724. right: 7px;
  725. }
  726. }
  727. &_right {
  728. position: absolute;
  729. right: -10%;
  730. height: 100%;
  731. border-top: 2px solid @borderColor;
  732. border-left: 2px solid @borderColor;
  733. transform: skew(-45deg);
  734. background-color: @topTitleBgLeft;
  735. border-image: --webkit-linear-gradient(to right, @borderColor, @topTitleBgLeft) 1;
  736. border-image: --moz-linear-gradient(to right, @borderColor, @topTitleBgLeft) 1;
  737. border-image: linear-gradient(to right, @borderColor, @topTitleBgLeft) 1;
  738. &_d1 {
  739. position: absolute;
  740. left: 10px;
  741. width: 50px;
  742. height: 20px;
  743. background-color: @borderColor64;
  744. }
  745. &_d2 {
  746. position: absolute;
  747. left: 70px;
  748. width: 80px;
  749. height: 10px;
  750. background-color: @borderColor32;
  751. }
  752. }
  753. &_topRight {
  754. position: absolute;
  755. top: 0;
  756. right: 0;
  757. display: flex;
  758. div:nth-child(1) {
  759. width: 5px;
  760. height: 2px;
  761. background-color: @borderColor;
  762. }
  763. div:nth-child(2) {
  764. margin: 0 1px;
  765. width: 5px;
  766. height: 2px;
  767. background-color: #f19b56;
  768. }
  769. div:nth-child(3) {
  770. width: 5px;
  771. height: 2px;
  772. background-color: @borderColor;
  773. }
  774. }
  775. }
  776. &:hover {
  777. .menuMainBox_main_image_box {
  778. background-size: 110% 220px;
  779. }
  780. }
  781. }
  782. // 选中后的样式
  783. .menuMainBoxA {
  784. position: relative;
  785. z-index: 999;
  786. margin: 10px 5px;
  787. min-height: 60px;
  788. border: 2px solid transparent;
  789. border-image: --webkit-linear-gradient(to top, @lightColor, transparent) 1;
  790. border-image: --moz-linear-gradient(to top, @lightColor, transparent) 1;
  791. border-image: linear-gradient(to top, @lightColor, transparent) 1;
  792. cursor: pointer;
  793. -moz-user-select: none;
  794. -webkit-user-select: none;
  795. -ms-user-select: none;
  796. -khtml-user-select: none;
  797. user-select: none;
  798. // type !== chart
  799. .menuMainBox_top {
  800. position: relative;
  801. width: 100%;
  802. height: 36px;
  803. display: flex;
  804. align-items: center;
  805. flex-wrap: nowrap;
  806. align-content: center;
  807. overflow: hidden;
  808. background-color: @lightColor;
  809. &_left {
  810. position: relative;
  811. display: flex;
  812. align-items: center;
  813. flex-wrap: nowrap;
  814. align-content: center;
  815. height: 100%;
  816. border-bottom: 2px solid @borderColor;
  817. background-image: --webkit-linear-gradient(to left, @lightColor, #007dff);
  818. background-image: --moz-linear-gradient(to left, @lightColor, #007dff);
  819. background-image: linear-gradient(to left, @lightColor, #007dff);
  820. &_iconS {
  821. margin: 10px;
  822. width: 20px;
  823. height: 20px;
  824. background-image: linear-gradient(to top, #0071b2, #1deef5);
  825. clip-path: polygon(0 0, 100% 50%, 0 100%, 30% 50%, 0 0);
  826. }
  827. &_iconR {
  828. position: relative;
  829. margin: 15px;
  830. width: 10px;
  831. height: 10px;
  832. background-image: transparent;
  833. border: 1px solid #1deef5;
  834. border-radius: 20px;
  835. &_active {
  836. position: absolute;
  837. transform: translate(-50%, -50%);
  838. top: 50%;
  839. left: 50%;
  840. width: 5px;
  841. height: 5px;
  842. background-color: #1deef5;
  843. border-radius: 20px;
  844. }
  845. }
  846. &_title {
  847. font-size: 28px;
  848. font-family: YouSheBiaoTiHei;
  849. font-weight: 400;
  850. color: #ffffff;
  851. }
  852. &_iconE {
  853. position: absolute;
  854. margin-left: 10px;
  855. width: 15px;
  856. height: 30px;
  857. background-image: linear-gradient(to bottom, transparent, transparent, #00a6c0);
  858. transform: skew(-45deg);
  859. }
  860. &_iconE1 {
  861. right: 27px;
  862. }
  863. &_iconE2 {
  864. right: 7px;
  865. }
  866. }
  867. &_right {
  868. position: absolute;
  869. right: -10%;
  870. height: 100%;
  871. border-top: 2px solid @borderColor;
  872. border-left: 2px solid @borderColor;
  873. transform: skew(-45deg);
  874. background-color: @topTitleBgLeft;
  875. border-image: --webkit-linear-gradient(to right, @borderColor, @topTitleBgLeft) 1;
  876. border-image: --moz-linear-gradient(to right, @borderColor, @topTitleBgLeft) 1;
  877. border-image: linear-gradient(to right, @borderColor, @topTitleBgLeft) 1;
  878. &_d1 {
  879. position: absolute;
  880. left: 10px;
  881. width: 50px;
  882. height: 20px;
  883. background-color: @borderColor64;
  884. }
  885. &_d2 {
  886. position: absolute;
  887. left: 70px;
  888. width: 80px;
  889. height: 10px;
  890. background-color: @borderColor32;
  891. }
  892. }
  893. &_topRight {
  894. position: absolute;
  895. top: 0;
  896. right: 0;
  897. display: flex;
  898. div:nth-child(1) {
  899. width: 5px;
  900. height: 2px;
  901. background-color: @borderColor;
  902. }
  903. div:nth-child(2) {
  904. margin: 0 1px;
  905. width: 5px;
  906. height: 2px;
  907. background-color: #f19b56;
  908. }
  909. div:nth-child(3) {
  910. width: 5px;
  911. height: 2px;
  912. background-color: @borderColor;
  913. }
  914. }
  915. }
  916. &:hover {
  917. .menuMainBox_main_image_box {
  918. background-size: 110% 220px;
  919. }
  920. }
  921. }
  922. // 公共样式
  923. .menuMainBox_topBottom {
  924. position: absolute;
  925. top: 20px;
  926. width: 38%;
  927. height: 20px;
  928. border-bottom: 2px solid @borderColor;
  929. border-right: 2px solid @borderColor;
  930. transform: skew(-45deg);
  931. border-image: --webkit-linear-gradient(to left, @borderColor, transparent) 1;
  932. border-image: --moz-linear-gradient(to left, @borderColor, transparent) 1;
  933. border-image: linear-gradient(to left, @borderColor, transparent) 1;
  934. z-index: 9999;
  935. div {
  936. position: absolute;
  937. top: -2px;
  938. right: -2px;
  939. width: 4px;
  940. height: 4px;
  941. border-radius: 4px;
  942. background-color: @borderColor;
  943. transform: skew(45deg);
  944. }
  945. }
  946. // type === chart
  947. .menuMainBox_topChart {
  948. width: 100%;
  949. height: 30px;
  950. position: relative;
  951. display: flex;
  952. align-items: center;
  953. flex-wrap: nowrap;
  954. justify-content: center;
  955. align-content: center;
  956. background-image: --webkit-linear-gradient(to left, @topTitleMinLeft, @borderColor, @topTitleMinLeft);
  957. background-image: --moz-linear-gradient(to left, @topTitleMinLeft, @borderColor, @topTitleMinLeft);
  958. background-image: linear-gradient(to left, @topTitleMinLeft, @borderColor, @topTitleMinLeft);
  959. &_title {
  960. font-size: 18px;
  961. font-family: PingFang SC;
  962. font-weight: 300;
  963. color: #e6e6e6;
  964. line-height: 60px;
  965. }
  966. }
  967. // 卡片主题
  968. .menuMainBox_main {
  969. position: relative;
  970. padding-top: 10px;
  971. width: 100%;
  972. height: calc(100% - 30px);
  973. background-image: --webkit-linear-gradient(to top, @topTitleMinLeft, @topTitleBgLeft);
  974. background-image: --moz-linear-gradient(to top, @topTitleMinLeft, @topTitleBgLeft);
  975. background-image: linear-gradient(to top, @topTitleMinLeft, @topTitleBgLeft);
  976. box-sizing: border-box;
  977. overflow-x: hidden;
  978. overflow-y: auto;
  979. scrollbar-width: none; /* Firefox */
  980. -ms-overflow-style: none; /* IE 10+ */
  981. &::-webkit-scrollbar {
  982. display: none; /* Chrome Safari */
  983. }
  984. &_top {
  985. margin: 0 10px;
  986. width: calc(100% - 20px);
  987. }
  988. &_bottom {
  989. margin: 0 10px;
  990. width: calc(100% - 20px);
  991. }
  992. &_all {
  993. margin: 0 10px;
  994. width: calc(100% - 20px);
  995. height: calc(100% - 10px);
  996. }
  997. &_image {
  998. margin: 0px 10px;
  999. width: calc(100% - 20px);
  1000. height: 210px;
  1001. background-size: 100% 200px;
  1002. background-repeat: no-repeat;
  1003. }
  1004. }
  1005. // 卡片主题
  1006. .menuMainBox_main_image {
  1007. position: relative;
  1008. margin: 0;
  1009. width: 100%;
  1010. height: calc(100% - 30px);
  1011. &_box {
  1012. width: 100%;
  1013. height: 200px;
  1014. background-size: 100% 200px;
  1015. background-repeat: no-repeat;
  1016. transition: all 0.3s;
  1017. }
  1018. }
  1019. // 图例上部图片
  1020. .legend {
  1021. position: absolute;
  1022. left: -2px;
  1023. top: -13px;
  1024. width: 104px;
  1025. height: 20px;
  1026. background: url("../../assets/home/legend_line.png") no-repeat center;
  1027. }
  1028. // tagcard
  1029. .menuCardFlex {
  1030. display: flex;
  1031. align-content: center;
  1032. align-items: center;
  1033. justify-content: space-between;
  1034. flex-wrap: nowrap;
  1035. position: relative;
  1036. .borders {
  1037. position: absolute;
  1038. left: 50%;
  1039. top: 50%;
  1040. transform: translate(-50%, -50%) rotate(45deg);
  1041. width: 110px;
  1042. height: 100px;
  1043. background: linear-gradient(to left, @borderColor, @borderColor) left top no-repeat,
  1044. linear-gradient(to bottom, @borderColor, @borderColor) left top no-repeat,
  1045. linear-gradient(to left, @borderColor, @borderColor) right top no-repeat,
  1046. linear-gradient(to bottom, @borderColor, @borderColor) right top no-repeat,
  1047. linear-gradient(to left, @borderColor, @borderColor) left bottom no-repeat,
  1048. linear-gradient(to bottom, @borderColor, @borderColor) left bottom no-repeat,
  1049. linear-gradient(to left, @borderColor, @borderColor) right bottom no-repeat,
  1050. linear-gradient(to left, @borderColor, @borderColor) right bottom no-repeat;
  1051. background-size: 6px 6px, 6px 6px, 6px 6px, 6px 6px;
  1052. }
  1053. }
  1054. </style>