123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308 |
- var searchGrid2=null;
- var selectedGrid=null;
- var temp_dept_id = null;
- var user_id=top.com.sinosoft.lz.system.user.LoginInfo.getUser_id();
- var CorpArea = top.com.sinosoft.lz.system.user.LoginInfo.getCorp_ids();
- var initDept_id=top.com.sinosoft.lz.system.user.LoginInfo.getDept_id();
- var isAdd = false;
- var loadCorp = "";
- var setloadtype_in=["deptId", CorpArea,"type","","loadCorp",loadCorp,"deptLevel",getDeptLevel2(CorpArea)];
- var setting;
- var gridData = {"rows" : []};//用于表格初始化
- $(function(){
- //初始化树
- setting = {
- view : {
- selectedMulti : false
- },
- async : {
- enable : true,
- dataType : 'JSON',
- dataName : 'treeNodes',
- aysnc : false,
- url : getAsyncUrl ,
- autoParam : [ "id", "name", "orgLevel" ],
- otherParam : setloadtype_in
- },
- callback: {
- onClick:zTreeSelect,
- }
- };
- $.fn.zTree.init($("#treeDept-gzfw"), setting);
- //初始化表格
- initSelectedGrid(gridData);
- //获取第一行数据
- initSearchGrid2(gridData);
-
-
- orgSearch();
- /*
- * 监听
- */
- $("#search_name").live("click",nameSearch);
- $("#deleteAll").live("click",deleteAll);
-
- });
- function getDeptLevel2(dpids){
- var dept_level = "";
- $.ajax({
- url : $.pathname()+ "/ws/planService/PlanService/getDeptLevel",
- type : 'post',
- timeout : 60000,
- data : {id:dpids},
- dataType : 'text',
- async: false,
- success : function(data){
- dept_level = data;
- }
- });
- return dept_level;
- }
- function zTreeSelect(event,treeId,treeNode) {
- zTreeCompId = treeNode.id;
- if(zTreeCompId=="benbu999"){//如果是点击本部,则查改单位
- zTreeCompId += "|"+treeNode.parentId;
- }
- orgSearch(zTreeCompId);
- }
- function getAsyncUrl(treeId, treeNode) {
- return isAdd ? $.pathname() + "/ws/OrganizationsService/OrganizationsService/addOrgInfoById?targetOrg=" + targetOrg
- : $.pathname() + "/ws/OrganizationsService/OrganizationsService/loadSysOrgInfo2";
- }
- function initSearchGrid2(data){
- searchGrid2 = $("#search_result").quiGrid({
- columns:[
- {display:'表格类型',name:'type',hide:true},
- {display:'用户id',name:'userId',hide:true },
- {display:'姓名', name:'userName', align:'center',width:'20%',showTitle:true},
- {display:'所属单位', name:'org_name',width:'20%',showTitle:true},
- {display:'所属部门', name:'dept_name',width:'27%',showTitle:true},
- {display:'手机号码', name:'phone', align:'center',width:'33%',showTitle:true}
- ],
- height:'370px',
- width:'520px',
- data:data,
- pageSize:10,
- showPageInfo:false,
- //rownumbers:true,
- percentWidthMode:true,
- onSelectRow:selectPeo,
- alternatingRow:false,
- rowAttrRender:valPeo
- });
- }
- function valPeo(rowdata,rowid){
- var rows = selectedGrid.getData();
- for(var i=0;i<rows.length;i++){
- if(rows[i].userId==rowdata.userId){
- return "style='background-color:#ebfb69;' title='该人选已被选定'" ;
- }
- }
- }
- function initSelectedGrid(data){
- selectedGrid=$("#selectedPeo").quiGrid({
- columns:[
- {display:'群组id',name:'group_id',hide:true},
- {display:'表格类型',name:'type',hide:true},
- {display:'用户id',name:'userId',hide:true },
- {display:'姓名', name:'userName', align:'center',width:'20%',showTitle:true},
- {display:'所属单位', name:'org_name', align:'center',width:'20%',showTitle:true},
- {display:'所属部门', name:'dept_name', align:'center',width:'27%',showTitle:true},
- {display:'手机号码', name:'phone', align:'left',width:'33%',showTitle:true}
- ],
- height:'370px',
- width:'390px',
- data:data,
- pageSize:5,
- rownumbers:true,
- percentWidthMode:true,
- usePager:false,
- showPageInfo:false,
- showPageSize:false,
- onSelectRow:deletePeo
- });
- }
- /*
- * 查询人员(组织机构)
- */
- function orgSearch(zTreeCompId){
- if((zTreeCompId== undefined||zTreeCompId=="")&&(temp_dept_id==null)||(temp_dept_id=="")){
- temp_dept_id = initDept_id;//贵州电网公司
- }else if(((temp_dept_id!=null)&&(temp_dept_id!=""))&&(zTreeCompId!=undefined&&zTreeCompId!="")){//点击组织机构
- temp_dept_id = zTreeCompId;
- }
- $.ajax({
- data:{
- "dept_id":temp_dept_id
- },
- type:'post',
- timeout:60000,
- dataType:'json',
- url:"/nwyj/ws/newsendsms/NewSendSmsService/getOrgData",
- success:function(result){
- initSearchGrid2(result);
- },
- error:function(){
- top.Dialog.alert("根据组织结构查询人员失败!");
- }
- });
- }
- /*
- * 根据姓名或者账号查询人员
- */
- function nameSearch(){
- var name = $("#name_org").val();
- var pattern = new RegExp("[`~!#$^&*()=|{}:;,\\[\\]<>/?~!#¥……&*()——|{}【】‘;:”“。,、?]");
- if (pattern.test(name)) {
- top.Dialog.alert("不能输入非法字符");
- return;
- }
- if(name=="请输入姓名或4A账号查询"){
- top.Dialog.alert("请输入姓名或4A账号!");
- return;
- }
- $.ajax({
- data:{
- "name":name
- },
- type:'post',
- timeout:60000,
- dataType:'json',
- url:"/nwyj/ws/newsendsms/NewSendSmsService/getNameData",
- success:function(result){
- initSearchGrid2(result);
- },
- error:function(){
- top.Dialog.alert("根据组织结构查询人员失败!");
- }
- });
- }
- /*
- * 不知道为什么一次点击会触发两次事件,这里这把第二次事件过滤掉
- */
- function percolate(grid,rowdata,flag){
- var gridData = grid.getData();
- for(var i=0;i<gridData.length;i++){
- if(rowdata.userId==gridData[i].userId){
- flag = 1 ;
- break;
- }
- }
- return flag;
- }
- /*
- * 添加人员
- */
- function selectPeo(rowdata, rowindex, rowDomElement){
- var flag = 0;
- var type = rowdata.type;
- var selData ={
- "type":type,
- "group_id":rowdata.group_id,
- "userId":rowdata.userId,
- "userName":rowdata.userName,
- "org_name":rowdata.org_name,
- "dept_name":rowdata.dept_name,
- "phone":rowdata.phone
- };
-
- flag = percolate(selectedGrid,rowdata,flag);
- if(flag==1){
- return;
- }
- var first = selectedGrid.getRow(0);
- selectedGrid.addRow(selData,first,true);
- searchGrid2.loadData();
- var length=(selectedGrid.getData().length);
- $("#number").val(length);
- }
- /*
- * 全部删除
- */
- function deleteAll(){
- var rows = selectedGrid.getData();
- for(var i=rows.length-1;i>-1;i--){
- selectedGrid.deleteRow(i);
- }
- for(var i=rows.length-1;i>-1;i--){
- var rowdata = rows[i];
- deletePeo(rowdata,null,null);
- }
- var length=(selectedGrid.getData().length);
- $("#number").val(length);
- }
- /*
- *删除
- */
- function deletePeo(rowdata, rowindex, rowDomElement){
- var flag = 0;
- var index = rowdata.__index;
- selectedGrid.deleteRow(index);
- var length=(selectedGrid.getData().length);
- $("#number").val(length);
- flag = percolate(searchGrid2,rowdata,flag);
- if(flag==1){
- searchGrid2.loadData();
- return;
- }
-
-
- }
- /*
- * 取消
- */
- function cancle(){
- top.Dialog.confirm("确定不选择人员?",function(){
- $(parent.document.body).find("#frmrightChild").height($(window.document.body).height()+30);
- $(top.document.body).find("#frmright").height($(parent.document.body).height()+30);
- top.Dialog.close();
- });
- }
- /*
- *选择人员
- */
- function getSelectPeople(){
- var rows = selectedGrid.getData();
- var grid = top.frmright.grid;
- for(var i=0;i<rows.length;i++){
- var row={
- "userId":rows[i].userId,
- "userName" : rows[i].userName,
- "org_name" : rows[i].org_name,
- "dept_name" : rows[i].dept_name,
- "phone" : rows[i].phone
- };
- var data =grid.getData();
- /**
- * 看表格里是否已经有本条数据
- */
- for(var j=0 ;j<data.length;j++){
- if(data[j].userId==rows[i].userId){
- top.Dialog.alert("您要选着的第"+i+"行的"+rows[i].userName+"已经在表中,请先删除");
- return;
- };
- }
- top.frmright.addData(row);
- }
- top.Dialog.close();
-
- }
|