|
@@ -22,6 +22,7 @@ import locale from 'antd/es/date-picker/locale/zh_CN';
|
|
|
import { useTranslation } from 'react-i18next';
|
|
|
|
|
|
const { TextArea } = Input;
|
|
|
+const { t, i18n } = useTranslation();
|
|
|
|
|
|
const layout = {
|
|
|
labelCol: {
|
|
@@ -32,9 +33,8 @@ const layout = {
|
|
|
},
|
|
|
};
|
|
|
|
|
|
-/* eslint-disable no-template-curly-in-string */
|
|
|
const validateMessages = {
|
|
|
- required: '${label}是必填项!',
|
|
|
+ required: t('${label}是必填项!'),
|
|
|
types: {
|
|
|
email: '${label} is not a valid email!',
|
|
|
number: '${label} is not a valid number!',
|
|
@@ -43,7 +43,6 @@ const validateMessages = {
|
|
|
range: '${label} must be between ${min} and ${max}',
|
|
|
},
|
|
|
};
|
|
|
-/* eslint-enable no-template-curly-in-string */
|
|
|
|
|
|
const getBase64 = (file) =>
|
|
|
new Promise((resolve, reject) => {
|
|
@@ -75,7 +74,6 @@ function CreateCourse(param) {
|
|
|
const [previewTitle, setPreviewTitle] = useState('');
|
|
|
const [loading, setLoading] = useState(false);
|
|
|
const [imageUrl, setImageUrl] = useState();
|
|
|
- const { t, i18n } = useTranslation();
|
|
|
|
|
|
let assistantsSearchTimer;
|
|
|
let currentAssistantsValue;
|
|
@@ -140,7 +138,7 @@ function CreateCourse(param) {
|
|
|
];
|
|
|
setFileList(newFileList);
|
|
|
} else {
|
|
|
- message.error('请选择jpg、jpeg、png的图片上传');
|
|
|
+ message.error(t('请选择jpg、jpeg、png的图片上传'));
|
|
|
}
|
|
|
return false;
|
|
|
};
|
|
@@ -180,14 +178,14 @@ function CreateCourse(param) {
|
|
|
if (result.result) {
|
|
|
onRequestClose();
|
|
|
} else {
|
|
|
- message.error('编辑失败');
|
|
|
+ message.error(toolbar(t('编辑失败')));
|
|
|
}
|
|
|
} else {
|
|
|
result = await coursesAPI.createCourseAsync(values.course);
|
|
|
if (result.result) {
|
|
|
onRequestClose();
|
|
|
} else {
|
|
|
- message.error('创建失败');
|
|
|
+ message.error(t('创建失败'));
|
|
|
}
|
|
|
}
|
|
|
};
|
|
@@ -197,7 +195,7 @@ function CreateCourse(param) {
|
|
|
return Promise.resolve();
|
|
|
}
|
|
|
|
|
|
- return Promise.reject(new Error('价格不得小于0元,且最多小数点后两位'));
|
|
|
+ return Promise.reject(new Error(t('价格不得小于0元,且最多小数点后两位')));
|
|
|
};
|
|
|
|
|
|
const uploadButton = (
|
|
@@ -488,23 +486,23 @@ function CreateCourse(param) {
|
|
|
<Col className='gutter-row' span={12}>
|
|
|
<Form.Item
|
|
|
name={['course', 'Name']}
|
|
|
- label='名称'
|
|
|
+ label={t('名称')}
|
|
|
rules={[
|
|
|
{
|
|
|
required: true,
|
|
|
},
|
|
|
{
|
|
|
pattern: /^\S+$/,
|
|
|
- message: '名称不能包含空格',
|
|
|
+ message: t('名称不能包含空格'),
|
|
|
},
|
|
|
]}>
|
|
|
- <Input placeholder='请输入名称' maxLength={40} />
|
|
|
+ <Input placeholder={t('请输入名称')} maxLength={40} />
|
|
|
</Form.Item>
|
|
|
</Col>
|
|
|
<Col className='gutter-row' span={12}>
|
|
|
<Form.Item
|
|
|
name={['course', 'CourseType']}
|
|
|
- label='课程分类'
|
|
|
+ label={t('课程分类')}
|
|
|
rules={[
|
|
|
{
|
|
|
required: true,
|
|
@@ -512,10 +510,10 @@ function CreateCourse(param) {
|
|
|
]}>
|
|
|
<Select
|
|
|
allowClear
|
|
|
- placeholder='请选择'
|
|
|
+ placeholder={t('请选择')}
|
|
|
options={[
|
|
|
- { value: 1, label: '直播课程' },
|
|
|
- { value: 2, label: '多媒体课程' },
|
|
|
+ { value: 1, label: t('直播课程') },
|
|
|
+ { value: 2, label: t('多媒体课程') },
|
|
|
]}
|
|
|
onChange={changeCourseType}
|
|
|
/>
|
|
@@ -523,7 +521,9 @@ function CreateCourse(param) {
|
|
|
</Col>
|
|
|
{isShowSmallClass && (
|
|
|
<Col className='gutter-row' span={12}>
|
|
|
- <Form.Item name={['course', 'IsSmallClass']} label='是否小班化'>
|
|
|
+ <Form.Item
|
|
|
+ name={['course', 'IsSmallClass']}
|
|
|
+ label={t('是否小班化')}>
|
|
|
<Radio.Group onChange={changeIsSmallClass} defaultValue={false}>
|
|
|
<Radio value={true}> {t('是')} </Radio>
|
|
|
<Radio value={false}> {t('否')} </Radio>
|
|
@@ -535,14 +535,14 @@ function CreateCourse(param) {
|
|
|
<Col className='gutter-row' span={12}>
|
|
|
<Form.Item
|
|
|
name={['course', 'StartTime']}
|
|
|
- label='开始时间'
|
|
|
+ label={t('开始时间')}
|
|
|
rules={[
|
|
|
{
|
|
|
required: true,
|
|
|
},
|
|
|
]}>
|
|
|
<DatePicker
|
|
|
- placeholder='请选择'
|
|
|
+ placeholder={t('请选择')}
|
|
|
locale={locale}
|
|
|
disabledDate={disabledDate}
|
|
|
disabledTime={disabledTime}
|
|
@@ -576,11 +576,13 @@ function CreateCourse(param) {
|
|
|
</Col>
|
|
|
)}
|
|
|
<Col className='gutter-row' span={12}>
|
|
|
- <Form.Item name={['course', 'CourseLabelCodes']} label='课程标签'>
|
|
|
+ <Form.Item
|
|
|
+ name={['course', 'CourseLabelCodes']}
|
|
|
+ label={t('课程标签')}>
|
|
|
<Select
|
|
|
allowClear
|
|
|
mode='multiple'
|
|
|
- placeholder='请选择'
|
|
|
+ placeholder={t('请选择')}
|
|
|
options={courseListData}
|
|
|
filterOption={(input, option) =>
|
|
|
(option?.label ?? '')
|
|
@@ -593,7 +595,7 @@ function CreateCourse(param) {
|
|
|
<Col className='gutter-row' span={12}>
|
|
|
<Form.Item
|
|
|
name={['course', 'AudienceType']}
|
|
|
- label='课程规模'
|
|
|
+ label={t('课程规模')}
|
|
|
rules={[
|
|
|
{
|
|
|
required: true,
|
|
@@ -601,10 +603,10 @@ function CreateCourse(param) {
|
|
|
]}>
|
|
|
<Select
|
|
|
allowClear
|
|
|
- placeholder='请选择'
|
|
|
+ placeholder={t('请选择')}
|
|
|
options={[
|
|
|
- { value: 1, label: '公开课' },
|
|
|
- { value: 2, label: '私有课' },
|
|
|
+ { value: 1, label: t('公开课') },
|
|
|
+ { value: 2, label: t('私有课') },
|
|
|
]}
|
|
|
onChange={changeAudienceType}
|
|
|
/>
|
|
@@ -612,40 +614,42 @@ function CreateCourse(param) {
|
|
|
</Col>
|
|
|
{isShowClassManagement && (
|
|
|
<Col className='gutter-row' span={12}>
|
|
|
- <Form.Item name={['course', 'UserGroupCodes']} label='班级管理'>
|
|
|
+ <Form.Item
|
|
|
+ name={['course', 'UserGroupCodes']}
|
|
|
+ label={t('班级管理')}>
|
|
|
<Select
|
|
|
allowClear
|
|
|
mode='multiple'
|
|
|
options={classManagementListData}
|
|
|
- placeholder='请选择'
|
|
|
+ placeholder={t('请选择')}
|
|
|
/>
|
|
|
</Form.Item>
|
|
|
</Col>
|
|
|
)}
|
|
|
{isShowAssistantParticipants && (
|
|
|
<Col className='gutter-row' span={12}>
|
|
|
- <Form.Item name={['course', 'Assistants']} label='助教'>
|
|
|
+ <Form.Item name={['course', 'Assistants']} label={t('助教')}>
|
|
|
<Select
|
|
|
allowClear
|
|
|
showSearch={true}
|
|
|
filterOption={false}
|
|
|
options={assistantsListData}
|
|
|
onSearch={handleSearchAssistants}
|
|
|
- placeholder='请选择'
|
|
|
+ placeholder={t('请选择')}
|
|
|
/>
|
|
|
</Form.Item>
|
|
|
</Col>
|
|
|
)}{' '}
|
|
|
{isShowAssistantParticipants && (
|
|
|
<Col className='gutter-row' span={12}>
|
|
|
- <Form.Item name={['course', 'Experts']} label='参会者'>
|
|
|
+ <Form.Item name={['course', 'Experts']} label={t('参会者')}>
|
|
|
<Select
|
|
|
allowClear
|
|
|
mode='multiple'
|
|
|
filterOption={false}
|
|
|
options={expertsListData}
|
|
|
onSearch={handleSearchAttendees}
|
|
|
- placeholder='请选择'
|
|
|
+ placeholder={t('请选择')}
|
|
|
/>
|
|
|
</Form.Item>
|
|
|
</Col>
|
|
@@ -653,7 +657,7 @@ function CreateCourse(param) {
|
|
|
<Col className='gutter-row' span={12}>
|
|
|
<Form.Item
|
|
|
name={['course', 'Price']}
|
|
|
- label='课程价格(元)'
|
|
|
+ label={t('课程价格(元)')}
|
|
|
rules={[
|
|
|
{
|
|
|
validator: validatePrice,
|
|
@@ -675,11 +679,13 @@ function CreateCourse(param) {
|
|
|
</Form.Item>
|
|
|
</Col>
|
|
|
<Col className='gutter-row' span={12}>
|
|
|
- <Form.Item name={['course', 'CourseAlbumCodes']} label='关联专辑'>
|
|
|
+ <Form.Item
|
|
|
+ name={['course', 'CourseAlbumCodes']}
|
|
|
+ label={t('关联专辑')}>
|
|
|
<Select
|
|
|
showSearch
|
|
|
mode='multiple'
|
|
|
- placeholder='请选择'
|
|
|
+ placeholder={t('请选择')}
|
|
|
optionFilterProp='children'
|
|
|
filterOption={(input, option) =>
|
|
|
(option?.label ?? '').includes(input)
|
|
@@ -697,7 +703,7 @@ function CreateCourse(param) {
|
|
|
<Col className='gutter-row' span={12}>
|
|
|
<Form.Item
|
|
|
name={['course', 'CourseVideoCodes']}
|
|
|
- label='课程源'
|
|
|
+ label={t('课程源')}
|
|
|
rules={[
|
|
|
{
|
|
|
required: true,
|
|
@@ -705,7 +711,7 @@ function CreateCourse(param) {
|
|
|
]}>
|
|
|
<Select
|
|
|
showSearch
|
|
|
- placeholder='请选择'
|
|
|
+ placeholder={t('请选择')}
|
|
|
optionFilterProp='children'
|
|
|
onChange={onChange}
|
|
|
onSearch={onSearch}
|
|
@@ -720,10 +726,10 @@ function CreateCourse(param) {
|
|
|
</Col>
|
|
|
)}
|
|
|
<Col className='gutter-row' span={12}>
|
|
|
- <Form.Item name={['course', 'CourseMaterialCodes']} label='资料'>
|
|
|
+ <Form.Item name={['course', 'CourseMaterialCodes']} label={t('资料')}>
|
|
|
<Select
|
|
|
showSearch
|
|
|
- placeholder='请选择'
|
|
|
+ placeholder={t('请选择')}
|
|
|
mode='multiple'
|
|
|
optionFilterProp='children'
|
|
|
onChange={onChange}
|
|
@@ -740,16 +746,16 @@ function CreateCourse(param) {
|
|
|
<Col className='gutter-row' span={24}>
|
|
|
<Form.Item
|
|
|
name={['course', 'CourseIntro']}
|
|
|
- label='课程描述'
|
|
|
+ label={t('课程描述')}
|
|
|
labelCol={{ span: 4 }}
|
|
|
rules={[{}]}>
|
|
|
- <TextArea rows={4} placeholder='请输入' maxLength={100} />
|
|
|
+ <TextArea rows={4} placeholder={t('请输入')} maxLength={100} />
|
|
|
</Form.Item>
|
|
|
</Col>
|
|
|
<Col className='gutter-row' span={24}>
|
|
|
<Form.Item
|
|
|
name={['course', 'Cover']}
|
|
|
- label='封面'
|
|
|
+ label={t('封面')}
|
|
|
style={{ height: '102px' }}
|
|
|
labelCol={{ span: 4 }}>
|
|
|
<ImgCrop aspect={16 / 9} quality={1}>
|