From a5308e76f8c8db7c05967886d1de085c34606078 Mon Sep 17 00:00:00 2001 From: huangxiang <155373492@qq.com> Date: Thu, 17 Apr 2025 12:29:19 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E5=A2=9E=E5=8A=A0=E6=9C=8D=E5=8A=A1?= =?UTF-8?q?=E5=99=A8=E4=B8=8A=E4=BC=A0=E5=9C=B0=E5=9D=80=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env | 2 +- .gitignore | 3 ++ package-lock.json | 4 +- package.json | 2 +- src/App.tsx | 10 +++- src/pages/system/Setting.tsx | 108 +++++++++++++++++++++++----------------- src/store/system/systemSlice.ts | 15 ++++-- 7 files changed, 90 insertions(+), 54 deletions(-) diff --git a/.env b/.env index 7a40b39..5e3f72f 100644 --- a/.env +++ b/.env @@ -1 +1 @@ -REACT_APP_WS_URL=192.168.1.146:8080/ws +REACT_APP_WS_URL=192.168.1.102:8080/ws diff --git a/.gitignore b/.gitignore index 4d29575..3bf9933 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,6 @@ npm-debug.log* yarn-debug.log* yarn-error.log* + +.idea +package-lock.json diff --git a/package-lock.json b/package-lock.json index 60c600a..ec2b1fe 100644 --- a/package-lock.json +++ b/package-lock.json @@ -48,6 +48,7 @@ "jest": "^27.4.3", "jest-resolve": "^27.4.2", "jest-watch-typeahead": "^1.0.0", + "konva": "^8.3.5", "mini-css-extract-plugin": "^2.4.5", "postcss-flexbugs-fixes": "^5.0.2", "postcss-loader": "^6.2.1", @@ -12277,8 +12278,7 @@ "url": "https://github.com/sponsors/lavrton" } ], - "license": "MIT", - "peer": true + "license": "MIT" }, "node_modules/language-subtag-registry": { "version": "0.3.23", diff --git a/package.json b/package.json index 1322ac4..647a4f6 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "outline", "version": "0.1.0", "private": true, - "proxy": "http://192.168.1.146:8080", + "proxy": "http://192.168.1.102:8080", "dependencies": { "@ant-design/icons": "^6.0.0", "@babel/core": "^7.16.0", diff --git a/src/App.tsx b/src/App.tsx index 4315bf8..cd5cae5 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -15,7 +15,12 @@ import { updateDevice } from "./store/features/contextSlice"; import { getStatus, update } from "./services/ktj/org"; import SyncData from "./components/syncData"; import { sysSet } from "./services/user/system"; -import { updateSystemAccountState, updateSystemAllState, updateSystemOrgState } from "./store/system/systemSlice"; +import { + updateSystemAccountState, + updateSystemAllState, + updateSystemOrgState, + updateUploadServerUrlState +} from "./store/system/systemSlice"; import { system } from "./types"; const { Header, Footer, Sider, Content } = Layout; @@ -103,6 +108,9 @@ function App() { if(item.code === 'UPLOAD_USERNAME'){ dispatch(updateSystemAccountState(item)) } + if(item.code === 'UPLOAD_SERVER_URL'){ + dispatch(updateUploadServerUrlState(item)) + } }) } diff --git a/src/pages/system/Setting.tsx b/src/pages/system/Setting.tsx index 8399b61..d0948b3 100644 --- a/src/pages/system/Setting.tsx +++ b/src/pages/system/Setting.tsx @@ -8,7 +8,11 @@ import { OrgItem } from '../../services/ktjTypes'; import {bleItem, child, GwdItem, orgCascaderType, systemItem} from './types'; import { sysSet } from '../../services/user/system'; import { useAppDispatch, useAppSelector } from "../../utils/hooks"; -import { updateSystemAccountState, updateSystemOrgState } from '../../store/system/systemSlice'; +import { + updateSystemAccountState, + updateSystemOrgState, + updateUploadServerUrlState +} from '../../store/system/systemSlice'; import {createWebSocket, sharedWsUrl} from "../../services/socket"; import {start, stop, disconnect, connect} from "../../services/ble/ble"; @@ -27,6 +31,7 @@ export default function Setting(){ const [systemList, setSystemList] = useState([]) const [accountInfo, setAccountInfo] = useState({}) const [orgInfo, setOrgInfo] = useState({}) + const [uploadServerUrl, setUploadServerUrl] = useState({}) const [orgValues, setOrgValues] = useState([]) const [bleList, setBleList] = useState([]) @@ -84,6 +89,19 @@ export default function Setting(){ useEffect(()=>{ + if(systemState.uploadServerUrl){ + const cloneUploadServerUrl = systemState.uploadServerUrl + let uploadServerUrl:systemItem = { + id: cloneUploadServerUrl.id, + name: cloneUploadServerUrl.name, + code: cloneUploadServerUrl.code, + value: cloneUploadServerUrl.value + } + setUploadServerUrl(uploadServerUrl) + } + }, [systemState.uploadServerUrl]) + + useEffect(()=>{ if(orgInfo && orgInfo.value){ let orgIds:string[] = [] const values:child[] = JSON.parse(orgInfo.value) @@ -146,9 +164,38 @@ export default function Setting(){ }) } + /** + * 上传服务器地址输入框内容变更 + * @param uploadServerUrlValue + */ + function onUploadServerUrlChange(uploadServerUrlValue:string){ + const uploadServerUrlParams = { + code:"UPLOAD_SERVER_URL", + name:uploadServerUrl.name, + value:uploadServerUrlValue, + id:uploadServerUrl.id + } + sysSet(uploadServerUrlParams, "PUT").then(res=>{ + if(res.status === 0){ + dispatch(updateUploadServerUrlState(uploadServerUrlParams)) + message.success("修改成功") + } + }) + } + function onAccountChange(accountValue:string){ - newAccountInfo.name = accountInfo.name || ''; - newAccountInfo.value = accountValue; + const accountParams = { + code:accountInfo.code, + name:accountInfo.name, + value:accountValue, + id:accountInfo.id + } + sysSet(accountParams, "PUT").then(res=>{ + if(res.status === 0){ + dispatch(updateSystemAccountState(accountParams)) + message.success("修改成功") + } + }) } function convertToCascaderData(data:OrgItem[]) { @@ -273,55 +320,24 @@ export default function Setting(){ } }; - const saveSet = (item:systemItem, value:string) => { - const params = { - id:item.id, - value - } - sysSet(params, "PUT").then(res=>{ - }) - - } - - const form = () =>{ - return
- { - systemList.map((item, index) => { - return - {item.code === 'ORG' ? - - : saveSet(item, e.target.value)}/>} - - }) - } -
- } - // @ts-ignore return <>

系统配置

- {form()} - {/*
*/} - {/* 铁路局:*/} - {/*
*/} - {/*
*/} - {/* {accountInfo.name}:*/} - {/* {onAccountChange(e.target.value)}} className='w-[300px]'>*/} - {/* */} - {/*
*/} +
+ 铁路局: +
+
+ {accountInfo.name}: + {onAccountChange(e.target.value)}} className='w-[300px]'> +
+ +
+ {uploadServerUrl.name}: + {onUploadServerUrlChange(e.target.value)}} className='w-[300px]'> +

设备配置

{connectionStatus()} diff --git a/src/store/system/systemSlice.ts b/src/store/system/systemSlice.ts index 6321803..3e7afd0 100644 --- a/src/store/system/systemSlice.ts +++ b/src/store/system/systemSlice.ts @@ -13,7 +13,13 @@ const initialState = { name:'', value:'', code:'' - } + }, + uploadServerUrl: { + id:'', + name:'', + value:'', + code:'' + } }; // 创建一个 Slice export const systemStateSlice = createSlice({ @@ -26,11 +32,14 @@ export const systemStateSlice = createSlice({ updateSystemOrgState: (state, { payload }) => { state.orgInfo = payload }, - updateSystemAccountState: (state, { payload }) => { + updateSystemAccountState: (state, { payload }) => { state.accountInfo = payload }, + updateUploadServerUrlState: (state, { payload }) => { + state.uploadServerUrl = payload + } }, }); -export const {updateSystemAllState, updateSystemOrgState, updateSystemAccountState } = systemStateSlice.actions; +export const {updateSystemAllState, updateSystemOrgState, updateSystemAccountState, updateUploadServerUrlState } = systemStateSlice.actions; // 默认导出 export default systemStateSlice.reducer;