index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416
  1. <template>
  2. <div class="screen-container">
  3. <bd-map :center="[121.9580475686964, 30.949993496740227]" :loaded="loaded"/>
  4. <div class="screen-title-container"><span class="title-content">{{ $t("screen.title") }}</span></div>
  5. <content-block :title="$t('screen.consManage')" class="screen-left-container">
  6. <template v-slot:content>
  7. <div class="control-content">
  8. <div class="ctl-item">
  9. <el-input :placeholder="$t('common.typeInfo',{name: $t('common.content')})" v-model="searchVal"
  10. class="input-with-select">
  11. <el-button slot="append" icon="el-icon-search"></el-button>
  12. </el-input>
  13. </div>
  14. <div class="ctl-item">
  15. <cons-unit-tree
  16. :placeholder="$t('common.select', {name: $t('cons.consUnit')})"
  17. v-model="consUnit"
  18. />
  19. </div>
  20. </div>
  21. <div class="machine-list">
  22. <div class="list-container-title">
  23. {{ $t("screen.machineList") }}
  24. <span v-if="loading" style="font-size: 10px;color: #fefefe;margin-left: 10px">
  25. {{
  26. $t("common.loading")
  27. }}
  28. </span>
  29. </div>
  30. <div class="content-list infinite-list-wrapper"
  31. v-infinite-scroll="loadMachine"
  32. :infinite-scroll-disabled="disabled"
  33. >
  34. <div v-for="item in machineList"
  35. :class="{'list-item':true,'selected-item': selectMachine && item.id===selectMachine.id}"
  36. :key="item.id" @click="handleMachineClick(item)">
  37. <i class="machine-status"
  38. :style="{backgroundColor: MachineStatus[item.status].color }"/>
  39. {{ item.name }}({{ item.machineNum }})
  40. </div>
  41. <p v-if="noMore" class="no-more" style="margin-top: auto">{{ $t("common.noMore") }}</p>
  42. </div>
  43. </div>
  44. </template>
  45. </content-block>
  46. <div class="screen-right-container">
  47. <content-block :title="$t('screen.onlineMachine')" class="online-machine-block">
  48. <template v-slot:content>
  49. <div class="online-summery">
  50. <div class="machine-pie-chart">
  51. <pie-chart-block :optCfg="machineOpt"/>
  52. </div>
  53. <div class="machine-pie-legend">
  54. <div class="legend-item">
  55. <i :style="{ backgroundColor:machineOpt.color[0] }"/>
  56. <span>{{ $t('screen.onlineMachine') }}</span>
  57. <span>{{ machineStatusCnt.online || 0 }}</span>
  58. </div>
  59. <div class="legend-item">
  60. <i :style="{ backgroundColor:machineOpt.color[1] }"/>
  61. <span>{{ $t('screen.offlineMachine') }}</span>
  62. <span>{{ machineStatusCnt.offline || 0 }}</span>
  63. </div>
  64. </div>
  65. </div>
  66. <div class="online-list">
  67. <div class="list-item" v-for="item in onlineMachine">
  68. <span class="machine-name">{{ item.name }}</span>
  69. <span class="cons-unit">{{ item.machineNum }}</span>
  70. </div>
  71. </div>
  72. </template>
  73. </content-block>
  74. <MachineIndex v-if="selectMachine" :select-machine="selectMachine">
  75. <template v-slot:title-right="scop">
  76. <el-tooltip
  77. class="item"
  78. effect="dark"
  79. content="click to machine"
  80. placement="top"
  81. >
  82. <svg-icon icon-class="location" @click="()=>{locationMachine(scop.data)}"/>
  83. </el-tooltip>
  84. <el-tooltip
  85. class="item"
  86. effect="dark"
  87. content="close"
  88. placement="top"
  89. >
  90. <i class="el-icon-close" @click="()=>{locationClose()}" style="margin-left: 5px"/>
  91. </el-tooltip>
  92. </template>
  93. </MachineIndex>
  94. <div class="pile-status-legend">
  95. <div class="legend-item" v-for="item in LegendItem">
  96. <i :style="{ backgroundColor:item.color }"/>
  97. {{ item.name }}
  98. </div>
  99. </div>
  100. </div>
  101. <!-- <PileHoleDetail ref="pileHoleDialog"/>-->
  102. </div>
  103. </template>
  104. <script>
  105. import BdMap from "@/components/map/index.vue";
  106. import Treeselect from "@riophae/vue-treeselect";
  107. import ConsUnitTree from "@/views/cons/consUnit/ConsUnitTree.vue";
  108. import ContentBlock from "@/views/cons/screen/ContentBlock.vue";
  109. import PieChartBlock from "@/components/charts/PieChartBlock.vue";
  110. import LineChartBlock from "@/components/charts/LineChartBlock.vue";
  111. import {calcPileMachineOnOffline, getConsUnitMachine, listAllPileMachineInfo} from "@/api/cons/pileMachineInfo";
  112. import {listPileHoleRealtimeIndex} from "@/api/cons/pileHoleInfo";
  113. import maphandle from "@/components/map/maphandle";
  114. import MachineIndex from "@/views/cons/screen/MachineIndex.vue";
  115. import PileHoleDetail from "@/views/cons/screen/PileHoleDetail.vue";
  116. import {copyObj} from "@/utils";
  117. import {Circle} from "@/components/map/GeoJson";
  118. import pileMachine from "./img/pile-machine.svg"
  119. import {MachineStatus} from "@/utils/EnumConst";
  120. import ComponentHandle from "@/utils/ComponentHandle"
  121. export default {
  122. components: {
  123. PileHoleDetail,
  124. MachineIndex,
  125. LineChartBlock,
  126. PieChartBlock,
  127. ContentBlock,
  128. ConsUnitTree,
  129. BdMap,
  130. Treeselect
  131. },
  132. mixins: [maphandle],
  133. props: {
  134. ws: {
  135. type: String,
  136. default: '',
  137. },
  138. },
  139. computed: {
  140. MachineStatus() {
  141. return MachineStatus
  142. },
  143. noMore() {
  144. return this.count >= 100
  145. },
  146. disabled() {
  147. return this.loading || this.noMore
  148. }
  149. },
  150. watch: {
  151. consUnit(val) {
  152. this.loadMachine()
  153. },
  154. searchVal(val) {
  155. this.searchValOnchange()
  156. },
  157. onlineMachine(val) {
  158. val && this.addMachineMarker()
  159. }
  160. },
  161. data() {
  162. return {
  163. mapIns: null,
  164. consUnit: null,
  165. searchVal: "",
  166. count: 10,
  167. loading: false,
  168. machineList: [],
  169. machineOriList: [],
  170. selectMachine: null,
  171. pileMachineLayer: null,
  172. realtimeInterVal: null,
  173. machineLatextIndex: {},
  174. pileHoleList: [],
  175. pileHoleLayer: null,
  176. machineStatusCnt: {},
  177. onlineMachine: [],
  178. hisClickGeom: null,
  179. machineOpt: {
  180. color: ['#006699', '#4cabce'],
  181. tooltip: {
  182. show: false
  183. },
  184. legend: {
  185. show: false,
  186. top: 0
  187. },
  188. label: {
  189. show: false,
  190. },
  191. emphasis: {
  192. label: {
  193. show: false,
  194. }
  195. },
  196. labelLine: {
  197. show: false
  198. },
  199. series: [
  200. {
  201. type: 'pie',
  202. radius: ['50%', '70%'],
  203. center: ['50%', '50%'],
  204. label: {
  205. show: false,
  206. position: 'center'
  207. },
  208. data: [
  209. {
  210. value: 19,
  211. name: 'online',
  212. },
  213. {
  214. value: 75,
  215. name: 'offline',
  216. }
  217. ],
  218. },
  219. ],
  220. },
  221. LegendItem: {
  222. NotStated: {
  223. color: '#C1C1C1',
  224. name: this.$t("screen.notStart")
  225. },
  226. InProcess: {
  227. color: '#FF5454',
  228. name: this.$t("screen.inProcess")
  229. },
  230. Completed: {
  231. color: '#93D467',
  232. name: this.$t("screen.completed")
  233. },
  234. Deviation: {
  235. color: '#F6E65C',
  236. name: this.$t("screen.deviation")
  237. }
  238. }
  239. };
  240. },
  241. // 组件卸载前清空图层信息
  242. beforeDestroy() {
  243. this.destroyLayer(this.pileHoleLayer.cust.layerId, this.mapIns)
  244. this.destroyLayer(this.pileMachineLayer.cust.layerId, this.mapIns)
  245. },
  246. created() {
  247. },
  248. mounted() {
  249. },
  250. methods: {
  251. init() {
  252. this.loadMachine()
  253. this.loadMachineOnOffline()
  254. this.loadOnlineMachine()
  255. },
  256. loadMachine() {
  257. this.loading = true;
  258. getConsUnitMachine(this.consUnit).then((response) => {
  259. this.machineList = response.data
  260. this.machineOriList = copyObj(response.data)
  261. this.searchValOnchange()
  262. this.count = 100
  263. this.loading = false
  264. })
  265. },
  266. loadOnlineMachine() {
  267. listAllPileMachineInfo({
  268. status: "00"
  269. }).then(response => {
  270. this.onlineMachine = response.rows
  271. });
  272. },
  273. addMachineMarker() {
  274. this.onlineMachine.forEach(item => {
  275. let marker = new BDLayers.Lib.Overlays.Marker(`marker${item.id}`, [item.lng, item.lat], {
  276. symbol: {
  277. 'textName': `${item.name}`,
  278. 'textSize': 12,
  279. markerWidth: 45,
  280. markerHeight: 45,
  281. markerDx: 30,
  282. textDx: 30,
  283. textDy: 10,
  284. 'markerFile': pileMachine,
  285. }
  286. });
  287. marker.on('click', () => {
  288. this.selectMachine = item
  289. })
  290. this.pileMachineLayer.addMarker(marker)
  291. })
  292. },
  293. searchValOnchange() {
  294. if (this.searchVal) {
  295. this.machineList = this.machineOriList.filter(item => `${item.name}(${item.machineNum})`.includes(this.searchVal))
  296. }
  297. },
  298. loadMachineOnOffline() {
  299. calcPileMachineOnOffline().then(response => {
  300. if (response.data) {
  301. const {online, offline} = response.data
  302. this.machineStatusCnt = response.data
  303. this.machineOpt.series[0].data = [{
  304. value: online,
  305. name: 'online'
  306. },
  307. {
  308. value: offline,
  309. name: 'offline'
  310. }]
  311. }
  312. })
  313. },
  314. loadPileHole() {
  315. listPileHoleRealtimeIndex({}).then(response => {
  316. this.pileHoleList = response.data
  317. this.pileHoleList.forEach((item, index) => {
  318. const geom = new BDLayers.Lib.Overlays.FromGeoJson(Circle({
  319. radius: 0.4,
  320. coordinates: [item.lng, item.lat],
  321. symbol: [
  322. {
  323. lineColor: '#34495e',
  324. lineWidth: 1,
  325. polygonFill: '#1bbc9b',
  326. polygonOpacity: 0.2
  327. }
  328. ]
  329. }).geojson);
  330. geom.cust = item
  331. geom.on('click', (e) => {
  332. if (this.hisClickGeom) {
  333. this.hisClickGeom.updateSymbol([
  334. {
  335. lineColor: '#34495e',
  336. lineWidth: 1,
  337. polygonFill: '#1bbc9b',
  338. polygonOpacity: 0.2
  339. }
  340. ])
  341. }
  342. this.hisClickGeom = geom
  343. geom.updateSymbol([
  344. {
  345. lineColor: 'green',
  346. lineWidth: 1,
  347. polygonFill: '#1bbc9b',
  348. polygonOpacity: 0.2
  349. }
  350. ])
  351. const pileHoleInfo = e.target.cust
  352. geom.setPopWindow({
  353. autoPan: true,
  354. content: `<div id='pop-window' class="window-content"></div>`
  355. });
  356. ComponentHandle.createComponent({
  357. wrapper: 'pop-window',
  358. component: PileHoleDetail,
  359. props: pileHoleInfo,
  360. onclose: () => {
  361. if (this.hisClickGeom) {
  362. this.hisClickGeom.updateSymbol([
  363. {
  364. lineColor: '#34495e',
  365. lineWidth: 1,
  366. polygonFill: '#1bbc9b',
  367. polygonOpacity: 0.2
  368. }
  369. ])
  370. }
  371. geom.closePopWindow();
  372. }
  373. });
  374. })
  375. this.pileHoleLayer.addGeometry(geom);
  376. })
  377. })
  378. },
  379. loaded(map) {
  380. this.mapIns = map
  381. this.pileHoleLayer = this.createLayer(map)
  382. this.pileMachineLayer = this.createLayer(map)
  383. this.loadPileHole()
  384. this.init();
  385. },
  386. handleClick(e) {
  387. },
  388. handleMachineClick(item) {
  389. if (item.status === MachineStatus.offline.code) {
  390. return;
  391. }
  392. if (this.selectMachine && this.selectMachine.id === item.id) {
  393. this.locationClose()
  394. return
  395. }
  396. this.locationMachine(item)
  397. this.selectMachine = item
  398. },
  399. locationMachine(selectMachine) {
  400. this.mapIns.flyToPoint([selectMachine.lng, selectMachine.lat], {duration: 1000})
  401. },
  402. locationClose() {
  403. this.selectMachine = null
  404. },
  405. },
  406. };
  407. </script>
  408. <style lang="scss" src="./index.scss" scoped/>