zhengpengju 3 years ago
parent 5c87f54246
commit 77df9d7c01

@ -181,10 +181,10 @@ const CourseList: React.FC = () => {
required: true,
message: '此项为必填项',
},
{
/*{
max: 4,
message: '最大长度为4字符',
}
}*/
],
}, // 传递给 Form.Item 的配置
},
@ -559,11 +559,13 @@ const CourseList: React.FC = () => {
console.log('uploadFileName', uploadFileName)
//return false;
// values.attachment_json.response.file.response.url
//console.log('currentRow', currentRow)
await handleAdd({
...values,
//course_id: currentRow?.course_id,
attachment_json: `{"img":"", "name": "${values.attachment_json.file.name}", "url": "down/M3u8/${uuid?.substr(0, 2)}/${uuid}.m3u8"}`
});
handleCreateModalVisible(false);
handleCreateModalVisible(false); // 隐藏创建窗口
actionRef.current?.reloadAndRest?.();
}}
submitter={{
@ -587,7 +589,7 @@ const CourseList: React.FC = () => {
visible={updateModalVisible}
destroyOnClose
onCancel={() => {
handleUpdateModalVisible(false);
handleUpdateModalVisible(false); // 隐藏编辑窗口
}}
footer={null}
>
@ -598,6 +600,14 @@ const CourseList: React.FC = () => {
labelCol={{ span: 8 }}
wrapperCol={{ span: 12 }}
onFinish={async (values) => {
alert(0)
console.log('currentRow', currentRow)
await handleUpdate({
...values,
course_id: currentRow?.course_id,
//attachment_json: `{"img":"", "name": "${values.attachment_json.file.name}", "url": "down/M3u8/${uuid?.substr(0, 2)}/${uuid}.m3u8"}`
});
handleUpdateModalVisible(false); // 隐藏编辑窗口
console.log(values);
}}
submitter={{

@ -0,0 +1,114 @@
/** 试题答案选项添加/编辑*/
//import { AlignLeftOutlined, PlusOutlined } from '@ant-design/icons';
import { Switch, Button, Card, Col, List, Menu, Progress, Row, Typography, Space, Divider, Radio, Checkbox, Tag, Dropdown, Upload, Modal, Form, Input } from 'antd';
import { PageContainer } from '@ant-design/pro-layout';
//import { useRequest } from 'umi';
//import { queryFakeList } from './service';
//import type { CardListItemDataType } from './data';
import styles from '../style.less';
//import SubMenu from 'antd/lib/menu/SubMenu';
//import ProCard from '@ant-design/pro-card';
import ProList from '@ant-design/pro-list';
import { ReactText, useEffect, useRef, useState } from 'react';
import { PlusOutlined, DeleteOutlined, DownloadOutlined, UploadOutlined, EditOutlined, EyeOutlined, EyeInvisibleOutlined, DownOutlined, MinusCircleOutlined } from '@ant-design/icons';
import { useParams, useRequest, history, useRouteMatch } from 'umi';
import { queryCourseView } from '@/pages/course/option/service';
import { queryQuestionById, queryQuestionList, queryQuestionType } from '@/pages/questionbank/service';
import ProForm, { ProFormSelect } from '@ant-design/pro-form';
import ProTable, { ActionType, ProColumns } from '@ant-design/pro-table';
//const { Paragraph } = Typography;
const formItemLayout = {
labelCol: {
xs: { span: 24 },
sm: { span: 4 },
},
wrapperCol: {
xs: { span: 24 },
sm: { span: 20 },
},
};
const formItemLayoutWithOutLabel = {
wrapperCol: {
xs: { span: 24, offset: 0 },
sm: { span: 20, offset: 4 },
},
};
console.log('first');
const AnswersSelector = () => {
return (
<Form.List
name="names"
rules={[
{
validator: async (_, names) => {
if (!names || names.length < 2) {
return Promise.reject(new Error('At least 2 passengers'));
}
},
},
]}
>
{(fields, { add, remove }, { errors }) => (
<>
{fields.map((field, index) => (
<Form.Item
{...(index === 0 ? formItemLayout : formItemLayoutWithOutLabel)}
label={index === 0 ? 'Passengers' : ''}
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.",
},
]}
noStyle
>
<Input placeholder="passenger name" style={{ width: '100%' }} />
</Form.Item>
{fields.length > 1 ? (
<MinusCircleOutlined
className="dynamic-delete-button"
onClick={() => remove(field.name)}
/>
) : null}
</Form.Item>
))}
<Form.Item>
<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' }}
icon={<PlusOutlined />}
>
Add field at head
</Button>
<Form.ErrorList errors={errors} />
</Form.Item>
</>
)}
</Form.List>
);
};
export default AnswersSelector;

@ -1,6 +1,6 @@
/** 资质考试 */
//import { AlignLeftOutlined, PlusOutlined } from '@ant-design/icons';
import { Switch, Button, Card, Col, List, Menu, Progress, Row, Typography, Space, Divider, Radio, Checkbox, Tag, Dropdown, Upload, Modal, Form } from 'antd';
import { Switch, Button, Card, Col, List, Menu, Progress, Row, Typography, Space, Divider, Radio, Checkbox, Tag, Dropdown, Upload, Modal, Form, Input } from 'antd';
import { PageContainer } from '@ant-design/pro-layout';
//import { useRequest } from 'umi';
//import { queryFakeList } from './service';
@ -10,7 +10,7 @@ import styles from './style.less';
//import ProCard from '@ant-design/pro-card';
import ProList from '@ant-design/pro-list';
import { ReactText, useEffect, useRef, useState } from 'react';
import { PlusOutlined, DeleteOutlined, DownloadOutlined, UploadOutlined, EditOutlined, EyeOutlined, EyeInvisibleOutlined, DownOutlined } from '@ant-design/icons';
import { PlusOutlined, DeleteOutlined, DownloadOutlined, UploadOutlined, EditOutlined, EyeOutlined, EyeInvisibleOutlined, DownOutlined, UserOutlined } from '@ant-design/icons';
import { exportQuestionTemplate, queryQuestionById, queryQuestionList, queryQuestionType } from './service';
import { useParams, useRequest, history, useRouteMatch } from 'umi';
import { queryCourseListByTag, queryCourseView, queryTagList } from '@/pages/course/option/service';
@ -19,8 +19,10 @@ import { DataItem } from '../dashboard/analysis/data';
import { ActionType, ProColumns } from '@ant-design/pro-table';
import ProFormRichEdit from '../course/subject/components/ProFormRichEdit';
import { TableListItem } from '../course/option/data';
import AnswersSelector from './components/AnswersEditor';
//const { Paragraph } = Typography;
const labels = ['A','B','C','D','E','F','G','H','I','J','K'];
const parsingMap = new Map()
console.log('first');
const QuestionBank = () => {
@ -114,32 +116,7 @@ const QuestionBank = () => {
hideInForm: false,
hideInSearch: true,
renderFormItem: (item, { defaultRender, ...rest }, form) => (
<ProFormList
name={undefined}
//children={}
initialValue={[
{
name: '1111',
},
]}
creatorButtonProps={{
position: 'bottom',
creatorButtonText: '添加选项',
}}
creatorRecord={{
useMode: 'none',
}}
itemContainerRender={(doms) => {
return <ProForm.Group>{doms}</ProForm.Group>;
}}
>
{(f, index, action) => {
console.log(f, index, action);
return (
<ProFormText name="name" label="A" />
)
}}
</ProFormList>
<AnswersSelector />
)
/*
formItemProps: {
@ -161,7 +138,7 @@ const QuestionBank = () => {
hideInSearch: true,
renderFormItem: (item, { defaultRender, ...rest }, form) => (
<ProFormList
name={undefined}
name='answertrue'
children={undefined}
creatorButtonProps={false}
creatorRecord={{
@ -221,7 +198,7 @@ const QuestionBank = () => {
const [expandedDescRowKeys, setExpandedDescRowKeys] = useState<readonly ReactText[]>([]); // 展开解析设置
const [addType, setAddType] = useState({name: '', value: 0});
const labels = ['A','B','C','D','E']
/** 获取题型 */
const { data } = useRequest(() => {

@ -19,5 +19,25 @@
display: inline-block;
width: 100%;
}
.ant-input-group-addon{
min-width: 40px;
}
.dynamic-delete-button {
position: relative;
top: 4px;
margin: 0 8px;
color: #999;
font-size: 24px;
cursor: pointer;
transition: all 0.3s;
}
.dynamic-delete-button:hover {
color: #777;
}
.dynamic-delete-button[disabled] {
cursor: not-allowed;
opacity: 0.5;
}
}
}

@ -5,6 +5,9 @@ import defaultSettings from './defaultSettings';
import proxy from './proxy';
const { REACT_APP_ENV } = process.env;
export default defineConfig({
history: {
type: 'hash'
},
hash: true,
antd: {},
dva: {

Loading…
Cancel
Save