page-search.vue 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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 } from 'vue';
  14. import ProSearch from '@/components/CommonPage/ProSearch2.vue';
  15. let { proxy } = getCurrentInstance();
  16. const emit = defineEmits(['search']);
  17. const props = defineProps({
  18. status: {
  19. type: String,
  20. default: ''
  21. }
  22. });
  23. const formItems = reactive([
  24. { type: 'input', label: '用户名', prop: 'nickName' },
  25. {
  26. type: 'dictSelect',
  27. label: '状态',
  28. prop: 'status',
  29. props: { code: 'withdrawal_status' }
  30. },
  31. {
  32. type: 'daterange',
  33. label: '时间',
  34. prop: 'timeRange',
  35. props: {
  36. valueFormat: 'YYYY-MM-DD',
  37. format: 'YYYY-MM-DD',
  38. startPlaceholder: '开始日期',
  39. endPlaceholder: '结束日期',
  40. onChange: (value) => {
  41. initKeys.startTime = value ? value[0] : '';
  42. initKeys.endTime = value ? value[1] : '';
  43. searchRef.value?.setData(initKeys);
  44. }
  45. }
  46. }
  47. ]);
  48. const initKeys = reactive({
  49. startTime: '',
  50. endTime: '',
  51. nickName: '',
  52. status: ''
  53. });
  54. // watch(
  55. // () => props.status,
  56. // (newVal) => {
  57. // initKeys.status = newVal;
  58. // searchRef.value?.setData(initKeys);
  59. // }
  60. // );
  61. const searchRef = ref(null);
  62. /** 搜索 */
  63. const search = (data) => {
  64. emit('search', { ...data });
  65. };
  66. </script>