index.vue 4.4 KB

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