BoxCommonVector.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636
  1. <template>
  2. <div class="BoxCommonVector" v-if="title">
  3. <div class="innerContainerVector leftPaneVector" v-drag>
  4. <h2 class="PangetitleVector">
  5. <span class="pange_textVector">{{ title }}</span>
  6. </h2>
  7. <i class="el-icon-close" @click="close"></i>
  8. <el-input clearable v-model="state" @input="change_witch" class="search" placeholder="请输入内容"></el-input>
  9. <el-table :data="active_dableData" style="width: 100%" height="650" :header-cell-style="{
  10. background: 'rgba(10, 25, 38, 0.6)',
  11. color: '#66b1ff',
  12. fontSize: '14px',
  13. fontFamily: 'Microsoft YaHei',
  14. fontWeight: '400',
  15. }">
  16. <el-table-column show-overflow-tooltip="true" v-for="(index, item) in store.state.cockpit_vector.columns"
  17. :key="index" width="120" :prop="store.state.cockpit_vector.columns[item]"
  18. :label="store.state.cockpit_vector.columns[item]">
  19. </el-table-column>
  20. <el-table-column fixed="right" label="操作" width="50">
  21. <template slot-scope="scope">
  22. <!-- <el-button @click="info(scope.row)" type="text" size="small">详情</el-button> -->
  23. <el-button @click="go(scope.row)" type="text" size="small">定位</el-button>
  24. </template>
  25. </el-table-column>
  26. </el-table>
  27. </div>
  28. </div>
  29. </template>
  30. <script>
  31. import { QueryList } from '@/api/cockpitNew'
  32. import * as tdsy from "@/views/cockpit/js/tdsy";
  33. import * as wellknown from "wellknown";
  34. import * as turf from "@turf/turf";
  35. let BoxCommonVector_entity = null;
  36. export default {
  37. data() {
  38. return {
  39. state: '',
  40. timeout: null,
  41. title: "",
  42. active_dableData: null,
  43. tableData: null,
  44. };
  45. },
  46. methods: {
  47. multiPolygonToPolygons(multiPolygon) {
  48. const polygons = [];
  49. multiPolygon.coordinates.forEach(polygonCoordinates => {
  50. polygons.push({
  51. type: 'Polygon',
  52. coordinates: polygonCoordinates
  53. });
  54. });
  55. return polygons;
  56. },
  57. // draw_vector_tdgy_gy_jd(data) {
  58. // const that = this;
  59. // data.forEach((res) => {
  60. // res.type = this.title
  61. // if (res.geom) {
  62. // res.geom.coordinates.forEach((res_coordinates) => {
  63. // // let arrayt = [];
  64. // // if (res_coordinates.length == 1) {
  65. // // arrayt = res_coordinates[0]
  66. // // const twoDArray = arrayt;
  67. // // const oneDArray = twoDArray.reduce((accumulator, currentValue) => accumulator.concat(currentValue), []);
  68. // // tdsy.add(res, oneDArray);
  69. // // } else {
  70. // // // arrayt = res_coordinates
  71. // // }
  72. // // 多面转单面
  73. // // if (res.geom.type == 'MultiPolygon') {
  74. // // let polygons = that.multiPolygonToPolygons(geojson);
  75. // // // 在
  76. // // polygons.forEach((res) => {
  77. // // that.add_viewer_for_vector(res, data);
  78. // // tdsy.add(res, oneDArray);
  79. // // })
  80. // // } else {
  81. // // }
  82. // })
  83. // }
  84. // })
  85. // },
  86. draw_vector_tdgy_gy_jd(data) {
  87. // tdsy.remove();
  88. data.forEach((res) => {
  89. res.type = '图斑上图'
  90. if (res.geom) {
  91. let geojson = res.geom;
  92. if (geojson.type == 'MultiPolygon') {
  93. geojson.coordinates.forEach((res) => {
  94. const twoDArray = res[0];
  95. const oneDArray = twoDArray.reduce((accumulator, currentValue) => accumulator.concat(currentValue), []);
  96. tdsy.add(res, oneDArray);
  97. })
  98. } else {
  99. const twoDArray = geojson.coordinates[0];
  100. const oneDArray = twoDArray.reduce((accumulator, currentValue) => accumulator.concat(currentValue), []);
  101. tdsy.add(res, oneDArray);
  102. }
  103. }
  104. })
  105. },
  106. close() {
  107. store.setViewerFlagb(true);
  108. tdsy.remove();
  109. store.state.vectorData = [];
  110. store.hideToolBar();
  111. },
  112. info() { },
  113. switch_show(flag) {
  114. BoxCommonVector_entity.entities.values.forEach((res) => {
  115. res.show = flag;
  116. })
  117. },
  118. build_data(geojson) {
  119. geojson.coordinates.forEach((res) => {
  120. const twoDArray = res[0];
  121. const oneDArray = twoDArray.reduce((accumulator, currentValue) => accumulator.concat(currentValue), []);
  122. BoxCommonVector_entity.entities.add({
  123. polygon: {
  124. // 获取指定属性(positions,holes(图形内需要挖空的区域))
  125. hierarchy: {
  126. positions: Cesium.Cartesian3.fromDegreesArrayHeights(oneDArray),
  127. },
  128. // 边框
  129. outline: true,
  130. // 边框颜色
  131. outlineColor: Cesium.Color.RED,
  132. // 边框尺寸
  133. outlineWidth: 10,
  134. // 填充的颜色,withAlpha透明度
  135. material: Cesium.Color.GREEN.withAlpha(0),
  136. // 是否被提供的材质填充
  137. fill: true,
  138. // 恒定高度
  139. height: 1.1,
  140. // 显示在距相机的距离处的属性,多少区间内是可以显示的
  141. // distanceDisplayCondition: new Cesium.DistanceDisplayCondition(1000, 10000000),
  142. // 是否显示
  143. show: true,
  144. // 顺序,仅当`clampToGround`为true并且支持地形上的折线时才有效。
  145. zIndex: 10
  146. }
  147. });
  148. // 注意:polygon首尾坐标要一致
  149. var polygon = turf.polygon([twoDArray]);
  150. var centroid = turf.centroid(polygon).geometry.coordinates;
  151. viewer.camera.flyTo({
  152. duration: 1,
  153. destination: Cesium.Cartesian3.fromDegrees(centroid[0], centroid[1], 3000),
  154. // destination: {
  155. // x: -6283267.004204832,
  156. // y: 28123682.896774407,
  157. // z: 23709669.98539126
  158. // },
  159. orientation: {
  160. heading: 6.149339593573709,
  161. pitch: -1.539825618847483,
  162. roll: 0
  163. },
  164. });
  165. })
  166. },
  167. go(item) {
  168. store.setVectordataid(item.dataid)
  169. let arr = [];
  170. const that = this;
  171. // BoxCommonVector_entity = new Cesium.CustomDataSource("BoxCommonVector_entity");
  172. // viewer.dataSources.add(BoxCommonVector_entity);
  173. Object.keys(item).forEach(key => {
  174. arr.push({
  175. "name": key,
  176. "value": item[key],
  177. });
  178. if (key == 'geom') {
  179. console.log();
  180. let geojson = item[key];
  181. if (geojson.type == 'MultiPolygon') {
  182. this.build_data(geojson);
  183. } else {
  184. const twoDArray = geojson.coordinates[0];
  185. const oneDArray = twoDArray.reduce((accumulator, currentValue) => accumulator.concat(currentValue), []);
  186. BoxCommonVector_entity.entities.add({
  187. polygon: {
  188. // 获取指定属性(positions,holes(图形内需要挖空的区域))
  189. hierarchy: {
  190. positions: Cesium.Cartesian3.fromDegreesArrayHeights(oneDArray),
  191. },
  192. // 边框
  193. outline: true,
  194. // 边框颜色
  195. outlineColor: Cesium.Color.RED,
  196. // 边框尺寸
  197. outlineWidth: 10,
  198. // 填充的颜色,withAlpha透明度
  199. material: Cesium.Color.GREEN.withAlpha(0),
  200. // 是否被提供的材质填充
  201. fill: true,
  202. // 恒定高度
  203. height: 1.1,
  204. // 显示在距相机的距离处的属性,多少区间内是可以显示的
  205. // distanceDisplayCondition: new Cesium.DistanceDisplayCondition(1000, 10000000),
  206. // 是否显示
  207. show: true,
  208. // 顺序,仅当`clampToGround`为true并且支持地形上的折线时才有效。
  209. zIndex: 10
  210. }
  211. });
  212. // 注意:polygon首尾坐标要一致
  213. var polygon = turf.polygon([geojson.coordinates[0]]);
  214. var centroid = turf.centroid(polygon).geometry.coordinates;
  215. viewer.camera.flyTo({
  216. duration: 1,
  217. destination: Cesium.Cartesian3.fromDegrees(centroid[0], centroid[1], 3000),
  218. // destination: {
  219. // x: -6283267.004204832,
  220. // y: 28123682.896774407,
  221. // z: 23709669.98539126
  222. // },
  223. orientation: {
  224. heading: 6.149339593573709,
  225. pitch: -1.539825618847483,
  226. roll: 0
  227. },
  228. });
  229. }
  230. let flag = true;
  231. let time = setInterval(() => {
  232. flag = !flag
  233. that.switch_show(flag);
  234. }, 500);
  235. setTimeout(() => {
  236. clearInterval(time);
  237. for (var i = 0; i < 10; i++) {
  238. BoxCommonVector_entity.entities.values.forEach((res) => {
  239. BoxCommonVector_entity.entities.remove(res);
  240. })
  241. }
  242. }, 6000)
  243. }
  244. });
  245. store.state.vectorData = arr
  246. store.setActiveToolBar(9);
  247. },
  248. change_witch() {
  249. this.get_search(this.state);
  250. },
  251. // get_search(word) {
  252. // if (word.length == 0) {
  253. // this.active_dableData = this.tableData;
  254. // } else {
  255. // let gy_ju = {
  256. // beginTime: store.state.cockpit_date[0],
  257. // endTime: store.state.cockpit_date[1],
  258. // jscType: store.state.cockpit_vector.tablejscType + '_cx',
  259. // id: '4602',
  260. // val0: word,
  261. // }
  262. // if (this.title == '土地供应完成项目' || this.title == '山水工程完成项目') {
  263. // gy_ju.beginTime = undefined
  264. // gy_ju.endTime = undefined
  265. // }
  266. // // let bj_sl = {
  267. // // beginTime: store.state.cockpit_date[0],
  268. // // endTime: store.state.cockpit_date[1],
  269. // // jscType: 'jsc_bjxm_csbj_zbmx_cx',
  270. // // id: '4602',
  271. // // val0: word,
  272. // // }
  273. // Promise.all([QueryList(gy_ju)]).then((values) => {
  274. // values[0].data.map((res) => {
  275. // if (res.geom) {
  276. // res.geom = wellknown.parse(res.geom.split(";")[1]);
  277. // }
  278. // })
  279. // this.active_dableData = values[0].data
  280. // }).catch((error) => {
  281. // console.error(error); // 如果有任何一个 promise 失败,则捕获这个错误
  282. // });
  283. // }
  284. // },
  285. get_search(word) {
  286. if (word.length == 0) {
  287. this.active_dableData = this.tableData;
  288. console.log('this.active_dableData: ', this.active_dableData);
  289. } else {
  290. // console.log('this.tableData: ', this.tableData);
  291. // this.active_dableData = this.tableData.filter((item) => {
  292. // item.项目名称.indexOf(word) >= 0
  293. // })
  294. console.log('this.tableData: ', this.word);
  295. this.active_dableData = this.tableData.filter((item) => {
  296. console.log('item: ', item);
  297. if (item[this.word] && word) {
  298. return item[this.word].indexOf(word) >= 0;
  299. }
  300. return false;
  301. })
  302. }
  303. },
  304. async init_vector(params) {
  305. const that = this;
  306. let obj = {
  307. jscType: store.state.cockpit_vector.tablejscType,
  308. beginTime: store.state.cockpit_date[0],
  309. endTime: store.state.cockpit_date[1],
  310. id: params ? params.id : "4602",
  311. };
  312. if (this.title == '土地供应完成项目' || this.title == '山水工程完成项目') {
  313. obj.beginTime = undefined
  314. obj.endTime = undefined
  315. }
  316. if (this.title == '进出平衡') {
  317. obj.jscType = "jsc_gdbh_jcph_zbmc",
  318. obj.val2 = 0,
  319. obj.val1 = 50000,
  320. obj.beginTime = store.state.cockpit_date[1].slice(0, 4),
  321. obj.endTime = undefined
  322. }
  323. if (this.title == '土地收储计划项目') {
  324. obj.beginTime = undefined
  325. obj.endTime = undefined
  326. }
  327. if (this.title == '私宅报建完成项目') {
  328. let dateString_beginTime = store.state.cockpit_date[0];
  329. let formattedDate = dateString_beginTime.slice(0, 4) + '-' + dateString_beginTime.slice(4, 6) + '-' + dateString_beginTime.slice(6);
  330. let dateString_endTime = store.state.cockpit_date[1];
  331. let formattedDate_endTime = dateString_endTime.slice(0, 4) + '-' + dateString_endTime.slice(4, 6) + '-' + dateString_endTime.slice(6);
  332. obj.beginTime = formattedDate
  333. obj.endTime = formattedDate_endTime
  334. }
  335. let data = await QueryList(obj);
  336. data.data.map((res) => {
  337. if (res.geom) {
  338. res.geom = wellknown.parse(res.geom.split(";")[1]);
  339. }
  340. });
  341. this.active_dableData = data.data
  342. console.log('data.data: ', data.data);
  343. this.tableData = data.data
  344. },
  345. },
  346. computed: {
  347. cockpit_vector() {
  348. return store.state.cockpit_vector;
  349. },
  350. },
  351. watch: {
  352. cockpit_vector(newVal, oldVal) {
  353. this.title = newVal.title
  354. this.word = newVal.word
  355. if (newVal.tableData && newVal.tableData.length > 0) {
  356. this.active_dableData = newVal.tableData
  357. this.tableData = newVal.tableData
  358. this.init_vector()
  359. } else if (this.title) {
  360. this.init_vector()
  361. }
  362. if (newVal.goitem) {
  363. this.go(newVal.goitem)
  364. }
  365. },
  366. active_dableData(newVal, oldVal) {
  367. this.draw_vector_tdgy_gy_jd(newVal);
  368. }
  369. },
  370. mounted() {
  371. const that = this;
  372. this.$nextTick(() => {
  373. BoxCommonVector_entity = new Cesium.CustomDataSource("BoxCommonVector_entity");
  374. viewer.dataSources.add(BoxCommonVector_entity);
  375. });
  376. },
  377. };
  378. </script>
  379. <style lang="scss" scoped>
  380. .BoxCommonVector {
  381. width: 100%;
  382. height: 100%;
  383. position: absolute;
  384. left: -1rem;
  385. top: 0rem;
  386. }
  387. .innerContainerVector {
  388. width: 350px;
  389. height: 760px; //calc(100% - 20px);
  390. position: absolute;
  391. top: 28px;
  392. z-index: 99;
  393. background-image: url("/static/images/ghzc/内容框.png");
  394. background-size: 100% 100%;
  395. border-top-right-radius: 15px;
  396. .search {
  397. // margin: 2rem;
  398. }
  399. /deep/ .el-input {
  400. display: inline-block;
  401. }
  402. /deep/ .el-input__inner {
  403. // background: transparent !important;
  404. color: white !important;
  405. background: rgba(10, 25, 38, 0.5);
  406. border-color: #5ecef09a;
  407. // color: #64daff;
  408. // font-size: 12px;
  409. }
  410. }
  411. .leftPaneVector {
  412. left: 20px;
  413. .el-icon-close {
  414. width: 22px;
  415. height: 22px;
  416. color: #fff !important;
  417. background-color: #335f87;
  418. line-height: 23px;
  419. padding: 0 5px;
  420. border-radius: 4px;
  421. top: -1.9rem !important;
  422. position: relative;
  423. right: -19.5rem;
  424. }
  425. .PangetitleVector {
  426. box-sizing: border-box;
  427. width: 100%;
  428. height: 35px;
  429. background: url("/static/images/overview/titlebox.gif") no-repeat !important;
  430. background-size: 100% 100% !important;
  431. line-height: 35px;
  432. font-size: 14px;
  433. padding-left: 15px;
  434. display: flex;
  435. position: relative;
  436. overflow: hidden;
  437. }
  438. .pange_textVector {
  439. font-size: 14px !important;
  440. font-family: 'HarmonyOS Sans, HarmonyOS Sans';
  441. font-weight: bold;
  442. font-size: 18px;
  443. color: #FFFFFF;
  444. margin-left: 30px;
  445. }
  446. }
  447. /deep/.el-input__inner:focus {
  448. border: 1px solid #1fb1ef;
  449. }
  450. /deep/.el-input__inner {
  451. border: 1px solid rgba(10, 25, 38, 0.5);
  452. background: rgba(10, 25, 38, 0.5);
  453. border-radius: 18px;
  454. height: 30px;
  455. color: white;
  456. line-height: 30px;
  457. // background: #ffffff3b;
  458. }
  459. /deep/.el-input__icon {
  460. line-height: 30px;
  461. border-radius: 0 18px 18px 0;
  462. cursor: pointer;
  463. }
  464. /deep/.el-input__suffix {
  465. background: #1fb1ef;
  466. right: 1px;
  467. padding: 0 5px;
  468. border-radius: 0 18px 18px 0;
  469. opacity: 0.8;
  470. color: #fff;
  471. }
  472. /deep/ .el-autocomplete-suggestion {
  473. margin-top: 8px;
  474. border-radius: 6px;
  475. border: 1px solid #198ec0;
  476. background: rgba(10, 25, 38, 0.9);
  477. color: rgba(25, 142, 192, 1);
  478. .popper__arrow {
  479. top: -8px;
  480. border-bottom-color: rgba(31, 177, 239, 1);
  481. }
  482. .popper__arrow::after {
  483. border-bottom-color: rgba(0, 80, 111, 0.9);
  484. }
  485. .el-autocomplete-suggestion__wrap {
  486. padding: 2px;
  487. }
  488. }
  489. /deep/ .el-autocomplete-suggestion li {
  490. color: #ffffff;
  491. }
  492. /deep/ .el-autocomplete-suggestion li:hover {
  493. background-color: rgba(8, 162, 223, 0.8);
  494. border-radius: 6px;
  495. }
  496. /deep/ .el-table tr {
  497. background: rgba(10, 25, 38, 0.5) !important;
  498. }
  499. /deep/ .el-table td.el-table__cell,
  500. .el-table th.el-table__cell.is-leaf {
  501. background: rgba(10, 25, 38, 0.5) !important;
  502. border-bottom: 0px solid #EBEEF5;
  503. }
  504. .el-table {
  505. color: #fff;
  506. background: rgba(10, 25, 38, 0.5) !important;
  507. }
  508. /deep/ .el-table__fixed-right::before,
  509. .el-table__fixed::before {
  510. background: rgba(10, 25, 38, 0.9) !important;
  511. }
  512. /deep/ .el-table__fixed-right-patch {
  513. background: rgba(10, 25, 38, 0.9) !important;
  514. }
  515. /deep/ .el-table--border::after,
  516. .el-table--group::after,
  517. .el-table::before {
  518. background: rgba(10, 25, 38, 0) !important;
  519. }
  520. </style>