page-search.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <!-- 搜索表单 -->
  2. <template>
  3. <ele-card :body-style="{ paddingBottom: '8px' }">
  4. <ProSearch
  5. :items="formItems"
  6. ref="searchRef"
  7. @search="search"
  8. :initKeys="initKeys"
  9. ></ProSearch>
  10. </ele-card>
  11. </template>
  12. <script setup>
  13. import { reactive, ref, defineEmits, defineProps, computed, getCurrentInstance } from 'vue';
  14. import ProSearch from '@/components/CommonPage/ProSearch2.vue';
  15. defineOptions({ name: 'page-search' });
  16. const props = defineProps({
  17. status: {
  18. type: String,
  19. default: ''
  20. }
  21. });
  22. const emit = defineEmits(['search']);
  23. const searchRef = ref(null);
  24. // 初始值
  25. const initKeys = reactive({
  26. isbn: '',
  27. processor: '',
  28. isPush: '',
  29. pushStatus: props.status,
  30. createTimeRange: [],
  31. pushTimeRange: []
  32. });
  33. // 表单项定义
  34. const formItems = computed(() => {
  35. return [
  36. {
  37. type: 'input',
  38. label: 'ISBN',
  39. prop: 'isbn'
  40. },
  41. {
  42. type: 'input',
  43. label: '处理人',
  44. prop: 'processor'
  45. },
  46. {
  47. type: 'select',
  48. label: '是否推送',
  49. prop: 'isPush',
  50. options: [
  51. { label: '是', value: '是' },
  52. { label: '否', value: '否' }
  53. ]
  54. },
  55. {
  56. type: 'select',
  57. label: '推送状态',
  58. prop: 'pushStatus',
  59. options: [
  60. { label: '成功', value: '成功' },
  61. { label: '失败', value: '失败' },
  62. { label: '系统错误', value: '系统错误' },
  63. { label: '无数据', value: '无数据' }
  64. ]
  65. },
  66. {
  67. type: 'daterange',
  68. label: '创建时间',
  69. prop: 'createTimeRange',
  70. props: {
  71. valueFormat: 'YYYY-MM-DD HH:mm:ss',
  72. rangeSeparator: '到',
  73. startPlaceholder: '开始日期',
  74. endPlaceholder: '结束日期'
  75. }
  76. },
  77. {
  78. type: 'daterange',
  79. label: '推送时间',
  80. prop: 'pushTimeRange',
  81. props: {
  82. valueFormat: 'YYYY-MM-DD HH:mm:ss',
  83. rangeSeparator: '到',
  84. startPlaceholder: '开始日期',
  85. endPlaceholder: '结束日期'
  86. }
  87. }
  88. ];
  89. });
  90. // 搜索
  91. const search = (data) => {
  92. const params = { ...data };
  93. // 处理时间范围
  94. if (params.createTimeRange && params.createTimeRange.length) {
  95. params.createTimeStart = params.createTimeRange[0];
  96. params.createTimeEnd = params.createTimeRange[1];
  97. delete params.createTimeRange;
  98. }
  99. if (params.pushTimeRange && params.pushTimeRange.length) {
  100. params.pushTimeStart = params.pushTimeRange[0];
  101. params.pushTimeEnd = params.pushTimeRange[1];
  102. delete params.pushTimeRange;
  103. }
  104. emit('search', params);
  105. };
  106. </script>