FileInfo.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399
  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>
  123. <div class="fileInfo-previewList">
  124. <div class="fileInfo-previewList-item">
  125. <img :src="state.info.thumbnail_url" />
  126. </div>
  127. </div>
  128. </a-spin>
  129. </div>
  130. </template>
  131. <script lang="ts" setup>
  132. import { reactive, onMounted } from 'vue';
  133. import { CloseOutlined, EnvironmentOutlined, DownloadOutlined } from '@ant-design/icons-vue';
  134. import Panoramic from '/@/components/panoramic/index.vue';
  135. import { useGMapManage } from '/@/hooks/use-g-map';
  136. import { apis } from '/@/api/custom';
  137. import { downloadFile } from '/@/utils/common';
  138. import { ELocalStorageKey } from '/@/types';
  139. import { downloadMediaFile } from '/@/api/media';
  140. interface Props {
  141. fileId: string,
  142. onClose: () => void,
  143. };
  144. const props = withDefaults(defineProps<Props>(), {
  145. });
  146. const state = reactive({
  147. downloadLoading: false,
  148. imgLoading: false,// 图片加载
  149. info: {
  150. url: '',
  151. thumbnail_url: '',// 缩略图
  152. media_type: null,
  153. file_id: '',
  154. file_name: '',
  155. picture_type: '',
  156. task_name: '',
  157. wayline_name: '',
  158. image_width: '',// 照片分辨率-宽度
  159. image_height: '',// 照片分辨率-高度
  160. size: 0,
  161. payload: '',
  162. picture_time: '',
  163. longitude: '',// 经度
  164. latitude: '',// 纬度
  165. },
  166. map: null, // 高德地图实例
  167. })
  168. // 高德地图Hook
  169. const AmapHook = useGMapManage();
  170. onMounted(async () => {
  171. try {
  172. const res = await apis.fetchFileDetail(props.fileId);
  173. state.info = res.data;
  174. if (res.data.media_type !== 4) {
  175. state.imgLoading = true;
  176. const img = new Image();
  177. img.src = state.info.url;
  178. img.onload = () => {
  179. state.imgLoading = false;
  180. };
  181. }
  182. if (state.info.longitude && state.info.latitude) {
  183. const AMap = await AmapHook.asyncInitMap();
  184. const map = new AMap.Map('photoPositionMap', {
  185. layers: [new AMap.TileLayer.Satellite()],// 卫星图-图层
  186. viewMode: '3D',// 3D地图
  187. rotateEnable: true,// 开启地图旋转交互
  188. pitchEnable: true,// 开启地图倾斜交互
  189. zoom: 17, // 初始化地图层级
  190. center: [state.info.longitude, state.info.latitude],// 中心点
  191. })
  192. state.map = map;
  193. // 创建一个标记并将其添加到地图上
  194. new AMap.Marker({
  195. map: map,
  196. cursor: 'pointer',
  197. position: [state.info.longitude, state.info.latitude],
  198. });
  199. }
  200. } catch (e) {
  201. console.error(e);
  202. }
  203. })
  204. // 点击下载
  205. const onClickDownload = async () => {
  206. state.downloadLoading = true;
  207. try {
  208. const workspaceId: string = localStorage.getItem(ELocalStorageKey.WorkspaceId) || '';
  209. const res = await downloadMediaFile(workspaceId, state.info.file_id)
  210. if (!res) {
  211. return
  212. }
  213. const data = new Blob([res])
  214. downloadFile(data, state.info.file_name)
  215. } catch (e) {
  216. console.error(e);
  217. } finally {
  218. state.downloadLoading = false;
  219. }
  220. }
  221. // 点击地图位置重置
  222. const onClickMapLocationReset = () => {
  223. const markerPosition = [state.info.longitude, state.info.latitude];
  224. const map: any = state.map;
  225. map.setCenter(markerPosition);
  226. map.setZoom(17);
  227. }
  228. </script>
  229. <style lang="scss">
  230. .fileInfo {
  231. width: 100%;
  232. height: 100vh;
  233. background: #1C1C1C;
  234. color: #FFFFFF;
  235. position: absolute;
  236. top: 0;
  237. left: 0;
  238. z-index: 9;
  239. overflow: auto;
  240. ::-webkit-scrollbar {
  241. width: 8px;
  242. height: 8px;
  243. background: transparent;
  244. }
  245. ::-webkit-scrollbar-thumb {
  246. border-radius: 4px;
  247. border: none;
  248. background: rgb(89, 89, 89);
  249. }
  250. &-detail {
  251. &-left {
  252. width: calc(100vw - 420px);
  253. height: calc(100vh - 120px);
  254. overflow: hidden;
  255. &-background {
  256. width: 100%;
  257. height: 100%;
  258. padding: 100px;
  259. display: flex;
  260. justify-content: center;
  261. align-items: center;
  262. }
  263. }
  264. &-info {
  265. width: 100%;
  266. height: calc(100vh - 120px);
  267. padding: 24px;
  268. overflow: auto;
  269. &-close {
  270. font-size: 20px;
  271. position: absolute;
  272. right: 24px;
  273. top: 24px;
  274. cursor: pointer;
  275. }
  276. &-title {
  277. font-size: 16px;
  278. margin-bottom: 16px;
  279. }
  280. &-item {
  281. width: 100%;
  282. height: 38px;
  283. display: flex;
  284. align-items: center;
  285. &-title {
  286. width: 85px;
  287. color: hsla(0, 0%, 100%, .45);
  288. }
  289. &-content {
  290. margin-left: 16px;
  291. &-line {
  292. display: flex;
  293. align-items: center;
  294. }
  295. }
  296. }
  297. &-map {
  298. &-title {
  299. height: 38px;
  300. display: flex;
  301. justify-content: space-between;
  302. align-items: center;
  303. &-text {
  304. color: hsla(0, 0%, 100%, .45);
  305. }
  306. &-icon {
  307. color: $primary;
  308. }
  309. }
  310. &-content {
  311. width: 100%;
  312. height: 250px;
  313. background: #dddddd;
  314. border-radius: 4px;
  315. margin-top: 10px;
  316. position: relative;
  317. overflow: hidden;
  318. &-title {
  319. width: 100%;
  320. height: 28px;
  321. padding-left: 10px;
  322. background: rgba(0, 0, 0, .5);
  323. line-height: 28px;
  324. font-size: 14px;
  325. color: #fff;
  326. position: absolute;
  327. bottom: 0;
  328. left: 0;
  329. }
  330. }
  331. }
  332. }
  333. }
  334. &-area {
  335. width: 100%;
  336. height: 50px;
  337. display: flex;
  338. justify-content: center;
  339. align-items: center;
  340. }
  341. &-previewList {
  342. width: 100%;
  343. height: 70px;
  344. display: flex;
  345. justify-content: center;
  346. &-item {
  347. width: 80px;
  348. height: 60px;
  349. border: 2px solid $primary;
  350. border-radius: 4px;
  351. margin-bottom: 10px;
  352. cursor: pointer;
  353. img {
  354. width: 100%;
  355. height: 100%;
  356. object-fit: cover;
  357. }
  358. }
  359. }
  360. }
  361. .amap-logo {
  362. display: none !important;
  363. }
  364. .amap-copyright {
  365. display: none !important;
  366. }
  367. </style>