diff --git a/.gitignore b/.gitignore index b6ae733..1823b26 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,6 @@ npm-debug.log* yarn-debug.log* yarn-error.log* *.zip + +.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 e875d3b..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.200: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 0eaa4dc..fe70ad1 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"; import Home from "./home"; @@ -105,6 +110,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 9d4e3d1..8c1a9b1 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, updateSystemAllState, 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([]) @@ -86,6 +91,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) @@ -129,6 +147,59 @@ export default function Setting(){ } } + let newAccountInfo = { + name:'', + value: '' + } + function onSaveAccount(){ + const accountParams = { + code:"UPLOAD_USERNAME", + name:accountInfo.name, + value:newAccountInfo.value, + id:accountInfo.id + } + sysSet(accountParams, "PUT").then(res=>{ + if(res.status === 0){ + dispatch(updateSystemAccountState(accountParams)) + message.success("修改成功") + } + }) + } + + /** + * 上传服务器地址输入框内容变更 + * @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){ + 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[]) { return data.map(item => { const newItem:orgCascaderType = { @@ -251,64 +322,24 @@ export default function Setting(){ } }; - const saveSet = (item:systemItem, value:string) => { - const params = { - id:item.id, - value - } - sysSet(params, "PUT").then(res=>{ - if(res.status === 0){ - const list:systemItem[] = JSON.parse(JSON.stringify(systemList)) - list.forEach(el => { - if(item.id === el.id){ - el.value = value - } - }) - dispatch(updateSystemAllState(list)) - message.success("修改成功") - } - }) - } - - 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;