book-search.vue 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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 formItems = reactive([
  18. { type: 'input', label: '书名', prop: 'bookName' },
  19. { type: 'input', label: 'ISBN', prop: 'isbn' },
  20. { type: 'input', label: '作者', prop: 'author' },
  21. { type: 'input', label: '出版社', prop: 'publish' },
  22. {
  23. type: 'daterange',
  24. label: '出版时间',
  25. prop: 'pubDate',
  26. keys: ['pubDateStart', 'pubDateEnd'],
  27. props: { format: 'YYYY-MM-DD', valueFormat: 'YYYY-MM-DD' }
  28. },
  29. {
  30. type: 'inputNumberRange',
  31. label: '定价',
  32. prop: 'price',
  33. keys: ['minPrice', 'maxPrice'],
  34. props: {
  35. onChange: (val) => {
  36. searchRef.value?.setData({ minPrice: val.min, maxPrice: val.max });
  37. }
  38. }
  39. },
  40. {
  41. type: 'inputNumberRange',
  42. label: '回收折扣',
  43. prop: 'discount',
  44. keys: ['minDiscount', 'maxDiscount'],
  45. props: {
  46. minAttrs: { min: 0 },
  47. maxAttrs: { max: 1 },
  48. onChange: (val) => {
  49. searchRef.value?.setData({ minDiscount: val.min, maxDiscount: val.max });
  50. }
  51. }
  52. },
  53. ]);
  54. const initKeys = reactive({
  55. bookName: '',
  56. isbn: '',
  57. author: '',
  58. publish: '',
  59. pubDateStart: '',
  60. pubDateEnd: '',
  61. minPrice: void 0,
  62. maxPrice: void 0,
  63. minDiscount: void 0,
  64. maxDiscount: void 0,
  65. searchType: 0,
  66. globalInDiscount: void 0,
  67. globalNotInDiscount: void 0
  68. });
  69. const searchRef = ref(null);
  70. /** 搜索 */
  71. const search = (data) => {
  72. let params = JSON.parse(JSON.stringify(data));
  73. delete params.price;
  74. delete params.discount;
  75. delete params.pubDate;
  76. emit('search', params);
  77. };
  78. </script>