diff --git a/src/pages/Measure.tsx b/src/pages/Measure.tsx index d826838..e67de96 100644 --- a/src/pages/Measure.tsx +++ b/src/pages/Measure.tsx @@ -36,7 +36,6 @@ export default function Measure() { const measureState = useAppSelector((state) => state.measure); const contextState = useAppSelector((state) => state.context); const baseState = useAppSelector((state) => state.baseData); - const device = useAppSelector((state) => state.context.device); const [railPickerVisible, setRailPickerVisible] = useState(false); const [railId, setRailId] = useState<(number | string | null)[]>([]); const canvasRef = useRef(null); @@ -170,7 +169,7 @@ export default function Measure() { return () => { dispatch(updateMeasureStatus('')) } - }, []) + }, [dispatch]) const onSaveClick = () => { if (!contextState.currOrgCode) { diff --git a/src/pages/MeasureSave.tsx b/src/pages/MeasureSave.tsx index 7b61fb1..63d20df 100644 --- a/src/pages/MeasureSave.tsx +++ b/src/pages/MeasureSave.tsx @@ -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') }`) } }); }, []); diff --git a/src/pages/Setting.tsx b/src/pages/Setting.tsx index 7d33f4b..e12cee7 100644 --- a/src/pages/Setting.tsx +++ b/src/pages/Setting.tsx @@ -12,7 +12,6 @@ export default function Setting() { const context = useAppSelector((state) => state.context); const addrInput = useRef(null); - const suffixInput = useRef(null); const [standbyPickerVisible, setStandbyPickerVisible] = useState(false); const [checked, setChecked] = useState(false) const [selectStandby, setSelectStandby] = useState([context.setting.standbyMinutes]);