*/}
diff --git a/public/react/src/modules/user/account/AccountBasicEditItem.js b/public/react/src/modules/user/account/AccountBasicEditItem.js
new file mode 100644
index 000000000..28988ebf3
--- /dev/null
+++ b/public/react/src/modules/user/account/AccountBasicEditItem.js
@@ -0,0 +1,199 @@
+import React, { Component } from 'react';
+
+import { SnackbarHOC, getImageUrl, City, ConditionToolTip } from 'educoder';
+import { Form, Button, Input, Radio, Select, Tooltip, Icon, AutoComplete } from 'antd'
+const RadioGroup = Radio.Group;
+const Option = Select.Option;
+class AccpimtBasicEditItem extends Component {
+ constructor(props){
+ super(props);
+ }
+
+ render(){
+ let {
+ professionalFlag ,
+ getFieldDecorator ,
+ identity ,
+ filterSchoolList ,
+ filterDepartments,
+ departmentsName,
+ school,
+ departments,
+ department_id
+ } = this.props
+ return(
+
+
+
+ {getFieldDecorator('job', {
+ rules: [{
+ initialValue:"teacher",
+ required: true,
+ message: '请先选择职业',
+ }],
+ })(
+
+ )}
+
+ {
+ identity && identity=="student" &&
+
+ {getFieldDecorator('student_No', {
+ rules: [{
+ required: true,
+ message: '请先输入学号',
+ }],
+ })(
+
+ )}
+
+ }
+ {
+ identity && identity=="teacher" &&
+
+ {getFieldDecorator('job1', {
+ rules: [{
+ initialValue:"教授",
+ required: true,
+ message: '请先选择职称',
+ }],
+ })(
+
+ )}
+
+ }
+ {
+ identity && identity=="professional" &&
+
+ {getFieldDecorator('job2', {
+ rules: [{
+ initialValue:"企业管理者",
+ required: true,
+ message: '请先选择职称',
+ }],
+ })(
+
+ )}
+
+ }
+
+
+ {getFieldDecorator('org', {
+ rules: [{
+ // initialValue: this.state.cityDefaultValue,
+ // type: 'array',
+ required: true,
+ message: '请先选择学校/单位',
+
+ // 做不了,输入时和submit时都会执行这里
+ // validator: (rule, value, callback) => {
+ // if (this.this_school_id) {
+ // callback();
+ // return;
+ // }
+ // callback('请先选择学校/单位');
+ // }
+
+ }],
+ })(
+
+ {
+ filterSchoolList && filterSchoolList.map((item,key)=>{
+ return()
+ })
+ }
+
+ )}
+
+
+ {!filterSchoolList || (filterSchoolList && filterSchoolList.length==0 )&& school &&
+
+
+ 未找到包含“{school}”的高校,
+ 申请新增
+
+
+ }
+
+
+ {getFieldDecorator('org2', {
+ rules: [{
+ // initialValue: this.state.cityDefaultValue,
+ // type: 'array',
+ required: true,
+ message: '请先选择院系/部门',
+ // validator: (rule, value, callback) => {
+ // if (this.this_department_id) {
+ // callback();
+ // return;
+ // }
+ // callback('请先选择院系/部门');
+ // }
+ }],
+ })(
+
+ {
+ filterDepartments && filterDepartments.map((item,key)=>{
+ return(
+
+ )
+ })
+ }
+
+ )}
+
+
+ {
+ filterDepartments != undefined && ( (filterDepartments && filterDepartments.length==0 )
+ || (departmentsName == '' && ! department_id
+ && (!departments || departments.length == 0) )) &&
+
+
+ {departmentsName ? `未找到包含“${departmentsName}”的院系/部门` : '未找到院系'},
+ 申请新增
+
+
+ }
+
+ )
+ }
+}
+export default AccpimtBasicEditItem;
\ No newline at end of file
diff --git a/public/react/src/modules/user/modal/RealNameCertificationModal.js b/public/react/src/modules/user/modal/RealNameCertificationModal.js
index 9af082fea..8076b0649 100644
--- a/public/react/src/modules/user/modal/RealNameCertificationModal.js
+++ b/public/react/src/modules/user/modal/RealNameCertificationModal.js
@@ -1,15 +1,19 @@
import React, { Component } from "react";
-import { message, Icon, Input, Form, Upload} from "antd";
+import { message, Icon, Input, Form, Upload,Radio ,Tooltip} from "antd";
import axios from 'axios'
import ModalWrapper from "../../courses/common/ModalWrapper"
-import { City, getUploadActionUrl, getImageUrl, ImageLayer2, getUploadActionUrlOfAuth } from 'educoder'
+import { City, getUploadActionUrl, getImageUrl, ImageLayer2, getUploadActionUrlOfAuth ,ConditionToolTip } from 'educoder'
import '../account/common.css'
+import AccountBasicEditItem from '../account/AccountBasicEditItem'
+import ApplyForAddOrgModal from './ApplyForAddOrgModal'
+import ApplyForAddChildOrgModal from './ApplyForAddChildOrgModal'
import authImg from '../../../images/account/auth.png'
import jobImg from '../../../images/account/job.png'
-const { TextArea } = Input;
+const RadioGroup = Radio.Group;
const Dragger = Upload.Dragger;
+const MAX_NAME_LENGTH = 10
function getBase64(img, callback) {
const reader = new FileReader();
reader.addEventListener('load', () => callback(reader.result));
@@ -26,16 +30,230 @@ function beforeUpload(file) {
}
return isJPG && isLt2M;
}
+export function getHiddenName(name) {
+ if (!name) return ''
+ let len=parseInt(name.length)-1;
+ let str="";
+ for(var i = 0; i < len; i++){ str += "*"; }
+ const newName = name.substr(0,1)+str;
+ return newName
+}
class RealNameCertificationModal extends Component{
constructor(props){
super(props);
this.state={
+ identity:"teacher",
+ departmentsName:undefined,
+ filterSchoolList:undefined,
+ filterDepartments :undefined,
+ school:undefined,
+ school_id:undefined,
+ department_id:undefined,
+ schoolList:undefined,
+ departments:undefined,
+ showRealName:true,
}
}
componentDidMount() {
-
+ if(this.props.basicInfo){
+ this.setValue(this.props.basicInfo);
+ this.getSchoolList(this.props.basicInfo);
+ }
+ }
+
+ setValue=(basicInfo)=>{
+ if(basicInfo){
+ this.props.form.setFieldsValue({
+ nickname:basicInfo.nickname,
+ name:!basicInfo.show_realname ? this.hideRealName(basicInfo.name) : basicInfo.name,
+ sex:String(basicInfo.gender),
+ job:basicInfo.identity,
+ org:basicInfo.school_name,
+
+ // city:[basicInfo.location,basicInfo.location_city]
+ })
+ setTimeout(() => {
+ // 等显示后再set
+ this.props.form.setFieldsValue({
+ job:basicInfo.identity,
+ student_No:basicInfo.student_id,
+ org2:basicInfo.department_name,
+ job1:basicInfo && basicInfo.identity=="teacher" ? basicInfo.technical_title:"教授",
+ job2:basicInfo && basicInfo.identity=="professional" ? basicInfo.technical_title:"企业管理者",
+ })
+ }, 100)
+ //if(basicInfo.nickname){
+ this.setState({
+ forDisable: true,
+ nameLength:basicInfo.nickname?basicInfo.nickname.length:0,
+ showRealName:basicInfo.show_realname,
+ realName: basicInfo.name,
+ identity:basicInfo.identity,
+ school_id:basicInfo.school_id,
+ department_id:basicInfo.department_id
+ })
+ //}
+ }
+ }
+
+ getSchoolList=(basicInfo, selectedName)=>{
+ let url=`/schools/for_option.json`;
+ axios.get(url).then((result)=>{
+ if(result){
+ this.setState({
+ schoolList:result.data.schools
+ })
+ 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
+ }, () => {
+ this.filterList(selectedName)
+ })
+ } else if(basicInfo && basicInfo.school_name){
+ this.setState({
+ school:basicInfo.school_name,
+ filterSchoolList:this.state.schoolList.filter(function(item){
+ return item.name.indexOf(basicInfo.school_name)>-1;
+ })
+ })
+ this.getDepartments(basicInfo.school_name,false);
+ }
+ }
+ }).catch((error)=>{
+ console.log(error);
+ })
+ }
+
+ // 将名字隐藏起来
+ hideRealName=(name)=>{
+ this.setState({ realName: name })
+ const newName = getHiddenName(name)
+
+ this.props.form.setFieldsValue({
+ name: newName
+ })
+ return newName
+ }
+
+ getDepartments=(e,flag)=>{
+ let arr=this.state.schoolList.filter(function(item){
+ if(item.name.indexOf(e) > -1){
+ return item.name;
+ }
+ });
+ if (!arr[0]) {
+ if (!e) {
+ this.setState({
+ filterSchoolList: []
+ })
+ }
+ // 没找到学校,清空部门
+ this.setState({
+ departments: [],
+ filterDepartments: [],
+ departmentsName: '',
+ 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:e,
+ })
+ 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 (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
+ })
+ this.setState({
+ department_id: result.data.departments[0].id
+ })
+ }else if(result.data.departments && result.data.departments.length == 0 && flag==true){
+ this.props.form.setFieldsValue({
+ org2:''
+ })
+ }
+ }
+ }).catch((error)=>{
+ console.log(error);
+ })
+ }
+
+ filterList =(e)=>{
+ const inputVal = e.trim()
+ let arr=[];
+ if(inputVal){
+ arr= this.state.schoolList.filter(function(item){
+ return item.name.indexOf(inputVal)>-1;
+ });
+ this.props.form.setFieldsValue({
+ org: inputVal
+ })
+ this.setState({
+ school: inputVal,
+ filterSchoolList: arr
+ })
+ } else {
+ this.setState({
+ school: '',
+ })
+ }
+ // else{
+ // let {school}=this.state;
+ // arr= this.state.schoolList.filter(function(item){
+ // return item.name.indexOf(school)>-1;
+ // });
+ // }
}
+
setVisible = (visible) => {
this.refs.modalWrapper.setVisible(visible)
}
@@ -53,6 +271,7 @@ class RealNameCertificationModal extends Component{
let url = `/users/accounts/${current_user && current_user.login}/authentication_apply.json`
axios.post((url),{
name:basicInfo.name,
+ gender:parseInt(values.sex),
id_number:values.credentials
}).then((result)=>{
if(result){
@@ -65,12 +284,13 @@ class RealNameCertificationModal extends Component{
})
}else{
// 职业认证
+ // console.log(values.job == "student" ? values.student_No : values.job == "teacher" ? values.job1 : values.job2);
let url = `/users/accounts/${current_user && current_user.login}/professional_auth_apply.json`
axios.post((url),{
- school_id:basicInfo && basicInfo.school_id,
- department_id:basicInfo && basicInfo.department_id,
- identity:basicInfo && basicInfo.identity,
- extra:basicInfo && basicInfo.identity == "student" ? basicInfo.student_id:basicInfo.technical_title
+ school_id:this.state.school_id,
+ department_id:this.state.department_id,
+ identity:this.state.identity,
+ extra: values.job == "student" ? values.student_No : values.job == "teacher" ? values.job1 : values.job2
}).then((result)=>{
if(result){
this.props.showNotification("申请已提交,请等待审核!");
@@ -119,13 +339,99 @@ class RealNameCertificationModal extends Component{
}));
}
}
+ // 切换职称
+ changeJob=(e)=>{
+ this.setState({
+ identity:e
+ })
+ let {basicInfo}=this.props;
+ if(basicInfo){
+ this.props.form.setFieldsValue({
+ job1:basicInfo && basicInfo.identity=="teacher" ? basicInfo.technical_title:"教授",
+ job2:basicInfo && basicInfo.identity=="professional" ? basicInfo.technical_title:"企业管理者",
+ })
+ }
+ }
+ // 选择学校(获取对应学校的学院、部门)
+ changeList=(e)=>{
+ this.getDepartments(e.trim(),true);
+ }
+
+ showApplyForAddOrgModal = () => {
+ this.applyForAddOrgForm.setVisible(true)
+ }
+ showApplyForAddChildOrgModal = () => {
+ let{school,schoolList}=this.state;
+ let arr=schoolList.filter(function(item){
+ return item.name == school;
+ });
+ if(arr.length > 0){
+ this.applyForAddChildOrgForm.setVisible(true)
+ }else{
+ this.props.showNotification("请先选择正确的单位或者学校!");
+ }
+ }
+ addOrgSuccess = (name) => {
+ // 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({
+ org: name
+ })
+ }
+
+ addChildOrgSuccess = (deptName) => {
+
+ this._getDepartments(this.state.school_id, false, deptName);
+
+ }
+
+ // 隐藏或显示真实姓名
+ showOrHide=(flag)=>{
+ const name = this.props.form.getFieldsValue().name || this.props.basicInfo.name
+ this.setState({
+ showRealName:flag==true?false:true
+ })
+ if(flag==true){ // 隐藏真实姓名
+ this.hideRealName(name);
+ }else{ // 显示
+ this.props.form.setFieldsValue({
+ name: this.state.realName
+ })
+ }
+ }
render(){
- const { course_lists, checkBoxValues, searchValue, loading, imageUrl, imageUrl2 } = this.state
+ const { course_lists, checkBoxValues, searchValue, loading, imageUrl, imageUrl2,
+ identity,
+ departmentsName ,
+ filterSchoolList ,
+ filterDepartments ,
+ school,
+ department_id,
+ departments,
+ school_id,
+
+ showRealName
+ } = this.state
const { moduleName } = this.props
const { getFieldDecorator } = this.props.form;
let {certification}=this.props;
// /api/users/accounts/${this.props.current_user.login}/auth_attachment.json
+
+ // 已职业认证的账户不能修改职业,学校/单位,院系/部门(true为disable)
+ const professionalFlag = basicInfo && basicInfo.professional_certification == "certified" ;
+
+ let{ basicInfo }=this.props
+ let common={
+ changeJob:this.changeJob,
+ filterList:this.filterList,
+ changeList:this.changeList,
+ showApplyForAddOrgModal:this.showApplyForAddOrgModal,
+ showApplyForAddChildOrgModal:this.showApplyForAddChildOrgModal
+ }
const uploadProps2 = {
name: 'image',
data:{type:certification == 1 ? "real_name" : "professional"},
@@ -136,190 +442,283 @@ class RealNameCertificationModal extends Component{
className: 'idPic-uploader',
onChange: this.handleChange2,
};
+
+ // form合并了
+ const propsWithoutForm = Object.assign({}, this.props)
+ delete propsWithoutForm.form
return(
-
实名认证:
- 职业认证
- }
- {...this.props }
- onOk={this.onOk}
- okText="保存"
- className="applyForModal certificationModal courseNormalForm"
- bottomRender={
- certification && certification == 1?
-
-
认证须知:
-
- 1.你需要准备有效的身份证正面(人像面)的证件照照片,请确保证件照片清晰可见,严禁PS;
-
- 2.我们将在你提交认证信息后的24小时(不包含节假日)内完成审核,审核结果将会以系统消息的形式发送给你;
-
- 3.实名认证审核完成后,无法删除,请谨慎填写;
-
- 4.实名认证审核完成后,系统将自动发放500个金币作为奖励;
-
- 5.我们会确保你所提供的信息均处于严格的保密状态,不会泄露;
-
- 6.如存在恶意乱填写姓名,证件号,及上传与实名认证证件无关图片者,一经发现将冻结EduCoder账号。
-
-
:
-
-
认证须知:
-
- 1.根据职业上传相应的证件照:教师(教师证),专业人士(员工证)、学生(学生证),请确保证件照内容完整并且清晰可见,严禁PS;
-
- 2.我们将在你提交职业证信息后的24小时(不包含节假日)内完成审核,审核结果将会以系统消息的形式发送给你;
-
- 3.职业认证审核完成后,无法删除,请谨慎填写;职业变更请选择重新认证;
-
- 4.职业认证审核完成后,系统将自动发放500个金币作为奖励;
-
- 5.我们会确保你所提供的信息均处于严格的保密状态,不会泄露;
-
- 6.如存在恶意乱填写姓名,学号,及上传与职业证件无关图片者,一经发现将冻结EduCoder账号。
-
-
- }
- >
-
-
- {getFieldDecorator('credentials', {
- rules: [{
- // initialValue: this.state.cityDefaultValue,
- required: true,
- message: '请输入证件号',
- }],
- })(
-
- )}
-
- }
-
+ span.idPic-uploader.demoImg {
+ width:160px;
+ background:rgba(240,240,240,1);
+ border:1px solid rgba(218,218,218,1);
+ border-radius:4px;
+ padding:0px 5px;
+ justify-content: center;
+ align-items: center;
+ display: -webkit-flex;
+ }
+ .formItemInline.ant-form-item {
+ display: -ms-flexbox;
+ display: flex;
+ }
+ .formItemInline {
+ display: flex;
+ margin-bottom: 10px;
+ position: relative;
+ }
+ .formItemInline .ant-form-explain{
+ position:absolute;
+ bottom:-20px;
+ left:0px;
+ width:100%;
+ }
+ .yslgraduainputedit{
+ width:295px;
+ }
+ `}
+
+
-
-
-
+
+
+
)
}
}