dataExportToolBase.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358
  1. <template>
  2. <view class="dataExportTool">
  3. <view class="relevant">
  4. <view class="relevantTitle">{{ $i18n.locale=='zh'?'已选择指标':'index of correlation' }}</view>
  5. <view class="page-section swiper">
  6. <view class="page-section-spacing">
  7. <swiper v-if="params.indicator.searchSelect.length>3" class="swiper" :interval="interval" :duration="duration" :display-multiple-items="4">
  8. <swiper-item v-for="(item,index) in params.indicator.searchSelect" :key="'iconitem'+index" @click="emitItem(item)">
  9. <view class="swiper-item">
  10. <view class="icon">
  11. <u-icon v-if="index == params.indicator.searchSelect.length-1" name="plus-circle-fill" color="#2979ff" size="28"></u-icon>
  12. <u-image :src="item.icon" mode="widthFix" alt="" width="100%"></u-image>
  13. </view>
  14. <view class="labeltext">{{item.label}}</view>
  15. </view>
  16. </swiper-item>
  17. </swiper>
  18. <view v-else class="swiper">
  19. <view style="width: 25%;height: 100%;display: inline-block;" v-for="(item,index) in params.indicator.searchSelect" :key="'iconitem'+index" @click="emitItem(item)">
  20. <view class="swiper-item">
  21. <view class="icon">
  22. <u-image :src="item.icon" mode="widthFix" alt="" width="100%"></u-image>
  23. </view>
  24. <view class="labeltext">{{item.label}}</view>
  25. </view>
  26. </view>
  27. </view>
  28. </view>
  29. </view>
  30. </view>
  31. <view class="relevant">
  32. <view class="relevantTitle">{{ $i18n.locale=='zh'?'已选择指标':'index of correlation' }}</view>
  33. <view class="page-section swiper">
  34. <view class="page-section-spacing">
  35. <swiper v-if="params.world.searchSelect.length>4" class="swiper" :interval="interval" :duration="duration" :display-multiple-items="4">
  36. <swiper-item v-for="(item,index) in params.indicator.searchSelect" :key="'iconitem'+index" @click="emitItem(item)">
  37. <view class="swiper-item">
  38. <view class="icon">
  39. <u-image :src="item.icon" mode="widthFix" alt="" width="100%"></u-image>
  40. </view>
  41. <view class="labeltext">{{item.label}}</view>
  42. </view>
  43. </swiper-item>
  44. </swiper>
  45. <view v-else class="swiper">
  46. <view style="width: 25%;height: 100%;display: inline-block;" v-for="(item,index) in params.world.searchSelect" :key="'iconitem'+index" @click="emitItem(item)">
  47. <view class="swiper-item">
  48. <view class="icon">
  49. <u-image :src="item.icon" mode="widthFix" alt="" width="100%"></u-image>
  50. </view>
  51. <view class="labeltext">{{item.label}}</view>
  52. </view>
  53. </view>
  54. </view>
  55. </view>
  56. </view>
  57. </view>
  58. <view class="relevant">
  59. <view class="relevantTitle">{{ $i18n.locale=='zh'?'已选择指标':'index of correlation' }}</view>
  60. <view class="page-section">
  61. </view>
  62. </view>
  63. <view class="btn">
  64. <button>{{i18n('export')}}EXCEL</button>
  65. <button>{{i18n('export')}}PDF</button>
  66. <button>{{i18n('reset')}}</button>
  67. </view>
  68. </view>
  69. </template>
  70. <script>
  71. let _self;
  72. let canvasColumnIns = null;
  73. let canvasLineIns = null;
  74. export default {
  75. name: "dataExportTool",
  76. data(){
  77. return {
  78. indicatorDots: true,
  79. autoplay: true,
  80. interval: 2000,
  81. duration: 500,
  82. params: {
  83. indicator:{
  84. searchSelect: [
  85. {
  86. icon:require('@/static/img/infomationdata/e1.png'),
  87. "label": this.$i18n.locale == 'zh'?'发电总量':'Total power generation',
  88. "item": {
  89. "indexName": "发电总量",
  90. "indexEnName": "Total power generation",
  91. "source": '{"IEA":{"index":{"发电总量":"132"}},"EIA":{"index":{"发电总量":"132"}}}'
  92. }
  93. },
  94. {
  95. icon:require('@/static/img/infomationdata/e1.png'),
  96. "label": this.$i18n.locale == 'zh'?'发电总量':'Total power generation',
  97. "item": {
  98. "indexName": "发电总量",
  99. "indexEnName": "Total power generation",
  100. "source": '{"IEA":{"index":{"发电总量":"132"}},"EIA":{"index":{"发电总量":"132"}}}'
  101. }
  102. },
  103. ],
  104. searchList: [],
  105. },
  106. world:{
  107. countryId:['93BC2730ED0A402186F596F6A01C007E'],
  108. countryName:this.$i18n.locale == 'zh' ? ['世界'] : ['World'],
  109. countryList: [
  110. {
  111. label: this.$i18n.locale=='zh'?'亚洲':'ASIA',
  112. labelEn: 'ASIA',
  113. children: [],
  114. },
  115. {
  116. label: this.$i18n.locale=='zh'?'非洲':'AFRICA',
  117. labelEn: 'AFRICA',
  118. children: [],
  119. },
  120. {
  121. label: this.$i18n.locale=='zh'?'欧洲':'EUROPE',
  122. labelEn: 'EUROPE',
  123. children: [],
  124. },
  125. {
  126. label: this.$i18n.locale=='zh'?'北美洲':'NORTH AMERICA',
  127. labelEn: 'NORTH AMERICA',
  128. children: [],
  129. },
  130. {
  131. label: this.$i18n.locale=='zh'?'南美洲':'SOUTH AMERICA',
  132. labelEn: 'SOUTH AMERICA',
  133. children: [],
  134. },
  135. {
  136. label: this.$i18n.locale=='zh'?'大洋洲':'OCEANIA',
  137. labelEn: 'OCEANIA',
  138. children: [],
  139. },
  140. ],
  141. originalCountryData:[],
  142. searchSelect: [
  143. {
  144. "label": this.$i18n.locale == 'zh'?'中国':'Total power generation',
  145. "item": {
  146. "indexName": "发电总量",
  147. "indexEnName": "Total power generation",
  148. "source": '{"IEA":{"index":{"发电总量":"132"}},"EIA":{"index":{"发电总量":"132"}}}'
  149. }
  150. },
  151. {
  152. "label": this.$i18n.locale == 'zh'?'韩国':'Total power generation',
  153. "item": {
  154. "indexName": "发电总量",
  155. "indexEnName": "Total power generation",
  156. "source": '{"IEA":{"index":{"发电总量":"132"}},"EIA":{"index":{"发电总量":"132"}}}'
  157. }
  158. }
  159. ],
  160. searchList: [],
  161. },
  162. time:{
  163. title: this.$i18n.locale == 'zh' ? '时间' : 'Time',
  164. showDateFlag: true,
  165. time:['2013','2014','2015','2016','2017','2018','2019','2020'],
  166. timeScope:[],
  167. isHighlight:false
  168. },
  169. },
  170. correlationIconList: [
  171. {
  172. icon:require('@/static/img/infomationdata/shehuijingji/jingji.png'),
  173. label:'基础经济'
  174. },
  175. {
  176. icon:require('@/static/img/infomationdata/shehuijingji/maoyi.png'),
  177. label:'贸易'
  178. },
  179. {
  180. icon:require('@/static/img/infomationdata/shehuijingji/renkou.png'),
  181. label:'人口'
  182. },
  183. {
  184. icon:require('@/static/img/infomationdata/shehuijingji/guotu.png'),
  185. label:'国土'
  186. },
  187. {
  188. icon:require('@/static/img/infomationdata/nengyuan/shengcheng.png'),
  189. label:'能源生产'
  190. },
  191. {
  192. icon:require('@/static/img/infomationdata/nengyuan/xiaofei.png'),
  193. label:'能源消费'
  194. },
  195. {
  196. icon:require('@/static/img/infomationdata/nengyuan/zhuanhua.png'),
  197. label:'能源转化'
  198. },
  199. {
  200. icon:require('@/static/img/infomationdata/dianli/fadianzhuangzhi.png'),
  201. label:'发电装机'
  202. },
  203. {
  204. icon:require('@/static/img/infomationdata/dianli/fadian.png'),
  205. label:'发电'
  206. },
  207. {
  208. icon:require('@/static/img/infomationdata/dianli/yongdian.png'),
  209. label:'用电'
  210. },
  211. {
  212. icon:require('@/static/img/infomationdata/qihou/huanjing.png'),
  213. label:'排放量'
  214. },
  215. ]
  216. }
  217. },
  218. created(){
  219. this.init()
  220. },
  221. async mounted(){
  222. _self = this;
  223. this.cWidth = uni.upx2px(750);
  224. this.cHeight = uni.upx2px(500);
  225. },
  226. methods:{
  227. async init() {
  228. await this.getServerData()
  229. await this.getCountryList()
  230. },
  231. i18n(data) {
  232. return this.$t('common.' + data);
  233. },
  234. isJsonString(str) {
  235. try {
  236. if (typeof JSON.parse(str) == "object") {
  237. return true;
  238. }
  239. } catch(e) {
  240. }
  241. return false;
  242. },
  243. // 类别
  244. async getServerData() {
  245. const res = await this.$myRequest({
  246. url: '/op/geiIntegratedDataMenus/getMenu',
  247. data: {}
  248. });
  249. this.params.indicator.searchList = res.data;
  250. this.setIcon(this.params.indicator.searchList)
  251. },
  252. setIcon(data){
  253. data.forEach(item=>{
  254. this.correlationIconList.forEach(icon=>{
  255. if(item.indexName == icon.label){
  256. item.icon = icon.icon;
  257. }
  258. })
  259. if(item.child && item.child.length!=0){
  260. this.setIcon(item.child)
  261. }
  262. })
  263. },
  264. // 国家/地区
  265. async getCountryList() {
  266. this.params.world.originalCountryData = this.$i18n.locale === 'zh'?
  267. await this.$api.json('originalCountryDataZH'):
  268. await this.$api.json('originalCountryDataEN');
  269. this.params.world.countryList.forEach(originalItem=>{
  270. this.params.world.originalCountryData.forEach((item, j) => {
  271. if(item.COUNTRY_EN_NAME === originalItem.labelEn){
  272. originalItem.COUNTRY_ID = item.COUNTRY_ID;
  273. originalItem.COUNTRY_CN_NAME = item.COUNTRY_CN_NAME;
  274. originalItem.COUNTRY_EN_NAME = item.COUNTRY_EN_NAME;
  275. originalItem.ifClick = false;
  276. }
  277. if(item.CONTINENT_EN_NAME === originalItem.labelEn){
  278. item.value = item.COUNTRY_ID;
  279. item.label = this.$i18n.locale == 'zh' ? item.COUNTRY_CN_NAME : item.COUNTRY_EN_NAME;
  280. item.ifClick = false;
  281. originalItem.children.push(item);
  282. }
  283. })
  284. })
  285. },
  286. countryFilter(array,flag){
  287. return array.filter(item=>item.ifClick===flag)
  288. },
  289. emitItem(item){
  290. }
  291. }
  292. }
  293. </script>
  294. <style scoped lang="scss">
  295. .swiper-item{
  296. font-size:26upx;
  297. /*margin:20upx 20upx;*/
  298. text-align:center;
  299. cursor:pointer;
  300. width: 100%;
  301. height: 100%;
  302. padding: 0 20%;
  303. box-sizing: border-box;
  304. .icon{
  305. position:relative;
  306. overflow:hidden;
  307. max-width:100upx;
  308. margin:20upx auto 10upx;
  309. img{
  310. display:block;
  311. width:100%;
  312. }
  313. }
  314. .labeltext{
  315. width:100%;
  316. //overflow:hidden;
  317. //text-overflow:ellipsis;
  318. //white-space: nowrap;
  319. word-break: break-all;
  320. text-overflow: ellipsis;
  321. overflow: hidden;
  322. display: -webkit-box;
  323. -webkit-line-clamp: 2;
  324. -webkit-box-orient: vertical;
  325. }
  326. }
  327. .relevantTitle{
  328. padding:20upx;
  329. position:relative;
  330. overflow:hidden;
  331. text-indent:10upx;
  332. }
  333. .relevantTitle:after{
  334. content:"";
  335. width:6upx;
  336. height:30upx;
  337. background:#1777FE;
  338. position:absolute;
  339. left:10upx;
  340. top:50%;
  341. text-indent:8upx;
  342. margin-top:-18upx;
  343. }
  344. .dataExportTool /deep/.swiper {
  345. display: block;
  346. height: 120px;
  347. }
  348. .btn{
  349. .uni-button{
  350. display: inline-block;
  351. }
  352. }
  353. </style>