billboardDesign.vue 36 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111
  1. <template>
  2. <div
  3. class="ZTGlobal"
  4. style="width: 100%; padding: 1rem 1rem 0rem 1rem; color: white"
  5. >
  6. <el-row :gutter="10">
  7. <el-col :span="18">
  8. <el-input
  9. clearable
  10. size="mini"
  11. placeholder="请输入内容"
  12. v-model="input3"
  13. class="input-with-select"
  14. @change="getZtBillboardInfoList()"
  15. >
  16. <el-button
  17. slot="append"
  18. icon="el-icon-search"
  19. @click="getZtBillboardInfoList()"
  20. ></el-button>
  21. </el-input>
  22. </el-col>
  23. <el-col :span="6">
  24. <el-button size="mini" type="primary" plain @click="addProjectInfo"
  25. >新建项目</el-button
  26. >
  27. </el-col>
  28. </el-row>
  29. <el-row>
  30. <div style="height: 90%">
  31. <el-row v-for="item in projects" :key="item.id">
  32. <el-card class="box-card card_body_style">
  33. <el-row>
  34. <span>{{ item.projectname }}</span></el-row
  35. >
  36. <el-row>
  37. <span>{{ item.checkDate }}</span></el-row
  38. >
  39. <el-row style="display: flex">
  40. <el-col class="con-col hover_style" style="cursor: pointer">
  41. <i
  42. style="font-size: 2rem"
  43. class="el-icon-s-operation"
  44. @click="billboarddetial(item)"
  45. ></i>
  46. <a @click="billboarddetial(item)">详情</a>
  47. </el-col>
  48. <el-col
  49. class="con-col hover_style"
  50. v-if="!item.dataurl"
  51. style="cursor: pointer"
  52. >
  53. <i
  54. style="font-size: 2rem"
  55. class="el-icon-folder-add"
  56. @click="importModel(item)"
  57. ></i>
  58. <a @click="importModel(item)">导入模型</a>
  59. </el-col>
  60. <el-col class="con-col hover_style" style="cursor: pointer">
  61. <i
  62. style="font-size: 2rem"
  63. class="el-icon-location-outline"
  64. @click="locationModel(item)"
  65. ></i>
  66. <a @click="locationModel(item)">定位</a>
  67. </el-col>
  68. <el-col class="con-col hover_style" style="cursor: pointer">
  69. <i
  70. style="font-size: 2rem"
  71. class="el-icon-tickets"
  72. @click="checkModel(item)"
  73. ></i>
  74. <a @click="checkModel(item)">审查</a>
  75. </el-col>
  76. <el-col class="con-col hover_style" style="cursor: pointer">
  77. <i
  78. style="font-size: 2rem"
  79. class="el-icon-delete"
  80. @click="deleteBillard(item)"
  81. ></i>
  82. <a @click="deleteBillard(item)">删除</a>
  83. </el-col>
  84. </el-row>
  85. </el-card>
  86. </el-row>
  87. </div>
  88. </el-row>
  89. <el-row>
  90. <el-pagination
  91. :hide-on-single-page="true"
  92. style="color: white"
  93. @size-change="handleSizeChange"
  94. @current-change="handleCurrentChange"
  95. :page-size="queryParams.pageSize"
  96. layout="prev, pager, next"
  97. :total="queryParams.total"
  98. >
  99. </el-pagination>
  100. </el-row>
  101. </div>
  102. </template>
  103. <script>
  104. import addbillboardProject from "@/views/ConstructionApplication3D/billboard/addBillboardPoject.vue";
  105. import billboarddetail from "@/views/ConstructionApplication3D/billboard/billboarddetail.vue";
  106. import billboardCheck from "@/views/ConstructionApplication3D/billboard/billboardCheckList.vue";
  107. import addBiillboardModel from "@/views/ConstructionApplication3D/billboard/addBiillboardModel.vue";
  108. import billboarddetailInfo from "@/views/ConstructionApplication3D/billboard/billboarddetailInfo.vue";
  109. import {
  110. cartesian3ToWGS84,
  111. mapQuery,
  112. flatten,
  113. mercator2lonLat,
  114. undergroundMode,
  115. } from "@/utils/MapHelper/MapHelper.js";
  116. import lodash from "lodash-es";
  117. import { v4 as uuidv4 } from "uuid";
  118. import {
  119. listZtBillboardInfoList,
  120. listBillboardModelList,
  121. delZtBillboardInfoList,
  122. getBillboardModelList,
  123. } from "@/api/zt/ztApi.js";
  124. let entityList = [];
  125. export default {
  126. data() {
  127. return {
  128. input3: "",
  129. thislayers: [],
  130. // projects: window.billboardInfoList,
  131. projects: [],
  132. deltailLayerId: null,
  133. checklLayerId: null,
  134. addlLayerId: null,
  135. // entityList: [],
  136. //点查entities事件
  137. getEntitiesHandler: null,
  138. selectBillardId: "",
  139. queryParams: {
  140. total: 0,
  141. pageNum: 1,
  142. pageSize: 10,
  143. },
  144. };
  145. },
  146. computed: {},
  147. mounted() {
  148. this.initEntitiesHandler();
  149. // this.init();
  150. this.getZtBillboardInfoList();
  151. },
  152. methods: {
  153. //页大小触发
  154. handleSizeChange(val) {
  155. this.queryParams.pageSize = val;
  156. this.queryParams.pageNum = 1;
  157. this.getZtBillboardInfoList();
  158. },
  159. //跳转页触发
  160. handleCurrentChange(val) {
  161. this.queryParams.pageNum = val;
  162. this.getZtBillboardInfoList();
  163. },
  164. /**
  165. * 获取广告项目信息
  166. */
  167. async getZtBillboardInfoList() {
  168. debugger;
  169. let BenchmarkLandPrices = await listZtBillboardInfoList({
  170. projectname: this.input3,
  171. ...this.queryParams,
  172. });
  173. this.queryParams.total = BenchmarkLandPrices.total;
  174. this.projects = BenchmarkLandPrices.rows;
  175. // this.BenchmarkLandPriceList = window.BenchmarkLandPriceList;
  176. },
  177. // 新增项目
  178. addProjectInfo() {
  179. this.$layer.iframe({
  180. id: "addXM",
  181. content: {
  182. content: addbillboardProject, //传递的组件对象
  183. parent: this, //当前的vue对象
  184. data: {}, //props
  185. },
  186. offset: ["650", "300"], //left top 左上角(left=430px/2;top=(800px+header高)/2)
  187. area: ["400px", "450px"], //宽 高
  188. title: "新增项目",
  189. maxmin: false,
  190. shade: false, //是否显示遮罩
  191. shadeClose: false, //点击遮罩是否关闭
  192. cancel: async () => {
  193. //关闭事件
  194. // alert("关闭iframe");
  195. // this.projects = window.billboardInfoList;
  196. await this.getZtBillboardInfoList();
  197. },
  198. });
  199. },
  200. /**
  201. * 渲染,定位
  202. * @param item
  203. * @param isPosition 默认定位
  204. */
  205. async locationModel(item, isPosition) {
  206. debugger;
  207. this.intoModel(item, isPosition);
  208. this.removeAllentities();
  209. //渲染范围
  210. // this.DrawProjectScope(item);
  211. //渲染单个广告牌
  212. // window.billboardModelList.forEach((billboardModel) => {
  213. // if (billboardModel.billboardInfoId == item.id) {
  214. // this.DrawBillboard(billboardModel);
  215. // }
  216. // });
  217. let data = await listBillboardModelList({
  218. billboardInfoId: item.id,
  219. });
  220. data.rows.forEach((element) => {
  221. this.DrawBillboard(element);
  222. });
  223. if (isPosition != false) {
  224. window.viewer.flyTo(entityList);
  225. }
  226. },
  227. /**
  228. * 定位到某个模型
  229. * @param Mitem 模型实体
  230. */
  231. locationSingleModel(Mitem) {
  232. if (Mitem.isAddModel) {
  233. if (Mitem.viewing_angle) {
  234. viewer.camera.setView(JSON.parse(Mitem.viewing_angle));
  235. } else {
  236. let entitie = viewer.entities.getById("point_Billboard_" + Mitem.id);
  237. if (!entitie) {
  238. //渲染单个广告牌
  239. // if (billboardModel.id == Mitem.id) {
  240. this.DrawBillboard(Mitem);
  241. // viewer.flyTo(entitie);
  242. // }
  243. }
  244. viewer.flyTo(entitie);
  245. }
  246. }
  247. },
  248. /**
  249. *查看详情
  250. */
  251. async billboarddetial(item) {
  252. await this.locationModel(item, false);
  253. this.$layer.iframe({
  254. id: "billboarddetail",
  255. content: {
  256. content: billboarddetail, //传递的组件对象
  257. parent: this, //当前的vue对象
  258. data: { info: { projectInfo: item } }, //props
  259. },
  260. offset: [720, 400], //left top 左上角(left=430px/2;top=(800px+header高)/2)
  261. area: ["300px", "400px"],
  262. title: "项目详情",
  263. maxmin: false,
  264. shade: false, //是否显示遮罩
  265. shadeClose: false, //点击遮罩是否关闭
  266. cancel: () => {
  267. //关闭事件
  268. // alert("关闭iframe");
  269. },
  270. });
  271. },
  272. /**
  273. *模型审查
  274. *
  275. */
  276. async checkModel(item) {
  277. await this.locationModel(item, false);
  278. var width = 400;
  279. var top = 250;
  280. var left = Math.floor(document.body.clientWidth - width / 2);
  281. var height = 400;
  282. this.$layer.iframe({
  283. id: "MXSCList",
  284. content: {
  285. content: billboardCheck, //传递的组件对象
  286. parent: this, //当前的vue对象
  287. data: { info: item }, //props
  288. },
  289. offset: [left.toString(), top.toString()], //left top 左上角(left=430px/2;top=(800px+header高)/2)
  290. area: [width.toString() + "px", height.toString() + "px"],
  291. title: "模型审查列表",
  292. maxmin: true,
  293. shade: false, //是否显示遮罩
  294. shadeClose: false, //点击遮罩是否关闭
  295. cancel: () => {
  296. //关闭事件
  297. // alert("关闭iframe");
  298. },
  299. });
  300. },
  301. /*
  302. *删除广告牌
  303. */
  304. deleteBillard(model) {
  305. debugger;
  306. var that = this;
  307. // that.$layer.confirm("确定要删除当前广告吗?", {
  308. // btn: ['确定', '取消'] //按钮
  309. // }, function (layerid) {
  310. // that.$layer.close(layerid);
  311. // that.$layer.msg('已删除');
  312. // },
  313. // function (layerid) {
  314. // that.$layer.close(layerid);
  315. // that.$layer.msg('已取消');
  316. // });
  317. // options,yes和cancel可以省略, 如果您不愿意写options,则可以直接写确定按钮的函数,即yes,或者覆盖默认的cancel方法。PS:yes和cancel方法不能互换
  318. //content 可以为html
  319. //yes,cancel如果是个function,这会自动添加参数layerid,
  320. this.$confirm("确定要删除当前广告吗?, 是否继续?", "提示", {
  321. confirmButtonText: "确定",
  322. cancelButtonText: "取消",
  323. type: "warning",
  324. })
  325. .then(async () => {
  326. debugger;
  327. let result = await delZtBillboardInfoList(model.id);
  328. debugger;
  329. if (result.code == 200) {
  330. that.getZtBillboardInfoList();
  331. viewer.entities.removeAll();
  332. // that.lyoption.cancel();
  333. that.$layer.close(that.layerid);
  334. that.$message({
  335. message: "删除成功",
  336. type: "success",
  337. });
  338. }
  339. })
  340. .catch(() => {
  341. debugger;
  342. this.$message({
  343. type: "info",
  344. message: "已取消删除",
  345. });
  346. });
  347. },
  348. /**
  349. * 导入模型(添加广告牌模型)
  350. */
  351. importModel(project) {
  352. this.intoModel(project);
  353. // this.locationModel(project);
  354. var width = 600;
  355. var top = 420;
  356. var left = Math.floor(document.body.clientWidth - width / 2 + 130);
  357. var height = 350;
  358. this.$layer.iframe({
  359. id: "addMX",
  360. content: {
  361. content: addBiillboardModel, //传递的组件对象
  362. parent: this, //当前的vue对象
  363. data: { layerId: "addMX", projectId: project.id }, //props
  364. },
  365. offset: [left.toString(), top.toString()], //left top 左上角(left=430px/2;top=(800px+header高)/2)
  366. area: ["350px", "720px"],
  367. title: "添加广告牌",
  368. maxmin: false,
  369. shade: false, //是否显示遮罩
  370. shadeClose: false, //点击遮罩是否关闭
  371. cancel: () => {
  372. //关闭事件
  373. this.locationModel(project, false);
  374. },
  375. });
  376. },
  377. /**
  378. * 绘制广告位项目范围
  379. */
  380. DrawProjectScope(item) {
  381. this.removeProjectScope(item);
  382. let ps = [];
  383. for (let index = 0; index < item.ProjectScope.length; index++) {
  384. const element = item.ProjectScope[index];
  385. ps.push(element.x);
  386. ps.push(element.y);
  387. }
  388. const line = viewer.entities.add({
  389. id: "ggwxmfw-" + item.id,
  390. polyline: {
  391. positions: Cesium.Cartesian3.fromDegreesArray(ps),
  392. width: 5,
  393. material: Cesium.Color.RED,
  394. clampToGround: true,
  395. },
  396. });
  397. entityList.push(line);
  398. },
  399. /**
  400. * 绘制广告牌
  401. */
  402. DrawBillboard(billboardModel) {
  403. if (billboardModel.isAddModel) {
  404. if (billboardModel.template) {
  405. if (typeof billboardModel.template === "string") {
  406. billboardModel.template = JSON.parse(billboardModel.template);
  407. }
  408. } else {
  409. billboardModel.template = {};
  410. }
  411. if (billboardModel.templateBottom) {
  412. if (typeof billboardModel.templateBottom === "string") {
  413. billboardModel.templateBottom = JSON.parse(
  414. billboardModel.templateBottom
  415. );
  416. }
  417. } else {
  418. billboardModel.templateBottom = {};
  419. }
  420. if (billboardModel.templateCentre) {
  421. if (typeof billboardModel.templateCentre === "string") {
  422. billboardModel.templateCentre = JSON.parse(
  423. billboardModel.templateCentre
  424. );
  425. }
  426. } else {
  427. billboardModel.templateCentre = {};
  428. }
  429. if (billboardModel.templateTop) {
  430. if (typeof billboardModel.templateTop === "string") {
  431. billboardModel.templateTop = JSON.parse(billboardModel.templateTop);
  432. }
  433. } else {
  434. billboardModel.templateTop = {};
  435. }
  436. debugger;
  437. var newposition = Cesium.Cartesian3.fromDegrees(
  438. billboardModel.x,
  439. billboardModel.y,
  440. billboardModel.z
  441. );
  442. if (billboardModel.template) {
  443. var imageurl = "../../../../static/ModelData/billboard/1.jpg";
  444. var modelurl = "../../../../static/ModelData/billboard/box.gltf";
  445. switch (billboardModel.template.ModelType) {
  446. //矩形广告
  447. case "rectangleBillboard":
  448. var orientation = Cesium.Transforms.headingPitchRollQuaternion(
  449. newposition,
  450. new Cesium.HeadingPitchRoll(
  451. Cesium.Math.toRadians(billboardModel.rotateZ),
  452. Cesium.Math.toRadians(billboardModel.rotateY),
  453. Cesium.Math.toRadians(billboardModel.rotateX)
  454. )
  455. );
  456. //计算当前实体的xyz
  457. var p = Cesium.Cartesian3.fromDegrees(
  458. Number(billboardModel.templateTop.x),
  459. Number(billboardModel.templateTop.y),
  460. Number(billboardModel.templateTop.z)
  461. );
  462. var topentity = viewer.entities.add({
  463. id: "top_billboard_" + billboardModel.id,
  464. name: "gltf",
  465. show: true,
  466. position: p,
  467. /**
  468. * 长方体
  469. */
  470. box: {
  471. dimensions: new Cesium.Cartesian3(
  472. Number(billboardModel.templateTop.xL),
  473. Number(billboardModel.templateTop.zL),
  474. Number(billboardModel.templateTop.yL)
  475. ),
  476. show: true,
  477. material: Cesium.Color.LIGHTGREEN,
  478. },
  479. orientation: orientation,
  480. });
  481. entityList.push(topentity);
  482. break;
  483. // 立杆型广告
  484. case "postsBillboard":
  485. var orientation = Cesium.Transforms.headingPitchRollQuaternion(
  486. newposition,
  487. new Cesium.HeadingPitchRoll(
  488. Cesium.Math.toRadians(billboardModel.rotateZ),
  489. Cesium.Math.toRadians(billboardModel.rotateY),
  490. Cesium.Math.toRadians(billboardModel.rotateX)
  491. )
  492. );
  493. var c_p = Cesium.Cartesian3.fromDegrees(
  494. billboardModel.templateCentre.x,
  495. billboardModel.templateCentre.y,
  496. billboardModel.templateCentre.z
  497. );
  498. var Centreentity = viewer.entities.add({
  499. id: "Centre_billboard_" + billboardModel.id,
  500. name: "gltf",
  501. show: true,
  502. position: c_p,
  503. /**
  504. * 圆柱
  505. */
  506. cylinder: {
  507. length: billboardModel.templateCentre.yL, //圆柱体长度
  508. topRadius: billboardModel.templateCentre.rL, //圆柱顶部半径
  509. bottomRadius: billboardModel.templateCentre.rL, //圆柱体底部半径
  510. material: Cesium.Color.LIGHTGREEN,
  511. shadows: Cesium.ShadowMode.DISABLED, //指定圆柱体是否从每个光源投射或接收阴影
  512. },
  513. orientation: Cesium.Transforms.headingPitchRollQuaternion(
  514. newposition,
  515. new Cesium.HeadingPitchRoll(
  516. Cesium.Math.toRadians(billboardModel.rotateZ),
  517. Cesium.Math.toRadians(0),
  518. Cesium.Math.toRadians(0)
  519. )
  520. ),
  521. });
  522. entityList.push(Centreentity);
  523. //计算当前实体的xyz
  524. var t_p = Cesium.Cartesian3.fromDegrees(
  525. Number(billboardModel.templateTop.x),
  526. Number(billboardModel.templateTop.y),
  527. Number(billboardModel.templateTop.z)
  528. );
  529. var topentity = viewer.entities.add({
  530. id: "top_billboard_" + billboardModel.id,
  531. name: "gltf",
  532. show: true,
  533. position: t_p,
  534. /**
  535. * 矩形
  536. */
  537. box: {
  538. dimensions: new Cesium.Cartesian3(
  539. Number(billboardModel.templateTop.xL),
  540. Number(billboardModel.templateTop.zL),
  541. Number(billboardModel.templateTop.yL)
  542. ),
  543. material: Cesium.Color.LIGHTGREEN,
  544. // outline: false,
  545. // outlineColor: Cesium.Color.SPRINGGREEN,
  546. // outlineWidth: 1,
  547. },
  548. orientation: orientation,
  549. });
  550. entityList.push(topentity);
  551. break;
  552. //底座型立杆广告
  553. case "ColumnWithaseBillboard":
  554. var orientation = Cesium.Transforms.headingPitchRollQuaternion(
  555. newposition,
  556. new Cesium.HeadingPitchRoll(
  557. Cesium.Math.toRadians(billboardModel.rotateZ),
  558. Cesium.Math.toRadians(billboardModel.rotateY),
  559. Cesium.Math.toRadians(billboardModel.rotateX)
  560. )
  561. );
  562. var b_p = Cesium.Cartesian3.fromDegrees(
  563. billboardModel.templateBottom.x,
  564. billboardModel.templateBottom.y,
  565. billboardModel.templateBottom.z
  566. );
  567. var bottomentity = viewer.entities.add({
  568. id: "bottom_billboard_" + billboardModel.id,
  569. name: "gltf",
  570. show: true,
  571. position: b_p,
  572. /**
  573. * 矩形
  574. */
  575. box: {
  576. dimensions: new Cesium.Cartesian3(
  577. billboardModel.templateBottom.xL,
  578. billboardModel.templateBottom.zL,
  579. billboardModel.templateBottom.yL
  580. ),
  581. material: Cesium.Color.LIGHTGREEN,
  582. // outline: false,
  583. // outlineColor: Cesium.Color.SPRINGGREEN,
  584. // outlineWidth: 1,
  585. },
  586. orientation: Cesium.Transforms.headingPitchRollQuaternion(
  587. newposition,
  588. new Cesium.HeadingPitchRoll(
  589. Cesium.Math.toRadians(billboardModel.rotateZ),
  590. Cesium.Math.toRadians(0),
  591. Cesium.Math.toRadians(0)
  592. )
  593. ),
  594. });
  595. entityList.push(bottomentity);
  596. var c_p = Cesium.Cartesian3.fromDegrees(
  597. billboardModel.templateCentre.x,
  598. billboardModel.templateCentre.y,
  599. billboardModel.templateCentre.z
  600. );
  601. var Centreentity = viewer.entities.add({
  602. id: "Centre_billboard_" + billboardModel.id,
  603. name: "gltf",
  604. show: true,
  605. position: c_p,
  606. /**
  607. * 圆柱
  608. */
  609. cylinder: {
  610. length: billboardModel.templateCentre.yL, //圆柱体长度
  611. topRadius: billboardModel.templateCentre.rL, //圆柱顶部半径
  612. bottomRadius: billboardModel.templateCentre.rL, //圆柱体底部半径
  613. material: Cesium.Color.LIGHTGREEN,
  614. shadows: Cesium.ShadowMode.DISABLED, //指定圆柱体是否从每个光源投射或接收阴影
  615. },
  616. orientation: Cesium.Transforms.headingPitchRollQuaternion(
  617. newposition,
  618. new Cesium.HeadingPitchRoll(
  619. Cesium.Math.toRadians(billboardModel.rotateZ),
  620. Cesium.Math.toRadians(0),
  621. Cesium.Math.toRadians(0)
  622. )
  623. ),
  624. });
  625. entityList.push(Centreentity);
  626. var t_p = Cesium.Cartesian3.fromDegrees(
  627. Number(billboardModel.templateTop.x),
  628. Number(billboardModel.templateTop.y),
  629. Number(billboardModel.templateTop.z)
  630. );
  631. var topentity = viewer.entities.add({
  632. id: "top_billboard_" + billboardModel.id,
  633. name: "gltf",
  634. show: true,
  635. position: t_p,
  636. /**
  637. * 矩形
  638. */
  639. box: {
  640. dimensions: new Cesium.Cartesian3(
  641. Number(billboardModel.templateTop.xL),
  642. Number(billboardModel.templateTop.zL),
  643. Number(billboardModel.templateTop.yL)
  644. ),
  645. material: Cesium.Color.LIGHTGREEN,
  646. // outline: false,
  647. // outlineColor: Cesium.Color.SPRINGGREEN,
  648. // outlineWidth: 1,
  649. },
  650. orientation: orientation,
  651. });
  652. entityList.push(topentity);
  653. break;
  654. //实物型广告(模型型)
  655. case "ModelBillboard":
  656. var orientation = Cesium.Transforms.headingPitchRollQuaternion(
  657. newposition,
  658. new Cesium.HeadingPitchRoll(
  659. Cesium.Math.toRadians(billboardModel.rotateZ),
  660. Cesium.Math.toRadians(billboardModel.rotateY),
  661. Cesium.Math.toRadians(billboardModel.rotateX)
  662. )
  663. );
  664. var p = Cesium.Cartesian3.fromDegrees(
  665. Number(billboardModel.templateTop.x),
  666. Number(billboardModel.templateTop.y),
  667. Number(billboardModel.templateTop.z)
  668. );
  669. var url = billboardModel.template.templateTopUrl || modelurl;
  670. var entity = viewer.entities.add({
  671. id: "top_billboard_" + billboardModel.id,
  672. name: "gltf",
  673. show: true,
  674. position: p,
  675. /**
  676. * 模型
  677. */
  678. model: {
  679. uri: url,
  680. scale: billboardModel.templateTop.scaleL,
  681. },
  682. orientation: orientation,
  683. });
  684. entityList.push(entity);
  685. break;
  686. //图片型广告
  687. case "imgBillboard":
  688. var orientation = Cesium.Transforms.headingPitchRollQuaternion(
  689. newposition,
  690. new Cesium.HeadingPitchRoll(
  691. Cesium.Math.toRadians(billboardModel.rotateZ),
  692. Cesium.Math.toRadians(billboardModel.rotateY),
  693. Cesium.Math.toRadians(billboardModel.rotateX)
  694. )
  695. );
  696. var p = Cesium.Cartesian3.fromDegrees(
  697. Number(billboardModel.templateTop.x),
  698. Number(billboardModel.templateTop.y),
  699. Number(billboardModel.templateTop.z)
  700. );
  701. var url = billboardModel.template.templateTopUrl || imageurl;
  702. var entity = viewer.entities.add({
  703. id: "top_billboard_" + billboardModel.id,
  704. name: "gltf",
  705. show: true,
  706. position: p,
  707. /**
  708. * 广告牌
  709. */
  710. billboard: {
  711. image: url,
  712. width: Number(billboardModel.templateTop.xL),
  713. height: Number(billboardModel.templateTop.yL),
  714. rotation: Number(billboardModel.rotateX),
  715. sizeInMeters: true,
  716. },
  717. orientation: orientation,
  718. });
  719. entityList.push(entity);
  720. break;
  721. }
  722. var h = 0;
  723. if (billboardModel.templateTop.yL) {
  724. h = Number(billboardModel.templateTop.yL) / 2;
  725. }
  726. viewer.entities.removeById("point_Billboard_" + billboardModel.id);
  727. lodash.remove(
  728. entityList,
  729. (entity) => entity.id === "point_Billboard_" + billboardModel.id
  730. );
  731. const point = viewer.entities.add({
  732. id: "point_Billboard_" + billboardModel.id,
  733. //点
  734. position: Cesium.Cartesian3.fromDegrees(
  735. Number(billboardModel.templateTop.x),
  736. Number(billboardModel.templateTop.y),
  737. Number(billboardModel.templateTop.z) + h
  738. ),
  739. label: {
  740. text: billboardModel.billboardName, //描述内容
  741. font: "20px Sans-Serif", //字体大小 类型
  742. fillColor: Cesium.Color.RED, //颜色
  743. outlineColor: Cesium.Color.GOLD,
  744. style: Cesium.LabelStyle.CENTER_LABEL,
  745. // 垂直位置
  746. verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
  747. // 中心位置
  748. pixelOffset: new Cesium.Cartesian2(0, -10),
  749. //设置背景颜色透明
  750. backgroundColor: new Cesium.Color(0.0, 0.0, 0.0, 0.0),
  751. //打开背景 打开背景 (不会被线段覆盖)
  752. showBackground: true,
  753. // heightReference: Cesium.HeightReference.RELATIVE_TO_GROUND,
  754. // distanceDisplayCondition: new Cesium.DistanceDisplayCondition(
  755. // 0.0,
  756. // 1800.0
  757. // ),
  758. // heightReference: Cesium.HeightReference.NONE,
  759. disableDepthTestDistance: Number.POSITIVE_INFINITY,
  760. },
  761. });
  762. entityList.push(point);
  763. }
  764. }
  765. // if (billboardModel.isAddModel) {
  766. // this.removeBillboard(billboardModel);
  767. // var modelurl = "../../../../static/ModelData/billboard/box.gltf";
  768. // let newposition = Cesium.Cartesian3.fromDegrees(
  769. // billboardModel.x,
  770. // billboardModel.y,
  771. // billboardModel.z
  772. // );
  773. // var orientation = Cesium.Transforms.headingPitchRollQuaternion(
  774. // newposition,
  775. // new Cesium.HeadingPitchRoll(
  776. // Cesium.Math.toRadians(billboardModel.rotateX),
  777. // Cesium.Math.toRadians(billboardModel.rotateY),
  778. // Cesium.Math.toRadians(billboardModel.rotateZ)
  779. // )
  780. // );
  781. // var entity = viewer.entities.add({
  782. // id: "billboard_" + billboardModel.id,
  783. // name: "gltf",
  784. // show: true,
  785. // position: newposition,
  786. // /**
  787. // * 长方体
  788. // */
  789. // box: {
  790. // dimensions: new Cesium.Cartesian3(
  791. // billboardModel.xL,
  792. // billboardModel.zL,
  793. // billboardModel.yL
  794. // ),
  795. // show: true,
  796. // material: Cesium.Color.LIGHTGREEN,
  797. // // outline: true,
  798. // // outlineColor: Cesium.Color.SPRINGGREEN,
  799. // // outlineWidth: 1,
  800. // },
  801. // /**
  802. // * 模型
  803. // */
  804. // // model: {
  805. // // uri: modelurl,
  806. // // scale: billboardModel.xL,
  807. // // },
  808. // /**
  809. // * 广告牌
  810. // */
  811. // // billboard: {
  812. // // image: imageurl,
  813. // // width: billboardModel.xL,
  814. // // height: billboardModel.zL,
  815. // // rotation: 0,
  816. // // },
  817. // orientation: orientation,
  818. // });
  819. // entityList.push(entity);
  820. // const point = viewer.entities.add({
  821. // id: "point_Billboard_" + billboardModel.id,
  822. // //点
  823. // position: Cesium.Cartesian3.fromDegrees(
  824. // billboardModel.x,
  825. // billboardModel.y,
  826. // billboardModel.z + billboardModel.yL / 2
  827. // ),
  828. // label: {
  829. // text: billboardModel.billboardName, //描述内容
  830. // font: "20px Sans-Serif", //字体大小 类型
  831. // fillColor: Cesium.Color.RED, //颜色
  832. // outlineColor: Cesium.Color.GOLD,
  833. // style: Cesium.LabelStyle.CENTER_LABEL,
  834. // // 垂直位置
  835. // verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
  836. // // 中心位置
  837. // pixelOffset: new Cesium.Cartesian2(0, -10),
  838. // //设置背景颜色透明
  839. // backgroundColor: new Cesium.Color(0.0, 0.0, 0.0, 0.0),
  840. // //打开背景 打开背景 (不会被线段覆盖)
  841. // showBackground: true,
  842. // // heightReference: Cesium.HeightReference.RELATIVE_TO_GROUND,
  843. // distanceDisplayCondition: new Cesium.DistanceDisplayCondition(
  844. // 0.0,
  845. // 300.0
  846. // ),
  847. // heightReference: Cesium.HeightReference.NONE,
  848. // },
  849. // });
  850. // }
  851. },
  852. initEntitiesHandler() {
  853. let that = this;
  854. this.getEntitiesHandler = new Cesium.ScreenSpaceEventHandler(
  855. scene.canvas
  856. );
  857. this.getEntitiesHandler.setInputAction(async function (click) {
  858. var pick = viewer.scene.pick(click.position);
  859. debugger;
  860. //广告牌信息弹窗
  861. if (pick && pick.id.id && pick.id.id.indexOf("_") !== -1) {
  862. let id = pick.id.id.split("_")[2];
  863. // let info = window.billboardModelList.find((c) => c.id == id);
  864. let info = await getBillboardModelList(id);
  865. that.openOBJInfo("广告牌信息详情", info.data);
  866. }
  867. }, Cesium.ScreenSpaceEventType.LEFT_CLICK);
  868. },
  869. //打开广告牌信息弹窗
  870. openOBJInfo(title, info) {
  871. let w = document.body.offsetWidth;
  872. let h = document.body.offsetHeight;
  873. //左上角(left=弹窗宽/2;top=弹窗高/2+header高)
  874. //右上角 (left=w-弹窗宽+(弹窗宽/2);top=弹窗高/2+header高);
  875. let left = 430 / 2 + 556;
  876. let top = 430 / 2 + 60;
  877. this.OBJInfolayerid = this.$layer.iframe({
  878. id: "GGPMXXQ",
  879. content: {
  880. content: billboarddetailInfo, //传递的组件对象
  881. parent: this, //当前的vue对象
  882. data: { info }, //props
  883. },
  884. offset: [left, top], //left top
  885. area: ["430px", "430px"], //宽 高
  886. title: title,
  887. maxmin: false,
  888. shade: false, //是否显示遮罩
  889. shadeClose: false, //点击遮罩是否关闭
  890. cancel: () => {
  891. //关闭事件
  892. // alert("关闭iframe");
  893. },
  894. });
  895. },
  896. //删除一个广告范围
  897. removeProjectScope(item) {
  898. if (item) {
  899. viewer.entities.removeById("ggwxmfw-" + item.id);
  900. lodash.remove(
  901. entityList,
  902. (entity) => entity.id === "ggwxmfw-" + item.id
  903. );
  904. }
  905. },
  906. //删除一个广告牌
  907. removeBillboard(item) {
  908. if (item) {
  909. viewer.entities.removeById("billboard_" + item.id);
  910. lodash.remove(
  911. entityList,
  912. (entity) => entity.id === "billboard_" + item.id
  913. );
  914. viewer.entities.removeById("point_Billboard_" + item.id);
  915. lodash.remove(
  916. entityList,
  917. (entity) => entity.id === "point_Billboard_" + item.id
  918. );
  919. }
  920. },
  921. removeAllentities() {
  922. viewer.entities.removeAll();
  923. entityList = [];
  924. },
  925. /**
  926. * 加载报建模型
  927. * @param info
  928. * @param isPosition
  929. */
  930. intoModel(info, isPosition) {
  931. let that = this;
  932. if (info.url && this.selectBillardId != info.id) {
  933. this.selectBillardId = info.id;
  934. this.thislayers.forEach((element) => {
  935. scene.layers.remove(element);
  936. });
  937. this.thislayers = [];
  938. setTimeout(function () {
  939. try {
  940. var dingwei = isPosition;
  941. if (isPosition != false) {
  942. dingwei = true;
  943. }
  944. var promisse11w = scene.open(info.url, undefined, {
  945. autoSetView: dingwei,
  946. });
  947. Cesium.when(promisse11w, function (layers) {
  948. debugger;
  949. layers.forEach((element) => {
  950. that.thislayers.push(element.name);
  951. // window.viewer.flyTo(element);
  952. });
  953. });
  954. that.yp(info);
  955. } catch (error) {
  956. console.log(error);
  957. }
  958. }, 1000);
  959. }
  960. },
  961. /**
  962. * 压平
  963. * @param Minfos 模型信息
  964. */
  965. async yp(info) {
  966. this.qxyp();
  967. const Minfo = info;
  968. //获取模型信息
  969. let queryBySQLParameters = {
  970. getFeatureMode: "SQL",
  971. datasetNames: [Minfo.datasourcename + ":项目范围"],
  972. queryParameter: {
  973. attributeFilter: "1=1",
  974. },
  975. hasGeometry: true,
  976. };
  977. let e = await mapQuery(
  978. Minfo.dataurl + "/featureResults.json?returnContent=true",
  979. queryBySQLParameters
  980. );
  981. if (e && e.totalCount > 0) {
  982. e.features.forEach((element) => {
  983. let flatPoints = element.geometry.points
  984. .map((item) => [item.x, item.y, 6.5])
  985. .flat();
  986. viewer.scene.layers.layerQueue.forEach((layer) => {
  987. let name = "flatten" + Math.random();
  988. let istrue = layer.addFlattenRegion({
  989. position: flatPoints,
  990. name: name,
  991. });
  992. });
  993. });
  994. }
  995. },
  996. qxyp() {
  997. viewer.scene.layers.layerQueue.forEach((layer) => {
  998. layer.removeAllFlattenRegion();
  999. });
  1000. },
  1001. },
  1002. beforeDestroy() {
  1003. this.$layer.close("MXSCList");
  1004. this.$layer.close("addXM");
  1005. this.$layer.close("GGPMXXQ");
  1006. this.$layer.close("addMX");
  1007. this.$layer.close("billboarddetail");
  1008. if (this.getEntitiesHandler) {
  1009. this.getEntitiesHandler.removeInputAction(
  1010. Cesium.ScreenSpaceEventType.LEFT_CLICK
  1011. );
  1012. }
  1013. this.qxyp();
  1014. this.removeAllentities();
  1015. debugger;
  1016. this.thislayers.forEach((element) => {
  1017. scene.layers.remove(element);
  1018. });
  1019. },
  1020. };
  1021. </script>
  1022. <style lang="scss">
  1023. @import "@/../../zt.scss";
  1024. </style>
  1025. <style lang="scss" scoped>
  1026. .card_body_style {
  1027. border: 1px dashed #02a7f0;
  1028. }
  1029. .hover_style:hover {
  1030. border: 1px solid #02a7f0;
  1031. }
  1032. .checkedState {
  1033. position: relative;
  1034. .status {
  1035. position: absolute;
  1036. right: 0;
  1037. top: 0;
  1038. // z-index: 2;
  1039. overflow: hidden;
  1040. // border-radius: 6px;
  1041. }
  1042. .icon {
  1043. position: absolute;
  1044. right: 0;
  1045. top: 0;
  1046. width: 2rem;
  1047. height: 2rem;
  1048. border: 8px;
  1049. background: #ffff80;
  1050. -webkit-clip-path: polygon(100% 0, 0 0, 100% 100%);
  1051. clip-path: polygon(100% 0, 0 0, 100% 100%);
  1052. }
  1053. .txts {
  1054. line-height: 2.6rem;
  1055. text-align: center;
  1056. transform: rotate(45deg);
  1057. transform-origin: center center;
  1058. color: #ec808c;
  1059. // font-size: 18px;
  1060. }
  1061. /* 带圆角的话这个status 和 txts的宽度/宽度 是要比icon的宽度/高度小的,效果可以自己慢慢调 */
  1062. .ce {
  1063. width: 4rem;
  1064. height: 4rem;
  1065. }
  1066. }
  1067. .con-col {
  1068. display: flex;
  1069. flex-flow: column nowrap;
  1070. justify-content: center;
  1071. align-items: center;
  1072. border-radius: 4px;
  1073. }
  1074. </style>