scjg.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366
  1. <template>
  2. <div class="scjg">
  3. <div class="downloadDiv">
  4. <div>
  5. <span class="xmmc">
  6. 项目名称:
  7. <span class="text">{{ scjgObj.xmmc }}</span>
  8. </span>
  9. <div
  10. class="eicon"
  11. :class="isshowAll ? 'eyes' : 'close_eyes'"
  12. @click="allChange('all')"
  13. ></div>
  14. </div>
  15. <div>
  16. 分析面积:
  17. <span class="text">{{ compute(scjgObj.fxmj) }}亩</span>
  18. <span class="export" @click="download">导出报告</span>
  19. </div>
  20. </div>
  21. <div v-for="(eitem, i) in echarts" :key="i" class="echars">
  22. <div class="echartTitle">
  23. <div class="block-title">{{ eitem.label }}</div>
  24. <div
  25. class="eicon"
  26. :class="eitem.iseyes ? 'eyes' : 'close_eyes'"
  27. @click="eyesChaneg(i)"
  28. ></div>
  29. <div
  30. class="eicon"
  31. :class="eitem.isshow ? 'eshow' : 'eclose'"
  32. @click="eitem.isshow = !eitem.isshow"
  33. ></div>
  34. </div>
  35. <scjgContent
  36. :ref="`contentRef${eitem.id}`"
  37. v-show="eitem.isshow"
  38. :litem="eitem"
  39. :piseyes="eitem.iseyes"
  40. @mapview="changeDataSources"
  41. ></scjgContent>
  42. <el-collapse v-if="eitem.lchildren.length" v-show="eitem.isshow">
  43. <collRecursiveTree
  44. :data="eitem.lchildren"
  45. :piseyes="eitem.iseyes"
  46. @addrefs="addrefs"
  47. @mapview="changeDataSources"
  48. ></collRecursiveTree>
  49. </el-collapse>
  50. </div>
  51. <!-- <div class="bottomBtns">
  52. <span></span>
  53. <span class="sureBtn" @click="download">导出报告</span>
  54. </div> -->
  55. </div>
  56. </template>
  57. <script>
  58. import scjgContent from "./scjgContent.vue";
  59. import collRecursiveTree from "./collRecursiveTree.vue";
  60. import { GetFxjg } from "@/api/ghss/hgxfx.js";
  61. // import hgxfx from "../../../../static/data/ghss/data.js";
  62. import parse from "wellknown";
  63. let dataSourceList = {};
  64. let colors = [
  65. "#62ADED",
  66. "#DFE15A",
  67. "#6EDC8D",
  68. "#00A42E",
  69. "#F9B447",
  70. "#7F4FE5",
  71. "#FF6969",
  72. "#27CED9",
  73. "#DF56F5",
  74. "#DCFFAF",
  75. ];
  76. export default {
  77. components: { scjgContent, collRecursiveTree },
  78. props: {
  79. scjgObj: {
  80. type: Object,
  81. },
  82. },
  83. data() {
  84. return {
  85. echarts: [],
  86. ruleForm: {
  87. name: "",
  88. xzmj: "",
  89. fileList: [],
  90. },
  91. tempdataSourcesId: null,
  92. fileid: 1,
  93. reflist: {},
  94. isshowAll: true,
  95. };
  96. },
  97. mounted() {
  98. // this.initData();
  99. },
  100. methods: {
  101. compute(mj) {
  102. return mj ? (mj * 0.0015).toFixed(2) : 0;
  103. },
  104. addrefs(key, ref) {
  105. this.reflist[key] = ref;
  106. },
  107. initData() {
  108. this.echarts = [];
  109. this.$emit("updateParent", "loading", true);
  110. this.addPolygon(this.$props.scjgObj.geom, "all", "#ff0000", true);
  111. GetFxjg({ bsm: this.$props.scjgObj.bsm }).then((res) => {
  112. if (res.success) {
  113. res.data.forEach((e) => {
  114. let c = e.dataList || [];
  115. c.map((ci) => {
  116. ci.name = ci.yslx_name || ci.scxname;
  117. // ci.value = this.compute(ci.mj);
  118. ci.value = ci.mj;
  119. ci.geom = ci.geom || "";
  120. // ci.label = ci.mc_name;
  121. });
  122. this.echarts.push({
  123. id: e.scxbsm,
  124. label: e.scxname,
  125. dataList: e.dataList,
  126. lchildren: e.children || [],
  127. iseyes: false,
  128. isshow: false,
  129. scxstyle: e.scxstyle,
  130. });
  131. if (e.scxstyle == 0) this.setEchart(c, e.scxbsm);
  132. if (e.children) this.lForEach(e.children, "echart");
  133. });
  134. this.$emit("updateParent", "loading", false);
  135. }
  136. });
  137. },
  138. allChange(id) {
  139. this.isshowAll = !this.isshowAll;
  140. if (dataSourceList[id]) {
  141. dataSourceList[id].show = this.isshowAll;
  142. } else {
  143. this.addPolygon(this.$props.scjgObj.geom, "all", "#ff0000", true);
  144. }
  145. },
  146. eyesChaneg(i) {
  147. this.echarts[i].iseyes = !this.echarts[i].iseyes;
  148. // if (i == 0 || i == 2) {
  149. // this.changeDataSources(this.echarts[i]);
  150. // } else {
  151. let iseyes = this.echarts[i].iseyes;
  152. if (this.echarts[i].dataList)
  153. this.echarts[i].dataList.forEach((child, ci) => {
  154. this.changeDataSources({ ...child, iseyes }, colors[ci]);
  155. });
  156. this.lForEach(this.echarts[i].lchildren, "sources", iseyes);
  157. // }
  158. // emit("eyesChaneg");
  159. },
  160. lForEach(data, fun, iseyes) {
  161. data.forEach((child) => {
  162. if (child.dataList) {
  163. child.dataList.forEach((ld, li) => {
  164. if (fun == "sources")
  165. this.changeDataSources({ ...ld, iseyes }, "#62ADED");
  166. else {
  167. ld.name = ld.yslx_name;
  168. ld.value = ld.mj;
  169. }
  170. });
  171. }
  172. if (child.children) {
  173. this.lForEach(child.children, fun, iseyes);
  174. }
  175. if (
  176. fun == "echart" &&
  177. child.scxstyle == 0 &&
  178. child.scxbsm.indexOf("GGFWSS") >= 0
  179. ) {
  180. child.id = child.scxbsm;
  181. setTimeout(() => {
  182. this.setEchart(child.dataList, child.id, child.id);
  183. }, 200);
  184. }
  185. });
  186. },
  187. changeDataSources({ geom, id, iseyes, iszoom }, color) {
  188. if (iszoom) {
  189. this.zoomTo(id, geom);
  190. } else if (dataSourceList[id]) {
  191. dataSourceList[id].show = iseyes;
  192. this.tempdataSourcesId = null;
  193. } else if (geom) {
  194. this.addPolygon(geom, id, color);
  195. }
  196. },
  197. zoomTo(id, geom) {
  198. let zid = "zoom" + id;
  199. if (!dataSourceList[zid]) {
  200. this.tempdataSourcesId = zid;
  201. this.addPolygon(geom, zid, "#ff0000");
  202. }
  203. },
  204. setEchart(data, id, childid) {
  205. this.$nextTick(() => {
  206. let type = data.length <= 6 ? "horizontal" : "vertical";
  207. if (!childid) this.$refs[`contentRef${id}`][0].setEchart(data, type);
  208. else {
  209. this.reflist[`contentRef${id}`].setEchart(data, type, childid);
  210. }
  211. });
  212. },
  213. // 加载GeoJSON数据
  214. addPolygon(geom, id, colors, fillreset) {
  215. let geojson = parse(geom);
  216. let _this = this;
  217. // viewer.entities.removeAll();
  218. let scolor = colors
  219. ? Cesium.Color.fromCssColorString(colors)
  220. : Cesium.Color.RED;
  221. let fcolor =
  222. colors && !fillreset
  223. ? Cesium.Color.fromCssColorString(colors)
  224. : Cesium.Color.WHITE;
  225. let polygon = Cesium.GeoJsonDataSource.load(geojson, {
  226. clampToGround: true,
  227. stroke: scolor,
  228. fill: fcolor.withAlpha(0.3), //注意:颜色必须大写,即不能为blue
  229. strokeWidth: 3,
  230. });
  231. polygon.then(function (dataSource) {
  232. // dataSource.id = id;
  233. // 将数据源添加到Cesium Viewer
  234. viewer.dataSources.add(dataSource);
  235. viewer.zoomTo(dataSource);
  236. dataSourceList[id] = dataSource;
  237. // 可以获取实体并进行操作
  238. // dataSource.entities.values.forEach((entity) => {
  239. // // 你可以在这里设置实体的属性,例如位置、颜色等
  240. // // console.log(entity);
  241. // });
  242. });
  243. },
  244. download() {
  245. // window.open(this.$props.scjgObj.fxbg); //this.$props.scjgObj.task.fxbg
  246. window.open(
  247. window.axiosURI +
  248. "/analyse/fzss/DownloadReport?filePath=" +
  249. `${this.$props.scjgObj.fxbg}`
  250. );
  251. },
  252. viewReport() {
  253. window.open(this.$props.scjgObj.fxbg.replace(".docx", ".pdf"), "_blank");
  254. },
  255. reset() {
  256. if (Object.keys(dataSourceList).length) viewer.dataSources.removeAll();
  257. dataSourceList = {};
  258. },
  259. },
  260. // watch(
  261. // () => prop.scjgObj,
  262. // (newValue, oldValue) => {
  263. // this.jcfwlist[0].value = newValue.task.fxmj + "m²";
  264. // nextTick(() => {
  265. // this.setEcharts(newValue);
  266. // });
  267. // }
  268. // );
  269. watch: {
  270. // scjgObj(newValue) {
  271. // this.initData();
  272. // },
  273. //监听区域id的变化,用于删除上一次点击生成的geojson区域面
  274. tempdataSourcesId(newVal, oldVal) {
  275. if (oldVal) {
  276. viewer.dataSources.remove(dataSourceList[oldVal]);
  277. dataSourceList[oldVal] = undefined;
  278. }
  279. },
  280. },
  281. };
  282. </script>
  283. <style lang="scss">
  284. .scjg {
  285. height: 100%;
  286. overflow-y: auto;
  287. overflow-x: hidden;
  288. padding-right: 10px;
  289. line-height: 40px;
  290. .downloadDiv {
  291. position: relative;
  292. .xmmc {
  293. width: calc(100% - 60px);
  294. display: inline-block;
  295. }
  296. .export {
  297. width: 95px;
  298. height: 28px;
  299. background: #0f7ac8;
  300. text-align: center;
  301. line-height: 32px;
  302. display: inline-block;
  303. position: absolute;
  304. right: 2px;
  305. bottom: 6px;
  306. }
  307. .text {
  308. color: #cddeeb;
  309. }
  310. }
  311. .eicon {
  312. width: 20px;
  313. height: 20px;
  314. margin-top: 10px;
  315. background-size: 100% 100%;
  316. display: inline-block;
  317. cursor: pointer;
  318. }
  319. .eyes {
  320. background-image: url("/static/images/ghzc/eyes.png");
  321. }
  322. .close_eyes {
  323. background-image: url("/static/images/ghzc/close_eyes.png");
  324. }
  325. .echars {
  326. margin-bottom: 10px;
  327. .echartTitle {
  328. width: 100%;
  329. height: 40px;
  330. display: flex;
  331. justify-content: space-between;
  332. // background: rgba(38, 38, 38, 0.9);
  333. border-bottom: 1px solid #166cad;
  334. margin-right: 10px;
  335. line-height: 40px;
  336. .block-title {
  337. width: calc(100% - 50px);
  338. }
  339. .eshow {
  340. background-image: url("/static/images/ghzc/to_bottom.png");
  341. }
  342. .eclose {
  343. background-image: url("/static/images/ghzc/to_right.png");
  344. }
  345. }
  346. .echart {
  347. width: 380px;
  348. height: 220px;
  349. }
  350. .echart_vertical {
  351. width: 380px;
  352. height: 370px;
  353. }
  354. }
  355. }
  356. </style>