93 lines
2.6 KiB
TypeScript
93 lines
2.6 KiB
TypeScript
import { putProjectUpdateProject } from '@/services/project/Project';
|
|
import {
|
|
ModalForm,
|
|
ProForm,
|
|
ProFormText,
|
|
} from '@ant-design/pro-components';
|
|
import { FormattedMessage, useIntl } from '@umijs/max';
|
|
import { Form, message } from 'antd';
|
|
import { proFormSmallItemStyleProps, proFormSmallModelWidth } from '../../../../../config/defaultForm';
|
|
import React from 'react';
|
|
export type FormValueType = {
|
|
target?: string;
|
|
template?: string;
|
|
type?: string;
|
|
time?: string;
|
|
frequency?: string;
|
|
} & Partial<API.Project>;
|
|
|
|
export type UpdateFormProps = {
|
|
updateModalOpen: boolean;
|
|
handleModal: () => void;
|
|
values: Partial<API.Project>;
|
|
reload: any;
|
|
};
|
|
|
|
|
|
|
|
const UpdateAccountForm: React.FC<UpdateFormProps> = (props) => {
|
|
const intl = useIntl();
|
|
const [form] = Form.useForm<API.Project>();
|
|
|
|
return (
|
|
<ModalForm<API.Project>
|
|
width={proFormSmallModelWidth}
|
|
title={intl.formatMessage({
|
|
id: 'account.account_center.table.list.UpdateAccountForm',
|
|
defaultMessage: '$$$',
|
|
})}
|
|
open={props.updateModalOpen}
|
|
form={form}
|
|
autoFocusFirstInput
|
|
modalProps={{
|
|
destroyOnClose: true,
|
|
onCancel: () => props.handleModal(),
|
|
}}
|
|
submitTimeout={2000}
|
|
onFinish={async (values) => {
|
|
putProjectUpdateProject(values)
|
|
.then(() => {
|
|
message.success(intl.formatMessage({ id: 'common.success', defaultMessage: '$$$' }));
|
|
props.reload();
|
|
})
|
|
.catch(() => {
|
|
message.error(intl.formatMessage({ id: 'common.failure', defaultMessage: '$$$' }));
|
|
});
|
|
|
|
props.handleModal();
|
|
return true;
|
|
}}
|
|
>
|
|
<ProForm.Group>
|
|
<ProFormText
|
|
width={proFormSmallItemStyleProps.width}
|
|
name="name"
|
|
label={<FormattedMessage id="account.account_center.table.list.account" defaultMessage="$$$" />}
|
|
placeholder={`${intl.formatMessage({
|
|
id: 'common.please_input',
|
|
defaultMessage: '$$$',
|
|
})}${intl.formatMessage({
|
|
id: 'account.account_center.table.list.account',
|
|
defaultMessage: '$$$',
|
|
})}`}
|
|
required={true}
|
|
initialValue={props.values.name}
|
|
disabled={false}
|
|
rules={[
|
|
{
|
|
required: true,
|
|
message: (
|
|
<FormattedMessage
|
|
id="account.account_center.table.rule.required.account"
|
|
defaultMessage="account is required"
|
|
/>
|
|
),
|
|
},
|
|
]}
|
|
/>
|
|
</ProForm.Group>
|
|
</ModalForm>
|
|
);
|
|
};
|
|
export default UpdateAccountForm;
|