Search.vue 3.5 KB

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