index.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638
  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.regionChange();
  225. },
  226. dlbmChange() {
  227. // let nowtype = this.typeList.find((x) => x.id == this.dlbm);
  228. this.gtype = this.typeList.find((x) => x.id == this.dlbm).label;
  229. if (this.pageType && this.dlbm == "01") this.gtype = "永久基本农田"
  230. this.xzqhChange();
  231. // this.regionChange();
  232. // if (this.dlbm == "01") {
  233. // this.nowlayer = this.nowyear;
  234. // } else {
  235. // if (nowtype.layerID) {
  236. // this.nowlayer = this.nowyear + nowtype.layerID;
  237. // } else if (this.layers.length) {
  238. // let yobj = this.yearList.find((y) => y.year == this.nowyear);
  239. // if (yobj) this.goLayer(yobj, nowtype);
  240. // }
  241. // }
  242. },
  243. xzqhChange() {
  244. this.regionChange();
  245. if (this.layers.length) {
  246. let yobj = this.yearList.find((y) => y.year == this.nowyear);
  247. if (yobj) this.goLayer(yobj);
  248. }
  249. },
  250. goLayer(lobj, nowtype) {
  251. let lname = this.layers[0].name; // `dlbm like '${this.dlbm}%'`,
  252. let sql = `${this.pageType ? "xzqdm" : "qsdwdm"} LIKE '%${this.region}%'`;
  253. if (this.dlbm != '01') sql += ` and dlbm LIKE '${this.dlbm}%'`;
  254. SetParameters(lname, sql, this.provider, (lid) => {
  255. // this.typeList[nowtype.index].layerID = lid;
  256. this.nowlayer = this.nowyear + lid;
  257. this.setImager({ ...lobj, lid });
  258. });
  259. },
  260. async GetDate() {
  261. this.yearList = [];
  262. let res = {};
  263. if (this.$props.pageType == 0) {
  264. res = await GetGdDate();
  265. } else {
  266. res = await GetYjjbntDate();
  267. }
  268. res.data.forEach((item) => {
  269. this.yearList.push({
  270. ...item,
  271. url: item.serverurl,
  272. fwgzkj: item.serverfwgzkj,
  273. fwmc: item.serverfwmc,
  274. source: "",
  275. title: item.year,
  276. id: item.serverid,
  277. });
  278. });
  279. this.nowyear = this.yearList.length ? this.yearList[0].year : "";
  280. this.nowlayer = this.nowyear;
  281. init_handler(this.yearList[0], this.showInfo);
  282. store.setaddNode([
  283. { id: "gdbh", url: this.yearList[0].url, label: "耕地保护" },
  284. ]);
  285. // + this.$props.pageType
  286. this.setImager(this.yearList[0], true, (layer) => {
  287. Getlayers(this.yearList[0].url, (layers) => {
  288. this.layers = layers;
  289. // SetParameters(
  290. // layers,
  291. // `dlbm like '${this.dlbm}%'`,
  292. // this.provider,
  293. // (lid) => {
  294. // this.setImager({ ...this.yearList[0], lid });
  295. // }
  296. // );
  297. });
  298. });
  299. },
  300. showInfo(data, obj) {
  301. let alegends = store.state.addlegend;
  302. if (alegends && alegends.length && alegends[0].id == "gdbh") {
  303. this.$emit("handleView", data, obj);
  304. }
  305. },
  306. setImager(obj, isshow = true, fun) {
  307. let lkey = obj.year + (obj.lid || "");
  308. // console.log(lkey, isshow, this.imagelayers[lkey], "---");
  309. if (this.imagelayers[lkey]) this.imagelayers[lkey].show = isshow;
  310. else if (isshow && obj.url) {
  311. let { supProvider, layer } = addImagery(obj);
  312. if (!obj.lid) this.provider = supProvider;
  313. this.imagelayers[lkey] = layer;
  314. }
  315. if (obj.top) viewer.imageryLayers.raiseToTop(this.imagelayers[lkey]);
  316. fun && fun(this.imagelayers[lkey]);
  317. viewer.flyTo(this.imagelayers[lkey]);
  318. },
  319. async regionChange(region) {
  320. // this.region = region;
  321. if (this.dlbm == "01") this.gtype = this.pageType ? "永久基本农田" : '耕地'
  322. if (region) this.nowyear = "";
  323. if (!this.nowyear) await this.GetDate();
  324. this.getData();
  325. },
  326. getData() {
  327. this.$emit("updateParent", "loading", true);
  328. this.Getzzxm();
  329. // this.Getkjxx();
  330. },
  331. async Getzzxm() {
  332. let parms = { year: this.nowyear, xzqhdm: this.region, dlbm: this.dlbm };
  333. if (this.$props.pageType == 0) {
  334. GetGdZl(parms).then((res) => {
  335. this.zldata = res.data;
  336. GetGdQxfl(parms).then((res) => {
  337. this.citymax = 0
  338. res.data.forEach(c => {
  339. c.number = (c.mj_m / this.zldata.mj_m * 100).toFixed(2);
  340. if (this.citymax < c.number) this.citymax = Math.ceil(c.number / 10) * 10;
  341. })
  342. this.cityList = res.data;
  343. });
  344. });
  345. if (this.dlbm == "01")
  346. GetGdFl(parms).then((res) => {
  347. this.fldata = res.data;
  348. });
  349. } else {
  350. GetYjjbntZl(parms).then((res) => {
  351. this.zldata = res.data;
  352. GetYjjbntQxfl(parms).then((res) => {
  353. this.citymax = 0
  354. res.data.forEach(c => {
  355. c.number = (c.mj_m / this.zldata.mj_m * 100).toFixed(2);
  356. if (this.citymax < c.number) this.citymax = Math.ceil(c.number / 10) * 10;
  357. })
  358. this.cityList = res.data;
  359. });
  360. });
  361. if (this.dlbm == "01")
  362. GetYjjbntFl(parms).then((res) => {
  363. this.fldata = res.data;
  364. });
  365. }
  366. this.GetLnbhqk();
  367. this.GetBhqk();
  368. },
  369. GetLnbhqk() {
  370. this.eData.xData = [];
  371. this.eData.yData = [[]];
  372. let parms = { year: this.nowyear, xzqhdm: this.region, dlbm: this.dlbm };
  373. if (!this.$props.pageType) {
  374. GetGdLnbhqk(parms).then(({ data }) => {
  375. this.lnbndata = data;
  376. this.setLnbh(data);
  377. });
  378. } else {
  379. GetYjjbntLnbhqk(parms).then(({ data }) => {
  380. this.lnbndata = data;
  381. this.setLnbh(data);
  382. });
  383. }
  384. },
  385. setLnbh(data) {
  386. this.eData.yName = `变化面积${this.unitList[this.nowunit].unit}`;
  387. this.eData.xData = [];
  388. this.eData.yData = [[]];
  389. data.forEach((res) => {
  390. this.eData.xData.push(res.year);
  391. this.eData.yData[0].push(res[this.uprops[this.nowunit]]);
  392. });
  393. this.setEchart(this.eData, 0);
  394. },
  395. GetBhqk() {
  396. let params = {
  397. sourceyear: this.nowyear,
  398. targeyear: this.tab,
  399. xzqhdm: this.region,
  400. };
  401. if (!this.$props.pageType) {
  402. GetGdBhqk(params).then((res) => {
  403. this.bhdata = res.data;
  404. });
  405. } else {
  406. GetYjjbntBhqk(params).then((res) => {
  407. this.bhdata = res.data;
  408. });
  409. }
  410. },
  411. async Getkjxx() {
  412. let res = await QueryList({
  413. jscType: "qytuzz_sdzl_kjxx",
  414. id: this.region,
  415. });
  416. this.active_tableData(res.data);
  417. },
  418. active_tableData(newVal) {
  419. newVal.forEach((res, index) => {
  420. let color = legends[res.type].color;
  421. if (res.geom)
  422. loadGeoJSON(res.geom, color, { isfly: true }, (data) => {
  423. geoSources[res.id] = data;
  424. data.name = "LandConsolidation";
  425. // data.entities.values.forEach((entity) => {
  426. // entity.properties = { type: "图斑上图", id: res.id };
  427. // });
  428. });
  429. });
  430. },
  431. contrast() {
  432. let dbdata = { id: this.region, fp: this.yearList.sort((a, b) => a.year - b.year), type: "gdbh" }; //+ this.$props.pageType,
  433. console.log("contrast", dbdata);
  434. this.$emit("contrast", dbdata);
  435. },
  436. fly() {
  437. // viewer.flyTo(this.imagelayers[this.nowlayer]);
  438. },
  439. sourcesshow(show) {
  440. this.setImager({ year: this.nowlayer }, show);
  441. },
  442. reset() {
  443. store.setaddNode([]);
  444. this.$nextTick(() => {
  445. // this.sourcesshow(false);
  446. Object.keys(this.imagelayers).forEach((key) => {
  447. viewer.imageryLayers.remove(this.imagelayers[key]);
  448. });
  449. this.imagelayers = {};
  450. this.typeList = [...JSON.parse(JSON.stringify(legends))];
  451. });
  452. },
  453. setEchart(data, id) {
  454. this.$nextTick(() => {
  455. this.$refs[`echartRef${id}`].setOptions(data);
  456. });
  457. },
  458. },
  459. watch: {
  460. region(newValue) {
  461. console.log(newValue, "---");
  462. },
  463. nowlayer(newValue, oldVal) {
  464. this.setImager({ year: oldVal }, false);
  465. this.setImager({ year: newValue }, true);
  466. },
  467. },
  468. beforeDestroy() {
  469. store.setaddNode([]);
  470. this.yearList.forEach((yi) => {
  471. viewer.imageryLayers.remove(this.imagelayers[yi.year]);
  472. });
  473. },
  474. };
  475. </script>
  476. <style lang="scss" scoped>
  477. .gdzl {
  478. height: 100%;
  479. .el-select {
  480. padding: 0 10px;
  481. }
  482. .headerSelect {
  483. width: 100%;
  484. height: 26px;
  485. // background: #00ffff;
  486. margin: 5px 0px;
  487. display: flex;
  488. justify-content: space-between;
  489. }
  490. .content {
  491. width: 100%;
  492. height: 190px;
  493. padding-top: 5px;
  494. .item {
  495. width: 32%;
  496. // height: 100px;
  497. display: inline-block;
  498. position: relative;
  499. .icon {
  500. width: 100%;
  501. height: 50px;
  502. display: flex;
  503. justify-content: space-between;
  504. }
  505. .iicon {
  506. background: no-repeat 50%;
  507. background-image: url("/static/images/overview/icon_yrkkg.png");
  508. width: 45px;
  509. height: 45px;
  510. flex: 1;
  511. }
  512. }
  513. .item50 {
  514. width: 48%;
  515. }
  516. .text {
  517. display: inline-block;
  518. // border: #00FFFF 1px solid;
  519. width: 100%;
  520. margin-bottom: 4px;
  521. text-align: center;
  522. margin-left: 0.3rem;
  523. .cvalue {
  524. font-family: "Arial Negreta", "Arial Normal", "Arial";
  525. font-weight: 700;
  526. font-style: normal;
  527. color: #68f4fb;
  528. }
  529. .unit {
  530. color: #fff;
  531. }
  532. }
  533. }
  534. .gdzlc {
  535. height: 65px;
  536. display: flex;
  537. justify-content: space-between;
  538. .item {
  539. width: 48%;
  540. height: 60px;
  541. padding-left: 20px;
  542. background: rgba(104, 244, 251, 0.21568627); // #2f5b71;
  543. border-radius: 5px;
  544. .icon {
  545. width: 50px;
  546. display: inline-block;
  547. }
  548. .text {
  549. display: inline-block;
  550. width: calc(100% - 60px);
  551. text-align: left;
  552. }
  553. }
  554. }
  555. .scontent {
  556. height: 60px;
  557. background: rgba(104, 244, 251, 0.21568627); //#2f5b71;
  558. border-radius: 5px;
  559. padding-top: 10px;
  560. margin-top: 5px;
  561. display: flex;
  562. .posNum {
  563. color: #ec808d !important;
  564. }
  565. .negNum {
  566. color: #00cc3a !important;
  567. }
  568. }
  569. .echars {
  570. // width: 100%;
  571. // height: calc(100% - 120px);
  572. // overflow-y: auto;
  573. // overflow-x: hidden;
  574. .echartTitle {
  575. height: 35px;
  576. }
  577. .block-title {
  578. width: calc(100% - 185px) !important;
  579. }
  580. .titlesel {
  581. width: 250px;
  582. display: flex;
  583. }
  584. }
  585. .echart {
  586. height: 200px !important;
  587. }
  588. .pietitle {
  589. position: relative;
  590. width: 200px;
  591. line-height: 26px;
  592. text-align: center;
  593. border: 1px solid #3f93f5;
  594. border-top-right-radius: 10px;
  595. margin: 10px 20% 0px 20%;
  596. color: #3f93f5;
  597. }
  598. .pie_echart {
  599. // width: 400px;
  600. margin-top: 10px;
  601. width: 21vw;
  602. height: 140px;
  603. }
  604. }
  605. </style>