|
|
@ -22,17 +22,17 @@ export default function MeasureSave() { |
|
|
|
const getDate = () => { |
|
|
|
const currentDate = new Date(); // 获取当前时间
|
|
|
|
|
|
|
|
const year = currentDate.getFullYear(); // 获取完整的年份
|
|
|
|
const month = currentDate.getMonth() + 1; // 获取月份(0-11),需要加1
|
|
|
|
const day = currentDate.getDate(); // 获取日
|
|
|
|
const year = currentDate.getFullYear(); |
|
|
|
const month = currentDate.getMonth() + 1; |
|
|
|
const day = currentDate.getDate(); |
|
|
|
|
|
|
|
// @ts-ignore
|
|
|
|
return year + (month < 10 ? "0" + month : month) + (day < 10 ? "0" + day : day); // 格式化日期为YYYY-MM-DD格式
|
|
|
|
return year + (month < 10 ? "0" + month : month) + (day < 10 ? "0" + day : day); |
|
|
|
} |
|
|
|
|
|
|
|
const isToday = (date:string) => { |
|
|
|
const currentDate = new Date(); // 获取当前时间
|
|
|
|
const targetDate = new Date(date); // 获取当前时间
|
|
|
|
const targetDate = new Date(date); |
|
|
|
|
|
|
|
return ( |
|
|
|
currentDate.getFullYear() === targetDate.getFullYear() && |
|
|
@ -43,13 +43,11 @@ export default function MeasureSave() { |
|
|
|
|
|
|
|
|
|
|
|
const loadData = useCallback(() => { |
|
|
|
const [tlj, gwd, xm] = orgTextArr; |
|
|
|
Bridge.getRecordList({ pageNum: 1, size: 1 }).then((res) => { |
|
|
|
const [tlj, gwd, xm] = orgTextArr; |
|
|
|
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 = isToday(res.data.list[0]?.date) ? data?.todayNumber : 0 |
|
|
|
setName(`${tlj}-${gwd}-${xm}-${getDate()}${(Number(num) + 1).toString().padStart(4, '0') }`) |
|
|
|
setBatch(data?.batch) |
|
|
@ -63,6 +61,8 @@ export default function MeasureSave() { |
|
|
|
setSleeperNum(Number(data?.sleeperNum || 1)) |
|
|
|
setStationCode([data?.stationCode]) |
|
|
|
document.getElementById('name-id')?.focus() |
|
|
|
}else { |
|
|
|
setName(`${tlj}-${gwd}-${xm}-${getDate()}${(1).toString().padStart(4, '0') }`) |
|
|
|
} |
|
|
|
}); |
|
|
|
}, []); |
|
|
|