From 90136595f2ab16a3e044fff5251bb42182a88693 Mon Sep 17 00:00:00 2001 From: hjm <63528605@qq.com> Date: Sat, 3 Aug 2019 13:42:36 +0800 Subject: [PATCH 1/6] a href --- public/react/src/common/UrlTool.js | 4 ++- public/react/src/common/educoder.js | 3 +- .../shixunHomework/ShixunhomeWorkItem.js | 32 ++++++++++++------- 3 files changed, 26 insertions(+), 13 deletions(-) diff --git a/public/react/src/common/UrlTool.js b/public/react/src/common/UrlTool.js index 3953f1f34..f224526e6 100644 --- a/public/react/src/common/UrlTool.js +++ b/public/react/src/common/UrlTool.js @@ -59,4 +59,6 @@ export function toPath(path) { } -// export default queryString \ No newline at end of file +export function getTaskUrlById(id) { + return `/tasks/${id}` +} diff --git a/public/react/src/common/educoder.js b/public/react/src/common/educoder.js index 791b2c6d6..2afbca8d1 100644 --- a/public/react/src/common/educoder.js +++ b/public/react/src/common/educoder.js @@ -3,7 +3,8 @@ import { from } from '_array-flatten@2.1.2@array-flatten'; // export { default as OrderStateUtil } from '../routes/Order/components/OrderStateUtil'; export { getImageUrl as getImageUrl, getUrl as getUrl, getUrl2 as getUrl2, setImagesUrl as setImagesUrl - , getUploadActionUrl as getUploadActionUrl, getUploadActionUrlOfAuth as getUploadActionUrlOfAuth } from './UrlTool'; + , getUploadActionUrl as getUploadActionUrl, getUploadActionUrlOfAuth as getUploadActionUrlOfAuth + , getTaskUrlById as getTaskUrlById } from './UrlTool'; export { default as queryString } from './UrlTool2'; export { SnackbarHOC as SnackbarHOC } from './SnackbarHOC'; diff --git a/public/react/src/modules/courses/shixunHomework/ShixunhomeWorkItem.js b/public/react/src/modules/courses/shixunHomework/ShixunhomeWorkItem.js index d97b58cca..b9aac1e6a 100644 --- a/public/react/src/modules/courses/shixunHomework/ShixunhomeWorkItem.js +++ b/public/react/src/modules/courses/shixunHomework/ShixunhomeWorkItem.js @@ -1,6 +1,6 @@ import React,{ Component } from "react"; import CoursesListType from '../coursesPublic/CoursesListType'; -import { WordsBtn } from 'educoder'; +import { WordsBtn, getTaskUrlById } from 'educoder'; import {Tooltip,message,Modal} from 'antd'; import {Link} from 'react-router-dom'; import axios from 'axios'; @@ -56,7 +56,7 @@ class ShixunhomeWorkItem extends Component{ startbtn:true, }) let url= list+".json"; - const w=window.open('about:blank'); + // const w=window.open('about:blank'); axios.get(url).then((response) => { if(response.status===200){ @@ -66,7 +66,7 @@ class ShixunhomeWorkItem extends Component{ shixunsreplace:true, hidestartshixunsreplacevalue:response.data.message+".json" }) - w.close() + // w.close() }else if(response.data.status===-1){ console.log(response) }else if(response.data.status===-3){ @@ -75,11 +75,15 @@ class ShixunhomeWorkItem extends Component{ startshixunCombattype:true, startbtn:false }) - w.close() + // w.close() }else{ - if(response.data.status!=401&&response.data.status!=403){ - w.location.href= "/tasks/"+response.data.game_identifier - } + this.setState({ + startbtn:false + }) + // if(response.data.status!=401&&response.data.status!=403){ + // w.location.href= "/tasks/"+response.data.game_identifier + // } + window.location.href = "/tasks/"+response.data.game_identifier } } @@ -87,7 +91,7 @@ class ShixunhomeWorkItem extends Component{ this.setState({ startbtn:false }) - w.close() + // w.close() }); @@ -389,9 +393,15 @@ class ShixunhomeWorkItem extends Component{ {this.props.isStudent===true?this.props.course_identity===5? - {startbtn===false?this.taskoperationId(discussMessage.task_operation[1])}> - {discussMessage.task_operation[0]} - :开启中} + {startbtn===false? + (discussMessage.task_operation[0] == '继续挑战' || discussMessage.task_operation[0] == '查看实战' ? + + {discussMessage.task_operation[0]} + + : + this.taskoperationId(discussMessage.task_operation[1])}> + {discussMessage.task_operation[0]} + ):开启中} :"":"" } From 1c3fec0cc799e6e7fcf1501178782bc3e5630ac9 Mon Sep 17 00:00:00 2001 From: hjm <63528605@qq.com> Date: Sat, 3 Aug 2019 14:13:21 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E9=99=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/react/src/modules/forums/MemoDetail.js | 16 +- public/react/src/modules/forums/MemoNew.js | 158 +++++++++++++++--- 2 files changed, 138 insertions(+), 36 deletions(-) diff --git a/public/react/src/modules/forums/MemoDetail.js b/public/react/src/modules/forums/MemoDetail.js index 0731c9a39..60c26b09d 100644 --- a/public/react/src/modules/forums/MemoDetail.js +++ b/public/react/src/modules/forums/MemoDetail.js @@ -180,18 +180,16 @@ class MemoDetail extends Component { }) } renderAttachment() { - const { memo } = this.props; + const { memo, attachments_list } = this.props; const attachments = [] - memo.attachment_url.forEach((item, index) => { + attachments_list.forEach((item, index) => { const ar = item.url.split('/') - const fileName = item.filename || ar[ar.length - 1] - let filesize = 0 - if (item.filesize) { - filesize = bytesToSize(item.filesize) - } + const fileName = item.title + let filesize = item.filesize + attachments.push(

