|
@ -8,11 +8,7 @@ import { OrgItem } from '../../services/ktjTypes'; |
|
|
import {bleItem, child, GwdItem, orgCascaderType, systemItem} from './types'; |
|
|
import {bleItem, child, GwdItem, orgCascaderType, systemItem} from './types'; |
|
|
import { sysSet } from '../../services/user/system'; |
|
|
import { sysSet } from '../../services/user/system'; |
|
|
import { useAppDispatch, useAppSelector } from "../../utils/hooks"; |
|
|
import { useAppDispatch, useAppSelector } from "../../utils/hooks"; |
|
|
import { |
|
|
|
|
|
updateSystemAccountState, |
|
|
|
|
|
updateSystemOrgState, |
|
|
|
|
|
updateUploadServerUrlState |
|
|
|
|
|
} from '../../store/system/systemSlice'; |
|
|
|
|
|
|
|
|
import { updateSystemAccountState, updateSystemOrgState } from '../../store/system/systemSlice'; |
|
|
import {createWebSocket, sharedWsUrl} from "../../services/socket"; |
|
|
import {createWebSocket, sharedWsUrl} from "../../services/socket"; |
|
|
import {start, stop, disconnect, connect} from "../../services/ble/ble"; |
|
|
import {start, stop, disconnect, connect} from "../../services/ble/ble"; |
|
|
|
|
|
|
|
@ -31,15 +27,14 @@ export default function Setting(){ |
|
|
const [systemList, setSystemList] = useState<systemItem[]>([]) |
|
|
const [systemList, setSystemList] = useState<systemItem[]>([]) |
|
|
const [accountInfo, setAccountInfo] = useState<systemItem>({}) |
|
|
const [accountInfo, setAccountInfo] = useState<systemItem>({}) |
|
|
const [orgInfo, setOrgInfo] = useState<systemItem>({}) |
|
|
const [orgInfo, setOrgInfo] = useState<systemItem>({}) |
|
|
const [uploadServerUrl, setUploadServerUrl] = useState<systemItem>({}) |
|
|
|
|
|
const [orgValues, setOrgValues] = useState<string[]>([]) |
|
|
const [orgValues, setOrgValues] = useState<string[]>([]) |
|
|
const [bleList, setBleList] = useState<bleItem[]>([]) |
|
|
const [bleList, setBleList] = useState<bleItem[]>([]) |
|
|
|
|
|
|
|
|
// 创建 websocket 客户端
|
|
|
// 创建 websocket 客户端
|
|
|
const wsClient = createWebSocket(sharedWsUrl); |
|
|
const wsClient = createWebSocket(sharedWsUrl); |
|
|
function querySettingData(){ |
|
|
function querySettingData(){ |
|
|
let systemInfo = systemState.systemInfo |
|
|
|
|
|
setSystemList(systemInfo) |
|
|
|
|
|
|
|
|
let systemInfo = systemState.systemInfo |
|
|
|
|
|
setSystemList(systemInfo) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -70,8 +65,6 @@ export default function Setting(){ |
|
|
value: cloneOrgItem.value |
|
|
value: cloneOrgItem.value |
|
|
} |
|
|
} |
|
|
setOrgInfo(orgItem) |
|
|
setOrgInfo(orgItem) |
|
|
let systemInfo = systemState.systemInfo |
|
|
|
|
|
setSystemList(systemInfo) |
|
|
|
|
|
} |
|
|
} |
|
|
}, [systemState.orgInfo]) |
|
|
}, [systemState.orgInfo]) |
|
|
|
|
|
|
|
@ -91,19 +84,6 @@ export default function Setting(){ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(()=>{ |
|
|
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){ |
|
|
if(orgInfo && orgInfo.value){ |
|
|
let orgIds:string[] = [] |
|
|
let orgIds:string[] = [] |
|
|
const values:child[] = JSON.parse(orgInfo.value) |
|
|
const values:child[] = JSON.parse(orgInfo.value) |
|
@ -166,38 +146,9 @@ 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){ |
|
|
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("修改成功") |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
newAccountInfo.name = accountInfo.name || ''; |
|
|
|
|
|
newAccountInfo.value = accountValue; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function convertToCascaderData(data:OrgItem[]) { |
|
|
function convertToCascaderData(data:OrgItem[]) { |
|
@ -214,8 +165,8 @@ export default function Setting(){ |
|
|
}; |
|
|
}; |
|
|
if (gwdItem.railDicList && gwdItem.railDicList.length > 0) { |
|
|
if (gwdItem.railDicList && gwdItem.railDicList.length > 0) { |
|
|
newGwdItem.children = gwdItem.railDicList.map(railItem => ({ |
|
|
newGwdItem.children = gwdItem.railDicList.map(railItem => ({ |
|
|
value: railItem.key, |
|
|
|
|
|
label: railItem.value || railItem.input |
|
|
|
|
|
|
|
|
value: railItem.key, |
|
|
|
|
|
label: railItem.value || railItem.input |
|
|
})); |
|
|
})); |
|
|
} |
|
|
} |
|
|
return newGwdItem; |
|
|
return newGwdItem; |
|
@ -322,29 +273,52 @@ export default function Setting(){ |
|
|
} |
|
|
} |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
const saveSet = (item:systemItem, value:string) => { |
|
|
|
|
|
const params = { |
|
|
|
|
|
id:item.id, |
|
|
|
|
|
value |
|
|
|
|
|
} |
|
|
|
|
|
sysSet(params, "PUT").then(res=>{ |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const form = () =>{ |
|
|
|
|
|
return <Form |
|
|
|
|
|
name="basic" |
|
|
|
|
|
labelCol={{ span: 3, offset: 1 }} |
|
|
|
|
|
wrapperCol={{ span: 16 }} |
|
|
|
|
|
style={{ maxWidth: 600 }} |
|
|
|
|
|
autoComplete="off" |
|
|
|
|
|
> |
|
|
|
|
|
{ |
|
|
|
|
|
systemList.map((item, index) => { |
|
|
|
|
|
return <Form.Item |
|
|
|
|
|
key={index} |
|
|
|
|
|
label={item.name} |
|
|
|
|
|
name={item.code} |
|
|
|
|
|
> |
|
|
|
|
|
{item.code === 'ORG' ? |
|
|
|
|
|
<Cascader className='w-[300px]' key={orgValues.length} defaultValue={orgValues} options={KTJOrgList} onChange={onOrgChange} placeholder="请选择局段线" /> |
|
|
|
|
|
: <Input defaultValue={item.value} onBlur={(e) => saveSet(item, e.target.value)}/>} |
|
|
|
|
|
</Form.Item> |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
</Form> |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// @ts-ignore
|
|
|
// @ts-ignore
|
|
|
return <><div className={'pr-2.5 pl-2.5 w-full h-full'}> |
|
|
return <><div className={'pr-2.5 pl-2.5 w-full h-full'}> |
|
|
<div className={'h-full w-full bg-white p-10 rounded-2xl'}> |
|
|
<div className={'h-full w-full bg-white p-10 rounded-2xl'}> |
|
|
<h1 className='text-[20px]'>系统配置</h1> |
|
|
<h1 className='text-[20px]'>系统配置</h1> |
|
|
<section className='p-[20px]'> |
|
|
<section className='p-[20px]'> |
|
|
<div> |
|
|
|
|
|
<span>铁路局:</span> |
|
|
|
|
|
<Cascader className='w-[300px]' key={orgValues.length} defaultValue={orgValues} options={KTJOrgList} onChange={onOrgChange} placeholder="请选择局段线" /></div> |
|
|
|
|
|
<div className='mt-[10px]'> |
|
|
|
|
|
<span> {accountInfo.name}:</span> |
|
|
|
|
|
<Input key={accountInfo.value} defaultValue={accountInfo.value} onBlur={(e)=>{onAccountChange(e.target.value)}} className='w-[300px]'></Input> |
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
|
|
|
|
<div className='mt-[10px]'> |
|
|
|
|
|
<span> {uploadServerUrl.name}:</span> |
|
|
|
|
|
<Input key={uploadServerUrl.value} defaultValue={uploadServerUrl.value} onBlur={(e)=>{onUploadServerUrlChange(e.target.value)}} className='w-[300px]'></Input> |
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
|
{form()} |
|
|
</section> |
|
|
</section> |
|
|
<h1 className='text-[20px]'>设备配置</h1> |
|
|
<h1 className='text-[20px]'>设备配置</h1> |
|
|
{connectionStatus()} |
|
|
{connectionStatus()} |
|
|
</div> |
|
|
</div> |
|
|
|
|
|
|
|
|
</div> |
|
|
</div> |
|
|
</> |
|
|
|
|
|
|
|
|
</> |
|
|
} |
|
|
} |