123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769 |
- <template>
- <view class="">
- <navbar-search :list="categoryList" @selectedItem="getSelectedItem"></navbar-search>
- <!-- 筛选 -->
- <view class="selectCondition">
- <u-dropdown ref="uDropdown" @open="open">
- <!-- 指标 -->
- <u-dropdown-item :title="$i18n.locale=='zh'?'指标':'indicator'">
- <view class="slot-content">
- <!-- 选择指标 -->
- <view style="height:1168upx;position: relative;">
- <scroll-view scroll-y="true" class="left">
- <view class="row" v-for="(fItem, fIndex) in categoryList" :key="fItem.id" :class="[fIndex===showCategoryIndex ?'on':'']" @tap="showCategory(fIndex)">
- <view class="text" :style="$i18n.locale=='zh'?'':'text-algin:center;'">{{ $i18n.locale=='zh'?fItem.indexName:fItem.indexEnName }}</view>
- </view>
- </scroll-view>
- <scroll-view scroll-y="true" class="right">
- <view v-for="(fItem, fIndex) in categoryList" :key="fItem.id" @tap="showCategory(fIndex)">
- <view v-if="fIndex === showCategoryIndex" class="category">
- <view v-for="(item,index) in fItem.child" :key="'c'+index" @click="getCategory2(item,index)" :class="item.child.length>0?'':'cateText'">
- <view :class="{'getCategory2':item.child.length>0,'nosumenu':item.child.length==0}"
- :style="item.child.length>0?'font-weight:700;color:#0079ef':'height:90upx;line-height:90upx;font-weight:400;'">
- {{ $i18n.locale=='zh'?item.indexName:item.indexEnName }}
- </view>
- <view class="threemenu">
- <view v-for="(i,j) in item.child" :key="j" class="cateText" @click="getCategory(item,i,index,j)"
- :class="{'active':cThreeSubmenu===j && index===cTwoSubmenu}"> {{$i18n.locale=='zh'?i.indexName:i.indexEnName}}
- </view>
- </view>
- </view>
- </view>
- </view>
- </scroll-view>
- </view>
- </view>
- </u-dropdown-item>
- <!-- 世界 -->
- <u-dropdown-item :title="$i18n.locale=='zh'?'世界':'world'" >
- <view class="slot-content">
- <view style="height:1168upx;position: relative;">
- <scroll-view scroll-y="true" class="left">
- <view class="row" v-for="(fItem, fIndex) in countryList" :key="fItem.id" :class="[fIndex === showCountryIndex ? 'on' : '']"
- @tap="showCategory2(fIndex)">
- <view class="text">{{ $i18n.locale=='zh'?fItem.label:fItem.labelEn }}</view>
- </view>
- </scroll-view>
- <scroll-view scroll-y="true" class="right">
- <view v-for="(fItem, fIndex) in countryList" :key="'fItem' + fIndex" @tap="showCategory2(fIndex)">
- <view v-if="fIndex === showCountryIndex && fItem.children" class="category">
- <view v-for="(item,index) in fItem.children" :key="index"
- @click="getCategory2(item,index)" :class="item.length>0?'':'cate'" >
- <view class=""><text :class="item.ifClick?'cateText3':'cateText2'" @click="getCountryId(item,index)">{{item.label}}</text>
- </view>
- </view>
- </view>
- </view>
- </scroll-view>
- </view>
- </view>
- </u-dropdown-item>
- <!-- 时间 -->
- <u-dropdown-item :title="$i18n.locale=='zh'?'时间':'time'" >
- <view class="slot-content" >
- <!-- 时间选择 -->
- <view class="date" style="height:1168upx;position:relative;background:#fff">
- <!-- <u-calendar v-model="showDateFlag"-->
- <!-- :mode="'range'"-->
- <!-- :start-text="i18n('resourceStart')"-->
- <!-- :end-text="i18n('resourceEnd')"-->
- <!-- @change="change"></u-calendar>-->
- <calendar v-model="showDateFlag"
- @change="change"
- mode="range"
- :start-text="i18n('resourceStart')" :end-text="i18n('resourceEnd')" :toolTip="i18n('resourceSelectTime')" max-date="2030-12-31"
- :range-color="'#2979ff'" :range-bg-color="'rgba(41,121,255,0.13)'" :active-bg-color="'#2979ff'" :btn-type="'primary'"
- :textzhi="$i18n.locale=='zh'?'至':' To '"
- >
- </calendar>
- </view>
- </view>
- </u-dropdown-item>
- </u-dropdown>
- </view>
- <!-- 图表区域 -->
- <view class="qiun-columns">
- <!-- 按钮区 -->
- <view class="qiun-bg-white qiun-title-bar qiun-common-mt" >
- <!-- 标题 -->
- <view class="qiun-title-dot-light">{{title}} </view>
- <!-- 切换线/柱图 -->
- <view class="changechart">
- <text :class="canvasType==1?'uChars2':'uChars1'" @click="canvasTypeChange(1)">{{i18n('ColumnChart')}} </text>
- <text :class="canvasType==2?'uChars2':'uChars1'" @click="canvasTypeChange(2)">{{i18n('LineChart')}} </text>
- </view>
- </view>
- <!-- 图表 -->
- <view class="qiun-charts" >
- <canvas v-if="canvasType==1" canvas-id="canvasColumn" id="canvasColumn" class="charts" @touchstart="touchColumn"></canvas>
- <canvas v-else canvas-id="canvasLineA" id="canvasLineA" class="charts" @touchstart="touchLineA"></canvas>
- </view>
- <!-- 重置按钮 -->
- <view class="reset">
- <u-button type="primary" @click="Reset">{{i18n('Reset')}}</u-button>
- </view>
- </view>
- <RelevantIndicators :dataList="dataList"></RelevantIndicators>
- <u-toast ref="uToast" />
- </view>
- </template>
- <script>
- import uCharts from '@/static/js/u-charts.js';
- import viewpoint from '../../conference/meetingIndexCh/viewpoint.vue';
- import RelevantIndicators from './dom/RelevantIndicators.vue'
- import navbarSearch from './dom/navbarSearch.vue'
- import calendar from "../../resourceSharing/calendar";
- var _self;
- var canvaColumn=null;
- var canvaLineA = null;
- export default {
- components: {
- viewpoint,
- RelevantIndicators,
- navbarSearch,
- calendar
- },
- data() {
- return {
- show1:false,
- show2:false,
- showDateFlag:true,
- yearStartShow:false,
- cWidth:'',
- cHeight:'',
- pixelRatio:1,
- serverData:'',
- plus:false,
- dataList:[
- // {
- // icon:require('../../../static/img/infomationdata/e1.png'),
- // label:'核发电总量'
- // },{
- // icon:require('../../../static/img/infomationdata/e2.png'),
- // label:'电力'
- // },{
- // icon:require('../../../static/img/infomationdata/e3.png'),
- // label:'风发电总量'
- // },{
- // icon:require('../../../static/img/infomationdata/e2.png'),
- // label:'水发电总量'
- // },{
- // icon:require('../../../static/img/infomationdata/e2.png'),
- // label:'其他发电总量'
- // }
- ],
- list: [
- ],
- cTwoSubmenu:-1,
- cThreeSubmenu:-1,
- background:{
- backgroundImage: 'linear-gradient(270deg, #4BC0E2 0%, #538BE7 100%)',
- },
- backStyle:{
- color:'#fff'
- },
- categoryList:[],
- showCategoryIndex: 0, // 一级菜单高亮显示序号
- CategoryList:{
- },
- title:null,// 头部展示的单位
- activeTitle:null,//选择的类型
- canvasType:1,// 控制显示柱形或折线
- countryName:[],
- cancelText:this.$t('common.Back'),
- submit:this.$t('common.submit'),
- activeType:{
- indexName:'发电总量',
- indexEnName:'Total power generation',
- source:{
- "IEA":{
- "index":{
- "发电总量":"132",
- },
- },
- }
- },
- countryId:[],
- TimeType:null,
- startTime:2013,
- endTime:2020,
- time:['2013','2014','2015','2016','2017','2018','2019','2020'],
- params: {
- year: true,
- month: false,
- day: false,
- hour: false,
- minute: false,
- second: false
- },
- showCountryIndex:0,
- countryList:[
- {
- label:'亚洲',
- labelEn:'Asia',
- children:[],
- },
- {
- label:'非洲',
- children:[],
- labelEn:'Africa'
- },
- {
- label:'欧洲',
- children:[],
- labelEn:'Europe'
- },
- {
- label:'北美洲',
- children:[],
- labelEn:'Northamerica'
- },
- {
- label:'南美洲',
- children:[],
- labelEn:'Southamerica'
- },
- {
- label:'大洋洲',
- children:[],
- labelEn:'Oceania'
- },
- ],
- selectedItem: '',
- }
- },
- onLoad() {
- _self = this;
- if(this.$i18n.locale=='zh'){
- this.countryName=['世界']
- }else {
- this.countryName=['WORLD']
- }
- this.cWidth=uni.upx2px(750);
- this.cHeight=uni.upx2px(500);
- this.getServerData();
- this.getCountryList();
- },
- // 监听日期选择器关闭
- watch:{
- },
- methods: {
- showCategory(index) {
- this.showCategoryIndex = index;
- },
- showCategory2(index) {
- this.showCountryIndex = index;
- },
- yearStartShowChange(type){
- this.yearStartShow = true;
- this.TimeType = type;
- },
- canvasTypeChange(num){
- this.canvasType = num;
- this.getCategory(null,this.activeType);
- },
- timeBack(e){
- console.log(e)
- if(this.TimeType=='start'){
- this.startTime = e.year;
- }else {
- this.endTime = e.year;
- }
- if(this.startTime-0 >this.endTime-0 || (this.endTime -0 ) - (this.startTime - 0)>7){
- this.$refs.uToast.show({
- title: this.$i18n.locale=='zh'?'请正确选择时间,时间段为7年内':'Please select the right time period within 7 years',
- type: 'error',
- });
- this.startTime = (this.endTime -0 ) - 7;
- this.endTime = (this.startTime -0 ) + 7;
- }
- let timeArr = [];
- this.time = [];
- for(let i=0; i<= Number(this.endTime)-Number(this.startTime); i++){
- timeArr.push(String(Number(this.startTime)+i))
- }
- this.time = timeArr;
- this.getCategory(null,this.activeType);
- },
- Reset(){
- uni.redirectTo({
- url: '/pages/information/InformationData/InformationData'
- });
- },
- plusChange(){
- this.plus=!this.plus;
- if(this.plus){
- plus.screen.lockOrientation('landscape-primary');//横屏
- this.Reset();
- }else {
- plus.screen.lockOrientation('portrait-primary');//竖屏
- }
- },
- i18n (data) {
- return this.$t('common.' + data);
- },
- getDataList(num){
- if(num==1){
- this.show1 = true;
- }else {
- this.show2 = true;
- }
- },
- getCategory(item,i,index,j){
- console.log(1)
- this.activeType=i;
- let source =typeof(this.activeType.source)!=='string'?JSON.stringify(this.activeType.source):this.activeType.source;
- let params={
- "Source":JSON.parse(source),
- "country":this.countryId.length>0?this.countryId:["93BC2730ED0A402186F596F6A01C007E"],
- "time":this.time,
- "language":this.$i18n.locale,
- }
- this.show1=false;
- this.show2=false;
- this.getInitialCategory(params);
- this.cTwoSubmenu = index;
- this.cThreeSubmenu = j;
- this.close(index)
- },
- getCategory2(item,index){
- console.log(1)
- if(item?.child?.length>0){
- return;
- }else {
- this.activeType=item;
- let source =typeof(this.activeType.source)!=='string'?JSON.stringify(this.activeType.source):this.activeType.source;
- let params={
- "Source":JSON.parse(this.activeType.source),
- "country":this.countryId.length>0?this.countryId:["93BC2730ED0A402186F596F6A01C007E"],
- "time":this.time,
- "language":this.$i18n.locale,
- }
- this.show1=false;
- this.getInitialCategory(params);
- }
- },
- async getCountryList(){
- let originalCountryData = await this.$api.json('originalCountryData');
- this.$nextTick(function(){
- let countryList=this.countryList;
- originalCountryData.forEach((originalItem,index)=>{
- countryList.forEach((item,j) =>{
- if(originalItem.CONTINENT_NAME == item.label){
- originalItem.value=originalItem.COUNTRY_ID;
- originalItem.label=this.$i18n.locale=='zh'?originalItem.COUNTRY_CN_NAME:originalItem.COUNTRY_EN_NAME;
- this.$set(originalItem,'ifClick',false);
- item.children.push(originalItem);
- item.value=originalItem.COUNTRY_EN_NAME;
- }
- })
- });
- this.list = countryList;
- })
- },
- getCountryId(item,index){
- item.ifClick=!item.ifClick;
- if(item.ifClick==true){
- this.countryId.push(item.value);
- if(this.countryName[0]=='世界'){
- this.countryName=[];
- }
- this.countryName.push(item.label);
- }else {
- console.log(this.countryId);
- const y = this.countryId.indexOf(item.value);
- this.countryId.splice(y,1);
- this.countryName.splice(y,1);
- }
- this.getCategory(0,this.activeType)
- },
- async getServerData(){
- const res = await this.$myRequest({
- url: '/op/geiIntegratedDataMenus/getMenu',
- data: {}
- });
- this.categoryList= res.data;
- let params = {
- "Source":{
- "IEA":{
- "index":{'发电总量':"132"},
- },
- },
- "country":["93BC2730ED0A402186F596F6A01C007E"],
- "time":this.time,
- "language":this.$i18n.locale,
- }
- this.getInitialCategory(params);
- },
- async getInitialCategory(params){
- const res = await this.$myRequest({
- url: '/op/geiIntegratedDataMenus/getChartData',
- data: {...params},
- method:'post',
- type:'payload'
- });
- if(res.data){
- this.canvas(res.data);
- }
- },
- canvas(data){
- this.title=data[0].unitY;// 头部展示的单位
- this.activeTitle=this.$i18n.locale=='zh'?this.activeType.indexName:this.activeType.indexEnName;//选择的类型
- let series = [];
- let seriesItem = {};
- data.forEach((item,index)=>{
- seriesItem = {
- "name": this.countryName[index],
- "data":item.y
- }
- series.push(seriesItem);
- })
- let Column = {
- "categories": data[0].x,
- "series": series
- };
- if(this.canvasType==1){
- this.showColumn('canvasColumn', Column);
- }else {
- this.showLineA("canvasLineA", Column);
- }
- },
- showColumn(canvasId,chartData){
- canvaColumn=new uCharts({
- $this:_self,
- canvasId: canvasId,
- type:'column',
- legend:{show:true},
- fontSize:11,
- background:'#FFFFFF',
- pixelRatio:_self.pixelRatio,
- animation: true,
- categories: chartData.categories,
- series: chartData.series,
- xAxis: {
- disableGrid: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
- }
- }
- })
- console.log(canvaColumn)
- },
- showLineA(canvasId, chartData) {
- canvaLineA=new uCharts({
- $this:_self,
- canvasId: canvasId,
- type: 'line',
- fontSize:11,
- legend:{show: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
- },
- 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'
- }
- }
- });
- },
- touchLineA(e) {
- canvaLineA.showToolTip(e,{
- format: function(item, category) { return item.data }
- })
- },
- touchColumn(e){
- canvaColumn.showToolTip(e, {
- format: function (item, category) {
- if(typeof item.data === 'object'){
- return category + ' ' + item.name + ':' + item.data.value
- }else {
- return category + ' ' + item.name + ':' + item.data
- }
- }
- });
- },
- openPropDialog(payload){
- },
- //下拉菜单打开触发回调
- open(index) {
- // if(index===2) this.showDateFlag=true;
- // else this.showDateFlag=false
- if(index===2) this.showDateFlag=true;
- this.$refs.uDropdown.highlight();
- console.log(this.showDateFlag)
- },
- //下拉菜单关闭触发回调
- close(index){
- setTimeout(()=>{
- this.$refs.uDropdown.close();
- this.cTwoSubmenu = -1;
- this.cThreeSubmenu = -1;
- },100)
- this.$refs.uDropdown.highlight(index);
- },
- //日期选择器
- change(e) {
- console.log(e);
- },
- // 获取列表选中值
- getSelectedItem(value) {
- this.selectedItem = value
- },
- }
- }
- </script>
- <style lang="scss" scoped>
- uni-page-body{
- padding-top:0;
- }
- page{
- background:#fff;
- width:750upx;
- overflow-x:hidden;
- height:100%;
- padding-bottom:20upx;
- overflow:hidden;
- }
- .qiun-padding{padding:2%; width:96%;}
- .qiun-wrap{display:flex; flex-wrap:wrap;}
- .qiun-rows{display:flex; flex-direction:row !important;}
- .qiun-columns{display:flex; flex-direction:column !important;border-top:20upx solid #f6f6f6}
- .qiun-common-mt{margin-top:10upx;}
- .qiun-bg-white{background:#FFFFFF;}
- .qiun-title-bar{
- padding:10upx 2%; flex-wrap:nowrap;display:flex;align-items:center;
- justify-content: space-between;
- .changechart{
- display:flex;
- align-items:center;
- }
- }
- .qiun-title-dot-light{padding-left: 10upx; font-size: 28upx;color: #aaa;width:50%;}
- .qiun-charts{width: 750upx; height:500upx;background-color: #FFFFFF;}
- .charts{width: 750upx; height:500upx;background-color: #FFFFFF;}
- .qiun-charts {
- width: 750upx;
- height: 500upx;
- background-color: #FFFFFF;
- }
- .uChars1 {
- padding: 10upx 20upx;
- background-color:#F1F2F4;
- font-size:26upx;
- color:#333;
- }
- .uChars2 {
- padding: 10upx 20upx;
- background-color: #E5F0FE;
- color: #1890FF;
- font-size:26upx;
- }
- .charts {
- width: 750upx;
- height: 500upx;
- background-color: #FFFFFF;
- }
- .data-text {
- margin:0 40upx;
- height: 100upx;
- line-height: 100upx;
- border-top:1px solid #f1f2f3;
- border-bottom:1px solid #f1f2f3;
- }
- .data-text2 {
- line-height: 50px;
- border-top:1px solid #f1f2f3;
- border-bottom:1px solid #f1f2f3;
- }
- .data-text:active {
- background-color: #f2f2f2;
- }
- .cate {
- display: inline-block;
- width: 240upx;
- vertical-align: middle;
- margin-right: 20upx;
- }
- .cateText2 {
- padding: 10upx;
- margin: 10upx 20upx 10upx 0;
- display: inline-block;
- width: 240upx;
- vertical-align: middle;
- background: #f1f2f3;
- text-align: center;
- }
- .cateText3 {
- padding: 10upx;
- margin: 10upx 20upx 10upx 0;
- display: inline-block;
- width: 240upx;
- vertical-align: middle;
- background-color: #0079ef;
- color: #fff;
- text-align: center;
- }
- .cateText :active{
- color: red;
- }
- .data-year {
- padding: 20upx 30upx;
- }
- .left,
- .right {
- position: absolute;
- height:100%;
- top:0;
- bottom: 0upx;
- }
- .left {
- width: 24%;
- left: 0upx;
- background:#F2F2F2;
- }
- .right {
- 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;
- }
- }
- }
- }
- // .cateText {
- // padding:20upx 0;
- // border:1px solid #f2f2f2;
- // &.active{
- // border:1px solid #1777FE;
- // color:#1777FE;
- // background:#fff;
- // }
- // }
- .threemenu{
- display:flex;
- flex-wrap:wrap;
- .cateText{
- margin:0 20upx 20upx 0;
- background:#F2F2F2;
- padding:20upx;
- border-radius:8upx;
- width:46%;
- overflow:hidden;
- text-overflow:ellipsis;
- white-space: nowrap;
- text-align:center;
- &.active{
- border:1px solid #1777FE;
- color:#1777FE;
- background:#fff;
- }
- }
- }
- .getCategory2{
- height:90upx;
- line-height:90upx;
- font-weight:700;
- color:#0079ef
- }
- // 重置按钮
- .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;
- }
- }
- // 筛选
- .selectCondition{
- position: relative;
- ::v-deep .u-dropdown__content{
- border-top:2upx solid #eaeaea !important;
- }
- }
- </style>
|