Index.vue 7.1 KB

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