index.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651
  1. <template>
  2. <div class="innerContainer leftPane" v-drag>
  3. <h2 class="Pangetitle darg-div el-col">
  4. <span class="pange_text">{{ pageType == 0 ? "耕地总览" : "永久基本农田" }}
  5. </span>
  6. <div class="region">
  7. <el-select v-model="nowunit" placeholder="请选择" size="mini" @change="unitChange">
  8. <el-option v-for="item in unitList" :key="item.code" :label="item.name" :value="item.code">
  9. </el-option>
  10. </el-select>
  11. </div>
  12. </h2>
  13. <div class="xz_box">
  14. <div class="gdzl">
  15. <div class="el-col headerSelect">
  16. <el-select v-model="nowyear" placeholder="请选择" size="mini" @change="yearChange()">
  17. <el-option v-for="item in yearList" :key="item.year" :label="item.year" :value="item.year">
  18. </el-option>
  19. </el-select>
  20. <!-- clearable -->
  21. <el-cascader v-model="region" :show-all-levels="false" :options="store.state.region_tree"
  22. @change="xzqhChange()" placeholder="行政区" size="mini" :props="{
  23. checkStrictly: true,
  24. expandTrigger: 'hover',
  25. emitPath: false,
  26. }"></el-cascader>
  27. <el-select v-model="dlbm" placeholder="请选择" size="mini" @change="dlbmChange">
  28. <el-option v-for="item in typeList" :key="item.id" :label="item.label" :value="item.id">
  29. </el-option>
  30. </el-select>
  31. <!-- <div class="region">
  32. </div> -->
  33. </div>
  34. <div class="echars">
  35. <div class="echartTitle">
  36. <div class="block-title">
  37. {{ gtype }}总量
  38. </div>
  39. </div>
  40. <div class="content gdzlc">
  41. <div class="item" v-for="zl in zllist[gtype]" :key="zl.name">
  42. <div class="icon">
  43. <div class="iicon"></div>
  44. </div>
  45. <div class="text">
  46. <p>{{ zl.name }}</p>
  47. <span class="cvalue">
  48. {{ (zldata[zl.prop || ((zl.p || '') + uprops[nowunit])] || 0).toFixed(2) }}
  49. {{ zl.unit || unitList[nowunit].unit }}</span>
  50. </div>
  51. </div>
  52. </div>
  53. <div class="content scontent" v-show="dlbm == '01'">
  54. <div class="item" v-for="(sd, index) in fldata" :key="index">
  55. <div class="text">
  56. <p>{{ sd.dlmc }}</p>
  57. <span class="cvalue">
  58. {{ (sd[uprops[nowunit]] || 0).toFixed(2) }}
  59. </span>
  60. <span class="unit">{{ unitList[nowunit].unit }}</span>
  61. </div>
  62. </div>
  63. </div>
  64. </div>
  65. <div class="echars">
  66. <div class="echartTitle">
  67. <div class="block-title">
  68. {{ gtype }}增减变化情况
  69. </div>
  70. <div class="titlesel" v-show="dlbm == '01'">
  71. 对比年份
  72. <div class="selectTab">
  73. <el-select v-model="tab" placeholder="请选择" :popper-append-to-body="false" @change="GetBhqk()">
  74. <el-option v-for="item in yearList" :key="item.year" :label="item.year" :value="item.year">
  75. </el-option>
  76. </el-select>
  77. </div>
  78. <div class="usable" @click="contrast">更多</div>
  79. </div>
  80. </div>
  81. <div class="content scontent" v-show="dlbm == '01'">
  82. <div class="item item50" v-for="(bh, index) in bhlist" :key="index">
  83. <div class="text">
  84. <p>{{ bh.name }}</p>
  85. <span class="cvalue" :class="bhdata.mjbh > 0 ? 'posNum' : 'negNum'">
  86. {{ (bhdata[bh.prop || uprops[nowunit]] || 0).toFixed(2) }}
  87. </span>
  88. <span class="unit">{{ bh.unit || unitList[nowunit].unit }}</span>
  89. </div>
  90. </div>
  91. </div>
  92. <div class="pietitle" v-show="dlbm == '01'">历年变化情况</div>
  93. <bar class="pie_echart" ref="echartRef0"></bar>
  94. </div>
  95. <div class="echars gqgd">
  96. <Statistics :title="`各区${gtype}分布`" :cityList="cityList" :prop="uprops[nowunit]" :max="citymax"
  97. :unit="unitList[nowunit].unit" :height="dlbm == '01' ? 180 : 260" :text="`占全市${gtype}`" textunit="%">
  98. </Statistics>
  99. <!-- <sidebar v-if="!sidebar.hide" class="sidebar-container" /> -->
  100. </div>
  101. </div>
  102. </div>
  103. </div>
  104. </template>
  105. <script>
  106. import bar from "@/components/echartsTemplate/bar.vue";
  107. import Statistics from "../components/statistics.vue";
  108. import { QueryOne, QueryList } from "@/api/cockpitNew";
  109. import {
  110. GetGdDate,
  111. GetGdZl,
  112. GetGdFl,
  113. GetGdBhqk,
  114. GetGdLnbhqk,
  115. GetGdQxfl,
  116. GetYjjbntDate,
  117. GetYjjbntZl,
  118. GetYjjbntFl,
  119. GetYjjbntBhqk,
  120. GetYjjbntLnbhqk,
  121. GetYjjbntQxfl,
  122. } from "@/api/ghss/gdbhadd.js";
  123. import { legends } from "../config.js";
  124. import {
  125. loadGeoJSON,
  126. Getlayers,
  127. addImagery,
  128. SetParameters,
  129. } from "@/utils/MapHelper/help.js";
  130. import { init_handler } from "@/utils/MapHelper/clickQuery.js";
  131. export default {
  132. props: {
  133. pageType: {
  134. type: String,
  135. },
  136. },
  137. data() {
  138. return {
  139. region: "4602",
  140. dlbm: "01",
  141. gtype: "耕地",
  142. nowunit: 0,
  143. unitList: [
  144. { code: 0, name: "平方千米", unit: "km²" },
  145. { code: 1, name: "平方米", unit: "m²" },
  146. { code: 2, name: "亩", unit: "亩" },
  147. { code: 3, name: "公顷", unit: "公顷" },
  148. ],
  149. nowyear: "",
  150. uprops: ["mj_qm", "mj", "mj_m", "mj_gq"],
  151. // bhprops: ["d1_mj_qm", "d1_mj", "mj_m"],
  152. yearList: [],
  153. typeList: [],
  154. tab: "2023",
  155. zllist: {
  156. 永久基本农田: [{ name: "永久基本农田" },
  157. { name: "占现状耕地比", prop: "zb", unit: "%", }],
  158. 耕地: [
  159. { name: "耕地保有量", },
  160. { name: "耕地保护目标", p: "bh_" },
  161. ],
  162. 水田: [
  163. { name: "水田现状" },
  164. { name: "占耕地比", prop: "zb", unit: "%" },
  165. ],
  166. 水浇地: [
  167. { name: "水浇地现状" },
  168. { name: "占耕地比", prop: "zb", unit: "%" },
  169. ],
  170. 旱地: [
  171. { name: "旱地现状" },
  172. { name: "占耕地比", prop: "zb", unit: "%" },
  173. ],
  174. },
  175. bhlist: [
  176. { name: "变化面积" },
  177. { name: "变化幅度", prop: "mjbh", unit: "%" },
  178. ],
  179. zldata: {},
  180. fldata: {},
  181. bhdata: {},
  182. lnbndata: [],
  183. eData: {
  184. xData: ["2020", "2021", "2022", "2023"],
  185. yData: [[-10, 10, 10, 10]],
  186. legend: [""],
  187. },
  188. citymax: 1,
  189. cityList: [],
  190. imagelayers: {},
  191. nowlayer: "",
  192. provider: null,
  193. layers: [],
  194. };
  195. },
  196. components: {
  197. bar,
  198. Statistics,
  199. },
  200. created() {
  201. // this.getYear();
  202. // this.GetDate();
  203. this.typeList = [...JSON.parse(JSON.stringify(legends))];
  204. },
  205. mounted() { },
  206. methods: {
  207. changeData(name, updata) {
  208. this[name] = updata;
  209. },
  210. getYear() {
  211. let date = new Date();
  212. let startYear = date.getFullYear() - 4; //起始年份
  213. let endYear = date.getFullYear(); //结束年份
  214. for (var i = startYear; i <= endYear; i++) {
  215. this.yearList.push({ value: i, label: i + "年" });
  216. }
  217. },
  218. unitChange() {
  219. this.setLnbh(this.lnbndata);
  220. },
  221. yearChange() {
  222. // let yobj = this.yearList.find((y) => y.year == this.nowyear);
  223. // this.setImager(yobj);
  224. this.yearList.forEach((yobj) => {
  225. this.setImager(yobj, yobj.year == this.nowyear);
  226. if (yobj.year == this.nowyear) {
  227. init_handler(yobj, this.showInfo);
  228. }
  229. });
  230. this.regionChange();
  231. },
  232. dlbmChange() {
  233. // let nowtype = this.typeList.find((x) => x.id == this.dlbm);
  234. this.gtype = this.typeList.find((x) => x.id == this.dlbm).label;
  235. if (this.pageType && this.dlbm == "01") this.gtype = "永久基本农田"
  236. this.xzqhChange();
  237. // this.regionChange();
  238. // if (this.dlbm == "01") {
  239. // this.nowlayer = this.nowyear;
  240. // } else {
  241. // if (nowtype.layerID) {
  242. // this.nowlayer = this.nowyear + nowtype.layerID;
  243. // } else if (this.layers.length) {
  244. // let yobj = this.yearList.find((y) => y.year == this.nowyear);
  245. // if (yobj) this.goLayer(yobj, nowtype);
  246. // }
  247. // }
  248. },
  249. xzqhChange() {
  250. this.regionChange();
  251. if (this.layers.length) {
  252. let yobj = this.yearList.find((y) => y.year == this.nowyear);
  253. if (yobj) this.goLayer(yobj);
  254. }
  255. },
  256. goLayer(lobj, nowtype) {
  257. let lname = this.layers[0].name; // `dlbm like '${this.dlbm}%'`,
  258. let sql = `${this.pageType ? "xzqdm" : "qsdwdm"} LIKE '%${this.region}%'`;
  259. if (this.dlbm != '01') sql += ` and dlbm LIKE '${this.dlbm}%'`;
  260. SetParameters(lname, sql, this.provider, (lid) => {
  261. // this.typeList[nowtype.index].layerID = lid;
  262. this.nowlayer = this.nowyear + lid;
  263. this.setImager({ ...lobj, lid });
  264. });
  265. },
  266. async GetDate() {
  267. this.yearList = [];
  268. let res = {};
  269. if (this.$props.pageType == 0) {
  270. res = await GetGdDate();
  271. } else {
  272. res = await GetYjjbntDate();
  273. }
  274. res.data.forEach((item) => {
  275. this.yearList.push({
  276. ...item,
  277. url: item.serverurl,
  278. fwgzkj: item.serverfwgzkj,
  279. fwmc: item.serverfwmc,
  280. source: "",
  281. title: item.year,
  282. id: item.serverid,
  283. });
  284. });
  285. this.nowyear = this.yearList.length ? this.yearList[0].year : "";
  286. this.nowlayer = this.nowyear;
  287. init_handler(this.yearList[0], this.showInfo);
  288. store.setaddNode([
  289. { id: "gdbh", url: this.yearList[0].url, label: "耕地保护" },
  290. ]);
  291. // + this.$props.pageType
  292. this.setImager(this.yearList[0], true, (layer) => {
  293. Getlayers(this.yearList[0].url, (layers) => {
  294. this.layers = layers;
  295. // SetParameters(
  296. // layers,
  297. // `dlbm like '${this.dlbm}%'`,
  298. // this.provider,
  299. // (lid) => {
  300. // this.setImager({ ...this.yearList[0], lid });
  301. // }
  302. // );
  303. });
  304. });
  305. },
  306. showInfo(data, obj) {
  307. let alegends = store.state.addlegend;
  308. if (alegends && alegends.length && alegends[0].id == "gdbh") {
  309. this.$emit("handleView", data, obj);
  310. }
  311. },
  312. setImager(obj, isshow = true, fun) {
  313. let lkey = obj.year + (obj.lid || "");
  314. // console.log(lkey, isshow, this.imagelayers[lkey], "---");
  315. if (this.imagelayers[lkey]) this.imagelayers[lkey].show = isshow;
  316. else if (isshow && obj.url) {
  317. let { supProvider, layer } = addImagery(obj);
  318. if (!obj.lid) this.provider = supProvider;
  319. this.imagelayers[lkey] = layer;
  320. }
  321. if (obj.top) viewer.imageryLayers.raiseToTop(this.imagelayers[lkey]);
  322. fun && fun(this.imagelayers[lkey]);
  323. if (this.imagelayers[lkey]) viewer.flyTo(this.imagelayers[lkey]);
  324. },
  325. async regionChange(region) {
  326. // this.region = region;
  327. if (this.dlbm == "01") this.gtype = this.pageType ? "永久基本农田" : '耕地'
  328. if (region) this.nowyear = "";
  329. if (!this.nowyear) await this.GetDate();
  330. this.getData();
  331. },
  332. getData() {
  333. this.$emit("updateParent", "loading", true);
  334. this.Getzzxm();
  335. // this.Getkjxx();
  336. },
  337. async Getzzxm() {
  338. let parms = { year: this.nowyear, xzqhdm: this.region, dlbm: this.dlbm };
  339. if (this.$props.pageType == 0) {
  340. GetGdZl(parms).then((res) => {
  341. this.zldata = res.data;
  342. GetGdQxfl(parms).then((res) => {
  343. this.citymax = 0
  344. res.data.forEach(c => {
  345. c.number = (c.mj_m / this.zldata.mj_m * 100).toFixed(2);
  346. if (this.citymax < c.number) this.citymax = Math.ceil(c.number / 10) * 10;
  347. })
  348. this.cityList = res.data;
  349. });
  350. });
  351. if (this.dlbm == "01")
  352. GetGdFl(parms).then((res) => {
  353. this.fldata = res.data;
  354. });
  355. } else {
  356. GetYjjbntZl(parms).then((res) => {
  357. this.zldata = res.data;
  358. GetYjjbntQxfl(parms).then((res) => {
  359. this.citymax = 0
  360. res.data.forEach(c => {
  361. c.number = (c.mj_m / this.zldata.mj_m * 100).toFixed(2);
  362. if (this.citymax < c.number) this.citymax = Math.ceil(c.number / 10) * 10;
  363. })
  364. this.cityList = res.data;
  365. });
  366. });
  367. if (this.dlbm == "01")
  368. GetYjjbntFl(parms).then((res) => {
  369. this.fldata = res.data;
  370. });
  371. }
  372. this.GetLnbhqk();
  373. this.GetBhqk();
  374. },
  375. GetLnbhqk() {
  376. this.eData.xData = [];
  377. this.eData.yData = [[]];
  378. let parms = { year: this.nowyear, xzqhdm: this.region, dlbm: this.dlbm };
  379. if (!this.$props.pageType) {
  380. GetGdLnbhqk(parms).then(({ data }) => {
  381. this.lnbndata = data;
  382. this.setLnbh(data);
  383. });
  384. } else {
  385. GetYjjbntLnbhqk(parms).then(({ data }) => {
  386. this.lnbndata = data;
  387. this.setLnbh(data);
  388. });
  389. }
  390. },
  391. setLnbh(data) {
  392. this.eData.yName = `变化面积${this.unitList[this.nowunit].unit}`;
  393. this.eData.xData = [];
  394. this.eData.yData = [[]];
  395. data.forEach((res) => {
  396. this.eData.xData.push(res.year);
  397. this.eData.yData[0].push(res[this.uprops[this.nowunit]]);
  398. });
  399. this.setEchart(this.eData, 0);
  400. },
  401. GetBhqk() {
  402. let params = {
  403. sourceyear: this.nowyear,
  404. targeyear: this.tab,
  405. xzqhdm: this.region,
  406. };
  407. if (!this.$props.pageType) {
  408. GetGdBhqk(params).then((res) => {
  409. this.bhdata = res.data;
  410. });
  411. } else {
  412. GetYjjbntBhqk(params).then((res) => {
  413. this.bhdata = res.data;
  414. });
  415. }
  416. },
  417. async Getkjxx() {
  418. let res = await QueryList({
  419. jscType: "qytuzz_sdzl_kjxx",
  420. id: this.region,
  421. });
  422. this.active_tableData(res.data);
  423. },
  424. active_tableData(newVal) {
  425. newVal.forEach((res, index) => {
  426. let color = legends[res.type].color;
  427. if (res.geom)
  428. loadGeoJSON(res.geom, color, { isfly: true }, (data) => {
  429. geoSources[res.id] = data;
  430. data.name = "LandConsolidation";
  431. // data.entities.values.forEach((entity) => {
  432. // entity.properties = { type: "图斑上图", id: res.id };
  433. // });
  434. });
  435. });
  436. },
  437. contrast() {
  438. let dbdata = { id: this.region, fp: this.yearList.sort((a, b) => a.year - b.year), type: "gdbh" }; //+ this.$props.pageType,
  439. console.log("contrast", dbdata);
  440. this.setImager({ year: this.nowlayer }, false);
  441. this.$emit("contrast", dbdata);
  442. },
  443. fly() {
  444. // viewer.flyTo(this.imagelayers[this.nowlayer]);
  445. },
  446. sourcesshow(show) {
  447. this.setImager({ year: this.nowlayer }, show);
  448. },
  449. reset() {
  450. store.setaddNode([]);
  451. this.$nextTick(() => {
  452. // this.sourcesshow(false);
  453. Object.keys(this.imagelayers).forEach((key) => {
  454. viewer.imageryLayers.remove(this.imagelayers[key]);
  455. });
  456. this.imagelayers = {};
  457. this.typeList = [...JSON.parse(JSON.stringify(legends))];
  458. });
  459. },
  460. setEchart(data, id) {
  461. this.$nextTick(() => {
  462. this.$refs[`echartRef${id}`].setOptions(data);
  463. });
  464. },
  465. },
  466. watch: {
  467. region(newValue) {
  468. console.log(newValue, "---");
  469. },
  470. nowlayer(newValue, oldVal) {
  471. // this.setImager({ year: oldVal }, false);
  472. // this.setImager({ year: newValue }, true);
  473. },
  474. },
  475. beforeDestroy() {
  476. store.setaddNode([]);
  477. this.yearList.forEach((yi) => {
  478. viewer.imageryLayers.remove(this.imagelayers[yi.year]);
  479. });
  480. },
  481. };
  482. </script>
  483. <style lang="scss" scoped>
  484. .gdzl {
  485. height: 100%;
  486. .region {
  487. width: 100px !important;
  488. position: absolute;
  489. right: 20px;
  490. }
  491. .el-select {
  492. padding: 0 10px;
  493. }
  494. .headerSelect {
  495. width: 100%;
  496. height: 26px;
  497. // background: #00ffff;
  498. margin: 5px 0px;
  499. display: flex;
  500. justify-content: space-between;
  501. }
  502. .content {
  503. width: 100%;
  504. height: 190px;
  505. padding-top: 5px;
  506. .item {
  507. width: 32%;
  508. // height: 100px;
  509. display: inline-block;
  510. position: relative;
  511. .icon {
  512. width: 100%;
  513. height: 50px;
  514. display: flex;
  515. justify-content: space-between;
  516. }
  517. .iicon {
  518. background: no-repeat 50%;
  519. background-image: url("/static/images/overview/icon_yrkkg.png");
  520. width: 45px;
  521. height: 45px;
  522. flex: 1;
  523. }
  524. }
  525. .item50 {
  526. width: 48%;
  527. }
  528. .text {
  529. display: inline-block;
  530. // border: #00FFFF 1px solid;
  531. width: 100%;
  532. margin-bottom: 4px;
  533. text-align: center;
  534. margin-left: 0.3rem;
  535. .cvalue {
  536. font-family: "Arial Negreta", "Arial Normal", "Arial";
  537. font-weight: 700;
  538. font-style: normal;
  539. color: #68f4fb;
  540. }
  541. .unit {
  542. color: #fff;
  543. }
  544. }
  545. }
  546. .gdzlc {
  547. height: 65px;
  548. display: flex;
  549. justify-content: space-between;
  550. .item {
  551. width: 48%;
  552. height: 60px;
  553. padding-left: 20px;
  554. background: rgba(104, 244, 251, 0.21568627); // #2f5b71;
  555. border-radius: 5px;
  556. .icon {
  557. width: 50px;
  558. display: inline-block;
  559. }
  560. .text {
  561. display: inline-block;
  562. width: calc(100% - 60px);
  563. text-align: left;
  564. }
  565. }
  566. }
  567. .scontent {
  568. height: 60px;
  569. background: rgba(104, 244, 251, 0.21568627); //#2f5b71;
  570. border-radius: 5px;
  571. padding-top: 10px;
  572. margin-top: 5px;
  573. display: flex;
  574. .posNum {
  575. color: #ec808d !important;
  576. }
  577. .negNum {
  578. color: #00cc3a !important;
  579. }
  580. }
  581. .echars {
  582. // width: 100%;
  583. // height: calc(100% - 120px);
  584. // overflow-y: auto;
  585. // overflow-x: hidden;
  586. .echartTitle {
  587. height: 35px;
  588. }
  589. .block-title {
  590. width: calc(100% - 185px) !important;
  591. }
  592. .titlesel {
  593. width: 250px;
  594. display: flex;
  595. }
  596. }
  597. .echart {
  598. height: 200px !important;
  599. }
  600. .pietitle {
  601. position: relative;
  602. width: 200px;
  603. line-height: 26px;
  604. text-align: center;
  605. border: 1px solid #3f93f5;
  606. border-top-right-radius: 10px;
  607. margin: 10px 20% 0px 20%;
  608. color: #3f93f5;
  609. }
  610. .pie_echart {
  611. // width: 400px;
  612. margin-top: 10px;
  613. width: 21vw;
  614. height: 140px;
  615. }
  616. }
  617. </style>