index.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. <template>
  2. <div class="trajectory">
  3. <Search :onClickSearch="onClickSearch" :onClickReset="onClickReset" />
  4. <div class="trajectory-table">
  5. <a-table :scroll="{ x: '100%', y: 500 }" rowKey="id" :loading="state.listLoading" :columns="columns"
  6. @change="refreshData" :rowClassName="rowClassName" :dataSource="state.list" :pagination="paginationConfig">
  7. <!-- 操作 -->
  8. <template #action="{ record }">
  9. <div style="color: #2d8cf0">
  10. <a-tooltip title="查看轨迹">
  11. <GatewayOutlined @click="onClickLookTrajectory(record.id)" />
  12. </a-tooltip>
  13. </div>
  14. </template>
  15. </a-table>
  16. </div>
  17. </div>
  18. </template>
  19. <script lang="ts" setup>
  20. import { reactive, onMounted } from 'vue';
  21. import { GatewayOutlined } from '@ant-design/icons-vue';
  22. import Search from './components/Search.vue';
  23. import { apis } from '/@/api/custom/index';
  24. import router from '/@/router';
  25. import { useMyStore } from '/@/store';
  26. import { wgs84togcj02 } from '../../../../vendors/coordtransform'
  27. const store = useMyStore()
  28. interface State {
  29. query: any,
  30. listLoading: boolean,
  31. list: any[],
  32. };
  33. const state: State = reactive({
  34. query: undefined,
  35. listLoading: false,
  36. list: [],
  37. });
  38. const paginationConfig = reactive({
  39. pageSizeOptions: ['20', '50', '100'],
  40. showQuickJumper: true,
  41. showSizeChanger: true,
  42. pageSize: 20,
  43. current: 1,
  44. total: 0
  45. })
  46. const fetchList = async () => {
  47. state.listLoading = true;
  48. try {
  49. const res = await apis.fetchTrajectoryList({
  50. ...state.query,
  51. page: paginationConfig.current,
  52. page_size: paginationConfig.pageSize
  53. });
  54. if (res.code === 0) {
  55. state.list = res.data.list;
  56. paginationConfig.total = res.data.pagination.total
  57. paginationConfig.current = res.data.pagination.page
  58. paginationConfig.pageSize = res.data.pagination.page_size
  59. }
  60. } catch (e) {
  61. console.error(e);
  62. } finally {
  63. state.listLoading = false;
  64. }
  65. }
  66. onMounted(async () => {
  67. await fetchList();
  68. })
  69. const columns = [
  70. {
  71. title: '计划名称',
  72. dataIndex: 'task_name',
  73. width: 250,
  74. ellipsis: true,
  75. sorter: (a: any, b: any) => a.task_name.localeCompare(b.task_name),
  76. },
  77. {
  78. title: '拍摄负载',
  79. dataIndex: 'payload',
  80. width: 150,
  81. ellipsis: true,
  82. },
  83. {
  84. title: '创建时间',
  85. dataIndex: 'create_time',
  86. width: 200,
  87. sorter: (a: any, b: any) => a.create_time.localeCompare(b.create_time),
  88. },
  89. {
  90. title: '任务类型',
  91. dataIndex: 'template_type',
  92. width: 150,
  93. customRender: ({ text }: any) => {
  94. let content = '--';
  95. switch (text) {
  96. case '0':
  97. content = '航点航线';
  98. break;
  99. case '1':
  100. content = '二维正射';
  101. break;
  102. case '2':
  103. content = '倾斜摄影';
  104. break;
  105. case '3':
  106. content = '带状航线';
  107. break;
  108. default:
  109. break;
  110. }
  111. return content;
  112. }
  113. },
  114. {
  115. title: '创建人',
  116. dataIndex: 'username',
  117. width: 150,
  118. },
  119. {
  120. title: '操作',
  121. dataIndex: 'actions',
  122. fixed: 'right',
  123. align: 'center',
  124. width: 60,
  125. slots: { customRender: 'action' },
  126. },
  127. ]
  128. const rowClassName = (record: any, index: number) => {
  129. const className = []
  130. if ((index & 1) === 0) {
  131. className.push('table-striped')
  132. }
  133. return className.toString().replaceAll(',', ' ')
  134. }
  135. const refreshData = async (page: any) => {
  136. paginationConfig.current = page?.current!
  137. paginationConfig.pageSize = page?.pageSize!
  138. await fetchList();
  139. }
  140. // 点击搜索
  141. const onClickSearch = async (query: any) => {
  142. state.query = query;
  143. await fetchList();
  144. }
  145. // 点击重置
  146. const onClickReset = async (query: any) => {
  147. state.query = query;
  148. await fetchList();
  149. }
  150. // 点击查看轨迹
  151. const onClickLookTrajectory = async (id: string) => {
  152. router.push({ path: '/workspace' });
  153. const res = await apis.fetchTrajectoryMap(id);
  154. const list = res.data.map((item: any) => {
  155. const data = {
  156. ...item,
  157. paths: wgs84togcj02(item.longitude, item.latitude),
  158. }
  159. delete data.latitude;
  160. delete data.longitude;
  161. return data;
  162. });
  163. store.commit('SET_TRAJECTORY_LIST', list)
  164. }
  165. </script>
  166. <style lang="scss">
  167. .trajectory {
  168. padding: 20px;
  169. }
  170. .ant-table {
  171. border-top: 1px solid rgb(0, 0, 0, 0.06);
  172. border-bottom: 1px solid rgb(0, 0, 0, 0.06);
  173. }
  174. .ant-table-tbody tr td {
  175. border: 0;
  176. }
  177. .table-striped {
  178. background-color: #f7f9fa;
  179. }
  180. </style>