page-search.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <!-- 搜索表单 -->
  2. <template>
  3. <ele-card :body-style="{ paddingBottom: '8px' }">
  4. <ProSearch :items="formItems" ref="searchRef" @search="search" :initKeys="initKeys" :offset="1" />
  5. </ele-card>
  6. </template>
  7. <script setup>
  8. import {
  9. reactive,
  10. ref,
  11. defineEmits,
  12. computed,
  13. getCurrentInstance
  14. } from 'vue';
  15. import ProSearch from '@/components/CommonPage/ProSearch2.vue';
  16. let { proxy } = getCurrentInstance();
  17. const emit = defineEmits(['search']);
  18. const godownList = ref([]);
  19. const provinceList = ref([]);
  20. function getProviceList(id = 1) {
  21. return proxy.$http.get(`/baseinfo/districtInfo/findInfo/${id}`);
  22. }
  23. getProviceList().then((res) => {
  24. provinceList.value = res.data.data;
  25. });
  26. const formItems = computed(() => {
  27. return [
  28. {
  29. type: 'select',
  30. label: '省份',
  31. prop: 'provinceId',
  32. options: provinceList.value.map((d) => {
  33. return { label: d.district, value: d.id };
  34. }),
  35. props: {
  36. filterable: true,
  37. multiple: true,
  38. onChange: (value) => {
  39. searchRef.value?.setData({
  40. provinceIdList: value
  41. });
  42. }
  43. }
  44. },
  45. {
  46. type: 'select',
  47. label: '收货仓库',
  48. prop: 'godownId',
  49. options: godownList.value.map((item) => ({
  50. label: item.godownName,
  51. value: item.id
  52. })),
  53. props: {
  54. placeholder: '请选择收货仓库',
  55. clearable: true
  56. }
  57. },
  58. {
  59. type: 'daterange',
  60. label: '统计日期',
  61. prop: 'time',
  62. props: {
  63. format: 'YYYY-MM-DD',
  64. valueFormat: 'YYYY-MM-DD',
  65. onChange: (value) => {
  66. searchRef.value?.setData({
  67. statDateStart: value ? value[0] : '',
  68. statDateEnd: value ? value[1] : ''
  69. });
  70. }
  71. },
  72. colProps: {
  73. span: 6
  74. }
  75. }
  76. ];
  77. });
  78. const initKeys = reactive({
  79. statDateStart: '',
  80. statDateEnd: '',
  81. godownId: '',
  82. provinceIdList: []
  83. });
  84. function getStoreList(name = '') {
  85. return proxy.$http.post(`/baseinfo/godown/searchGodown?name=${name}`);
  86. }
  87. getStoreList().then((res) => {
  88. godownList.value = res.data.data;
  89. });
  90. const searchRef = ref(null);
  91. /** 搜索 */
  92. const search = (data) => {
  93. const searchParams = {
  94. godownId: data.godownId,
  95. statDateStart: data.statDateStart || initKeys.statDateStart,
  96. statDateEnd: data.statDateEnd || initKeys.statDateEnd,
  97. provinceIdList: data.provinceIdList.join(',') || initKeys.provinceIdList.join(',')
  98. };
  99. emit('search', searchParams);
  100. };
  101. </script>