From f049d7763c066101b30ac397f8b105f2b7637f44 Mon Sep 17 00:00:00 2001 From: hjm <63528605@qq.com> Date: Wed, 24 Jul 2019 15:40:08 +0800 Subject: [PATCH 1/6] addSuc --- .../src/modules/user/account/AccountBasicEdit.js | 11 ++++++++++- .../src/modules/user/modal/ApplyForAddOrgModal.js | 1 + 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/public/react/src/modules/user/account/AccountBasicEdit.js b/public/react/src/modules/user/account/AccountBasicEdit.js index 8af24022d..13741fd5b 100644 --- a/public/react/src/modules/user/account/AccountBasicEdit.js +++ b/public/react/src/modules/user/account/AccountBasicEdit.js @@ -273,6 +273,14 @@ class AccountBasic extends Component { } } + addOrgSuccess = (name) => { + const schoolList = this.state.schoolList.slice(0) + schoolList.push({ id: schoolList.length + 2000, name: name}) + this.setState({ schoolList }) + this.props.form.setFieldsValue({ + name: name + }) + } showApplyForAddOrgModal = () => { this.applyForAddOrgForm.setVisible(true) @@ -309,7 +317,8 @@ class AccountBasic extends Component { return (
this.applyForAddOrgForm = form} schoolName={school} - {...propsWithoutForm}> + {...propsWithoutForm} addOrgSuccess={this.addOrgSuccess} + > this.applyForAddChildOrgForm = form} > diff --git a/public/react/src/modules/user/modal/ApplyForAddOrgModal.js b/public/react/src/modules/user/modal/ApplyForAddOrgModal.js index 95cfa9105..72ae542c6 100644 --- a/public/react/src/modules/user/modal/ApplyForAddOrgModal.js +++ b/public/react/src/modules/user/modal/ApplyForAddOrgModal.js @@ -48,6 +48,7 @@ class ApplyForAddOrgModal extends Component{ }).then((result)=>{ if(result){ this.props.showNotification("新增学校/单位成功!"); + this.props.addOrgSuccess(values.schoolName) this.setVisible(false); } }).catch((error)=>{ From 42c2cc50cb2099dd8630806ebc3da9bff0e087fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Wed, 24 Jul 2019 18:02:32 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/modules/courses/new/CoursesNew.js | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/public/react/src/modules/courses/new/CoursesNew.js b/public/react/src/modules/courses/new/CoursesNew.js index 149f9bc27..87b6c63ab 100644 --- a/public/react/src/modules/courses/new/CoursesNew.js +++ b/public/react/src/modules/courses/new/CoursesNew.js @@ -46,7 +46,8 @@ class CoursesNew extends Component { let coursesId = this.props.match.params.coursesId; let user_school=this.props.current_user&&this.props.current_user.user_school; - + this.getschool("") + this.Searchvalue("") if (coursesId != undefined) { let url = "/courses/" + coursesId + "/settings.json" axios.get(url).then((result) => { @@ -85,8 +86,7 @@ class CoursesNew extends Component { }) } - this.getschool("") - this.Searchvalue("") + } componentDidUpdate(prevProps){ @@ -292,7 +292,8 @@ class CoursesNew extends Component { search:value }).then((result)=>{ // console.log(result.data) - if (result.data.status===0) { + if (result.data.message===undefined) { + this.setState({ searchlist: result.data.course_lists, // course:value, @@ -357,7 +358,9 @@ class CoursesNew extends Component { }; getschool=(value)=>{ - + this.props.form.setFieldsValue({ + school: value + }) let url="/schools/school_list.json"; axios.get(url,{ params: { @@ -369,9 +372,7 @@ class CoursesNew extends Component { searchlistscholl: result.data.school_names, school: value }) - this.props.form.setFieldsValue({ - school: value - }) + } }).catch((error)=>{ console.log(error) @@ -389,7 +390,7 @@ class CoursesNew extends Component { const optionschool = this.state.searchlistscholl&&this.state.searchlistscholl.map(z => ); // console.log(this.props.current_user.user_school) // form合并了 - // console.log(optionschool) + console.log(options) return ( From 4b388e090b74a950e4dfb5be88fb29ba1d4d90e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=9E=97?= <904079904@qq.com> Date: Wed, 24 Jul 2019 18:02:59 +0800 Subject: [PATCH 3/6] =?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/modules/user/Interestpage.js | 2 ++ public/react/src/modules/user/InterestpageMax.js | 8 +++----- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/public/react/src/modules/user/Interestpage.js b/public/react/src/modules/user/Interestpage.js index dbca5a242..1054d620e 100644 --- a/public/react/src/modules/user/Interestpage.js +++ b/public/react/src/modules/user/Interestpage.js @@ -192,6 +192,8 @@ class InterestpageComponent extends Component { ints.push(this.state.gouxuans4[i].id); } } + console.log("195195"); + console.log(ints); if(ints.length<1){ this.openNotification("请至少选择一个您感兴趣的内容"); return diff --git a/public/react/src/modules/user/InterestpageMax.js b/public/react/src/modules/user/InterestpageMax.js index e0585ed33..6dc182154 100644 --- a/public/react/src/modules/user/InterestpageMax.js +++ b/public/react/src/modules/user/InterestpageMax.js @@ -182,10 +182,6 @@ class InterestpageMax extends Component { //兴趣页面点击 Interestcompletionpage(){ - - this.setState({ - setpagecomplet:true - }) if(this.state.gouxuans.length === 0){ this.openNotification("请选择职业"); return @@ -197,6 +193,8 @@ class InterestpageMax extends Component { ints.push(this.state.gouxuans4[i].id); } } + console.log("200200"); + console.log(ints); if(ints.length<1){ this.openNotification("请至少选择一个您感兴趣的内容"); return @@ -302,7 +300,7 @@ class InterestpageMax extends Component { ) })}
- + From 47c6b5446d7f53069ccf7bb089f4c2c5825c9471 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Wed, 24 Jul 2019 18:04:47 +0800 Subject: [PATCH 4/6] =?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/modules/courses/new/CoursesNew.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/public/react/src/modules/courses/new/CoursesNew.js b/public/react/src/modules/courses/new/CoursesNew.js index 87b6c63ab..6e996297b 100644 --- a/public/react/src/modules/courses/new/CoursesNew.js +++ b/public/react/src/modules/courses/new/CoursesNew.js @@ -152,7 +152,7 @@ class CoursesNew extends Component { } if(values.school===""||values.school===undefined){ - this.scrollToAnchor("isschool") + // this.scrollToAnchor("isschool") return } @@ -220,7 +220,7 @@ class CoursesNew extends Component { return } if(values.school===""||values.school===undefined){ - this.scrollToAnchor("isschool") + // this.scrollToAnchor("isschool") return } From 3d316e2e4e381eb4c58504e15c1af08bdd880d55 Mon Sep 17 00:00:00 2001 From: hjm <63528605@qq.com> Date: Wed, 24 Jul 2019 18:06:43 +0800 Subject: [PATCH 5/6] account --- .../modules/user/account/AccountBasicEdit.js | 148 +++++++++++++++--- .../user/modal/ApplyForAddChildOrgModal.js | 8 +- 2 files changed, 132 insertions(+), 24 deletions(-) diff --git a/public/react/src/modules/user/account/AccountBasicEdit.js b/public/react/src/modules/user/account/AccountBasicEdit.js index 13741fd5b..c3b150229 100644 --- a/public/react/src/modules/user/account/AccountBasicEdit.js +++ b/public/react/src/modules/user/account/AccountBasicEdit.js @@ -1,7 +1,7 @@ import React, { Component } from 'react'; import { SnackbarHOC, getImageUrl, City, ConditionToolTip } from 'educoder'; -import { Form, Button, Input, Radio, Select, Tooltip, Icon } from 'antd' +import { Form, Button, Input, Radio, Select, Tooltip, Icon, AutoComplete } from 'antd' import ApplyForAddOrgModal from '../modal/ApplyForAddOrgModal' import ApplyForAddChildOrgModal from '../modal/ApplyForAddChildOrgModal' import axios from 'axios' @@ -84,14 +84,29 @@ class AccountBasic extends Component { } // 获取学校、单位 - getSchoolList=(basicInfo)=>{ + getSchoolList=(basicInfo, selectedName)=>{ let url=`/schools/for_option.json`; axios.get(url).then((result)=>{ if(result){ this.setState({ schoolList:result.data.schools }) - if(basicInfo && basicInfo.school_name){ + if (selectedName) { + let school_id + result.data.schools.reverse().some( item => { + if (item.name == selectedName) { + school_id = item.id + return true; + } + }) + this.props.form.setFieldsValue({ + org: selectedName + }) + this.setState({ + school_id, + school: selectedName + }) + } else if(basicInfo && basicInfo.school_name){ this.setState({ school:basicInfo.school_name, filterSchoolList:this.state.schoolList.filter(function(item){ @@ -119,6 +134,15 @@ class AccountBasic extends Component { console.log(values); let {basicInfo}=this.props; if(!err ){ + if (!this.state.school_id) { + this.props.showNotification('请先请先选择学校/单位') + return; + } + if (!this.state.department_id) { + this.props.showNotification('请先选择院系/部门') + return; + } + let url=`/users/accounts/${basicInfo.id}.json` axios.put((url),{ nickname:values.nickname, @@ -187,6 +211,10 @@ class AccountBasic extends Component { school:e, filterSchoolList:arr }) + } else { + this.setState({ + school: '', + }) } // else{ // let {school}=this.state; @@ -208,17 +236,30 @@ class AccountBasic extends Component { filterDepartments:arr, departmentsName:e }) + } else { + this.setState({ + filterDepartments: this.state.departments + }) } } // 选择部门、学院 changeDepartment=(e)=>{ - let arr= this.state.departments && this.state.departments.filter ? this.state.departments.filter(function(item){ + let arr = this.state.departments && this.state.departments.filter ? this.state.departments.filter(function(item){ return item.name == e; }) : []; + if (!arr[0]) { + this.setState({ + department_id: '', + departmentsName: e, + }) + this.this_department_id = '' + return; + } + this.this_department_id = arr[0].id this.setState({ departmentsName:e, - department_id:arr[0].id + department_id: arr[0].id }) } @@ -231,20 +272,57 @@ class AccountBasic extends Component { let arr=this.state.schoolList.filter(function(item){ return item.name == e; }); + if (!arr[0]) { + // 没找到学校,清空部门 + this.setState({ + departments: [], + filterDepartments: [], + school_id: '', + department_id: '', + }) + this.this_school_id = '' + this.props.form.setFieldsValue({ + org2: '' + }) + return; + } + this.props.form.setFieldsValue({ + org: arr[0].name + }) + this.filterList(e) // 保存选择的学校id + this.this_school_id = arr[0].id this.setState({ - school_id:arr[0].id, + school_id: arr[0].id, school:e, }) - let url=`/schools/${arr[0].id}/departments/for_option.json`; + this._getDepartments(arr[0].id, flag) + } + _getDepartments = (schoolId, flag, selectedName) => { + let url=`/schools/${schoolId || this.state.school_id}/departments/for_option.json`; axios.get(url).then((result)=>{ if(result){ this.setState({ departments:result.data.departments, filterDepartments:result.data.departments }) - // 切换学校后,部门默认选择第一个 - if(result.data.departments && result.data.departments.length>0 && flag==true){ + if (selectedName) { + let department_id + result.data.departments.reverse().some( item => { + if (item.name == selectedName) { + department_id = item.id + return true; + } + }) + this.props.form.setFieldsValue({ + org2: selectedName + }) + this.setState({ + department_id, + // school: selectedName + }) + } else if(result.data.departments && result.data.departments.length>0 && flag==true){ + // 切换学校后,部门默认选择第一个 this.props.form.setFieldsValue({ org2:result.data.departments[0].name }) @@ -274,14 +352,23 @@ class AccountBasic extends Component { } addOrgSuccess = (name) => { - const schoolList = this.state.schoolList.slice(0) - schoolList.push({ id: schoolList.length + 2000, name: name}) - this.setState({ schoolList }) + // const schoolList = this.state.schoolList.slice(0) + // schoolList.push({ id: schoolList.length + 2000, name: name}) + // this.setState({ schoolList }) + + this.getSchoolList(this.props.basicInfo, name); + this.props.form.setFieldsValue({ name: name }) } + addChildOrgSuccess = (deptName) => { + + this._getDepartments(this.state.school_id, false, deptName); + + } + showApplyForAddOrgModal = () => { this.applyForAddOrgForm.setVisible(true) } @@ -320,17 +407,19 @@ class AccountBasic extends Component { {...propsWithoutForm} addOrgSuccess={this.addOrgSuccess} > this.applyForAddChildOrgForm = form} > + {...propsWithoutForm} wrappedComponentRef={(form) => this.applyForAddChildOrgForm = form} + addChildOrgSuccess={this.addChildOrgSuccess} + >