index.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  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 }" :childrenColumnName="null" 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;margin-right: 10px;" @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. listLoading: boolean,
  29. list: any[],
  30. };
  31. const state: State = reactive({
  32. listLoading: false,
  33. list: [],
  34. });
  35. const paginationConfig = reactive({
  36. pageSizeOptions: ['20', '50', '100'],
  37. showQuickJumper: true,
  38. showSizeChanger: true,
  39. pageSize: 20,
  40. current: 1,
  41. total: 0
  42. })
  43. const fetchList = async (query?: any) => {
  44. state.listLoading = true;
  45. try {
  46. const res = await apis.fetchTrajectoryList({
  47. ...query,
  48. page: paginationConfig.current,
  49. page_size: paginationConfig.pageSize
  50. });
  51. if (res.code === 0) {
  52. paginationConfig.total = res.data.pagination.total
  53. paginationConfig.current = res.data.pagination.page
  54. paginationConfig.pageSize = res.data.pagination.page_size
  55. }
  56. state.list = res.data.list;
  57. } catch (e) {
  58. console.error(e);
  59. } finally {
  60. state.listLoading = false;
  61. }
  62. }
  63. onMounted(async () => {
  64. await fetchList();
  65. })
  66. const columns = [
  67. {
  68. title: '计划名称',
  69. dataIndex: 'task_name',
  70. width: 250,
  71. ellipsis: true,
  72. sorter: (a: any, b: any) => a.task_name.localeCompare(b.task_name),
  73. },
  74. {
  75. title: '拍摄负载',
  76. dataIndex: 'payload',
  77. width: 150,
  78. ellipsis: true,
  79. },
  80. {
  81. title: '创建时间',
  82. dataIndex: 'create_time',
  83. width: 200,
  84. sorter: (a: any, b: any) => a.create_time.localeCompare(b.create_time),
  85. },
  86. {
  87. title: '任务类型',
  88. dataIndex: 'template_type',
  89. width: 150,
  90. customRender: ({ text }: any) => {
  91. let content = '--';
  92. switch (text) {
  93. case '0':
  94. content = '航点航线';
  95. break;
  96. case '1':
  97. content = '二维正射';
  98. break;
  99. case '2':
  100. content = '倾斜摄影';
  101. break;
  102. case '3':
  103. content = '带状航线';
  104. break;
  105. case '4':
  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: 50,
  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. await fetchList(query);
  143. }
  144. // 点击重置
  145. const onClickReset = async (query: any) => {
  146. await fetchList(query);
  147. }
  148. // 点击查看轨迹
  149. const onClickLookTrajectory = async (id: string) => {
  150. router.push({ path: '/workspace' });
  151. const res = await apis.fetchTrajectoryMap(id);
  152. const list = res.data.map((item: any) => {
  153. return wgs84togcj02(item.longitude, item.latitude);
  154. });
  155. store.commit('SET_TRAJECTORY_LIST', list)
  156. }
  157. </script>
  158. <style lang="scss">
  159. .trajectory {
  160. padding: 20px;
  161. }
  162. .ant-table {
  163. border-top: 1px solid rgb(0, 0, 0, 0.06);
  164. border-bottom: 1px solid rgb(0, 0, 0, 0.06);
  165. }
  166. .ant-table-tbody tr td {
  167. border: 0;
  168. }
  169. .table-striped {
  170. background-color: #f7f9fa;
  171. }
  172. </style>