book-search.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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. const props = defineProps({
  16. isBookTag: {
  17. type: Boolean,
  18. default: false
  19. }
  20. });
  21. let { proxy } = getCurrentInstance();
  22. const emit = defineEmits(['search']);
  23. const formItems = reactive([
  24. { type: 'input', label: '书名', prop: 'bookName' },
  25. { type: 'input', label: 'ISBN', prop: 'isbn' },
  26. { type: 'input', label: '作者', prop: 'author' },
  27. { type: 'input', label: '出版社', prop: 'publish' },
  28. {
  29. type: 'daterange',
  30. label: '出版时间',
  31. prop: 'pubDate',
  32. keys: ['pubDateStart', 'pubDateEnd'],
  33. props: {
  34. format: 'YYYY-MM-DD',
  35. valueFormat: 'YYYY-MM-DD',
  36. onChange: (val) => {
  37. searchRef.value?.setData({
  38. pubDateStart: val && val.length > 0 ? val[0] : '',
  39. pubDateEnd: val && val.length > 0 ? val[1] : ''
  40. });
  41. }
  42. }
  43. },
  44. {
  45. type: 'inputNumberRange',
  46. label: '定价',
  47. prop: 'price',
  48. keys: ['minPrice', 'maxPrice'],
  49. props: {
  50. onChange: (val) => {
  51. searchRef.value?.setData({ minPrice: val.min, maxPrice: val.max });
  52. }
  53. }
  54. },
  55. {
  56. type: 'inputNumberRange',
  57. label: '回收折扣',
  58. prop: 'discount',
  59. keys: ['minDiscount', 'maxDiscount'],
  60. props: {
  61. minAttrs: { min: 0 },
  62. maxAttrs: { max: 10 },
  63. onChange: (val) => {
  64. searchRef.value?.setData({
  65. minDiscount: val.min,
  66. maxDiscount: val.max
  67. });
  68. }
  69. }
  70. },
  71. {
  72. type: 'dictSelect',
  73. label: '图书类型',
  74. prop: 'bookTag',
  75. props: {
  76. code: 'book_tag'
  77. },
  78. vIf: () => {
  79. return props.isBookTag;
  80. }
  81. // 1教材 2社科 3中小学 4其他 5全部
  82. },
  83. {
  84. type: 'select',
  85. label: '默认参数',
  86. prop: 'defaultType',
  87. props: {
  88. multiple: true,
  89. clearable: true,
  90. collapseTags: true
  91. },
  92. options: [
  93. { label: '最大回收数量', value: 1 },
  94. { label: '单个订单回收数量', value: 2 },
  95. { label: '回收折扣', value: 3 }
  96. ]
  97. }
  98. ]);
  99. const initKeys = reactive({
  100. bookName: '',
  101. isbn: '',
  102. author: '',
  103. publish: '',
  104. pubDateStart: '',
  105. pubDateEnd: '',
  106. minPrice: void 0,
  107. maxPrice: void 0,
  108. minDiscount: void 0,
  109. maxDiscount: void 0,
  110. globalInDiscount: void 0,
  111. globalNotInDiscount: void 0,
  112. defaultType: []
  113. });
  114. const searchRef = ref(null);
  115. /** 搜索 */
  116. const search = (data) => {
  117. let params = JSON.parse(JSON.stringify(data));
  118. delete params.price;
  119. delete params.discount;
  120. delete params.pubDate;
  121. params.defaultType = params.defaultType.join(',');
  122. emit('search', params);
  123. };
  124. </script>