index.vue 8.2 KB

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