9 changed files with 231 additions and 42 deletions
-
2.env
-
2package.json
-
36src/components/SideMenu.tsx
-
63src/pages/measure/components/MeasureAction.tsx
-
28src/pages/measure/components/MeasureDetail.tsx
-
99src/pages/system/Setting.tsx
-
22src/pages/system/types.ts
-
9src/services/measure/type.ts
-
12src/services/user/system.ts
@ -1 +1 @@ |
|||||
REACT_APP_WS_URL=192.168.1.146:8080/ws |
|
||||
|
REACT_APP_WS_URL=127.0.0.1:8080/ws |
@ -1,3 +1,100 @@ |
|||||
|
import { useState, useEffect } from 'react'; |
||||
|
import type { CascaderProps } from 'antd'; |
||||
|
import { Button, Cascader, Input } from 'antd'; |
||||
|
import { getOrgListService } from '../../services/ktj/org'; |
||||
|
import { options, OrgItem } from '../../services/ktjTypes'; |
||||
|
import { GwdItem, orgCascaderType, systemItem } from './types'; |
||||
|
import { sysSet } from '../../services/user/system'; |
||||
export default function Setting(){ |
export default function Setting(){ |
||||
return <div>123</div> |
|
||||
|
useEffect(()=>{ |
||||
|
queryRailData() |
||||
|
querySettingData() |
||||
|
},[]) |
||||
|
|
||||
|
const [systemList, setSystemList] = useState<systemItem[]>([]) |
||||
|
const [accountInfo, setAccountInfo] = useState<systemItem>({}) |
||||
|
function querySettingData(){ |
||||
|
sysSet({}, "GET").then(res=>{ |
||||
|
setSystemList(res.data) |
||||
|
let data:systemItem[] = res.data; |
||||
|
let accountInfo:systemItem = {} |
||||
|
data.map(item => { |
||||
|
if(item.code === 'UPLOAD_USERNAME'){ |
||||
|
accountInfo = { |
||||
|
name: item.name, |
||||
|
code: item.code, |
||||
|
value: item.value |
||||
|
} |
||||
|
} |
||||
|
}) |
||||
|
console.log('accountInfo---', accountInfo) |
||||
|
setAccountInfo(accountInfo) |
||||
|
}) |
||||
|
} |
||||
|
|
||||
|
useEffect(()=>{ |
||||
|
|
||||
|
}, [accountInfo]) |
||||
|
|
||||
|
//获取铁路局数据
|
||||
|
const [KTJOrgList, setKTJOrgList] = useState<orgCascaderType[]>([]); |
||||
|
function queryRailData(){ |
||||
|
getOrgListService().then((res) => { |
||||
|
if (res && res.data) { |
||||
|
let resData: OrgItem[] = res.data; |
||||
|
let data = convertToCascaderData(resData) |
||||
|
setKTJOrgList(data) |
||||
|
} |
||||
|
}).catch((e) => {}); |
||||
|
} |
||||
|
|
||||
|
function onOrgChange(value:string[]){ |
||||
|
console.log('value===', value) |
||||
|
if(value && value.length) |
||||
|
sysSet({code:"ORG",name:"org",value:JSON.stringify(value)}, "PUT").then(res=>{ |
||||
|
console.log('res===', res) |
||||
|
}) |
||||
|
} |
||||
|
|
||||
|
function onSaveAccount(){ |
||||
|
sysSet({code:"UPLOAD_USERNAME", name:accountInfo.name,value:accountInfo.value}, "PUT").then(res=>{ |
||||
|
console.log('res===', res) |
||||
|
}) |
||||
|
} |
||||
|
|
||||
|
function convertToCascaderData(data:OrgItem[]) { |
||||
|
return data.map(item => { |
||||
|
const newItem:orgCascaderType = { |
||||
|
value: item.key, |
||||
|
label: item.value, |
||||
|
}; |
||||
|
if (item.gwdDicList && item.gwdDicList.length > 0) { |
||||
|
newItem.children = item.gwdDicList.map(gwdItem => { |
||||
|
const newGwdItem:GwdItem = { |
||||
|
value: gwdItem.key, |
||||
|
label: gwdItem.value, |
||||
|
}; |
||||
|
if (gwdItem.railDicList && gwdItem.railDicList.length > 0) { |
||||
|
newGwdItem.children = gwdItem.railDicList.map(railItem => ({ |
||||
|
value: railItem.key, |
||||
|
label: railItem.value || railItem.input |
||||
|
})); |
||||
|
} |
||||
|
return newGwdItem; |
||||
|
}); |
||||
|
} |
||||
|
return newItem; |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
return <div> |
||||
|
<section className='p-[20px]'> |
||||
|
<div>铁路局:<Cascader className='w-[300px]' options={KTJOrgList} onChange={onOrgChange} placeholder="请选择局段线" /></div> |
||||
|
<div className='mt-[10px]'> |
||||
|
{accountInfo.name}: |
||||
|
<Input key={accountInfo.value} defaultValue={accountInfo.value} onChange={(e)=>{setAccountInfo({...accountInfo, value:e.target.value})}} className='w-[300px]'></Input> |
||||
|
<Button className='ml-[10px]' size='small' type="primary" onClick={onSaveAccount}>保存</Button> |
||||
|
</div> |
||||
|
</section> |
||||
|
</div> |
||||
} |
} |
@ -0,0 +1,22 @@ |
|||||
|
export type child = { |
||||
|
value: string; |
||||
|
label: string; |
||||
|
} |
||||
|
|
||||
|
export type GwdItem = { |
||||
|
value: string; |
||||
|
label: string; |
||||
|
children?: child[] |
||||
|
} |
||||
|
|
||||
|
export type orgCascaderType = { |
||||
|
value: string; |
||||
|
label: string; |
||||
|
children?: child[] |
||||
|
} |
||||
|
|
||||
|
export type systemItem = { |
||||
|
code?: string; |
||||
|
name?: string; |
||||
|
value?: string; |
||||
|
} |
@ -1,8 +1,10 @@ |
|||||
import httpRequest, { BaseResponse } from "../httpRequest"; |
import httpRequest, { BaseResponse } from "../httpRequest"; |
||||
export function sysSet(params: { name:string, value: string }) { |
|
||||
|
export function sysSet(params:{code?: string, name?: string, value?: string}, type: "GET" | "POST" | "PATCH" | "PUT" | "DELETE" = "GET"): Promise<BaseResponse> { |
||||
return httpRequest<BaseResponse>({ |
return httpRequest<BaseResponse>({ |
||||
url: "/api/sysSet", |
|
||||
params, |
|
||||
method: "PUT", |
|
||||
|
url: "/api/sysSet/", |
||||
|
params: { |
||||
|
...params, |
||||
|
}, |
||||
|
method: type |
||||
}); |
}); |
||||
} |
|
||||
|
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue