index.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  1. <template>
  2. <div class="trajectoryList">
  3. <div style="width: 100%;height: 400px;">
  4. <EasyPlayer :url="'webrtc://smsp.jkec.info:18000/rtc/stream_27'" />
  5. </div>
  6. <Search :mode="state.mode" :selectedRowKeys="state.selectedRowKeys" :onClickDownload="onClickBatchDownload"
  7. :onClickSearch="onClickSearch" :onClickReset="onClickReset" />
  8. <div style="background: #FFFFFF;padding: 20px;">
  9. <div class="trajectoryList-info">
  10. <div>
  11. 轨迹回放文件
  12. </div>
  13. <div class="trajectoryList-info-right">
  14. <div class="trajectoryList-info-right-text">
  15. <div>
  16. 已选/全部:
  17. </div>
  18. <div>
  19. {{ state.selectedRowKeys.length }}/{{ paginationConfig.total }}
  20. </div>
  21. </div>
  22. <a-button style="padding:0 5px;" :type="state.mode === 'table' ? 'primary' : 'default'"
  23. :ghost="state.mode === 'table'" size="small" @click="state.mode = 'table'">
  24. <MenuOutlined />
  25. </a-button>
  26. <a-button style="padding:0 5px;" :type="state.mode === 'list' ? 'primary' : 'default'"
  27. :ghost="state.mode === 'list'" size="small" @click="state.mode = 'list'">
  28. <AppstoreOutlined />
  29. </a-button>
  30. </div>
  31. </div>
  32. <div>
  33. <div class="trajectoryList-table" v-if="state.mode === 'table'">
  34. <a-table :scroll="{ x: '100%', y: 500 }" :childrenColumnName="null" rowKey="id" :loading="state.listLoading"
  35. :columns="columns" :dataSource="state.list" :rowClassName="rowClassName" :pagination="paginationConfig"
  36. :rowSelection="{ selectedRowKeys: state.selectedRowKeys, onChange: onSelectChange }">
  37. <!-- 文件夹名称 -->
  38. <template #dir_name="{ record }">
  39. <a-tooltip :title="record.dir_name">
  40. <div class="fileName" @click="onClickFile(record)">
  41. <img :src="fileSrc">
  42. <div>
  43. {{ record.dir_name }}
  44. </div>
  45. </div>
  46. </a-tooltip>
  47. </template>
  48. <!-- 操作 -->
  49. <template #action="{ record }">
  50. <div class="flex-align-center flex-row" style="color: #2d8cf0">
  51. <a-tooltip title="压缩下载">
  52. <DownloadOutlined style="margin-right: 10px;" @click="onClickDownload(record)" />
  53. </a-tooltip>
  54. <a-tooltip title="轨迹回放">
  55. <EnvironmentOutlined @click="onClickTrajectory" />
  56. </a-tooltip>
  57. </div>
  58. </template>
  59. </a-table>
  60. </div>
  61. <div class="trajectoryList-list" v-else>
  62. <a-list :grid="{ gutter: 16, xs: 1, sm: 2, md: 3, lg: 4, xl: 8, xxl: 12 }" :loading="state.listLoading"
  63. :dataSource="state.list" :pagination="paginationConfig">
  64. <template #renderItem="{ item }">
  65. <a-list-item>
  66. <a-card hoverable @click="onClickFile(item)">
  67. <template #cover>
  68. <div style="display: flex;justify-content:center;align-items: center;">
  69. <img style="width: 70%;" :src="fileSrc" />
  70. </div>
  71. </template>
  72. <a-card-meta>
  73. <template #description>
  74. <a-tooltip placement="bottom" :title="item.dir_name">
  75. <div class="trajectoryList-list-name">
  76. {{ item.dir_name }}
  77. </div>
  78. </a-tooltip>
  79. </template>
  80. </a-card-meta>
  81. </a-card>
  82. </a-list-item>
  83. </template>
  84. </a-list>
  85. </div>
  86. </div>
  87. </div>
  88. </div>
  89. </template>
  90. <script lang="ts" setup>
  91. import { reactive, onMounted } from 'vue';
  92. import { MenuOutlined, AppstoreOutlined, DownloadOutlined, EnvironmentOutlined } from '@ant-design/icons-vue';
  93. import Search from './components/Search.vue';
  94. import fileSrc from '/@/assets/media/file.svg';
  95. import { apis } from '/@/api/custom';
  96. import router from '/@/router/index';
  97. import EasyPlayer from '/@/components/easyPlayer/index.vue';
  98. interface State {
  99. listLoading: boolean,
  100. list: any[],
  101. selectedRowKeys: string[],
  102. mode: 'table' | 'list',
  103. };
  104. const state: State = reactive({
  105. listLoading: false,
  106. list: [],
  107. selectedRowKeys: [],
  108. mode: 'table',
  109. })
  110. const paginationConfig = reactive({
  111. pageSizeOptions: ['20', '50', '100'],
  112. showQuickJumper: true,
  113. showSizeChanger: true,
  114. pageSize: 20,
  115. current: 1,
  116. total: 0,
  117. onChange: async (current: number) => {
  118. paginationConfig.current = current;
  119. await fetchList();
  120. },
  121. onShowSizeChange: async (current: number, pageSize: number) => {
  122. paginationConfig.pageSize = pageSize;
  123. await fetchList();
  124. }
  125. })
  126. const fetchList = async () => {
  127. state.listLoading = true;
  128. try {
  129. const res = await apis.fetchMediaFileList({ page: paginationConfig.current, page_size: paginationConfig.pageSize });
  130. state.list = res.data.list;
  131. paginationConfig.current = res.data.pagination.page;
  132. paginationConfig.pageSize = res.data.pagination.page_size;
  133. paginationConfig.total = res.data.pagination.total;
  134. } catch (e) {
  135. console.error(e);
  136. } finally {
  137. state.listLoading = false;
  138. }
  139. }
  140. onMounted(async () => {
  141. // await fetchList();
  142. })
  143. const columns = [
  144. {
  145. title: '文件夹名称',
  146. dataIndex: 'dir_name',
  147. width: 250,
  148. ellipsis: true,
  149. sorter: (a: any, b: any) => a.dir_name.localeCompare(b.dir_name),
  150. slots: { customRender: 'dir_name' }
  151. },
  152. {
  153. title: '设备型号',
  154. dataIndex: 'device_name',
  155. width: 150,
  156. ellipsis: true,
  157. },
  158. {
  159. title: '拍摄负载',
  160. dataIndex: 'payload',
  161. width: 150,
  162. ellipsis: true,
  163. },
  164. {
  165. title: '容量大小',
  166. dataIndex: 'is_original',
  167. width: 150,
  168. ellipsis: true,
  169. customRender: ({ text }: any) => {
  170. return text || '--';
  171. }
  172. },
  173. {
  174. title: '创建时间',
  175. dataIndex: 'create_time',
  176. width: 200,
  177. sorter: (a: any, b: any) => a.create_time.localeCompare(b.create_time),
  178. },
  179. {
  180. title: '航线名称',
  181. dataIndex: 'wayline_name',
  182. width: 150,
  183. },
  184. {
  185. title: '任务类型',
  186. dataIndex: 'template_type',
  187. width: 150,
  188. customRender: ({ text }: any) => {
  189. return text || '--';
  190. }
  191. },
  192. {
  193. title: '创建人',
  194. dataIndex: 'username',
  195. width: 150,
  196. },
  197. {
  198. title: '操作',
  199. dataIndex: 'actions',
  200. fixed: 'right',
  201. width: 80,
  202. slots: { customRender: 'action' },
  203. },
  204. ]
  205. const rowClassName = (record: any, index: number) => {
  206. const className = []
  207. if ((index & 1) === 0) {
  208. className.push('table-striped')
  209. }
  210. return className.toString().replaceAll(',', ' ')
  211. }
  212. // 点击批量下载
  213. const onClickBatchDownload = async () => {
  214. console.log(state.selectedRowKeys, '点击批量下载');
  215. }
  216. // 点击搜索
  217. const onClickSearch = async () => {
  218. console.log('点击搜索');
  219. }
  220. // 点击重置
  221. const onClickReset = async () => {
  222. console.log('点击重置');
  223. }
  224. // 点击文件夹
  225. const onClickFile = (record: any) => {
  226. router.push({ path: `/media/${record.id}` })
  227. }
  228. // 勾选
  229. const onSelectChange = (selectedRowKeys: string[]) => {
  230. state.selectedRowKeys = selectedRowKeys;
  231. }
  232. // 点击下载
  233. const onClickDownload = async (record: any) => {
  234. state.listLoading = true;
  235. try {
  236. } catch (e) {
  237. console.error(e);
  238. } finally {
  239. state.listLoading = false;
  240. }
  241. }
  242. // 点击轨迹回放
  243. const onClickTrajectory = () => {
  244. router.push({ path: '/trajectory' })
  245. }
  246. </script>
  247. <style lang="scss">
  248. .trajectoryList {
  249. padding: 20px;
  250. &-info {
  251. display: flex;
  252. justify-content: space-between;
  253. align-items: center;
  254. margin-bottom: 20px;
  255. &-right {
  256. display: flex;
  257. align-items: center;
  258. &-text {
  259. display: flex;
  260. align-items: center;
  261. margin-right: 20px;
  262. }
  263. }
  264. }
  265. .fileName {
  266. display: flex;
  267. align-items: center;
  268. cursor: pointer;
  269. img {
  270. width: 36px;
  271. height: 36px;
  272. margin-right: 5px;
  273. }
  274. }
  275. &-list {
  276. &-name {
  277. overflow: hidden;
  278. text-overflow: ellipsis;
  279. white-space: nowrap;
  280. }
  281. }
  282. }
  283. .ant-table {
  284. border-top: 1px solid rgb(0, 0, 0, 0.06);
  285. border-bottom: 1px solid rgb(0, 0, 0, 0.06);
  286. }
  287. .ant-table-tbody tr td {
  288. border: 0;
  289. }
  290. .table-striped {
  291. background-color: #f7f9fa;
  292. }
  293. .ant-card-body {
  294. padding: 0 10px 10px;
  295. }
  296. </style>