Browse Source

用户管理模块上传

liting2017 7 years ago
parent
commit
df8b5f1be6

+ 148 - 99
js/component/manageCenter/set/userManagementS/newUser.jsx

@@ -4,8 +4,10 @@ import ajax from 'jquery/src/ajax/xhr.js';
 import $ from 'jquery/src/ajax';
 import './userMangagement.less';
 import {socialAttribute,cityArr,station,post} from '../../../dataDic.js';
+import {splitUrl} from '../../../tools.js';
 const Option = AutoComplete.Option;
 
+
 //图片组件
 const PicturesWall = React.createClass({
     getInitialState() {
@@ -13,6 +15,10 @@ const PicturesWall = React.createClass({
             previewVisible: false,
             previewImage: '',
             fileList: [],
+            role:[],
+            district:[],
+            cityOption:[],
+            kkt:false
         }
     },
     handleCancel() {
@@ -43,7 +49,7 @@ const PicturesWall = React.createClass({
         return (
             <div style={{display:"inline-block"}}>
                 <Upload
-                    action={globalConfig.context + "/api/admin/customer/attachmentUpload"}
+                    action={globalConfig.context + "/api/admin/superviser/uploadAdminImg"}
                     data={{ 'sign': this.props.pictureSign }}
                     listType="picture-card"
                     fileList={fileList}
@@ -65,19 +71,29 @@ const Newuser = Form.create()(React.createClass({
         	orgCodeUrl:[],
             loading: false,
             loaduser: {}, 
-            visible:false
+            visible:false,
+            datauser:[],
+            role:[]
         };
     },
     handleSubmit(e) {
         e.preventDefault();
         if(!this.state.role){
-        	message.warning('亲!请选择角色');
+        	message.warning('请选择角色');
         	return false;
         };
-        if(!this.state.roleState){
-        	message.warning('亲!请选择角色状态');
+        if(!this.state.status&&this.props.userDetaile){
+        	message.warning('请选择角色状态');
         	return false;
-        }
+        };
+        if(!this.state.departmentId){
+        	message.warning('请选择组织部门');
+        	return false;
+        };
+        if(!this.state.theTypes&&!this.state.superiorId){
+        	message.warning('请输入正确的上级主管');
+        	return false;
+        };
         let theorgCodeUrl = [];
         if (this.state.orgCodeUrl.length) {
             let picArr = [];
@@ -86,27 +102,33 @@ const Newuser = Form.create()(React.createClass({
             });
             theorgCodeUrl = picArr.join(",");
         };
+        let api = this.props.userDetaile?"/api/admin/superviser/updateAdmin":'/api/admin/superviser/insertAdmin'
         this.setState({
             loading: true
-        });
+        });  
+        let roleArrT=[];
+		roleArrT.push((this.state.role).toString())
         $.ajax({
             method: "POST",
             dataType: "json",
             crossDomain: false,
-            url: globalConfig.context + '/api/admin/customer/addCustomer',
+            url: globalConfig.context + api,
             data: {
-            	id:this.props.datauser.id,
-                uesrName:this.state.uesrName,
-				role:this.state.role,
-				roleState:this.state.roleState,
-				customerName:this.state.customerName,
-				department:this.state.department,
-				post:this.state.post,
-				station:this.state.station,
-				phone:this.state.phone,
-				email:this.state.email,
-				director:this.state.theTypes,
-				companyIntention:JSON.stringify(this.state.companyIntention),
+            	roles:roleArrT,
+            	data:JSON.stringify({
+            		id:this.state.id?this.state.id:this.props.addId,
+	                mobile:this.state.mobile,
+					status:this.state.status,
+					name:this.state.name,
+					departmentId:this.state.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,
+            	})
+            	
             }
         }).done(function (data) { 
             this.setState({
@@ -123,10 +145,10 @@ const Newuser = Form.create()(React.createClass({
     //主管初始加载(自动补全)
 	supervisor(e){ 
 		$.ajax({
-            method: "get",
+            method: "post",
             dataType: "json",
             crossDomain: false,
-            url: globalConfig.context + "/api/admin/customer/findCustomerByName",
+            url: globalConfig.context + "/api/admin/organization/selectName",
             data:{
             	name:e
             },
@@ -151,11 +173,10 @@ const Newuser = Form.create()(React.createClass({
 	//上级主管输入框失去焦点是判断客户是否存在
 	selectAuto(value,options){
 		this.setState({
-			auto:value
+			superior:value
 		})
 	},
 	blurChange(e){
-		console.log(e)
 		let theType='';
 		let contactLists=this.state.customerArr||[];
 			if (e) {
@@ -171,40 +192,51 @@ const Newuser = Form.create()(React.createClass({
 	},
 	//值改变时请求客户名称
 	httpChange(e){
-		if(e.length>=2){
+		if(e.length>=1){
 			this.supervisor(e); 
-		}	
+		}
 		this.setState({
-			auto:e
+			superior:e
 		})
 	},
 	//查看基本详情基本信息
     loaduser(record){
     	if(record){
     	$.ajax({
-            method: "get",
+            method: "post",
             dataType: "json",
             crossDomain: false,
-            url: globalConfig.context + '/api/admin/customer/toUpdateBusiness',
+            url: globalConfig.context + '/api/admin/superviser/selectAllByid',
             data: {
-              businessId: record.name
+              id: record.id
             },
             success: function (data) {
-                let thisData = data.data;                
-                if (!thisData) {
+                let thisdata = data.data;                
+                if (!thisdata) {
                     if (data.error && data.error.length) {
                         message.warning(data.error[0].message);
                     };
-                    thisData = {};
+                    thisdata = {};
                 }; 
+                let roleArr=[]
+                roleArr.push(this.props.role[0])
                 this.setState({
-                	orgCodeUrl: thisData.orgCodeUrl ? splitUrl(thisData.orgCodeUrl, ',', globalConfig.avatarHost + '/upload') : [],
-                	uids:thisData.uid,
-                	followSituation:thisData.followSituation,
-                	businessGlossoryId:thisData.businessGlossoryId,
-                	customerStatus:thisData.customerStatus,
-                	remarks:thisData.remarks,	
-                });                  
+                    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,
+                    departmentId:thisdata.departmentId?thisdata.departmentId:undefined,//部门id
+                    userNo:thisdata.userNo,
+                	orgCodeUrl: thisdata.headPortraitUrl? splitUrl(thisdata.headPortraitUrl, ',', globalConfig.avatarHost + '/upload') : [],
+                	role:roleArr,
+                });
             }.bind(this),
        }).always(function () {
             this.setState({            	
@@ -213,18 +245,19 @@ const Newuser = Form.create()(React.createClass({
         }.bind(this));  
        }
     },
+    
     //重置密码
-    resetPwd(e) {
+    resetPwd() {
         this.setState({
             loading: true
         })
         $.ajax({
             type: 'post',
-            url: globalConfig.context + "/api/admin/supervise/resetPwd",
+            url: globalConfig.context + "/api/admin/superviser/resetPwd",
             dataType: "json",
             data: {
-                id: this.state.id
-            }
+                id: this.props.datauser.id
+            },
         }).done((res) => {
             if (res.error && res.error.length) {
                 message.error(res.error[0].message);
@@ -261,25 +294,28 @@ const Newuser = Form.create()(React.createClass({
         });
         this.state.cityOption=cityArrs;
     },
+   
     componentWillReceiveProps(nextProps) {
     	this.state.visible = nextProps.showDesc;
     	this.state.Detaile=nextProps.userDetaile;
-		if(!nextProps.userDetaile){
-			this.state.uesrName='';
-			this.state.role=undefined;
-			this.state.roleState=undefined;
-			this.state.customerName='';
-			this.state.department=undefined;
-			this.state.post=undefined;
+		if(nextProps.userDetaile&&nextProps.datauser.id){
+			this.loaduser(nextProps.datauser)
+   		}else{
+    		this.state.name='';
+			this.state.role=[];
+			this.state.departmentId=undefined;
+			this.state.mobile='';
+			this.state.duty=undefined;
+			this.state.position=undefined;
 			this.state.station=undefined;
-			this.state.phone='';
 			this.state.email='';
-			this.state.auto='';
-			this.state.companyIntention=[];
+			this.state.superiorId='';
+			this.state.superior='';
+			this.state.district=[];
 			this.state.orgCodeUrl=[];
-   		}else{
-    		this.loaduser(nextProps.datauser)
-    	   }     
+			this.state.id='';
+    	   } 
+
       },
     render() {
         const FormItem = Form.Item
@@ -291,6 +327,9 @@ const Newuser = Form.create()(React.createClass({
         const options = dataSources.map((group,index) =>
 				      <Select.Option key={index} value={group.name}>{group.name}</Select.Option>
 				     )
+        const departmentArr=this.props.departmentArr || [];
+        const roleArrS=this.props.roleArr || [];
+        const rolst=this.props.role || [];
         return (
         <div>
            <Modal maskClosable={false} visible={this.state.visible}
@@ -306,13 +345,13 @@ const Newuser = Form.create()(React.createClass({
 					                    	<FormItem className="half-item"
 						                            {...formItemLayout}
 						                            label="用户名" >   
-					                                    <Input placeholder="输入用户名" value={this.state.uesrName}
-					                                    onChange={(e)=>{this.setState({uesrName:e.target.value})}} required="required" style={{width:'200px'}}/>
+					                                    <Input placeholder="输入登录用户名" value={this.state.mobile}
+					                                    onChange={(e)=>{this.setState({mobile:e.target.value})}} required="required" style={{width:'200px'}}/>
 					                                <span className="mandatory">*</span>
 						                    </FormItem>
 						                    {this.props.userDetaile?
 						                    	<Popconfirm
-			                                        title={"用户 [ " + this.state.name + " ] 的密码将会重置为123456,确认操作?"}
+			                                        title={"用户 [ " + this.props.datauser.name + " ] 的密码将会重置为123456,确认操作?"}
 			                                        onConfirm={this.resetPwd}
 			                                        okText="确认"
 			                                        cancelText="取消"
@@ -320,52 +359,69 @@ const Newuser = Form.create()(React.createClass({
 			                                        <Button>重置密码</Button>
 			                                    </Popconfirm>:''}
 					                    </div>
-					                    <FormItem className="half-item" 
-					                          {...formItemLayout}
+					                     <FormItem className="half-item"
+						                        {...formItemLayout}
 					                           label="用户角色"
 					                         > 
-												  <Select placeholder="选择用户角色" value={this.state.role}
-												    onChange={(e)=>{this.setState({role:e})}} style={{width:'200px'}}>
-					                                {
-					                                    socialAttribute.map(function (item) {
-					                                        return <Select.Option key={item.value} >{item.key}</Select.Option>
-					                                    })
-					                                }
-					                              </Select>
-					                              <span className="mandatory">*</span>
+					                                <Select
+											            placeholder="选择用户角色"
+											            value={this.state.role}
+											            style={{width:'200px'}}
+											            onChange={(e)=>{this.setState({role:e,kkt:true})}} >
+											            {
+							                                roleArrS.map(function (item) {
+							                                        return <Select.Option key={item.id} >{item.roleName}</Select.Option>
+							                                })
+							                            }
+											        </Select>
+					                                <span className="mandatory">*</span>
 			                   		    </FormItem>
+			                   		    <FormItem className="half-item"
+						                        {...formItemLayout}
+					                           label=""
+					                         > 
+					                         <span style={{display:rolst.length>1?'block':'none',color:'red'}}>存在多个角色</span>
+					                    </FormItem>
 			                   		    {this.props.userDetaile?<FormItem className="half-item"
 						                            {...formItemLayout}
 						                            label="用户状态" >   
-					                                    <Select placeholder="用户状态" value={this.state.roleState} style={{width:'200px'}}
-												          onChange={(e)=>{this.setState({roleState:e})}} > 
-					                                      {
-					                                      socialAttribute.map(function (item) {
-					                                        return <Select.Option key={item.value} >{item.key}</Select.Option>
-					                                       })
-					                                      }
+					                                    <Select placeholder="用户状态" value={this.state.status} style={{width:'200px'}}
+												          onChange={(e)=>{this.setState({status:e})}} > 
+					                                      	 <Select.Option value="正常" >正常</Select.Option>
+	                           								 <Select.Option value="注销" >注销</Select.Option>
+	                           								 <Select.Option value="锁定" >锁定</Select.Option>
 					                                   </Select>
 					                                   <span className="mandatory">*</span>
 						                </FormItem>:''}
 					                    <FormItem className="half-item"
 					                            {...formItemLayout}
 					                            label="用户姓名" >   
-				                                    <Input placeholder="请输入用户姓名" style={{width:'200px'}} value={this.state.customerName}
-					                                    onChange={(e)=>{this.setState({customerName:e.target.value})}} required="required"/> 
+				                                    <Input placeholder="请输入用户姓名" style={{width:'200px'}} value={this.state.name}
+					                                    onChange={(e)=>{this.setState({name:e.target.value})}} required="required"/> 
 				                                    <span className="mandatory">*</span>
 					                    </FormItem>
+					                    
 					                    <FormItem className="half-item"
 					                            {...formItemLayout}
 					                            label="组织部门" >   
-				                                    <Input placeholder="请输入组织部门" style={{width:'200px'}} value={this.state.department}
-					                                    onChange={(e)=>{this.setState({department:e.target.value})}} required="required"/> 
+				                                    <Select placeholder="选择组织部门"
+							                            style={{ width: 200 }}
+							                            value={this.state.departmentId}
+							                            onChange={(e) => { this.setState({ departmentId: e }) }}>
+							                            {
+							                                departmentArr.map(function (item) {
+							                                        return <Select.Option key={item.id} >{item.name}</Select.Option>
+							                                })
+							                            }
+							                        </Select>
 				                                    <span className="mandatory">*</span>
 					                    </FormItem>
+					                    
 					                    <FormItem className="half-item" 
 					                          {...formItemLayout}
 					                           label="职务"
 					                         > 
-												  <Select placeholder="选择职务" style={{width:'200px'}} value={this.state.post} onChange={(e)=>{this.setState({post:e})}}> 
+												  <Select placeholder="选择职务" style={{width:'200px'}} value={this.state.duty} onChange={(e)=>{this.setState({duty:e})}}> 
 					                                {
 					                                    post.map(function (item) {
 					                                        return <Select.Option key={item.value} >{item.key}</Select.Option>
@@ -377,7 +433,7 @@ const Newuser = Form.create()(React.createClass({
 					                          {...formItemLayout}
 					                           label="岗位"
 					                         > 
-												  <Select placeholder="选择岗位" style={{width:'200px'}} value={this.state.station} onChange={(e)=>{this.setState({station:e})}}> 
+												  <Select placeholder="选择岗位" style={{width:'200px'}} value={this.state.position} onChange={(e)=>{this.setState({position:e})}}> 
 					                                {
 					                                    station.map(function (item) {
 					                                        return <Select.Option key={item.value} >{item.key}</Select.Option>
@@ -385,13 +441,6 @@ const Newuser = Form.create()(React.createClass({
 					                                }
 					                              </Select>
 			                   		    </FormItem>
-			                   		    <FormItem className="half-item"
-					                            {...formItemLayout}
-					                            label="联系手机" >   
-				                                    <Input placeholder="请输入号码" style={{width:'200px'}} value={this.state.phone}
-					                                    onChange={(e)=>{this.setState({phone:e.target.value})}} required="required"/> 
-				                                    <span className="mandatory">*</span>
-					                    </FormItem>
 					                    <FormItem className="half-item"
 					                            {...formItemLayout}
 					                            label="电子邮箱" >   
@@ -411,7 +460,7 @@ const Newuser = Form.create()(React.createClass({
 											        style={{ width: '200px' }}
 											        dataSource={options}
 											        placeholder="输入名称"
-											        value={this.state.auto}
+											        value={this.state.superior}
 											        onChange={this.httpChange}
 											        filterOption={true}
 											        onBlur={this.blurChange}
@@ -422,13 +471,12 @@ const Newuser = Form.create()(React.createClass({
 											      <span className="mandatory">*</span>
 							            </FormItem>
 							           {this.props.userDetaile?
-							           	
 						                    <FormItem className="half-item"
 						                            {...formItemLayout}
 						                            label="用户编号" >   
-						                            <span>{this.state.id}</span>
+						                            <span>{this.state.userNo}</span>
 						                    </FormItem>
-						                :''}
+						                :''} 
 							            <div className='clearfix'>
 							            	<FormItem className="half-item"
 						                        {...formItemLayout}
@@ -438,18 +486,19 @@ const Newuser = Form.create()(React.createClass({
 						                                style={{width:'500px'}}
 						                                placeholder="选择地区"                               
 						                                filterOption={(input, option) => { return option.props.children.indexOf(input) >= 0 }}
-						                                value={this.state.companyIntention}
+						                                value={this.state.district}
 						                                onChange={(pids) => {
-						                                    this.state.companyIntention = pids;
+						                                    this.state.district = pids;
 						                                    this.setState({
-						                                        companyIntention: this.state.companyIntention
+						                                        district: this.state.district
 						                                    })
 						                                }}
 						                            >
-						                                {this.state.cityOption}
+						                               {this.state.cityOption}
 						                            </Select>
 						                    </FormItem>	
 							            </div>
+							            
 							             <div className="clearfix pictures">
 						                        <FormItem
 							                        labelCol={{ span: 4 }}

+ 573 - 304
js/component/manageCenter/set/userManagementS/user.jsx

@@ -2,321 +2,570 @@ import React from 'react';
 import ReactDom from 'react-dom';
 import ajax from 'jquery/src/ajax/xhr.js';
 import $ from 'jquery/src/ajax';
-import { Form,Radio, Icon, Button, Input, Select, Spin, Table, Switch, message, DatePicker, Modal, Upload } from 'antd';
+import { Form, Radio, Icon, Button, Input, Select, AutoComplete, Spin, Table, Switch, message, DatePicker, Modal, Upload } from 'antd';
 import Newuser from "./newUser.jsx"
 import './userMangagement.less'
-import {techAuditStatusList, station,post } from '../../../dataDic.js';
+import { techAuditStatusList, station, post } from '../../../dataDic.js';
+import {getPost,getStation} from '../../../tools.js';
 
-const User=Form.create()(React.createClass({
+const User = Form.create()(React.createClass({
 	loadData(pageNo) {
-        this.state.data = [];
-        this.setState({
-            loading: true
-        });
-        $.ajax({
-            method: "get",
-            dataType: "json",
-            crossDomain: false,
-            url: globalConfig.context + '/api/admin/supervise/adminLi',
-            data: {
-                pageNo: pageNo || 1,
-                pageSize: this.state.pagination.pageSize,
-                userName:this.state.userNameSearch,
-				organization:this.state.organizationSearch,
-				role:this.state.rolesSearch,
-				post:this.state.postSearch,
-				station:this.state.stationSearch,
-				status:this.state.statusSeach,
-				signName:this.state.signNameSearch,
-				mobile:this.state.mobileSearch,
-				proName:this.state.proNameSearch
-            },
-            success: function (data) {
-                let theArr = [];
-                if (!data.data || !data.data.list) {
-                    if (data.error && data.error.length) {
-                        message.warning(data.error[0].message);
-                    };
-                } else {
-                    for (let i = 0; i < data.data.list.length; i++) {
-                        let thisdata = data.data.list[i];
-                        theArr.push({
-                            key: i,
-                            id: thisdata.id,
-                            mobile: thisdata.mobile,
-                            name: thisdata.name,
-                            email: thisdata.email,
-                            createTime: thisdata.createTime,
-                            number: thisdata.number,
-                            province: thisdata.province,
-                            position: thisdata.position,
-                            superior: thisdata.superior,
-                            superiorId: thisdata.superiorId,
-                            createTimeFormattedDate: thisdata.createTimeFormattedDate
-                        });
-                    }; 
-                    this.state.pagination.current = data.data.pageNo?data.data.pageNo:'0';
-                    this.state.pagination.total = data.data.totalCount?data.data.totalCount:'0';
-                };
-                this.setState({
-                    dataSource: theArr,
-                    pagination: this.state.pagination
-                });
-            }.bind(this),
-        }).always(function () {
-            this.setState({
-                loading: false
-            });
-        }.bind(this));
-    },
-    getInitialState() {
-        return {
-        	datauser:{},
-            searchMore: true,
-            selectedRowKeys: [],
-            selectedRows: [],
-            loading: false,
-            pagination: {
-                defaultCurrent: 1,
-                defaultPageSize: 10,
-                showQuickJumper: true,
-                pageSize: 10,
-                onChange: function (page) {
-                    this.loadData(page);
-                }.bind(this),
-                showTotal: function (total) {
-                    return '共' + total + '条数据';
-                }
-            },
-            columns: [
-                {
-                    title: '用户编号',
-                    dataIndex: 'key',
-                    key: 'key',
-                }, {
-                    title: '登录用户名',
-                    dataIndex: 'name',
-                    key: 'name',
-                }, {
-                    title: '角色',
-                    dataIndex: 'email',
-                    key: 'email',
-                }, {
-                    title: '用户姓名',
-                    dataIndex: 'createTime',
-                    key: 'createTime',
-                }, {
-                    title: '组织机构',
-                    dataIndex: 'number',
-                    key: 'number',
-                }, {
-                    title: '职务',
-                    dataIndex: 'auditStatus',
-                    key: 'auditStatus',
-                }, 
-                {
-                    title: '岗位',
-                    dataIndex: 'boutique',
-                    key: 'boutique',
-                },
-                
-                {
-                    title: '上级主管姓名',
-                    dataIndex: 'province',
-                    key: 'province',
-                },
-                {
-                    title: '状态',
-                    dataIndex: 'a',
-                    key: 'a',
-                }
-            ],
-            dataSource: [],
-        };
-    },
-    componentWillMount() {
-        let organizationArr = [];
-        techAuditStatusList.map(function (item) {
-            organizationArr.push(
-                <Select.Option value={item.value} key={item.key}>{item.key}</Select.Option>
-            )
-        });
-        this.state.organizationList = organizationArr;
-        this.loadData();
-    },
-    tableRowClick(record, index) {
-    	this.state.userDetaile=true;
-        this.state.datauser = record;
-        this.setState({
-            showDesc: true
-        });
-    },
-    //锁定
-    locking() {
-        let deletedIds = [];
-        for (let idx = 0; idx < this.state.selectedRows.length; idx++) {
-            let rowItem = this.state.selectedRows[idx];
-            if (rowItem.id) {
-                deletedIds.push(rowItem.id)
-            };
-        };
-        this.setState({
-            selectedRowKeys: [],
-            loading: true
-        });
-        $.ajax({
-            method: "POST",
-            dataType: "json",
-            crossDomain: false,
-            url: globalConfig.context + "/api/admin/achievement/delete",
-            data: {
-                ids: deletedIds
-            }
-        }).done(function (data) {
-            if (!data.error.length) {
-                message.success('锁定成功!');
-                this.setState({
-                    loading: false,
-                });
-            } else {
-                message.warning(data.error[0].message);
-            };
-            this.loadData();
-        }.bind(this));
-    },
-    //激活
-    activation() {
-        let deletedIds = [];
-        for (let idx = 0; idx < this.state.selectedRows.length; idx++) {
-            let rowItem = this.state.selectedRows[idx];
-            if (rowItem.id) {
-                deletedIds.push(rowItem.id)
-            };
-        };
-        this.setState({
-            selectedRowKeys: [],
-            loading: true
-        });
-        $.ajax({
-            method: "POST",
-            dataType: "json",
-            crossDomain: false,
-            url: globalConfig.context + "/api/admin/achievement/delete",
-            data: {
-                ids: deletedIds
-            }
-        }).done(function (data) {
-            if (!data.error.length) {
-                message.success('激活成功!');
-                this.setState({
-                    loading: false,
-                });
-            } else {
-                message.warning(data.error[0].message);
-            };
-            this.loadData();
-        }.bind(this));
-    },
-    //删除
-    delectRow() {
-        let deletedIds = [];
-        for (let idx = 0; idx < this.state.selectedRows.length; idx++) {
-            let rowItem = this.state.selectedRows[idx];
-            if (rowItem.id) {
-                deletedIds.push(rowItem.id)
-            };
-        };
-        this.setState({
-            selectedRowKeys: [],
-            loading: true
-        });
-        $.ajax({
-            method: "POST",
-            dataType: "json",
-            crossDomain: false,
-            url: globalConfig.context + "/api/admin/achievement/delete",
-            data: {
-                ids: deletedIds
-            }
-        }).done(function (data) {
-            if (!data.error.length) {
-                message.success('删除成功!');
-                this.setState({
-                    loading: false,
-                });
-            } else {
-                message.warning(data.error[0].message);
-            };
-            this.loadData();
-        }.bind(this));
-    },
-    addClick() {
-    	this.state.userDetaile=false;
-        this.setState({
-            showDesc: true
-        });
-    },
-    closeDesc(e, s) {
-        this.state.showDesc = e;
-        if (s) {
-            this.loadData();
-        };
-    },
-    search() {
-        this.loadData();
-    },
-    reset() {
-    	this.state.userNameSearch='';
-		this.state.organizationSearch=undefined;
-		this.state.rolesSearch=undefined;
-		this.state.postSearch=undefined;
-		this.state.stationSearch=undefined;
-		this.state.statusSeach=undefined;
-		this.state.signNameSearch='';
-		this.state.mobileSearch='';
-		this.state.proNameSearch='';
-        this.loadData();       
-    },
-    searchSwitch() {
-        this.setState({
-            searchMore: !this.state.searchMore
-        });
-    },
-    render() {
-        const rowSelection = {
-            selectedRowKeys: this.state.selectedRowKeys,
-            onChange: (selectedRowKeys, selectedRows) => {
-                this.setState({
-                    selectedRows: selectedRows.slice(-1),
-                    selectedRowKeys: selectedRowKeys.slice(-1)
-                });
-            },
-            onSelectAll: (selected, selectedRows, changeRows) => {
-			   this.setState({
-			   		selectedRowKeys:[]
-			   })
+		this.state.data = [];
+		this.setState({
+			userDetaile:false,
+			loading: true
+		});
+		$.ajax({
+			method: "get",
+			dataType: "json",
+			crossDomain: false,
+			url: globalConfig.context + '/api/admin/superviser/adminList',
+			data: {
+				pageNo: pageNo || 1,
+				pageSize: this.state.pagination.pageSize,
+				name: this.state.userNameSearch,
+				departmentId: this.state.organizationSearch,
+				rid: this.state.rolesSearch,
+				duty: this.state.postSearch,
+				position: this.state.stationSearch,
+				status: this.state.statusSeach,
+				mobile: this.state.signNameSearch,
+				superiorId: this.state.theTypes
 			},
-        };
-        const hasSelected = this.state.selectedRowKeys.length > 0;
-        const { RangePicker } = DatePicker;
-        return (
-            <div className="user-content" >
+			success: function(data) {
+				let theArr = [];
+				if(!data.data || !data.data.list) {
+					if(data.error && data.error.length) {
+						message.warning(data.error[0].message);
+					};
+				} else {
+					for(let i = 0; i < data.data.list.length; i++) {
+						let thisdata = data.data.list[i];
+						theArr.push({
+							key: i,
+							id: thisdata.id,
+							mobile: thisdata.mobile,
+							name: thisdata.name,
+							email: thisdata.email,
+							createTime: thisdata.createTime,
+							province: thisdata.province,
+							position: thisdata.position,
+							superior: thisdata.superior, //上级名称
+							superiorId: thisdata.superiorId, //上级Id
+							duty: thisdata.duty, //职务
+							status: thisdata.status,
+							userNo: thisdata.userNo,
+							departmentName: thisdata.departmentName, //部门名称
+							departmentId: thisdata.departmentId, //部门id
+							roles:thisdata.roles[0]
+						});
+					};
+					this.state.pagination.current = data.data.pageNo ? data.data.pageNo : '0';
+					this.state.pagination.total = data.data.totalCount ? data.data.totalCount : '0';
+				};
+				this.setState({
+					dataSource: theArr,
+					pagination: this.state.pagination
+				});
+			}.bind(this),
+		}).always(function() {
+			this.setState({
+				loading: false
+			});
+		}.bind(this));
+	},
+	getInitialState() {
+		return {
+			datauser: {},
+			searchMore: true,
+			selectedRowKeys: [],
+			selectedRows: [],
+			userDetaile: false,
+			departmentArr: [],
+			loading: false,
+			roleArr:[],
+			pagination: {
+				defaultCurrent: 1,
+				defaultPageSize: 10,
+				showQuickJumper: true,
+				pageSize: 10,
+				onChange: function(page) {
+					this.loadData(page);
+				}.bind(this),
+				showTotal: function(total) {
+					return '共' + total + '条数据';
+				}
+			},
+			columns: [{
+					title: '用户编号',
+					dataIndex: 'userNo',
+					key: 'userNo',
+				}, {
+					title: '登录用户名',
+					dataIndex: 'mobile',
+					key: 'mobile',
+				}, {
+					title: '角色',
+					dataIndex: 'roles',
+					key: 'roles',
+				}, {
+					title: '用户姓名',
+					dataIndex: 'name',
+					key: 'name',
+				}, {
+					title: '部门',
+					dataIndex: 'departmentName',
+					key: 'departmentName',
+				}, {
+					title: '职务',
+					dataIndex: 'duty',
+					key: 'duty',
+					render: text => { return getPost(text) }
+				},
+				{
+					title: '岗位',
+					dataIndex: 'position',
+					key: 'position',
+					render: text => { return getStation(text) }
+				},
+
+				{
+					title: '上级主管姓名',
+					dataIndex: 'superior',
+					key: 'superior',
+				},
+				{
+					title: '状态',
+					dataIndex: 'status',
+					key: 'status',
+				}
+			],
+			dataSource: [],
+		};
+	},
+	componentWillMount() {
+		this.loadData();
+		this.departmentList();
+		this.rolesList();
+	},
+	tableRowClick(record, index) {
+		this.rolesArrS(record)
+		this.state.userDetaile = true;
+		this.state.datauser = record;
+		this.setState({
+			showDesc: true
+		});
+	},
+	//新建获取id
+	addIdS() {
+		$.ajax({
+			method: "post",
+			dataType: "json",
+			crossDomain: false,
+			url: globalConfig.context + '/api/admin/superviser/newId',
+			data: {},
+			success: function(data) {
+				this.setState({
+					addId: data.data
+				});
+			}.bind(this),
+		}).always(function() {
+			this.setState({
+				loading: false
+			});
+		}.bind(this));
+	},
+	//部门
+	departmentList() {
+		this.setState({
+			loading: true
+		});
+		$.ajax({
+			method: "post",
+			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);
+					};
+					thedata = {};
+				} 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));
+	},
+	//修改时获取角色数组 
+	rolesArrS(e) {
+		$.ajax({
+			method: "get",
+			dataType: "json",
+			crossDomain: false,
+			url: globalConfig.context + "/api/admin/role",
+			data: {
+				uid:e.id
+			},
+			success: function(data) {
+				let thedata = data.data;
+				let theArr = [];
+				let theId=[]
+				if(!thedata) {
+					if(data.error && data.error.length) {
+						message.warning(data.error[0].message);
+					};
+					thedata = {};
+				} else {
+				
+				}
+				this.setState({
+					role:thedata
+				})
+			}.bind(this),
+		}).always(function() {
+		}.bind(this));
+	},
+	//角色
+	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));
+	},
+	
+	//锁定
+	locking() {
+		let deletedIds;
+		let statust;
+		let mobiles;
+		let names;
+		for(let idx = 0; idx < this.state.selectedRows.length; idx++) {
+			let rowItem = this.state.selectedRows[idx];
+			if(rowItem.id) {
+				deletedIds=rowItem.id;
+				statust=rowItem.status;
+				names=rowItem.name;
+				mobiles=rowItem.mobile;
+			};
+		};
+		if(statust!='锁定'){
+			this.setState({
+				selectedRowKeys: [],
+				loading: true
+			});
+			$.ajax({
+				method: "POST",
+				dataType: "json",
+				crossDomain: false,
+				url: globalConfig.context + "/api/admin/superviser/updateAdmin",
+				data: {
+					data:JSON.stringify({
+						id: deletedIds,
+						status: '锁定',
+						name: names,
+						mobile: mobiles
+					})
+				}
+			}).done(function(data) {
+				if(!data.error.length) {
+					message.success('锁定成功!');
+					this.setState({
+						loading: false,
+					});
+				} else {
+					message.warning(data.error[0].message);
+				};
+				this.loadData();
+			}.bind(this));
+		}else{
+			message.warning('已是锁定状态')
+		}
+	},
+	//激活
+	activation() {
+		let deletedIds;
+		let statust;
+		let mobiles;
+		let names;
+		for(let idx = 0; idx < this.state.selectedRows.length; idx++) {
+			let rowItem = this.state.selectedRows[idx];
+			if(rowItem.id) {
+				deletedIds=rowItem.id;
+				statust=rowItem.status;
+				names=rowItem.name;
+				mobiles=rowItem.mobile;
+			};
+		};
+		if(statust!='正常'){
+			this.setState({
+				selectedRowKeys: [],
+				loading: true
+			});
+			$.ajax({
+				method: "POST",
+				dataType: "json",
+				crossDomain: false,
+				url: globalConfig.context + "/api/admin/superviser/updateAdmin",
+				data: {
+					data:JSON.stringify({
+						id: deletedIds,
+						status: '正常',
+						name: names,
+						mobile: mobiles
+					})
+				}
+			}).done(function(data) {
+				if(!data.error.length) {
+					message.success('激活成功!');
+					this.setState({
+						loading: false,
+					});
+				} else {
+					message.warning(data.error[0].message);
+				};
+				this.loadData();
+			}.bind(this));
+		}else{
+			message.warning('已是激活状态')
+		}
+	},
+	//删除
+	delectRow() {
+		let deletedIds;
+		let statust;
+		let mobiles;
+		let names;
+		for(let idx = 0; idx < this.state.selectedRows.length; idx++) {
+			let rowItem = this.state.selectedRows[idx];
+			if(rowItem.id) {
+				deletedIds=rowItem.id;
+				statust=rowItem.status;
+				names=rowItem.name;
+				mobiles=rowItem.mobile
+			};
+		};
+		this.setState({
+			selectedRowKeys: [],
+			loading: true
+		});
+		$.ajax({
+			method: "POST",
+			dataType: "json",
+			crossDomain: false,
+			url: globalConfig.context + "/api/admin/superviser/updateAdmin",
+			data: {
+				data:JSON.stringify({
+					id: deletedIds,
+					status:'注销',
+					name: names,
+					mobile: mobiles
+				})
+			}
+		}).done(function(data) {
+			if(!data.error.length) {
+				message.success('删除成功!');
+				this.setState({
+					loading: false,
+				});
+			} else {
+				message.warning(data.error[0].message);
+			};
+			this.loadData();
+		}.bind(this));
+	},
+	addClick() {
+		this.addIdS()
+		this.state.userDetaile = false;
+		this.setState({
+			showDesc: true
+		});
+	},
+	closeDesc(e, s) {
+		this.state.showDesc = e;
+		if(s) {
+			this.loadData();
+		};
+	},
+	search() {
+		this.state.userDetaile = false
+		this.loadData();
+	},
+	reset() {
+		this.state.userNameSearch = '';
+		this.state.organizationSearch = undefined;
+		this.state.rolesSearch = undefined;
+		this.state.postSearch = undefined;
+		this.state.stationSearch = undefined;
+		this.state.statusSeach = undefined;
+		this.state.signNameSearch = '';
+		this.state.mobileSearch = '';
+		this.state.auto = '';
+		this.loadData();
+	},
+	searchSwitch() {
+		this.setState({
+			searchMore: !this.state.searchMore
+		});
+	},
+	//主管初始加载(自动补全)
+	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({
+			auto: 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({
+			theTypes: theType
+		})
+	},
+	//值改变时请求客户名称
+	httpChange(e) {
+		if(e.length >= 1) {
+			this.supervisor(e);
+		}
+		this.setState({
+			auto: e
+		})
+	},
+	render() {
+		const rowSelection = {
+			selectedRowKeys: this.state.selectedRowKeys,
+			onChange: (selectedRowKeys, selectedRows) => {
+				this.setState({
+					selectedRows: selectedRows.slice(-1),
+					selectedRowKeys: selectedRowKeys.slice(-1)
+				});
+			},
+			onSelectAll: (selected, selectedRows, changeRows) => {
+				this.setState({
+					selectedRowKeys: []
+				})
+			},
+		};
+		const dataSources = this.state.customerArr || [];
+		const options = dataSources.map((group, index) =>
+			<Select.Option key={index} value={group.name}>{group.name}</Select.Option>
+		)
+		const hasSelected = this.state.selectedRowKeys.length > 0;
+		const { RangePicker } = DatePicker;
+		let departmentArr = this.state.departmentArr || [];
+		let roleArr = this.state.roleArr || [];
+		return(
+			<div className="user-content" >
                 <div className="content-title">
 	                <div className="user-search">
 	                    <Input placeholder="用户姓名" style={{width:'150px'}}
 	                        value={this.state.userNameSearch}
 	                        onChange={(e) => { this.setState({ userNameSearch: e.target.value }); }} />
-	                    <Select placeholder="组织机构"
+	                    <Select placeholder="部门"
                             style={{ width: 160 }}
                             value={this.state.organizationSearch}
                             onChange={(e) => { this.setState({ organizationSearch: e }) }}>
-                            {this.state.organizationList}
+                            {
+                                departmentArr.map(function (item) {
+                                        return <Select.Option key={item.id} >{item.name}</Select.Option>
+                                })
+                            }
                         </Select>
                         <Select placeholder="角色"
                             style={{ width: 160 }}
                             value={this.state.rolesSearch}
                             onChange={(e) => { this.setState({ rolesSearch: e }) }}>
-                            {this.state.organizationList}
+                            {
+                                roleArr.map(function (item) {
+                                        return <Select.Option key={item.id} >{item.roleName}</Select.Option>
+                                })
+                            }
                         </Select>    
 	                    <Button type="primary" onClick={this.search}>搜索</Button>
 	                    <Button onClick={this.reset}>重置</Button>
@@ -357,14 +606,30 @@ const User=Form.create()(React.createClass({
 	                            style={{ width: 160 }}
 	                            value={this.state.statusSeach}
 	                            onChange={(e) => { this.setState({ statusSeach: e }) }}>
-	                            {this.state.organizationList}
+	                            <Select.Option value="正常" >正常</Select.Option>
+   								<Select.Option value="锁定" >锁定</Select.Option>
                        		</Select>
                        		<Input placeholder="登录用户名" style={{width:'150px'}}
 		                        value={this.state.signNameSearch}
 		                        onChange={(e) => { this.setState({ signNameSearch: e.target.value }); }} />
-	                        <Input placeholder="上级主管名称" style={{width:'150px'}}
-		                        value={this.state.proNameSearch}
-		                        onChange={(e) => { this.setState({ proNameSearch: e.target.value }); }} />
+	                        
+	                        <AutoComplete
+						        className="certain-category-search"
+						        dropdownClassName="certain-category-search-dropdown"
+						        dropdownMatchSelectWidth={false}
+						        dropdownStyle={{ width: 200 }}
+						        size="large"
+						        style={{ width: '150px',height:'28px' ,marginLeft:'10px'}}
+						        dataSource={options}
+						        placeholder="输入上级主管名字"
+						        value={this.state.auto}
+						        onChange={this.httpChange}
+						        filterOption={true}
+						        onBlur={this.blurChange}
+						        onSelect={this.selectAuto}
+						      >
+						        <Input/>
+						      </AutoComplete> 
 	                    </div>
 	                </div>
 	                <div className="patent-table">
@@ -377,14 +642,18 @@ const User=Form.create()(React.createClass({
 	                    </Spin>
 	                </div>
 	                <Newuser
+	                    role={this.state.role}
+	                    addId={this.state.addId}
+	                    roleArr={this.state.roleArr}
+	                    departmentArr={this.state.departmentArr}
 	                    userDetaile={this.state.userDetaile}
 	                    datauser={this.state.datauser}
 	                    showDesc={this.state.showDesc}
 	                    closeDesc={this.closeDesc} />
 	            </div >
             </div>
-        );
-    }
+		);
+	}
 }));
 
-export default User;
+export default User;

+ 4 - 1
js/component/manageCenter/set/userManagementS/userMangagement.less

@@ -66,4 +66,7 @@
     color: red;
     margin-left: 8px;
 }
-
+.search-more .ant-select-auto-complete.ant-select-lg .ant-input{
+    height:28px
+}
+.rolesCol{width: 90%;}