FileInfo.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514
  1. <template>
  2. <div class="fileInfo">
  3. <a-spin :spinning="state.downloadLoading" tip="下载中...">
  4. <div class="fileInfo-detail">
  5. <a-row>
  6. <a-col flex="auto">
  7. <div class="fileInfo-detail-left">
  8. <div class="fileInfo-detail-left-background" v-if="state.imgLoading">
  9. <a-spin tip="加载中..." />
  10. </div>
  11. <Panoramic :src="state.info.url" v-if="state.info.media_type === 3" />
  12. <video style="width: 100%;height: 100%;" controls :src="state.info.url"
  13. v-else-if="state.info.media_type === 4"></video>
  14. <a-image width="100%" height="100%" :src="state.info.url" v-else />
  15. </div>
  16. </a-col>
  17. <a-col flex="420px">
  18. <div class="fileInfo-detail-info">
  19. <CloseOutlined class="fileInfo-detail-info-close" @click="onClose" />
  20. <div class="fileInfo-detail-info-title">
  21. 详细信息
  22. </div>
  23. <div class="fileInfo-detail-info-item">
  24. <div class="fileInfo-detail-info-item-title">
  25. 文件名称
  26. </div>
  27. <div class="fileInfo-detail-info-item-content">
  28. {{ state.info.file_name || '--' }}
  29. </div>
  30. </div>
  31. <div class="fileInfo-detail-info-item">
  32. <div class="fileInfo-detail-info-item-title">
  33. 文件类型
  34. </div>
  35. <div class="fileInfo-detail-info-item-content">
  36. {{ state.info.picture_type || '--' }}
  37. </div>
  38. </div>
  39. <div class="fileInfo-detail-info-item">
  40. <div class="fileInfo-detail-info-item-title">
  41. 任务名称
  42. </div>
  43. <div class="fileInfo-detail-info-item-content">
  44. {{ state.info.task_name || '--' }}
  45. </div>
  46. </div>
  47. <div class="fileInfo-detail-info-item">
  48. <div class="fileInfo-detail-info-item-title">
  49. 航线名称
  50. </div>
  51. <div class="fileInfo-detail-info-item-content">
  52. {{ state.info.wayline_name || '--' }}
  53. </div>
  54. </div>
  55. <div class="fileInfo-detail-info-item">
  56. <div class="fileInfo-detail-info-item-title">
  57. 分辨率
  58. </div>
  59. <div class="fileInfo-detail-info-item-content">
  60. <div class="fileInfo-detail-info-item-content-line"
  61. v-if="state.info.image_width && state.info.image_height">
  62. {{ state.info.image_width }}*{{ state.info.image_height }}
  63. </div>
  64. <div v-else>
  65. --
  66. </div>
  67. </div>
  68. </div>
  69. <div class="fileInfo-detail-info-item">
  70. <div class="fileInfo-detail-info-item-title">
  71. 文件大小
  72. </div>
  73. <div class="fileInfo-detail-info-item-content">
  74. {{ state.info.size > 0 ? (state.info.size / 1024 / 1024).toFixed(1) + 'M' : '--' }}
  75. </div>
  76. </div>
  77. <div class="fileInfo-detail-info-item">
  78. <div class="fileInfo-detail-info-item-title">
  79. 拍摄负载
  80. </div>
  81. <div class="fileInfo-detail-info-item-content">
  82. {{ state.info.payload || '--' }}
  83. </div>
  84. </div>
  85. <div class="fileInfo-detail-info-item">
  86. <div class="fileInfo-detail-info-item-title">
  87. 拍摄时间
  88. </div>
  89. <div class="fileInfo-detail-info-item-content">
  90. {{ state.info.picture_time || '--' }}
  91. </div>
  92. </div>
  93. <div class="fileInfo-detail-info-map">
  94. <div class="fileInfo-detail-info-map-title">
  95. <div class="fileInfo-detail-info-map-title-text">
  96. 照片位置
  97. </div>
  98. <div class="fileInfo-detail-info-map-title-icon">
  99. <EnvironmentOutlined @click="onClickMapLocationReset" />
  100. </div>
  101. </div>
  102. <div class="fileInfo-detail-info-map-content">
  103. <div id="photoPositionMap" :style="{ width: '100%', height: '100%' }"></div>
  104. <div class="fileInfo-detail-info-map-content-title">
  105. <span>
  106. {{ state.info.latitude }}° N
  107. </span>
  108. <span>
  109. {{ state.info.longitude }}° E
  110. </span>
  111. </div>
  112. </div>
  113. </div>
  114. </div>
  115. </a-col>
  116. </a-row>
  117. </div>
  118. <div class="fileInfo-area">
  119. <a-tooltip placement="bottom" title="下载">
  120. <DownloadOutlined style="font-size: 20px;margin-right: 20px;" @click="onClickDownload" />
  121. </a-tooltip>
  122. <div v-if="[1, 3].includes(state.info.media_type)">
  123. <a-tooltip placement="bottom" title="在地图上加载" v-if="!state.info.element_id">
  124. <AimOutlined style="font-size: 20px;margin-right: 20px;" @click="onClickCreateMapElement" />
  125. </a-tooltip>
  126. <a-tooltip placement="bottom" title="在地图上取消加载" v-else>
  127. <AimOutlined style="font-size: 20px;margin-right: 20px;" @click="onClickDeleteMapElement" />
  128. </a-tooltip>
  129. </div>
  130. </div>
  131. <div class="fileInfo-previewList">
  132. <div class="fileInfo-previewList-button" @click="onClickScroll('LEFT')" @mousedown.prevent>
  133. <VerticalRightOutlined />
  134. </div>
  135. <div ref="contentRef" class="fileInfo-previewList-content">
  136. <img
  137. :class="['fileInfo-previewList-content-item', state.currentId === item.file_id ? 'fileInfo-previewList-content-item-selected' : '']"
  138. v-for="item in fileList" :src="item.thumbnail_url" @click="onClickSelected(item.file_id)" />
  139. </div>
  140. <div class="fileInfo-previewList-button" @click="onClickScroll('RIGHT')" @mousedown.prevent>
  141. <VerticalLeftOutlined />
  142. </div>
  143. </div>
  144. </a-spin>
  145. </div>
  146. </template>
  147. <script lang="ts" setup>
  148. import { ref, reactive, onMounted } from 'vue';
  149. import { message } from 'ant-design-vue';
  150. import { CloseOutlined, EnvironmentOutlined, DownloadOutlined, AimOutlined, VerticalRightOutlined, VerticalLeftOutlined } from '@ant-design/icons-vue';
  151. import Panoramic from '/@/components/panoramic/index.vue';
  152. import { useGMapManage } from '/@/hooks/use-g-map';
  153. import { apis } from '/@/api/custom';
  154. import { downloadFile } from '/@/utils/common';
  155. import { downloadMediaFile } from '/@/api/media';
  156. import { wgs84togcj02 } from '/@/vendors/coordtransform'
  157. import { getWorkspaceId } from '/@/utils/index'
  158. interface Props {
  159. fileId: string,
  160. fileList: any[],
  161. onClose: () => Promise<any>,
  162. };
  163. const props = withDefaults(defineProps<Props>(), {
  164. });
  165. const state = reactive({
  166. currentId: props.fileId,
  167. downloadLoading: false,
  168. imgLoading: false,// 图片加载
  169. info: {
  170. url: '',
  171. media_type: 0,
  172. file_id: '',
  173. element_id: '',
  174. file_name: '',
  175. picture_type: '',
  176. task_name: '',
  177. wayline_name: '',
  178. image_width: '',// 照片分辨率-宽度
  179. image_height: '',// 照片分辨率-高度
  180. size: 0,
  181. payload: '',
  182. picture_time: '',
  183. longitude: '',// 经度
  184. latitude: '',// 纬度
  185. coordinates: [],
  186. },
  187. map: null, // 高德地图实例
  188. })
  189. const contentRef = ref();
  190. // 高德地图Hook
  191. const AmapHook = useGMapManage();
  192. const init = async () => {
  193. try {
  194. const res = await apis.fetchFileDetail(state.currentId);
  195. state.info = {
  196. ...res.data,
  197. longitude: res.data.longitude ? res.data.longitude.toFixed(6) : '',
  198. latitude: res.data.latitude ? res.data.latitude.toFixed(6) : '',
  199. coordinates: (res.data.longitude && res.data.latitude) ? wgs84togcj02(res.data.longitude, res.data.latitude) : [],
  200. };
  201. if (res.data.media_type !== 4) {
  202. state.imgLoading = true;
  203. const img = new Image();
  204. img.src = state.info.url;
  205. img.onload = () => {
  206. state.imgLoading = false;
  207. };
  208. }
  209. if (state.info.coordinates.length) {
  210. const AMap = await AmapHook.asyncInitMap();
  211. const map = new AMap.Map('photoPositionMap', {
  212. layers: [new AMap.TileLayer.Satellite()],// 卫星图-图层
  213. viewMode: '3D',// 3D地图
  214. rotateEnable: true,// 开启地图旋转交互
  215. pitchEnable: true,// 开启地图倾斜交互
  216. zoom: 17, // 初始化地图层级
  217. center: state.info.coordinates,// 中心点
  218. })
  219. state.map = map;
  220. // 创建一个标记并将其添加到地图上
  221. new AMap.Marker({
  222. map: map,
  223. cursor: 'pointer',
  224. position: state.info.coordinates,
  225. });
  226. }
  227. } catch (e) {
  228. console.error(e);
  229. }
  230. }
  231. onMounted(async () => {
  232. await init()
  233. })
  234. // 点击下载
  235. const onClickDownload = async () => {
  236. state.downloadLoading = true;
  237. try {
  238. const workspaceId: string = getWorkspaceId();
  239. const res = await downloadMediaFile(workspaceId, state.info.file_id)
  240. if (!res) {
  241. return
  242. }
  243. const data = new Blob([res])
  244. downloadFile(data, state.info.file_name)
  245. } catch (e) {
  246. console.error(e);
  247. } finally {
  248. state.downloadLoading = false;
  249. }
  250. }
  251. // 点击在地图上加载
  252. const onClickCreateMapElement = async () => {
  253. try {
  254. const id = state.info.file_id;
  255. const res = await apis.createMapElement(id);
  256. state.info.element_id = res.data.element_id;
  257. message.success('在地图上加载成功');
  258. } catch (e: any) {
  259. console.error(e);
  260. }
  261. }
  262. // 点击在地图上取消加载
  263. const onClickDeleteMapElement = async () => {
  264. try {
  265. const id = state.info.file_id;
  266. await apis.deleteMapElement(id);
  267. state.info.element_id = '';
  268. message.success('在地图上取消加载成功');
  269. } catch (e: any) {
  270. console.error(e);
  271. }
  272. }
  273. // 点击地图位置重置
  274. const onClickMapLocationReset = () => {
  275. const markerPosition = state.info.coordinates;
  276. const map: any = state.map;
  277. map.setCenter(markerPosition);
  278. map.setZoom(17);
  279. }
  280. // 点击滚动
  281. const onClickScroll = (type: 'LEFT' | 'RIGHT') => {
  282. const contentElement = contentRef.value;
  283. const scrollAmount = 80; // 滚动的像素数等于图片宽度
  284. if (type === 'LEFT') {
  285. contentElement.scrollLeft -= scrollAmount; // 向左滚动
  286. } else if (type === 'RIGHT') {
  287. contentElement.scrollLeft += scrollAmount; // 向右滚动
  288. }
  289. };
  290. // 点击选中
  291. const onClickSelected = async (id: string) => {
  292. state.currentId = id;
  293. state.downloadLoading = false;
  294. state.imgLoading = false;
  295. state.info = {
  296. url: '',
  297. media_type: 0,
  298. file_id: '',
  299. element_id: '',
  300. file_name: '',
  301. picture_type: '',
  302. task_name: '',
  303. wayline_name: '',
  304. image_width: '',// 照片分辨率-宽度
  305. image_height: '',// 照片分辨率-高度
  306. size: 0,
  307. payload: '',
  308. picture_time: '',
  309. longitude: '',// 经度
  310. latitude: '',// 纬度
  311. coordinates: [],
  312. }
  313. await init()
  314. }
  315. </script>
  316. <style lang="scss">
  317. .fileInfo {
  318. width: 100%;
  319. height: 100vh;
  320. background: #1C1C1C;
  321. color: #FFFFFF;
  322. position: absolute;
  323. top: 0;
  324. left: 0;
  325. z-index: 9;
  326. overflow: auto;
  327. ::-webkit-scrollbar {
  328. width: 8px;
  329. height: 8px;
  330. background: transparent;
  331. }
  332. ::-webkit-scrollbar-thumb {
  333. border-radius: 4px;
  334. border: none;
  335. background: rgb(89, 89, 89);
  336. }
  337. &-detail {
  338. &-left {
  339. width: calc(100vw - 420px);
  340. height: calc(100vh - 130px);
  341. overflow: hidden;
  342. &-background {
  343. width: 100%;
  344. height: 100%;
  345. padding: 100px;
  346. display: flex;
  347. justify-content: center;
  348. align-items: center;
  349. }
  350. }
  351. &-info {
  352. width: 100%;
  353. height: calc(100vh - 130px);
  354. padding: 24px;
  355. overflow: auto;
  356. &-close {
  357. font-size: 20px;
  358. position: absolute;
  359. right: 24px;
  360. top: 24px;
  361. cursor: pointer;
  362. }
  363. &-title {
  364. font-size: 16px;
  365. margin-bottom: 16px;
  366. }
  367. &-item {
  368. width: 100%;
  369. height: 38px;
  370. display: flex;
  371. align-items: center;
  372. &-title {
  373. width: 85px;
  374. color: hsla(0, 0%, 100%, .45);
  375. }
  376. &-content {
  377. margin-left: 16px;
  378. &-line {
  379. display: flex;
  380. align-items: center;
  381. }
  382. }
  383. }
  384. &-map {
  385. &-title {
  386. height: 38px;
  387. display: flex;
  388. justify-content: space-between;
  389. align-items: center;
  390. &-text {
  391. color: hsla(0, 0%, 100%, .45);
  392. }
  393. &-icon {
  394. color: $primary;
  395. }
  396. }
  397. &-content {
  398. width: 100%;
  399. height: 250px;
  400. background: #dddddd;
  401. border-radius: 4px;
  402. margin-top: 10px;
  403. position: relative;
  404. overflow: hidden;
  405. &-title {
  406. width: 100%;
  407. height: 28px;
  408. padding-left: 10px;
  409. background: rgba(0, 0, 0, .5);
  410. line-height: 28px;
  411. font-size: 14px;
  412. color: #fff;
  413. position: absolute;
  414. bottom: 0;
  415. left: 0;
  416. }
  417. }
  418. }
  419. }
  420. }
  421. &-area {
  422. width: 100%;
  423. height: 50px;
  424. display: flex;
  425. justify-content: center;
  426. align-items: center;
  427. }
  428. &-previewList {
  429. width: 100%;
  430. height: 60px;
  431. display: flex;
  432. justify-content: space-between;
  433. align-items: center;
  434. margin-bottom: 20px;
  435. &-content {
  436. width: calc(100vw - 80px);
  437. display: flex;
  438. overflow: auto;
  439. scrollbar-width: none;
  440. &-item {
  441. width: 80px;
  442. height: 60px;
  443. object-fit: cover;
  444. border: 2px solid transparent;
  445. border-radius: 4px;
  446. margin-right: 10px;
  447. cursor: pointer;
  448. &-selected {
  449. border-color: $primary;
  450. }
  451. }
  452. &-item:last-child {
  453. margin: 0;
  454. }
  455. }
  456. &-button {
  457. width: 30px;
  458. height: 60px;
  459. border: 1px solid #FFFFFF;
  460. display: flex;
  461. justify-content: center;
  462. align-items: center;
  463. cursor: pointer;
  464. }
  465. }
  466. }
  467. .amap-logo {
  468. display: none !important;
  469. }
  470. .amap-copyright {
  471. display: none !important;
  472. }
  473. </style>