HD.vue 5.6 KB

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