|
|
@ -30,6 +30,17 @@ export default function MeasureSave() { |
|
|
|
return year + (month < 10 ? "0" + month : month) + (day < 10 ? "0" + day : day); // 格式化日期为YYYY-MM-DD格式
|
|
|
|
} |
|
|
|
|
|
|
|
const isToday = (date:string) => { |
|
|
|
const currentDate = new Date(); // 获取当前时间
|
|
|
|
const targetDate = new Date(date); // 获取当前时间
|
|
|
|
|
|
|
|
return ( |
|
|
|
currentDate.getFullYear() === targetDate.getFullYear() && |
|
|
|
currentDate.getMonth() === targetDate.getMonth() && |
|
|
|
currentDate.getDate() === targetDate.getDate() |
|
|
|
) |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const loadData = useCallback(() => { |
|
|
|
Bridge.getRecordList({ pageNum: 1, size: 1 }).then((res) => { |
|
|
@ -37,8 +48,9 @@ export default function MeasureSave() { |
|
|
|
if (res.success && res.data.list.length) { |
|
|
|
console.log('res', res) |
|
|
|
const data = res.data.list[0]?.records?.[0] |
|
|
|
console.log(222, isToday(res.data.list[0]?.date)) |
|
|
|
console.log(data) |
|
|
|
let num = data?.todayNumber || 0 |
|
|
|
let num = isToday(res.data.list[0]?.date) ? data?.todayNumber : 0 |
|
|
|
setName(`${tlj}-${gwd}-${xm}-${getDate()}${(Number(num) + 1).toString().padStart(4, '0') }`) |
|
|
|
setBatch(data?.batch) |
|
|
|
setMile(data?.mileage?.split('+')?.[0]) |
|
|
|