Commit 734ef405 authored by baixian's avatar baixian

作业和日历打卡编辑功能及删除

parent 2697ec49
...@@ -164,6 +164,7 @@ export default { ...@@ -164,6 +164,7 @@ export default {
find_subject_detail: `${dakaapi}member/unlock_subject/show`, find_subject_detail: `${dakaapi}member/unlock_subject/show`,
unlockSubjectRelease: `${dakaapi}member/unlock_subject/release`, unlockSubjectRelease: `${dakaapi}member/unlock_subject/release`,
deleteTheme: `${dakaapi}member/subjects`, deleteTheme: `${dakaapi}member/subjects`,
delete_unlock_subject: `${dakaapi}member/unlock_subject`,
}, },
}; };
...@@ -9,6 +9,7 @@ import { ...@@ -9,6 +9,7 @@ import {
getWeek, getWeek,
unique1, unique1,
getWeekDay, getWeekDay,
getDateStamp,
} from '../utils/index'; } from '../utils/index';
import errorcode from '../common/errorcode'; import errorcode from '../common/errorcode';
import * as themeAjax from '../services/createtheme'; import * as themeAjax from '../services/createtheme';
...@@ -20,6 +21,7 @@ export default { ...@@ -20,6 +21,7 @@ export default {
namespace: 'createtheme', namespace: 'createtheme',
state: { state: {
sid: 0, sid: 0,
tabIndex: 1,
classList: [], classList: [],
editorText: '', editorText: '',
jobParams: { jobParams: {
...@@ -119,6 +121,13 @@ export default { ...@@ -119,6 +121,13 @@ export default {
}, },
}, },
}); });
yield put({
type: 'updateState',
payload: {
tabIndex: record.subject_type,
record,
},
});
} else if (record.subject_type === 2) { } else if (record.subject_type === 2) {
yield put({ yield put({
type: 'updateState', type: 'updateState',
...@@ -129,19 +138,37 @@ export default { ...@@ -129,19 +138,37 @@ export default {
}, },
}, },
}); });
// yield put({ yield put({
// type: 'chooseWeek', type: 'updateState',
// payload: { payload: {
// }, tabIndex: record.subject_type,
// }); record,
},
});
let editDates = [];
if (record.calendar_set.rest_dates != '') { editDates = record.calendar_set.rest_dates.split(','); }
let day = [];
for (let i = 0; i < editDates.length; i++) {
editDates[i] = getDateStamp(editDates[i]);
editDates[i] = moment(editDates[i]).format('YYYY-MM-DD');
day = Number(getWeekDay(editDates[i]));
console.log(day, 'day');
yield put({
type: 'chooseWeek',
payload: {
day,
start_time: moment(record.start_time).format('YYYY-MM-DD'),
end_time: moment(record.end_time).format('YYYY-MM-DD'),
},
});
yield put({
type: 'updateState',
payload: {
rest_dates: [...editDates],
},
});
}
} }
yield put({
type: 'updateState',
payload: {
tabIndex: record.subject_type,
record,
},
});
yield put(routerRedux.push('/sjd/newtheme')); yield put(routerRedux.push('/sjd/newtheme'));
}, },
* createThemeModalAdd({ payload }, { call, put, select }) { * createThemeModalAdd({ payload }, { call, put, select }) {
...@@ -158,30 +185,6 @@ export default { ...@@ -158,30 +185,6 @@ export default {
message.error('标题长度不能超过20个字!', 1); message.error('标题长度不能超过20个字!', 1);
return; return;
} }
if (payload.subject_type === 1) {
jobParams.content.push({
type: 'text',
value: editorText,
});
yield put({
type: 'updateState',
payload: {
jobParams: { ...jobParams },
},
});
}
if (payload.subject_type === 2) {
calendarParams.content.push({
type: 'text',
value: calendarText,
});
yield put({
type: 'updateState',
payload: {
calendarParams: { ...calendarParams },
},
});
}
if (themeAddLoading) { if (themeAddLoading) {
return; return;
} }
...@@ -218,18 +221,13 @@ export default { ...@@ -218,18 +221,13 @@ export default {
supplement_num, supplement_num,
callBack, callBack,
} = payload; } = payload;
console.log(jobParams, 'jobParams11111111111111');
let new_rest_dates = []; let new_rest_dates = [];
const loadmessage = message.loading('保存中...', 0); const loadmessage = message.loading('保存中...', 0);
let newParams = {}; let newParams = {};
if (subject_type === 1) { if (subject_type === 1) {
newParams = { newParams = {
...jobParams, ...jobParams,
content: jobParams.content,
}; };
console.log(jobParams.content, 'jobParams.content');
console.log(newParams.content, 'newParams');
console.log(newParams, '4444444444444444444444444444444444');
} else if (subject_type === 2) { } else if (subject_type === 2) {
new_rest_dates = [...new Set(new_rest_dates.concat(...rest_dates))]; new_rest_dates = [...new Set(new_rest_dates.concat(...rest_dates))];
for (let i = 0; i < new_rest_dates.length; i++) { for (let i = 0; i < new_rest_dates.length; i++) {
...@@ -237,12 +235,8 @@ export default { ...@@ -237,12 +235,8 @@ export default {
} }
newParams = { newParams = {
...calendarParams, ...calendarParams,
content: calendarParams.content,
}; };
} }
console.log(newParams, 'newJobParams');
console.log(payload, 'payload1111111111111111');
console.log(Object.assign(newParams, payload), '1111111111111111111111111111222222');
const postFunction = (newParams.id != undefined) && newParams.id !== 0 ? themeAjax.editTheme : themeAjax.addTheme; const postFunction = (newParams.id != undefined) && newParams.id !== 0 ? themeAjax.editTheme : themeAjax.addTheme;
const data = yield call(postFunction, Object.assign(newParams, { const data = yield call(postFunction, Object.assign(newParams, {
is_cheat, is_cheat,
...@@ -270,7 +264,7 @@ export default { ...@@ -270,7 +264,7 @@ export default {
clock_end_time, clock_end_time,
supplement_status, supplement_status,
supplement_num, supplement_num,
content: newParams.content ? JSON.stringify(newParams.content) : JSON.stringify([]), content: subject_type === 1 ? JSON.stringify(jobParams.content) : JSON.stringify(calendarParams.content),
// eslint-disable-next-line prefer-spread // eslint-disable-next-line prefer-spread
rest_dates: rest_dates && rest_dates.length > 0 ? new_rest_dates.join(',') : '', rest_dates: rest_dates && rest_dates.length > 0 ? new_rest_dates.join(',') : '',
})); }));
...@@ -519,7 +513,6 @@ export default { ...@@ -519,7 +513,6 @@ export default {
}); });
setTimeout(loadmessage); setTimeout(loadmessage);
if (data.code === 200) { if (data.code === 200) {
console.log(data, 'data');
yield put({ yield put({
type: 'updateState', type: 'updateState',
payload: { payload: {
...@@ -798,21 +791,59 @@ export default { ...@@ -798,21 +791,59 @@ export default {
}, },
}); });
}, },
* changeText({ payload }, { call, put, select }) { * jobChangeSize({ payload }, { call, put, select }) {
const { textValue, index } = payload;
const { jobParams } = yield select(state => state.createtheme);
jobParams.content[index] = {
type: 'text',
value: textValue,
};
yield put({
type: 'updateState',
payload: {
jobParams: { ...jobParams },
},
});
},
* changeJobText({ payload }, { call, put, select }) {
const { textValue } = payload; const { textValue } = payload;
const { jobParams } = yield select(state => state.createtheme);
jobParams.content.push({
type: 'text',
value: '',
});
yield put({ yield put({
type: 'updateState', type: 'updateState',
payload: { payload: {
editorText: textValue, jobParams: { ...jobParams },
}, },
}); });
}, },
* changeCalendarText({ payload }, { call, put, select }) { * calendarChangeSize({ payload }, { call, put, select }) {
const { textValue, index } = payload;
const { calendarParams } = yield select(state => state.createtheme);
calendarParams.content[index] = {
type: 'text',
value: textValue,
};
yield put({
type: 'updateState',
payload: {
calendarParams: { ...calendarParams },
},
});
},
* addCalendarText({ payload }, { call, put, select }) {
const { textValue } = payload; const { textValue } = payload;
const { calendarParams } = yield select(state => state.createtheme);
calendarParams.content.push({
type: 'text',
value: '',
});
yield put({ yield put({
type: 'updateState', type: 'updateState',
payload: { payload: {
calendarText: textValue, calendarParams: { ...calendarParams },
}, },
}); });
}, },
...@@ -1055,6 +1086,7 @@ export default { ...@@ -1055,6 +1086,7 @@ export default {
sid: 0, sid: 0,
classList: [], classList: [],
editorText: '', editorText: '',
tabIndex: 1,
jobParams: { jobParams: {
is_cheat: 0, is_cheat: 0,
title: '', title: '',
......
...@@ -185,7 +185,7 @@ export default { ...@@ -185,7 +185,7 @@ export default {
* deleteTheme({ payload }, { call, put, select }) { * deleteTheme({ payload }, { call, put, select }) {
const { id, record } = payload; const { id, record } = payload;
const { sid } = yield select(state => state.webapp); const { sid } = yield select(state => state.webapp);
const postFunction = record.subject_type == 3 ? '' : themeAjax.deleteTheme; const postFunction = record.subject_type == 3 ? themeAjax.deleteSubject : themeAjax.deleteTheme;
const goodsdelete = yield call(postFunction, { const goodsdelete = yield call(postFunction, {
id, id,
school_id: sid, school_id: sid,
......
...@@ -31,6 +31,10 @@ class ThemeEditor extends React.Component { ...@@ -31,6 +31,10 @@ class ThemeEditor extends React.Component {
previewVisible: false, previewVisible: false,
}); });
} }
change = (e, index) => {
console.log(e.target.value, 'textValue12');
console.log(index, 'index');
}
render() { render() {
const { previewVisible, previewImage } = this.state; const { previewVisible, previewImage } = this.state;
const { const {
...@@ -41,10 +45,18 @@ class ThemeEditor extends React.Component { ...@@ -41,10 +45,18 @@ class ThemeEditor extends React.Component {
deleteThemeImg, deleteThemeImg,
deleteThemeVideo, deleteThemeVideo,
editorText, editorText,
editorAddText,
} = this.props; } = this.props;
return ( return (
<div className={pageStyle.container}> <div className={pageStyle.container}>
<TextArea value={editorText} onChange={e => editorChange(e)} placeholder="请输入内容" style={{ width: 560 }} maxLength={500} rows={6} /> {commentParams.content.map((item, index) => (
item.type === 'text' &&
<div className={pageStyle.textWrap}>
<TextArea autosize={{ minRows: 4, maxRows: 10 }} value={item.value} onChange={e => editorChange(e, index)} placeholder="请输入内容" style={{ width: 560 }} maxLength={500} />
<div className={pageStyle.sizeNumber}>{item.value.length}/500</div>
<div onClick={() => deleteThemeImg(index)} className={pageStyle.delete}><Icon type="close-circle" theme="filled" /></div>
</div>
))}
<div className={pageStyle.editorwrap}> <div className={pageStyle.editorwrap}>
<div className={pageStyle.uploadimgbox}> <div className={pageStyle.uploadimgbox}>
{commentParams.content.map((item, index) => ( {commentParams.content.map((item, index) => (
...@@ -70,6 +82,7 @@ class ThemeEditor extends React.Component { ...@@ -70,6 +82,7 @@ class ThemeEditor extends React.Component {
</div> </div>
</div> </div>
<div className={pageStyle.uploadflex}> <div className={pageStyle.uploadflex}>
<div className={pageStyle.uploadimg} onClick={editorAddText}><Icon style={{ marginRight: 10 }} type="font-size" />添加文字</div>
<div className={pageStyle.uploadimg}><input type="file" id="uploadImg" className={pageStyle.fileuploadinput} onChange={editorUploadImg} accept="image/*" /><Icon style={{ marginRight: 10 }} type="picture" />添加图片</div> <div className={pageStyle.uploadimg}><input type="file" id="uploadImg" className={pageStyle.fileuploadinput} onChange={editorUploadImg} accept="image/*" /><Icon style={{ marginRight: 10 }} type="picture" />添加图片</div>
<div className={pageStyle.uploadimg}><input type="file" id="uploadVideo" className={pageStyle.fileuploadinput} onChange={editorUploadAudio} accept="video/*" /><Icon style={{ marginRight: 10 }} type="video-camera" />添加视频</div> <div className={pageStyle.uploadimg}><input type="file" id="uploadVideo" className={pageStyle.fileuploadinput} onChange={editorUploadAudio} accept="video/*" /><Icon style={{ marginRight: 10 }} type="video-camera" />添加视频</div>
</div> </div>
......
.textWrap {
width: 560px;
height: auto;
position: relative;
:global {
.ant-input {
padding: 6px 15px 20px;
}
}
.sizeNumber {
position: absolute;
bottom: 8px;
right: 10px;
}
.delete {
position: absolute;
top: 0;
right: 10px;
cursor: pointer;
color:#FF7373;
:global {
.anticon {
font-size: 20px;
}
}
}
}
.editorwrap { .editorwrap {
width: 563px; width: 563px;
margin-top: 15px; margin-top: 15px;
......
...@@ -129,17 +129,18 @@ class CalendarClockForm extends React.Component { ...@@ -129,17 +129,18 @@ class CalendarClockForm extends React.Component {
}, },
}); });
} }
editorChange = (e) => { editorChange = (e, index) => {
const { dispatch } = this.props; const { dispatch } = this.props;
const textValue = e.target.value; const textValue = e.target.value;
if (textValue.length >= 500) { if (textValue.length > 500) {
message.error('最多500字', 0.5); message.error('最多500字', 0.5);
return; return;
} }
dispatch({ dispatch({
type: 'createtheme/changeCalendarText', type: 'createtheme/calendarChangeSize',
payload: { payload: {
textValue, textValue,
index,
}, },
}); });
} }
...@@ -218,6 +219,14 @@ class CalendarClockForm extends React.Component { ...@@ -218,6 +219,14 @@ class CalendarClockForm extends React.Component {
calendarShow: false, calendarShow: false,
}); });
} }
calendarAddText = () => {
const { dispatch } = this.props;
dispatch({
type: 'createtheme/addCalendarText',
payload: {
},
});
}
render() { render() {
const { isShow, calendarShow, title } = this.state; const { isShow, calendarShow, title } = this.state;
const { const {
...@@ -225,7 +234,6 @@ class CalendarClockForm extends React.Component { ...@@ -225,7 +234,6 @@ class CalendarClockForm extends React.Component {
themeAddLoading, themeAddLoading,
classList, classList,
calendarParams, calendarParams,
calendarText,
dateArray, dateArray,
rest_dates, rest_dates,
calendarData, calendarData,
...@@ -271,7 +279,7 @@ class CalendarClockForm extends React.Component { ...@@ -271,7 +279,7 @@ class CalendarClockForm extends React.Component {
}, },
}; };
const selectBefore = ( const selectBefore = (
<div>{title.length || 0}/20</div> <div>{calendarParams.title ? calendarParams.title.length : title.length || 0}/20</div>
); );
const dateFormat = 'YYYY/MM/DD HH:mm'; const dateFormat = 'YYYY/MM/DD HH:mm';
return ( return (
...@@ -516,7 +524,7 @@ class CalendarClockForm extends React.Component { ...@@ -516,7 +524,7 @@ class CalendarClockForm extends React.Component {
</FormItem> </FormItem>
{getFieldValue('audio_require_status') === true ? ( {getFieldValue('audio_require_status') === true ? (
<FormItem {...formItemverticalLayout} labelAlign="right" label="学员打卡最少"> <FormItem {...formItemverticalLayout} labelAlign="right" label="学员打卡最少">
{getFieldDecorator('audio_require_num', { initialValue: calendarParams.audio_require_status })( {getFieldDecorator('audio_require_num', { initialValue: calendarParams.audio_require_num })(
<InputNumber placeholder="请输入" min={0} max={600} style={{ width: 100 }} />, <InputNumber placeholder="请输入" min={0} max={600} style={{ width: 100 }} />,
)} )}
<span className="ant-form-text">秒录音</span> <span className="ant-form-text">秒录音</span>
...@@ -598,7 +606,7 @@ class CalendarClockForm extends React.Component { ...@@ -598,7 +606,7 @@ class CalendarClockForm extends React.Component {
editorUploadAudio={this.jobUploadAudio} editorUploadAudio={this.jobUploadAudio}
editorChange={this.editorChange} editorChange={this.editorChange}
deleteThemeImg={this.deleteCalendarImg} deleteThemeImg={this.deleteCalendarImg}
editorText={calendarText} editorAddText={this.calendarAddText}
/> />
<FormItem {...submitFormLayout} style={{ marginTop: 32 }}> <FormItem {...submitFormLayout} style={{ marginTop: 32 }}>
<Button type="primary" htmlType="submit" loading={themeAddLoading}> <Button type="primary" htmlType="submit" loading={themeAddLoading}>
......
...@@ -18,10 +18,10 @@ class NewThemeForm extends React.Component { ...@@ -18,10 +18,10 @@ class NewThemeForm extends React.Component {
} }
tabChange=(key) => { tabChange=(key) => {
const { dispatch, tabIndex } = this.props; const { dispatch, tabIndex } = this.props;
// if (Number(key) === 3) { if (Number(key) === 3) {
// message.warning('功能即将开放,敬请期待', 1); message.warning('功能即将开放,敬请期待', 1);
// return; return;
// } }
dispatch({ dispatch({
type: 'createtheme/tabChange', type: 'createtheme/tabChange',
payload: { payload: {
......
...@@ -121,17 +121,18 @@ class JobClockForm extends React.Component { ...@@ -121,17 +121,18 @@ class JobClockForm extends React.Component {
}, },
}); });
} }
editorChange = (e) => { jobChangeSize = (e, index) => {
const { dispatch } = this.props; const { dispatch } = this.props;
const textValue = e.target.value; const textValue = e.target.value;
if (textValue.length >= 500) { if (textValue.length > 500) {
message.error('最多500字', 0.5); message.error('最多500字', 0.5);
return; return;
} }
dispatch({ dispatch({
type: 'createtheme/changeText', type: 'createtheme/jobChangeSize',
payload: { payload: {
textValue, textValue,
index,
}, },
}); });
} }
...@@ -166,6 +167,14 @@ class JobClockForm extends React.Component { ...@@ -166,6 +167,14 @@ class JobClockForm extends React.Component {
disabledDate = (current) => { disabledDate = (current) => {
return current && current < moment(new Date(new Date().getTime() - (24 * 3600 * 1000))); return current && current < moment(new Date(new Date().getTime() - (24 * 3600 * 1000)));
} }
jobAddText = () => {
const { dispatch } = this.props;
dispatch({
type: 'createtheme/changeJobText',
payload: {
},
});
}
render() { render() {
const { isShow, title } = this.state; const { isShow, title } = this.state;
const { const {
...@@ -212,7 +221,7 @@ class JobClockForm extends React.Component { ...@@ -212,7 +221,7 @@ class JobClockForm extends React.Component {
}, },
}; };
const selectBefore = ( const selectBefore = (
<div>{title.length || 0}/20</div> <div>{jobParams.title ? jobParams.title.length : title.length || 0}/20</div>
); );
const dateFormat = 'YYYY/MM/DD HH:mm'; const dateFormat = 'YYYY/MM/DD HH:mm';
return ( return (
...@@ -353,7 +362,7 @@ class JobClockForm extends React.Component { ...@@ -353,7 +362,7 @@ class JobClockForm extends React.Component {
</FormItem> </FormItem>
{getFieldValue('video_require_status') === true ? ( {getFieldValue('video_require_status') === true ? (
<FormItem {...formItemverticalLayout} labelAlign="right" label="学员打卡最少"> <FormItem {...formItemverticalLayout} labelAlign="right" label="学员打卡最少">
{getFieldDecorator('video_require_num', { initialValue: jobParams.video_require_status })( {getFieldDecorator('video_require_num', { initialValue: jobParams.video_require_num })(
<InputNumber placeholder="请输入" min={0} max={9} style={{ width: 100 }} />, <InputNumber placeholder="请输入" min={0} max={9} style={{ width: 100 }} />,
)} )}
<span className="ant-form-text">个视频</span> <span className="ant-form-text">个视频</span>
...@@ -433,9 +442,9 @@ class JobClockForm extends React.Component { ...@@ -433,9 +442,9 @@ class JobClockForm extends React.Component {
commentParams={jobParams} commentParams={jobParams}
editorUploadImg={this.jobUploadImg} editorUploadImg={this.jobUploadImg}
editorUploadAudio={this.jobUploadAudio} editorUploadAudio={this.jobUploadAudio}
editorChange={this.editorChange} editorChange={this.jobChangeSize}
deleteThemeImg={this.deleteJobImg} deleteThemeImg={this.deleteJobImg}
editorText={editorText} editorAddText={this.jobAddText}
/> />
<FormItem {...submitFormLayout} style={{ marginTop: 32 }}> <FormItem {...submitFormLayout} style={{ marginTop: 32 }}>
<Button type="primary" htmlType="submit" loading={themeAddLoading}> <Button type="primary" htmlType="submit" loading={themeAddLoading}>
......
...@@ -137,6 +137,10 @@ class ThemeMgt extends React.Component { ...@@ -137,6 +137,10 @@ class ThemeMgt extends React.Component {
} }
editTheme = (record) => { editTheme = (record) => {
const { dispatch } = this.props; const { dispatch } = this.props;
if (record.subject_type == 3) {
message.error('闯关打卡暂时不支持编辑哟', 1);
return;
}
dispatch({ dispatch({
type: 'createtheme/editGoTheme', type: 'createtheme/editGoTheme',
payload: { payload: {
...@@ -147,7 +151,6 @@ class ThemeMgt extends React.Component { ...@@ -147,7 +151,6 @@ class ThemeMgt extends React.Component {
deleteTheme = (record) => { deleteTheme = (record) => {
const me = this; const me = this;
const { dispatch } = me.props; const { dispatch } = me.props;
console.log(record, 'record1111111');
Modal.confirm({ Modal.confirm({
title: `确定删除“${record.title}”?`, title: `确定删除“${record.title}”?`,
content: '删除后不可恢复,请谨慎操作!', content: '删除后不可恢复,请谨慎操作!',
......
...@@ -23,6 +23,12 @@ export function deleteTheme({ id }) { ...@@ -23,6 +23,12 @@ export function deleteTheme({ id }) {
method: 'DELETE', method: 'DELETE',
}); });
} }
export function deleteSubject({ id }) {
return request({
url: `${api.createtheme.delete_unlock_subject}/${id}`,
method: 'DELETE',
});
}
export function addEmigrated(params) { export function addEmigrated(params) {
const data = qs.stringify(params); const data = qs.stringify(params);
return request({ return request({
......
...@@ -816,4 +816,5 @@ export { ...@@ -816,4 +816,5 @@ export {
getWeek, getWeek,
unique1, unique1,
getWeekDay, getWeekDay,
getDateStamp,
}; };
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