12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229 |
- <template>
- <view class="indicatorDataRankings">
- <!-- 下拉菜单 -->
- <view class="selectCondition">
- <u-dropdown ref="uDropdown" @open="open" @close="close">
- <!-- 指标 -->
- <u-dropdown-item :title="dropdown.indicator.title">
- <view class="slot-content">
- <view style="height:1000upx;position: relative;">
- <scroll-view scroll-y="true" class="left">
- <view v-for="(fItem, fIndex) in dropdown.indicator.searchList" :key="fItem+fIndex"
- class="row" :class="[fIndex===dropdown.indicator.showCategoryIndex ?'on':'']"
- @tap="dropdown.indicator.showCategoryIndex = fIndex">
- <view class="text">
- {{ $i18n.locale == 'zh' ? fItem['indexName'] : fItem['indexEnName'] }}
- </view>
- </view>
- </scroll-view>
- <block v-for="(fItem, fIndex) in dropdown.indicator.searchList" :key="fItem+fIndex+'1'">
- <scroll-view scroll-y class="right"
- v-if="fIndex === dropdown.indicator.showCategoryIndex">
- <view v-for="(item,index) in fItem['child']" :key="'c'+index"
- :class="(item['child']&&item['child'].length>0)?'':'cate'">
- <view v-if="item['child'] && item['child'].length>0">
- <view :class="{'getCategory':item['child'].length>0}">
- {{ $i18n.locale=='zh'?item['indexName']:item['indexEnName'] }}
- </view>
- <view class="threemenu">
- <view v-for="(i,j) in item['child']" :key="j" class="cateText"
- @click="getCategory1({item:i,index:j})"
- :class="{'cateTextActive':i.ifClick}">
- {{$i18n.locale=='zh'?i['indexName']:i['indexEnName']}}
- </view>
- </view>
- </view>
- <view v-else>
- <view class="cateText" @click="getCategory1({item,index})"
- :class="{'cateTextActive':item.ifClick}">
- {{ $i18n.locale=='zh'?item['indexName']:item['indexEnName'] }}
- </view>
- </view>
- </view>
- </scroll-view>
- </block>
- </view>
- </view>
- </u-dropdown-item>
- <!-- 时间 -->
- <u-dropdown-item :title="dropdown.time.title">
- <view class="slot-content">
- <!-- 时间选择 -->
- <view style="height:1000upx;position:absolute;bottom: 0;">
- <yearSelector :range="false" :show="dropdown.time.showDateFlag"
- :defaultTimeValue="[2013,2020]" @getTimeValue="getTimeValue" @cancel="timeCancel">
- </yearSelector>
- </view>
- </view>
- </u-dropdown-item>
- <!-- top -->
- <u-dropdown-item v-model="dropdown.top.value" :options="dropdown.top.options"
- :title="dropdown.top.title" @change="topChange">
- </u-dropdown-item>
- </u-dropdown>
- </view>
- <!-- 内容 -->
- <view style="height: calc(100% - 80upx);background: #fff;">
- <!-- 图表 -->
- <view class="chart-columns">
- <!-- 按钮区 -->
- <view class="chart-bg-white chart-title-bar chart-common-mt">
- <!-- 标题 -->
- <view class="chart-title-dot-light">{{ charts.chartsTitle }}</view>
- <!-- 切换线/柱图 -->
- <view class="changeChart">
- <text :class="canvasType===1?'uCharts2':'uCharts1'"
- @click="canvasTypeChange(1)">{{ i18n('ColumnChart') }}</text>
- <text :class="canvasType===2?'uCharts2':'uCharts1'"
- @click="canvasTypeChange(2)">{{ i18n('LineChart') }}</text>
- <view class="export" :class="[loading?'loading':'']">
- <u-loading v-if="loading"></u-loading>
- <easy-select v-else ref="easySelect" size="medium"
- :value="$i18n.locale == 'zh' ? '导出' : 'Export'" :options="exportDocument"
- @selectOne="selectExportType"></easy-select>
- </view>
- </view>
- </view>
- <!-- 图表 -->
- <view class="chart-charts">
- <canvas v-if="canvasType===1" canvas-id="canvasColumn2" id="canvasColumn2" class="charts"
- @touchstart="touchColumn2" @touchmove="moveColumn2" @touchend="touchEndColumn2"></canvas>
- <canvas v-else-if="canvasType===2" canvas-id="canvasLine2" id="canvasLine2" class="charts"
- @touchstart="touchLine2" @touchmove="moveLine2" @touchend="touchEndLine2"></canvas>
- </view>
- <view style="height: 36upx;margin: 0 0 20upx 0;">
- <p class="dataSourcep">
- <span style="margin-left: 50upx">{{ $t('common.Datasources') }}</span>:{{ submitSource }}
- </p>
- </view>
- <!-- 重置按钮 -->
- <view class="reset">
- <u-button type="primary" @click="Reset">{{ i18n('Reset') }}</u-button>
- </view>
- </view>
- <!-- 相关指标 -->
- <RelevantIndicators :dataList="correlationList" @showRelevant="showRelevant"></RelevantIndicators>
- </view>
- </view>
- </template>
- <script>
- import uCharts from '@/static/js/u-charts.js';
- import easySelect from '@/components/easy-select/easy-select';
- import yearSelector from "./yearSelector";
- import RelevantIndicators from "./RelevantIndicators";
- let _self;
- let canvasColumnIns = null;
- let canvasLineIns = null;
- export default {
- name: 'indicatorDataRankings',
- components: {
- yearSelector,
- easySelect,
- RelevantIndicators
- },
- props: {
- searchItem: {
- type: Object,
- default: {}
- },
- },
- data() {
- return {
- loading: false,
- cWidth: '',
- cHeight: '',
- /**
- * 下拉菜单
- */
- dropdown: {
- indicator: {
- title: this.$i18n.locale == 'zh' ? '人均GDP' : 'GDP per capita',
- searchSelect: {},
- searchList: [],
- showCategoryIndex: 0,
- },
- world: {
- title: this.$i18n.locale == 'zh' ? '世界' : 'World',
- countryId: ['93BC2730ED0A402186F596F6A01C007E'],
- countryName: this.$i18n.locale == 'zh' ? ['世界'] : ['World'],
- countryList: [{
- label: this.$i18n.locale == 'zh' ? '亚洲' : 'ASIA',
- labelEn: 'ASIA',
- children: [],
- },
- {
- label: this.$i18n.locale == 'zh' ? '非洲' : 'AFRICA',
- labelEn: 'AFRICA',
- children: [],
- },
- {
- label: this.$i18n.locale == 'zh' ? '欧洲' : 'EUROPE',
- labelEn: 'EUROPE',
- children: [],
- },
- {
- label: this.$i18n.locale == 'zh' ? '北美洲' : 'NORTH AMERICA',
- labelEn: 'NORTH AMERICA',
- children: [],
- },
- {
- label: this.$i18n.locale == 'zh' ? '南美洲' : 'SOUTH AMERICA',
- labelEn: 'SOUTH AMERICA',
- children: [],
- },
- {
- label: this.$i18n.locale == 'zh' ? '大洋洲' : 'OCEANIA',
- labelEn: 'OCEANIA',
- children: [],
- },
- ],
- originalCountryData: [],
- showCategoryIndex: 0,
- temp: {
- country: [],
- countryId: [],
- countryName: []
- }
- },
- time: {
- title: this.$i18n.locale == 'zh' ? '时间' : 'Time',
- showDateFlag: true,
- time: 2013,
- timeScope: [],
- isHighlight: false
- },
- top: {
- title: 'Top5',
- value: '5',
- options: [{
- label: 'Top5',
- value: '5',
- },
- {
- label: 'Top10',
- value: '10',
- },
- /*{
- label: this.$i18n.locale == 'zh' ? '全部' : 'All',
- value: 'All',
- },*/
- ],
- isHighlight: false
- },
- },
- /**
- * 图表
- */
- canvasType: 1,
- pixelRatio: 1,
- charts: {
- chartsTitle: null, // 头部展示的单位
- activeTitle: null, // 选择的类型
- activeType: {
- indexName: '人均GDP',
- indexEnName: 'GDP per capita',
- source: {
- "世界银行": {
- "index": {
- "人均GDP": "28"
- }
- }
- }
- },
- },
- submitSource: this.$i18n.locale == 'zh' ? '世界银行' : 'World Bank',
- exportDocument: [{
- value: 'EXCEL',
- label: 'Excel'
- }, {
- value: 'PDF',
- label: 'PDF'
- }, ],
- /**
- * 相关指标
- */
- correlationList: [{
- icon: require('@/static/img/infomationdata/e1.png'),
- "label": this.$i18n.locale == 'zh' ? '人均GDP' : 'GDP per capita',
- "item": {
- "indexName": "人均GDP",
- "indexEnName": "GDP per capita",
- "source": '{"世界银行":{"index":{"人均GDP":"28"}}}'
- }
- }],
- correlationIconList: [{
- icon: require('@/static/img/infomationdata/shehuijingji/jingji.png'),
- label: '基础经济'
- },
- {
- icon: require('@/static/img/infomationdata/shehuijingji/maoyi.png'),
- label: '贸易'
- },
- {
- icon: require('@/static/img/infomationdata/shehuijingji/renkou.png'),
- label: '人口'
- },
- {
- icon: require('@/static/img/infomationdata/shehuijingji/guotu.png'),
- label: '国土'
- },
- {
- icon: require('@/static/img/infomationdata/nengyuan/shengcheng.png'),
- label: '能源生产'
- },
- {
- icon: require('@/static/img/infomationdata/nengyuan/xiaofei.png'),
- label: '能源消费'
- },
- {
- icon: require('@/static/img/infomationdata/nengyuan/zhuanhua.png'),
- label: '能源转化'
- },
- {
- icon: require('@/static/img/infomationdata/dianli/fadianzhuangzhi.png'),
- label: '发电装机'
- },
- {
- icon: require('@/static/img/infomationdata/dianli/fadian.png'),
- label: '发电'
- },
- {
- icon: require('@/static/img/infomationdata/dianli/yongdian.png'),
- label: '用电'
- },
- {
- icon: require('@/static/img/infomationdata/qihou/huanjing.png'),
- label: '排放量'
- },
- ],
- exportId: [],
- exportPoll: ''
- }
- },
- created() {
- this.init()
- },
- async mounted() {
- _self = this;
- this.cWidth = uni.upx2px(750);
- this.cHeight = uni.upx2px(500);
- await this.getInitialCategory({
- "Source": [{
- "世界银行": {
- "index": {
- "人均GDP": "28"
- }
- }
- }],
- "time": [String(this.dropdown.time.time), String(this.dropdown.time.time)],
- "language": this.$i18n.locale,
- "type": {
- "rule": this.canvasType == 1 ? 'CIRCLE' : 'LINE',
- "top": this.dropdown.top.value
- }
- });
- },
- watch: {
- exportId(n, o) {
- let _this = this;
- if (_this.exportId.length > 0) {
- } else {
- this.loading = false
- }
- clearInterval(this.exportPoll)
- this.exportPoll = setInterval(() => {
- _this.exportId.forEach(item => {
- _this.getTime(item)
- })
- }, 2000)
- },
- searchItem(n, o) {
- let nodeId = n.item.nodeId.split('_')
- let item = this.dropdown.indicator.searchList
- let index = ''
- nodeId.forEach(it => {
- item = item[Number(it)]
- if (item.child && item.child.length && item.child.length !== 0) {
- item = item.child
- }
- index = Number(it)
- })
- this.getCategory1({
- item,
- index
- })
- }
- },
- methods: {
- async init() {
- await this.getServerData()
- },
- i18n(data) {
- return this.$t('common.' + data);
- },
- isJsonString(str) {
- try {
- if (typeof JSON.parse(str) == "object") {
- return true;
- }
- } catch (e) {}
- return false;
- },
- /**
- * 下拉菜单
- */
- open(index) {
- this.$forceUpdate()
- },
- close(index) {
- },
- // 类别
- async getServerData() {
- const res = await this.$myRequest({
- url: '/op/geiIntegratedDataMenus/getMenu',
- data: {}
- });
- this.dropdown.indicator.searchList = res.data;
- this.setIcon(this.dropdown.indicator.searchList)
- this.dropdown.indicator.showCategoryIndex = 0
- this.dropdown.indicator.searchSelect = res.data[0].child[0].child[2]
- this.dropdown.indicator.searchSelect.ifClick = true;
- },
- setIcon(data) {
- data.forEach(item => {
- this.correlationIconList.forEach(icon => {
- if (item.indexName == icon.label) {
- item.icon = icon.icon;
- }
- })
- if (item.child && item.child.length != 0) {
- this.setIcon(item.child)
- }
- })
- },
- // 日历选择
- getTimeValue(e) {
- console.log('e')
- console.log(e)
- this.dropdown.time.timeScope = e
- this.dropdown.time.time = e[0]
- this.dropdown.time.title = `${e[0]}`
- this.$refs.uDropdown.close()
- this.getCategory();
- },
- timeCancel(e) {
- this.$refs.uDropdown.close()
- },
- // top
- topChange(e) {
- this.dropdown.top.title = this.dropdown.top.options.filter(item => e == item.value)[0].label
- this.getCategory();
- },
- /**
- * 图表
- */
- canvasTypeChange(num) {
- this.canvasType = num;
- this.getCategory();
- },
- touchColumn(e) {
- canvasColumnIns.showToolTip(e, {
- format: function(item, category) {
- if (typeof item.data === 'object') {
- return category + '\n' + item.name + ':' + item.data.value
- let country = item.name.split(' ')
- this.textList = [{
- text: category
- }];
- country.forEach(it => {
- this.textList.push({
- text: it
- })
- })
- this.textList.push({
- text: item.data.value
- })
- } else {
- return category + '\n' + item.name + ':' + item.data
- let country = item.name.split(' ')
- this.textList = [{
- text: category
- }];
- country.forEach(it => {
- this.textList.push({
- text: it
- })
- })
- this.textList.push({
- text: item.data
- })
- }
- }
- });
- },
- touchLine(e) {
- canvasLineIns.showToolTip(e, {
- format: function(item, category) {
- return item.data
- }
- })
- },
- // 启用图表拖拽
- touchColumn2(e) {
- canvasColumnIns.scrollStart(e);
- },
- moveColumn2(e) {
- canvasColumnIns.scroll(e);
- },
- touchEndColumn2(e) {
- canvasColumnIns.scrollEnd(e);
- //下面是toolTip事件,如果滚动后不需要显示,可不填写
- canvasColumnIns.showToolTip(e, {
- format: function(item, category) {
- return category + ' ' + item.name + ':' + item.data
- }
- });
- },
- touchLine2(e) {
- canvasLineIns.scrollStart(e);
- },
- moveLine2(e) {
- canvasLineIns.scroll(e);
- },
- touchEndLine2(e) {
- canvasLineIns.scrollEnd(e);
- //下面是toolTip事件,如果滚动后不需要显示,可不填写
- canvasLineIns.showToolTip(e, {
- format: function(item, category) {
- return category + ' ' + item.name + ':' + item.data
- }
- });
- },
- async getInitialCategory(params) {
- const res = await this.$myRequest({
- url: '/op/geiIntegratedDataMenus/getTopN',
- data: {
- ...params
- },
- method: 'post',
- });
- if (res.data) {
- this.canvas(res.data);
- }
- this.getCorrelationList()
- this.$forceUpdate()
- },
- canvas(data) {
- this.charts.chartsTitle = data.unitY; // 头部展示的单位
- this.charts.activeTitle = this.$i18n.locale === 'zh' ? this.charts.activeType.indexName : this.charts
- .activeType.indexEnName; //选择的类型
- let series = [];
- let seriesItem = {};
- seriesItem = {
- "name": this.dropdown.time.time,
- "data": data.y
- }
- series.push(seriesItem);
- let Column = {
- "categories": data.x,
- "series": series
- };
- if (this.canvasType == 1) {
- this.showColumn('canvasColumn2', Column);
- } else {
- this.showLine("canvasLine2", Column);
- }
- },
- showColumn(canvasId, chartData) {
- canvasColumnIns = new uCharts({
- $this: _self,
- canvasId: canvasId,
- type: 'column',
- legend: {
- show: true
- },
- fontSize: 11,
- enableScroll: true, //开启图表拖拽功能
- background: '#FFFFFF',
- pixelRatio: _self.pixelRatio,
- animation: true,
- categories: chartData.categories,
- series: chartData.series,
- xAxis: {
- disableGrid: true,
- itemCount: 5, //x轴单屏显示数据的数量,默认为5个
- scrollShow: true, //新增是否显示滚动条,默认false
- scrollAlign: 'left', //滚动条初始位置
- scrollBackgroundColor: '#F7F7FF', //默认为 #EFEBEF
- scrollColor: '#DEE7F7', //默认为 #A6A6A6
- // rotateLabel:true
- },
- yAxis: {},
- dataLabel: false,
- width: _self.cWidth * _self.pixelRatio,
- height: _self.cHeight * _self.pixelRatio,
- extra: {
- column: {
- type: 'group',
- width: _self.cWidth * _self.pixelRatio * 0.45 / chartData.categories.length
- }
- }
- })
- },
- showLine(canvasId, chartData) {
- canvasLineIns = new uCharts({
- $this: _self,
- canvasId: canvasId,
- type: 'line',
- fontSize: 11,
- legend: {
- show: true
- },
- enableScroll: true, //开启图表拖拽功能
- dataLabel: false,
- dataPointShape: true,
- background: '#FFFFFF',
- pixelRatio: _self.pixelRatio,
- categories: chartData.categories,
- series: chartData.series,
- animation: true,
- xAxis: {
- type: 'grid',
- gridColor: '#CCCCCC',
- gridType: 'dash',
- dashLength: 8,
- itemCount: 5, //x轴单屏显示数据的数量,默认为5个
- scrollShow: true, //新增是否显示滚动条,默认false
- scrollAlign: 'left', //滚动条初始位置
- scrollBackgroundColor: '#F7F7FF', //默认为 #EFEBEF
- scrollColor: '#DEE7F7', //默认为 #A6A6A6
- },
- yAxis: {
- gridType: 'dash',
- gridColor: '#CCCCCC',
- dashLength: 8,
- splitNumber: 5,
- min: 10,
- max: 180,
- },
- width: _self.cWidth * _self.pixelRatio,
- height: _self.cHeight * _self.pixelRatio,
- extra: {
- line: {
- type: 'straight'
- }
- }
- });
- },
- // 点击事件
- getCategory() {
- // 数据优先级
- let item = this.dropdown.indicator.searchSelect
- this.getSubmitSource(item)
- let source = this.charts.activeType.source;
- if (this.isJsonString(this.charts.activeType.source)) {
- source = JSON.parse(this.charts.activeType.source)
- }
- let params = {
- "Source": [source],
- "time": [String(this.dropdown.time.time), String(this.dropdown.time.time)],
- "language": this.$i18n.locale,
- "type": {
- "rule": this.canvasType == 1 ? 'CIRCLE' : 'LINE',
- "top": this.dropdown.top.value
- }
- }
- this.getInitialCategory(params);
- this.$refs.uDropdown.close()
- },
- getCategory1({
- item,
- index,
- ifClick
- }) {
- this.dropdown.indicator.searchSelect.ifClick = false
- this.dropdown.indicator.searchSelect = item
- this.dropdown.indicator.title = this.$i18n.locale == 'zh' ? item.indexName : item.indexEnName
- item.ifClick = true
- this.$forceUpdate()
- this.charts.activeType = {
- indexName: item.indexName,
- indexEnName: item.indexEnName,
- source: item.source
- };
- this.getCategory()
- },
- empty() {
- if (this.dropdown.world.temp.countryId.length == 0) {
- this.dropdown.world.temp.countryId = JSON.parse(JSON.stringify(this.dropdown.world.countryId))
- this.dropdown.world.temp.countryName = JSON.parse(JSON.stringify(this.dropdown.world.countryName))
- }
- this.dropdown.world.countryList.forEach(item => {
- if (item.ifClick) {
- this.dropdown.world.temp.country.push(item)
- }
- item.ifClick = false;
- item.children.forEach(it => {
- if (it.ifClick) {
- this.dropdown.world.temp.country.push(it)
- }
- it.ifClick = false
- })
- })
- this.dropdown.world.countryId = ['93BC2730ED0A402186F596F6A01C007E']
- this.dropdown.world.countryName = this.$i18n.locale == 'zh' ? ['世界'] : ['World']
- this.$forceUpdate();
- },
- submit() {
- this.dropdown.world.temp = {
- country: [],
- countryId: [],
- countryName: []
- }
- _self.getCategory()
- },
- // 导出
- async selectExportType(data) {
- let _this = this
- this.loading = true
- let source = this.charts.activeType.source;
- if (this.isJsonString(this.charts.activeType.source)) {
- source = JSON.parse(this.charts.activeType.source)
- }
- let id = this.randomString(18)
- try {
- const resId = await this.$myRequest({
- url: '/op/geiIntegratedDataMenus/getRandomId',
- method: 'get',
- data: {
- uuid: id
- },
- });
- let params = {
- "Source": [source],
- "time": [String(this.dropdown.time.time), String(this.dropdown.time.time)],
- "language": _this.$i18n.locale,
- "type": {
- "rule": this.canvasType == 1 ? 'CIRCLE' : 'LINE',
- "top": this.dropdown.top.value
- }
- }
- const res = await this.$myRequest({
- url: '/op/geiIntegratedDataMenus/saveFile',
- data: {
- ...params
- },
- method: 'post',
- });
- if (res) {
- this.exportId.push({
- type: data,
- id: id
- })
- }
- } catch (e) {
- this.loading = false
- let eg = _this.$i18n.locale == 'zh' ? '失败请重新下载' : 'Please download again if failed'
- uni.showToast({
- icon: 'none',
- mask: true,
- title: eg,
- });
- }
- },
- async getTime(id) {
- let _this = this
- const res = await this.$myRequest({
- url: '/op/geiIntegratedDataMenus/getTime',
- method: 'get',
- data: {
- uuid: id.id
- },
- });
- if (res.data && res.status == '200') {
- let url = id.type.value == 'EXCEL' ? res.data[0] : res.data[1]
- this.exportId = this.exportId.filter(item => item.id != id.id)
- this.download(url)
- } else if (res.data && res.status == '500') {
- this.exportId = this.exportId.filter(item => item.id != id.id)
- let eg = _this.$i18n.locale == 'zh' ? '失败请重新下载' : 'Please download again if failed'
- uni.showToast({
- icon: 'none',
- mask: true,
- title: eg,
- });
- }
- },
- download(url) {
- let _this = this
- // this.playpapers(this.websiteUrl + url)
- uni.downloadFile({
- url: 'https://m.geidcp.com/api/file/pub/' + url,
- success: (data) => {
- if (data.statusCode === 200) {
- //文件保存到本地
- // #ifdef APP-PLUS
- uni.saveFile({
- tempFilePath: data.tempFilePath, //临时路径
- success: function(res) {
- let eg = _this.$i18n.locale == 'zh' ? '文件已保存:' :
- 'The file is saved:'
- uni.showToast({
- icon: 'none',
- mask: true,
- title: eg + res.savedFilePath, //保存路径
- duration: 3000,
- });
- setTimeout(() => {
- //打开文档查看
- uni.openDocument({
- filePath: res.savedFilePath,
- success: function(res) {
- // console.log('打开文档成功');
- }
- });
- }, 3000)
- }
- });
- // #endif
- } else {
- let eg = _this.$i18n.locale == 'zh' ? '失败请重新下载' : 'Please download again if failed'
- uni.showToast({
- icon: 'none',
- mask: true,
- title: eg,
- });
- }
- },
- fail: (err) => {
- let eg = _this.$i18n.locale == 'zh' ? '失败请重新下载' : 'Please download again if failed'
- uni.showToast({
- icon: 'none',
- mask: true,
- title: eg,
- });
- },
- });
- },
- playpapers(url) {
- let dload = document.createElement("a");
- dload.download = ''; // 设置下载的文件名,默认是'下载'
- dload.href = url;
- document.body.appendChild(dload);
- dload.click();
- dload.remove(); // 下载之后把创建的元素删除
- },
- randomString(length) {
- let str = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
- let result = '';
- for (let i = length; i > 0; --i)
- result += str[Math.floor(Math.random() * str.length)];
- return result;
- },
- // 重置按钮
- Reset() {
- this.$emit('reset', 1)
- },
- /**
- * 相关指标
- */
- getCorrelationList() {
- let select = _self.charts.activeType.indexName
- function getParent(data, parent) {
- data.forEach(item => {
- if (item.indexName == select) {
- _self.correlationList = parent.child.map(it => {
- return {
- icon: parent.icon,
- "label": _self.$i18n.locale == 'zh' ? it.indexName : it.indexEnName,
- "item": {
- "indexName": it.indexName,
- "indexEnName": it.indexEnName,
- "source": it.source
- }
- }
- })
- }
- if (item.child && item.child.length != 0) {
- getParent(item.child, item)
- }
- })
- }
- getParent(_self.dropdown.indicator.searchList, null)
- },
- showRelevant(e) {
- let ser = {}
- function getOther(data, source) {
- data.forEach(item => {
- if (item.source == source) {
- ser = item
- return
- } else {
- getOther(item.child, source)
- }
- })
- }
- getOther([this.dropdown.indicator.searchList[this.dropdown.indicator.showCategoryIndex]], e.item.source)
- ser.ifClick = true
- this.charts.activeType = {
- indexName: e.item.indexName,
- indexEnName: e.item.indexEnName,
- source: JSON.parse(e.item.source)
- }
- this.dropdown.indicator.title = this.$i18n.locale == 'zh' ? e.item.indexName : e.item.indexEnName
- this.dropdown.indicator.searchSelect.ifClick = false;
- this.dropdown.indicator.searchSelect = ser
- this.getCategory();
- },
- /**
- * 查询优先级
- */
- getSubmitSource(data) {
- let dataSources = [];
- let sources = JSON.parse(data.source);
- let sourceKeys = Object.keys(sources);
- sourceKeys.forEach(item => {
- dataSources.push({
- label: item,
- value: JSON.stringify({
- [item]: sources[item]
- })
- })
- })
- let buer = sourceKeys.indexOf("IEA") > -1 ? true : false;
- this.submitSource = '';
- if (buer == true) {
- let i = sourceKeys.indexOf("IEA")
- this.submitSource = "IEA";
- // 如果本条数据的dataSources里有IEA就使用IEA作为查询时使用的数据源
- this.charts.activeType["source"] = JSON.parse(dataSources[i].value);
- if (this.$i18n.locale == 'zh') {
- this.submitSource = '国际能源署'
- }
- } else {
- this.submitSource = sourceKeys[0]
- // 由于客户没有英国石油公司的数据使用权限,所以不能用英国石油公司的数据源查询
- this.charts.activeType["source"] = JSON.parse(dataSources[0].value);
- if (this.$i18n.locale == 'en') {
- this.submitSource = this.zhToen(this.submitSource)
- } else {
- this.submitSource = this.enTozh(this.submitSource)
- }
- }
- },
- zhToen(str) {
- switch (str) {
- case '世界银行':
- return 'World Bank';
- break;
- case '英国石油公司(BP)':
- return 'British Petroleum';
- break;
- case 'EIA':
- return 'Energy Information Administration';
- break;
- }
- },
- enTozh(str) {
- switch (str) {
- case 'IEA':
- return '国际能源署';
- break;
- case 'EIA':
- return '美国能源信息署';
- break;
- case '世界银行':
- return '世界银行';
- break;
- case '英国石油公司(BP)':
- return '英国石油公司';
- break;
- }
- },
-
- }
- }
- </script>
- <style scoped lang="scss">
- .indicatorDataQuery {
- width: 100%;
- height: 100%;
- }
- .u-dropdown /deep/ .u-dropdown__menu {
- width: 100%;
- overflow: hidden;
- }
- .u-dropdown /deep/ .u-dropdown__menu .u-dropdown__menu__item {
- width: 33%;
- background: #fff;
- }
- .u-dropdown /deep/ .u-dropdown__menu .u-dropdown__menu__item .u-flex {
- width: 100%;
- justify-content: center;
- }
- .u-dropdown /deep/ .u-dropdown__menu__item__text {
- overflow: hidden; //超出的文本隐藏
- text-overflow: ellipsis; //溢出用省略号显示
- white-space: nowrap; //溢出不换行
- //width: 80%;
- text-align: center;
- }
- /deep/ .u-dropdown .u-dropdown__content {
- .u-dropdown__content__popup {
- height: 100%;
- }
- }
- .left {
- position: absolute;
- height: 100%;
- top: 0;
- bottom: 0upx;
- width: 24%;
- left: 0upx;
- background: #F2F2F2;
- }
- .right {
- position: absolute;
- height: 100%;
- top: 0;
- bottom: 0upx;
- width: 76%;
- left: 24%;
- background-color: #fff;
- margin-left: 0;
- padding: 0 20upx;
- }
- .row {
- width: 100%;
- height: 90upx;
- display: flex;
- align-items: center;
- .text {
- width: 100%;
- position: relative;
- font-size: 28upx;
- display: flex;
- justify-content: center;
- color: #3c3c3c;
- text-align: center;
- .block {
- position: absolute;
- width: 0upx;
- left: 0;
- }
- }
- &.on {
- height: 90upx;
- background-color: #fff;
- .text {
- font-size: 30upx;
- color: #1677FD;
- .block {
- width: 6upx;
- height: 100%;
- left: 10upx;
- }
- }
- &:before {
- content: "";
- position: absolute;
- left: 10upx;
- width: 10upx;
- height: 60upx;
- background-color: rgba(22, 119, 253, 0.8);
- }
- }
- }
- .threemenu {
- display: flex;
- flex-wrap: wrap;
- }
- .getCategory {
- height: 90upx;
- line-height: 90upx;
- font-weight: 700;
- //color: #0079ef;
- }
- .cate {
- display: inline-block;
- width: 240upx;
- vertical-align: middle;
- margin-right: 20upx;
- }
- .cateText {
- padding: 10upx;
- margin: 10upx 20upx 10upx 0;
- display: inline-block;
- width: 240upx;
- vertical-align: middle;
- background: #f1f2f3;
- text-align: center;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- }
- .cateTextActive {
- padding: 10upx;
- margin: 10upx 20upx 10upx 0;
- display: inline-block;
- width: 240upx;
- vertical-align: middle;
- background-color: #0079ef;
- color: #fff;
- text-align: center;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- }
- .contry-btn {
- height: 50upx;
- display: inline-block;
- line-height: 50upx;
- }
- .dataSourcep {
- font-size: 28upx;
- color: #c1c1c1;
- line-height: 1.5em;
- margin: 0;
- }
- </style>
- <style scoped lang="scss">
- .chart-columns {
- display: flex;
- flex-direction: column !important;
- border-top: 20upx solid #fff
- }
- .chart-common-mt {
- margin-top: 10upx;
- }
- .chart-bg-white {
- background: #FFFFFF;
- }
- .chart-title-bar {
- padding: 10upx 2%;
- flex-wrap: nowrap;
- display: flex;
- align-items: center;
- justify-content: space-between;
- .changeChart {
- display: flex;
- align-items: center;
- }
- }
- .uCharts1 {
- padding: 10upx 20upx;
- background-color: #F1F2F4;
- font-size: 26upx;
- color: #333;
- }
- .uCharts2 {
- padding: 10upx 20upx;
- background-color: #E5F0FE;
- color: #1890FF;
- font-size: 26upx;
- }
- .export {
- width: 100upx;
- margin-left: 20upx;
- height: 60upx;
- &.loading {
- text-align: center;
- padding-top: 10upx;
- }
- /deep/.easy-select {
- width: 100% !important;
- height: 90% !important;
- margin-top: 5%;
- border: none;
- border: 0;
- color: #fff;
- background-color: #1777FE;
- font-size: 26upx;
- uni-input {
- padding: 0;
- text-align: center;
- font-size: 26upx;
- }
- .easy-select-suffix {
- display: none;
- }
- .easy-select-options {
- min-width: 0 !important;
- width: 100%;
- }
- .easy-select-options-item {
- padding: 0 10upx;
- }
- }
- }
- .charts {
- width: 750upx;
- height: 500upx;
- background-color: #FFFFFF;
- }
- .reset {
- width: 90%;
- margin: 0 auto 40upx;
- .u-btn--primary {
- border-radius: 60upx;
- background: linear-gradient(90deg, #33AFFF, #1777FE);
- font-size: 32upx;
- font-weight: 600;
- }
- }
- </style>
|