Commit 2ee1f46e authored by wangxuelai's avatar wangxuelai

''

parent 09644546
......@@ -327,6 +327,20 @@ export default {
});
}
},
* uEditorChange({ payload }, { call, put, select }) {
const { value } = payload;
const { addCourseObj } = yield select(state => state.coursegatherdetail);
addCourseObj.intro = [{
type: 'editor',
value,
}];
yield put({
type: 'updateState',
payload: {
addCourseObj: { ...addCourseObj },
},
});
},
* getGatherDetail({ payload }, { call, put, select }) {
const { id, addCourseObj } = yield select(state => state.coursegatherdetail);
const loading = message.loading('数据加载中...', 0);
......@@ -336,6 +350,36 @@ export default {
setTimeout(loading);
const { data, msg, code } = detaildata;
if (code == 200) {
let intro = [];
if (data.intro) {
try {
const newIntro = JSON.parse(data.intro);
if (newIntro.length == 1 && newIntro[0].value == '') {
intro = [
{
type: 'editor',
value: '',
},
];
} else {
intro = newIntro;
}
} catch (e) {
intro = [
{
type: 'editor',
value: '',
},
];
}
} else {
intro = [
{
type: 'editor',
value: '',
},
];
}
yield put({
type: 'updateState',
payload: {
......@@ -347,7 +391,7 @@ export default {
charge_type: data.charge_type,
created_at: data.created_at,
type: data.type,
intro: data.intro && data.intro != null ? JSON.parse(data.intro) : addCourseObj.intro,
intro: JSON.parse(JSON.stringify(intro)),
remark: data.remark,
study_count: data.study_count,
status: data.status,
......@@ -460,6 +504,10 @@ export default {
start_time: null,
cover: '',
content: '',
intro: [{
type: 'editor',
value: '',
}],
},
saveSingleCourseSubmitting: false,
coursewareSubmitting: false,
......@@ -1581,6 +1629,7 @@ export default {
...value,
id,
content: editSingleCourseInfo.content ? JSON.stringify(editSingleCourseInfo.content) : '',
intro: JSON.stringify(editSingleCourseInfo.intro),
});
} else {
saveData = yield call(onlineAjax.editCourse, {
......@@ -1589,6 +1638,7 @@ export default {
id: editSingleCourseId,
content: '',
type: 1,
intro: JSON.stringify(editSingleCourseInfo.intro),
});
}
yield put({
......@@ -1617,6 +1667,10 @@ export default {
start_time: null,
cover: '',
content: '',
intro: [{
type: 'editor',
value: '',
}],
},
},
});
......
......@@ -2,6 +2,7 @@ import React from 'react';
import { List, Icon, DatePicker, Form, Card, Button, Menu, Dropdown, Input, Pagination, Row, Col, Popover } from 'antd';
import moment from 'moment';
import pageStyle from './CourseBox.less';
import ThemeEditor from '../../onlineclasses/ThemeEditor';
import { imagify } from '../../../utils';
const FormItem = Form.Item;
class CourseBoxForm extends React.Component {
......@@ -67,6 +68,10 @@ class CourseBoxForm extends React.Component {
document.getElementById('uploadsinglecoursecover').value = '';
});
}
uEditorSingleChange = (value) => {
const { uEditorSingleChange } = this.props;
uEditorSingleChange(value);
}
render() {
const {
list,
......@@ -316,6 +321,12 @@ class CourseBoxForm extends React.Component {
style={{ width: 424 }}
/>)}
</FormItem>
<FormItem {...formItemModalLineLayout} label="课&nbsp;程&nbsp;介&nbsp;绍">
<ThemeEditor
commentParams={editSingleCourseInfo}
uEditorChange={this.uEditorSingleChange}
/>
</FormItem>
<FormItem {...formItemModalLineLayout}>
<Button type="primary" htmlType="submit" style={{ marginRight: 20 }} loading={singleCourseSubmitting}>{singleCourseSubmitting ? '保存中...' : '保存'}</Button>
<Button type="primary" onClick={toAddCourseWare} style={{ marginRight: 20 }}>上传课件</Button>
......
......@@ -226,6 +226,15 @@ class CourseDetailForm extends React.Component {
},
});
}
uEditorChange = (value) => {
const { dispatch } = this.props;
dispatch({
type: 'coursegatherdetail/uEditorChange',
payload: {
value,
},
});
}
render() {
const {
form: { getFieldDecorator, getFieldValue },
......@@ -418,6 +427,7 @@ class CourseDetailForm extends React.Component {
moveContent={this.courseMoveContent}
editorAddText={this.courseAddText}
editorUploadAudio={this.courseUploadAudio}
uEditorChange={this.uEditorChange}
/>
</FormItem>
<div
......
......@@ -219,5 +219,5 @@
box-shadow:1px -6px 6px 0px rgba(0, 0, 0, 0.04);
transition: 0.2s left;
transition: 0.1s width;
z-index: 5;
z-index: 20;
}
......@@ -672,6 +672,7 @@ class StaticCenter extends React.Component {
start_time: item.start_time,
cover: item.cover,
content: item.content ? JSON.parse(item.content) : '',
intro: item.intro,
},
},
});
......@@ -706,6 +707,10 @@ class StaticCenter extends React.Component {
start_time: null,
cover: '',
content: '',
intro: [{
type: 'editor',
value: '',
}],
},
},
});
......@@ -723,6 +728,10 @@ class StaticCenter extends React.Component {
start_time: item.start_time,
cover: item.cover,
content: item.content ? JSON.parse(item.content) : '',
intro: item.intro ? JSON.parse(item.intro) : [{
type: 'editor',
value: '',
}],
},
},
});
......@@ -793,6 +802,20 @@ class StaticCenter extends React.Component {
},
});
}
uEditorSingleChange = (value) => {
const { editSingleCourseInfo, dispatch } = this.props;
const neweditSingleCourseInfo = JSON.parse(JSON.stringify(editSingleCourseInfo));
neweditSingleCourseInfo.intro = [{
type: 'editor',
value,
}];
dispatch({
type: 'coursegatherdetail/updateState',
payload: {
editSingleCourseInfo: neweditSingleCourseInfo,
},
});
}
render() {
const that = this;
const {
......@@ -828,6 +851,7 @@ class StaticCenter extends React.Component {
courseQueryParams,
coursewareSubmitting,
} = this.props;
console.log(editSingleCourseInfo, 'editSingleCourseInfo');
const menu = (
<Menu>
<Menu.Item key="0">
......@@ -869,6 +893,7 @@ class StaticCenter extends React.Component {
list={courseList}
total={courseListTotal}
toManageCourse={this.toManageCourse}
uEditorSingleChange={this.uEditorSingleChange}
// allList={allCourseList}
// allTotal={allCourseListTotal}
toAddCourse={this.toAddCourse}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment