Search.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. <template>
  2. <a-row style="margin-bottom: 20px;" justify="space-between">
  3. <a-col>
  4. <div style="display: flex;">
  5. <a-upload :action="uploadUrl" method="POST" :headers="getHeaders()" accept=".png,.jpg,.jpeg" :multiple="false"
  6. :showUploadList="false" @change="handleChangeUploadFile">
  7. <a-button style="margin-right: 10px;" type="primary" @click="onClickDownload">
  8. 上传合成文件
  9. </a-button>
  10. </a-upload>
  11. <a-button style="margin-right: 10px;" type="primary" :disabled="!selectedRowKeys.length"
  12. @click="onClickDownload">
  13. 压缩下载
  14. </a-button>
  15. <a-button type="primary" danger :disabled="!selectedRowKeys.length" @click="onClickDelete">
  16. 删除
  17. </a-button>
  18. </div>
  19. </a-col>
  20. <a-col>
  21. <a-form ref="formRef" layout="inline" :model="formModel" :colon="false">
  22. <a-form-item name="rangeDate">
  23. <a-range-picker style="width: 250px;" v-model:value="formModel.rangeDate" />
  24. </a-form-item>
  25. <a-form-item name="media_type">
  26. <a-select style="width: 200px;" placeholder="请选择媒体类型" v-model:value="formModel.media_type">
  27. <a-select-option :value="1">
  28. 原图
  29. </a-select-option>
  30. <a-select-option :value="2">
  31. 截图
  32. </a-select-option>
  33. <a-select-option :value="3">
  34. 全景图
  35. </a-select-option>
  36. <a-select-option :value="4">
  37. 视频
  38. </a-select-option>
  39. <a-select-option :value="-1">
  40. 其他
  41. </a-select-option>
  42. </a-select>
  43. </a-form-item>
  44. <a-form-item name="search_info">
  45. <a-input style="width: 200px;" placeholder="文件名称" v-model:value="formModel.search_info" />
  46. </a-form-item>
  47. <a-form-item>
  48. <a-button style="margin-right: 10px;" @click="handleClicSekarch">
  49. <template #icon>
  50. <SearchOutlined />
  51. </template>
  52. </a-button>
  53. <a-button @click="handleClickReset">
  54. <template #icon>
  55. <ReloadOutlined />
  56. </template>
  57. </a-button>
  58. </a-form-item>
  59. </a-form>
  60. </a-col>
  61. </a-row>
  62. </template>
  63. <script lang="ts" setup>
  64. import { ref, reactive } from 'vue';
  65. import { message } from 'ant-design-vue'
  66. import { SearchOutlined, ReloadOutlined } from '@ant-design/icons-vue';
  67. import router from '/@/router';
  68. import { ELocalStorageKey } from '/@/types'
  69. import { getWorkspaceId } from '/@/utils/index'
  70. import moment from 'moment';
  71. interface Props {
  72. fetchList: () => Promise<any>,
  73. selectedRowKeys: string[],
  74. onClickDownload: () => Promise<any>,
  75. onClickDelete: () => Promise<any>,
  76. onClickSearch: (query: any) => Promise<any>,
  77. onClickReset: (query: any) => Promise<any>,
  78. };
  79. const props = withDefaults(defineProps<Props>(), {
  80. });
  81. const formRef = ref();
  82. const formModel = reactive({
  83. rangeDate: [],
  84. media_type: undefined,
  85. device_name: undefined,
  86. search_info: '',
  87. })
  88. const state = reactive({
  89. visible: false,
  90. })
  91. const workspaceId: string = getWorkspaceId();
  92. const dirId = router.currentRoute.value.params?.id;
  93. const uploadUrl = `/api/media/api/v1/files/${workspaceId}/file/${dirId}/upload`
  94. const getHeaders = () => {
  95. const token = localStorage.getItem(ELocalStorageKey.Token);
  96. return {
  97. [ELocalStorageKey.Token]: token,
  98. }
  99. }
  100. // 上传合成文件
  101. const handleChangeUploadFile = async (info: any) => {
  102. if (info.file.status === 'done') {// 上传成功
  103. await props.fetchList()
  104. message.success('上传成功');
  105. } else if (info.file.status === 'error') {// 上传失败
  106. message.error('上传失败');
  107. }
  108. }
  109. // 点击查询
  110. const handleClicSekarch = async () => {
  111. const values = formRef.value?.getFieldsValue();
  112. const data = {
  113. ...values,
  114. };
  115. delete data.rangeDate;
  116. if (values.rangeDate.length === 2) {
  117. data.begin_time = moment(values.rangeDate[0]).valueOf();
  118. data.end_time = moment(values.rangeDate[1]).valueOf();
  119. }
  120. await props.onClickSearch(data);
  121. }
  122. // 点击重置
  123. const handleClickReset = async () => {
  124. formRef.value?.resetFields();
  125. const values = formRef.value?.getFieldsValue();
  126. const data = {
  127. ...values,
  128. };
  129. delete data.rangeDate;
  130. await props.onClickReset(data);
  131. }
  132. </script>
  133. <style lang="scss" scoped></style>