/// /// /// /// Custom_PhoneSelectUser = function () { this.ApplicationPath = "../"; this.ControlID = "Window_PhoneSelectUser"; this.ParentElement = null; //要加入的父容器 var listSelectPerson = null; this.OldDiv = null; //要隐藏的div this.SelectType = "all"; //要隐藏的div var My = this; var EventHandler = new Sys.EventHandlerList(); var IsT = 0; var IsS = 0; var pid = -1; //#region 加载 this.Load = function () { Init(); $("#ul_user").on("click", ".rank", function () { if ($(this).find("i").attr("sd") == "0") { $(this).find("i").addClass("selected"); $(this).find("i").attr("sd", "1"); } else { $(this).find("i").removeClass("selected"); $(this).find("i").attr("sd", "0"); } SumNum(); }); $("#ul_user").on("click", ".odd", function () { var pid = $(this).attr("pid"); if ($(this).find("i").attr("sd") == "0") { $(this).find("i").addClass("selected"); $("#ul_user li[pid=" + pid + "]").find("i").addClass("selected"); $("#ul_user li[pid=" + pid + "]").find("i").attr("sd", "1"); $(this).find("i").attr("sd", "1"); } else { $(this).find("i").removeClass("selected"); $("#ul_user li[pid=" + pid + "]").find("i").removeClass("selected"); $("#ul_user li[pid=" + pid + "]").find("i").attr("sd", "0"); $(this).find("i").attr("sd", "0"); } SumNum(); }); $("#ul_xs").on("click", ".rank", function () { if ($(this).find("i").attr("sd") == "0") { $(this).find("i").addClass("selected"); $(this).find("i").attr("sd", "1"); } else { $(this).find("i").removeClass("selected"); $(this).find("i").attr("sd", "0"); } SumNum(); }); $("#ul_xs").on("click", "a[pid]", function () { var pid = $(this).attr("pid"); if ($(this).attr("zd") == "0") { $("#ul_xs li[pid=" + pid + "].rank").hide(); $(this).removeClass("btn-off"); $(this).removeClass("btn-on"); $(this).addClass("btn-on"); $(this).attr("title","展开"); $(this).attr("zd", "1"); } else { $("#ul_xs li[pid=" + pid + "].rank").show(); $(this).removeClass("btn-off"); $(this).removeClass("btn-on"); $(this).addClass("btn-off"); $(this).attr("title", "折叠"); $(this).attr("zd", "0"); } }); $("#ul_xs").on("click", "i[pid]", function () { var pid = $(this).attr("pid"); if ($(this).attr("sd") == "0") { $(this).addClass("selected"); $("#ul_xs li[pid=" + pid + "]").find("i").addClass("selected"); $("#ul_xs li[pid=" + pid + "]").find("i").attr("sd", "1"); $(this).attr("sd", "1"); } else { $(this).removeClass("selected"); $("#ul_xs li[pid=" + pid + "]").find("i").removeClass("selected"); $("#ul_xs li[pid=" + pid + "]").find("i").attr("sd", "0"); $(this).attr("sd", "0"); } SumNum(); }); $("#ul_z").on("click", ".rank", function () { if ($(this).find("i").attr("sd") == "0") { $(this).find("i").addClass("selected"); $(this).find("i").attr("sd", "1"); } else { $(this).find("i").removeClass("selected"); $(this).find("i").attr("sd", "0"); } SumNum(); }); $("#ul_z").on("click", ".odd", function () { var pid = $(this).attr("pid"); if ($(this).find("i").attr("sd") == "0") { $(this).find("i").addClass("selected"); $("#ul_z li[pid=" + pid + "]").find("i").addClass("selected"); $("#ul_z li[pid=" + pid + "]").find("i").attr("sd", "1"); $(this).find("i").attr("sd", "1"); } else { $(this).find("i").removeClass("selected"); $("#ul_z li[pid=" + pid + "]").find("i").removeClass("selected"); $("#ul_z li[pid=" + pid + "]").find("i").attr("sd", "0"); $(this).find("i").attr("sd", "0"); } SumNum(); }); $("#ul_user").on("click", "#li_all", function () { if ($(this).find("i").attr("sd") == "0") { $(this).find("i").addClass("selected"); $(this).find("i").attr("sd", "1"); $("#ul_user").find("i").addClass("selected"); $("#ul_user").find("i").attr("sd", "1"); } else { $(this).find("i").removeClass("selected"); $(this).find("i").attr("sd", "0"); $("#ul_user").find("i").removeClass("selected"); $("#ul_user").find("i").attr("sd", "0"); } SumNum(); }); $("#ul_dept").on("click", "a[pid]", function () { $("#ul_dept a[pid]").removeClass("select"); pid = $(this).attr("pid"); $(this).addClass("select"); //if (pid > 0) // GetListUser2(pid); //else GetListUserT(); }); $("#" + My.ControlID).on("input propertychange", "#btn_schT", function () { GetListUserT(); }); $("#" + My.ControlID).on("input propertychange", "#btn_schS", function () { if ($("#btn_schS").val() == "") return; GetListUserXS(); }); $("#li_allXS,#li_allSS").bind("click", function () { if ($(this).find("i").attr("sd") == "0") { $(this).find("i").addClass("selected"); $(this).find("i").attr("sd", "1"); } else { $(this).find("i").removeClass("selected"); $(this).find("i").attr("sd", "0"); } SumNum(); }); $("#Window_PhoneSelectUser_cmdClose", My.ParentElement).on("click",function () { $("#" + My.ControlID, My.ParentElement).hide(); if (My.OldDiv != null) My.OldDiv.show(); }); //$("#Window_PhoneSelectUser_cmdClose2", My.ParentElement).on("click", function () { // $("#" + My.ControlID, My.ParentElement).hide(); // if (My.OldDiv != null) // My.OldDiv.show(); //}); $("#Window_PhoneSelectUser_cmdSave", My.ParentElement).on("click",function () { OnSave(); $("#" + My.ControlID, My.ParentElement).hide(); if (My.OldDiv != null) My.OldDiv.show(); }); $("#a_ls", My.ParentElement).on("click", function () { $("#xr_ls,#xr_xs,#xr_qxxs,#xr_qxss").hide(); $("#xr_ls").show(); if (IsS == 0) GetListUserT(); }); $("#a_xs", My.ParentElement).on("click", function () { $("#xr_ls,#xr_xs,#xr_qxxs,#xr_qxss").hide(); $("#ul_xs,#xr_xs").show(); if(IsS==0) GetListUserXS(); }); $("#a_qtxs", My.ParentElement).on("click", function () { $("#xr_ls,#xr_xs,#xr_qxxs,#xr_qxss").hide(); $("#xr_qxxs").show(); }); $("#a_qtss", My.ParentElement).on("click", function () { $("#xr_ls,#xr_xs,#xr_qxxs,#xr_qxss").hide(); $("#xr_qxss").show(); }); } function SumNum() { listSelectPerson = new Array(); $("i[uid][sd=1]").each(function () { var uid = $(this).attr("uid"); var uname = $(this).attr("uname"); var purl = $(this).attr("purl"); var md = new Object(); if (uid == "S0") { md.UserType = "S"; md.Id = 0; } else if (uid == "A0") { md.UserType = "A"; md.Id = 0; } else { md.UserType = "U"; md.Id = uid; } md.Name = uname; md.PhotoUrl = purl; var fg=0; if (listSelectPerson != null) { $(listSelectPerson).each(function () { if (this.Id == uid) fg = 1; }); } if(fg==0) Array.add(listSelectPerson, md); }); $("#Window_PhoneSelectUser_cmdSave_sp_num").html("【" + $("i[uid][sd=1]").length + "】"); } //#endregion //#region 初始化 function Init() { if (My.ParentElement == null) My.ParentElement = $(document.body); if ($("#" + My.ControlID, My.ParentElement).length > 0) return; var htmlString = new Sys.StringBuilder(); htmlString.append(""); My.ParentElement.append(htmlString.toString()); } //#region 显示 this.Show = function () { $("#" + My.ControlID, My.ParentElement).show(); if(My.OldDiv!=null) My.OldDiv.hide(); GetListUser(); if (My.SelectType == "All" || My.SelectType == "T") { GetListUserDept(); GetListUserT(); } else GetListUserXS(); } //#endregion //#region 绑定部门 function BindDept() { $("#" + txtDeptTitle, My.ParentElement).text("部门:"); var param = new Object(); param.SchId = My.SchId; $.ajax({ url: My.ApplicationPath + "BaseDataService.asmx/GetListDept", data: Sys.Serialization.JavaScriptSerializer.serialize(param), async: false, success: function (data) { var html = new Sys.StringBuilder(); html.append(""); $(data.d).each(function (i) { html.append(""); }); $('#' + listDeptName, My.ParentElement).html(html.toString()); } }); } //#endregion //#region 绑定组 function BindGroup() { $("#" + txtDeptTitle, My.ParentElement).text("教师组:"); $.ajax({ url: My.ApplicationPath + "BaseDataService.asmx/GetListUserGroup", async: false, success: function (data) { var html = new Sys.StringBuilder(); html.append(""); $(data.d).each(function (i) { html.append(""); }); $('#' + listDeptName, My.ParentElement).html(html.toString()); } }); } //#endregion //#region 读取用户信息 function ReadUserInfo(Persons) { var param = new Object(); param.SchId = My.SchId; param.Persons = Persons; param.Name = $("#" + txtName, My.ParentElement).val(); var url = My.ApplicationPath + "BaseDataService.asmx/GetListUserInfo"; if ($("#" + radSelectGroup, My.ParentElement)[0].checked == true) { url += "2"; param.GroupId = $("#" + listDeptName, My.ParentElement).val(); } else { param.DeptID = $("#" + listDeptName, My.ParentElement).val(); } $.ajax({ url: url, data: Sys.Serialization.JavaScriptSerializer.serialize(param), success: function (data) { var html = new Sys.StringBuilder(); $(data.d).each(function (i) { html.append(""); }); $('#' + listLeftPerson, My.ParentElement).html(html.toString()); } }); } var userlist = null; //#endregion function GetListUser() { var param = new Object(); param.SelectType =My.SelectType; $.ajax({ url: "../CenterData/CenterService.asmx/GetUser", data: Sys.Serialization.JavaScriptSerializer.serialize(param), async: false, success: function (data) { userlist = data.d; } }); } function GetListUserDept() { var shtml = new Sys.StringBuilder(); $("#ul_dept").empty(); var pname = ''; $(userlist).each(function () { if (this.UserType == 'T') { if (this.ParentName != pname) { $("#ul_dept").append("") } pname = this.ParentName; } }); $("#ul_dept").append("") } function GetListUserT() { IsT = 1; var shtml = new Sys.StringBuilder(); $("#ul_user").empty(); var ishead = false; // shtml.append('
'); shtml.append('
  •   全选
  • '); // shtml2.append('
    '); var pname = ''; var sname = $("#btn_schT").val(); var iszd = 0; $(userlist).each(function () { if (this.UserType == 'T') { if (pid >= 0) { if (sname == "" || (sname != "" && this.Name.indexOf(sname) >= 0)) { if (this.ParentId == pid) { if (ishead == false) { shtml.append('
  •   ' + this.ParentName + '
  • '); ishead = true; } var purl = "resources/imgs/user-teacher-w.jpg"; if (this.Sex == '男') purl = "resources/imgs/user-teacher-M.jpg"; if (this.PhotoUrl != null && this.PhotoUrl != "") purl = ".." + this.PhotoUrl; shtml.append('
  • '); shtml.append('  '); shtml.append('
    '); shtml.append(''); shtml.append('' + this.Name + ''); shtml.append('
    '); // shtml.append(''); shtml.append('
    '); shtml.append('
    '); shtml.append('
  • '); pname = this.ParentName; } } } else { if (sname == "" || (sname != "" && this.Name.indexOf(sname) >= 0)) { if (this.ParentName != pname) { shtml.append('
  •   ' + this.ParentName + '
  • '); } var purl = "resources/imgs/user-teacher-w.jpg"; if (this.Sex == '男') purl = "resources/imgs/user-teacher-M.jpg"; if (this.PhotoUrl != null && this.PhotoUrl != "") purl = ".." + this.PhotoUrl; shtml.append('
  • '); shtml.append('  '); shtml.append('
    '); shtml.append(''); shtml.append('' + this.Name + ''); shtml.append('
    '); // shtml.append(''); shtml.append('
    '); shtml.append('
    '); shtml.append('
  • '); pname = this.ParentName; } } } }); $("#ul_user").html(shtml.toString()); } function GetListUser2(pid) { var param = new Object(); // param.UserId = 261; var shtml = new Sys.StringBuilder(); $("#ul_user").empty(); var ishead = false; var sname = $("#btn_schT").val(); $(userlist).each(function () { if(sname==""||(sname!=""&&this.Name.indexOf(sname)>=0)) { if (this.ParentId == pid) { if (ishead == false) { shtml.append('
  •   ' + this.ParentName + '
  • '); ishead = true; } var purl = "resources/imgs/user-teacher-w.jpg"; if (this.Sex == '男') purl = "resources/imgs/user-teacher-M.jpg"; if (this.PhotoUrl != null && this.PhotoUrl != "") purl = ".." + this.PhotoUrl; shtml.append('
  • '); shtml.append('  '); shtml.append('
    '); shtml.append(''); shtml.append('' + this.Name + ''); shtml.append('
    '); // shtml.append(''); shtml.append('
    '); shtml.append('
    '); shtml.append('
  • '); pname = this.ParentName; } } }); $("#ul_user").html(shtml.toString()); } function GetListUser3() { $("#ul_user").empty(); var shtml = new Sys.StringBuilder(); shtml.append('
  •   全选
  • '); var pname = ''; $(userlist).each(function () { if (this.UserType == 'T') { if (this.ParentName != pname) { shtml.append('
  •   ' + this.ParentName + '
  • '); } var purl = "resources/imgs/user-teacher-w.jpg"; if (this.Sex == '男') purl = "resources/imgs/user-teacher-M.jpg"; if (this.PhotoUrl != null && this.PhotoUrl != "") purl = ".." + this.PhotoUrl; shtml.append('
  • '); shtml.append('  '); shtml.append('
    '); shtml.append(''); shtml.append('' + this.Name + ''); shtml.append('
    '); // shtml.append(''); shtml.append('
    '); shtml.append('
    '); shtml.append('
  • '); pname = this.ParentName; } }); $("#ul_user").html(shtml.toString()); } function GetListUserXS() { IsS = 1; var shtml2 = new Sys.StringBuilder(); var sname = $("#btn_schS").val(); var pname = ''; var iszd = 0; $(userlist).each(function () { if (this.UserType == 'S') { if(sname==""||(sname!=""&&this.Name.indexOf(sname)>=0)) { if (this.ParentName != pname) { if (pname != "") { shtml2.append('
  •   ' + this.ParentName + '
  • '); iszd = 1; } else shtml2.append('
  •   ' + this.ParentName + '
  • '); } var purl = "resources/imgs/user-girl.jpg"; if (this.Sex == '男') purl = "resources/imgs/user-boy.jpg"; if (this.PhotoUrl != null && this.PhotoUrl != "") purl = ".." + this.PhotoUrl; if (iszd == 0) { shtml2.append('
  • '); } else shtml2.append('
  • '); pname = this.ParentName; } } }); $("#ul_xs").html(shtml2.toString()); } //#region 刷新已设置人员 function RefshRightPerson() { var html = new Sys.StringBuilder(); var html2 = new Sys.StringBuilder(); $(RightPerson).each(function (i) { html.append(""); html2.append(this.Id + ","); }); var Persons = html2.toString(); if (Persons != "") Persons = Persons.substr(0, Persons.length - 1); $('#' + listRightPerson, My.ParentElement).html(html.toString()); ReadUserInfo(Persons); } //#endregion //#region 点击确定时触发 this.Save = function (handler) { EventHandler.addHandler('Save', handler); } //#endregion //#region 点击确定时触发 function OnSave() { var h = EventHandler.getHandler('Save'); if (h) h(listSelectPerson); } //#endregion }