stock-off-search.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <template>
  2. <ele-card :body-style="{ paddingBottom: '8px' }">
  3. <div class="flex items-start">
  4. <div class="flex flex-col gap-[12px]">
  5. <div class="flex items-center gap-2 w-full">
  6. <el-select class="w-[120px] flex-1" v-model="initKeys.timeType" @change="handleTimeTypeChange">
  7. <el-option label="创建时间" :value="1"></el-option>
  8. <el-option label="完成时间" :value="2"></el-option>
  9. </el-select>
  10. <el-radio-group v-model="initKeys.timeRangeType" @change="handleTimeRangeTypeChange">
  11. <el-radio label="今天" :value="1"></el-radio>
  12. <el-radio label="近7天" :value="2"></el-radio>
  13. <el-radio label="近30天" :value="3"></el-radio>
  14. </el-radio-group>
  15. </div>
  16. <el-date-picker format="YYYY-MM-DD HH:mm:ss" value-format="YYYY-MM-DD HH:mm:ss" v-model="timeRange" type="datetimerange" range-separator="至" start-placeholder="开始日期"
  17. @change="handleTimeRangeChange" end-placeholder="结束日期" />
  18. </div>
  19. <ProSearch class="flex-1 ml-8" :items="formItems" ref="searchRef" @search="search" :initKeys="initKeys">
  20. </ProSearch>
  21. </div>
  22. </ele-card>
  23. </template>
  24. <script setup>
  25. import { reactive, ref, defineEmits, getCurrentInstance, computed, onMounted } from 'vue';
  26. import ProSearch from '@/components/CommonPage/ProSearch2.vue';
  27. import dayjs from 'dayjs';
  28. let { proxy } = getCurrentInstance();
  29. const emit = defineEmits(['search']);
  30. const godownList = ref([]);
  31. const searchRef = ref(null);
  32. const initKeys = reactive({
  33. godownId: '',
  34. positionCode: '',
  35. waybillCode: '',
  36. orderId: '',
  37. taskCode: '',
  38. operator: '',
  39. remark: '',
  40. taskStatus: '',
  41. startTime: '',
  42. endTime: '',
  43. timeType: 1,
  44. timeRangeType: 1
  45. });
  46. /** 搜索 */
  47. const search = (data) => {
  48. emit('search', { ...data });
  49. };
  50. const timeRange = ref([]);
  51. const handleTimeRangeChange = (val) => {
  52. timeRange.value = val;
  53. searchRef.value?.setData({
  54. startTime: val?.[0] || '',
  55. endTime: val?.[1] || ''
  56. });
  57. }
  58. const handleTimeTypeChange = (val) => {
  59. initKeys.timeType = val;
  60. searchRef.value?.setData({
  61. timeType: val
  62. });
  63. }
  64. const handleTimeRangeTypeChange = (val) => {
  65. initKeys.timeRangeType = val;
  66. const now = dayjs();
  67. const end = now.endOf('day').format('YYYY-MM-DD HH:mm:ss');
  68. let start;
  69. switch (val) {
  70. case 1: // 今天
  71. start = now.startOf('day').format('YYYY-MM-DD HH:mm:ss');
  72. break;
  73. case 2: // 近7天
  74. start = now.subtract(6, 'day').startOf('day').format('YYYY-MM-DD HH:mm:ss');
  75. break;
  76. case 3: // 近30天
  77. start = now.subtract(29, 'day').startOf('day').format('YYYY-MM-DD HH:mm:ss');
  78. break;
  79. }
  80. initKeys.startTime = start;
  81. initKeys.endTime = end;
  82. timeRange.value = [start, end];
  83. searchRef.value?.setData(initKeys);
  84. search(initKeys);
  85. }
  86. onMounted(() => {
  87. handleTimeRangeTypeChange(1)
  88. })
  89. const formItems = computed(() => {
  90. return [
  91. {
  92. type: 'select',
  93. label: '仓库名称',
  94. prop: 'godownId',
  95. options: godownList.value.map((d) => {
  96. return { label: d.godownName, value: d.id };
  97. }),
  98. props: {
  99. placeholder: '请选择或输入搜索',
  100. filterable: true
  101. },
  102. colProps: {
  103. span: 6
  104. }
  105. },
  106. { type: 'input', label: '下架库位', prop: 'positionCode', colProps: { span: 6 } },
  107. { type: 'input', label: '物流单号', prop: 'waybillCode', colProps: { span: 6 } },
  108. { type: 'input', label: '订单编号', prop: 'orderId', colProps: { span: 6 } },
  109. { type: 'input', label: '作业编号', prop: 'taskCode', colProps: { span: 6 } },
  110. { type: 'input', label: '操作人', prop: 'operator', colProps: { span: 6 } },
  111. { type: 'input', label: '备注', prop: 'remark', colProps: { span: 6 } },
  112. { type: 'dictSelect', label: '作业状态', prop: 'taskStatus', props: { code: 'task_status' }, colProps: { span: 6 } },
  113. ];
  114. });
  115. function getStoreList(name = '') {
  116. return proxy.$http.post(`/baseinfo/godown/searchGodown?name=${name}`);
  117. }
  118. getStoreList().then((res) => {
  119. godownList.value = res.data.data;
  120. });
  121. </script>