1 В избранное 0 Ответвления 0

OSCHINA-MIRROR/rainbond-rainbond-ui

Присоединиться к Gitlife
Откройте для себя и примите участие в публичных проектах с открытым исходным кодом с участием более 10 миллионов разработчиков. Приватные репозитории также полностью бесплатны :)
Присоединиться бесплатно
Клонировать/Скачать
index.js 4.9 КБ
Копировать Редактировать Web IDE Исходные данные Просмотреть построчно История
songyg Отправлено 3 лет назад e802d19
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 )

Вы можете оставить комментарий после Вход в систему

1
https://gitlife.ru/oschina-mirror/rainbond-rainbond-ui.git
git@gitlife.ru:oschina-mirror/rainbond-rainbond-ui.git
oschina-mirror
rainbond-rainbond-ui
rainbond-rainbond-ui
main