scjg.vue 8.1 KB

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