Search.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <template>
  2. <a-row style="margin-bottom: 20px;" justify="space-between">
  3. <a-col>
  4. <a-button type="primary" :disabled="!selectedRowKeys.length" @click="onClickDownload" v-if="mode === 'table'">
  5. 压缩下载
  6. </a-button>
  7. </a-col>
  8. <a-col>
  9. <a-form ref="formRef" layout="inline" :model="formModel" :colon="false">
  10. <a-form-item name="rangeDate">
  11. <a-range-picker style="width: 250px;" v-model:value="formModel.rangeDate" />
  12. </a-form-item>
  13. <a-form-item name="template_type">
  14. <a-select style="width: 200px;" placeholder="任务类型" v-model:value="formModel.template_type">
  15. <a-select-option :value="0">
  16. 航点航线
  17. </a-select-option>
  18. <a-select-option :value="1">
  19. 二维正射
  20. </a-select-option>
  21. <a-select-option :value="2">
  22. 倾斜摄影
  23. </a-select-option>
  24. <a-select-option :value="3">
  25. 带状航线
  26. </a-select-option>
  27. <a-select-option value="">
  28. </a-select-option>
  29. </a-select>
  30. </a-form-item>
  31. <a-form-item name="payload">
  32. <a-select style="width: 200px;" placeholder="拍摄负载" v-model:value="formModel.payload">
  33. <a-select-option v-for="item in state.payloadList" :value="item.value">
  34. {{ item.label }}
  35. </a-select-option>
  36. </a-select>
  37. </a-form-item>
  38. <a-form-item name="search_info">
  39. <a-input style="width: 200px;" placeholder="文件夹名称" v-model:value="formModel.search_info" />
  40. </a-form-item>
  41. <a-form-item>
  42. <a-button style="margin-right: 10px;" @click="handleClicSekarch">
  43. <template #icon>
  44. <SearchOutlined />
  45. </template>
  46. </a-button>
  47. <a-button @click="handleClickReset">
  48. <template #icon>
  49. <ReloadOutlined />
  50. </template>
  51. </a-button>
  52. </a-form-item>
  53. </a-form>
  54. </a-col>
  55. </a-row>
  56. </template>
  57. <script lang="ts" setup>
  58. import { ref, reactive, onMounted } from 'vue';
  59. import { SearchOutlined, ReloadOutlined } from '@ant-design/icons-vue';
  60. import { apis } from '/@/api/custom';
  61. import moment from 'moment';
  62. interface Props {
  63. mode: 'table' | 'list',
  64. selectedRowKeys: string[],
  65. onClickDownload: () => Promise<any>,
  66. onClickSearch: (query: any) => Promise<any>,
  67. onClickReset: (query: any) => Promise<any>,
  68. };
  69. const props = withDefaults(defineProps<Props>(), {
  70. });
  71. const formRef = ref();
  72. const formModel = reactive({
  73. rangeDate: [],
  74. template_type: undefined,
  75. payload: undefined,
  76. search_info: undefined,
  77. })
  78. interface State {
  79. payloadList: {
  80. value: string,
  81. label: string,
  82. }[],
  83. };
  84. const state: State = reactive({
  85. payloadList: [],
  86. })
  87. onMounted(async () => {
  88. try {
  89. const res = await apis.fetchPayloadList();
  90. const list = res.data.map((item: any) => {
  91. return {
  92. value: item.payload_name,
  93. label: item.payload_name,
  94. }
  95. })
  96. state.payloadList = list;
  97. } catch (e) {
  98. console.error(e);
  99. }
  100. })
  101. // 点击查询
  102. const handleClicSekarch = async () => {
  103. const values = formRef.value?.getFieldsValue();
  104. const data = {
  105. ...values,
  106. };
  107. delete data.rangeDate;
  108. if (values.rangeDate.length === 2) {
  109. data.begin_time = moment(values.rangeDate[0]).valueOf();
  110. data.end_time = moment(values.rangeDate[1]).valueOf();
  111. }
  112. await props.onClickSearch(data);
  113. }
  114. // 点击重置
  115. const handleClickReset = async () => {
  116. formRef.value?.resetFields();
  117. const values = formRef.value?.getFieldsValue();
  118. const data = {
  119. ...values,
  120. };
  121. delete data.rangeDate;
  122. await props.onClickReset(data);
  123. }
  124. </script>
  125. <style lang="scss" scoped></style>