import React,{Component} from "react"; import {AutoComplete, Button, Form, Icon, Input, message, Modal, Popconfirm, Select, Spin} from "antd"; import {cityArr, post, station} from "../../../dataDic"; import $ from "jquery/src/ajax"; import {splitUrl} from "../../../tools"; import moment from "moment"; import ImgList from "../../../common/imgList"; class PicturesWall extends Component{ constructor(props) { super(props); this.state={ previewVisible: false, previewImage: '', fileList: [], role:[], district:[], cityOption:[], } } handleCancel() { this.setState({ previewVisible: false }) } handlePreview(file) { this.setState({ previewImage: file.url || file.thumbUrl, previewVisible: true, }); } handleChange(info) { let fileList = info.fileList; this.setState({ fileList }); this.props.fileList(fileList); } componentWillReceiveProps(nextProps) { this.state.fileList = nextProps.pictureUrl; } render() { const { fileList } = this.state; return ( { this.handleChange(infor) }} fileList={fileList} /> ); } } class UserProcessing extends Component{ constructor(props) { super(props); this.state={ orgCodeUrl:[], loading: false, loaduser: {}, visible:false, datauser:[], role:[], roleArr:[], departmentArr:[], addId:'', customerArr:[], } this.getOrgCodeUrl = this.getOrgCodeUrl.bind(this); this.handleSubmit = this.handleSubmit.bind(this); this.httpChange = this.httpChange.bind(this); this.blurChange = this.blurChange.bind(this); this.selectAuto = this.selectAuto.bind(this); this.resetPwd = this.resetPwd.bind(this); } //新建获取id addIdS() { $.ajax({ method: "get", dataType: "json", crossDomain: false, url: globalConfig.context + '/api/admin/superviser/newId', data: {}, success: function(data) { this.setState({ id: data.data }); }.bind(this), }).always(function() { this.setState({ loading: false }); }.bind(this)); } handleSubmit(e) { e.preventDefault(); this.props.inspect(()=>{ if(!this.state.role || this.state.role.length === 0){ message.warning('请选择角色'); return false; }; if(!this.state.status&&this.props.userDetaile){ message.warning('请选择角色状态'); return false; }; if(window.adminData.isSuperAdmin){ if(!this.state.departmentId){ message.warning('请选择组织部门'); return false; }; } if(!this.state.theTypes&&!this.state.superiorId){ message.warning('请输入正确的上级主管'); return false; }; if(this.state.contactMobile){ if(!(/^1[1-9][0-9]\d{4,8}$/.test(this.state.contactMobile))){ message.warning("不是完整的11位手机号或者正确的手机号前七位"); this.setState({ loading: false }); return false; } } let theorgCodeUrl = []; if (this.state.orgCodeUrl.length) { let picArr = []; this.state.orgCodeUrl.map(function (item) { if ( item.response && item.response.data && item.response.data.length ){ picArr.push(item.response.data); } }); theorgCodeUrl = picArr.join(","); }; let api = this.props.userDetaile?"/api/admin/superviser/updateAdmin":'/api/admin/superviser/insertAdmin' this.setState({ loading: true }); $.ajax({ method: "POST", dataType: "json", crossDomain: false, url: globalConfig.context + api, data: { roles:this.state.role, data:JSON.stringify({ id:this.state.id?this.state.id:this.props.aid, mobile:this.state.mobile, status:this.state.status, contactMobile:this.state.contactMobile, name:this.props.name, departmentId:window.adminData.isSuperAdmin?this.state.departmentId:window.adminData.departmentId, duty:this.state.duty, position:this.state.position,//岗位 email:this.state.email, superiorId:this.state.theTypes?this.state.theTypes:this.state.superiorId, district:this.state.district, headPortraitUrl:theorgCodeUrl.length?theorgCodeUrl:'', entryTime:this.state.selTime }) } }).done(function (data) { this.setState({ loading: false }); if (!data.error.length) { if(this.props.userDetaile){ this.props.onPreservation(this.props.aid); }else{ this.props.onPreservation(data.data.id); } } else { message.warning(data.error[0].message); } }.bind(this)); }); } //主管初始加载(自动补全) supervisor(e){ $.ajax({ method: "post", dataType: "json", crossDomain: false, url: globalConfig.context + "/api/admin/organization/selectName", data:{ name:e }, success: function (data) { let thedata=data.data; if (!thedata) { if (data.error && data.error.length) { message.warning(data.error[0].message); }; thedata = {}; }; this.setState({ customerArr:thedata, }); }.bind(this), }).always(function () { this.setState({ loading: false }); }.bind(this)); } //上级主管输入框失去焦点是判断客户是否存在 selectAuto(value,options){ this.setState({ superior:value }) } blurChange(e){ let theType=''; let contactLists=this.state.customerArr || []; if (e) { contactLists.map(function (item) { if (item.name == e.toString()) { theType = item.id; } }); } this.setState({ theName:e, theTypes:theType }) } //值改变时请求客户名称 httpChange(e){ if(e.length>=1){ this.supervisor(e); } this.setState({ superior:e }) } rolesArrS() { $.ajax({ method: "get", dataType: "json", crossDomain: false, url: globalConfig.context + "/api/admin/role", data: { uid: this.props.aid }, success: function(data) { let thedata = data.data; if(data.error && data.error.length) { message.warning(data.error[0].message); }else{ this.setState({ role:thedata, }) } }.bind(this), }).always(function() { }.bind(this)); } //查看基本详情基本信息 loaduser(aid){ if(aid){ $.ajax({ method: "post", dataType: "json", crossDomain: false, url: globalConfig.context + '/api/admin/superviser/selectAllByid', data: { id: aid }, success: function (data) { let thisdata = data.data; if (!thisdata) { if (data.error && data.error.length) { message.warning(data.error[0].message); }; thisdata = {}; }; this.setState({ id: thisdata.id, mobile: thisdata.mobile, name: thisdata.name, email: thisdata.email, createTime: thisdata.createTime, district:thisdata.district!=' '?JSON.parse(thisdata.district):undefined, position: thisdata.position?thisdata.position:undefined, superior:thisdata.superior, superiorId: thisdata.superiorId,//上级Id duty:thisdata.duty?thisdata.duty:undefined,//职务 status:thisdata.status?thisdata.status:undefined, contactMobile:thisdata.contactMobile?thisdata.contactMobile:undefined,//手机号 departmentId:thisdata.departmentId?thisdata.departmentId:undefined,//部门id userNo:thisdata.userNo, orgCodeUrl: thisdata.headPortraitUrl? splitUrl(thisdata.headPortraitUrl, ',', globalConfig.avatarHost + '/upload') : [], theTypes:'', entryTime:thisdata.entryTime?moment(thisdata.entryTime,'YYYY-MM-DD'):undefined, selTime:thisdata.entryTime }); }.bind(this), }).always(function () { this.setState({ loading: false }); }.bind(this)); } } //重置密码 resetPwd() { this.setState({ loading: true }) $.ajax({ type: 'post', url: globalConfig.context + "/api/admin/superviser/resetPwd", dataType: "json", data: { id: this.props.aid }, }).done((res) => { if (res.error && res.error.length) { message.error(res.error[0].message); } else { message.success("密码重置成功"); } }).always(() => { this.setState({ loading: false }) }); } //入职时间选择 selTime(e,index){ this.setState({ entryTime:e, selTime:index }) } getOrgCodeUrl(e) { this.setState({ orgCodeUrl: e }); } componentDidMount() { if(!this.props.userDetaile){ this.addIdS(); }; this.rolesList(); this.departmentList(); if(this.props.userDetaile && this.props.aid){ this.loaduser(this.props.aid); this.rolesArrS(); }else{ this.state.name=''; this.state.mobile='', this.state.role=[]; this.state.departmentId=undefined; this.state.mobile=''; this.state.duty=undefined; this.state.position=undefined; this.state.station=undefined; this.state.contactMobile=''; this.state.email=''; this.state.superiorId=''; this.state.superior=''; this.state.district=[]; this.state.orgCodeUrl=[]; this.state.id=''; this.state.entryTime=undefined; } } componentWillMount(e){ const cityArrs=[]; cityArr.map(function (item) { cityArrs.push( {item.key} ) }); this.state.cityOption=cityArrs; } rolesList() { this.setState({ loading: true }); $.ajax({ method: "get", dataType: "json", crossDomain: false, url: globalConfig.context + "/api/roles", data: {}, success: function (data) { let thedata = data.data; let theArr = []; if (!thedata) { if (data.error && data.error.length) { message.warning(data.error[0].message); } ; thedata = {}; } else { thedata.map(function (item, index) { theArr.push({ key: index, roleName: item.roleName, id: item.id, }) }) } this.setState({ roleArr: theArr, }) }.bind(this), }).always(function () { this.setState({ loading: false }); }.bind(this)); } //部门 departmentList() { this.setState({ loading: true }); $.ajax({ method: "get", dataType: "json", crossDomain: false, url: globalConfig.context + "/api/admin/organization/selectSuperId", data: { }, success: function(data) { let thedata = data.data; let theArr = []; if(!thedata) { if(data.error && data.error.length) { message.warning(data.error[0].message); }; } else { thedata.map(function(item, index) { theArr.push({ key: index, name: item.name, id: item.id, depNo: item.depNo }) }) } this.setState({ departmentArr: theArr, }) }.bind(this), }).always(function() { this.setState({ loading: false }); }.bind(this)); } render() { const FormItem = Form.Item const formItemLayout = { labelCol: { span: 8 }, wrapperCol: { span: 14 }, }; const dataSources=this.state.customerArr || []; const options = dataSources.map((group,index) => {group.name} ) return (

{this.props.userDetaile?'修改系统账户':'同步系统账户'}

* 存在多个角色 {this.props.userDetaile? :''} {this.props.userDetaile? * :''} {this.setState({mobile:e.target.value})}} required="required"/> * {this.setState({contactMobile:e.target.value})}} /> {window.adminData.isSuperAdmin? * :''} {this.setState({email:e.target.value})}} /> * {this.props.userDetaile? {this.state.userNo} :''}

图片建议:要清晰。

); } } export default UserProcessing;