Search.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. <template>
  2. <a-row style="margin-bottom: 20px;" justify="space-between">
  3. <a-col>
  4. <a-button style="margin-right: 10px;" type="primary" :disabled="!selectedRowKeys.length" @click="onClickDownload"
  5. v-if="mode === 'table'">
  6. 压缩下载
  7. </a-button>
  8. <a-upload :action="uploadUrl" method="POST" :headers="getHeaders()" accept=".rar,.zip" :multiple="false"
  9. :showUploadList="false" @change="handleChangeUploadFile" v-if="true">
  10. <a-button type="primary">
  11. 上传
  12. </a-button>
  13. </a-upload>
  14. </a-col>
  15. <a-col>
  16. <a-form ref="formRef" layout="inline" :model="formModel" :colon="false">
  17. <a-form-item name="rangeDate">
  18. <a-range-picker style="width: 250px;" v-model:value="formModel.rangeDate" />
  19. </a-form-item>
  20. <a-form-item name="template_type">
  21. <a-select style="width: 200px;" placeholder="任务类型" v-model:value="formModel.template_type">
  22. <a-select-option value="waypoint">
  23. 航点航线
  24. </a-select-option>
  25. <a-select-option value="mapping2d">
  26. 二维正射
  27. </a-select-option>
  28. <a-select-option value="mapping3d">
  29. 倾斜摄影
  30. </a-select-option>
  31. <a-select-option value="mappingStrip">
  32. 带状航线
  33. </a-select-option>
  34. </a-select>
  35. </a-form-item>
  36. <a-form-item name="payload">
  37. <a-select style="width: 200px;" placeholder="拍摄负载" v-model:value="formModel.payload">
  38. <a-select-option v-for="item in state.payloadList" :value="item.value">
  39. {{ item.label }}
  40. </a-select-option>
  41. </a-select>
  42. </a-form-item>
  43. <a-form-item name="search_info">
  44. <a-input style="width: 200px;" placeholder="文件夹名称" v-model:value="formModel.search_info" />
  45. </a-form-item>
  46. <a-form-item>
  47. <a-button style="margin-right: 10px;" @click="handleClickSearch">
  48. <template #icon>
  49. <SearchOutlined />
  50. </template>
  51. </a-button>
  52. <a-button @click="handleClickReset">
  53. <template #icon>
  54. <ReloadOutlined />
  55. </template>
  56. </a-button>
  57. </a-form-item>
  58. </a-form>
  59. </a-col>
  60. </a-row>
  61. </template>
  62. <script lang="ts" setup>
  63. import { ref, reactive, onMounted } from 'vue';
  64. import { message } from 'ant-design-vue'
  65. import { SearchOutlined, ReloadOutlined } from '@ant-design/icons-vue';
  66. import { apis } from '/@/api/custom';
  67. import { getWorkspaceId } from '/@/utils';
  68. import moment from 'moment';
  69. import { ELocalStorageKey } from '/@/types'
  70. interface Props {
  71. fetchList: () => Promise<any>,
  72. mode: 'table' | 'list',
  73. selectedRowKeys: string[],
  74. onClickDownload: () => Promise<any>,
  75. onClickSearch: (query: any) => Promise<any>,
  76. onClickReset: (query: any) => Promise<any>,
  77. };
  78. const props = withDefaults(defineProps<Props>(), {
  79. });
  80. const formRef = ref();
  81. const formModel = reactive({
  82. rangeDate: [],
  83. template_type: undefined,
  84. payload: undefined,
  85. search_info: undefined,
  86. })
  87. interface State {
  88. payloadList: {
  89. value: string,
  90. label: string,
  91. }[],
  92. };
  93. const state: State = reactive({
  94. payloadList: [],
  95. })
  96. const uploadUrl = `/api/media/api/v1/files/${getWorkspaceId()}/file/zip/upload`;
  97. const getHeaders = () => {
  98. const token = localStorage.getItem(ELocalStorageKey.Token);
  99. return {
  100. [ELocalStorageKey.Token]: token,
  101. }
  102. }
  103. onMounted(async () => {
  104. try {
  105. const res = await apis.fetchPayloadList();
  106. const list = res.data.map((item: any) => {
  107. return {
  108. value: item.payload_name,
  109. label: item.payload_name,
  110. }
  111. })
  112. state.payloadList = list;
  113. } catch (e) {
  114. console.error(e);
  115. }
  116. })
  117. // 上传合成文件
  118. const handleChangeUploadFile = async (info: any) => {
  119. if (info.file.status === 'done') {// 上传成功
  120. await props.fetchList()
  121. message.success('上传成功');
  122. } else if (info.file.status === 'error') {// 上传失败
  123. message.error('上传失败');
  124. }
  125. }
  126. // 点击查询
  127. const handleClickSearch = async () => {
  128. const values = formRef.value?.getFieldsValue();
  129. const data = {
  130. ...values,
  131. };
  132. delete data.rangeDate;
  133. if (values.rangeDate?.length === 2) {
  134. data.begin_time = moment(values.rangeDate[0]).valueOf();
  135. data.end_time = moment(values.rangeDate[1]).valueOf();
  136. }
  137. await props.onClickSearch(data);
  138. }
  139. // 点击重置
  140. const handleClickReset = async () => {
  141. formRef.value?.resetFields();
  142. const values = formRef.value?.getFieldsValue();
  143. const data = {
  144. ...values,
  145. };
  146. delete data.rangeDate;
  147. await props.onClickReset(data);
  148. }
  149. </script>
  150. <style lang="scss" scoped></style>