index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555
  1. <template>
  2. <div class="container">
  3. <el-row :gutter="10" style="height:100%;">
  4. <el-col style="height:100%;position: relative;" :span="24">
  5. <el-radio-group class="model" v-model="pattern" label="size control" size="small">
  6. <el-radio-button label="two-dimensional" @click="pattern = 'two-dimensional'">二维态势</el-radio-button>
  7. <el-radio-button label="three-dimensional" @click="pattern = 'three-dimensional'">三维态势</el-radio-button>
  8. </el-radio-group>
  9. <el-card class="table1">
  10. <div slot="header" class="clearfix">
  11. <span>兵力装备显示</span>
  12. </div>
  13. <el-table :data="maptable" @current-change="instanceChange" :row-style="{ height: '20px' }" :cell-style="{ padding: '0px' }">
  14. <el-table-column prop="platID" label="ID"></el-table-column>
  15. <el-table-column prop="platName" label="名称"></el-table-column>
  16. <el-table-column prop="isEnemy" label="敌我属性"></el-table-column>
  17. </el-table>
  18. </el-card>
  19. <el-card class="table2">
  20. <div slot="header" class="clearfix">
  21. <span>战损显示</span>
  22. </div>
  23. <el-table :data="healthtable" @current-change="instanceChange" :row-style="{ height: '20px' }" :cell-style="{ padding: '0px' }">
  24. <el-table-column prop="platID" label="ID"></el-table-column>
  25. <el-table-column prop="platName" label="名称"></el-table-column>
  26. <el-table-column prop="platState" label="健康度"></el-table-column>
  27. </el-table>
  28. </el-card>
  29. <div v-show="pattern == 'two-dimensional'" class="echarts-box">
  30. <div id="mapEchart" class="mapecharts"></div>
  31. </div>
  32. <div v-show="pattern == 'three-dimensional'" class="main-layout">
  33. <div id="cesiumContainer" class="mapecharts"></div>
  34. </div>
  35. </el-col>
  36. </el-row>
  37. </div>
  38. </template>
  39. <script>
  40. import { mapGetters } from 'vuex'
  41. export default ({
  42. computed: {
  43. ...mapGetters([
  44. 'map',
  45. 'init',
  46. 'platforms',
  47. 'instances',
  48. 'properties',
  49. 'platformShow'
  50. ]),
  51. },
  52. watch: {
  53. init: {
  54. handler: function (val, oldVal) {
  55. console.log(val)
  56. this.setTimer();
  57. }
  58. },
  59. platforms: {
  60. handler: function (val, oldVal) {
  61. }
  62. },
  63. instances: {
  64. handler: function (val, oldVal) {
  65. this.instancetable = val
  66. }
  67. },
  68. platformID: {
  69. handler: function (val, oldVal) {
  70. this.$wst.send({
  71. url: 'getRadarInstances',
  72. data: { PlatformID: val }
  73. })
  74. }
  75. },
  76. properties: {
  77. handler: function (val, oldVal) {
  78. this.propertyinittable = val.InitParams
  79. this.propertycontroltable = val.CtrlParams
  80. }
  81. },
  82. platformShow: {
  83. handler: function (val, oldVal) {
  84. this.resizeDom()
  85. }
  86. }
  87. },
  88. data() {
  89. return {
  90. pattern: "two-dimensional",
  91. instancetable: null,
  92. propertyinittable: null,
  93. propertycontroltable: null,
  94. timer: null,
  95. mapEchart: null,
  96. maptable: [
  97. {
  98. 'platID': '1001',
  99. 'platName': '弹道导弹1',
  100. 'isEnemy': '我方'
  101. },
  102. {
  103. 'platID': '1002',
  104. 'platName': '弹道导弹2',
  105. 'isEnemy': '我方'
  106. },
  107. // {
  108. // 'platID': '1003',
  109. // 'platName': '弹道导弹3',
  110. // 'isEnemy': '我方'
  111. // },
  112. // {
  113. // 'platID': '1004',
  114. // 'platName': '弹道导弹4',
  115. // 'isEnemy': '我方'
  116. // },
  117. // {
  118. // 'platID': '1005',
  119. // 'platName': '弹道导弹5',
  120. // 'isEnemy': '我方'
  121. // },
  122. // {
  123. // 'platID': '1006',
  124. // 'platName': '弹道导弹6',
  125. // 'isEnemy': '我方'
  126. // },
  127. // {
  128. // 'platID': '1007',
  129. // 'platName': '弹道导弹7',
  130. // 'isEnemy': '我方'
  131. // },
  132. {
  133. 'platID': '6001',
  134. 'platName': 'THADD系统1',
  135. 'isEnemy': '敌方'
  136. },
  137. {
  138. 'platID': '6002',
  139. 'platName': 'THADD系统2',
  140. 'isEnemy': '敌方'
  141. },
  142. ],
  143. healthtable: [
  144. {
  145. 'platID': '1001',
  146. 'platName': '弹道导弹1',
  147. 'platState': "85%"
  148. },
  149. {
  150. 'platID': '1002',
  151. 'platName': '弹道导弹2',
  152. 'platState': "90%"
  153. },
  154. // {
  155. // 'platID': '1003',
  156. // 'platName': '弹道导弹3',
  157. // 'platState': "90%"
  158. // },
  159. // {
  160. // 'platID': '1004',
  161. // 'platName': '弹道导弹4',
  162. // 'platState': "95%"
  163. // },
  164. // {
  165. // 'platID': '1005',
  166. // 'platName': '弹道导弹5',
  167. // 'platState': "100%"
  168. // },
  169. // {
  170. // 'platID': '1006',
  171. // 'platName': '弹道导弹6',
  172. // 'platState': "100%"
  173. // },
  174. // {
  175. // 'platID': '1007',
  176. // 'platName': '弹道导弹7',
  177. // 'platState': "100%"
  178. // },
  179. {
  180. 'platID': '6001',
  181. 'platName': 'THADD系统1',
  182. 'platState': "80%"
  183. },
  184. {
  185. 'platID': '6002',
  186. 'platName': 'THADD系统2',
  187. 'platState': '80%'
  188. },
  189. ],
  190. mapOption: {
  191. aria: {
  192. show: true
  193. },
  194. tooltip: {
  195. formatter: '{a}&name:{b}&location:{c}',
  196. },
  197. legend: {
  198. orient: 'vertical',
  199. left: 'left',
  200. data: ['categoryA', 'categoryB', 'categoryC']
  201. },
  202. geo: {
  203. map: "china",
  204. // zoom: 1,
  205. // center: [120.397128, 25.916527],
  206. roam: true,
  207. scaleLimit: {
  208. min: 1,
  209. max: 20
  210. },
  211. label: {
  212. color: "#fff",
  213. show: true
  214. },
  215. emphasis: {
  216. label: {
  217. color: "#fff",
  218. show: true
  219. },
  220. itemStyle: {
  221. areaColor: {
  222. x: 0,
  223. y: 0,
  224. x2: 0,
  225. y2: 1,
  226. colorStops: [
  227. {
  228. offset: 0,
  229. color: "#073684" // 0% 处的颜色
  230. },
  231. {
  232. offset: 1,
  233. color: "#2B91B7" // 100% 处的颜色
  234. }
  235. ]
  236. }
  237. }
  238. },
  239. itemStyle: {
  240. areaColor: {
  241. x: 0,
  242. y: 0,
  243. x2: 0,
  244. y2: 1,
  245. colorStops: [
  246. {
  247. offset: 0,
  248. color: "#073684" // 0% 处的颜色
  249. },
  250. {
  251. offset: 1,
  252. color: "#061E3D" // 100% 处的颜色
  253. }
  254. ]
  255. },
  256. borderColor: "#87ADCB",
  257. shadowColor: "rgba(10,76,139,1)",
  258. shadowOffsetY: 0,
  259. shadowBlur: 60,
  260. borderWidth: 1
  261. },
  262. tooltip: {
  263. show: false
  264. }
  265. },
  266. series: [
  267. {
  268. name: '我方飞机',
  269. type: 'scatter',
  270. coordinateSystem: 'geo',
  271. symbol: 'image://' + require('@/assets/image/redairplane.png'),
  272. symbolSize: 20,
  273. data: null,
  274. label: {
  275. normal: {
  276. formatter: '{b}',
  277. position: 'right',
  278. show: false
  279. },
  280. emphasis: {
  281. show: true
  282. }
  283. },
  284. itemStyle: {
  285. normal: {
  286. color: '#ddb926'
  287. //color: '#0000ff'
  288. }
  289. }
  290. },
  291. {
  292. name: '我方dddd',
  293. type: 'scatter',
  294. coordinateSystem: 'geo',
  295. symbol: 'image://' + require('@/assets/image/redmissile.png'),
  296. symbolSize: 20,
  297. data: null,
  298. label: {
  299. normal: {
  300. formatter: '{b}',
  301. position: 'right',
  302. show: false
  303. },
  304. emphasis: {
  305. show: true
  306. }
  307. },
  308. itemStyle: {
  309. normal: {
  310. color: '#ddb926'
  311. //color: '#0000ff'
  312. }
  313. }
  314. },
  315. {
  316. name: '敌方',
  317. type: 'scatter',
  318. coordinateSystem: 'geo',
  319. symbol: 'image://' + require('@/assets/image/blueradar.png'),
  320. symbolSize: 20,
  321. data: null,
  322. label: {
  323. normal: {
  324. formatter: '{b}',
  325. position: 'right',
  326. show: false
  327. },
  328. emphasis: {
  329. show: true
  330. }
  331. },
  332. itemStyle: {
  333. normal: {
  334. color: '#ff0000'
  335. }
  336. }
  337. },
  338. ]
  339. }
  340. }
  341. },
  342. mounted() {
  343. this.echartsInit();
  344. this.cesiumInit();
  345. // 页面加载设置高度自适应
  346. window.onresize = () => {
  347. this.resizeDom()
  348. };
  349. // 页面加载设置高度自适应
  350. this.resizeDom()
  351. if (this.init == 100) {
  352. this.setTimer();
  353. }
  354. },
  355. beforeDestroy() {
  356. this.timerDestory()
  357. },
  358. methods: {
  359. setTimer() {
  360. if (this.timer == null) {
  361. this.timer = setInterval(() => {
  362. console.log('开始定时...每过一秒执行一次')
  363. this.echartsInit()
  364. }, 1000)
  365. }
  366. },
  367. //初始化echarts
  368. echartsInit() {
  369. if (this.init == 100) { this.$wst.send({ url: 'getLocalMap' }) }
  370. if (this.map != null && this.map.type == 'local') { this.submitForm('mapEchart') }
  371. if (this.mapEchart == null) {
  372. this.mapEchart = this.$echarts.init(document.getElementById('mapEchart'))
  373. }
  374. this.mapEchart.setOption(this.mapOption);
  375. this.resizeDom()
  376. },
  377. //初始化echarts
  378. cesiumInit() {
  379. this.viewer = new this.Cesium.Viewer('cesiumContainer', {
  380. animation: true, // 是否显示时间轴动画
  381. baseLayerPicker: false,
  382. // homeButton: false,
  383. // geocoder: false,
  384. timeline: false,
  385. fullscreenButton: false,
  386. // sceneModePicker: false,
  387. navigationHelpButton: false,
  388. imageryProvider: new this.Cesium.ArcGisMapServerImageryProvider({
  389. url: 'https://server.arcgisonline.com/arcgis/rest/services/World_Terrain_Base/MapServer'
  390. }),
  391. });
  392. this.viewer._cesiumWidget._creditContainer.style.display = "none";
  393. },
  394. //通过窗体高宽计算容器高宽,渲染echart图表的div的宽高度以达到自适应目的
  395. resizeDom() {
  396. console.log("高度自适应")
  397. this.$echarts.init(document.getElementById('mapEchart')).resize()
  398. // var mapEchart = document.getElementById('mapEchart')
  399. // var mapEchart = document.getElementById('mapEchart')
  400. // var mapEchart = document.getElementById('mapEchart')
  401. // var mapEchart = document.getElementById('mapEchart')
  402. // const boxHeight = document.getElementsByClassName("echarts-box")[0].clientHeight
  403. // mapEchart.style.height = (boxHeight/2-65)+'px';
  404. // mapEchart.style.height = (boxHeight/2-65)+'px';
  405. // mapEchart.style.height = (boxHeight/2-65)+'px';
  406. // mapEchart.style.height = (boxHeight/2-65)+'px';
  407. },
  408. echartsChange() {
  409. this.timerDestory()
  410. this.echartsInit();
  411. this.setTimer();
  412. },
  413. timerDestory() {
  414. if (this.timer) {
  415. clearInterval(this.timer);
  416. }
  417. },
  418. submitForm(map) {
  419. console.log("放入数据")
  420. this.mapOption.series[0].data = this.map.data.friend.Planes;
  421. this.mapOption.series[1].data = this.map.data.friend.Missiles;
  422. this.mapOption.series[2].data = this.map.data.enemy.Radars;
  423. this.$echarts.init(document.getElementById(map)).setOption(this.mapOption);
  424. console.log(this.mapOption);
  425. },
  426. instanceChange(val) {
  427. if (val.instanceName.includes("信号侦察")) {
  428. this.$wst.send({
  429. url: 'getESMParams',
  430. data: { InstanceID: val.instanceID }
  431. })
  432. } else
  433. if (val.instanceName.includes("导航")) {
  434. this.$wst.send({
  435. url: 'getNavParams',
  436. data: { InstanceID: val.instanceID }
  437. })
  438. } else
  439. if (val.instanceName.includes("雷达")) {
  440. this.$wst.send({
  441. url: 'getRadarParams',
  442. data: { InstanceID: val.instanceID }
  443. })
  444. } else
  445. if (val.instanceName.includes("电子攻击")) {
  446. this.$wst.send({
  447. url: 'getECMParams',
  448. data: { InstanceID: val.instanceID }
  449. })
  450. }
  451. }
  452. },
  453. })
  454. </script>
  455. <style scoped>
  456. .model {
  457. position: absolute;
  458. top: 20px;
  459. left: 100px;
  460. z-index: 999;
  461. }
  462. .table1 {
  463. position: absolute;
  464. top: 40px;
  465. right: 20px;
  466. z-index: 999;
  467. width: 400px;
  468. height: 400px;
  469. }
  470. .table1 /deep/ .el-card__header {
  471. background-color: #11144e;
  472. color: white;
  473. }
  474. .table2 {
  475. position: absolute;
  476. top: 460px;
  477. right: 20px;
  478. z-index: 999;
  479. width: 400px;
  480. height: 400px;
  481. }
  482. .table2 /deep/ .el-card__header {
  483. background-color: #11144e;
  484. color: white;
  485. }
  486. .box-card {
  487. min-height: 100%;
  488. height: 100%;
  489. }
  490. /deep/ .el-card__body {
  491. height: 100% !important;
  492. padding: 0px !important;
  493. }
  494. .echarts-box {
  495. height: 100%;
  496. width: 100%;
  497. background-image: url('~@/assets/image/map-bg.png');
  498. background-repeat: no-repeat;
  499. background-size: 100% 100%;
  500. }
  501. .main-layout {
  502. height: 100%;
  503. width: 100%;
  504. }
  505. .container {
  506. height: 100%;
  507. }
  508. .mapecharts {
  509. width: 100%;
  510. height: 100%;
  511. }
  512. .tableHeight {
  513. flex-grow: 1;
  514. height: 33%;
  515. }
  516. .tableHeight /deep/ .el-card__body {
  517. height: calc(100% - 95px) !important;
  518. }
  519. </style>