- + {fileName}{filesize? ` ${filesize}` : ''}

@@ -777,7 +775,7 @@ class MemoDetail extends Component {

- { memo.attachment_url && !!memo.attachment_url.length && + { this.props.attachments_list &&
{this.renderAttachment()}
diff --git a/public/react/src/modules/forums/MemoNew.js b/public/react/src/modules/forums/MemoNew.js index 98d95ddce..3eb83dc06 100644 --- a/public/react/src/modules/forums/MemoNew.js +++ b/public/react/src/modules/forums/MemoNew.js @@ -7,17 +7,17 @@ import PropTypes from 'prop-types'; import classNames from 'classnames' -import { Select,Icon } from 'antd'; +import { Select,Icon, Upload, Button } from 'antd'; // demo http://react-component.github.io/upload/examples/simple.html -import Upload from 'rc-upload'; +// import Upload from 'rc-upload'; import axios from 'axios' import 'antd/lib/select/style/index.css' import TPMMDEditor from '../tpm/challengesnew/TPMMDEditor' -import { getUrl } from 'educoder' +import { getUrl, getUploadActionUrl, appendFileSizeToUploadFileAll, appendFileSizeToUploadFile } from 'educoder' const Option = Select.Option; const $ = window.$; @@ -169,7 +169,9 @@ class MemoNew extends Component { repertoires: [], currentSelectRepertoiresIndex: -1, - repertoiresTagMap: {} + repertoiresTagMap: {}, + + fileList: [] } } onCommit() { @@ -207,19 +209,21 @@ class MemoNew extends Component { // collect attachments const $ = window.$; const attachmentsMap = {}; - const attachmentIds = [] - $('#attachments_fields .attachment').each(( index, item ) => { - const filename = $(item).find('.upload_filename').val(); - // $($('#attachments_fields .attachment')[0]).find('input:nth-child(6)').val() - const token = $(item).find('input:nth-child(7)').val() - const attachment_id = parseInt($(item).children().last().val()) - attachmentsMap[index] = { - filename, - token, - attachment_id - } - attachmentIds.push(attachment_id) + const attachmentIds = this.state.fileList.map(item => { + return item.response ? item.response.id : item.id }) + // $('#attachments_fields .attachment').each(( index, item ) => { + // const filename = $(item).find('.upload_filename').val(); + // // $($('#attachments_fields .attachment')[0]).find('input:nth-child(6)').val() + // const token = $(item).find('input:nth-child(7)').val() + // const attachment_id = parseInt($(item).children().last().val()) + // attachmentsMap[index] = { + // filename, + // token, + // attachment_id + // } + // attachmentIds.push(attachment_id) + // }) if (currentMemoId) { @@ -253,7 +257,7 @@ class MemoNew extends Component { // language: memoLanguage.join(languageSeparator), // // }, - attachments: attachmentsMap + attachment_ids: attachmentsMap }, { // withCredentials: true, }) @@ -283,7 +287,7 @@ class MemoNew extends Component { // repertoire_name: memoRepertoire, // }, - attachments: attachmentsMap + attachment_ids: attachmentsMap }, { // withCredentials: true, }) @@ -349,7 +353,7 @@ class MemoNew extends Component { if (tag_list) { // this.setState({...response.data}) const { content, forum_id, id, repertoire_name, subject, - current_user, tag_list, attachments_url, memo_tags } = response.data; + current_user, tag_list, attachments_url, memo_tags, attachments } = response.data; this.initMD(content); // this.onRepertoiresChange(repertoire_name) // tag -> memo_tags @@ -360,7 +364,18 @@ class MemoNew extends Component { return item.id + "" }) } + const fileList = attachments.map(item => { + return { + id: item.id, + uid: item.id, + name: appendFileSizeToUploadFile(item), + url: item.url, + filesize: item.filesize, + status: 'done' + } + }) this.setState({ + fileList, currentMemoId: memoId, memoSubject: subject, memoType: forum_id, @@ -531,6 +546,55 @@ class MemoNew extends Component { ) }) return attachments; + } + handleChange = (info) => { + let fileList = info.fileList; + this.setState({ + fileList: appendFileSizeToUploadFileAll(fileList) + }); + } + onAttachmentRemove = (file) => { + this.props.confirm({ + // title: '确定要删除这个附件吗?', + content: '是否确认删除?', + + okText: '确定', + cancelText: '取消', + // content: 'Some descriptions', + onOk: () => { + this.deleteAttachment(file) + }, + onCancel() { + console.log('Cancel'); + }, + }); + return false; + } + deleteAttachment = (file) => { + // 初次上传不能直接取uid + const url = `/attachments/${file.response ? file.response.id : file.uid}.json` + axios.delete(url, { + }) + .then((response) => { + if (response.data) { + const { status } = response.data; + if (status == 0) { + console.log('--- success') + + this.setState((state) => { + const index = state.fileList.indexOf(file); + const newFileList = state.fileList.slice(); + newFileList.splice(index, 1); + return { + fileList: newFileList, + }; + }); + } + } + }) + .catch(function (error) { + console.log(error); + }); } render() { const { match, history } = this.props @@ -538,8 +602,28 @@ class MemoNew extends Component { // repertoires, repertoiresTagMap, currentSelectRepertoiresIndex, memoRepertoire, tag_list, memoSubject, memoType, - memoLanguage, attachments_url } = this.state; + memoLanguage, attachments_url, fileList } = this.state; const memoId = match.params.memoId; + + const uploadProps = { + width: 600, + fileList, + multiple: true, + // https://github.com/ant-design/ant-design/issues/15505 + // showUploadList={false},然后外部拿到 fileList 数组自行渲染列表。 + // showUploadList: false, + action: `${getUploadActionUrl()}`, + onChange: this.handleChange, + onRemove: this.onAttachmentRemove, + beforeUpload: (file) => { + console.log('beforeUpload', file.name); + const isLt150M = file.size / 1024 / 1024 < 150; + if (!isLt150M) { + // message.error('文件大小必须小于150MB!'); + } + return isLt150M; + }, + }; return (
@@ -592,13 +676,13 @@ class MemoNew extends Component { -
+ {/* { attachments_url && !!attachments_url.length && this.renderAttachment() } - + {debugger;window.addInputFiles( window.$('.file_selector')[0] ) }} style={{'display':'none'}} type="file"> - -
+ + */} + {/*开始上传*/} + + + (单个文件150M以内) + {/* 请求status 422 */} -
+ + {/* */} + {/*
window.$('#_file').click()} data-tip-down="请选择文件上传"> - 上传附件(单个文件50M以内) + 上传附件 + (单个文件50M以内) -
+
*/}
{/* TODOTODO 这里重复的html代码太多,如果有其他页面有类似需求,需要封装*/} From 85842e522632080eed4f4dbebe4d7322b2f19280 Mon Sep 17 00:00:00 2001 From: hjm <63528605@qq.com> Date: Sat, 3 Aug 2019 14:32:41 +0800 Subject: [PATCH 3/6] title --- public/react/src/modules/user/usersInfo/InfosPath.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/public/react/src/modules/user/usersInfo/InfosPath.js b/public/react/src/modules/user/usersInfo/InfosPath.js index d23739280..b7038b0e9 100644 --- a/public/react/src/modules/user/usersInfo/InfosPath.js +++ b/public/react/src/modules/user/usersInfo/InfosPath.js @@ -164,11 +164,14 @@ class InfosPath extends Component{ Subject12

- {item.name} + {item.name}

- {item.owner_name} + 12 ? item.owner_name : ''} style={{ maxWidth: '198px'}} + >{item.owner_name} From 2fb774e24335dbc7858804df9a028528496a9894 Mon Sep 17 00:00:00 2001 From: hjm <63528605@qq.com> Date: Sat, 3 Aug 2019 15:14:08 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E7=BB=9F=E4=B8=80=20noti?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../react/src/modules/forums/ForumsIndex.js | 3 ++- public/react/src/modules/forums/MemoDetail.js | 24 +++++++++---------- public/react/src/modules/forums/MemoNew.js | 16 ++++++------- .../src/modules/forums/PostPaginationHOC.js | 2 +- 4 files changed, 23 insertions(+), 22 deletions(-) diff --git a/public/react/src/modules/forums/ForumsIndex.js b/public/react/src/modules/forums/ForumsIndex.js index 2e5693fa0..c24b92c95 100644 --- a/public/react/src/modules/forums/ForumsIndex.js +++ b/public/react/src/modules/forums/ForumsIndex.js @@ -42,6 +42,7 @@ import './ForumsIndex.css' import './RightSection.css' import { SnackbarHOC, getUrl } from 'educoder' +import { CNotificationHOC } from '../courses/common/CNotificationHOC' let _url_origin = getUrl() @@ -248,7 +249,7 @@ class ForumsIndex extends Component { } } -export default SnackbarHOC() ( TPMIndexHOC ( ForumsIndex ) ); +export default CNotificationHOC() (SnackbarHOC() ( TPMIndexHOC ( ForumsIndex ) )); /* : diff --git a/public/react/src/modules/forums/MemoDetail.js b/public/react/src/modules/forums/MemoDetail.js index 60c26b09d..0a0f4f4ac 100644 --- a/public/react/src/modules/forums/MemoDetail.js +++ b/public/react/src/modules/forums/MemoDetail.js @@ -65,7 +65,7 @@ class MemoDetail extends Component { const memo = response.data.memo if (response.data.status === -1) { setTimeout(() => { - this.props.showSnackbar('帖子不存在!') + this.props.showNotification('帖子不存在!') }, 300) this.props.history.push(`/forums`) return; @@ -127,11 +127,11 @@ class MemoDetail extends Component { const status = response.data.status if (status === 0) { - this.props.showSnackbar('删除成功'); + this.props.showNotification('删除成功'); this.props.history.push(`/forums`) } else if (status === -1) { - this.props.showSnackbar('帖子已被删除'); + this.props.showNotification('帖子已被删除'); this.props.history.push(`/forums`) } }).catch((error) => { @@ -213,9 +213,9 @@ class MemoDetail extends Component { } } replyComment = (commentContent, id, editor) => { - const { showSnackbar } = this.props; + const { showNotification } = this.props; if (!commentContent || commentContent.length === 0) { - showSnackbar('必须填写内容!') + showNotification('必须填写内容!') return; } @@ -375,7 +375,7 @@ class MemoDetail extends Component { }) } rewardCode = (parrentComment, childComment, amount) => { - const { showSnackbar } = this.props; + const { showNotification } = this.props; const { comments } = this.state; let handleComment = parrentComment if (childComment) { @@ -419,12 +419,12 @@ class MemoDetail extends Component { } }).catch((error) => { console.log(error) - showSnackbar('奖励失败,请联系系统管理员!') + showNotification('奖励失败,请联系系统管理员!') }) } hiddenComment = (item, childCommentId) => { const id = item.id - const { showSnackbar } = this.props; + const { showNotification } = this.props; const user = this._getUser(); const url = `/memos/${id}/hidden.json` const { comments } = this.state; @@ -439,7 +439,7 @@ class MemoDetail extends Component { } ).then((response) => { if (response.data.status === -1) { - showSnackbar(response.data.message) + showNotification(response.data.message) return; } if (response.data.status === 0) { @@ -598,7 +598,7 @@ class MemoDetail extends Component { .then((response) => { const status = response.data.status if (status === 0) { - this.props.showSnackbar( memo.sticky ? '取消置顶成功' : '置顶成功'); + this.props.showNotification( memo.sticky ? '取消置顶成功' : '置顶成功'); memo.sticky = memo.sticky ? false : true this.setState({ memo: Object.assign({}, memo) @@ -633,9 +633,9 @@ class MemoDetail extends Component { this.props.initForumState({ memo: newMemo }) - this.props.showSnackbar( '奖励成功' ); + this.props.showNotification( '奖励成功' ); } else { - this.props.showSnackbar( '奖励失败,请联系系统管理员!' ); + this.props.showNotification( '奖励失败,请联系系统管理员!' ); } }).catch((error) => { console.log(error) diff --git a/public/react/src/modules/forums/MemoNew.js b/public/react/src/modules/forums/MemoNew.js index 3eb83dc06..e6482b8b6 100644 --- a/public/react/src/modules/forums/MemoNew.js +++ b/public/react/src/modules/forums/MemoNew.js @@ -176,9 +176,9 @@ class MemoNew extends Component { } onCommit() { const { memoSubject, memoRepertoire, memoLanguage, currentMemoId, memoType } = this.state; - const { showSnackbar } = this.props; + const { showNotification } = this.props; if (!memoSubject) { - showSnackbar('请先输入话题名称') + showNotification('请先输入话题名称') return } let mdVal; @@ -186,17 +186,17 @@ class MemoNew extends Component { mdVal = this.mdRef.current.getValue() } catch (e) { - showSnackbar('编辑器还未加载完毕,请稍后') + showNotification('编辑器还未加载完毕,请稍后') return } if (!mdVal) { - showSnackbar('请先输入话题内容') + showNotification('请先输入话题内容') return } // !memoRepertoire || if (memoType === 5 && ( !memoLanguage || memoLanguage.length === 0 )) { - showSnackbar('请先选择技术标签') + showNotification('请先选择技术标签') return } /* @@ -267,7 +267,7 @@ class MemoNew extends Component { window.$("html,body").animate({"scrollTop":0}) this.props.history.push(`/forums/${currentMemoId}`) } else { - this.props.showSnackbar(message) + this.props.showNotification(message) } }).catch((error) => { console.log(error) @@ -297,7 +297,7 @@ class MemoNew extends Component { window.$("html,body").animate({"scrollTop":0}) this.props.history.push(`/forums/${memo_id}`) } else { - this.props.showSnackbar(message) + this.props.showNotification(message) } }).catch((error) => { console.log(error) @@ -481,7 +481,7 @@ class MemoNew extends Component { onTagChange(value) { if (value && value.length > 3) { - this.props.showSnackbar(`最多选择3个技术标签`) + this.props.showNotification(`最多选择3个技术标签`) return; } diff --git a/public/react/src/modules/forums/PostPaginationHOC.js b/public/react/src/modules/forums/PostPaginationHOC.js index 99370051a..243cffeab 100644 --- a/public/react/src/modules/forums/PostPaginationHOC.js +++ b/public/react/src/modules/forums/PostPaginationHOC.js @@ -276,7 +276,7 @@ return function wrap(WrappedComponent) { const status = response.data.status if (status === 0) { - this.props.showSnackbar('删除成功'); + this.props.showNotification('删除成功'); // 刷新列表 this.fetchMemos(); } From e87665010b273d42f4070f7bc74d014afa52fadf Mon Sep 17 00:00:00 2001 From: hjm <63528605@qq.com> Date: Sat, 3 Aug 2019 15:28:26 +0800 Subject: [PATCH 5/6] =?UTF-8?q?(=E7=A4=BA=E4=BE=8B=E8=AF=BE=E5=A0=82?= =?UTF-8?q?=EF=BC=8C=E9=83=A8=E5=88=86=E6=88=90=E5=91=98=E4=B8=8D=E5=8F=AF?= =?UTF-8?q?=E8=A7=81)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/react/src/modules/courses/members/teacherList.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/public/react/src/modules/courses/members/teacherList.js b/public/react/src/modules/courses/members/teacherList.js index fc6b56313..c7430fa75 100644 --- a/public/react/src/modules/courses/members/teacherList.js +++ b/public/react/src/modules/courses/members/teacherList.js @@ -604,6 +604,7 @@ class studentsList extends Component{ } const isAdminOrTeacher = this.props.isAdminOrTeacher() const hasGraduationModule = this.hasGraduationModule() + const coursesId = this.props.match.params.coursesId return( @@ -624,7 +625,10 @@ class studentsList extends Component{ > + 教师列表 + {coursesId == '1309' && (示例课堂,部分成员不可见)} + } searchValue={ searchValue } onInputSearchChange={this.onInputSearchChange} showSearchInput={total_count >= 10} @@ -641,6 +645,7 @@ class studentsList extends Component{ 已审批({total_count}) 待审批({apply_size}) + {/* */}

: (!!total_count ? : '') } From 10d534bbd59749c7954aa5a1eec1c84f85e4fd51 Mon Sep 17 00:00:00 2001 From: hjm <63528605@qq.com> Date: Sat, 3 Aug 2019 15:51:28 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E5=88=A0=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/react/src/modules/tpm/TPMsettings/TPMsettings.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/react/src/modules/tpm/TPMsettings/TPMsettings.js b/public/react/src/modules/tpm/TPMsettings/TPMsettings.js index 910ea5882..2e34bcffb 100644 --- a/public/react/src/modules/tpm/TPMsettings/TPMsettings.js +++ b/public/react/src/modules/tpm/TPMsettings/TPMsettings.js @@ -1313,7 +1313,7 @@ export default class TPMsettings extends Component {
取消 - {delType===2?确定:确定} + {delType===1?确定:确定}