|
@@ -5,9 +5,9 @@ import queryString from 'query-string';
|
|
import { connect } from 'dva';
|
|
import { connect } from 'dva';
|
|
import { Spin, Popover, Badge, Table, Radio, Card, Form, Input, Icon, Button, Select } from 'antd';
|
|
import { Spin, Popover, Badge, Table, Radio, Card, Form, Input, Icon, Button, Select } from 'antd';
|
|
import PageHeaderLayout from '../../../layouts/PageHeaderLayout';
|
|
import PageHeaderLayout from '../../../layouts/PageHeaderLayout';
|
|
-import LessonSelectSortModal from './lessonModal';
|
|
|
|
-import ResourceSelectModal from './resourceModal';
|
|
|
|
-import SupportSelectSortModal from './supportModal';
|
|
|
|
|
|
+import LessonSelectSortModal from './lesson';
|
|
|
|
+import ResourceSelectModal from './resource';
|
|
|
|
+import SupportSelectSortModal from './support';
|
|
import { Codes } from '../../../utils/config';
|
|
import { Codes } from '../../../utils/config';
|
|
|
|
|
|
const FormItem = Form.Item;
|
|
const FormItem = Form.Item;
|
|
@@ -21,12 +21,25 @@ const { TextArea } = Input;
|
|
resource: state.resource,
|
|
resource: state.resource,
|
|
lesson: state.lesson,
|
|
lesson: state.lesson,
|
|
support: state.support,
|
|
support: state.support,
|
|
|
|
+ merchant: state.merchant,
|
|
}))
|
|
}))
|
|
export default class CourseDetail extends PureComponent {
|
|
export default class CourseDetail extends PureComponent {
|
|
state = {
|
|
state = {
|
|
curClickedBtn: null, //记录点击的按钮
|
|
curClickedBtn: null, //记录点击的按钮
|
|
};
|
|
};
|
|
|
|
|
|
|
|
+ componentDidMount() {
|
|
|
|
+ const { dispatch } = this.props;
|
|
|
|
+ dispatch({
|
|
|
|
+ type: 'merchant/query',
|
|
|
|
+ payload: {
|
|
|
|
+ pageSize: 1000,
|
|
|
|
+ pageNo: 1,
|
|
|
|
+ domain: Codes.CODE_CP,
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+
|
|
// 展示选择模态框 - 加载第一页数据
|
|
// 展示选择模态框 - 加载第一页数据
|
|
handleModalShow = (btnName) => {
|
|
handleModalShow = (btnName) => {
|
|
this.setState({
|
|
this.setState({
|
|
@@ -88,17 +101,17 @@ export default class CourseDetail extends PureComponent {
|
|
if (curClickedBtn === 'lessonBtn') {
|
|
if (curClickedBtn === 'lessonBtn') {
|
|
dispatch({
|
|
dispatch({
|
|
type: 'courseDetail/saveLessonList',
|
|
type: 'courseDetail/saveLessonList',
|
|
- payload: { lessonList: data }
|
|
|
|
|
|
+ payload: { subItemList: data }
|
|
});
|
|
});
|
|
} else if (curClickedBtn === 'cvImgBtn') {
|
|
} else if (curClickedBtn === 'cvImgBtn') {
|
|
dispatch({
|
|
dispatch({
|
|
type: 'courseDetail/saveCoverImg',
|
|
type: 'courseDetail/saveCoverImg',
|
|
- payload: { cvImg: data },
|
|
|
|
|
|
+ payload: { coverUrl: data.url },
|
|
});
|
|
});
|
|
} else if (curClickedBtn === 'bgImgBtn') {
|
|
} else if (curClickedBtn === 'bgImgBtn') {
|
|
dispatch({
|
|
dispatch({
|
|
type: 'courseDetail/saveBackgroundImg',
|
|
type: 'courseDetail/saveBackgroundImg',
|
|
- payload: { bgImg: data },
|
|
|
|
|
|
+ payload: { bgUrl: data.url },
|
|
});
|
|
});
|
|
} else if (curClickedBtn === 'supportBtn') {
|
|
} else if (curClickedBtn === 'supportBtn') {
|
|
dispatch({
|
|
dispatch({
|
|
@@ -183,10 +196,33 @@ export default class CourseDetail extends PureComponent {
|
|
} = this.props;
|
|
} = this.props;
|
|
validateFields((errors) => {
|
|
validateFields((errors) => {
|
|
if (errors) { return; }
|
|
if (errors) { return; }
|
|
|
|
+
|
|
|
|
+ // 过滤掉gmtCreated, gmtModified, status三个字段
|
|
|
|
+ const { subItemList, supportList, gmtCreated, gmtModified, status, ...rest } = currentItem;
|
|
|
|
+ let newSubItemList;
|
|
|
|
+ let newSupportList;
|
|
|
|
+ // 如果subItemList是个list且内容不为空
|
|
|
|
+ if (Array.isArray(subItemList) && subItemList.length) {
|
|
|
|
+ newSubItemList = subItemList.map(item => ({ id: item.id, type: Codes.CODE_LESSON }));
|
|
|
|
+ } else {
|
|
|
|
+ newSubItemList = [];
|
|
|
|
+ }
|
|
|
|
+ // 如果supportList是个list且内容不为空
|
|
|
|
+ if (Array.isArray(supportList) && supportList.length) {
|
|
|
|
+ newSupportList = supportList.map(item => ({ id: item.id, type: Codes.CODE_SUPPORT}));
|
|
|
|
+ } else {
|
|
|
|
+ newSupportList = [];
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 最终要提交的数据
|
|
const data = {
|
|
const data = {
|
|
- ...currentItem,
|
|
|
|
|
|
+ ...rest,
|
|
...getFieldsValue(),
|
|
...getFieldsValue(),
|
|
|
|
+ subItemList: newSubItemList,
|
|
|
|
+ supportList: newSupportList,
|
|
};
|
|
};
|
|
|
|
+
|
|
|
|
+ // 操作成功要返回列表页,同时要保持列表页的过滤数据
|
|
dispatch({
|
|
dispatch({
|
|
type: `courseDetail/${operType}`,
|
|
type: `courseDetail/${operType}`,
|
|
payload: data,
|
|
payload: data,
|
|
@@ -205,7 +241,6 @@ export default class CourseDetail extends PureComponent {
|
|
|
|
|
|
handlePageCancel = () => {
|
|
handlePageCancel = () => {
|
|
const { dispatch, courseDetail: { filters } } = this.props;
|
|
const { dispatch, courseDetail: { filters } } = this.props;
|
|
- dispatch({ type: 'courseDetail/clearPage' });
|
|
|
|
dispatch(
|
|
dispatch(
|
|
routerRedux.push({
|
|
routerRedux.push({
|
|
pathname: '/product/course',
|
|
pathname: '/product/course',
|
|
@@ -215,9 +250,36 @@ export default class CourseDetail extends PureComponent {
|
|
}
|
|
}
|
|
|
|
|
|
render() {
|
|
render() {
|
|
- const { dispatch, form: { getFieldDecorator }, courseDetail, lesson, resource, support } = this.props;
|
|
|
|
- const { itemLoading, currentItem, filters, lessonModalVisible, supportModalVisible, resourceModalVisible } = courseDetail;
|
|
|
|
- const { lessonList = [], supportList = [], name, code, digest, cvImg = {}, bgImg = {} } = currentItem;
|
|
|
|
|
|
+ const {
|
|
|
|
+ dispatch,
|
|
|
|
+ courseDetail,
|
|
|
|
+ lesson,
|
|
|
|
+ resource,
|
|
|
|
+ support,
|
|
|
|
+ merchant,
|
|
|
|
+ form: {
|
|
|
|
+ getFieldDecorator
|
|
|
|
+ },
|
|
|
|
+ } = this.props;
|
|
|
|
+ const {
|
|
|
|
+ itemLoading,
|
|
|
|
+ currentItem,
|
|
|
|
+ filters,
|
|
|
|
+ lessonModalVisible,
|
|
|
|
+ supportModalVisible,
|
|
|
|
+ resourceModalVisible
|
|
|
|
+ } = courseDetail;
|
|
|
|
+ const {
|
|
|
|
+ name,
|
|
|
|
+ code,
|
|
|
|
+ digest,
|
|
|
|
+ detail,
|
|
|
|
+ cpId,
|
|
|
|
+ coverUrl,
|
|
|
|
+ bgUrl,
|
|
|
|
+ subItemList = [],
|
|
|
|
+ supportList = [],
|
|
|
|
+ } = currentItem;
|
|
|
|
|
|
// 待选表格去掉分页的跳转及变换页码
|
|
// 待选表格去掉分页的跳转及变换页码
|
|
if (resource && resource.pagination) {
|
|
if (resource && resource.pagination) {
|
|
@@ -277,34 +339,46 @@ export default class CourseDetail extends PureComponent {
|
|
initialValue: name,
|
|
initialValue: name,
|
|
})(<Input />)}
|
|
})(<Input />)}
|
|
</FormItem>
|
|
</FormItem>
|
|
- <FormItem label="课程简述:" hasFeedback {...formItemLayout}>
|
|
|
|
|
|
+ <FormItem label="课程概要:" hasFeedback {...formItemLayout}>
|
|
{getFieldDecorator('digest', {
|
|
{getFieldDecorator('digest', {
|
|
initialValue: digest,
|
|
initialValue: digest,
|
|
})(<TextArea />)}
|
|
})(<TextArea />)}
|
|
</FormItem>
|
|
</FormItem>
|
|
|
|
+ <FormItem label="课程详情:" hasFeedback {...formItemLayout}>
|
|
|
|
+ {getFieldDecorator('detail', {
|
|
|
|
+ initialValue: detail,
|
|
|
|
+ })(<TextArea />)}
|
|
|
|
+ </FormItem>
|
|
|
|
+ <FormItem label="所属供应商:" {...formItemLayout}>
|
|
|
|
+ {getFieldDecorator('cpId', {
|
|
|
|
+ initialValue: cpId,
|
|
|
|
+ })(
|
|
|
|
+ <Select placeholder="请选择">{merchant.list.map(item => <Option value={item.id} key={item.id}>{item.name}</Option>)}</Select>
|
|
|
|
+ )}
|
|
|
|
+ </FormItem>
|
|
<FormItem label="封面图片" {...formItemLayout}>
|
|
<FormItem label="封面图片" {...formItemLayout}>
|
|
<Button onClick={() => this.handleModalShow('cvImgBtn')} type="primary" icon="select" size="small">选择</Button>
|
|
<Button onClick={() => this.handleModalShow('cvImgBtn')} type="primary" icon="select" size="small">选择</Button>
|
|
- {cvImg.url === undefined ? null :
|
|
|
|
|
|
+ {coverUrl === undefined ? null :
|
|
<Card
|
|
<Card
|
|
hoverable
|
|
hoverable
|
|
bordered
|
|
bordered
|
|
- cover={<img alt="图片加载失败" src={cvImg.url} />}
|
|
|
|
|
|
+ cover={<img alt="" src={coverUrl} />}
|
|
style={{ width: 240, marginTop: 20 }}
|
|
style={{ width: 240, marginTop: 20 }}
|
|
>
|
|
>
|
|
</Card>}
|
|
</Card>}
|
|
</FormItem>
|
|
</FormItem>
|
|
<FormItem label="背景图片" {...formItemLayout}>
|
|
<FormItem label="背景图片" {...formItemLayout}>
|
|
<Button onClick={() => this.handleModalShow('bgImgBtn')} type="primary" icon="select" size="small">选择</Button>
|
|
<Button onClick={() => this.handleModalShow('bgImgBtn')} type="primary" icon="select" size="small">选择</Button>
|
|
- {bgImg.url === undefined ? null :
|
|
|
|
|
|
+ {bgUrl === undefined ? null :
|
|
<Card
|
|
<Card
|
|
hoverable
|
|
hoverable
|
|
bordered
|
|
bordered
|
|
- cover={<img alt="图片加载失败" src={bgImg.url} />}
|
|
|
|
|
|
+ cover={<img alt="" src={bgUrl} />}
|
|
style={{ width: 240, marginTop: 20 }}
|
|
style={{ width: 240, marginTop: 20 }}
|
|
>
|
|
>
|
|
</Card>}
|
|
</Card>}
|
|
</FormItem>
|
|
</FormItem>
|
|
- <FormItem label="选择课" {...formItemLayout}>
|
|
|
|
|
|
+ <FormItem label="相关课" {...formItemLayout}>
|
|
<Button onClick={() => this.handleModalShow('lessonBtn')} type="primary" size="small" icon="edit">编辑</Button>
|
|
<Button onClick={() => this.handleModalShow('lessonBtn')} type="primary" size="small" icon="edit">编辑</Button>
|
|
</FormItem>
|
|
</FormItem>
|
|
<FormItem wrapperCol={{ offset: 7, span: 12 }}>
|
|
<FormItem wrapperCol={{ offset: 7, span: 12 }}>
|
|
@@ -313,7 +387,7 @@ export default class CourseDetail extends PureComponent {
|
|
emptyText: <span style={{ color: "#C6D0D6" }}> <Icon type="frown-o"/>
|
|
emptyText: <span style={{ color: "#C6D0D6" }}> <Icon type="frown-o"/>
|
|
该课程下不包含任何课,请选择!</span>
|
|
该课程下不包含任何课,请选择!</span>
|
|
}}
|
|
}}
|
|
- dataSource={lessonList}
|
|
|
|
|
|
+ dataSource={subItemList}
|
|
columns={lessonTableColumns}
|
|
columns={lessonTableColumns}
|
|
rowKey={record => record.id}
|
|
rowKey={record => record.id}
|
|
bordered
|
|
bordered
|
|
@@ -350,7 +424,7 @@ export default class CourseDetail extends PureComponent {
|
|
onCancel={this.handleModalCancel}
|
|
onCancel={this.handleModalCancel}
|
|
onOk={this.handleModalOk}
|
|
onOk={this.handleModalOk}
|
|
onSearch={this.handleModalSearch}
|
|
onSearch={this.handleModalSearch}
|
|
- selTableData={lessonList}
|
|
|
|
|
|
+ selTableData={subItemList || []}
|
|
fsTableDataSource={lesson.list || []}
|
|
fsTableDataSource={lesson.list || []}
|
|
fsTableLoading={lesson.listLoading}
|
|
fsTableLoading={lesson.listLoading}
|
|
fsTablePagination={lesson.pagination}
|
|
fsTablePagination={lesson.pagination}
|
|
@@ -379,7 +453,7 @@ export default class CourseDetail extends PureComponent {
|
|
onCancel={this.handleModalCancel}
|
|
onCancel={this.handleModalCancel}
|
|
onOk={this.handleModalOk}
|
|
onOk={this.handleModalOk}
|
|
onSearch={this.handleModalSearch}
|
|
onSearch={this.handleModalSearch}
|
|
- selTableData={supportList}
|
|
|
|
|
|
+ selTableData={supportList || []}
|
|
fsTableDataSource={support.list || []}
|
|
fsTableDataSource={support.list || []}
|
|
fsTableLoading={support.listLoading}
|
|
fsTableLoading={support.listLoading}
|
|
fsTablePagination={support.pagination}
|
|
fsTablePagination={support.pagination}
|