Index.vue 7.2 KB

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