page-search.vue 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <!-- 搜索表单 -->
  2. <template>
  3. <ele-card :body-style="{ paddingBottom: '8px' }">
  4. <ProSearch
  5. :items="formItems"
  6. ref="searchRef"
  7. @search="search"
  8. :offset="1"
  9. />
  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 godownList = ref([]);
  18. const formItems = computed(() => {
  19. return [
  20. {
  21. type: 'daterange',
  22. label: '日期',
  23. prop: 'time',
  24. props: {
  25. format: 'YYYY-MM-DD',
  26. valueFormat: 'YYYY-MM-DD',
  27. onChange: (value) => {
  28. searchRef.value?.setData({
  29. statisticDateStart: value ? value[0] : '',
  30. statisticDateEnd: value ? value[1] : ''
  31. });
  32. }
  33. },
  34. colProps: {
  35. span: 6
  36. }
  37. },
  38. {
  39. type: 'select',
  40. label: '仓库名称',
  41. prop: 'godownId',
  42. options: godownList.value.map((d) => {
  43. return { label: d.godownName, value: d.id };
  44. }),
  45. props: {
  46. placeholder: '请选择或输入搜索',
  47. filterable: true
  48. }
  49. }
  50. ];
  51. });
  52. const initKeys = reactive({
  53. statisticDateStart: '',
  54. statisticDateEnd: '',
  55. godownId: ''
  56. });
  57. function getStoreList(name = '') {
  58. return proxy.$http.post(`/baseinfo/godown/searchGodown?name=${name}`);
  59. }
  60. getStoreList().then((res) => {
  61. godownList.value = res.data.data;
  62. });
  63. const searchRef = ref(null);
  64. /** 搜索 */
  65. const search = (data) => {
  66. emit('search', { ...data });
  67. };
  68. </script>