96 lines
3.0 KiB
TypeScript
96 lines
3.0 KiB
TypeScript
/*
|
|
* @Author: zhoux zhouxia@supervision.ltd
|
|
* @Date: 2023-12-26 14:46:35
|
|
* @LastEditors: zhoux zhouxia@supervision.ltd
|
|
* @LastEditTime: 2023-12-26 14:58:36
|
|
* @FilePath: \general-ai-platform-web\src\pages\Alarm\AlarmWays\components\CreateForm.tsx
|
|
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
|
|
*/
|
|
import { ModalForm, ProForm, ProFormText } from '@ant-design/pro-components';
|
|
import { FormattedMessage, useIntl } from '@umijs/max';
|
|
import { Form } from 'antd';
|
|
import React from 'react';
|
|
import {
|
|
proFormSmallItemStyleProps,
|
|
proFormSmallModelWidth,
|
|
} from '../../../../../config/defaultForm';
|
|
// TODO 需要根据接口替换API.DeviceCategory
|
|
export type FormValueType = {
|
|
target?: string;
|
|
template?: string;
|
|
type?: string;
|
|
time?: string;
|
|
frequency?: string;
|
|
} & Partial<API.DeviceCategory>;
|
|
|
|
export type CreateFormProps = {
|
|
createModalOpen: boolean;
|
|
handleModal: () => void;
|
|
reload: any;
|
|
};
|
|
const CreateForm: React.FC<CreateFormProps> = (props) => {
|
|
const intl = useIntl();
|
|
// const [isAuto, setIsAuto] = useState(true);
|
|
const [form] = Form.useForm<API.DeviceCategory>();
|
|
|
|
return (
|
|
<ModalForm<API.DeviceCategory>
|
|
width={proFormSmallModelWidth}
|
|
title={intl.formatMessage({
|
|
id: 'alarm.ways.page.add',
|
|
defaultMessage: '$$$',
|
|
})}
|
|
open={props.createModalOpen}
|
|
form={form}
|
|
autoFocusFirstInput
|
|
modalProps={{
|
|
destroyOnClose: true,
|
|
onCancel: () => props.handleModal(),
|
|
}}
|
|
submitTimeout={2000}
|
|
onFinish={async (values) => {
|
|
// TODO 需要对接新增告警方式接口
|
|
console.log('onFinish_values', values);
|
|
// postDeviceCategoryCreateDeviceCategory(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="alarm.ways.page.model.name" defaultMessage="$$$" />}
|
|
placeholder={`${intl.formatMessage({
|
|
id: 'common.please_input',
|
|
defaultMessage: '$$$',
|
|
})}${intl.formatMessage({
|
|
id: 'alarm.ways.page.model.name',
|
|
defaultMessage: '$$$',
|
|
})}`}
|
|
required={true}
|
|
rules={[
|
|
{
|
|
required: true,
|
|
message: (
|
|
<FormattedMessage
|
|
id="alarm.ways.page.model.rule.required.name"
|
|
defaultMessage="name is required"
|
|
/>
|
|
),
|
|
},
|
|
]}
|
|
/>
|
|
</ProForm.Group>
|
|
</ModalForm>
|
|
);
|
|
};
|
|
export default CreateForm;
|