indicatorDataRankings.vue 30 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229
  1. <template>
  2. <view class="indicatorDataRankings">
  3. <!-- 下拉菜单 -->
  4. <view class="selectCondition">
  5. <u-dropdown ref="uDropdown" @open="open" @close="close">
  6. <!-- 指标 -->
  7. <u-dropdown-item :title="dropdown.indicator.title">
  8. <view class="slot-content">
  9. <view style="height:1000upx;position: relative;">
  10. <scroll-view scroll-y="true" class="left">
  11. <view v-for="(fItem, fIndex) in dropdown.indicator.searchList" :key="fItem+fIndex"
  12. class="row" :class="[fIndex===dropdown.indicator.showCategoryIndex ?'on':'']"
  13. @tap="dropdown.indicator.showCategoryIndex = fIndex">
  14. <view class="text">
  15. {{ $i18n.locale == 'zh' ? fItem['indexName'] : fItem['indexEnName'] }}
  16. </view>
  17. </view>
  18. </scroll-view>
  19. <block v-for="(fItem, fIndex) in dropdown.indicator.searchList" :key="fItem+fIndex+'1'">
  20. <scroll-view scroll-y class="right"
  21. v-if="fIndex === dropdown.indicator.showCategoryIndex">
  22. <view v-for="(item,index) in fItem['child']" :key="'c'+index"
  23. :class="(item['child']&&item['child'].length>0)?'':'cate'">
  24. <view v-if="item['child'] && item['child'].length>0">
  25. <view :class="{'getCategory':item['child'].length>0}">
  26. {{ $i18n.locale=='zh'?item['indexName']:item['indexEnName'] }}
  27. </view>
  28. <view class="threemenu">
  29. <view v-for="(i,j) in item['child']" :key="j" class="cateText"
  30. @click="getCategory1({item:i,index:j})"
  31. :class="{'cateTextActive':i.ifClick}">
  32. {{$i18n.locale=='zh'?i['indexName']:i['indexEnName']}}
  33. </view>
  34. </view>
  35. </view>
  36. <view v-else>
  37. <view class="cateText" @click="getCategory1({item,index})"
  38. :class="{'cateTextActive':item.ifClick}">
  39. {{ $i18n.locale=='zh'?item['indexName']:item['indexEnName'] }}
  40. </view>
  41. </view>
  42. </view>
  43. </scroll-view>
  44. </block>
  45. </view>
  46. </view>
  47. </u-dropdown-item>
  48. <!-- 时间 -->
  49. <u-dropdown-item :title="dropdown.time.title">
  50. <view class="slot-content">
  51. <!-- 时间选择 -->
  52. <view style="height:1000upx;position:absolute;bottom: 0;">
  53. <yearSelector :range="false" :show="dropdown.time.showDateFlag"
  54. :defaultTimeValue="[2013,2020]" @getTimeValue="getTimeValue" @cancel="timeCancel">
  55. </yearSelector>
  56. </view>
  57. </view>
  58. </u-dropdown-item>
  59. <!-- top -->
  60. <u-dropdown-item v-model="dropdown.top.value" :options="dropdown.top.options"
  61. :title="dropdown.top.title" @change="topChange">
  62. </u-dropdown-item>
  63. </u-dropdown>
  64. </view>
  65. <!-- 内容 -->
  66. <view style="height: calc(100% - 80upx);background: #fff;">
  67. <!-- 图表 -->
  68. <view class="chart-columns">
  69. <!-- 按钮区 -->
  70. <view class="chart-bg-white chart-title-bar chart-common-mt">
  71. <!-- 标题 -->
  72. <view class="chart-title-dot-light">{{ charts.chartsTitle }}</view>
  73. <!-- 切换线/柱图 -->
  74. <view class="changeChart">
  75. <text :class="canvasType===1?'uCharts2':'uCharts1'"
  76. @click="canvasTypeChange(1)">{{ i18n('ColumnChart') }}</text>
  77. <text :class="canvasType===2?'uCharts2':'uCharts1'"
  78. @click="canvasTypeChange(2)">{{ i18n('LineChart') }}</text>
  79. <view class="export" :class="[loading?'loading':'']">
  80. <u-loading v-if="loading"></u-loading>
  81. <easy-select v-else ref="easySelect" size="medium"
  82. :value="$i18n.locale == 'zh' ? '导出' : 'Export'" :options="exportDocument"
  83. @selectOne="selectExportType"></easy-select>
  84. </view>
  85. </view>
  86. </view>
  87. <!-- 图表 -->
  88. <view class="chart-charts">
  89. <canvas v-if="canvasType===1" canvas-id="canvasColumn2" id="canvasColumn2" class="charts"
  90. @touchstart="touchColumn2" @touchmove="moveColumn2" @touchend="touchEndColumn2"></canvas>
  91. <canvas v-else-if="canvasType===2" canvas-id="canvasLine2" id="canvasLine2" class="charts"
  92. @touchstart="touchLine2" @touchmove="moveLine2" @touchend="touchEndLine2"></canvas>
  93. </view>
  94. <view style="height: 36upx;margin: 0 0 20upx 0;">
  95. <p class="dataSourcep">
  96. <span style="margin-left: 50upx">{{ $t('common.Datasources') }}</span>:{{ submitSource }}
  97. </p>
  98. </view>
  99. <!-- 重置按钮 -->
  100. <view class="reset">
  101. <u-button type="primary" @click="Reset">{{ i18n('Reset') }}</u-button>
  102. </view>
  103. </view>
  104. <!-- 相关指标 -->
  105. <RelevantIndicators :dataList="correlationList" @showRelevant="showRelevant"></RelevantIndicators>
  106. </view>
  107. </view>
  108. </template>
  109. <script>
  110. import uCharts from '@/static/js/u-charts.js';
  111. import easySelect from '@/components/easy-select/easy-select';
  112. import yearSelector from "./yearSelector";
  113. import RelevantIndicators from "./RelevantIndicators";
  114. let _self;
  115. let canvasColumnIns = null;
  116. let canvasLineIns = null;
  117. export default {
  118. name: 'indicatorDataRankings',
  119. components: {
  120. yearSelector,
  121. easySelect,
  122. RelevantIndicators
  123. },
  124. props: {
  125. searchItem: {
  126. type: Object,
  127. default: {}
  128. },
  129. },
  130. data() {
  131. return {
  132. loading: false,
  133. cWidth: '',
  134. cHeight: '',
  135. /**
  136. * 下拉菜单
  137. */
  138. dropdown: {
  139. indicator: {
  140. title: this.$i18n.locale == 'zh' ? '人均GDP' : 'GDP per capita',
  141. searchSelect: {},
  142. searchList: [],
  143. showCategoryIndex: 0,
  144. },
  145. world: {
  146. title: this.$i18n.locale == 'zh' ? '世界' : 'World',
  147. countryId: ['93BC2730ED0A402186F596F6A01C007E'],
  148. countryName: this.$i18n.locale == 'zh' ? ['世界'] : ['World'],
  149. countryList: [{
  150. label: this.$i18n.locale == 'zh' ? '亚洲' : 'ASIA',
  151. labelEn: 'ASIA',
  152. children: [],
  153. },
  154. {
  155. label: this.$i18n.locale == 'zh' ? '非洲' : 'AFRICA',
  156. labelEn: 'AFRICA',
  157. children: [],
  158. },
  159. {
  160. label: this.$i18n.locale == 'zh' ? '欧洲' : 'EUROPE',
  161. labelEn: 'EUROPE',
  162. children: [],
  163. },
  164. {
  165. label: this.$i18n.locale == 'zh' ? '北美洲' : 'NORTH AMERICA',
  166. labelEn: 'NORTH AMERICA',
  167. children: [],
  168. },
  169. {
  170. label: this.$i18n.locale == 'zh' ? '南美洲' : 'SOUTH AMERICA',
  171. labelEn: 'SOUTH AMERICA',
  172. children: [],
  173. },
  174. {
  175. label: this.$i18n.locale == 'zh' ? '大洋洲' : 'OCEANIA',
  176. labelEn: 'OCEANIA',
  177. children: [],
  178. },
  179. ],
  180. originalCountryData: [],
  181. showCategoryIndex: 0,
  182. temp: {
  183. country: [],
  184. countryId: [],
  185. countryName: []
  186. }
  187. },
  188. time: {
  189. title: this.$i18n.locale == 'zh' ? '时间' : 'Time',
  190. showDateFlag: true,
  191. time: 2013,
  192. timeScope: [],
  193. isHighlight: false
  194. },
  195. top: {
  196. title: 'Top5',
  197. value: '5',
  198. options: [{
  199. label: 'Top5',
  200. value: '5',
  201. },
  202. {
  203. label: 'Top10',
  204. value: '10',
  205. },
  206. /*{
  207. label: this.$i18n.locale == 'zh' ? '全部' : 'All',
  208. value: 'All',
  209. },*/
  210. ],
  211. isHighlight: false
  212. },
  213. },
  214. /**
  215. * 图表
  216. */
  217. canvasType: 1,
  218. pixelRatio: 1,
  219. charts: {
  220. chartsTitle: null, // 头部展示的单位
  221. activeTitle: null, // 选择的类型
  222. activeType: {
  223. indexName: '人均GDP',
  224. indexEnName: 'GDP per capita',
  225. source: {
  226. "世界银行": {
  227. "index": {
  228. "人均GDP": "28"
  229. }
  230. }
  231. }
  232. },
  233. },
  234. submitSource: this.$i18n.locale == 'zh' ? '世界银行' : 'World Bank',
  235. exportDocument: [{
  236. value: 'EXCEL',
  237. label: 'Excel'
  238. }, {
  239. value: 'PDF',
  240. label: 'PDF'
  241. }, ],
  242. /**
  243. * 相关指标
  244. */
  245. correlationList: [{
  246. icon: require('@/static/img/infomationdata/e1.png'),
  247. "label": this.$i18n.locale == 'zh' ? '人均GDP' : 'GDP per capita',
  248. "item": {
  249. "indexName": "人均GDP",
  250. "indexEnName": "GDP per capita",
  251. "source": '{"世界银行":{"index":{"人均GDP":"28"}}}'
  252. }
  253. }],
  254. correlationIconList: [{
  255. icon: require('@/static/img/infomationdata/shehuijingji/jingji.png'),
  256. label: '基础经济'
  257. },
  258. {
  259. icon: require('@/static/img/infomationdata/shehuijingji/maoyi.png'),
  260. label: '贸易'
  261. },
  262. {
  263. icon: require('@/static/img/infomationdata/shehuijingji/renkou.png'),
  264. label: '人口'
  265. },
  266. {
  267. icon: require('@/static/img/infomationdata/shehuijingji/guotu.png'),
  268. label: '国土'
  269. },
  270. {
  271. icon: require('@/static/img/infomationdata/nengyuan/shengcheng.png'),
  272. label: '能源生产'
  273. },
  274. {
  275. icon: require('@/static/img/infomationdata/nengyuan/xiaofei.png'),
  276. label: '能源消费'
  277. },
  278. {
  279. icon: require('@/static/img/infomationdata/nengyuan/zhuanhua.png'),
  280. label: '能源转化'
  281. },
  282. {
  283. icon: require('@/static/img/infomationdata/dianli/fadianzhuangzhi.png'),
  284. label: '发电装机'
  285. },
  286. {
  287. icon: require('@/static/img/infomationdata/dianli/fadian.png'),
  288. label: '发电'
  289. },
  290. {
  291. icon: require('@/static/img/infomationdata/dianli/yongdian.png'),
  292. label: '用电'
  293. },
  294. {
  295. icon: require('@/static/img/infomationdata/qihou/huanjing.png'),
  296. label: '排放量'
  297. },
  298. ],
  299. exportId: [],
  300. exportPoll: ''
  301. }
  302. },
  303. created() {
  304. this.init()
  305. },
  306. async mounted() {
  307. _self = this;
  308. this.cWidth = uni.upx2px(750);
  309. this.cHeight = uni.upx2px(500);
  310. await this.getInitialCategory({
  311. "Source": [{
  312. "世界银行": {
  313. "index": {
  314. "人均GDP": "28"
  315. }
  316. }
  317. }],
  318. "time": [String(this.dropdown.time.time), String(this.dropdown.time.time)],
  319. "language": this.$i18n.locale,
  320. "type": {
  321. "rule": this.canvasType == 1 ? 'CIRCLE' : 'LINE',
  322. "top": this.dropdown.top.value
  323. }
  324. });
  325. },
  326. watch: {
  327. exportId(n, o) {
  328. let _this = this;
  329. if (_this.exportId.length > 0) {
  330. } else {
  331. this.loading = false
  332. }
  333. clearInterval(this.exportPoll)
  334. this.exportPoll = setInterval(() => {
  335. _this.exportId.forEach(item => {
  336. _this.getTime(item)
  337. })
  338. }, 2000)
  339. },
  340. searchItem(n, o) {
  341. let nodeId = n.item.nodeId.split('_')
  342. let item = this.dropdown.indicator.searchList
  343. let index = ''
  344. nodeId.forEach(it => {
  345. item = item[Number(it)]
  346. if (item.child && item.child.length && item.child.length !== 0) {
  347. item = item.child
  348. }
  349. index = Number(it)
  350. })
  351. this.getCategory1({
  352. item,
  353. index
  354. })
  355. }
  356. },
  357. methods: {
  358. async init() {
  359. await this.getServerData()
  360. },
  361. i18n(data) {
  362. return this.$t('common.' + data);
  363. },
  364. isJsonString(str) {
  365. try {
  366. if (typeof JSON.parse(str) == "object") {
  367. return true;
  368. }
  369. } catch (e) {}
  370. return false;
  371. },
  372. /**
  373. * 下拉菜单
  374. */
  375. open(index) {
  376. this.$forceUpdate()
  377. },
  378. close(index) {
  379. },
  380. // 类别
  381. async getServerData() {
  382. const res = await this.$myRequest({
  383. url: '/op/geiIntegratedDataMenus/getMenu',
  384. data: {}
  385. });
  386. this.dropdown.indicator.searchList = res.data;
  387. this.setIcon(this.dropdown.indicator.searchList)
  388. this.dropdown.indicator.showCategoryIndex = 0
  389. this.dropdown.indicator.searchSelect = res.data[0].child[0].child[2]
  390. this.dropdown.indicator.searchSelect.ifClick = true;
  391. },
  392. setIcon(data) {
  393. data.forEach(item => {
  394. this.correlationIconList.forEach(icon => {
  395. if (item.indexName == icon.label) {
  396. item.icon = icon.icon;
  397. }
  398. })
  399. if (item.child && item.child.length != 0) {
  400. this.setIcon(item.child)
  401. }
  402. })
  403. },
  404. // 日历选择
  405. getTimeValue(e) {
  406. console.log('e')
  407. console.log(e)
  408. this.dropdown.time.timeScope = e
  409. this.dropdown.time.time = e[0]
  410. this.dropdown.time.title = `${e[0]}`
  411. this.$refs.uDropdown.close()
  412. this.getCategory();
  413. },
  414. timeCancel(e) {
  415. this.$refs.uDropdown.close()
  416. },
  417. // top
  418. topChange(e) {
  419. this.dropdown.top.title = this.dropdown.top.options.filter(item => e == item.value)[0].label
  420. this.getCategory();
  421. },
  422. /**
  423. * 图表
  424. */
  425. canvasTypeChange(num) {
  426. this.canvasType = num;
  427. this.getCategory();
  428. },
  429. touchColumn(e) {
  430. canvasColumnIns.showToolTip(e, {
  431. format: function(item, category) {
  432. if (typeof item.data === 'object') {
  433. return category + '\n' + item.name + ':' + item.data.value
  434. let country = item.name.split(' ')
  435. this.textList = [{
  436. text: category
  437. }];
  438. country.forEach(it => {
  439. this.textList.push({
  440. text: it
  441. })
  442. })
  443. this.textList.push({
  444. text: item.data.value
  445. })
  446. } else {
  447. return category + '\n' + item.name + ':' + item.data
  448. let country = item.name.split(' ')
  449. this.textList = [{
  450. text: category
  451. }];
  452. country.forEach(it => {
  453. this.textList.push({
  454. text: it
  455. })
  456. })
  457. this.textList.push({
  458. text: item.data
  459. })
  460. }
  461. }
  462. });
  463. },
  464. touchLine(e) {
  465. canvasLineIns.showToolTip(e, {
  466. format: function(item, category) {
  467. return item.data
  468. }
  469. })
  470. },
  471. // 启用图表拖拽
  472. touchColumn2(e) {
  473. canvasColumnIns.scrollStart(e);
  474. },
  475. moveColumn2(e) {
  476. canvasColumnIns.scroll(e);
  477. },
  478. touchEndColumn2(e) {
  479. canvasColumnIns.scrollEnd(e);
  480. //下面是toolTip事件,如果滚动后不需要显示,可不填写
  481. canvasColumnIns.showToolTip(e, {
  482. format: function(item, category) {
  483. return category + ' ' + item.name + ':' + item.data
  484. }
  485. });
  486. },
  487. touchLine2(e) {
  488. canvasLineIns.scrollStart(e);
  489. },
  490. moveLine2(e) {
  491. canvasLineIns.scroll(e);
  492. },
  493. touchEndLine2(e) {
  494. canvasLineIns.scrollEnd(e);
  495. //下面是toolTip事件,如果滚动后不需要显示,可不填写
  496. canvasLineIns.showToolTip(e, {
  497. format: function(item, category) {
  498. return category + ' ' + item.name + ':' + item.data
  499. }
  500. });
  501. },
  502. async getInitialCategory(params) {
  503. const res = await this.$myRequest({
  504. url: '/op/geiIntegratedDataMenus/getTopN',
  505. data: {
  506. ...params
  507. },
  508. method: 'post',
  509. });
  510. if (res.data) {
  511. this.canvas(res.data);
  512. }
  513. this.getCorrelationList()
  514. this.$forceUpdate()
  515. },
  516. canvas(data) {
  517. this.charts.chartsTitle = data.unitY; // 头部展示的单位
  518. this.charts.activeTitle = this.$i18n.locale === 'zh' ? this.charts.activeType.indexName : this.charts
  519. .activeType.indexEnName; //选择的类型
  520. let series = [];
  521. let seriesItem = {};
  522. seriesItem = {
  523. "name": this.dropdown.time.time,
  524. "data": data.y
  525. }
  526. series.push(seriesItem);
  527. let Column = {
  528. "categories": data.x,
  529. "series": series
  530. };
  531. if (this.canvasType == 1) {
  532. this.showColumn('canvasColumn2', Column);
  533. } else {
  534. this.showLine("canvasLine2", Column);
  535. }
  536. },
  537. showColumn(canvasId, chartData) {
  538. canvasColumnIns = new uCharts({
  539. $this: _self,
  540. canvasId: canvasId,
  541. type: 'column',
  542. legend: {
  543. show: true
  544. },
  545. fontSize: 11,
  546. enableScroll: true, //开启图表拖拽功能
  547. background: '#FFFFFF',
  548. pixelRatio: _self.pixelRatio,
  549. animation: true,
  550. categories: chartData.categories,
  551. series: chartData.series,
  552. xAxis: {
  553. disableGrid: true,
  554. itemCount: 5, //x轴单屏显示数据的数量,默认为5个
  555. scrollShow: true, //新增是否显示滚动条,默认false
  556. scrollAlign: 'left', //滚动条初始位置
  557. scrollBackgroundColor: '#F7F7FF', //默认为 #EFEBEF
  558. scrollColor: '#DEE7F7', //默认为 #A6A6A6
  559. // rotateLabel:true
  560. },
  561. yAxis: {},
  562. dataLabel: false,
  563. width: _self.cWidth * _self.pixelRatio,
  564. height: _self.cHeight * _self.pixelRatio,
  565. extra: {
  566. column: {
  567. type: 'group',
  568. width: _self.cWidth * _self.pixelRatio * 0.45 / chartData.categories.length
  569. }
  570. }
  571. })
  572. },
  573. showLine(canvasId, chartData) {
  574. canvasLineIns = new uCharts({
  575. $this: _self,
  576. canvasId: canvasId,
  577. type: 'line',
  578. fontSize: 11,
  579. legend: {
  580. show: true
  581. },
  582. enableScroll: true, //开启图表拖拽功能
  583. dataLabel: false,
  584. dataPointShape: true,
  585. background: '#FFFFFF',
  586. pixelRatio: _self.pixelRatio,
  587. categories: chartData.categories,
  588. series: chartData.series,
  589. animation: true,
  590. xAxis: {
  591. type: 'grid',
  592. gridColor: '#CCCCCC',
  593. gridType: 'dash',
  594. dashLength: 8,
  595. itemCount: 5, //x轴单屏显示数据的数量,默认为5个
  596. scrollShow: true, //新增是否显示滚动条,默认false
  597. scrollAlign: 'left', //滚动条初始位置
  598. scrollBackgroundColor: '#F7F7FF', //默认为 #EFEBEF
  599. scrollColor: '#DEE7F7', //默认为 #A6A6A6
  600. },
  601. yAxis: {
  602. gridType: 'dash',
  603. gridColor: '#CCCCCC',
  604. dashLength: 8,
  605. splitNumber: 5,
  606. min: 10,
  607. max: 180,
  608. },
  609. width: _self.cWidth * _self.pixelRatio,
  610. height: _self.cHeight * _self.pixelRatio,
  611. extra: {
  612. line: {
  613. type: 'straight'
  614. }
  615. }
  616. });
  617. },
  618. // 点击事件
  619. getCategory() {
  620. // 数据优先级
  621. let item = this.dropdown.indicator.searchSelect
  622. this.getSubmitSource(item)
  623. let source = this.charts.activeType.source;
  624. if (this.isJsonString(this.charts.activeType.source)) {
  625. source = JSON.parse(this.charts.activeType.source)
  626. }
  627. let params = {
  628. "Source": [source],
  629. "time": [String(this.dropdown.time.time), String(this.dropdown.time.time)],
  630. "language": this.$i18n.locale,
  631. "type": {
  632. "rule": this.canvasType == 1 ? 'CIRCLE' : 'LINE',
  633. "top": this.dropdown.top.value
  634. }
  635. }
  636. this.getInitialCategory(params);
  637. this.$refs.uDropdown.close()
  638. },
  639. getCategory1({
  640. item,
  641. index,
  642. ifClick
  643. }) {
  644. this.dropdown.indicator.searchSelect.ifClick = false
  645. this.dropdown.indicator.searchSelect = item
  646. this.dropdown.indicator.title = this.$i18n.locale == 'zh' ? item.indexName : item.indexEnName
  647. item.ifClick = true
  648. this.$forceUpdate()
  649. this.charts.activeType = {
  650. indexName: item.indexName,
  651. indexEnName: item.indexEnName,
  652. source: item.source
  653. };
  654. this.getCategory()
  655. },
  656. empty() {
  657. if (this.dropdown.world.temp.countryId.length == 0) {
  658. this.dropdown.world.temp.countryId = JSON.parse(JSON.stringify(this.dropdown.world.countryId))
  659. this.dropdown.world.temp.countryName = JSON.parse(JSON.stringify(this.dropdown.world.countryName))
  660. }
  661. this.dropdown.world.countryList.forEach(item => {
  662. if (item.ifClick) {
  663. this.dropdown.world.temp.country.push(item)
  664. }
  665. item.ifClick = false;
  666. item.children.forEach(it => {
  667. if (it.ifClick) {
  668. this.dropdown.world.temp.country.push(it)
  669. }
  670. it.ifClick = false
  671. })
  672. })
  673. this.dropdown.world.countryId = ['93BC2730ED0A402186F596F6A01C007E']
  674. this.dropdown.world.countryName = this.$i18n.locale == 'zh' ? ['世界'] : ['World']
  675. this.$forceUpdate();
  676. },
  677. submit() {
  678. this.dropdown.world.temp = {
  679. country: [],
  680. countryId: [],
  681. countryName: []
  682. }
  683. _self.getCategory()
  684. },
  685. // 导出
  686. async selectExportType(data) {
  687. let _this = this
  688. this.loading = true
  689. let source = this.charts.activeType.source;
  690. if (this.isJsonString(this.charts.activeType.source)) {
  691. source = JSON.parse(this.charts.activeType.source)
  692. }
  693. let id = this.randomString(18)
  694. try {
  695. const resId = await this.$myRequest({
  696. url: '/op/geiIntegratedDataMenus/getRandomId',
  697. method: 'get',
  698. data: {
  699. uuid: id
  700. },
  701. });
  702. let params = {
  703. "Source": [source],
  704. "time": [String(this.dropdown.time.time), String(this.dropdown.time.time)],
  705. "language": _this.$i18n.locale,
  706. "type": {
  707. "rule": this.canvasType == 1 ? 'CIRCLE' : 'LINE',
  708. "top": this.dropdown.top.value
  709. }
  710. }
  711. const res = await this.$myRequest({
  712. url: '/op/geiIntegratedDataMenus/saveFile',
  713. data: {
  714. ...params
  715. },
  716. method: 'post',
  717. });
  718. if (res) {
  719. this.exportId.push({
  720. type: data,
  721. id: id
  722. })
  723. }
  724. } catch (e) {
  725. this.loading = false
  726. let eg = _this.$i18n.locale == 'zh' ? '失败请重新下载' : 'Please download again if failed'
  727. uni.showToast({
  728. icon: 'none',
  729. mask: true,
  730. title: eg,
  731. });
  732. }
  733. },
  734. async getTime(id) {
  735. let _this = this
  736. const res = await this.$myRequest({
  737. url: '/op/geiIntegratedDataMenus/getTime',
  738. method: 'get',
  739. data: {
  740. uuid: id.id
  741. },
  742. });
  743. if (res.data && res.status == '200') {
  744. let url = id.type.value == 'EXCEL' ? res.data[0] : res.data[1]
  745. this.exportId = this.exportId.filter(item => item.id != id.id)
  746. this.download(url)
  747. } else if (res.data && res.status == '500') {
  748. this.exportId = this.exportId.filter(item => item.id != id.id)
  749. let eg = _this.$i18n.locale == 'zh' ? '失败请重新下载' : 'Please download again if failed'
  750. uni.showToast({
  751. icon: 'none',
  752. mask: true,
  753. title: eg,
  754. });
  755. }
  756. },
  757. download(url) {
  758. let _this = this
  759. // this.playpapers(this.websiteUrl + url)
  760. uni.downloadFile({
  761. url: 'https://m.geidcp.com/api/file/pub/' + url,
  762. success: (data) => {
  763. if (data.statusCode === 200) {
  764. //文件保存到本地
  765. // #ifdef APP-PLUS
  766. uni.saveFile({
  767. tempFilePath: data.tempFilePath, //临时路径
  768. success: function(res) {
  769. let eg = _this.$i18n.locale == 'zh' ? '文件已保存:' :
  770. 'The file is saved:'
  771. uni.showToast({
  772. icon: 'none',
  773. mask: true,
  774. title: eg + res.savedFilePath, //保存路径
  775. duration: 3000,
  776. });
  777. setTimeout(() => {
  778. //打开文档查看
  779. uni.openDocument({
  780. filePath: res.savedFilePath,
  781. success: function(res) {
  782. // console.log('打开文档成功');
  783. }
  784. });
  785. }, 3000)
  786. }
  787. });
  788. // #endif
  789. } else {
  790. let eg = _this.$i18n.locale == 'zh' ? '失败请重新下载' : 'Please download again if failed'
  791. uni.showToast({
  792. icon: 'none',
  793. mask: true,
  794. title: eg,
  795. });
  796. }
  797. },
  798. fail: (err) => {
  799. let eg = _this.$i18n.locale == 'zh' ? '失败请重新下载' : 'Please download again if failed'
  800. uni.showToast({
  801. icon: 'none',
  802. mask: true,
  803. title: eg,
  804. });
  805. },
  806. });
  807. },
  808. playpapers(url) {
  809. let dload = document.createElement("a");
  810. dload.download = ''; // 设置下载的文件名,默认是'下载'
  811. dload.href = url;
  812. document.body.appendChild(dload);
  813. dload.click();
  814. dload.remove(); // 下载之后把创建的元素删除
  815. },
  816. randomString(length) {
  817. let str = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
  818. let result = '';
  819. for (let i = length; i > 0; --i)
  820. result += str[Math.floor(Math.random() * str.length)];
  821. return result;
  822. },
  823. // 重置按钮
  824. Reset() {
  825. this.$emit('reset', 1)
  826. },
  827. /**
  828. * 相关指标
  829. */
  830. getCorrelationList() {
  831. let select = _self.charts.activeType.indexName
  832. function getParent(data, parent) {
  833. data.forEach(item => {
  834. if (item.indexName == select) {
  835. _self.correlationList = parent.child.map(it => {
  836. return {
  837. icon: parent.icon,
  838. "label": _self.$i18n.locale == 'zh' ? it.indexName : it.indexEnName,
  839. "item": {
  840. "indexName": it.indexName,
  841. "indexEnName": it.indexEnName,
  842. "source": it.source
  843. }
  844. }
  845. })
  846. }
  847. if (item.child && item.child.length != 0) {
  848. getParent(item.child, item)
  849. }
  850. })
  851. }
  852. getParent(_self.dropdown.indicator.searchList, null)
  853. },
  854. showRelevant(e) {
  855. let ser = {}
  856. function getOther(data, source) {
  857. data.forEach(item => {
  858. if (item.source == source) {
  859. ser = item
  860. return
  861. } else {
  862. getOther(item.child, source)
  863. }
  864. })
  865. }
  866. getOther([this.dropdown.indicator.searchList[this.dropdown.indicator.showCategoryIndex]], e.item.source)
  867. ser.ifClick = true
  868. this.charts.activeType = {
  869. indexName: e.item.indexName,
  870. indexEnName: e.item.indexEnName,
  871. source: JSON.parse(e.item.source)
  872. }
  873. this.dropdown.indicator.title = this.$i18n.locale == 'zh' ? e.item.indexName : e.item.indexEnName
  874. this.dropdown.indicator.searchSelect.ifClick = false;
  875. this.dropdown.indicator.searchSelect = ser
  876. this.getCategory();
  877. },
  878. /**
  879. * 查询优先级
  880. */
  881. getSubmitSource(data) {
  882. let dataSources = [];
  883. let sources = JSON.parse(data.source);
  884. let sourceKeys = Object.keys(sources);
  885. sourceKeys.forEach(item => {
  886. dataSources.push({
  887. label: item,
  888. value: JSON.stringify({
  889. [item]: sources[item]
  890. })
  891. })
  892. })
  893. let buer = sourceKeys.indexOf("IEA") > -1 ? true : false;
  894. this.submitSource = '';
  895. if (buer == true) {
  896. let i = sourceKeys.indexOf("IEA")
  897. this.submitSource = "IEA";
  898. // 如果本条数据的dataSources里有IEA就使用IEA作为查询时使用的数据源
  899. this.charts.activeType["source"] = JSON.parse(dataSources[i].value);
  900. if (this.$i18n.locale == 'zh') {
  901. this.submitSource = '国际能源署'
  902. }
  903. } else {
  904. this.submitSource = sourceKeys[0]
  905. // 由于客户没有英国石油公司的数据使用权限,所以不能用英国石油公司的数据源查询
  906. this.charts.activeType["source"] = JSON.parse(dataSources[0].value);
  907. if (this.$i18n.locale == 'en') {
  908. this.submitSource = this.zhToen(this.submitSource)
  909. } else {
  910. this.submitSource = this.enTozh(this.submitSource)
  911. }
  912. }
  913. },
  914. zhToen(str) {
  915. switch (str) {
  916. case '世界银行':
  917. return 'World Bank';
  918. break;
  919. case '英国石油公司(BP)':
  920. return 'British Petroleum';
  921. break;
  922. case 'EIA':
  923. return 'Energy Information Administration';
  924. break;
  925. }
  926. },
  927. enTozh(str) {
  928. switch (str) {
  929. case 'IEA':
  930. return '国际能源署';
  931. break;
  932. case 'EIA':
  933. return '美国能源信息署';
  934. break;
  935. case '世界银行':
  936. return '世界银行';
  937. break;
  938. case '英国石油公司(BP)':
  939. return '英国石油公司';
  940. break;
  941. }
  942. },
  943. }
  944. }
  945. </script>
  946. <style scoped lang="scss">
  947. .indicatorDataQuery {
  948. width: 100%;
  949. height: 100%;
  950. }
  951. .u-dropdown /deep/ .u-dropdown__menu {
  952. width: 100%;
  953. overflow: hidden;
  954. }
  955. .u-dropdown /deep/ .u-dropdown__menu .u-dropdown__menu__item {
  956. width: 33%;
  957. background: #fff;
  958. }
  959. .u-dropdown /deep/ .u-dropdown__menu .u-dropdown__menu__item .u-flex {
  960. width: 100%;
  961. justify-content: center;
  962. }
  963. .u-dropdown /deep/ .u-dropdown__menu__item__text {
  964. overflow: hidden; //超出的文本隐藏
  965. text-overflow: ellipsis; //溢出用省略号显示
  966. white-space: nowrap; //溢出不换行
  967. //width: 80%;
  968. text-align: center;
  969. }
  970. /deep/ .u-dropdown .u-dropdown__content {
  971. .u-dropdown__content__popup {
  972. height: 100%;
  973. }
  974. }
  975. .left {
  976. position: absolute;
  977. height: 100%;
  978. top: 0;
  979. bottom: 0upx;
  980. width: 24%;
  981. left: 0upx;
  982. background: #F2F2F2;
  983. }
  984. .right {
  985. position: absolute;
  986. height: 100%;
  987. top: 0;
  988. bottom: 0upx;
  989. width: 76%;
  990. left: 24%;
  991. background-color: #fff;
  992. margin-left: 0;
  993. padding: 0 20upx;
  994. }
  995. .row {
  996. width: 100%;
  997. height: 90upx;
  998. display: flex;
  999. align-items: center;
  1000. .text {
  1001. width: 100%;
  1002. position: relative;
  1003. font-size: 28upx;
  1004. display: flex;
  1005. justify-content: center;
  1006. color: #3c3c3c;
  1007. text-align: center;
  1008. .block {
  1009. position: absolute;
  1010. width: 0upx;
  1011. left: 0;
  1012. }
  1013. }
  1014. &.on {
  1015. height: 90upx;
  1016. background-color: #fff;
  1017. .text {
  1018. font-size: 30upx;
  1019. color: #1677FD;
  1020. .block {
  1021. width: 6upx;
  1022. height: 100%;
  1023. left: 10upx;
  1024. }
  1025. }
  1026. &:before {
  1027. content: "";
  1028. position: absolute;
  1029. left: 10upx;
  1030. width: 10upx;
  1031. height: 60upx;
  1032. background-color: rgba(22, 119, 253, 0.8);
  1033. }
  1034. }
  1035. }
  1036. .threemenu {
  1037. display: flex;
  1038. flex-wrap: wrap;
  1039. }
  1040. .getCategory {
  1041. height: 90upx;
  1042. line-height: 90upx;
  1043. font-weight: 700;
  1044. //color: #0079ef;
  1045. }
  1046. .cate {
  1047. display: inline-block;
  1048. width: 240upx;
  1049. vertical-align: middle;
  1050. margin-right: 20upx;
  1051. }
  1052. .cateText {
  1053. padding: 10upx;
  1054. margin: 10upx 20upx 10upx 0;
  1055. display: inline-block;
  1056. width: 240upx;
  1057. vertical-align: middle;
  1058. background: #f1f2f3;
  1059. text-align: center;
  1060. overflow: hidden;
  1061. text-overflow: ellipsis;
  1062. white-space: nowrap;
  1063. }
  1064. .cateTextActive {
  1065. padding: 10upx;
  1066. margin: 10upx 20upx 10upx 0;
  1067. display: inline-block;
  1068. width: 240upx;
  1069. vertical-align: middle;
  1070. background-color: #0079ef;
  1071. color: #fff;
  1072. text-align: center;
  1073. overflow: hidden;
  1074. text-overflow: ellipsis;
  1075. white-space: nowrap;
  1076. }
  1077. .contry-btn {
  1078. height: 50upx;
  1079. display: inline-block;
  1080. line-height: 50upx;
  1081. }
  1082. .dataSourcep {
  1083. font-size: 28upx;
  1084. color: #c1c1c1;
  1085. line-height: 1.5em;
  1086. margin: 0;
  1087. }
  1088. </style>
  1089. <style scoped lang="scss">
  1090. .chart-columns {
  1091. display: flex;
  1092. flex-direction: column !important;
  1093. border-top: 20upx solid #fff
  1094. }
  1095. .chart-common-mt {
  1096. margin-top: 10upx;
  1097. }
  1098. .chart-bg-white {
  1099. background: #FFFFFF;
  1100. }
  1101. .chart-title-bar {
  1102. padding: 10upx 2%;
  1103. flex-wrap: nowrap;
  1104. display: flex;
  1105. align-items: center;
  1106. justify-content: space-between;
  1107. .changeChart {
  1108. display: flex;
  1109. align-items: center;
  1110. }
  1111. }
  1112. .uCharts1 {
  1113. padding: 10upx 20upx;
  1114. background-color: #F1F2F4;
  1115. font-size: 26upx;
  1116. color: #333;
  1117. }
  1118. .uCharts2 {
  1119. padding: 10upx 20upx;
  1120. background-color: #E5F0FE;
  1121. color: #1890FF;
  1122. font-size: 26upx;
  1123. }
  1124. .export {
  1125. width: 100upx;
  1126. margin-left: 20upx;
  1127. height: 60upx;
  1128. &.loading {
  1129. text-align: center;
  1130. padding-top: 10upx;
  1131. }
  1132. /deep/.easy-select {
  1133. width: 100% !important;
  1134. height: 90% !important;
  1135. margin-top: 5%;
  1136. border: none;
  1137. border: 0;
  1138. color: #fff;
  1139. background-color: #1777FE;
  1140. font-size: 26upx;
  1141. uni-input {
  1142. padding: 0;
  1143. text-align: center;
  1144. font-size: 26upx;
  1145. }
  1146. .easy-select-suffix {
  1147. display: none;
  1148. }
  1149. .easy-select-options {
  1150. min-width: 0 !important;
  1151. width: 100%;
  1152. }
  1153. .easy-select-options-item {
  1154. padding: 0 10upx;
  1155. }
  1156. }
  1157. }
  1158. .charts {
  1159. width: 750upx;
  1160. height: 500upx;
  1161. background-color: #FFFFFF;
  1162. }
  1163. .reset {
  1164. width: 90%;
  1165. margin: 0 auto 40upx;
  1166. .u-btn--primary {
  1167. border-radius: 60upx;
  1168. background: linear-gradient(90deg, #33AFFF, #1777FE);
  1169. font-size: 32upx;
  1170. font-weight: 600;
  1171. }
  1172. }
  1173. </style>