HD.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. <template>
  2. <div class="map-ditu">
  3. <Tmap ref="map" :maplist="maplist" @feature-click="featureClick"></Tmap>
  4. <bottom-data :maplistArr="maplistArr" :defaultdata="defaultdata" />
  5. <div class="zuobian">
  6. <selecttree
  7. placeholder="请选择所属公司"
  8. :list="parentOpt"
  9. type="1"
  10. v-model="companyCode"
  11. @change="parentChange"
  12. :defaultParentProps="{
  13. children: 'children',
  14. label: 'companyName',
  15. value: 'codeNumber',
  16. }"
  17. >
  18. </selecttree>
  19. </div>
  20. <router-view></router-view>
  21. </div>
  22. </template>
  23. <script>
  24. import selecttree from "../../../components/selecttree.vue";
  25. import {
  26. getCompanyFieldNumberVo,
  27. getSysOrganizationAuthTreeByRoleId,
  28. } from "@/api/ledger.js";
  29. import Tmap from "@/components/map";
  30. import BottomData from "./component/bottomData.vue";
  31. export default {
  32. name: "Index",
  33. components: {
  34. Tmap,
  35. BottomData,
  36. selecttree,
  37. },
  38. props: {
  39. fieldCode: "",
  40. batchCode: "",
  41. },
  42. data() {
  43. return {
  44. ShowRi: true,
  45. treeval: "",
  46. value1: true,
  47. treeval: "", // 绑定的输入框值
  48. showTree: false, // 控制树列表显示
  49. treeData: [],
  50. maplist: [],
  51. maplistArr: {},
  52. totalList: [],
  53. parentOpt: [],
  54. companyCode: "",
  55. defaultdata: {},
  56. };
  57. },
  58. created() {
  59. this.GETtree();
  60. this.GETtotal();
  61. },
  62. mounted() {
  63. //模拟地图上的点位
  64. const data = this.maplist;
  65. // data.forEach((element) => {
  66. // console.log(element);
  67. // // this.$refs.map.addMarker({ point: [116.40740,39.90420], val: "1" });
  68. // });
  69. },
  70. methods: {
  71. // 获取总数
  72. GETtotal() {
  73. getCompanyFieldNumberVo().then((res) => {
  74. this.totalList = res.data;
  75. });
  76. },
  77. // 获取企业数
  78. async GETtree() {
  79. const res = await getSysOrganizationAuthTreeByRoleId();
  80. const treedata = res.data;
  81. const processedData = this.processTreeData(treedata);
  82. this.parentOpt = processedData;
  83. this.defaultdata = res.data[0];
  84. this.parentChange(this.defaultdata);
  85. // const firstLayer = this.findFirstFieldLayer(processedData);
  86. // if (firstLayer) {
  87. // this.parentChange( this.defaultdata);
  88. // }
  89. },
  90. //过滤数据
  91. processTreeData(treeData) {
  92. const processedData = [];
  93. function processNode(node) {
  94. if (node.codeType === "field") {
  95. node.companyName = node.fieldName;
  96. }
  97. if (node.children && node.children.length > 0) {
  98. node.children.forEach((child) => {
  99. processNode(child);
  100. });
  101. }
  102. }
  103. treeData.forEach((root) => {
  104. processNode(root);
  105. processedData.push(root);
  106. });
  107. return processedData;
  108. },
  109. handleTreeData() {
  110. this.treeData = this.processTreeData(this.treeData);
  111. },
  112. parseCoordinates(input) {
  113. if (input && typeof input === "string") {
  114. return input.split(",").map(Number);
  115. }
  116. // debugger;
  117. return [];
  118. },
  119. parentChange(data) {
  120. //data为当前选中对象
  121. this.$refs.map.clearMarkers();
  122. this.maplist = data;
  123. this.maplistArr = data;
  124. console.log(data, "parentChange");
  125. if (data.codeType === "field") {
  126. if (this.parseCoordinates(data.longitudeAndLatitudeString).length > 0) {
  127. this.$refs.map.addMarker({
  128. point: this.parseCoordinates(data.longitudeAndLatitudeString),
  129. val: data.analysisState,
  130. ...data,
  131. });
  132. return;
  133. }
  134. this.$refs.map.clearMarkers();
  135. } else {
  136. const dataMapList = data.children;
  137. dataMapList.forEach((element) => {
  138. console.log(element);
  139. if (
  140. this.parseCoordinates(element.longitudeAndLatitudeString).length >
  141. 0 &&
  142. element.codeType === "field"
  143. ) {
  144. this.$refs.map.addMarker({
  145. point: this.parseCoordinates(element.longitudeAndLatitudeString),
  146. val: element.analysisState,
  147. ...element,
  148. });
  149. return;
  150. }
  151. this.$refs.map.clearMarkers();
  152. });
  153. }
  154. },
  155. findFirstFieldLayer(data) {
  156. for (const item of data) {
  157. if (item.codeType === "field") {
  158. return item;
  159. }
  160. if (item.children && item.children.length > 0) {
  161. const childResult = this.findFirstFieldLayer(item.children);
  162. if (childResult) {
  163. return childResult;
  164. }
  165. }
  166. }
  167. return null;
  168. },
  169. featureClick(data) {
  170. console.log(data, "featureClick");
  171. const val = data.val;
  172. if (val === "-1" || val === -1 || val === 10) {
  173. this.$message.error("当前风场未完成分析");
  174. } else if (val === "0" || val === 0) {
  175. this.$message({
  176. message: "当前风场正在分析中",
  177. type: "warning",
  178. });
  179. } else if (val === "1" || val === 1 || val === "30" || val === 30) {
  180. console.log("打包成功");
  181. this.$router.push({
  182. path: "cockpitManage/electronic-map",
  183. query: {
  184. fieldCode: data.codeNumber,
  185. batchCode: data.batchCode,
  186. },
  187. });
  188. }
  189. },
  190. handleSwitchChange() {
  191. this.ShowRi = !this.ShowRi;
  192. },
  193. },
  194. };
  195. </script>
  196. <style lang="scss" scoped>
  197. .map-ditu {
  198. height: 93.3vh;
  199. display: flex;
  200. flex-direction: column;
  201. }
  202. // 动态计算 Tmap 组件高度
  203. Tmap {
  204. height: calc(93.3vh - 230px);
  205. min-height: 0; // 防止 flex 项溢出
  206. }
  207. // 设置 bottom-data 组件高度为 230px
  208. bottom-data {
  209. height: 230px;
  210. flex-shrink: 0; // 防止组件缩小
  211. }
  212. .zuobian{
  213. width: 180px;
  214. position: absolute;
  215. top: 10px;
  216. left: 10px;
  217. }
  218. </style>