16 changed files with 327 additions and 208 deletions
-
2.env
-
BINbuild.zip
-
2package.json
-
31src/App.tsx
-
84src/components/Header.tsx
-
61src/components/syncData.tsx
-
18src/pages/measure/components/Detail.tsx
-
103src/pages/measure/components/MeasureAction.tsx
-
69src/pages/measure/components/MeasureDetail.tsx
-
102src/pages/measure/components/konva/MeasurementCanvas.tsx
-
15src/services/measure/analysis.ts
-
1src/services/measure/type.ts
-
13src/services/wsTypes.ts
-
4src/store/index.ts
-
8src/store/ktj/orgState.ts
-
22src/store/measure/measureState.ts
@ -1 +1 @@ |
|||||
REACT_APP_WS_URL=127.0.0.1:8080/ws |
|
||||
|
REACT_APP_WS_URL=192.168.1.146:8080/ws |
@ -1,60 +1,31 @@ |
|||||
import { useState, useEffect } from "react"; |
import { useState, useEffect } from "react"; |
||||
import { Progress } from "antd"; |
|
||||
|
import { message, Progress } from "antd"; |
||||
|
import { useAppDispatch, useAppSelector } from "../utils/hooks"; |
||||
import "./sync.scss"; |
import "./sync.scss"; |
||||
import { update } from "../services/ktj/org"; |
|
||||
export default function SyncData(props:{isShowModal:boolean, closeModal:Function}) { |
|
||||
//同步科天健基础数据
|
|
||||
const onSyncKTJData = () => { |
|
||||
update().then(res => { |
|
||||
setPercent(100) |
|
||||
props.closeModal() |
|
||||
setTimeout(() => { |
|
||||
setPercent(0) |
|
||||
}, 2000); |
|
||||
}) |
|
||||
} |
|
||||
|
|
||||
useEffect(()=>{ |
|
||||
onSyncKTJData() |
|
||||
}, [props.isShowModal]) |
|
||||
|
|
||||
|
export default function SyncData(props:{isShowModal:boolean, closeModal:Function, setIsSync:Function}) { |
||||
const [percent, setPercent] = useState(0) |
const [percent, setPercent] = useState(0) |
||||
useEffect(() => { |
|
||||
const intervalId = setInterval(() => { |
|
||||
if (percent < 100) { |
|
||||
const randomIncrement = Math.floor(Math.random() * 3) + 1; |
|
||||
const newProgress = Math.min(percent + randomIncrement, 100); |
|
||||
setPercent(newProgress); |
|
||||
} else { |
|
||||
clearInterval(intervalId); |
|
||||
} |
|
||||
}, 1000); |
|
||||
if(percent >= 90){ |
|
||||
clearInterval(intervalId); |
|
||||
|
const syncDataProcess = useAppSelector(store => store.orgState.syncDataProcess); |
||||
|
useEffect(()=>{ |
||||
|
setPercent(syncDataProcess) |
||||
|
if(syncDataProcess === 100){ |
||||
|
props.closeModal(); |
||||
|
props.setIsSync(false) |
||||
} |
} |
||||
return () => { |
|
||||
clearInterval(intervalId); |
|
||||
}; |
|
||||
}, [props.isShowModal,percent]); |
|
||||
|
},[syncDataProcess]) |
||||
|
|
||||
const styleObj:any = { |
const styleObj:any = { |
||||
position: "absolute", |
position: "absolute", |
||||
marginTop: "-200px", |
marginTop: "-200px", |
||||
color: "#0051b9", |
|
||||
|
color: "#1677ff", |
||||
fontSize: "20px" |
fontSize: "20px" |
||||
} |
} |
||||
|
|
||||
return ( |
return ( |
||||
<> |
|
||||
|
|
||||
<div |
|
||||
className="fixed inset-0 bg-red opacity-50 z-50 cursor-pointer flex justify-center items-center" style={{background:"#202020"}} |
|
||||
> |
|
||||
<div style={styleObj}>正在进行数据同步</div> |
|
||||
<div className="flex w-[60vw] justify-center items-center margin-auto"> |
|
||||
<Progress type="circle" format={(percent) => <span style={{ color: '#0051b9' }}>{percent}%</span>} percent={percent}/> |
|
||||
</div> |
|
||||
|
<div className="fixed inset-0 bg-red opacity-50 z-50 cursor-pointer flex justify-center items-center" style={{background:"#202020"}} > |
||||
|
<div style={styleObj}>正在进行数据同步</div> |
||||
|
<div className="flex w-[60vw] justify-center items-center margin-auto"> |
||||
|
<Progress type="circle" format={(percent) => <span style={{ color: '#1677ff' }}>{percent}%</span>} percent={percent}/> |
||||
</div> |
</div> |
||||
</> |
|
||||
|
</div> |
||||
); |
); |
||||
} |
} |
@ -0,0 +1,22 @@ |
|||||
|
import { createSlice } from "@reduxjs/toolkit"; |
||||
|
|
||||
|
const initialState = { |
||||
|
gxCode:'' |
||||
|
} |
||||
|
|
||||
|
// 创建一个 Slice
|
||||
|
export const measureStateSlice = createSlice({ |
||||
|
name: "measureState", |
||||
|
initialState, |
||||
|
// 定义 reducers 并生成关联的操作
|
||||
|
reducers: { |
||||
|
// 更新轨型
|
||||
|
updateGxState: (state, { payload }) => { |
||||
|
state.gxCode = payload.gxCode || "GX-60"; |
||||
|
}, |
||||
|
}, |
||||
|
}); |
||||
|
export const { updateGxState } = measureStateSlice.actions; |
||||
|
|
||||
|
// 默认导出
|
||||
|
export default measureStateSlice.reducer; |
Write
Preview
Loading…
Cancel
Save
Reference in new issue