Browse Source

merge

feature/0607-opt
LiLongLong 4 months ago
parent
commit
ecfc614ea1
  1. 3
      .env
  2. 2
      package.json
  3. 81
      src/pages/system/Setting.tsx

3
.env

@ -1 +1,2 @@
REACT_APP_WS_URL=127.1.1.0:8080/ws
REACT_APP_WS_URL=192.168.1.146:8080/ws
PORT= 3000

2
package.json

@ -2,7 +2,7 @@
"name": "outline",
"version": "0.1.0",
"private": true,
"proxy": "http://127.1.1.0:8080",
"proxy": "http://192.168.1.146:8080",
"dependencies": {
"@ant-design/icons": "^6.0.0",
"@babel/core": "^7.16.0",

81
src/pages/system/Setting.tsx

@ -1,5 +1,5 @@
import { useState, useEffect, useRef } from 'react';
import { Button, Cascader, Input, message } from 'antd';
import { useState, useEffect } from 'react';
import { Button, Cascader, Input, message, Form } from 'antd';
import {
LoadingOutlined,
} from '@ant-design/icons';
@ -127,32 +127,6 @@ export default function Setting(){
}
}
let newAccountInfo = useRef({
name:'',
value:''
})
function onSaveAccount(){
console.log('newAccountInfo---', newAccountInfo)
const accountParams = {
code:"UPLOAD_USERNAME",
name:accountInfo.name,
value:newAccountInfo.current.value,
id:accountInfo.id
}
sysSet(accountParams, "PUT").then(res=>{
if(res.status === 0){
dispatch(updateSystemAccountState(accountParams))
message.success("修改成功")
}
})
}
function onAccountChange(accountValue:string){
newAccountInfo.current.name = accountInfo.name || '';
newAccountInfo.current.value = accountValue;
console.log('newAccountInfo--22-', newAccountInfo)
}
function convertToCascaderData(data:OrgItem[]) {
return data.map(item => {
const newItem:orgCascaderType = {
@ -275,20 +249,55 @@ export default function Setting(){
}
};
const saveSet = (item:systemItem) => {
const params = {
id:item.id,
value:item.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={() => saveSet(item)}/>}
</Form.Item>
})
}
</Form>
}
// @ts-ignore
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'}>
<h1 className='text-[20px]'></h1>
<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} onChange={(e)=>{onAccountChange(e.target.value)}} className='w-[300px]'></Input>
<Button className='ml-[10px]' size='small' type="primary" onClick={onSaveAccount}></Button>
</div>
{form()}
{/*<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} onChange={(e)=>{onAccountChange(e.target.value)}} className='w-[300px]'></Input>*/}
{/* <Button className='ml-[10px]' size='small' type="primary" onClick={onSaveAccount}>保存</Button>*/}
{/*</div>*/}
</section>
<h1 className='text-[20px]'></h1>
{connectionStatus()}

Loading…
Cancel
Save