BoxCommonVector.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536
  1. <template>
  2. <div class="BoxCommonVector" v-if="title">
  3. <div class="innerContainerVector leftPaneVector">
  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. draw_vector_tdgy_gy_jd(data) {
  48. // tdsy.remove();
  49. data.forEach((res) => {
  50. res.type = this.title
  51. if (res.geom) {
  52. res.geom.coordinates.forEach((res_coordinates) => {
  53. let arrayt = [];
  54. if (res_coordinates.length == 1) {
  55. arrayt = res_coordinates[0]
  56. } else {
  57. arrayt = res_coordinates
  58. }
  59. const twoDArray = arrayt;
  60. const oneDArray = twoDArray.reduce((accumulator, currentValue) => accumulator.concat(currentValue), []);
  61. tdsy.add(res, oneDArray);
  62. })
  63. }
  64. })
  65. },
  66. close() {
  67. store.setViewerFlagb(true);
  68. tdsy.remove();
  69. store.state.vectorData = [];
  70. },
  71. info() { },
  72. switch_show(flag) {
  73. BoxCommonVector_entity.entities.values.forEach((res) => {
  74. res.show = flag;
  75. })
  76. },
  77. build_data(geojson) {
  78. geojson.coordinates.forEach((res) => {
  79. const twoDArray = res[0];
  80. const oneDArray = twoDArray.reduce((accumulator, currentValue) => accumulator.concat(currentValue), []);
  81. BoxCommonVector_entity.entities.add({
  82. polygon: {
  83. // 获取指定属性(positions,holes(图形内需要挖空的区域))
  84. hierarchy: {
  85. positions: Cesium.Cartesian3.fromDegreesArrayHeights(oneDArray),
  86. },
  87. // 边框
  88. outline: true,
  89. // 边框颜色
  90. outlineColor: Cesium.Color.RED,
  91. // 边框尺寸
  92. outlineWidth: 10,
  93. // 填充的颜色,withAlpha透明度
  94. material: Cesium.Color.GREEN.withAlpha(0),
  95. // 是否被提供的材质填充
  96. fill: true,
  97. // 恒定高度
  98. height: 1.1,
  99. // 显示在距相机的距离处的属性,多少区间内是可以显示的
  100. // distanceDisplayCondition: new Cesium.DistanceDisplayCondition(1000, 10000000),
  101. // 是否显示
  102. show: true,
  103. // 顺序,仅当`clampToGround`为true并且支持地形上的折线时才有效。
  104. zIndex: 10
  105. }
  106. });
  107. // 注意:polygon首尾坐标要一致
  108. var polygon = turf.polygon([twoDArray]);
  109. var centroid = turf.centroid(polygon).geometry.coordinates;
  110. viewer.camera.flyTo({
  111. duration: 1,
  112. destination: Cesium.Cartesian3.fromDegrees(centroid[0], centroid[1], 3000),
  113. // destination: {
  114. // x: -6283267.004204832,
  115. // y: 28123682.896774407,
  116. // z: 23709669.98539126
  117. // },
  118. orientation: {
  119. heading: 6.149339593573709,
  120. pitch: -1.539825618847483,
  121. roll: 0
  122. },
  123. });
  124. })
  125. },
  126. go(item) {
  127. let arr = [];
  128. const that = this;
  129. // BoxCommonVector_entity = new Cesium.CustomDataSource("BoxCommonVector_entity");
  130. // viewer.dataSources.add(BoxCommonVector_entity);
  131. Object.keys(item).forEach(key => {
  132. arr.push({
  133. "name": key,
  134. "value": item[key],
  135. });
  136. if (key == 'geom') {
  137. console.log();
  138. let geojson = item[key];
  139. if (geojson.type == 'MultiPolygon') {
  140. this.build_data(geojson);
  141. } else {
  142. const twoDArray = geojson.coordinates[0];
  143. const oneDArray = twoDArray.reduce((accumulator, currentValue) => accumulator.concat(currentValue), []);
  144. BoxCommonVector_entity.entities.add({
  145. polygon: {
  146. // 获取指定属性(positions,holes(图形内需要挖空的区域))
  147. hierarchy: {
  148. positions: Cesium.Cartesian3.fromDegreesArrayHeights(oneDArray),
  149. },
  150. // 边框
  151. outline: true,
  152. // 边框颜色
  153. outlineColor: Cesium.Color.RED,
  154. // 边框尺寸
  155. outlineWidth: 10,
  156. // 填充的颜色,withAlpha透明度
  157. material: Cesium.Color.GREEN.withAlpha(0),
  158. // 是否被提供的材质填充
  159. fill: true,
  160. // 恒定高度
  161. height: 1.1,
  162. // 显示在距相机的距离处的属性,多少区间内是可以显示的
  163. // distanceDisplayCondition: new Cesium.DistanceDisplayCondition(1000, 10000000),
  164. // 是否显示
  165. show: true,
  166. // 顺序,仅当`clampToGround`为true并且支持地形上的折线时才有效。
  167. zIndex: 10
  168. }
  169. });
  170. // 注意:polygon首尾坐标要一致
  171. var polygon = turf.polygon([geojson.coordinates[0]]);
  172. var centroid = turf.centroid(polygon).geometry.coordinates;
  173. viewer.camera.flyTo({
  174. duration: 1,
  175. destination: Cesium.Cartesian3.fromDegrees(centroid[0], centroid[1], 3000),
  176. // destination: {
  177. // x: -6283267.004204832,
  178. // y: 28123682.896774407,
  179. // z: 23709669.98539126
  180. // },
  181. orientation: {
  182. heading: 6.149339593573709,
  183. pitch: -1.539825618847483,
  184. roll: 0
  185. },
  186. });
  187. }
  188. let flag = true;
  189. let time = setInterval(() => {
  190. flag = !flag
  191. that.switch_show(flag);
  192. }, 500);
  193. setTimeout(() => {
  194. clearInterval(time);
  195. for (var i = 0; i < 10; i++) {
  196. BoxCommonVector_entity.entities.values.forEach((res) => {
  197. BoxCommonVector_entity.entities.remove(res);
  198. })
  199. }
  200. }, 6000)
  201. }
  202. });
  203. store.state.vectorData = arr
  204. store.setActiveToolBar(9);
  205. },
  206. change_witch() {
  207. this.get_search(this.state);
  208. },
  209. get_search(word) {
  210. if (word.length == 0) {
  211. this.active_dableData = this.tableData;
  212. } else {
  213. let gy_ju = {
  214. beginTime: store.state.cockpit_date[0],
  215. endTime: store.state.cockpit_date[1],
  216. jscType: store.state.cockpit_vector.tablejscType + '_cx',
  217. id: '4602',
  218. val0: word,
  219. }
  220. if(this.title == '土地供应完成项目' || this.title == '山水工程完成项目'){
  221. gy_ju.beginTime = undefined
  222. gy_ju.endTime = undefined
  223. }
  224. // let bj_sl = {
  225. // beginTime: store.state.cockpit_date[0],
  226. // endTime: store.state.cockpit_date[1],
  227. // jscType: 'jsc_bjxm_csbj_zbmx_cx',
  228. // id: '4602',
  229. // val0: word,
  230. // }
  231. Promise.all([QueryList(gy_ju)]).then((values) => {
  232. values[0].data.map((res) => {
  233. if (res.geom) {
  234. res.geom = wellknown.parse(res.geom.split(";")[1]);
  235. }
  236. })
  237. this.active_dableData = values[0].data
  238. }).catch((error) => {
  239. console.error(error); // 如果有任何一个 promise 失败,则捕获这个错误
  240. });
  241. }
  242. },
  243. async init_vector(params) {
  244. const that = this;
  245. let obj = {
  246. jscType: store.state.cockpit_vector.tablejscType,
  247. beginTime: store.state.cockpit_date[0],
  248. endTime: store.state.cockpit_date[1],
  249. id: params ? params.id : "4602",
  250. };
  251. if(this.title == '土地供应完成项目' || this.title == '山水工程完成项目'){
  252. obj.beginTime = undefined
  253. obj.endTime = undefined
  254. }
  255. let data = await QueryList(obj);
  256. data.data.map((res) => {
  257. if (res.geom) {
  258. res.geom = wellknown.parse(res.geom.split(";")[1]);
  259. }
  260. });
  261. this.active_dableData = data.data
  262. this.tableData = data.data
  263. },
  264. },
  265. computed: {
  266. cockpit_vector() {
  267. return store.state.cockpit_vector;
  268. },
  269. },
  270. watch: {
  271. cockpit_vector(newVal, oldVal) {
  272. console.log('newVal: ', newVal);
  273. this.title = newVal.title
  274. if (newVal.tableData.length > 0) {
  275. this.active_dableData = newVal.tableData
  276. this.tableData = newVal.tableData
  277. }else {
  278. this.init_vector()
  279. }
  280. if(newVal.goitem){
  281. this.go(newVal.goitem)
  282. }
  283. },
  284. active_dableData(newVal, oldVal) {
  285. this.draw_vector_tdgy_gy_jd(newVal);
  286. }
  287. },
  288. mounted() {
  289. const that = this;
  290. this.$nextTick(() => {
  291. BoxCommonVector_entity = new Cesium.CustomDataSource("BoxCommonVector_entity");
  292. viewer.dataSources.add(BoxCommonVector_entity);
  293. });
  294. }
  295. };
  296. </script>
  297. <style lang="scss" scoped>
  298. .BoxCommonVector {
  299. width: 100%;
  300. height: 100%;
  301. position: absolute;
  302. left: -1rem;
  303. top: 0rem;
  304. }
  305. .innerContainerVector {
  306. width: 350px;
  307. height: 760px; //calc(100% - 20px);
  308. position: absolute;
  309. top: 28px;
  310. z-index: 99;
  311. background-image: url("/static/images/ghzc/内容框.png");
  312. background-size: 100% 100%;
  313. border-top-right-radius: 15px;
  314. .search {
  315. // margin: 2rem;
  316. }
  317. /deep/ .el-input {
  318. display: inline-block;
  319. }
  320. /deep/ .el-input__inner {
  321. // background: transparent !important;
  322. color: white !important;
  323. background: rgba(10, 25, 38, 0.5);
  324. border-color: #5ecef09a;
  325. // color: #64daff;
  326. // font-size: 12px;
  327. }
  328. }
  329. .leftPaneVector {
  330. left: 20px;
  331. .el-icon-close {
  332. width: 22px;
  333. height: 22px;
  334. color: #fff !important;
  335. background-color: #335f87;
  336. line-height: 23px;
  337. padding: 0 5px;
  338. border-radius: 4px;
  339. top: -1.9rem !important;
  340. position: relative;
  341. right: -19.5rem;
  342. }
  343. .PangetitleVector {
  344. box-sizing: border-box;
  345. width: 100%;
  346. height: 35px;
  347. background: url("/static/images/overview/titlebox.gif") no-repeat !important;
  348. background-size: 100% 100% !important;
  349. line-height: 35px;
  350. font-size: 14px;
  351. padding-left: 15px;
  352. display: flex;
  353. position: relative;
  354. overflow: hidden;
  355. }
  356. .pange_textVector {
  357. font-size: 14px !important;
  358. font-family: 'HarmonyOS Sans, HarmonyOS Sans';
  359. font-weight: bold;
  360. font-size: 18px;
  361. color: #FFFFFF;
  362. margin-left: 30px;
  363. }
  364. }
  365. /deep/.el-input__inner:focus {
  366. border: 1px solid #1fb1ef;
  367. }
  368. /deep/.el-input__inner {
  369. border: 1px solid rgba(10, 25, 38, 0.5);
  370. background: rgba(10, 25, 38, 0.5);
  371. border-radius: 18px;
  372. height: 30px;
  373. color: white;
  374. line-height: 30px;
  375. // background: #ffffff3b;
  376. }
  377. /deep/.el-input__icon {
  378. line-height: 30px;
  379. border-radius: 0 18px 18px 0;
  380. cursor: pointer;
  381. }
  382. /deep/.el-input__suffix {
  383. background: #1fb1ef;
  384. right: 1px;
  385. padding: 0 5px;
  386. border-radius: 0 18px 18px 0;
  387. opacity: 0.8;
  388. color: #fff;
  389. }
  390. /deep/ .el-autocomplete-suggestion {
  391. margin-top: 8px;
  392. border-radius: 6px;
  393. border: 1px solid #198ec0;
  394. background: rgba(10, 25, 38, 0.9);
  395. color: rgba(25, 142, 192, 1);
  396. .popper__arrow {
  397. top: -8px;
  398. border-bottom-color: rgba(31, 177, 239, 1);
  399. }
  400. .popper__arrow::after {
  401. border-bottom-color: rgba(0, 80, 111, 0.9);
  402. }
  403. .el-autocomplete-suggestion__wrap {
  404. padding: 2px;
  405. }
  406. }
  407. /deep/ .el-autocomplete-suggestion li {
  408. color: #ffffff;
  409. }
  410. /deep/ .el-autocomplete-suggestion li:hover {
  411. background-color: rgba(8, 162, 223, 0.8);
  412. border-radius: 6px;
  413. }
  414. /deep/ .el-table tr {
  415. background: rgba(10, 25, 38, 0.5) !important;
  416. }
  417. /deep/ .el-table td.el-table__cell,
  418. .el-table th.el-table__cell.is-leaf {
  419. background: rgba(10, 25, 38, 0.5) !important;
  420. border-bottom: 0px solid #EBEEF5;
  421. }
  422. .el-table {
  423. color: #fff;
  424. background: rgba(10, 25, 38, 0.5) !important;
  425. }
  426. /deep/ .el-table__fixed-right::before,
  427. .el-table__fixed::before {
  428. background: rgba(10, 25, 38, 0.9) !important;
  429. }
  430. /deep/ .el-table__fixed-right-patch {
  431. background: rgba(10, 25, 38, 0.9) !important;
  432. }
  433. /deep/ .el-table--border::after,
  434. .el-table--group::after,
  435. .el-table::before {
  436. background: rgba(10, 25, 38, 0) !important;
  437. }
  438. </style>