123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620 |
- var searchGrid1=null;
- var searchGrid2=null;
- var searchGrid3=null;
- var selectedGrid=null;
- var group_tree = null;
- var groupGrid=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 = {"pageNo":1,"pageSize":10,"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);
- initGroup();
- //初始化表格
- initSelectedGrid(gridData);
- //获取第一行数据
- initSearchGrid3(gridData);
- initSearchGrid1(gridData);
- initSearchGrid2(gridData);
-
-
- search();
- orgSearch();
- /*
- * 监听
- */
- $("#search").live("click",search);
- $("#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=="999"){//如果是点击本部,则查改单位
- zTreeCompId += "|"+treeNode.parentId;
- }
- orgSearch(zTreeCompId);
- }
- function getAsyncUrl(treeId, treeNode) {
- return isAdd ? $.pathname() + "/ws/OrganizationsService/OrganizationsService/addOrgInfoById?targetOrg=" + targetOrg
- : $.pathname() + "/ws/OrganizationsService/OrganizationsService/loadSysOrgInfo2";
- }
- /*
- * 初始化表格
- */
- function initSearchGrid1(data){
- searchGrid1=$("#searchPeo").quiGrid({
- columns:[
- {display:'表格类型',name:'type',hide:true},
- {display:'用户id',name:'userId',hide:true },
- {display:'姓名', name:'userName', align:'center',width:'25%'},
- {display:'所属单位', name:'org_name', align:'center',width:'30%'},
- {display:'所属部门', name:'dept_name', align:'center',width:'25%'},
- {display:'手机号码', name:'phone', align:'center',width:'20%'},
- /* {display:'操作', isAllowHide:false,align:'center',width:'10%',
- render:function(rowdata, rowindex, value, column){
- return "<div><span class='img_add hand' style='margin-top:10px' title='添加' onclick='selectPeo("+rowindex+",1"+")'></span></div>";
-
- }
- }*/
- ],
- height:'370px',
- width:'778px',
- data:data,
- pageSize:10,
- rownumbers:true,
- percentWidthMode:true,
- onSelectRow:selectPeo,
- alternatingRow:false,
- rowAttrRender:valPeo
- });
- }
- 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:'50%'},
- {display:'所属单位', name:'org_name',hide:true},
- {display:'所属部门', name:'dept_name',hide:true},
- {display:'手机号码', name:'phone', align:'center',width:'50%'},
- /*{display:'操作', isAllowHide:false,align:'center',width:'90px',
- render:function(rowdata, rowindex, value, column){
- return "<div><span class='img_add hand' style='margin-top:10px' title='添加' onclick='selectPeo("+rowindex+",2"+")'></span></div>";
-
- }
- }*/
- ],
- height:'370px',
- width:'520px',
- data:data,
- pageSize:10,
- showPageInfo:false,
- //rownumbers:true,
- percentWidthMode:true,
- onSelectRow:selectPeo,
- alternatingRow:false,
- rowAttrRender:valPeo
- });
- }
- function initSearchGrid3(data){
- searchGrid3 = $("#group_data").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:'18%'},
- {display:'所属单位', name:'org_name',align:'center',width:'30%'},
- {display:'所属部门', name:'dept_name', align:'center',width:'25%'},
- {display:'手机号码', name:'phone', align:'center',width:'27%'},
- ],
- height:'370px',
- width:'550px',
- data:data,
- pageSize:10,
- //showPageInfo:false,
- //rownumbers:true,
- percentWidthMode:true,
- onSelectRow:selectPeo,
- alternatingRow:false,
- rowAttrRender:valPeo
- });
- getNum();
- }
- 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 initGroup(){
- var nodes = null;
- $.ajax({
- data:{"user_id":user_id},
- type:'post',
- timeout:60000,
- dataType:'json',
- url:"/nwyj/ws/newsendsms/NewSendSmsService/getGroup",
- async:false,
- success:function(result){
- nodes = result.nodes;
- },
- error:function(){
- top.Dialog.alert("获取群组数据失败!");
- }
- });
-
- //初始化树
- var setting1 = {
- view : {
- selectedMulti : false
- },
- callback: {
- onClick:getGroupData,
- }
- };
- group_tree=$.fn.zTree.init($("#group_tree"), setting1,nodes);
-
-
- }
- 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%',
- /*render:function(rowdata,rowindex,value,column){
- return "<div><span class='img_delete hand' title='删除' onclick='deletePeo("+rowindex+")'></span>"+value+"</div>";
- },*/
- },
- {display:'所属单位', name:'org_name', align:'center',width:'25%'},
- {display:'所属部门', name:'dept_name', align:'center',width:'25%'},
- {display:'手机号码', name:'phone', align:'center',width:'30%'},
- ],
- height:'370px',
- width:'390px',
- data:data,
- pageSize:5,
- rownumbers:true,
- percentWidthMode:true,
- usePager:false,
- showPageInfo:false,
- showPageSize:false,
- onSelectRow:deletePeo
- });
- }
- /*
- * 查询人员(最近联系人)
- */
- function search() {
- var name = $("#name").val();
- if(name=="请输入姓名或4A账号查询"){
- name = "";
- }
- var pattern = new RegExp("[`~!@#$^&*()=|{}:;,\\[\\]<>/?~!#¥……&*()——|{}【】‘;:”“。,、?]");
- if (pattern.test(name)) {
- top.Dialog.alert("不能输入非法字符");
- } else {
- $.ajax({
- data : {
- "user_id":user_id,
- "name" : name
- },
- type : 'post',
- dataType : 'json',
- timeout : 60000,
- url : "/nwyj/ws/newsendsms/NewSendSmsService/getRecentData",
- success : function(data) {
- initSearchGrid1(data);
- },
- error : function() {
- top.Dialog.alert('操作失败');
- }
- });
- }
- }
- /*
- * 查询人员(组织机构)
- */
- 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 getGroupData(event,treeId,JSON,number){
- var result = null;
- var treeNode = JSON;
- if(treeNode==undefined){
- var data = {"rows":[]};
- initSearchGrid3(data);
- return;
- }
- var group_id = treeNode.id;
- $.ajax({
- data:{
- "group_id":group_id
- },
- type:'post',
- timeout:60000,
- dataType:'json',
- url:"/nwyj/ws/newsendsms/NewSendSmsService/getGroupData",
- success:function(data){
- initSearchGrid3(data);
- result = data;
- },
- error:function(){
- top.Dialog.alert("获取群组人员数据失败!");
- }
- });
- getNum();
- return result;
- }
- /*
- * 不知道为什么一次点击会触发两次事件,这里这把第二次事件过滤掉
- */
- 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 selectAll(){
- var rows = searchGrid3.data.rows;
- for(var i=0;i<rows.length;i++){
- selectPeo(rows[i]);
- }
- }
- /*
- * 添加人员
- */
- 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);
- if(type==1){
- searchGrid1.loadData();
- }else if(type==2){
- searchGrid2.loadData();
- }else{
- searchGrid3.loadData();
- }
- var length=(selectedGrid.getData().length);
- $("#number").html(length+"人");
- getNum();
- }
- /*
- * 全部删除
- */
- 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").html(length+"人");
- $("#peoNum").html("0");
- }
- /*
- *删除
- */
- function deletePeo(rowdata, rowindex, rowDomElement){
- var flag = 0;
- var type = rowdata.type;
- var index = rowdata.__index;
- selectedGrid.deleteRow(index);
- var length=(selectedGrid.getData().length);
- $("#number").html(length+"人");
- if(type==1){
- flag = percolate(searchGrid1,rowdata,flag);
- if(flag==1){
- searchGrid1.loadData();
- return;
- }
- }else if(type==2){
- flag = percolate(searchGrid2,rowdata,flag);
- if(flag==1){
- searchGrid2.loadData();
- return;
- }
- }else{
- getNum();
- flag = percolate(searchGrid3,rowdata,flag);
- if(flag==1){
- searchGrid3.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();
-
- }
- function reload(){
- var temp = selectedGrid.getData();//为了分页刷新表格
- var json = "{\"pageSize\":"+10+",\"pageNo\":"+1+",\"totalRow:\":"+temp.length+",\"rows\":[";
- for(var i=0;i<temp.length;i++){
- json += "{";
- json += "\"userId\":\""+temp[i].userId+"\",";
- json += "\"userName\":\""+temp[i].userName+"\",";
- json += "\"org_name\":\""+temp[i].org_name+"\",";
- json += "\"dept_name\":\""+temp[i].dept_name+"\",";
- json += "\"phone\":\""+temp[i].phone+"\"";
- json += "},";
- }
- json = json.substr(0,json.length-1);
- json += "]}";
- initSelectedGrid(JSON.parse(json));
- }
- /*
- * 更新群组
- */
- function updateGroup(rowindex){
- var iframeHeight = $(window.document.body).height();
- $(top.document.body).find("#frmright").height(iframeHeight+30);
- var diag = new parent.Dialog();
- var rowdata = null;
- //短信管理按新增按钮时跳转地址
- var url = '/nwyj/page/system/sms/updateGroup.html';
- if(rowindex==undefined||rowindex==null){
- diag.Title = "添加群组";
- }else{
- diag.Title = "修改群组";
- rowdata = groupGrid.getRow(rowindex);
- url = '/nwyj/page/system/sms/updateGroup.html?'+rowdata.group_id+"?"+rowdata.group_name;
- }
- diag.URL = encodeURI(url);
- diag.Top = "25%";
- diag.ID="updateGroup";
- diag.Height = 450;
- diag.Width = 1000;
- diag.Left = "50%";
- diag.ShowOkButton=false;// 不显示确认按钮
- diag.ShowCancelButton=false;// 不显示取消按钮
- diag.ButtonAlign = 'center';
- diag.show();
-
- diag.addButton("close","取消",function(){
- diag.innerFrame.contentWindow.cancle();
- $(top.document.body).find("#frmright").height(iframeHeight+30);
- });
-
- diag.addButton("add","确定",function(){
- if(rowindex==undefined||rowindex==null){
- diag.innerFrame.contentWindow.saveGroupData();
- }else{
- diag.innerFrame.contentWindow.updateGroupData(rowdata.group_id);
- }
- $(top.document.body).find("#frmright").height(iframeHeight+30);
- reloadGroup();
- });
-
- }
- /*
- * 删除群组
- */
- function deleteGroup(rowindex){
- var rowdata = groupGrid.getRow(rowindex);
- var group_id = rowdata.group_id;
- var group_name = rowdata.group_name;
- top.Dialog.confirm("确定要删除"+group_name+"吗?",function(){
- $.ajax({
- data:{"group_id":group_id},
- type:'post',
- timeout:60000,
- dataType:'json',
- url:"/nwyj/ws/newsendsms/NewSendSmsService/deleteGroup",
- async:false,
- success:function(result){
- if(result.Msg.info=="success"){
- top.Dialog.alert("删除"+group_name+"成功!");
- }
- reloadGroup();
- },
- error:function(){
- top.Dialog.alert("删除"+group_name+"失败!");
- }
- });
- });
-
- }
- /*
- * 重新加载群组数据
- */
- function reloadGroup(){
- initGroup();
- // 获取第一行数据
- var firstRow = getGroupData(0);
- initSearchGrid3(firstRow);
- }
- function getNum(){
- var num = 0;
- var list = group_tree.getSelectedNodes();
- var rows = selectedGrid.data.rows;
- var group_rows = searchGrid3.data.rows;
- for(var i=0;i<group_rows.length;i++){
- for(var j=0;j<rows.length;j++){
- if(group_rows[i].userId==rows[j].userId){
- num++;
- }
- }
- }
- if(list.length>0){
- $("#group_name").html(list[0].name);
- $("#peoNum").html(num);
- }
- }
|