zstc.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. <script setup>
  2. import {
  3. inject
  4. } from "vue";
  5. import html2canvas from 'html2canvas';
  6. import {
  7. blobToBase64,
  8. base64ToBlob
  9. } from '@/assets/js/blobtobase64';
  10. const getMapInstance = inject("getMapInstance");
  11. jt3d = getMapInstance();
  12. </script>
  13. <template>
  14. <div style="font-weight: bold;">总设备数量</div>
  15. </template>
  16. <script>
  17. let jt3d = undefined;
  18. export default {
  19. data() {
  20. return {
  21. // viewersName: '', //视角标签名称
  22. // ImgurlList: [], //截图地址列表
  23. }
  24. },
  25. methods: {
  26. //获取输入框值
  27. getName() {
  28. this.viewersName = document.getElementById("inputValue").value;
  29. },
  30. //跳转方法
  31. flyto(options) {
  32. jt3d.LocateUtil.flyToPoint(options)
  33. },
  34. //删除方法,传keyvalue以及需要修改属性
  35. deleteviewer(item, index) {
  36. //删除对应数组内的对象
  37. this.ImgurlList.splice(index, 1)
  38. if (item.id) {
  39. this.$http.get('/delete', {
  40. tableName: 'sys_map_angle',
  41. keyValue: item.id,
  42. }).then(res => {
  43. console.log(res.data)
  44. })
  45. }
  46. },
  47. //添加视角标签,当前页存数组,向数据库传入相机参数
  48. addviewer() {
  49. //获取当前界面截图方法
  50. html2canvas(
  51. this.$parent.$parent.$refs.refMap3d.$refs.cesiumContainer, {
  52. // backgroundColor: null, //画出来的图片有白色的边框,不要可设置背景为透明色(null)
  53. useCORS: true, //支持图片跨域
  54. scale: 1 / 8, //设置放大的倍数
  55. }
  56. ).then(canvas => {
  57. //截图用img元素承装,显示在页面的上
  58. let url = canvas.toDataURL('image/png')
  59. //经纬度、高度
  60. // 获取 相机姿态信息
  61. let heading = window["viewer"].scene.camera.heading
  62. let pitch = window["viewer"].scene.camera.pitch
  63. let roll = window["viewer"].scene.camera.roll
  64. let position = window["viewer"].scene.camera.positionCartographic
  65. let longitude = Cesium.Math.toDegrees(position.longitude) //y
  66. let latitude = Cesium.Math.toDegrees(position.latitude) //x
  67. let height = position.height
  68. let info = {
  69. latitude: latitude,
  70. longitude: longitude,
  71. height: height,
  72. pitch: Cesium.Math.toDegrees(pitch),
  73. roll: Cesium.Math.toDegrees(roll),
  74. heading: Cesium.Math.toDegrees(heading)
  75. }
  76. //dom for循环渲染列表
  77. this.ImgurlList.unshift({
  78. url: url,
  79. name: this.viewersName,
  80. info: info
  81. })
  82. //base64转换为二进制文件
  83. // let blob = base64ToBlob(url)
  84. // //文件转为文件流
  85. // let formData = new FormData();
  86. // formData.append('file',blob)
  87. let data = {
  88. name: this.viewersName,
  89. x: latitude,
  90. y: longitude,
  91. z: height,
  92. pitch: Cesium.Math.toDegrees(pitch),
  93. roll: Cesium.Math.toDegrees(roll),
  94. heading: Cesium.Math.toDegrees(heading),
  95. screenshot: url,
  96. userId: this.id,
  97. // id:0
  98. }
  99. //添加数据接口
  100. this.$http.post('/postSubmit', {
  101. tableName: 'sys_map_angle',
  102. keyValue: '',
  103. formData: data,
  104. }).then(res => {
  105. console.log(res)
  106. if (res.success == true) {
  107. }
  108. })
  109. }).catch(err => {
  110. console.log(err)
  111. })
  112. },
  113. searchviewer() {
  114. this.info = JSON.parse(localStorage.getItem('person'))
  115. this.id = this.info.id
  116. //获取所有图片数据
  117. this.$http.get('/getTableList', {
  118. tableName: 'sys_map_angle', //
  119. sqlWhere: "name like '%" + this.viewersName + "%'",
  120. orderByField: ''
  121. }).then(res => {
  122. console.log('获取图片', res.data)
  123. this.ImgurlList = [];
  124. res.data.forEach(item => {
  125. let info = {
  126. latitude: item.x,
  127. longitude: item.y,
  128. height: item.z,
  129. pitch: item.pitch,
  130. roll: item.roll,
  131. heading: item.heading
  132. }
  133. // let url = blobToBase64(item.screenshot)
  134. //dom for循环渲染列表
  135. this.ImgurlList.push({
  136. url: item.screenshot,
  137. name: item.name,
  138. info: info,
  139. id: item.id
  140. })
  141. })
  142. // console.log('img列表',this.ImgurlList)
  143. })
  144. }
  145. },
  146. mounted() {
  147. this.info = JSON.parse(localStorage.getItem('person'))
  148. this.id = this.info.id
  149. //获取所有图片数据
  150. this.$http.get('/getTableList', {
  151. tableName: 'sys_map_angle', //
  152. sqlWhere: '', //+ this.loginForm.id
  153. orderByField: ''
  154. }).then(res => {
  155. console.log('获取图片', res.data)
  156. res.data.forEach(item => {
  157. let info = {
  158. latitude: item.x,
  159. longitude: item.y,
  160. height: item.z,
  161. pitch: item.pitch,
  162. roll: item.roll,
  163. heading: item.heading
  164. }
  165. // let url = blobToBase64(item.screenshot)
  166. //dom for循环渲染列表
  167. this.ImgurlList.push({
  168. url: item.screenshot,
  169. name: item.name,
  170. info: info,
  171. id: item.id
  172. })
  173. })
  174. // console.log('img列表',this.ImgurlList)
  175. })
  176. }
  177. }
  178. </script>
  179. <style lang="scss" scoped>
  180. .mainview {
  181. width: 100%;
  182. height: 100%;
  183. .header {
  184. width: 100%;
  185. display: flex;
  186. input,
  187. input:focus {
  188. outline: none;
  189. width: 185rem !important;
  190. border: 1rem solid rgba(255, 255, 255, 0.8);
  191. margin-right: 10rem;
  192. height: 26rem !important;
  193. color: rgba(255, 255, 255, 1);
  194. background-color: rgba(255, 255, 255, 0) !important;
  195. border-radius: 3rem;
  196. }
  197. }
  198. .middleviewer {
  199. width: 265rem;
  200. height: 100%;
  201. margin-left: 7rem;
  202. .viewer {
  203. width: 265rem !important;
  204. height: 196rem !important;
  205. margin-top: 15rem;
  206. border: 1rem solid #ffffff !important;
  207. border-radius: 1rem !important;
  208. .viewertop {
  209. width: 265rem !important;
  210. height: 166rem !important;
  211. img {
  212. width: 100% !important;
  213. height: 100% !important;
  214. }
  215. }
  216. .viewerbottom {
  217. line-height: 30rem !important;
  218. text-align: center !important;
  219. width: 265rem !important;
  220. height: 30rem !important;
  221. position: relative;
  222. background-color: rgba(15, 145, 185, 0.7);
  223. .deleteImg {
  224. width: 24rem;
  225. height: 24rem;
  226. right: 5rem;
  227. top: 3rem;
  228. position: absolute;
  229. }
  230. }
  231. }
  232. }
  233. }
  234. ::v-deep .el-input {
  235. flex-grow: 0 !important;
  236. width: 200rem !important;
  237. // display: inline !important;
  238. // margin-left: 5rem;
  239. margin-right: 10rem;
  240. height: 30rem !important;
  241. }
  242. //输入框文字颜色
  243. ::v-deep .el-input__inner {
  244. color: rgba(255, 255, 255, 1)
  245. }
  246. //输入框背景色
  247. ::v-deep .el-input__wrapper {
  248. background-color: rgba(255, 255, 255, 0) !important;
  249. }
  250. ::v-deep .el-button {
  251. border-radius: 3rem !important;
  252. }
  253. ::v-deep .el-button--primary {
  254. background-color: rgba(64, 158, 255, 0.6) !important;
  255. }
  256. ::-webkit-scrollbar {
  257. width: 0rem;
  258. }
  259. </style>