$("#ctl00_PlaceHolderMain_txtDutyMan_div_style ").bind('DOMNodeInserted', function (e) {
if ($(e.target).html().indexOf("username") > 0) {
var text_divHtml = $(e.target).html();
var ADAccount = $("#ctl00_PlaceHolderMain_txtDutyMan_div_style").find($(".text_div")).find($(".text_select")).attr("username").trim().replace('\\', '\\\\');
var Name = $("#ctl00_PlaceHolderMain_txtDutyMan_div_style").find($(".text_div")).text().trim();
$("div#ctl00_PlaceHolderMain_txtUser_div_style").each(function () {
var div = $(this).find($(".text_div"));
div.html(text_divHtml);
});
$("div#ctl00_PlaceHolderMain_txtUser_qwe").each(function () {
var txtUser_json = $(this).find("#ctl00_PlaceHolderMain_txtUser_json");
txtUser_json.val('[{"Name":"' + ADAccount + '","Displayname":"' + Name + '"}]');
});
//绑定岗位
BindJob(ADAccount.replace("\\\\", "\\"));
//绑定上级
BindApprover(ADAccount.replace("\\\\", "\\"));
}
});
function BindApprover(ADAccount) {
var url = "/_layouts/15/SaiLun_SP_MySite/handler/Task/GetApproverByADAccount.aspx?ADAccount=" + ADAccount;
$.ajax({
url: url,
type: "GET",
dataType: "json",
error: function () {
alert("Error");
},
success: function (data) {
var result = eval(data);
var test = JSON.stringify(result);
var txtUser = $("#ctl00_PlaceHolderMain_txtApprover_qwe").find($("#ctl00_PlaceHolderMain_txtApprover_json"));
txtUser.val(test);
var div = $("#ctl00_PlaceHolderMain_txtApprover_div_style").find($(".text_div"));
var divHtml = '<div class="text_div"><div class="text_select" username="' + result[0].Name + '">' + result[0].Displayname + '</div><div class="text-remove"></div></div>';
div.html(divHtml);
$("div#ctl00_PlaceHolderMain_txtInspectUser_div_style").each(function () {
//alert(divHtml);
$(this).find($(".text_div")).html(divHtml);
});
$("div#ctl00_PlaceHolderMain_txtInspectUser_qwe").each(function () {
//alert(test);
$(this).find("#ctl00_PlaceHolderMain_txtInspectUser_json").val(test);
});
}
});
}
function BindJob(ADAccount) {
var url = "/_layouts/15/SaiLun_SP_MySite/handler/Task/GetJobByADAccount.aspx?ADAccount=" + ADAccount;
$.ajax({
url: url,
type: "GET",
dataType: "json",
error: function () {
alert("Error");
},
success: function (data) {
var result = eval(data);
$("#<%=ddlJobID.ClientID%>").empty();
$(result).each(function (key) {
var opt = $("<option></option>").text(result[key].Location).val(result[key].JobID);
$("#<%=ddlJobID.ClientID%>").append(opt);
});
}
});
}
</script>
public partial class GetApproverByADAccount : LayoutsPageBase
{
protected void Page_Load(object sender, EventArgs e)
{
string adaccount = Request["ADAccount"].ToString();
string jsonStr = "";
SqlParameter[] parameter = { new SqlParameter("@adaccount", SqlDbType.VarChar) };
parameter[0].Value = adaccount;
SqlDataReader reader = DbHelperSQL.RunProcedure("cSP_GetProReportToByADAccount", parameter);
if (reader.Read())
{
string Displayname = reader["name"].ToString();
string name = reader["adaccount"].ToString().Replace(@"\", @"\\");
jsonStr = "[{\"Name\":\"" + name + "\",\"Displayname\":\"" + Displayname + "\"}]";
reader.Close();
}
Response.ContentType = "text/plain";
Response.Write(jsonStr);
Response.End();
}
}
public partial class GetJobByADAccount : LayoutsPageBase
{
protected void Page_Load(object sender, EventArgs e)
{
string adaccount = Request["ADAccount"].ToString();
SqlParameter[] parameter = { new SqlParameter("@adaccount", SqlDbType.NVarChar) };
parameter[0].Value = adaccount;
DataTable dt = (DbHelperSQL.RunProcedure("cSP_GetJobByADAccount", parameter, "data")).Tables[0];
IsoDateTimeConverter timeFormat = new IsoDateTimeConverter();
timeFormat.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
string jsonStr = JsonConvert.SerializeObject(dt);
Response.ContentType = "text/plain";
Response.Write(jsonStr);
Response.End();
}
}