Commit 172ce1c0 authored by wangxuelai's avatar wangxuelai

'最新代码提交'

parent e4449827
......@@ -38,6 +38,7 @@
"eventsource-polyfill": "^0.9.6",
"fetch-ie8": "^1.5.0",
"fetch-jsonp": "^1.1.3",
"immutability-helper": "^3.0.1",
"jquery": "^3.3.1",
"js-base64": "^2.5.1",
"lodash": "^4.17.5",
......@@ -48,6 +49,8 @@
"qs": "^6.5.1",
"query-string": "^6.8.3",
"react": "16.9.0",
"react-dnd": "^9.4.0",
"react-dnd-html5-backend": "^9.4.0",
"react-dom": "^16.2.0",
"react-slick": "^0.25.2",
"video-react": "^0.14.1",
......
......@@ -27,21 +27,21 @@ class UploadCourseware extends React.Component {
}
save = () => {
const { info, dispatch, callback } = this.props;
console.log(info, 'info');
dispatch({
type: 'uploadcourseware/uploadCourseware',
payload: {
info,
},
});
callback(JSON.parse(JSON.stringify(info)));
// console.log(info, 'info');
// dispatch({
// type: 'uploadcourseware/updateState',
// type: 'uploadcourseware/uploadCourseware',
// payload: {
// visible: false,
// info: {},
// info,
// },
// });
callback(JSON.parse(JSON.stringify(info)));
dispatch({
type: 'uploadcourseware/updateState',
payload: {
visible: false,
info: {},
},
});
}
hide = () => {
const { dispatch } = this.props;
......
......@@ -4,6 +4,7 @@ import { message } from 'antd';
import { delay } from 'redux-saga';
import co from 'co';
import moment from 'moment';
import update from 'immutability-helper';
import {
LocalStorage,
SessionStorage,
......@@ -1004,7 +1005,9 @@ export default {
}
},
* saveManageCourse({ payload }, { call, put, select }) {
const { manageCourseObj, id, manageCourseSubmitting } = yield select(state => state.coursegatherdetail);
const {
manageCourseObj, id, manageCourseSubmitting, manageCourseList,
} = yield select(state => state.coursegatherdetail);
if (manageCourseSubmitting) {
return;
}
......@@ -1015,14 +1018,21 @@ export default {
},
});
const targetArr = [];
for (const i in manageCourseObj) {
manageCourseList.forEach((ele) => {
targetArr.push({
id: i,
sort: 0,
cover: manageCourseObj[i].cover,
content: manageCourseObj[i].content,
id: ele.id,
cover: (manageCourseObj[ele.id] && manageCourseObj[ele.id].cover) || '',
content: (manageCourseObj[ele.id] && manageCourseObj[ele.id].content) || '',
});
}
});
// for (const i in manageCourseObj) {
// targetArr.push({
// id: i,
// sort: 0,
// cover: manageCourseObj[i].cover,
// content: manageCourseObj[i].content,
// });
// }
const saveData = yield call(onlineAjax.onlineCoursesBatch, {
id,
json: JSON.stringify(targetArr),
......@@ -1042,6 +1052,12 @@ export default {
manageCourseShow: false,
},
});
yield put({
type: 'selectCourseList',
payload: {
params: {},
},
});
} else {
yield put({
type: 'webapp/errorrequestresolve',
......@@ -1050,16 +1066,19 @@ export default {
},
});
}
// const newManageCourseObj = JSON.parse(JSON.stringify(manageCourseObj));
// if (!newManageCourseObj[id]) {
// newManageCourseObj[id] = {
// cover: '',
// sort: 0,
// content: info,
// };
// } else {
// newManageCourseObj[id].content = info;
// }
},
* moveRow({ payload }, { call, put, select }) {
const { manageCourseList } = yield select(state => state.coursegatherdetail);
const { dragIndex, hoverIndex } = payload;
const newmanageCourseList = JSON.parse(JSON.stringify(manageCourseList));
yield put({
type: 'updateState',
payload: {
manageCourseList: update(newmanageCourseList, {
$splice: [[dragIndex, 1], [hoverIndex, 0, newmanageCourseList[dragIndex]]],
}),
},
});
},
},
reducers: {
......
......@@ -56,6 +56,7 @@ export default {
perPage: 10,
},
commentListTotal: 0,
coursewareSubmitting: false,
},
subscriptions: {
setup({ dispatch, history }) { // eslint-disable-line
......@@ -879,6 +880,53 @@ export default {
},
});
},
* uploadCourseware({ payload }, { call, put, select }) {
const { info } = payload;
const { addCourseObj, coursewareSubmitting } = yield select(state => state.onlineclasses);
if (coursewareSubmitting) {
return;
}
yield put({
type: 'updateState',
payload: {
coursewareSubmitting: true,
},
});
const loadmessage = message.loading('保存中...', 0);
const data = yield call(courseMateriaAjax.uploadCourseware, {
content: JSON.stringify(info),
id: addCourseObj.id,
});
yield put({
type: 'updateState',
payload: {
coursewareSubmitting: false,
},
});
setTimeout(loadmessage);
if (data.code == 200) {
yield put({
type: 'uploadcourseware/updateState',
payload: {
visible: false,
info: {},
},
});
yield put({
type: 'findCourse',
payload: {
id: addCourseObj.id,
},
});
} else {
yield put({
type: 'webapp/errorrequestresolve',
payload: {
data,
},
});
}
},
},
reducers: {
save(state, action) {
......
......@@ -144,32 +144,32 @@ export default {
});
}
},
* uploadCourseware({ payload }, { call, put, select }) {
const { info } = payload;
const { addCourseObj } = yield select(state => state.onlineclasses);
const loadmessage = message.loading('保存中...', 0);
const data = yield call(courseMateriaAjax.uploadCourseware, {
content: JSON.stringify(info),
id: addCourseObj.id,
});
setTimeout(loadmessage);
if (data.code == 200) {
yield put({
type: 'updateState',
payload: {
visible: false,
info: {},
},
});
} else {
yield put({
type: 'webapp/errorrequestresolve',
payload: {
data,
},
});
}
},
// * uploadCourseware({ payload }, { call, put, select }) {
// const { info } = payload;
// const { addCourseObj } = yield select(state => state.onlineclasses);
// const loadmessage = message.loading('保存中...', 0);
// const data = yield call(courseMateriaAjax.uploadCourseware, {
// content: JSON.stringify(info),
// id: addCourseObj.id,
// });
// setTimeout(loadmessage);
// if (data.code == 200) {
// yield put({
// type: 'updateState',
// payload: {
// visible: false,
// info: {},
// },
// });
// } else {
// yield put({
// type: 'webapp/errorrequestresolve',
// payload: {
// data,
// },
// });
// }
// },
* createCourseMateria({ payload }, { call, put, select }) {
const { sid } = yield select(state => state.webapp);
const {
......
......@@ -46,7 +46,6 @@ class CommentListForm extends React.Component {
gatherDetail,
staticChartId,
} = this.props;
console.log(allRelativeCourseList, 'allRelativeCourseList');
const dataSource = [
{
key: '1',
......
......@@ -2,63 +2,75 @@ import React from 'react';
import { List, Icon, DatePicker, Spin, Card, Button } from 'antd';
import pageStyle from './CourseBox.less';
import { imagify } from '../../../utils';
const CourseBox = (props) => {
const {
list,
total,
toAddCourse,
toManageCourse,
} = props;
return (
<div className={pageStyle.mediaCardBox}>
<div className={pageStyle.mediaCardBoxHeader}>
<div className={pageStyle.mediaCardBoxHeaderTitle}>课程列表</div>
<div className={pageStyle.courseCount}>({total})</div>
<Button type="primary" style={{ marginRight: '20px', marginBottom: '26px' }}>创建课程</Button>
<Button type="primary" style={{ marginRight: '20px', marginBottom: '26px' }} onClick={() => toAddCourse()}>批量添加课程</Button>
<Button type="primary" style={{ marginRight: '20px', marginBottom: '26px' }}>课程排序</Button>
<Button type="primary" style={{ marginRight: '20px', marginBottom: '26px' }} onClick={() => toManageCourse()}>批量管理课程</Button>
</div>
<div>
<List
size="large"
grid={{
gutter: 20,
xs: 1,
sm: 1,
md: 2,
lg: 2,
xl: 3,
xxl: 4,
}}
dataSource={list}
renderItem={item => (
<List.Item style={{ minWidth: '320px' }}>
<Card bodyStyle={{ padding: 20, minWidth: '320px' }}>
<Card.Meta
style={{ padding: 0, borderRadius: '6px' }}
avatar={<img className={pageStyle.itemImg} alt="图片" src={imagify(item.cover)} />}
title={
<div className={pageStyle.itemTitleWrap}>
<div className={pageStyle.itemTitle}>{item.title}</div>
class CourseBox extends React.Component {
constructor(props) {
super(props);
this.state = {
};
}
componentDidMount() { // 挂载
}
componentDidUpdate() {
}
componentWillUnmount() { // 卸载
}
render() {
const {
list,
total,
toAddCourse,
toManageCourse,
} = this.props;
return (
<div className={pageStyle.mediaCardBox}>
<div className={pageStyle.mediaCardBoxHeader}>
<div className={pageStyle.mediaCardBoxHeaderTitle}>课程列表</div>
<div className={pageStyle.courseCount}>({total})</div>
<Button type="primary" style={{ marginRight: '20px', marginBottom: '26px' }}>创建课程</Button>
<Button type="primary" style={{ marginRight: '20px', marginBottom: '26px' }} onClick={() => toAddCourse()}>批量添加课程</Button>
<Button type="primary" style={{ marginRight: '20px', marginBottom: '26px' }} onClick={() => toManageCourse()}>批量管理课程</Button>
</div>
<div>
<List
size="large"
grid={{
gutter: 20,
xs: 1,
sm: 1,
md: 2,
lg: 2,
xl: 3,
xxl: 4,
}}
dataSource={list}
renderItem={item => (
<List.Item style={{ minWidth: '320px' }}>
<Card bodyStyle={{ padding: 20, minWidth: '320px' }}>
<Card.Meta
style={{ padding: 0, borderRadius: '6px' }}
avatar={<img className={pageStyle.itemImg} alt="图片" src={imagify(item.cover)} />}
title={
<div className={pageStyle.itemTitleWrap}>
<div className={pageStyle.itemTitle}>{item.title}</div>
</div>
}
description={
<span className={pageStyle.itemTime}>{item.created_at}</span>
}
/>
<div className={pageStyle.editbtn}>
<div className={pageStyle.itemBtn}>
<Icon style={{ marginRight: 5 }} type="edit" /> 编辑课程
</div>
}
description={
<span className={pageStyle.itemTime}>{item.created_at}</span>
}
/>
<div className={pageStyle.editbtn}>
<div className={pageStyle.itemBtn}>
<Icon style={{ marginRight: 5 }} type="edit" /> 编辑课程
<div className={pageStyle.moreoperate}>更多</div>
</div>
<div className={pageStyle.moreoperate}>更多</div>
</div>
</Card>
</List.Item>
)}
/>
</Card>
</List.Item>
)}
/>
</div>
</div>
</div>
);
};
);
}
}
export default CourseBox;
......@@ -18,14 +18,73 @@ import {
InputNumber, Checkbox, Radio, message,
} from 'antd';
import moment from 'moment';
import { DndProvider, DragSource, DropTarget } from 'react-dnd';
import HTML5Backend from 'react-dnd-html5-backend';
import pageStyle from './ManageCourse.less';
import { pageIn, hasBtnPower, imagify } from '../../../utils';
const { TabPane } = Tabs;
const FormItem = Form.Item;
const { Option } = Select;
const { TextArea } = Input;
let dragingIndex = -1;
class BodyRow extends React.Component {
render() {
const {
isOver, connectDragSource, connectDropTarget, moveRow, ...restProps
} = this.props;
const style = { ...restProps.style, cursor: 'move' };
let { className } = restProps;
if (isOver) {
if (restProps.index > dragingIndex) {
className += ' drop-over-downward';
}
if (restProps.index < dragingIndex) {
className += ' drop-over-upward';
}
}
class ManageCourse extends React.Component {
return connectDragSource(
connectDropTarget(<tr {...restProps} className={className} style={style} />),
);
}
}
const rowSource = {
beginDrag(props) {
dragingIndex = props.index;
return {
index: props.index,
};
},
};
const rowTarget = {
drop(props, monitor) {
const dragIndex = monitor.getItem().index;
const hoverIndex = props.index;
// Don't replace items with themselves
if (dragIndex === hoverIndex) {
return;
}
// Time to actually perform the action
props.moveRow(dragIndex, hoverIndex);
// Note: we're mutating the monitor item here!
// Generally it's better to avoid mutations,
// but it's good here for the sake of performance
// to avoid expensive index searches.
monitor.getItem().index = hoverIndex; // eslint-disable-line
},
};
const DragableBodyRow = DropTarget('row', rowTarget, (connect, monitor) => ({
connectDropTarget: connect.dropTarget(),
isOver: monitor.isOver(),
}))(
DragSource('row', rowSource, connect => ({
connectDragSource: connect.dragSource(),
}))(BodyRow),
);
class ManageCourse extends React.Component { // eslint-disable-line
constructor(props) {
super(props);
this.state = {
......@@ -80,6 +139,30 @@ class ManageCourse extends React.Component {
const { submit } = this.props;
submit();
}
components = {
body: {
row: DragableBodyRow,
},
};
moveRow = (dragIndex, hoverIndex) => {
// const { data } = this.state;
// const dragRow = data[dragIndex];
const { moveRow } = this.props;
moveRow({
dragIndex,
hoverIndex,
});
// dispatch({
// type: 'moveRow'
// })
// this.setState(
// update(this.state, {
// data: {
// $splice: [[dragIndex, 1], [hoverIndex, 0, dragRow]],
// },
// }),
// );
};
render() {
const {
visible,
......@@ -172,17 +255,34 @@ class ManageCourse extends React.Component {
confirmLoading={loading}
okText={loading ? '保存中...' : '保存'}
onOk={this.submit}
className="managecoursecontainer"
bodyStyle={{
padding: '40px 20px',
}}
>
<Table
rowKey="id"
columns={columns}
dataSource={list}
pagination={false}
loading={tableLoading}
/>
<DndProvider backend={HTML5Backend}>
{/* <Table
columns={columns}
dataSource={this.state.data}
components={this.components}
onRow={(record, index) => ({
index,
moveRow: this.moveRow,
})}
/> */}
<Table
rowKey="id"
columns={columns}
dataSource={list}
components={this.components}
onRow={(record, index) => ({
index,
moveRow: this.moveRow,
})}
pagination={false}
loading={tableLoading}
/>
</DndProvider>
</Modal>
);
}
......
......@@ -22,4 +22,18 @@
top: 0;
}
}
}
:global {
.managecoursecontainer {
.drop-over-downward {
td {
border-bottom: 2px dashed #1890FF;
}
}
.drop-over-upward {
td {
border-top: 2px dashed #1890FF;
}
}
}
}
\ No newline at end of file
......@@ -63,7 +63,6 @@ class StaticBox extends React.Component {
for (let i = 0; i < month.length && i < visitorCount.length; i++) {
dataChart.push({ month: month[i], count: visitorCount[i], name: '访问人数' });
}
console.log(this.props, ' this.props');
return (
<div>
<div className={pageStyle.StaticBox}>
......
......@@ -399,6 +399,13 @@ class StaticCenter extends React.Component {
type: 'coursegatherdetail/saveManageCourse',
});
}
moveRow = (value) => {
const { dispatch } = this.props;
dispatch({
type: 'coursegatherdetail/moveRow',
payload: value,
});
}
render() {
const that = this;
const {
......@@ -508,6 +515,7 @@ class StaticCenter extends React.Component {
reUploadCover={this.reUploadCover}
toUploadManageCourseware={this.toUploadManageCourseware}
submit={this.saveManageCourse}
moveRow={this.moveRow}
/>
<MaterialModal
visible={materialVisible}
......
......@@ -260,7 +260,6 @@ class CourseDetailForm extends React.Component {
}
toUploadCourseware = () => {
const { dispatch, coursewareInfo } = this.props;
console.log(coursewareInfo, 'coursewareInfo1111111');
dispatch({
type: 'uploadcourseware/updateState',
payload: {
......
......@@ -55,9 +55,9 @@ class singleDetailForm extends React.Component {
uploadCourseware = (values) => {
const { dispatch } = this.props;
dispatch({
type: 'onlineclasses/updateState',
type: 'onlineclasses/uploadCourseware',
payload: {
coursewareInfo: { ...values },
info: { ...values },
},
});
}
......@@ -148,6 +148,7 @@ class singleDetailForm extends React.Component {
materiaListTotal,
queryParams,
materialVisible2,
coursewareSubmitting,
} = this.props;
const formItemModalLineLayout = {
labelCol: {
......@@ -197,6 +198,7 @@ class singleDetailForm extends React.Component {
callback={this.uploadCourseware}
delCourseware={this.delCourseware}
chooseFromCourseMateria={this.chooseFromCourseMateria}
loading={coursewareSubmitting}
/>
<MaterialModal
visible={materialVisible2}
......@@ -223,6 +225,7 @@ function mapStateToProps(state) {
materiaList,
materiaListTotal,
queryParams,
coursewareSubmitting,
} = state.onlineclasses;
return {
addCourseObj,
......@@ -230,6 +233,7 @@ function mapStateToProps(state) {
materiaList,
materiaListTotal,
queryParams,
coursewareSubmitting,
};
}
export default connect(mapStateToProps)(singleDetail);
......
......@@ -731,6 +731,10 @@
lodash "^4.17.13"
to-fast-properties "^2.0.0"
"@types/asap@^2.0.0":
version "2.0.0"
resolved "https://registry.yarnpkg.com/@types/asap/-/asap-2.0.0.tgz#d529e9608c83499a62ae08c871c5e62271aa2963"
"@types/events@*":
version "3.0.0"
resolved "https://registry.yarnpkg.com/@types/events/-/events-3.0.0.tgz#2862f3f58a9a7f7c3e78d79f130dd4d71c25c2a7"
......@@ -747,6 +751,17 @@
version "4.7.3"
resolved "https://registry.yarnpkg.com/@types/history/-/history-4.7.3.tgz#856c99cdc1551d22c22b18b5402719affec9839a"
"@types/hoist-non-react-statics@^3.3.1":
version "3.3.1"
resolved "https://registry.yarnpkg.com/@types/hoist-non-react-statics/-/hoist-non-react-statics-3.3.1.tgz#1124aafe5118cb591977aeb1ceaaed1070eb039f"
dependencies:
"@types/react" "*"
hoist-non-react-statics "^3.3.0"
"@types/invariant@^2.2.30":
version "2.2.30"
resolved "https://registry.yarnpkg.com/@types/invariant/-/invariant-2.2.30.tgz#20efa342807606ada5483731a8137cb1561e5fe9"
"@types/isomorphic-fetch@^0.0.34":
version "0.0.34"
resolved "https://registry.yarnpkg.com/@types/isomorphic-fetch/-/isomorphic-fetch-0.0.34.tgz#3c3483e606c041378438e951464f00e4e60706d6"
......@@ -800,6 +815,10 @@
"@types/prop-types" "*"
csstype "^2.2.0"
"@types/shallowequal@^1.1.1":
version "1.1.1"
resolved "https://registry.yarnpkg.com/@types/shallowequal/-/shallowequal-1.1.1.tgz#aad262bb3f2b1257d94c71d545268d592575c9b1"
"@webassemblyjs/ast@1.8.5":
version "1.8.5"
resolved "https://registry.yarnpkg.com/@webassemblyjs/ast/-/ast-1.8.5.tgz#51b1c5fe6576a34953bf4b253df9f0d490d9e359"
......@@ -1177,7 +1196,7 @@ array-unique@^0.3.2:
version "0.3.2"
resolved "https://registry.yarnpkg.com/array-unique/-/array-unique-0.3.2.tgz#a894b75d4bc4f6cd679ef3244a9fd8f46ae2d428"
asap@~2.0.3:
asap@^2.0.6, asap@~2.0.3:
version "2.0.6"
resolved "https://registry.yarnpkg.com/asap/-/asap-2.0.6.tgz#e50347611d7e690943208bbdafebcbc2fb866d46"
......@@ -3172,6 +3191,16 @@ diffie-hellman@^5.0.0:
miller-rabin "^4.0.0"
randombytes "^2.0.0"
dnd-core@^9.4.0:
version "9.4.0"
resolved "https://registry.yarnpkg.com/dnd-core/-/dnd-core-9.4.0.tgz#ccf605d36887f18cdde8fd5576ca3145d2e69fa8"
dependencies:
"@types/asap" "^2.0.0"
"@types/invariant" "^2.2.30"
asap "^2.0.6"
invariant "^2.2.4"
redux "^4.0.4"
dns-equal@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/dns-equal/-/dns-equal-1.0.0.tgz#b39e7f1da6eb0a75ba9c17324b34753c47e0654d"
......@@ -6742,6 +6771,22 @@ react-async-component@^1.0.0-beta.3:
version "1.0.2"
resolved "https://registry.yarnpkg.com/react-async-component/-/react-async-component-1.0.2.tgz#b041722bf7734a95c51dc9fc2f28ec9e918e9659"
react-dnd-html5-backend@^9.4.0:
version "9.4.0"
resolved "https://registry.yarnpkg.com/react-dnd-html5-backend/-/react-dnd-html5-backend-9.4.0.tgz#5b1d192f57d103298657cde1fe0eabdbf2726311"
dependencies:
dnd-core "^9.4.0"
react-dnd@^9.4.0:
version "9.4.0"
resolved "https://registry.yarnpkg.com/react-dnd/-/react-dnd-9.4.0.tgz#eec87035c6360fb33a44932326b3369af011a41c"
dependencies:
"@types/hoist-non-react-statics" "^3.3.1"
"@types/shallowequal" "^1.1.1"
dnd-core "^9.4.0"
hoist-non-react-statics "^3.3.0"
shallowequal "^1.1.0"
react-dom@^16.2.0, react-dom@^16.4.0:
version "16.11.0"
resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-16.11.0.tgz#7e7c4a5a85a569d565c2462f5d345da2dd849af5"
......@@ -6912,7 +6957,7 @@ redux-saga@^0.16.0:
version "0.16.2"
resolved "https://registry.yarnpkg.com/redux-saga/-/redux-saga-0.16.2.tgz#993662e86bc945d8509ac2b8daba3a8c615cc971"
"redux@>= 3.7.2", redux@^4.0.1:
"redux@>= 3.7.2", redux@^4.0.1, redux@^4.0.4:
version "4.0.4"
resolved "https://registry.yarnpkg.com/redux/-/redux-4.0.4.tgz#4ee1aeb164b63d6a1bcc57ae4aa0b6e6fa7a3796"
dependencies:
......
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