liting2017 7 years ago
parent
commit
fc10ed2fec

+ 98 - 126
js/component/manageCenter/customer/individualCustomer/individualCustomer.jsx

@@ -1,5 +1,5 @@
 import React from 'react';
-import { Radio, Icon, Button, Cascader, Input, Select, Tabs, Spin, Popconfirm, Popover, Table, Switch, message, DatePicker, Modal, Upload, Form, Row, Col } from 'antd';
+import { Radio, Icon, Button,AutoComplete, Cascader, Input, Select, Tabs, Spin, Popconfirm, Popover, Table, Switch, message, DatePicker, Modal, Upload, Form, Row, Col } from 'antd';
 import ajax from 'jquery/src/ajax/xhr.js';
 import $ from 'jquery/src/ajax';
 import moment from 'moment';
@@ -185,7 +185,6 @@ const IndividualCustomer = Form.create()(React.createClass({
 			releaseDate: [],
 			releaseDate: [],
 			selectedRowKeys: [],
-			selectedRowKey: [],
 			selectedRows: [],
 			loading: false,
 			pagination: {
@@ -826,103 +825,33 @@ const IndividualCustomer = Form.create()(React.createClass({
 		}.bind(this));
 	},
 
-	//指定转交人的点击函数
-	showModa() {
-		this.setState({
-			visible: true,
-		});
-		this.setState({
-			selectedRowKey: [],
-		});
+	//转交
+	changeAssigner() {
 		this.setState({
-			selectedRowKeys: this.state.selectedRowKeys,
+			selectedRowKeys: [],
 		});
 		let changeIds;
-		let adminName;
-		let customerStatus;
-		let companyIntention;
-		let followSituation;
 		for(let idx = 0; idx < this.state.selectedRows.length; idx++) {
 			let rowItem = this.state.selectedRows[idx];
 			if(rowItem.id) {
 				changeIds = rowItem.id;
-				adminName = rowItem.adminName;
-				customerStatus = rowItem.customerStatus;
-				companyIntention = rowItem.companyIntention;
-				followSituation = rowItem.followSituation;
+				
 			};
 		};
 		$.ajax({
-			method: "post",
-			dataType: "json",
-			crossDomain: false,
-			url: globalConfig.context + "/api/admin/customer/findAdmin",
-			data: {
-				id: changeIds, //这一行数据的ID	           
-				beforeCompanyIntention: companyIntention, //意向服务
-				beforeCustomerStatus: customerStatus, //客户状态
-				beforeFollowSituation: followSituation, //最新跟进状态
-				beforeAdminName: adminName, //跟进人
-			}
-		}).done(function(data) {
-			if(data.error && data.error.length) {
-				message.warning(data.error[0].message);
-			} else {
-				let theAssigne = [];
-				if(!data.data) {
-					if(data.error && data.error.length) {
-						message.warning(data.error[0].message);
-					};
-
-				} else {
-					for(let i = 0; i < data.data.length; i++) {
-
-						let thisdata = data.data[i];
-						//处理数据 进行循环
-						theAssigne.push({
-							name: thisdata.name,
-							id: thisdata.id,
-							ids: thisdata.cid,
-							mobile: thisdata.mobile,
-							adminName: thisdata.beforeAdminName,
-							customerStatus: thisdata.beforeCustomerStatus,
-							companyIntention: thisdata.beforeCompanyIntention,
-							followSituation: thisdata.beforeFollowSituation,
-						});
-					};
-
-				};
-				this.setState({
-					dataman: theAssigne,
-					paginations: false
-				});
-			}
-		}.bind(this));
-	},
-	//选择了指定人之后的保存点击函数,需要修改函数
-	changeAssigner() {
-		this.setState({
-			visible: false,
-		});
-		this.setState({
-			selectedRowKeys: [],
-		});
-		let datt = this.state.selectedRow;
-		$.ajax({
-			method: "post",
+			method: "get",
 			dataType: "json",
 			crossDomain: false,
-			url: globalConfig.context + "/api/admin/customer/transferCustomer",
+			url: globalConfig.context + "/api/admin/customer/transferToOther",
 			data: {
-				id: datt[0].ids, //这一行数据的ID
-				aid: datt[0].id, //指定转交人的ID 
-				beforeAdminName: datt[0].adminName, //之前的跟进人
-				adminName: datt[0].name, //转交的跟进人
+				uid: changeIds, //这一行数据的ID
+				aid: this.state.theTypes, //指定转交人的ID 
 			}
 		}).done(function(data) {
 			if(!data.error.length) {
 				message.success('转交成功!');
 				this.setState({
+					auto:'',
 					loading: false,
 				});
 			} else {
@@ -2011,6 +1940,64 @@ const IndividualCustomer = Form.create()(React.createClass({
 			});
 		}.bind(this));
 	},
+	//指定转交人自动补全
+	supervisor(e){ 
+		$.ajax({
+            method: "get",
+            dataType: "json",
+            crossDomain: false,
+            url: globalConfig.context + "/api/admin/customer/listAdminByName",
+            data:{
+            	adminName: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){
+		console.log(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
+		})
+	},
 	componentWillReceiveProps(nextProps) {
 		if(!this.props.visible && nextProps.visible) {
 			if(nextProps.data && nextProps.data.id) {
@@ -2039,22 +2026,6 @@ const IndividualCustomer = Form.create()(React.createClass({
 				})
 			},
 		};
-		const rowSelections = {
-			selectedRowKeys: this.state.selectedRowKey,
-			onChange: (selectedRowKey, selectedRow) => {
-				this.setState({
-					selectedRow: selectedRow.slice(-1),
-					selectedRowKey: selectedRowKey.slice(-1)
-				});
-			},
-			onSelect: (records, selected, selectedRow) => {
-				this.setState({
-					selectedRow: selectedRow.slice(-1),
-					records: records.id,
-				})
-			},
-
-		};
 		const hasSelected = this.state.selectedRowKeys.length > 0;
 		const { RangePicker, MonthPicker } = DatePicker;
 		const { getFieldDecorator } = this.props.form;
@@ -2069,6 +2040,11 @@ const IndividualCustomer = Form.create()(React.createClass({
 			wrapperCol: { span: 14 },
 		};
 		const contacts = this.state.contacts || '';
+		const dataSources=this.state.customerArr || [];
+		console.log(dataSources)
+        const options = dataSources.map((group) =>
+				      <Select.Option key={group.id} value={group.name}>{group.name}</Select.Option>
+				     )
 		return(
 			<div className="user-content" >
                 <div className="content-title">                  
@@ -2118,32 +2094,29 @@ const IndividualCustomer = Form.create()(React.createClass({
 					<Button style={{ background: "#ea0862", border: "none", color: "#fff",marginRight:'10px' ,marginLeft:'10px'}}
 	                        disabled={!hasSelected} 
 	                        onClick={this.delectRow}>删除<Icon type="minus" />
-	                </Button>	
-					<Button type="primary" onClick={this.showModa}  disabled={!hasSelected}>指定转交人</Button>  
+	                </Button>
+	               <AutoComplete
+				        className="certain-category-search"
+				        dropdownClassName="certain-category-search-dropdown"
+				        dropdownMatchSelectWidth={false}
+				        dropdownStyle={{ width: 120 }}
+				        
+				        style={{ width: '120px'}}
+				        dataSource={options}
+				        placeholder="输入转交人姓名"
+				        value={this.state.auto}
+				        onChange={this.httpChange}
+				        filterOption={true}
+				        onBlur={this.blurChange}
+				        onSelect={this.selectAuto}
+				        disabled={!hasSelected}
+				      >
+				        <Input />
+				      </AutoComplete>  
+					<Button type="primary" onClick={this.changeAssigner}  disabled={!hasSelected} >转交</Button>  
 					<Button style={{ background: "#3fcf9e", border: "none", color: "#fff" }}
                         disabled={!hasSelected}
                         onClick={this.changeRow}>转为公共客户<Icon /></Button>
-           			<Modal				             
-			              footer=''
-					          title="选择指定人"
-					          visible={this.state.visible}
-					          onOk={this.handleOk}
-					          onCancel={this.handleCancel}							          
-					        >
-				            <Spin spinning={this.state.loading}>
-				            	 <Table 
-				            	 scroll={{y:'350px'}}
-				            	 pagination={false}
-				            	 columns={this.state.columnsman} 
-				            	 rowSelection={rowSelections} 
-				            	 dataSource={this.state.dataman}
-				            	 />		            				        
-			               <FormItem wrapperCol={{ span: 12, offset: 12 }} style={{marginTop:'15px'}}>
-                       		<Button className="set-submit" type="primary" htmlType="submit" id="change_keep" style={{marginLeft:"50px"}} onClick={this.changeAssigner }>保存</Button>
-                       		<Button className="set-submit" type="ghost" onClick={this.handleCancel } style={{marginLeft:"30px"}} id='change_rem'>取消</Button>
-                	  </FormItem>  
-                	</Spin>
-					</Modal>
 	                  <Button style={{marginRight:'10px',background: "#595a5c", border: "none",color: "#fff" }}												
 	                        disabled 
 	                        onClick={this.delectRow}>锁定
@@ -2151,10 +2124,9 @@ const IndividualCustomer = Form.create()(React.createClass({
 	                  <Button style={{marginRight:'10px',background: "#11a2c6", border: "none",color: "#fff" }}												
 	                         disabled
 	                        onClick={this.delectRow}>激活
-	                  </Button>			
-	                  <span style={{marginLeft:'10px',marginRight:'20px'}}>更多搜索<Switch defaultChecked={false} onChange={this.searchSwitch} /></span>
-                    <Button type="primary" className="addButton" onClick={this.addClick}>新增客户<Icon type="plus" /></Button> 
-                    
+	                  </Button>	
+	                  <Button type="primary" className="addButton" onClick={this.addClick}>新增客户<Icon type="plus" /></Button> 
+                      <span style={{marginLeft:'10px',marginRight:'20px'}}>更多搜索<Switch defaultChecked={false} onChange={this.searchSwitch} /></span>
                     <div className='clearfix' style={{marginTop:'5px'}}>
 	                  <div className="search-more" style={this.state.searchMore ? { display: 'none' } : {}}>                    			                  
 			                <RangePicker
@@ -2373,9 +2345,9 @@ const IndividualCustomer = Form.create()(React.createClass({
 							                    </FormItem>
 							                    <FormItem className="half-item" 
 								                    	 {...formItemLayout}
-								                        label="业资格"
+								                        label="业资格"
 						                           	 >
-							                            <Input placeholder="业资格" value={this.state.qualification} onChange={(e) => {
+							                            <Input placeholder="业资格" value={this.state.qualification} onChange={(e) => {
 									                        this.setState({ qualification:  e.target.value })}}/>
 							                    </FormItem>
 							                    <FormItem className="half-item"

+ 3 - 3
js/component/manageCenter/customer/individualCustomer/queryCustomer.jsx

@@ -2170,9 +2170,9 @@ const QueryCustomer = Form.create()(React.createClass({
 							                    </FormItem>
 							                    <FormItem className="half-item" 
 								                    	 {...formItemLayout}
-								                        label="业资格"
+								                        label="业资格"
 						                           	 >
-							                            <Input placeholder="业资格" value={this.state.qualification} onChange={(e) => {
+							                            <Input placeholder="业资格" value={this.state.qualification} onChange={(e) => {
 									                        this.setState({ qualification:  e.target.value })}}/>
 							                    </FormItem>
 							                    <FormItem className="half-item"
@@ -2467,7 +2467,7 @@ const QueryCustomer = Form.create()(React.createClass({
 						                    </FormItem>
 						                    <FormItem className="half-item" 
 							                    	 {...formItemLayout}
-							                        label="业资格"
+							                        label="业资格"
 					                           	 >
 						                   	    <span>{this.state.qualification}</span>
 						                    </FormItem>