book-search.vue 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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: {
  28. format: 'YYYY-MM-DD',
  29. valueFormat: 'YYYY-MM-DD',
  30. onChange: (val) => {
  31. searchRef.value?.setData({
  32. pubDateStart: val && val.length > 0 ? val[0] : '',
  33. pubDateEnd: val && val.length > 0 ? val[1] : ''
  34. });
  35. }
  36. }
  37. },
  38. {
  39. type: 'inputNumberRange',
  40. label: '定价',
  41. prop: 'price',
  42. keys: ['minPrice', 'maxPrice'],
  43. props: {
  44. onChange: (val) => {
  45. searchRef.value?.setData({ minPrice: val.min, maxPrice: val.max });
  46. }
  47. }
  48. },
  49. {
  50. type: 'inputNumberRange',
  51. label: '回收折扣',
  52. prop: 'discount',
  53. keys: ['minDiscount', 'maxDiscount'],
  54. props: {
  55. minAttrs: { min: 0 },
  56. maxAttrs: { max: 1 },
  57. onChange: (val) => {
  58. searchRef.value?.setData({
  59. minDiscount: val.min,
  60. maxDiscount: val.max
  61. });
  62. }
  63. }
  64. }
  65. ]);
  66. const initKeys = reactive({
  67. bookName: '',
  68. isbn: '',
  69. author: '',
  70. publish: '',
  71. pubDateStart: '',
  72. pubDateEnd: '',
  73. minPrice: void 0,
  74. maxPrice: void 0,
  75. minDiscount: void 0,
  76. maxDiscount: void 0,
  77. searchType: 0,
  78. globalInDiscount: void 0,
  79. globalNotInDiscount: void 0
  80. });
  81. const searchRef = ref(null);
  82. /** 搜索 */
  83. const search = (data) => {
  84. let params = JSON.parse(JSON.stringify(data));
  85. delete params.price;
  86. delete params.discount;
  87. delete params.pubDate;
  88. emit('search', params);
  89. };
  90. </script>