1. 程式人生 > >通達OA工作流表單ajax獲取資料使用例項

通達OA工作流表單ajax獲取資料使用例項

<script>
jQuery(function(){
  //alert("1111");
  if(g_prcs_id==1){
jQuery('#xingming').change(function(){ 
	var xingming= document.getElementById("xingming").value;
  //alert(xingming);
	if(xingming!=""){
	jQuery.ajax({
    type: "GET",//使用post會出現亂碼
    url: "getxinxi.php",
    dataType: "text",
    data: "run_id=" +g_run_id+"&g_flow_id="+g_flow_id+"&xingming="+xingming,
    success: function(msg){
    //alert(msg);
    //$("#htbh").focus();
    if(msg!=""){
       var obj = eval("("+msg+")");    
      jQuery("input[name='DATA_221']").val(obj["bumen"]);
      jQuery("input[name='DATA_330']").val(obj["zhiwu"]);
      jQuery("input[name='DATA_110']").val(obj["lianxiren"]);
      jQuery("input[name='DATA_111']").val(obj["lianxirendianhua"]);
      //jQuery("#zhuguan").val(msg);
      //document.getElementById("htbh").value = msg;
       }
          }
      });
		}
	});
  }
});


jQuery(function(){
  //alert("1111");
  if(g_prcs_id==1){
jQuery('#bushi').change(function(){ 
	var bushi=document.getElementById("bushi").value;
  //alert(bushi);
	if(bushi!=""){
		 jQuery.ajax({
    type: "GET",//使用post會出現亂碼
    url: "getzhuguan.php",
    dataType: "text",
    data: "run_id=" +g_run_id+"&g_flow_id="+g_flow_id+"&bushi="+bushi,
    success: function(msg){
      //alert(msg);
    //$("#htbh").focus();
    if(msg!=""){
     jQuery("#zhuguan").val(msg);
   // document.getElementById("htbh").value = msg;
       }
          }
      });
		}
	});
  }
});

jQuery(function(){
  if(g_prcs_id==1){
jQuery('#bushi').change(function(){ 
	var bushi=document.getElementById("bushi").value;
	if(bushi!=""){
		 jQuery.ajax({
    type: "GET",//使用post會出現亂碼
    url: "getguanglichu.php",
    dataType: "text",
    data: "run_id=" +g_run_id+"&g_flow_id="+g_flow_id+"&bushi="+bushi,
    success: function(msg){
    if(msg!=""){
     jQuery("#guanglichu").val(msg);
       }
          }
      });
		}
	});
  }
});

jQuery(function(){
  if(g_prcs_id==1){
jQuery('#bushi').change(function(){ 
	var bushi=document.getElementById("bushi").value;
  //alert(bushi);
	if(bushi!=""){
		 jQuery.ajax({
    type: "GET",//使用post會出現亂碼
    url: "getbumenfzr.php",
    dataType: "text",
    data: "run_id=" +g_run_id+"&g_flow_id="+g_flow_id+"&bushi="+bushi,
    success: function(msg){
    //  alert(msg);
    if(msg!=""){
     jQuery("#bumenfzr").val(msg);
       }
          }
      });
		}
	});
  }
});

jQuery(function(){
  if(g_prcs_id==1){
jQuery('#bushi').change(function(){ 
	var bushi=document.getElementById("bushi").value;
	if(bushi!=""){
		 jQuery.ajax({
    type: "GET",//使用post會出現亂碼
    url: "getfengsfzr.php",
    dataType: "text",
    data: "run_id=" +g_run_id+"&g_flow_id="+g_flow_id+"&bushi="+bushi,
    success: function(msg){
    if(msg!=""){
     jQuery("#fengsfzr").val(msg);
       }
          }
      });
		}
	});
  }
});

</script>

getxinxi.php:
<?
//include_once("inc/auth.inc.php");         // 如需登入驗證則包含,未登入將退出
include_once("inc/conn.php");       // 如需要連線資料庫則包含
include_once("inc/utility_org.php");  
 

$liushuihao=$_REQUEST["run_id"];//流水號
$g_flow_id =$_REQUEST["g_flow_id"];  //流程型別的id
$xingming=$_REQUEST["xingming"];//

$query="select user_id,dept_id,user_priv from user where user_name='$xingming' limit 1";
$cursor=exequery(TD::conn(),$query);
while($row=mysql_fetch_array($cursor)){
	
	$user_id=$row["user_id"];
	$dept_id=$row["dept_id"];
	$user_priv=$row["user_priv"];
	}
	//echo $user_id;
$query1="select priv_name from user_priv where user_priv='$user_priv' limit 1";
$cursor1=exequery(TD::conn(),$query1);
if($row1=mysql_fetch_row($cursor1)){
	$priv_name=$row1[0];
	}
	
$query2="select dept_name from department where dept_id='$dept_id' limit 1";
$cursor2=exequery(TD::conn(),$query2);
if($row2=mysql_fetch_row($cursor2)){
	$dept_name=$row2[0];
	}			

$query3="select * from hr_staff_info where user_id='$user_id' limit 1";
$cursor3=exequery(TD::conn(),$query3);	
while($row3=mysql_fetch_array($cursor3)){
	$zhiwu=$row3["JOB_POSITION"];
	$lianxidianhua=$row3["STAFF_MOBILE"];
	$lianxiren=$row3["PART_TIME"];
	$lianxirendianhua=$row3["STAFF_PHONE"];
	$ruzhiriqi=$row3["DATES_EMPLOYED"];
	$ruzhixinziyuexin=$row3["GRADUATION_SCHOOL"];
	$ruzhixinzinianxin=$row3["STAFF_MAJOR"];
	$xingbie=$row3["STAFF_SEX"];//STAFF_CARD_NO
	$shenfenzheng=$row3["STAFF_CARD_NO"];//STAFF_AGE
	$nianling=$row3["STAFF_AGE"];
	if($STAFF_SEX == '0'){
		$xingbie='男';
	}
	if($STAFF_SEX == '1'){
		$xingbie='女';
	}
	}	


$arr=array();
$arr["bumen"]=iconv("gb2312","utf-8",$dept_name);
$arr["zhiwu"]=iconv("gb2312","utf-8",$zhiwu);
$arr["lianxidianhua"]=iconv("gb2312","utf-8",$lianxidianhua);
$arr["lianxiren"]=iconv("gb2312","utf-8",$lianxiren);
$arr["lianxirendianhua"]=iconv("gb2312","utf-8",$lianxirendianhua);
$arr["ruzhiriqi"]=iconv("gb2312","utf-8",$ruzhiriqi);
$arr["ruzhixinziyuexin"]=iconv("gb2312","utf-8",$ruzhixinziyuexin);
$arr["ruzhixinzinianxin"]=iconv("gb2312","utf-8",$ruzhixinzinianxin);
$arr["xingbie"]=iconv("gb2312","utf-8",$xingbie);
$arr["shenfenzheng"]=iconv("gb2312","utf-8",$shenfenzheng);
$arr["nianling"]=iconv("gb2312","utf-8",$nianling);

//echo $dept_name.$zhiwu.$lianxiren.$lianxirendianhua;
echo json_encode($arr);
?>