Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
ems3.3
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wuhao
ems3.3
Commits
c64cfb4d
Commit
c64cfb4d
authored
Dec 16, 2022
by
TZW
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
11
parent
0c3adabd
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
105 additions
and
33 deletions
+105
-33
FormItems.jsx
src/components/InitForm/FormItems.jsx
+70
-3
columns.js
src/pages/setting/users/columns.js
+22
-8
index.jsx
src/pages/setting/users/index.jsx
+13
-22
No files found.
src/components/InitForm/FormItems.jsx
View file @
c64cfb4d
...
@@ -30,7 +30,7 @@ import {
...
@@ -30,7 +30,7 @@ import {
import
ImgCrop
from
'antd-img-crop'
;
import
ImgCrop
from
'antd-img-crop'
;
import
{
doFetch
}
from
'@/utils/doFetch'
;
import
{
doFetch
}
from
'@/utils/doFetch'
;
import
moment
from
'moment'
;
import
moment
from
'moment'
;
import
{
useAsyncEffect
}
from
'ahooks'
;
import
{
useAsyncEffect
,
useRequest
}
from
'ahooks'
;
import
*
as
Antd
from
'antd'
;
import
*
as
Antd
from
'antd'
;
import
{
PlusOutlined
,
DownOutlined
,
CloseOutlined
,
RedoOutlined
}
from
'@ant-design/icons'
;
import
{
PlusOutlined
,
DownOutlined
,
CloseOutlined
,
RedoOutlined
}
from
'@ant-design/icons'
;
import
BraftEditor
from
'braft-editor'
;
import
BraftEditor
from
'braft-editor'
;
...
@@ -38,8 +38,20 @@ import EditTable from './EditTable';
...
@@ -38,8 +38,20 @@ import EditTable from './EditTable';
import
EditorItem
from
'./EditorItem'
;
import
EditorItem
from
'./EditorItem'
;
import
Diyrule
from
'./Diyrule'
;
import
Diyrule
from
'./Diyrule'
;
import
defaultSetting
from
'../../../config/defaultSettings'
;
import
defaultSetting
from
'../../../config/defaultSettings'
;
const
{
const
{
Image
,
Form
,
Upload
,
Col
,
Pagination
,
Avatar
,
Dropdown
,
Menu
,
Tabs
,
message
}
=
Antd
;
Image
,
Form
,
Upload
,
Col
,
Pagination
,
Avatar
,
Dropdown
,
Menu
,
Tabs
,
message
,
AutoComplete
,
Row
,
}
=
Antd
;
const
AntdCheckBox
=
Antd
.
Checkbox
;
const
AntdCheckBox
=
Antd
.
Checkbox
;
const
FormItems
=
{
const
FormItems
=
{
...
@@ -76,6 +88,7 @@ const FormItems = {
...
@@ -76,6 +88,7 @@ const FormItems = {
FormSelectList
,
FormSelectList
,
CheckboxItem
,
CheckboxItem
,
RadioItem
,
RadioItem
,
MyAutoComplete
,
};
};
function
upperCase
(
str
)
{
function
upperCase
(
str
)
{
const
newStr
=
str
.
slice
(
0
,
1
).
toUpperCase
()
+
str
.
slice
(
1
);
const
newStr
=
str
.
slice
(
0
,
1
).
toUpperCase
()
+
str
.
slice
(
1
);
...
@@ -190,6 +203,60 @@ function Input({ item, colProps }) {
...
@@ -190,6 +203,60 @@ function Input({ item, colProps }) {
</>
</>
);
);
}
}
function
MyAutoComplete
({
item
,
colProps
,
formRef
})
{
const
[
options
,
setoptions
]
=
useState
([]);
const
[
username
,
setusername
]
=
useState
();
const
{
data
,
run
,
runAsync
}
=
useRequest
(
async
()
=>
{
let
res
=
await
doFetch
({
url
:
'/auth/sysUser/queryLikeIotUsername'
,
params
:
{
username
},
});
return
res
?.
data
?.
dataList
;
},
{
manual
:
true
,
},
);
useEffect
(()
=>
{
console
.
log
(
username
);
runAsync
()
.
then
((
data
)
=>
{
const
options
=
data
?.
map
((
it
)
=>
({
...
it
,
label
:
`
${
it
?.
username
}
-
$
{
it
?.
fullName
}
`,
value: `
$
{
it
?.
username
}
-
$
{
it
?.
fullName
}
`,
}));
setoptions(options);
})
.catch((error) => {
console.log(error);
});
}, [username]);
let col = item.colProps ?? colProps;
let curkey = item.key ?? item.dataIndex;
return (
<Col span={12}>
<ProForm.Item name={curkey} label={item.title} {...item.formItemProps}>
<AutoComplete
formRef={formRef}
allowClear={true}
style={{ width: '100%' }}
fieldProps={item?.fieldProps}
disabled={item?.disabled}
colProps={item.colProps ?? colProps}
onSearch={(e) => {
setusername(e);
}}
options={options}
onSelect={item?.onSelect}
/>
</ProForm.Item>
</Col>
);
}
//pwd
//pwd
function Password({ item, colProps }) {
function Password({ item, colProps }) {
return (
return (
...
...
src/pages/setting/users/columns.js
View file @
c64cfb4d
...
@@ -2,12 +2,11 @@ import { doFetch } from '@/utils/doFetch';
...
@@ -2,12 +2,11 @@ import { doFetch } from '@/utils/doFetch';
import
{
Image
}
from
'antd'
;
import
{
Image
}
from
'antd'
;
import
fieldsDetail
from
'@/utils/fieldsDetail'
;
import
fieldsDetail
from
'@/utils/fieldsDetail'
;
import
{
useState
,
useEffect
}
from
'react'
;
import
{
useState
,
useEffect
}
from
'react'
;
function
getcolumns
(
setDrawer
,
usermsg
)
{
function
getcolumns
(
ifs
,
formRef
)
{
const
options
=
usermsg
?.
map
((
it
)
=>
({
// const options = usermsg?.map((it) => ({
label
:
`
${
it
?.
username
}
-
$
{
it
?.
fullName
}
`,
// label: `${it?.username}-${it?.fullName}`,
value: it?.id,
// value: it?.id,
}));
// }));
console.log(options);
return
[
return
[
{
{
title
:
'用户名'
,
title
:
'用户名'
,
...
@@ -15,9 +14,24 @@ function getcolumns(setDrawer, usermsg) {
...
@@ -15,9 +14,24 @@ function getcolumns(setDrawer, usermsg) {
width
:
120
,
width
:
120
,
key
:
'username'
,
key
:
'username'
,
formItemProps
:
{
rules
:
[{
required
:
true
,
message
:
'此项为必填项'
}]
},
formItemProps
:
{
rules
:
[{
required
:
true
,
message
:
'此项为必填项'
}]
},
valueType: 'select',
valueType
:
'MyAutoComplete'
,
options,
onSelect
:
(
value
,
option
)
=>
{
formRef
.
current
.
setFieldValue
(
'telephone'
,
option
?.
phone
);
formRef
.
current
.
setFieldValue
(
'fullName'
,
option
?.
fullName
);
formRef
.
current
.
setFieldValue
(
'mailNo'
,
option
?.
mailbox
);
formRef
.
current
.
setFieldValue
(
'status'
,
option
?.
enabled
);
},
disabled
:
ifs
,
},
},
// {
// title: '用户名',
// dataIndex: 'username',
// width: 120,
// key: 'username',
// formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
// valueType: 'select',
// options,
// },
{
{
title
:
'姓名'
,
title
:
'姓名'
,
dataIndex
:
'fullName'
,
dataIndex
:
'fullName'
,
...
...
src/pages/setting/users/index.jsx
View file @
c64cfb4d
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
* @Author: Li Hanlin
* @Author: Li Hanlin
* @Date: 2022-11-09 14:44:44
* @Date: 2022-11-09 14:44:44
* @Last Modified by: Li Hanlin
* @Last Modified by: Li Hanlin
* @Last Modified time: 2022-12-16
16:57:18
* @Last Modified time: 2022-12-16
20:20:17
*/
*/
import
*
as
React
from
'react'
;
import
*
as
React
from
'react'
;
...
@@ -17,18 +17,12 @@ import { message, AutoComplete } from 'antd';
...
@@ -17,18 +17,12 @@ import { message, AutoComplete } from 'antd';
import
ExtendField
from
'@/components/ExtendField'
;
import
ExtendField
from
'@/components/ExtendField'
;
import
{
useModel
}
from
'umi'
;
import
{
useModel
}
from
'umi'
;
import
{
useRequest
}
from
'ahooks'
;
import
{
useRequest
}
from
'ahooks'
;
import
{
indexOf
}
from
'lodash'
;
function
User
(
props
)
{
function
User
(
props
)
{
const
{
initialState
,
loading
,
error
,
refresh
,
setInitialState
}
=
useModel
(
'@@initialState'
);
const
{
initialState
,
loading
,
error
,
refresh
,
setInitialState
}
=
useModel
(
'@@initialState'
);
const
[
username
,
setusername
]
=
useState
(
null
);
const
[
username
,
setusername
]
=
useState
(
null
);
const
{
data
}
=
useRequest
(
async
()
=>
{
let
res
=
await
doFetch
({
url
:
'/auth/sysUser/queryLikeIotUsername'
,
params
:
{
username
:
initialState
?.
currentUser
?.
username
},
});
return
res
?.
data
?.
dataList
;
});
console
.
log
(
data
);
const
actionRef
=
useRef
(),
const
actionRef
=
useRef
(),
formRef
=
useRef
();
formRef
=
useRef
();
const
[
drawer
,
setDrawer
]
=
useState
({
const
[
drawer
,
setDrawer
]
=
useState
({
...
@@ -149,14 +143,14 @@ function User(props) {
...
@@ -149,14 +143,14 @@ function User(props) {
};
};
const
columns
=
useMemo
(()
=>
{
const
columns
=
useMemo
(()
=>
{
let
defcolumn
=
getcolumns
(
setDrawer
,
data
);
let
defcolumn
=
getcolumns
(
setDrawer
,
formRef
);
return
defcolumn
.
concat
({
return
defcolumn
.
concat
({
title
:
'操作'
,
title
:
'操作'
,
valueType
:
'option'
,
valueType
:
'option'
,
width
:
150
,
width
:
150
,
render
:
(
text
,
row
,
_
,
action
)
=>
[
edit
(
text
,
row
,
_
,
action
),
remove
(
text
,
row
,
_
,
action
)],
render
:
(
text
,
row
,
_
,
action
)
=>
[
edit
(
text
,
row
,
_
,
action
),
remove
(
text
,
row
,
_
,
action
)],
});
});
},
[
data
]);
},
[]);
function
selectType
(
type
)
{
function
selectType
(
type
)
{
switch
(
type
)
{
switch
(
type
)
{
...
@@ -182,6 +176,7 @@ function User(props) {
...
@@ -182,6 +176,7 @@ function User(props) {
}
}
let
params
=
{
let
params
=
{
...
vals
,
...
vals
,
username
:
vals
?.
username
.
slice
(
0
,
vals
?.
username
?.
indexOf
(
'-'
)),
id
:
drawer
?.
title
==
'编辑'
?
drawer
?.
item
?.
id
:
''
,
id
:
drawer
?.
title
==
'编辑'
?
drawer
?.
item
?.
id
:
''
,
userCharReqList
,
userCharReqList
,
};
};
...
@@ -205,16 +200,12 @@ function User(props) {
...
@@ -205,16 +200,12 @@ function User(props) {
}
}
}
}
}
}
defaultFormValue=
{
drawer
.
item
}
defaultFormValue=
{
drawer
.
item
}
onValuesChange=
{
(
changedValues
,
allValues
)
=>
{
// onValuesChange={(changedValues, allValues) => {
if
(
changedValues
[
'username'
])
{
// console.log(changedValues, allValues);
let
item
=
data
?.
filter
((
it
)
=>
{
// if (changedValues['username']) {
return
it
?.
id
==
;
// console.log(changedValues, allValues);
});
// }
console
.
log
(
item
);
// }}
console
.
log
(
changedValues
,
allValues
);
formRef
.
current
.
setFieldValue
(
'telephone'
,
'123123'
);
}
}
}
/>
/>
);
);
...
@@ -224,7 +215,7 @@ function User(props) {
...
@@ -224,7 +215,7 @@ function User(props) {
setDrawer=
{
setDrawer
}
setDrawer=
{
setDrawer
}
drawer=
{
drawer
}
drawer=
{
drawer
}
actionRef=
{
actionRef
}
actionRef=
{
actionRef
}
columns=
{
columns
}
columns=
{
getcolumns
(
true
,
formRef
)
}
formId=
{
'1'
}
formId=
{
'1'
}
urlParams=
{
urlParams
}
urlParams=
{
urlParams
}
onFinish=
{
async
(
vals
)
=>
{
onFinish=
{
async
(
vals
)
=>
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment