dengzhiguo 6 years ago
parent
commit
6e648b7cb1
1 changed files with 25 additions and 8 deletions
  1. 25 8
      js/component/manageCenter/set/organization/organization.jsx

+ 25 - 8
js/component/manageCenter/set/organization/organization.jsx

@@ -130,6 +130,7 @@ const Organization=Form.create()(React.createClass({
                 },
                 success: function (data) {                	  
                 		let theArr = [];
+                		let theId=[];//用于保存上级组织的ID和名称
 					    let thedata=data.data;
 					    if (!thedata) {
 		                    if (data.error && data.error.length) {
@@ -138,16 +139,19 @@ const Organization=Form.create()(React.createClass({
 		                    thedata = {}; 
 		              };   
 					    var contactIds=[];
-				        //for (let item in data.data) {
-				        	for(var i=0;i<data.data.length;i++){
+				        for(var i=0;i<data.data.length;i++){
 		                    let theData = data.data[i];
 		                    theArr.push(
 		                        <Select.Option value={theData.id} key={theData.id}>{theData.name}</Select.Option>
 		                    );
+		                    theId.push(
+		                        [theData.id,theData.name]
+		                    );
 		                };
 						this.setState({	
 							SuperArr:thedata,
 		                    contactsOption: theArr, 
+		                    theId: theId, 
 		                    orderStatusOptions:data.data,
 	                    });
 	                    
@@ -165,8 +169,19 @@ const Organization=Form.create()(React.createClass({
     	//上级组织字典
         let nameText=this.state.SuperArr
         let superText=this.state.editSuperId;
+        let upId=this.state.theId;
+        let oldId='';
+        //console.log(this.state.theId);//用于保存上级组织的ID和名称
         //let superText=(this.state.editSuperId).length<=1?nameText[parseInt(this.state.editSuperId)].name:''
     	let superOne=this.state.editDataSource[0].editSuperId;
+    	if(superOne==superText){
+    		for(let j=0;j<upId.length;j++){
+    			if(superText==upId[j][1]){
+    				oldId=upId[j][0]
+    			}
+    		}
+    	};
+    	//console.log(oldId);
     	let remarksText=(this.state.editRemarks)?this.state.editRemarks:'该组织没有职能说明,请完善!';
     	let isStatus=this.state.editStatus;
     	if(isStatus==1){
@@ -211,7 +226,7 @@ const Organization=Form.create()(React.createClass({
 			            	name:this.state.editName,//组织名称
 			            	type:this.state.editType, //组织类型
 			            	managerId:this.state.theTypes?this.state.theTypes:this.state.managerIdOrganizationId,//负责人ID
-			                superId:this.state.editSuperId,//上级组织
+			                superId:oldId,//上级组织
 			                status:this.state.editStatus,//组织状态
 			                remarks:remarksText,//组织职能说明
 			                id:this.state.editId,//组织ID
@@ -233,6 +248,7 @@ const Organization=Form.create()(React.createClass({
     	}else{
     		if(!(superOne==superText)){
 		    		if(confirm('上级组织已修改,是否保存?')){
+		    		console.log(this.state.editSuperId);
 			        $.ajax({
 			            method: "post",
 			            dataType: "json",
@@ -262,7 +278,8 @@ const Organization=Form.create()(React.createClass({
 			        return false
 		        	}
 		    	}else {
-		        	$.ajax({
+		    		console.log(this.state.editSuperId);
+		    		$.ajax({
 			            method: "post",
 			            dataType: "json",
 			            crossDomain: false,
@@ -271,7 +288,7 @@ const Organization=Form.create()(React.createClass({
 			            	name:this.state.editName,//组织名称
 			            	type:this.state.editType, //组织类型
 			            	managerId:this.state.theTypes?this.state.theTypes:this.state.managerIdOrganizationId,//负责人ID
-			                superId:this.state.editSuperId,//上级组织
+			                superId:oldId,//上级组织
 			                status:this.state.editStatus,//组织状态
 			                remarks:remarksText,//组织职能说明
 			                id:this.state.editId,//组织ID
@@ -346,9 +363,9 @@ const Organization=Form.create()(React.createClass({
                 });
             }.bind(this),
         }).always(function (data) {
-        	if (data.error.length) {
-        		message.warn(data.error[0].message);
-        	};
+//      	if (data.error.length) {
+//      		message.warn(data.error[0].message);
+//      	};
             this.setState({
                 loading: false
             });