Commit 1f33b8cd authored by 前端-钟卫鹏's avatar 前端-钟卫鹏
parents d0867132 c710903d
import React, { useState } from 'react';
import { IApiRequest } from '@/utils/request';
export interface IHttpRequestReturn<T> {
data: T | null,
loading: boolean,
err: any,
run(params?: any)
}
/**
* 简易版本的useRequest hooks, 用于处理带有loading的业务场景
* @auth xjm
*/
export function useHttpRequest<T>(api: (params?, config?) => Promise<T>, config?: IApiRequest): IHttpRequestReturn<T> {
const [loading, setLoading] = useState(false)
const [data, setData] = useState<T | null>(null)
const [err, setErr] = useState()
const run = (params) => {
setLoading(true)
api(params).then((res: any) => {
setData(res.data)
}).catch(err => {
setErr(err)
}).finally(() => {
setTimeout(() => {
setLoading(false)
}, 200)
})
}
return {
data,
loading,
err,
run
}
}
\ No newline at end of file
......@@ -304,4 +304,7 @@
.mr_t-40 {
margin-top: 40px;
}
.mr_t-24 {
margin-top: 24px;
}
\ No newline at end of file
......@@ -49,6 +49,7 @@ const CustomCheckbox = props => {
const CustomInput = props => {
const { help, ...restProps } = props
console.log(props)
return (
<AntdInput
{...restProps}
......@@ -281,7 +282,7 @@ const UserRegistry = () => {
GlobalConfig.userRegister.useDetail.map(v => {
return (
<FormBlock className={styles['mr_t-40']} visible={current === 2} key={v.groupName} title={<span className={styles.commonPanelTitle}>{v.groupName}</span>}>
<FormMegaLayout columns={2} grid>
<FormMegaLayout columns={2} grid autoRow size='large' className={styles['mr_t-24']}>
{
v.elements.map(field => {
// 字段类型暂时为null, 所以固定为input
......@@ -309,7 +310,8 @@ const UserRegistry = () => {
pattern: v.rulePattern
}
})}
x-component-props={{ help: field.fieldRemark, placeholder: `请输入${field.fieldCNName}`}}
maxLength={field.fieldLength}
x-component-props={{ help: field.fieldRemark, placeholder: `请输入${field.fieldCNName}`, size: 'large'}}
x-component='CustomInput'
>
</Field>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment