|
|
|
@ -17,7 +17,7 @@ import { queryQuestionById, queryQuestionList, queryQuestionType } from '@/pages
|
|
|
|
|
import ProForm, { ProFormSelect } from '@ant-design/pro-form';
|
|
|
|
|
import ProTable, { ActionType, ProColumns } from '@ant-design/pro-table';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const labels = ['A','B','C','D','E','F','G','H','I','J']; // 默认10个
|
|
|
|
|
|
|
|
|
|
//const { Paragraph } = Typography;
|
|
|
|
|
const formItemLayout = {
|
|
|
|
@ -40,13 +40,14 @@ console.log('first');
|
|
|
|
|
const AnswersSelector = () => {
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<Form.List
|
|
|
|
|
<Form.List
|
|
|
|
|
initialValue={['','','','']}
|
|
|
|
|
name="names"
|
|
|
|
|
rules={[
|
|
|
|
|
{
|
|
|
|
|
validator: async (_, names) => {
|
|
|
|
|
if (!names || names.length < 2) {
|
|
|
|
|
return Promise.reject(new Error('At least 2 passengers'));
|
|
|
|
|
return Promise.reject(new Error('至少填写2个选项'));
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
@ -56,24 +57,24 @@ const AnswersSelector = () => {
|
|
|
|
|
<>
|
|
|
|
|
{fields.map((field, index) => (
|
|
|
|
|
<Form.Item
|
|
|
|
|
{...(index === 0 ? formItemLayout : formItemLayoutWithOutLabel)}
|
|
|
|
|
label={index === 0 ? 'Passengers' : ''}
|
|
|
|
|
label={labels[index]}
|
|
|
|
|
required={false}
|
|
|
|
|
key={field.key}
|
|
|
|
|
>
|
|
|
|
|
<Form.Item
|
|
|
|
|
|
|
|
|
|
{...field}
|
|
|
|
|
validateTrigger={['onChange', 'onBlur']}
|
|
|
|
|
rules={[
|
|
|
|
|
{
|
|
|
|
|
required: true,
|
|
|
|
|
whitespace: true,
|
|
|
|
|
message: "Please input passenger's name or delete this field.",
|
|
|
|
|
message: "选项不能为空",
|
|
|
|
|
},
|
|
|
|
|
]}
|
|
|
|
|
noStyle
|
|
|
|
|
>
|
|
|
|
|
<Input placeholder="passenger name" style={{ width: '100%' }} />
|
|
|
|
|
<Input placeholder="" style={{ width: '80%' }} />
|
|
|
|
|
</Form.Item>
|
|
|
|
|
{fields.length > 1 ? (
|
|
|
|
|
<MinusCircleOutlined
|
|
|
|
@ -87,20 +88,10 @@ const AnswersSelector = () => {
|
|
|
|
|
<Button
|
|
|
|
|
type="dashed"
|
|
|
|
|
onClick={() => add()}
|
|
|
|
|
style={{ width: '60%' }}
|
|
|
|
|
icon={<PlusOutlined />}
|
|
|
|
|
>
|
|
|
|
|
Add field
|
|
|
|
|
</Button>
|
|
|
|
|
<Button
|
|
|
|
|
type="dashed"
|
|
|
|
|
onClick={() => {
|
|
|
|
|
add('The head item', 0);
|
|
|
|
|
}}
|
|
|
|
|
style={{ width: '60%', marginTop: '20px' }}
|
|
|
|
|
style={{ marginLeft: 22, width: '60%' }}
|
|
|
|
|
icon={<PlusOutlined />}
|
|
|
|
|
>
|
|
|
|
|
Add field at head
|
|
|
|
|
添加选项
|
|
|
|
|
</Button>
|
|
|
|
|
<Form.ErrorList errors={errors} />
|
|
|
|
|
</Form.Item>
|
|
|
|
|