scjg.vue 8.3 KB

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