Commit 0328ee98 authored by baixian's avatar baixian

优化

parent 74a2ec65
......@@ -167,6 +167,7 @@ export default {
delete_unlock_subject: `${dakaapi}member/unlock_subject`,
find_unlock_subject: `${dakaapi}member/unlock_subject/detail`,
pattern_list: `${dakaapi}member/unlock_subject/index`,
edit_unlock_subject: `${dakaapi}member/unlock_subject/update`,
},
};
......@@ -22,7 +22,7 @@ class CourseChart extends React.Component {
});
}
calculateStyle = (info) => {
const colorList = ['#FF9A6C', '#FF5971', '#82D7FE', '#38E0C9', '#BD9FFF'];
const colorList = ['#FF9A6C', '#FF5971', '#82D7FE', '#38E0C9', '#BD9FFF', '#ffd338', '#35c13a'];
const dayStartTimestamp = new Date(`${info.start_date} 06:00`.replace(/-/g, '/'));
const dayEndTimestamp = new Date(`${info.start_date} 24:00`.replace(/-/g, '/'));
const dayTotalTimestamp = (dayEndTimestamp - dayStartTimestamp) + 3600000;
......
......@@ -114,23 +114,23 @@ class SjdMenu extends React.Component {
))}
</div>
}
{!isDepartment &&
<div className={SjdHeaderStyle.useraccount}>
<span className={SjdHeaderStyle.usermobile}>{(schoolUserInfo && schoolUserInfo.nickname) || ''}</span>
<img alt={(schoolUserInfo && schoolUserInfo.name) || ''} src={(schoolUserInfo && imagify(schoolUserInfo.avatar)) || ''} className={SjdHeaderStyle.avator} />
</div>
}
{isDepartment &&
<div className={SjdHeaderStyle.useraccount}>
<span className={SjdHeaderStyle.usermobile}>{(userInfo && userInfo.nickname) || ''}</span>
<img alt={(userInfo && userInfo.name) || ''} src={(userInfo && imagify(schoolUserInfo.avatar)) || ''} className={SjdHeaderStyle.avator} />
</div>
}
<div className={SjdHeaderStyle.accountoperate}>
<Dropdown overlay={menu} trigger={['click']}>
<Dropdown overlay={menu}>
<div className={SjdHeaderStyle.accountoperate}>
<Icon type="caret-down" className={SjdHeaderStyle.caretDown} />
</Dropdown>
</div>
{!isDepartment &&
<div className={SjdHeaderStyle.useraccount}>
<span className={SjdHeaderStyle.usermobile}>{(schoolUserInfo && schoolUserInfo.nickname) || ''}</span>
<img alt={(schoolUserInfo && schoolUserInfo.name) || ''} src={(schoolUserInfo && imagify(schoolUserInfo.avatar)) || ''} className={SjdHeaderStyle.avator} />
</div>
}
{isDepartment &&
<div className={SjdHeaderStyle.useraccount}>
<span className={SjdHeaderStyle.usermobile}>{(userInfo && userInfo.nickname) || ''}</span>
<img alt={(userInfo && userInfo.name) || ''} src={(userInfo && imagify(schoolUserInfo.avatar)) || ''} className={SjdHeaderStyle.avator} />
</div>
}
</div>
</Dropdown>
</Header>
);
}
......
......@@ -72,3 +72,10 @@
color: #fff;
}
}
:global {
.ant-menu.ant-menu-dark .ant-menu-item:hover {
background-color: #1890FF;
color: rgba(254, 254, 254, 1);
border-left: 5px solid #FFFFFF;
}
}
......@@ -39,6 +39,14 @@ export default {
value: 5,
color: '#BD9FFF',
},
{
value: 6,
color: '#ffd338',
},
{
value: 7,
color: '#35c13a',
},
],
editCourseInfo: {
id: 0,
......@@ -238,6 +246,14 @@ export default {
value: 5,
color: '#BD9FFF',
},
{
value: 6,
color: '#ffd338',
},
{
value: 7,
color: '#35c13a',
},
],
editCourseInfo: {
id: 0,
......
......@@ -147,6 +147,29 @@ export default {
pathname: `/sjd/newtheme/emigratedclock/${patternId}`,
}));
},
* editSubjectCourse({ payload }, { call, put, select }) {
const { record } = payload;
yield put(routerRedux.push({
pathname: `/sjd/newtheme/emigratedcourse/${record.id}`,
}));
},
* findSubjectCourse({ payload }, { call, put, select }) {
const { id } = payload;
const { sid } = yield select(state => state.webapp);
const { emigratedObj } = yield select(state => state.createtheme);
const courseData = yield call(themeAjax.findTheme, {
id,
});
if (courseData.code == 200) {
courseData.data.content = JSON.parse(courseData.data.content);
yield put({
type: 'updateState',
payload: {
emigrateParams: { ...courseData.data },
},
});
}
},
* copyGoTheme({ payload }, { call, put, select }) {
const { record, isCopy } = payload;
if (record.subject_type === 1) {
......@@ -412,8 +435,9 @@ export default {
* createThemeModalAddEmigrated({ payload }, { call, put, select }) {
const { sid } = yield select(state => state.webapp);
const {
unClockLoading, stepNumber,
unClockLoading, stepNumber, emigratedObj,
} = yield select(state => state.createtheme);
console.log(emigratedObj, 'emigratedObj');
if (unClockLoading) {
return;
}
......@@ -438,7 +462,13 @@ export default {
unlock_limit,
callBack,
} = payload;
const data = yield call(themeAjax.addEmigrated, {
const newParams = {
id: emigratedObj.unlock_mode_id,
...emigratedObj,
};
console.log(newParams, 'newParams');
const postFunction = (newParams.id != undefined) && newParams.id !== 0 ? themeAjax.EditEmigrated : themeAjax.addEmigrated;
const data = yield call(postFunction, Object.assign(newParams, {
title,
push_status,
push_time,
......@@ -451,14 +481,15 @@ export default {
max_clock_count,
subject_count,
unlock_limit,
});
yield put({
type: 'updateState',
payload: {
unClockLoading: false,
},
});
}));
// yield put({
// type: 'updateState',
// payload: {
// unClockLoading: false,
// },
// });
if (data.code === 200) {
message.success(newParams.id ? '闯关打卡活动编辑成功' : '闯关打卡活动创建成功', 0.3);
yield put({
type: 'updateState',
payload: {
......@@ -468,10 +499,14 @@ export default {
if (callBack && (typeof callBack == 'function')) {
callBack();
}
message.success('闯关打卡活动创建成功', 0.5);
yield put(routerRedux.push({
pathname: `/sjd/newtheme/emigratedcount/${data.data.id}`,
}));
if (newParams.id) {
yield delay(100);
yield put(routerRedux.goBack());
} else {
yield put(routerRedux.push({
pathname: `/sjd/newtheme/emigratedcount/${data.data.id}`,
}));
}
// yield put({
// type: 'createtheme/createThemeModalfindEmigrated',
// payload: {
......@@ -498,8 +533,8 @@ export default {
sortNumber,
} = yield select(state => state.createtheme);
let newParams = {};
if (payload.title.length > 20) {
message.error('标题长度不能超过20个字!', 1);
if (payload.title.length > 40) {
message.error('标题长度不能超过40个字!', 1);
return;
}
if (emigrateLoading) {
......@@ -528,18 +563,19 @@ export default {
force_num,
callBack,
} = payload;
newParams = { ...emigratedObj };
newParams = { ...emigrateParams };
if (newParams.school) {
delete newParams.school;
}
console.log(newParams, 'newParams');
console.log(emigratedObj, 'emigratedObj');
const loadmessage = message.loading('保存中...', 0);
const postFunction = (newParams.id != undefined) && newParams.id !== 0 ? themeAjax.editTheme : themeAjax.addTheme;
const data = yield call(postFunction, Object.assign(newParams, {
is_cheat,
is_encrypt,
title,
// class_id: emigratedObj.class_id,
class_id: emigratedObj.class_id,
subject_type,
school_id: sid,
text_require_status,
......@@ -553,7 +589,7 @@ export default {
force_status,
force_num,
sort: sortNumber,
// unlock_mode_id: emigratedObj.id,
unlock_mode_id: emigratedObj.unlock_mode_id,
content: JSON.stringify(emigrateParams.content),
}));
yield put({
......@@ -569,6 +605,19 @@ export default {
payload: {
emigrateText: '',
emigrateParams: {
is_cheat: 0,
title: '',
is_encrypt: 0,
text_require_status: 2,
text_require_num: 0,
image_require_status: 2,
image_require_num: 0,
video_require_status: 2,
video_require_num: 0,
audio_require_status: 2,
audio_require_num: 0,
force_status: 2,
force_num: 0,
content: [
{ type: 'text', value: '' },
],
......@@ -589,6 +638,10 @@ export default {
callBack();
}
message.success('保存成功', 0.5);
if ((emigrateParams.id != undefined) && emigrateParams.id !== 0) {
yield delay(300);
yield put(routerRedux.goBack());
}
} else {
yield put({
type: 'webapp/errorrequestresolve',
......@@ -600,7 +653,9 @@ export default {
},
* saveRelease({ payload }, { call, put, select }) {
const { sid } = yield select(state => state.webapp);
const { releaseLoading, emigratedObj } = yield select(state => state.createtheme);
const {
releaseLoading, emigratedObj, emigrateParams, patternId,
} = yield select(state => state.createtheme);
if (releaseLoading) {
return;
}
......@@ -613,7 +668,7 @@ export default {
const data = yield call(themeAjax.saveRelease, {
status: 2,
school_id: sid,
id: emigratedObj.unlock_mode_id,
id: emigratedObj.unlock_mode_id ? emigratedObj.unlock_mode_id : patternId,
});
yield put({
type: 'updateState',
......@@ -626,14 +681,37 @@ export default {
type: 'updateState',
payload: {
stepNumber: 0,
emigrateText: '',
emigrateParams: {
content: [],
is_cheat: 0,
title: '',
is_encrypt: 0,
text_require_status: 2,
text_require_num: 0,
image_require_status: 2,
image_require_num: 0,
video_require_status: 2,
video_require_num: 0,
audio_require_status: 2,
audio_require_num: 0,
force_status: 2,
force_num: 0,
content: [
{ type: 'text', value: '' },
],
},
isRelease: false,
emigrateLoading: false,
},
});
if ((emigrateParams.id != undefined) && emigrateParams.id !== 0) {
yield delay(500);
yield put(routerRedux.goBack());
} else {
yield delay(500);
yield put(routerRedux.push({
pathname: `/sjd/thememgt/${emigratedObj.class_id}`,
}));
}
message.success('闯关打卡发布成功', 1);
} else {
yield put({
......@@ -665,7 +743,6 @@ export default {
let length = emigratedDate.data.subject_count;
// eslint-disable-next-line no-irregular-whitespace
const result = Array.from({ length }, () => length--).sort((a, b) => a - b);
console.log(emigratedDate.data, ' emigratedDate.data');
yield put({
type: 'updateState',
payload: {
......@@ -1341,6 +1418,19 @@ export default {
selectPlanDays: [],
emigrateText: '',
emigrateParams: {
is_cheat: 0,
title: '',
is_encrypt: 0,
text_require_status: 2,
text_require_num: 0,
image_require_status: 2,
image_require_num: 0,
video_require_status: 2,
video_require_num: 0,
audio_require_status: 2,
audio_require_num: 0,
force_status: 2,
force_num: 0,
content: [
{ type: 'text', value: '' },
],
......
......@@ -857,6 +857,35 @@ export default {
},
});
}
const EditSubjectCourseActive = pathToRegexp('/sjd/newtheme/emigratedcourse/:id').exec(pathname);
if (EditSubjectCourseActive) {
dispatch({
type: 'createtheme/pageInit',
payload: {
},
});
dispatch({
type: 'createtheme/findSubjectCourse',
payload: {
id: EditSubjectCourseActive[1],
},
});
dispatch({
type: 'webapp/updateState',
payload: {
breadcrumbList: [
{
path: 'sjd/indexstaic',
name: '首页',
},
{
path: pathname,
name: '编辑闯关打卡',
},
],
},
});
}
if (pathname === '/sjd/newtheme/calendarclock') {
dispatch({
type: 'createtheme/queryClassList',
......
......@@ -7,7 +7,7 @@
transition: all 0.2s;
// overflow: auto;
// min-width: 900px;
}
.collapsedcontent {
margin-left: 220px;
......@@ -31,4 +31,3 @@
}
}
}
......@@ -75,13 +75,14 @@ class StaticCenter extends React.Component {
});
}
createUnlockTheme = () => {
const { dispatch } = this.props;
dispatch({
type: 'createtheme/goTheme',
payload: {
index: 3,
},
});
message.warning('功能即将开放,敬请期待', 1);
// const { dispatch } = this.props;
// dispatch({
// type: 'createtheme/goTheme',
// payload: {
// index: 3,
// },
// });
}
disabledDate=(current) => {
return current > moment();
......
......@@ -143,12 +143,12 @@ class ContentSettingForm extends React.Component {
}
changeTab = (index) => {
const { dispatch, isSort } = this.props;
dispatch({
type: 'createtheme/getSort',
payload: {
key: index + 1,
},
});
// dispatch({
// type: 'createtheme/getSort',
// payload: {
// key: index + 1,
// },
// });
}
saveSubject = () => {
const { dispatch, isRelease } = this.props;
......@@ -196,6 +196,7 @@ class ContentSettingForm extends React.Component {
releaseLoading,
isRelease,
} = this.props;
console.log(emigrateParams, 'emigrateParams');
console.log(emigratedObj, 'emigratedObj');
const formItemModalLineLayout = {
labelCol: {
......@@ -234,36 +235,30 @@ class ContentSettingForm extends React.Component {
},
};
const selectBefore = (
<div>{title.length || 0}/40</div>
<div>{emigrateParams.title ? emigrateParams.title.length : title.length || 0}/40</div>
);
return (
<div className={pageStyle.container}>
<Form labelAlign="left" onSubmit={this.handleSubmit}>
<div className={pageStyle.title}>关卡设置</div>
<div className={pageStyle.customs}>
{/* <Tabs ActiveKey={`${sortNumber}`} onChange={this.changeTab} style={{ height: 220 }}> */}
{/* { */}
{/* unlockSubjectList.map((item, index) => */}
{/* ( */}
{/* <TabPane tab={item} key={item}> */}
{/* </TabPane> */}
{/* ), */}
{/* ) */}
{/* } */}
{/* </Tabs> */}
{
unlockSubjectList.map((item, index) =>
(
<div onClick={() => this.changeTab(index)} className={sortNumber === item ? pageStyle.numitemActive : pageStyle.numitem}>
{item}
</div>
),
)
}
<div className={pageStyle.add}>添加</div>
</div>
{
!emigrateParams.id && unlockSubjectList.length > 0 &&
<div className={pageStyle.customs} >
{
unlockSubjectList.map((item, index) =>
(
<div onClick={() => this.changeTab(index)} className={sortNumber === item ? pageStyle.numitemActive : pageStyle.numitem}>
{item}
</div>
),
)
}
<div className={pageStyle.add}>添加</div>
</div>
}
<FormItem {...formItemModalLineLayout}>
{getFieldDecorator('title', {
initialValue: emigrateParams.title,
rules: [
{
required: true,
......@@ -294,7 +289,7 @@ class ContentSettingForm extends React.Component {
<div className={pageStyle.commonright}>
<FormItem {...formItemModaltypeLayout} label="文字字数要求" style={{ marginBottom: 0 }}>
{getFieldDecorator('text_require_status', {
initialValue: false,
initialValue: emigrateParams.text_require_status === 1,
valuePropName: 'checked',
})(
<Switch checkedChildren="开启" unCheckedChildren="关闭" />,
......@@ -303,7 +298,7 @@ class ContentSettingForm extends React.Component {
</FormItem>
{getFieldValue('text_require_status') === true ? (
<FormItem {...formItemverticalLayout} labelAlign="right" label="学员打卡最少">
{getFieldDecorator('text_require_num', { initialValue: 0 })(
{getFieldDecorator('text_require_num', { initialValue: emigrateParams.text_require_num })(
<InputNumber placeholder="请输入" min={0} max={500} style={{ width: 100 }} />,
)}
<span className="ant-form-text">个文字</span>
......@@ -313,7 +308,7 @@ class ContentSettingForm extends React.Component {
)}
<FormItem {...formItemModaltypeLayout} label="图片个数要求" style={{ marginBottom: 0 }}>
{getFieldDecorator('image_require_status', {
initialValue: false,
initialValue: emigrateParams.image_require_status === 1,
valuePropName: 'checked',
})(
<Switch checkedChildren="开启" unCheckedChildren="关闭" />,
......@@ -322,7 +317,7 @@ class ContentSettingForm extends React.Component {
</FormItem>
{getFieldValue('image_require_status') === true ? (
<FormItem {...formItemverticalLayout} labelAlign="right" label="学员打卡最少">
{getFieldDecorator('image_require_num', { initialValue: 0 })(
{getFieldDecorator('image_require_num', { initialValue: emigrateParams.image_require_num })(
<InputNumber placeholder="请输入" min={0} max={9} style={{ width: 100 }} />,
)}
<span className="ant-form-text">张图片</span>
......@@ -332,7 +327,7 @@ class ContentSettingForm extends React.Component {
)}
<FormItem {...formItemModaltypeLayout} label="视频个数要求" style={{ marginBottom: 0 }}>
{getFieldDecorator('video_require_status', {
initialValue: false,
initialValue: emigrateParams.video_require_status === 1,
valuePropName: 'checked',
})(
<Switch checkedChildren="开启" unCheckedChildren="关闭" />,
......@@ -341,7 +336,7 @@ class ContentSettingForm extends React.Component {
</FormItem>
{getFieldValue('video_require_status') === true ? (
<FormItem {...formItemverticalLayout} labelAlign="right" label="学员打卡最少">
{getFieldDecorator('video_require_num', { initialValue: 0 })(
{getFieldDecorator('video_require_num', { initialValue: emigrateParams.video_require_num })(
<InputNumber placeholder="请输入" min={0} max={9} style={{ width: 100 }} />,
)}
<span className="ant-form-text">个视频</span>
......@@ -351,7 +346,7 @@ class ContentSettingForm extends React.Component {
)}
<FormItem {...formItemModaltypeLayout} label="录音时长要求" style={{ marginBottom: 0 }}>
{getFieldDecorator('audio_require_status', {
initialValue: false,
initialValue: emigrateParams.audio_require_status === 1,
valuePropName: 'checked',
})(
<Switch checkedChildren="开启" unCheckedChildren="关闭" />,
......@@ -360,7 +355,7 @@ class ContentSettingForm extends React.Component {
</FormItem>
{getFieldValue('audio_require_status') === true ? (
<FormItem {...formItemverticalLayout} labelAlign="right" label="学员打卡最少">
{getFieldDecorator('audio_require_num', { initialValue: 0 })(
{getFieldDecorator('audio_require_num', { initialValue: emigrateParams.audio_require_num })(
<InputNumber placeholder="请输入" min={0} max={600} style={{ width: 100 }} />,
)}
<span className="ant-form-text">秒录音</span>
......@@ -377,7 +372,7 @@ class ContentSettingForm extends React.Component {
<div className={pageStyle.commonright}>
<FormItem {...formItemModaltypeLayout} label="强制阅读模式" style={{ marginBottom: 0 }}>
{getFieldDecorator('force_status', {
initialValue: false,
initialValue: emigrateParams.force_status === 1,
valuePropName: 'checked',
})(
<Switch checkedChildren="开启" unCheckedChildren="关闭" />,
......@@ -386,7 +381,7 @@ class ContentSettingForm extends React.Component {
</FormItem>
{getFieldValue('force_status') === true ? (
<FormItem {...formItemverticalLayout} labelAlign="right" label="学员强制阅读">
{getFieldDecorator('force_num', { initialValue: 0 })(
{getFieldDecorator('force_num', { initialValue: emigrateParams.force_num })(
<InputNumber placeholder="请输入" min={0} style={{ width: 100 }} />,
)}
<span className="ant-form-text">分钟</span>
......@@ -402,7 +397,9 @@ class ContentSettingForm extends React.Component {
<Button htmlType="submit" loading={emigrateLoading}>
保存此关卡
</Button>
<Button style={{ float: 'right' }} loading={releaseLoading} type="primary" onClick={this.saveSubject}>发布主题</Button>
{
emigrateParams.id ? '' : <Button style={{ float: 'right' }} loading={releaseLoading} type="primary" onClick={this.saveSubject}>发布主题</Button>
}
</FormItem>
</Form>
</div>
......
......@@ -90,7 +90,6 @@ class UnClockForm extends React.Component {
classList,
emigratedObj,
} = this.props;
console.log(emigratedObj, 'emigratedObj');
const formItemModalLineLayout = {
labelCol: {
xs: { span: 3 },
......@@ -157,7 +156,7 @@ class UnClockForm extends React.Component {
},
],
})(
<Select placeholder="请选择班级" style={{ width: 174 }} showSearch onChange={this.handleStudentChange}>
<Select disabled={(emigratedObj.class_id && emigratedObj.class_id != undefined)} placeholder="请选择班级" style={{ width: 174 }} showSearch onChange={this.handleStudentChange}>
{classList.map(ele => <Option value={ele.id}>{ele.title}</Option>)}
</Select>,
)}
......
......@@ -24,7 +24,13 @@ class EmigratedClockForm extends React.Component {
componentWillUnmount() { // 卸载
}
editCourse = (record) => {
console.log(record);
const { dispatch } = this.props;
dispatch({
type: 'createtheme/editSubjectCourse',
payload: {
record,
},
});
}
editClock = () => {
const { dispatch } = this.props;
......@@ -34,6 +40,14 @@ class EmigratedClockForm extends React.Component {
},
});
}
saveSubject = () => {
const { dispatch } = this.props;
dispatch({
type: 'createtheme/saveRelease',
payload: {
},
});
}
render() {
const columns = [
{
......@@ -41,7 +55,7 @@ class EmigratedClockForm extends React.Component {
dataIndex: 'sort',
},
{
title: '课程名称',
title: '关卡标题',
dataIndex: 'title',
},
{
......@@ -55,6 +69,7 @@ class EmigratedClockForm extends React.Component {
];
const {
patternList,
releaseLoading,
} = this.props;
return (
<div className={pageStyle.container}>
......@@ -71,7 +86,7 @@ class EmigratedClockForm extends React.Component {
</Row>
<Row>
<Col span={24} style={{ textAlign: 'right' }}>
<Button type="primary">发布主题</Button>
<Button loading={releaseLoading} type="primary" onClick={this.saveSubject} >发布主题</Button>
</Col>
</Row>
</div>
......@@ -85,9 +100,11 @@ const EmigratedClock = Form.create()(EmigratedClockForm);
function mapStateToProps(state) {
const {
patternList,
releaseLoading,
} = state.createtheme;
return {
patternList,
releaseLoading,
};
}
export default connect(mapStateToProps)(EmigratedClock);
......
......@@ -137,6 +137,10 @@ class ThemeMgt extends React.Component {
}
editTheme = (record) => {
const { dispatch } = this.props;
if (record.subject_type == 3) {
message.warning('功能即将开放,敬请期待', 1);
return;
}
dispatch({
type: 'createtheme/editGoTheme',
payload: {
......
......@@ -240,6 +240,7 @@ function RouterConfig({ history }) {
<Route path="/sjd/newtheme/editemigrated/:id" exact component={EditEmigratedClock} />
<Route path="/sjd/newtheme/emigratedclock/:id" exact component={EmigratedSetting} />
<Route path="/sjd/newtheme/emigratedcount/:showId" exact component={EmigratedContent} />
<Route path="/sjd/newtheme/emigratedcourse/:id" exact component={EmigratedContent} />
</SjdIndex>
)}
/>
......
......@@ -77,3 +77,11 @@ export function find_pattern_list(params) {
data,
});
}
export function EditEmigrated(params) {
const data = qs.stringify(params);
return request({
url: `${api.createtheme.edit_unlock_subject}`,
method: 'POST',
data,
});
}
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