| | |
| | | </view> |
| | | <view v-else class="no-data">暂无数据</view> |
| | | </view> |
| | | <up-popup :show="showDatePicker" mode="bottom" @close="showDatePicker = false"> |
| | | <up-datetime-picker |
| | | v-model="dateValue" |
| | | :mode="datePickerMode" |
| | |
| | | @confirm="onDateConfirm" |
| | | @cancel="showDatePicker = false" |
| | | /> |
| | | </up-popup> |
| | | </view> |
| | | </template> |
| | | |
| | |
| | | import { ref, reactive, toRefs, computed, watch } from "vue"; |
| | | import dayjs from "dayjs"; |
| | | import PageHeader from "@/components/PageHeader.vue"; |
| | | import { formatDateToYMD } from "@/utils/ruoyi"; |
| | | import { onShow, onReachBottom } from "@dcloudio/uni-app"; |
| | | import { getConsumablesInReportList, getConsumablesInInAndOutReportList } from "@/api/consumablesLogistics/consumablesIn.js"; |
| | | import { |
| | |
| | | getList(); |
| | | }; |
| | | |
| | | const toPickerTimestamp = (val, target) => { |
| | | if (!val) return Date.now(); |
| | | let parsed; |
| | | if (target === "startMonth" || target === "endMonth") { |
| | | parsed = dayjs(`${val}-01`).valueOf(); |
| | | } else { |
| | | parsed = dayjs(val).valueOf(); |
| | | } |
| | | return Number.isNaN(parsed) ? Date.now() : parsed; |
| | | }; |
| | | |
| | | const formatPickerDate = (value, isMonth) => { |
| | | const parsed = dayjs(value); |
| | | if (!parsed.isValid()) return ""; |
| | | return parsed.format(isMonth ? "YYYY-MM" : "YYYY-MM-DD"); |
| | | }; |
| | | |
| | | const openDatePicker = (target) => { |
| | | datePickerTarget.value = target; |
| | | let val = ""; |
| | |
| | | else if (target === "endMonth") val = searchForm.value.endMonth; |
| | | else if (target === "startDate") val = searchForm.value.startDate; |
| | | else if (target === "endDate") val = searchForm.value.endDate; |
| | | dateValue.value = val ? new Date(val).getTime() : Date.now(); |
| | | dateValue.value = toPickerTimestamp(val, target); |
| | | showDatePicker.value = true; |
| | | }; |
| | | |
| | | const onDateConfirm = (e) => { |
| | | const isMonth = datePickerTarget.value === "startMonth" || datePickerTarget.value === "endMonth"; |
| | | const str = isMonth ? dayjs(e.value).format("YYYY-MM") : formatDateToYMD(e.value); |
| | | const str = formatPickerDate(e.value, isMonth); |
| | | if (!str) { |
| | | showDatePicker.value = false; |
| | | uni.showToast({ title: "日期格式无效", icon: "none" }); |
| | | return; |
| | | } |
| | | if (datePickerTarget.value === "single") { |
| | | searchForm.value.singleDate = str; |
| | | showDatePicker.value = false; |
| | |
| | | searchForm.value.endDate = today.format("YYYY-MM-DD"); |
| | | searchForm.value.startDate = today.subtract(6, "day").format("YYYY-MM-DD"); |
| | | } |
| | | if (!datePickerTarget.value) { |
| | | dateValue.value = toPickerTimestamp(searchForm.value.singleDate, "single"); |
| | | } |
| | | }; |
| | | |
| | | watch( |
| | |
| | | fetchStockRecordTypeOptions(); |
| | | }); |
| | | |
| | | initDefaultDates(); |
| | | |
| | | onReachBottom(() => loadMore()); |
| | | |
| | | const goBack = () => uni.navigateBack(); |