Browse Source

fix:保存规则变更

master
guoapeng 2 months ago
parent
commit
21929906b2
  1. 3
      src/pages/Measure.tsx
  2. 16
      src/pages/MeasureSave.tsx
  3. 1
      src/pages/Setting.tsx

3
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<MeasurementCanvasRef>(null);
@ -170,7 +169,7 @@ export default function Measure() {
return () => {
dispatch(updateMeasureStatus(''))
}
}, [])
}, [dispatch])
const onSaveClick = () => {
if (!contextState.currOrgCode) {

16
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') }`)
}
});
}, []);

1
src/pages/Setting.tsx

@ -12,7 +12,6 @@ export default function Setting() {
const context = useAppSelector((state) => state.context);
const addrInput = useRef<HTMLInputElement>(null);
const suffixInput = useRef<HTMLInputElement>(null);
const [standbyPickerVisible, setStandbyPickerVisible] = useState(false);
const [checked, setChecked] = useState(false)
const [selectStandby, setSelectStandby] = useState<number[]>([context.setting.standbyMinutes]);

Loading…
Cancel
Save