index.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612
  1. <!--
  2. * @LastEditors: wangcc
  3. -->
  4. <template>
  5. <div class>
  6. <Map></Map>
  7. <Header></Header>
  8. <section class="nav-wrap">
  9. <div
  10. class="nav-item"
  11. :class="{active:(index+1)==page}"
  12. v-for="(item,index) in navList"
  13. @click="navClick(index+1)"
  14. :key="index"
  15. >{{item.text}}</div>
  16. </section>
  17. <Alarm v-if="page==6&&alarmData.length>=1" :data="alarmData" />
  18. <section class="left-wrap" v-if="$store.state.addr.page=='forest'">
  19. <Numerical class :data="page1numerical" />
  20. <MyEcharts
  21. class="blur-wrap u-p-t"
  22. mid="page1Char1"
  23. ref="page1Char1"
  24. :option="page1Char1"
  25. height="30vh"
  26. style="padding-left:20px"
  27. />
  28. <MyEcharts
  29. class="blur-wrap u-m-t u-p-t"
  30. mid="page1Char2"
  31. ref="page1Char2"
  32. :option="page1Char2"
  33. height="30vh"
  34. style="padding-left:20px"
  35. />
  36. </section>
  37. <section class="left-wrap" v-if="$store.state.addr.page=='treeSpecies'">
  38. <MyEcharts
  39. class="blur-wrap u-p-t"
  40. mid="page2Char1"
  41. :option="page2Char1"
  42. ref="page2Char1"
  43. height="30vh"
  44. />
  45. <MyEcharts
  46. class="blur-wrap u-m-t u-p-t"
  47. mid="page2Char2"
  48. :option="page2Char2"
  49. ref="page2Char2"
  50. height="40vh"
  51. />
  52. </section>
  53. <!-- 林业经济 -->
  54. <section class="left-wrap" v-if="$store.state.addr.page=='economics'">
  55. <Typeslide :data="typeSlideData" />
  56. <Numerical class :data="page5numerical" />
  57. <MyEcharts
  58. class="blur-wrap u-p-t"
  59. mid="page5Char1"
  60. ref="page5Char1"
  61. :option="page5Char1"
  62. height="30vh"
  63. />
  64. <MyEcharts
  65. class="blur-wrap u-m-t u-p-t"
  66. mid="page5Char2"
  67. ref="page5Char2"
  68. :option="page5Char2"
  69. height="30vh"
  70. />
  71. </section>
  72. <!-- 事件信息 -->
  73. <section class="left-wrap" v-if="$store.state.addr.page=='event'">
  74. <Numerical class :data="page6numerical" />
  75. <MyEcharts
  76. class="blur-wrap u-p-t"
  77. mid="page6Char1"
  78. ref="page6Char1"
  79. :option="page6Char1"
  80. height="30vh"
  81. />
  82. </section>
  83. <section class="right-wrap">
  84. <PickerAddr />
  85. <div class="xiaoban u-flex">
  86. <div class="title">小班查询:</div>
  87. <el-input v-model="xiaobaninput" placeholder="请输入小班号">
  88. <i class="el-icon-search el-input__icon" slot="suffix" @click="xiaobansearch"></i>
  89. </el-input>
  90. </div>
  91. <section class="scroll-board-wrap blur-wrap">
  92. <dv-scroll-board
  93. :key="scrollBoardKey"
  94. class="scroll-board-01"
  95. :config="scrollBoardConfig"
  96. ref="scrollBoard"
  97. @click="scrollBoardClick"
  98. :style="scrollBoardStyle"
  99. />
  100. </section>
  101. </section>
  102. </div>
  103. </template>
  104. <script>
  105. import Map from '../components/amap.vue';
  106. import Header from '../components/header';
  107. import MyEcharts from '../components/echarts';
  108. import Numerical from '../components/numerical';
  109. import Alarm from '../components/alarm';
  110. import PickerAddr from '../components/pickerAddr';
  111. import Typeslide from '../components/typeslide';
  112. import { Message } from 'element-ui';
  113. import { debounce } from '@/utils/mdebounce';
  114. import { sliceArray } from '@/utils/sliceArray';
  115. import {
  116. page1numerical,
  117. page1echarts01,
  118. page1echarts02,
  119. rightScrollData,
  120. alarmDataApi,
  121. page2echarts01,
  122. page2echarts02,
  123. page5numerical,
  124. typeSlideApi,
  125. page5echarts01,
  126. page5echarts02,
  127. page6numerical,
  128. page6echarts01,
  129. smallClassMap
  130. } from '../service/index';
  131. import scrollBoardSchema from '../dataSchema/scrollBoardSchema';
  132. import page1Char1Schema from '../dataSchema/page1Char1Schema';
  133. import page1Char2Schema from '../dataSchema/page1Char2Schema';
  134. import page2Char1Schema from '../dataSchema/page2Char1Schema';
  135. import page2Char2Schema from '../dataSchema/page2Char2Schema';
  136. import page6Char1Schema from '../dataSchema/page6Char1Schema';
  137. // import { provinceAndCityData, regionData, provinceAndCityDataPlus, regionDataPlus, CodeToText, TextToCode } from 'element-china-area-data';
  138. export default {
  139. name: '',
  140. components: {
  141. Map,
  142. Header,
  143. MyEcharts,
  144. Numerical,
  145. Alarm,
  146. PickerAddr,
  147. Typeslide
  148. },
  149. data() {
  150. return {
  151. page: 1,
  152. // addrOptions: regionDataPlus,
  153. addrSelectedOptions: ['520000', ''],
  154. navList: [
  155. { text: '森林资源', en: 'forest' },
  156. { text: '林木结构', en: 'treeSpecies' },
  157. { text: '碳汇管理', en: 'sink' },
  158. { text: '林下经济', en: 'economics' },
  159. { text: '土地流转', en: 'circulation' },
  160. { text: '事件信息', en: 'event' }
  161. ],
  162. scrollBoardKey: Date.now(),
  163. scrollBoardStyle: {
  164. width: '100%',
  165. height: '72vh'
  166. },
  167. scrollBoardConfig: scrollBoardSchema,
  168. page1numerical: [
  169. { name: '蓄积量', number: '2309', unit: '立方米' },
  170. { name: '占地面积', number: '55.4', unit: '万亩' }
  171. ],
  172. alarmData: [
  173. // {msg:'三都林场01小班于15:00:00发现火情,请尽快处理!'},
  174. // {msg:'测试1!'},
  175. // {msg:'测试22222222!'},
  176. ],
  177. page1Char1: page1Char1Schema,
  178. page1Char2: page1Char2Schema,
  179. page2Char1: page2Char1Schema,
  180. page2Char2: page2Char2Schema,
  181. page5numerical: [],
  182. typeSlideData: [],
  183. page5Char1: {},
  184. page5Char2: {},
  185. page6numerical: [],
  186. page6Char1: page6Char1Schema,
  187. xiaobaninput: ''
  188. };
  189. },
  190. created() {},
  191. mounted() {
  192. this.getPageData();
  193. this.getRightScrollData();
  194. setInterval(() => {
  195. this.getPageData();
  196. }, 60000);
  197. },
  198. watch: {
  199. xiaobaninput: {
  200. handler: function () {
  201. debounce(this.xiaobansearch, 500, false);
  202. }
  203. },
  204. '$store.state.addr.selectCity'(val) {
  205. // debounce(this.getPageData(), 1000, false)
  206. this.getPageData();
  207. },
  208. '$store.state.addr.selectDistrict'(val) {
  209. this.getPageData();
  210. },
  211. '$store.state.addr.selectStreet'(val) {
  212. this.getPageData();
  213. }
  214. },
  215. methods: {
  216. addrChange(value) {
  217. console.log('addrChange', value);
  218. },
  219. navClick(index) {
  220. this.$store.commit('changePage', this.navList[index - 1].en);
  221. console.log('this.navList[index-1].en', this.navList[index - 1].en);
  222. this.page = index;
  223. console.log('index', index);
  224. if (
  225. this.$store.state.addr.page == 'sink' ||
  226. this.$store.state.addr.page == 'circulation'
  227. ) {
  228. Message('暂未开放!');
  229. return;
  230. }
  231. // 切换专题时,重置区域
  232. // this.$store.dispatch('searchArea', {
  233. // parentId: '520000',
  234. // name: '贵州省',
  235. // mapLevel: 'province'
  236. // });
  237. this.getPageData();
  238. },
  239. getPageData() {
  240. debounce(this.debounceGetData, 1000, true);
  241. },
  242. debounceGetData() {
  243. console.log('page', this.$store.state.addr.page);
  244. // {text:'森林资源',en:'forest'},
  245. // {text:'林木结构',en:'treeSpecies'},
  246. // {text:'碳汇管理',en:'sink'},
  247. // {text:'林下经济',en:'economics'},
  248. // {text:'土地流转',en:'circulation'},
  249. // {text:'事件信息',en:'event'},
  250. if (this.$store.state.addr.page == 'forest') {
  251. this.getPage1numerical();
  252. this.getPage1echarts01();
  253. this.getPage1echarts02();
  254. this.getRightScrollData();
  255. } else if (this.$store.state.addr.page == 'treeSpecies') {
  256. this.getPage2echarts01();
  257. this.getPage2echarts02();
  258. this.getRightScrollData();
  259. } else if (this.$store.state.addr.page == 'economics') {
  260. this.getPage5numerical();
  261. this.getTypeSlideData();
  262. this.getPage5echarts01();
  263. this.getPage5echarts02();
  264. this.getRightScrollData();
  265. } else if (this.$store.state.addr.page == 'event') {
  266. this.getPage6numerical();
  267. this.getPage6echarts01();
  268. this.getAlarmData();
  269. this.getRightScrollData();
  270. }
  271. },
  272. getPage1numerical() {
  273. let param = {
  274. cityId: this.$store.state.addr.selectCity.areaId,
  275. countyId: this.$store.state.addr.selectDistrict.areaId,
  276. townId: this.$store.state.addr.vuexSelectStreet.areaId
  277. };
  278. page1numerical(param)
  279. .then((res) => {
  280. // console.log('res',res);
  281. this.page1numerical = res.data;
  282. })
  283. .catch((err) => {
  284. console.log('echarts01 err', err);
  285. });
  286. },
  287. getPage1echarts01() {
  288. let param = {
  289. cityId: this.$store.state.addr.selectCity.areaId,
  290. countyId: this.$store.state.addr.selectDistrict.areaId,
  291. townId: this.$store.state.addr.vuexSelectStreet.areaId
  292. };
  293. // console.log('cityId',param.cityId);
  294. page1echarts01(param)
  295. .then((res) => {
  296. this.page1Char1.xAxis.data = res.data.map((item) => {
  297. return item.name;
  298. });
  299. this.page1Char1.series[0].data = res.data.map((item) => {
  300. return item.number;
  301. });
  302. let charUuid = this.$refs.page1Char1.mid;
  303. this.$refs.page1Char1.intChar(charUuid);
  304. })
  305. .catch((err) => {
  306. console.log('getPage1echarts01 err', err);
  307. });
  308. },
  309. getPage1echarts02() {
  310. let param = {
  311. cityId: this.$store.state.addr.selectCity.areaId,
  312. countyId: this.$store.state.addr.selectDistrict.areaId,
  313. townId: this.$store.state.addr.selectStreet.areaId
  314. };
  315. // console.log('cityId',param.cityId);
  316. page1echarts02(param)
  317. .then((res) => {
  318. this.page1Char2.xAxis.data = res.data.map((item) => {
  319. return item.name;
  320. });
  321. this.page1Char2.series[0].data = res.data.map((item) => {
  322. return item.number;
  323. });
  324. let charUuid = this.$refs.page1Char2.mid;
  325. this.$refs.page1Char2.intChar(charUuid);
  326. })
  327. .catch((err) => {
  328. console.log('getPage1echarts02 err', err);
  329. });
  330. },
  331. getRightScrollData() {
  332. let param = {
  333. smallNumber: this.xiaobaninput,
  334. cityId: this.$store.state.addr.selectCity.areaId,
  335. countyId: this.$store.state.addr.selectDistrict.areaId,
  336. townId: this.$store.state.addr.selectStreet.areaId
  337. };
  338. rightScrollData(param)
  339. .then((res) => {
  340. // console.log('res',res.rows.length);
  341. // console.log('this.scrollBoardConfig',this.scrollBoardConfig);
  342. //当小班滚动数据少时重设参数
  343. // if(res.rows.length<=15){
  344. // this.scrollBoardConfig.rowNum = 5;
  345. // this.scrollBoardStyle.height = '25vh'
  346. // }
  347. this.scrollBoardConfig.data = [];
  348. res.rows.forEach((element) => {
  349. this.scrollBoardConfig.data.push([
  350. element.smallNumber,
  351. element.treeComp,
  352. element.perAcreStock,
  353. element.landArea
  354. ]);
  355. });
  356. this.scrollBoardKey = Date.now();
  357. this.$refs.scrollBoard.updateRows(this.scrollBoardConfig.data);
  358. // console.log('this.scrollBoardConfig.data', this.scrollBoardConfig.data);
  359. // this.scrollBoardConfig = res.data;
  360. })
  361. .catch((err) => {
  362. console.log('echarts01 err', err);
  363. });
  364. },
  365. getAlarmData() {
  366. alarmDataApi()
  367. .then((res) => {
  368. // console.log('this.page',this.page);
  369. // console.log('res',res);
  370. this.alarmData = res.data;
  371. // console.log('alarmData.length',this.alarmData.length);
  372. })
  373. .catch((err) => {
  374. console.log('echarts01 err', err);
  375. });
  376. },
  377. getPage2echarts01() {
  378. let param = {
  379. smallNumber: this.xiaobaninput,
  380. cityId: this.$store.state.addr.selectCity.areaId,
  381. countyId: this.$store.state.addr.selectDistrict.areaId,
  382. townId: this.$store.state.addr.selectStreet.areaId
  383. };
  384. page2echarts01(param)
  385. .then((res) => {
  386. // console.log('res',res);
  387. this.page2Char1.series[0].data = [];
  388. this.page2Char1.series[0].data = res.data;
  389. let charUuid = this.$refs.page2Char1.mid;
  390. this.$refs.page2Char1.intChar(charUuid);
  391. })
  392. .catch((err) => {
  393. console.log('getPage2echarts01 err', err);
  394. });
  395. },
  396. getPage2echarts02() {
  397. let param = {
  398. smallNumber: this.xiaobaninput,
  399. cityId: this.$store.state.addr.selectCity.areaId,
  400. countyId: this.$store.state.addr.selectDistrict.areaId,
  401. townId: this.$store.state.addr.selectStreet.areaId
  402. };
  403. page2echarts02(param)
  404. .then((res) => {
  405. // console.log('res',res);
  406. // this.page2Char2 = res.data;
  407. // console.log('this.page2Char2.series', this.page2Char2.series);
  408. this.page2Char2.xAxis.data = [];
  409. this.page2Char2.series = [];
  410. const rows = res.rows;
  411. // console.log(rows)
  412. // x坐标
  413. this.page2Char2.xAxis.data = rows.map((item) => {
  414. return item.smallNumber;
  415. });
  416. // console.log('x坐标', this.page2Char2.xAxis.data)
  417. // 获取所有项
  418. let seriesList = rows.map((item) => {
  419. return item.treeList;
  420. });
  421. // 数组扁平化
  422. seriesList = seriesList.flat();
  423. // 去重
  424. let obj = {};
  425. seriesList = seriesList.reduce((newArr, next) => {
  426. obj[next.name] ? '' : (obj[next.name] = true && newArr.push(next));
  427. return newArr;
  428. }, []);
  429. seriesList = seriesList.map((item) => {
  430. return {
  431. name: item.name,
  432. type: 'bar',
  433. stack: 'total',
  434. label: {
  435. show: false
  436. },
  437. emphasis: {
  438. focus: 'series'
  439. },
  440. data: []
  441. };
  442. });
  443. // console.log(seriesList)
  444. rows.forEach((item) => {
  445. seriesList.forEach((jtem, index) => {
  446. let num = 0;
  447. item.treeList.map((ktem) => {
  448. if (ktem.name.indexOf(jtem.name) > -1) {
  449. num = ktem.value;
  450. }
  451. });
  452. seriesList[index].data.push(num);
  453. });
  454. });
  455. // console.log(seriesList)
  456. this.page2Char2.series = seriesList;
  457. let charUuid = this.$refs.page2Char2.mid;
  458. this.$refs.page2Char2.intChar(charUuid);
  459. })
  460. .catch((err) => {
  461. console.log('getPage2echarts02 err', err);
  462. });
  463. },
  464. getPage5numerical() {
  465. let param = {
  466. cityId: this.$store.state.addr.selectCity.areaId,
  467. countyId: this.$store.state.addr.selectDistrict.areaId,
  468. townId: this.$store.state.addr.selectStreet.areaId
  469. };
  470. page5numerical(param)
  471. .then((res) => {
  472. // console.log('res',res);
  473. this.page5numerical = res.data;
  474. })
  475. .catch((err) => {
  476. console.log('echarts01 err', err);
  477. });
  478. },
  479. getTypeSlideData() {
  480. let param = {
  481. cityId: this.$store.state.addr.selectCity.areaId,
  482. countyId: this.$store.state.addr.selectDistrict.areaId,
  483. townId: this.$store.state.addr.selectStreet.areaId
  484. };
  485. typeSlideApi(param)
  486. .then((res) => {
  487. this.typeSlideData = sliceArray(res.data, 3);
  488. // console.log(' this.typeSlideData', this.typeSlideData);
  489. })
  490. .catch((err) => {
  491. console.log('getTypeSlideData err', err);
  492. });
  493. },
  494. getPage5echarts01() {
  495. let param = {
  496. cityId: this.$store.state.addr.selectCity.areaId,
  497. countyId: this.$store.state.addr.selectDistrict.areaId,
  498. townId: this.$store.state.addr.selectStreet.areaId
  499. };
  500. page5echarts01(param)
  501. .then((res) => {
  502. // console.log('res',res);
  503. this.page5Char1 = res.data;
  504. let charUuid = this.$refs.page5Char1.mid;
  505. this.$refs.page5Char1.intChar(charUuid);
  506. })
  507. .catch((err) => {
  508. console.log('getPage5echarts01 err', err);
  509. });
  510. },
  511. getPage5echarts02() {
  512. let param = {
  513. cityId: this.$store.state.addr.selectCity.areaId,
  514. countyId: this.$store.state.addr.selectDistrict.areaId,
  515. townId: this.$store.state.addr.selectStreet.areaId
  516. };
  517. page5echarts02(param)
  518. .then((res) => {
  519. // console.log('res',res);
  520. this.page5Char2 = res.data;
  521. let charUuid = this.$refs.page5Char2.mid;
  522. this.$refs.page5Char1.intChar(charUuid);
  523. })
  524. .catch((err) => {
  525. console.log('getPage5echarts02 err', err);
  526. });
  527. },
  528. getPage6numerical() {
  529. let param = {
  530. cityId: this.$store.state.addr.selectCity.areaId,
  531. countyId: this.$store.state.addr.selectDistrict.areaId,
  532. townId: this.$store.state.addr.selectStreet.areaId
  533. };
  534. //第一屏统计
  535. page6numerical(param)
  536. .then((res) => {
  537. // console.log('res',res);
  538. this.page6numerical = res.data;
  539. })
  540. .catch((err) => {
  541. console.log('getPage6numerical err', err);
  542. });
  543. },
  544. getPage6echarts01() {
  545. let param = {
  546. cityId: this.$store.state.addr.selectCity.areaId,
  547. countyId: this.$store.state.addr.selectDistrict.areaId,
  548. townId: this.$store.state.addr.selectStreet.areaId
  549. };
  550. page6echarts01(param)
  551. .then((res) => {
  552. // console.log('res',res);
  553. // this.page6Char1 = res.data;
  554. this.page6Char1.xAxis[0].data = [];
  555. this.page6Char1.series[0].data = [];
  556. this.page6Char1.series[1].data = [];
  557. this.page6Char1.series[2].data = [];
  558. res.data &&
  559. res.data.forEach((element) => {
  560. this.page6Char1.xAxis[0].data.push(element.villageName);
  561. this.page6Char1.series[0].data.push(element.fireCount);
  562. this.page6Char1.series[1].data.push(element.cutCount);
  563. this.page6Char1.series[2].data.push(element.pestCount);
  564. });
  565. let charUuid = this.$refs.page6Char1.mid;
  566. this.$refs.page6Char1.intChar(charUuid);
  567. })
  568. .catch((err) => {
  569. console.log('getPage6echarts01 err', err);
  570. });
  571. },
  572. xiaobansearch() {
  573. // console.log('xiaobansearch');
  574. this.getRightScrollData();
  575. this.getPageData();
  576. },
  577. scrollBoardClick(e) {
  578. console.log('scrollBoardClick', e);
  579. }
  580. }
  581. };
  582. </script>
  583. <style lang='scss' scoped>
  584. @import url(./index.scss);
  585. </style>