Search.vue 3.4 KB

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