From 28d20554129bea86a0889a132cee538b48256c76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Fri, 6 Sep 2019 19:44:05 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/react/src/AppConfig.js | 20 +++++----- .../user/usersInfo/banks/NewGtaskForm.js | 38 ++++++++++--------- 2 files changed, 31 insertions(+), 27 deletions(-) diff --git a/public/react/src/AppConfig.js b/public/react/src/AppConfig.js index 2fbee86da..939d2cdaa 100644 --- a/public/react/src/AppConfig.js +++ b/public/react/src/AppConfig.js @@ -21,16 +21,16 @@ let hashTimeout // TODO 开发期多个身份切换 let debugType ="" -// if (isDev) { -// const _search = window.location.search; -// let parsed = {}; -// if (_search) { -// parsed = queryString.parse(_search); -// } -// debugType = window.location.search.indexOf('debug=t') != -1 ? 'teacher' : -// window.location.search.indexOf('debug=s') != -1 ? 'student' : -// window.location.search.indexOf('debug=a') != -1 ? 'admin' : parsed.debug || 'admin' -// } +if (isDev) { + const _search = window.location.search; + let parsed = {}; + if (_search) { + parsed = queryString.parse(_search); + } + debugType = window.location.search.indexOf('debug=t') != -1 ? 'teacher' : + window.location.search.indexOf('debug=s') != -1 ? 'student' : + window.location.search.indexOf('debug=a') != -1 ? 'admin' : parsed.debug || 'admin' +} window._debugType = debugType; export function initAxiosInterceptors(props) { diff --git a/public/react/src/modules/user/usersInfo/banks/NewGtaskForm.js b/public/react/src/modules/user/usersInfo/banks/NewGtaskForm.js index cfd85b260..16f77ad46 100644 --- a/public/react/src/modules/user/usersInfo/banks/NewGtaskForm.js +++ b/public/react/src/modules/user/usersInfo/banks/NewGtaskForm.js @@ -19,6 +19,7 @@ class NewGtaskForms extends Component{ initValue = (data) => { + if (data.isEdit===true) { const contentFileList = data.attachments.map(item => { return { id: item.id, @@ -31,10 +32,10 @@ class NewGtaskForms extends Component{ }) this.setState({ ...data, - base_on_project: data.group_info.base_on_project, + base_on_project: data.task_type===2?data.group_info.base_on_project:undefined, title_num: parseInt(data.name.length), - min_num: data.group_info.min_number, - max_num: data.group_info.max_number, + min_num: data.task_type===2?data.group_info.min_number:undefined, + max_num: data.task_type===2?data.group_info.max_number:undefined, contentFileList, }, () => { setTimeout(() => { @@ -47,6 +48,8 @@ class NewGtaskForms extends Component{ }); }) + } + } @@ -120,27 +123,28 @@ class NewGtaskForms extends Component{ values.description = mdContnet; if (!err) { + if (this.props.data.isEdit===true) { let url="/task_banks/"+topicId+".json"; axios.put(url, { - gtask_bank: { - name: values.title, - description: values.description, - min_num:task_type===1?undefined:min_num, - max_num:task_type===1?undefined:max_num, - base_on_project: task_type===1?undefined:base_on_project===true?1:0 - }, - attachment_ids:contentFileList + gtask_bank: { + name: values.title, + description: values.description, + min_num:task_type===1?undefined:min_num, + max_num:task_type===1?undefined:max_num, + base_on_project: task_type===1?undefined:base_on_project===true?1:0 + }, + attachment_ids:contentFileList } ).then((response) => { - if(response.data.status===0){ - this.props.showNotification(response.data.message) - }else{ - this.props.showNotification(response.data.message) - } + if(response.data.status===0){ + this.props.showNotification(response.data.message) + }else{ + this.props.showNotification(response.data.message) + } }).catch((error) => { console.log(error) }) - + } } else { $("html").animate({ scrollTop: $('html').scrollTop() - 100 }) }