All checks were successful
Build and Push Docker Image / build (push) Successful in 5m10s
93 lines
2.4 KiB
TypeScript
93 lines
2.4 KiB
TypeScript
import {
|
|
MyBetaModalFormProps,
|
|
MyButtons,
|
|
MyFormItems,
|
|
MyModalFormProps,
|
|
rulesHelper,
|
|
} from '@/common';
|
|
import { Selects } from '@/components/Select';
|
|
import { Apis } from '@/gen/Apis';
|
|
import { QuestionsTypeEnum } from '@/gen/Enums';
|
|
import { BetaSchemaForm } from '@ant-design/pro-components';
|
|
import { Form, message } from 'antd';
|
|
|
|
export default function QuestionsCreate(props: MyBetaModalFormProps) {
|
|
const [form] = Form.useForm();
|
|
|
|
return (
|
|
<BetaSchemaForm<ApiTypes.Survey.Questions.Store>
|
|
{...MyModalFormProps.props}
|
|
form={form}
|
|
title={`添加${props.title}`}
|
|
wrapperCol={{ span: 24 }}
|
|
key={new Date().getTime()}
|
|
width="600px"
|
|
trigger={<MyButtons.Create title={`添加${props.title}`} />}
|
|
onOpenChange={(open: any) => {
|
|
if (open) {
|
|
form.resetFields(); // 清空表单数据
|
|
}
|
|
}}
|
|
onFinish={async (values) => {
|
|
console.log(values);
|
|
return Apis.Survey.Questions.Store({
|
|
...values,
|
|
is_enabled: values?.is_enabled ? true : false,
|
|
})
|
|
.then(() => {
|
|
props.reload?.();
|
|
message.success(props.title + '成功');
|
|
return true;
|
|
})
|
|
.catch(() => false);
|
|
}}
|
|
columns={[
|
|
MyFormItems.EnumRadio({
|
|
key: 'type',
|
|
title: '类型',
|
|
valueEnum: QuestionsTypeEnum,
|
|
colProps: { span: 12 },
|
|
formItemProps: { ...rulesHelper.text },
|
|
}),
|
|
Selects?.QuestionCategories({
|
|
colProps: { span: 12 },
|
|
required: true,
|
|
}),
|
|
{
|
|
key: 'title',
|
|
title: '题目',
|
|
colProps: { span: 24 },
|
|
formItemProps: { ...rulesHelper.text },
|
|
},
|
|
{
|
|
key: 'placeholder',
|
|
title: '提示',
|
|
colProps: { span: 12 },
|
|
},
|
|
{
|
|
key: 'max_length',
|
|
title: '回答最大字数',
|
|
valueType: 'digit',
|
|
fieldProps: {
|
|
style: { width: '100%' },
|
|
},
|
|
colProps: { span: 12, suffix: '个字' },
|
|
},
|
|
{
|
|
key: 'required',
|
|
title: '是否必答',
|
|
valueType: 'switch',
|
|
colProps: { span: 12 },
|
|
},
|
|
{
|
|
key: 'is_enabled',
|
|
title: '是否启用',
|
|
valueType: 'switch',
|
|
colProps: { span: 12 },
|
|
},
|
|
// MyFormItems.ColorPicker(),
|
|
]}
|
|
/>
|
|
);
|
|
}
|