scjg.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  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">{{ scjgObj.xzmj }}平方千米</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-show="eitem.isshow"
  32. class="echart"
  33. :class="`echart${i}`"
  34. @echartClick="echartClick"
  35. :ref="`echartRef`"
  36. ></pie>
  37. </div>
  38. <!-- <div class="bottomBtns">
  39. <span></span>
  40. <span class="sureBtn" @click="download">导出报告</span>
  41. </div> -->
  42. </div>
  43. </template>
  44. <script>
  45. import pie from "@/components/echartsTemplate/pie.vue";
  46. import hgxfx from "../../../../static/data/ghss/data.js";
  47. let colors = [
  48. ["#FC8053", "#F2CAA4"],
  49. ["#5583e7", "#36dddb"],
  50. ["#f888b1", "#fbe6ee"],
  51. ];
  52. export default {
  53. components: { pie },
  54. props: {
  55. scjgObj: {
  56. type: Object,
  57. },
  58. },
  59. data() {
  60. return {
  61. echarts: [],
  62. ruleForm: {
  63. name: "",
  64. xzmj: "",
  65. fileList: [],
  66. },
  67. dataSources: {},
  68. };
  69. },
  70. mounted() {
  71. hgxfx.treeData.forEach((e) => {
  72. if (e.label == "控制性详细规划") e.label = "详细规划分析";
  73. this.echarts.push({ ...e, iseyes: false, isshow: true });
  74. });
  75. this.setEchart1();
  76. this.setEchart2();
  77. // this.setEchart3();
  78. this.setEchart4();
  79. },
  80. methods: {
  81. eyesChaneg(i) {
  82. this.echarts[i].iseyes = !this.echarts[i].iseyes;
  83. if (i == 0 || i == 2) {
  84. this.changeDataSources(this.echarts[i]);
  85. } else {
  86. let iseyes = this.echarts[i].iseyes;
  87. this.echarts[i].children.forEach((child, ci) => {
  88. this.changeDataSources({ ...child, iseyes }, colors[ci]);
  89. });
  90. }
  91. // emit("eyesChaneg");
  92. },
  93. changeDataSources({ label, id, iseyes }, color) {
  94. if (this.dataSources[id]) {
  95. this.dataSources[id].show = iseyes;
  96. } else this.addPolygon(label, id, color);
  97. },
  98. echartClick(name, iseyes) {
  99. if (this.echarts[1].iseyes) {
  100. let click = this.echarts[1].children.filter((c) => c.label == name);
  101. if (click.length > 0)
  102. this.changeDataSources({
  103. label: click[0].label,
  104. id: click[0].id,
  105. iseyes,
  106. });
  107. }
  108. },
  109. setEchart1() {
  110. this.$nextTick(() => {
  111. this.$refs.echartRef[0].setOptions({
  112. type: "vertical",
  113. data: hgxfx.xzfxlist,
  114. });
  115. });
  116. },
  117. setEchart2() {
  118. this.$nextTick(() => {
  119. let setoptions = {
  120. data: hgxfx.sxfxlist,
  121. type: "horizontal", //横向
  122. isclick: true,
  123. };
  124. this.$refs.echartRef[1].setOptions(setoptions);
  125. });
  126. },
  127. setEchart3() {
  128. this.$nextTick(() => {
  129. this.$refs.echartRef[2].setOptions({ data: tdlylist });
  130. });
  131. },
  132. setEchart4() {
  133. this.$nextTick(() => {
  134. this.$refs.echartRef[2].setOptions({
  135. data: hgxfx.xxghlist,
  136. type: "vertical",
  137. });
  138. });
  139. },
  140. // 加载GeoJSON数据
  141. addPolygon(label, id, colors) {
  142. let _this = this;
  143. // viewer.entities.removeAll();
  144. let scolor = colors
  145. ? Cesium.Color.fromCssColorString(colors[0])
  146. : Cesium.Color.BLUE;
  147. let fcolor = colors
  148. ? Cesium.Color.fromCssColorString(colors[1])
  149. : Cesium.Color.WHITE;
  150. let polygon = Cesium.GeoJsonDataSource.load(
  151. `/static/data/ghss/${label}.geojson`,
  152. {
  153. clampToGround: true,
  154. stroke: scolor,
  155. fill: fcolor.withAlpha(0.3), //注意:颜色必须大写,即不能为blue
  156. strokeWidth: 3,
  157. }
  158. );
  159. polygon.then(function (dataSource) {
  160. // dataSource.id = id;
  161. // 将数据源添加到Cesium Viewer
  162. viewer.dataSources.add(dataSource);
  163. viewer.zoomTo(dataSource);
  164. _this.dataSources[id] = dataSource;
  165. // 可以获取实体并进行操作
  166. // dataSource.entities.values.forEach((entity) => {
  167. // // 你可以在这里设置实体的属性,例如位置、颜色等
  168. // // console.log(entity);
  169. // });
  170. });
  171. },
  172. download() {
  173. window.open(this.$props.scjgObj.fxbg); //this.$props.scjgObj.task.fxbg
  174. },
  175. viewReport() {
  176. window.open(this.$props.scjgObj.fxbg.replace(".docx", ".pdf"), "_blank");
  177. },
  178. reset() {
  179. if (Object.keys(this.dataSources).length) viewer.dataSources.removeAll();
  180. this.dataSources = {};
  181. },
  182. },
  183. // watch(
  184. // () => prop.scjgObj,
  185. // (newValue, oldValue) => {
  186. // this.jcfwlist[0].value = newValue.task.fxmj + "m²";
  187. // nextTick(() => {
  188. // this.setEcharts(newValue);
  189. // });
  190. // }
  191. // );
  192. watch: {},
  193. };
  194. </script>
  195. <style lang="scss" scoped>
  196. .scjg {
  197. height: 100%;
  198. overflow-y: auto;
  199. overflow-x: hidden;
  200. line-height: 40px;
  201. .downloadDiv {
  202. .xmmc {
  203. width: calc(100% - 120px);
  204. display: inline-block;
  205. }
  206. .export {
  207. width: 116px;
  208. height: 32px;
  209. background: #0f7ac8;
  210. text-align: center;
  211. line-height: 32px;
  212. display: inline-block;
  213. }
  214. }
  215. .text {
  216. color: #cddeeb;
  217. }
  218. .echars {
  219. margin-bottom: 10px;
  220. .echartTitle {
  221. width: calc(100% - 10px);
  222. height: 40px;
  223. display: flex;
  224. justify-content: space-between;
  225. // background: rgba(38, 38, 38, 0.9);
  226. border-bottom: 1px solid #166cad;
  227. margin-right: 10px;
  228. line-height: 40px;
  229. .block-title {
  230. width: calc(100% - 80px);
  231. }
  232. .eicon {
  233. width: 30px;
  234. height: 30px;
  235. margin: 5px;
  236. background-size: 100% 100%;
  237. }
  238. .eyes {
  239. background-image: url("/static/images/ghzc/eyes.png");
  240. }
  241. .close_eyes {
  242. background-image: url("/static/images/ghzc/close_eyes.png");
  243. }
  244. .eshow {
  245. background-image: url("/static/images/ghzc/to_bottom.png");
  246. }
  247. .eclose {
  248. background-image: url("/static/images/ghzc/to_right.png");
  249. }
  250. }
  251. .echart {
  252. width: 380px;
  253. height: 220px;
  254. }
  255. .echart0,
  256. .echart2 {
  257. width: 380px;
  258. height: 370px;
  259. }
  260. }
  261. }
  262. </style>