scjg.vue 6.6 KB

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