Слияние кода завершено, страница обновится автоматически
import dateUtil from '@/utils/date-util';
import { Form, Input, Modal, Select, Skeleton } from 'antd';
import { connect } from 'dva';
import React, { PureComponent } from 'react';
import { formatMessage, FormattedMessage } from 'umi-plugin-locale';
import globalUtil from '../../utils/global';
import roleUtil from '../../utils/role';
import UserSelect from '../UserSelect';
const { Option } = Select;
const FormItem = Form.Item;
@Form.create()
@connect()
class ConfirmModal extends PureComponent {
constructor(arg) {
super(arg);
this.state = {
roles: [],
currentRoles: [],
roleLoading: true,
currentRolesLoading: true
};
}
componentDidMount() {
this.loadRoles();
const { viewName, data } = this.props;
if (
viewName === 'enterprise' &&
data &&
data.roles &&
data.roles.length > 0
) {
this.fetchTeamUserRoles();
} else {
this.handleCloseCurrentRolesLoading();
}
}
fetchTeamUserRoles = () => {
const { dispatch, userId, eid, teamName } = this.props;
dispatch({
type: 'teamControl/fetchUserTeamsRoles',
payload: {
tenantName: teamName,
team_name: teamName,
enterprise_id: eid,
user_id: userId,
page: 1,
page_size: -1
},
callback: res => {
this.setState(
{
currentRoles: (res.bean && res.bean.roles) || []
},
() => {
this.handleCloseCurrentRolesLoading();
}
);
}
});
};
loadRoles = () => {
const { dispatch, teamName } = this.props;
dispatch({
type: 'teamControl/fetchTeamRoles',
payload: {
team_name: teamName || globalUtil.getCurrTeamName(),
page_size: -1,
page: 1
},
callback: data => {
this.setState(
{
roles: data.list || []
},
() => {
this.handleCloseRoleLoading();
}
);
}
});
};
handleSubmit = () => {
const { form, onOk } = this.props;
form.validateFields((err, values) => {
if (!err && onOk) {
onOk(values);
}
});
};
handleCloseRoleLoading = () => {
this.setState({
roleLoading: false
});
};
handleCloseCurrentRolesLoading = () => {
this.setState({
currentRolesLoading: false
});
};
render() {
const { onCancel, data, form, title, loading } = this.props;
const { getFieldDecorator } = form;
const {
roles,
currentRoles,
roleLoading,
currentRolesLoading
} = this.state;
const initialValueRoles = [];
const arr =
(currentRoles && currentRoles.length > 0 && currentRoles) ||
(data && data.roles && data.roles.length > 0 && data.roles) ||
[];
arr.map(item => {
if (item.role_id) {
initialValueRoles.push(Number(item.role_id));
}
});
const formItemLayout = {
labelCol: {
xs: { span: 24 },
sm: { span: 6 }
},
wrapperCol: {
xs: { span: 24 },
sm: { span: 14 }
}
};
return (
<Modal
confirmLoading={loading}
title={title || (data ? formatMessage({id:'confirmModal.edit.image.title'}) : formatMessage({id:'confirmModal.add.image.title'}))}
visible
onOk={this.handleSubmit}
onCancel={onCancel}
>
<Skeleton loading={roleLoading || currentRolesLoading}>
<Form onSubmit={this.handleSubmit}>
<FormItem {...formItemLayout} label={formatMessage({id:'confirmModal.image.lable.username'})}>
{getFieldDecorator('username', {
initialValue: data.username || '',
rules: [
{
required: true,
message: formatMessage({id:'placeholder.userName'}),
},
{
max: 255,
message: formatMessage({id:'placeholder.max255'}),
}
]
})(<Input placeholder={formatMessage({id:'placeholder.userName'})} />)}
</FormItem>
<FormItem {...formItemLayout} label={formatMessage({id:'confirmModal.image.lable.password'})}>
{getFieldDecorator('password', {
initialValue: data.password || '',
rules: [
{
required: true,
message: formatMessage({id:'placeholder.password_1'}),
},
{
max: 255,
message: formatMessage({id:'placeholder.max255'}),
}
]
})(<Input placeholder={formatMessage({id:'placeholder.password_1'})} type="password"/>)}
</FormItem>
</Form>
</Skeleton>
</Modal>
);
}
}
export default ConfirmModal;
Вы можете оставить комментарий после Вход в систему
Неприемлемый контент может быть отображен здесь и не будет показан на странице. Вы можете проверить и изменить его с помощью соответствующей функции редактирования.
Если вы подтверждаете, что содержание не содержит непристойной лексики/перенаправления на рекламу/насилия/вульгарной порнографии/нарушений/пиратства/ложного/незначительного или незаконного контента, связанного с национальными законами и предписаниями, вы можете нажать «Отправить» для подачи апелляции, и мы обработаем ее как можно скорее.
Опубликовать ( 0 )