线上课编辑页面上架时间优化

This commit is contained in:
unknown 2023-09-06 09:42:06 +08:00
parent 780e73c029
commit fc9682c31d
3 changed files with 15 additions and 14 deletions

View File

@ -695,7 +695,7 @@ export const CourseCreate: React.FC<PropInterface> = ({
form.setFieldsValue({ thumb: url }); form.setFieldsValue({ thumb: url });
}} }}
></UploadImageButton> ></UploadImageButton>
<span className="helper-text ml-16"> <span className="helper-text ml-8">
推荐尺寸:400x300px 推荐尺寸:400x300px
</span> </span>
</div> </div>

View File

@ -96,8 +96,8 @@ export const CourseUpdate: React.FC<PropInterface> = ({
type: type, type: type,
short_desc: res.data.course.short_desc, short_desc: res.data.course.short_desc,
hasChapter: chapterType, hasChapter: chapterType,
published_at: res.data.published_at published_at: res.data.course.published_at
? dayjs(res.data.published_at, "YYYY-MM-DD HH:mm:ss") ? dayjs(res.data.course.published_at, "YYYY-MM-DD HH:mm:ss")
: "", : "",
}); });
setType(type); setType(type);
@ -188,6 +188,10 @@ export const CourseUpdate: React.FC<PropInterface> = ({
setType(e.target.value); setType(e.target.value);
}; };
const disabledDate = (current: any) => {
return current && current >= moment().add(0, "days"); // 选择时间要大于等于当前天。若今天不能被选择,去掉等号即可。
};
return ( return (
<> <>
{open ? ( {open ? (
@ -388,7 +392,7 @@ export const CourseUpdate: React.FC<PropInterface> = ({
form.setFieldsValue({ thumb: url }); form.setFieldsValue({ thumb: url });
}} }}
></UploadImageButton> ></UploadImageButton>
<span className="helper-text ml-16"> <span className="helper-text ml-8">
推荐尺寸:400x300px 推荐尺寸:400x300px
</span> </span>
</div> </div>
@ -403,22 +407,19 @@ export const CourseUpdate: React.FC<PropInterface> = ({
maxLength={200} maxLength={200}
/> />
</Form.Item> </Form.Item>
<Form.Item label="上架时间" required={true}> <Form.Item label="上架时间">
<Space align="baseline" style={{ height: 32 }}> <Space align="baseline" style={{ height: 32 }}>
<Form.Item <Form.Item name="published_at">
name="published_at"
rules={[{ required: true, message: "请选择上架时间!" }]}
>
<DatePicker <DatePicker
disabledDate={disabledDate}
format="YYYY-MM-DD HH:mm:ss" format="YYYY-MM-DD HH:mm:ss"
style={{ width: 240 }} style={{ width: 240 }}
showTime showTime
placeholder="请选择上架时间" placeholder="请选择上架时间"
/> />
</Form.Item> </Form.Item>
<div className="helper-text">
<div className="helper-text ml-24">
</div> </div>
</Space> </Space>
</Form.Item> </Form.Item>

View File

@ -200,8 +200,8 @@ const CoursePage = () => {
), ),
}, },
{ {
title: "创建时间", title: "上架时间",
dataIndex: "created_at", dataIndex: "published_at",
render: (text: string) => <span>{dateFormat(text)}</span>, render: (text: string) => <span>{dateFormat(text)}</span>,
}, },
{ {