Index.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. <template>
  2. <div class="map-ditu">
  3. <Tmap ref="map" :maplist="maplist" @feature-click="featureClick"></Tmap>
  4. <div class="ledata">
  5. <selecttree placeholder="请选择上级单位" :list="parentOpt" type="1" v-model="companyCode" @change="parentChange"
  6. :defaultParentProps="{
  7. children: 'children',
  8. label: 'companyName',
  9. value: 'codeNumber',
  10. }">
  11. </selecttree>
  12. <p>
  13. <span class="SpText">登录人风场总数:</span>
  14. {{ totalList?.fieldSumNumber ? totalList.fieldSumNumber : 0 }}
  15. </p>
  16. <p>
  17. <span class="SpText">已完成分析风场:</span>
  18. {{
  19. totalList?.analysisFinishNumber ? totalList.analysisFinishNumber : 0
  20. }}
  21. </p>
  22. <p>
  23. <span class="SpText">未完成分析风场:</span>
  24. {{
  25. totalList?.analysisUnFinishedNumber
  26. ? totalList.analysisUnFinishedNumber
  27. : 0
  28. }}
  29. </p>
  30. <p>
  31. <span class="SpText">风机数量:</span>
  32. {{ totalList?.engineGroupNumber ? totalList.engineGroupNumber : 0 }}
  33. </p>
  34. <p>
  35. <span class="SpText">风场状态:</span>
  36. <span class="red"></span>
  37. <span class="yellow"></span>
  38. <span class="green"></span>
  39. </p>
  40. <el-switch v-model="value1" active-text="显示" inactive-text="隐藏" @change="handleSwitchChange">
  41. </el-switch>
  42. </div>
  43. <Rightdata v-show="ShowRi" ref="childRef" :maplistArr="maplistArr" :defaultdata="defaultdata" class="ridata">
  44. </Rightdata>
  45. <router-view></router-view>
  46. </div>
  47. </template>
  48. <script>
  49. import selecttree from "../../../components/selecttree.vue";
  50. import {
  51. getCompanyFieldNumberVo,
  52. getSysOrganizationAuthTreeByRoleId,
  53. } from "@/api/ledger.js";
  54. import Tmap from "@/components/map";
  55. import Rightdata from "./component/rightdata.vue";
  56. export default {
  57. name: "Index",
  58. components: {
  59. Tmap,
  60. Rightdata,
  61. selecttree,
  62. },
  63. data() {
  64. return {
  65. ShowRi: true,
  66. treeval: "",
  67. value1: true,
  68. treeval: "", // 绑定的输入框值
  69. showTree: false, // 控制树列表显示
  70. treeData: [],
  71. maplist: [],
  72. maplistArr: {},
  73. totalList: [],
  74. parentOpt: [],
  75. companyCode: "",
  76. defaultdata: {},
  77. };
  78. },
  79. created() {
  80. this.GETtree();
  81. this.GETtotal();
  82. // 页面初始化时手动触发一次赋值操作
  83. this.$watch("defaultdata", (newValue) => {
  84. this.maplistArr = newValue; // 将defaultdata的值赋给maplistArr
  85. });
  86. this.maplistArr = this.defaultdata;
  87. },
  88. mounted() {
  89. //模拟地图上的点位
  90. const data = this.maplist;
  91. // data.forEach((element) => {
  92. // console.log(element);
  93. // // this.$refs.map.addMarker({ point: [116.40740,39.90420], val: "1" });
  94. // });
  95. },
  96. methods: {
  97. // 获取总数
  98. GETtotal() {
  99. getCompanyFieldNumberVo().then((res) => {
  100. this.totalList = res.data;
  101. });
  102. },
  103. // 获取企业数
  104. async GETtree() {
  105. const res = await getSysOrganizationAuthTreeByRoleId();
  106. const treedata = res.data;
  107. const processedData = this.processTreeData(treedata);
  108. this.parentOpt = processedData;
  109. this.defaultdata = res.data[0];
  110. },
  111. //过滤数据
  112. processTreeData(treeData) {
  113. const processedData = [];
  114. function processNode(node) {
  115. if (node.codeType === "field") {
  116. node.companyName = node.fieldName;
  117. }
  118. if (node.children && node.children.length > 0) {
  119. node.children.forEach((child) => {
  120. processNode(child);
  121. });
  122. }
  123. }
  124. treeData.forEach((root) => {
  125. processNode(root);
  126. processedData.push(root);
  127. });
  128. return processedData;
  129. },
  130. parseCoordinates(input) {
  131. if (input && typeof input === "string") {
  132. return input.split(",").map(Number);
  133. }
  134. return [];
  135. },
  136. parentChange(data) {
  137. //data为当前选中对象
  138. this.$refs.map.clearMarkers();
  139. this.maplist = data;
  140. this.maplistArr = data;
  141. console.log(data, "parentChange");
  142. if (data.codeType === "field") {
  143. if (this.parseCoordinates(data.longitudeAndLatitudeString).length > 0) {
  144. this.$refs.map.addMarker({
  145. point: this.parseCoordinates(data.longitudeAndLatitudeString),
  146. val: data.analysisState,
  147. ...data,
  148. });
  149. return;
  150. }
  151. this.$refs.map.clearMarkers();
  152. } else {
  153. const dataMapList = data.children;
  154. dataMapList.forEach((element) => {
  155. console.log(element);
  156. if (
  157. this.parseCoordinates(element.longitudeAndLatitudeString).length >
  158. 0 &&
  159. element.codeType === "field"
  160. ) {
  161. this.$refs.map.addMarker({
  162. point: this.parseCoordinates(element.longitudeAndLatitudeString),
  163. val: element.analysisState,
  164. ...element,
  165. });
  166. return;
  167. }
  168. this.$refs.map.clearMarkers();
  169. });
  170. }
  171. },
  172. featureClick(data) {
  173. console.log(data, "featureClick");
  174. const val = data.val;
  175. if (val === "-1" || val === -1) {
  176. this.$message.error("当前风场未进行分析");
  177. } else if (val === "0" || val === 0) {
  178. this.$message({
  179. message: "当前风场正在分析中",
  180. type: "warning",
  181. });
  182. } else if (val === "1" || val === 1) {
  183. this.$router.push({
  184. path: "cockpitManage/electronic-map",
  185. query: {
  186. fieldCode: data.codeNumber,
  187. },
  188. });
  189. }
  190. },
  191. handleSwitchChange() {
  192. this.ShowRi = !this.ShowRi;
  193. },
  194. },
  195. };
  196. </script>
  197. <style lang="scss" scoped>
  198. .map-ditu {
  199. // min-width: 86.9vw;
  200. // max-width: 94.9vw;
  201. height: 93vh;
  202. position: relative;
  203. }
  204. .ridata {
  205. position: absolute;
  206. top: 20px;
  207. right: 20px;
  208. }
  209. .ledata {
  210. font-size: 14px;
  211. width: 300px;
  212. position: absolute;
  213. top: 20px;
  214. left: 60px;
  215. background: #008080;
  216. padding: 10px;
  217. color: #fff;
  218. border-radius: 5px;
  219. p {
  220. line-height: 24px;
  221. .SpText {
  222. display: inline-block;
  223. width: 120px;
  224. text-align: right;
  225. }
  226. .red,
  227. .yellow,
  228. .green {
  229. display: inline-block;
  230. width: 30px;
  231. height: 12px;
  232. margin-right: 5px;
  233. }
  234. .red {
  235. background-color: #e16757;
  236. }
  237. .yellow {
  238. background-color: #eecb5f;
  239. }
  240. .green {
  241. background-color: #7ecf51;
  242. }
  243. }
  244. }
  245. ::v-deep .el-switch__label.is-active {
  246. color: #fff;
  247. }
  248. </style>