2ddf017c904880b265e01dde7b4fe5c86cc70df5.svn-base 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620
  1. var searchGrid1=null;
  2. var searchGrid2=null;
  3. var searchGrid3=null;
  4. var selectedGrid=null;
  5. var group_tree = null;
  6. var groupGrid=null;
  7. var temp_dept_id = null;
  8. var user_id=top.com.sinosoft.lz.system.user.LoginInfo.getUser_id();
  9. var CorpArea = top.com.sinosoft.lz.system.user.LoginInfo.getCorp_ids();
  10. var initDept_id=top.com.sinosoft.lz.system.user.LoginInfo.getDept_id();
  11. var isAdd = false;
  12. var loadCorp = "";
  13. var setloadtype_in=["deptId", CorpArea,"type","","loadCorp",loadCorp,"deptLevel",getDeptLevel2(CorpArea)];
  14. var setting;
  15. var gridData = {"pageNo":1,"pageSize":10,"rows" : []};//用于表格初始化
  16. $(function(){
  17. //初始化树
  18. setting = {
  19. view : {
  20. selectedMulti : false
  21. },
  22. async : {
  23. enable : true,
  24. dataType : 'JSON',
  25. dataName : 'treeNodes',
  26. aysnc : false,
  27. url : getAsyncUrl ,
  28. autoParam : [ "id", "name", "orgLevel" ],
  29. otherParam : setloadtype_in
  30. },
  31. callback: {
  32. onClick:zTreeSelect,
  33. }
  34. };
  35. $.fn.zTree.init($("#treeDept-gzfw"), setting);
  36. initGroup();
  37. //初始化表格
  38. initSelectedGrid(gridData);
  39. //获取第一行数据
  40. initSearchGrid3(gridData);
  41. initSearchGrid1(gridData);
  42. initSearchGrid2(gridData);
  43. search();
  44. orgSearch();
  45. /*
  46. * 监听
  47. */
  48. $("#search").live("click",search);
  49. $("#search_name").live("click",nameSearch);
  50. $("#deleteAll").live("click",deleteAll);
  51. });
  52. function getDeptLevel2(dpids){
  53. var dept_level = "";
  54. $.ajax({
  55. url : $.pathname()+ "/ws/planService/PlanService/getDeptLevel",
  56. type : 'post',
  57. timeout : 60000,
  58. data : {id:dpids},
  59. dataType : 'text',
  60. async: false,
  61. success : function(data){
  62. dept_level = data;
  63. }
  64. });
  65. return dept_level;
  66. }
  67. function zTreeSelect(event,treeId,treeNode) {
  68. zTreeCompId = treeNode.id;
  69. if(zTreeCompId=="999"){//如果是点击本部,则查改单位
  70. zTreeCompId += "|"+treeNode.parentId;
  71. }
  72. orgSearch(zTreeCompId);
  73. }
  74. function getAsyncUrl(treeId, treeNode) {
  75. return isAdd ? $.pathname() + "/ws/OrganizationsService/OrganizationsService/addOrgInfoById?targetOrg=" + targetOrg
  76. : $.pathname() + "/ws/OrganizationsService/OrganizationsService/loadSysOrgInfo2";
  77. }
  78. /*
  79. * 初始化表格
  80. */
  81. function initSearchGrid1(data){
  82. searchGrid1=$("#searchPeo").quiGrid({
  83. columns:[
  84. {display:'表格类型',name:'type',hide:true},
  85. {display:'用户id',name:'userId',hide:true },
  86. {display:'姓名', name:'userName', align:'center',width:'25%'},
  87. {display:'所属单位', name:'org_name', align:'center',width:'30%'},
  88. {display:'所属部门', name:'dept_name', align:'center',width:'25%'},
  89. {display:'手机号码', name:'phone', align:'center',width:'20%'},
  90. /* {display:'操作', isAllowHide:false,align:'center',width:'10%',
  91. render:function(rowdata, rowindex, value, column){
  92. return "<div><span class='img_add hand' style='margin-top:10px' title='添加' onclick='selectPeo("+rowindex+",1"+")'></span></div>";
  93. }
  94. }*/
  95. ],
  96. height:'370px',
  97. width:'778px',
  98. data:data,
  99. pageSize:10,
  100. rownumbers:true,
  101. percentWidthMode:true,
  102. onSelectRow:selectPeo,
  103. alternatingRow:false,
  104. rowAttrRender:valPeo
  105. });
  106. }
  107. function initSearchGrid2(data){
  108. searchGrid2 = $("#search_result").quiGrid({
  109. columns:[
  110. {display:'表格类型',name:'type',hide:true},
  111. {display:'用户id',name:'userId',hide:true },
  112. {display:'姓名', name:'userName', align:'center',width:'50%'},
  113. {display:'所属单位', name:'org_name',hide:true},
  114. {display:'所属部门', name:'dept_name',hide:true},
  115. {display:'手机号码', name:'phone', align:'center',width:'50%'},
  116. /*{display:'操作', isAllowHide:false,align:'center',width:'90px',
  117. render:function(rowdata, rowindex, value, column){
  118. return "<div><span class='img_add hand' style='margin-top:10px' title='添加' onclick='selectPeo("+rowindex+",2"+")'></span></div>";
  119. }
  120. }*/
  121. ],
  122. height:'370px',
  123. width:'520px',
  124. data:data,
  125. pageSize:10,
  126. showPageInfo:false,
  127. //rownumbers:true,
  128. percentWidthMode:true,
  129. onSelectRow:selectPeo,
  130. alternatingRow:false,
  131. rowAttrRender:valPeo
  132. });
  133. }
  134. function initSearchGrid3(data){
  135. searchGrid3 = $("#group_data").quiGrid({
  136. columns:[
  137. {display:'群组id',name:'group_id',hide:true},
  138. {display:'表格类型',name:'type',hide:true},
  139. {display:'用户id',name:'userId',hide:true },
  140. {display:'姓名', name:'userName', align:'center',width:'18%'},
  141. {display:'所属单位', name:'org_name',align:'center',width:'30%'},
  142. {display:'所属部门', name:'dept_name', align:'center',width:'25%'},
  143. {display:'手机号码', name:'phone', align:'center',width:'27%'},
  144. ],
  145. height:'370px',
  146. width:'550px',
  147. data:data,
  148. pageSize:10,
  149. //showPageInfo:false,
  150. //rownumbers:true,
  151. percentWidthMode:true,
  152. onSelectRow:selectPeo,
  153. alternatingRow:false,
  154. rowAttrRender:valPeo
  155. });
  156. getNum();
  157. }
  158. function valPeo(rowdata,rowid){
  159. var rows = selectedGrid.getData();
  160. for(var i=0;i<rows.length;i++){
  161. if(rows[i].userId==rowdata.userId){
  162. return "style='background-color:#ebfb69;' title='该人选已被选定'" ;
  163. }
  164. }
  165. }
  166. function initGroup(){
  167. var nodes = null;
  168. $.ajax({
  169. data:{"user_id":user_id},
  170. type:'post',
  171. timeout:60000,
  172. dataType:'json',
  173. url:"/nwyj/ws/newsendsms/NewSendSmsService/getGroup",
  174. async:false,
  175. success:function(result){
  176. nodes = result.nodes;
  177. },
  178. error:function(){
  179. top.Dialog.alert("获取群组数据失败!");
  180. }
  181. });
  182. //初始化树
  183. var setting1 = {
  184. view : {
  185. selectedMulti : false
  186. },
  187. callback: {
  188. onClick:getGroupData,
  189. }
  190. };
  191. group_tree=$.fn.zTree.init($("#group_tree"), setting1,nodes);
  192. }
  193. function initSelectedGrid(data){
  194. selectedGrid=$("#selectedPeo").quiGrid({
  195. columns:[
  196. {display:'群组id',name:'group_id',hide:true},
  197. {display:'表格类型',name:'type',hide:true},
  198. {display:'用户id',name:'userId',hide:true },
  199. {display:'姓名', name:'userName', align:'center',width:'20%',
  200. /*render:function(rowdata,rowindex,value,column){
  201. return "<div><span class='img_delete hand' title='删除' onclick='deletePeo("+rowindex+")'></span>"+value+"</div>";
  202. },*/
  203. },
  204. {display:'所属单位', name:'org_name', align:'center',width:'25%'},
  205. {display:'所属部门', name:'dept_name', align:'center',width:'25%'},
  206. {display:'手机号码', name:'phone', align:'center',width:'30%'},
  207. ],
  208. height:'370px',
  209. width:'390px',
  210. data:data,
  211. pageSize:5,
  212. rownumbers:true,
  213. percentWidthMode:true,
  214. usePager:false,
  215. showPageInfo:false,
  216. showPageSize:false,
  217. onSelectRow:deletePeo
  218. });
  219. }
  220. /*
  221. * 查询人员(最近联系人)
  222. */
  223. function search() {
  224. var name = $("#name").val();
  225. if(name=="请输入姓名或4A账号查询"){
  226. name = "";
  227. }
  228. var pattern = new RegExp("[`~!@#$^&*()=|{}:;,\\[\\]<>/?~!#¥……&*()——|{}【】‘;:”“。,、?]");
  229. if (pattern.test(name)) {
  230. top.Dialog.alert("不能输入非法字符");
  231. } else {
  232. $.ajax({
  233. data : {
  234. "user_id":user_id,
  235. "name" : name
  236. },
  237. type : 'post',
  238. dataType : 'json',
  239. timeout : 60000,
  240. url : "/nwyj/ws/newsendsms/NewSendSmsService/getRecentData",
  241. success : function(data) {
  242. initSearchGrid1(data);
  243. },
  244. error : function() {
  245. top.Dialog.alert('操作失败');
  246. }
  247. });
  248. }
  249. }
  250. /*
  251. * 查询人员(组织机构)
  252. */
  253. function orgSearch(zTreeCompId){
  254. if((zTreeCompId== undefined||zTreeCompId=="")&&(temp_dept_id==null)||(temp_dept_id=="")){
  255. temp_dept_id = initDept_id;//贵州电网公司
  256. }else if(((temp_dept_id!=null)&&(temp_dept_id!=""))&&(zTreeCompId!=undefined&&zTreeCompId!="")){//点击组织机构
  257. temp_dept_id = zTreeCompId;
  258. }
  259. $.ajax({
  260. data:{
  261. "dept_id":temp_dept_id
  262. },
  263. type:'post',
  264. timeout:60000,
  265. dataType:'json',
  266. url:"/nwyj/ws/newsendsms/NewSendSmsService/getOrgData",
  267. success:function(result){
  268. initSearchGrid2(result);
  269. },
  270. error:function(){
  271. top.Dialog.alert("根据组织结构查询人员失败!");
  272. }
  273. });
  274. }
  275. /*
  276. * 根据姓名或者账号查询人员
  277. */
  278. function nameSearch(){
  279. var name = $("#name_org").val();
  280. var pattern = new RegExp("[`~!@#$^&*()=|{}:;,\\[\\]<>/?~!#¥……&*()——|{}【】‘;:”“。,、?]");
  281. if (pattern.test(name)) {
  282. top.Dialog.alert("不能输入非法字符");
  283. return;
  284. }
  285. if(name=="请输入姓名或4A账号查询"){
  286. top.Dialog.alert("请输入姓名或4A账号!");
  287. return;
  288. }
  289. $.ajax({
  290. data:{
  291. "name":name
  292. },
  293. type:'post',
  294. timeout:60000,
  295. dataType:'json',
  296. url:"/nwyj/ws/newsendsms/NewSendSmsService/getNameData",
  297. success:function(result){
  298. initSearchGrid2(result);
  299. },
  300. error:function(){
  301. top.Dialog.alert("根据组织结构查询人员失败!");
  302. }
  303. });
  304. }
  305. /*
  306. * 查询群组人员
  307. */
  308. function getGroupData(event,treeId,JSON,number){
  309. var result = null;
  310. var treeNode = JSON;
  311. if(treeNode==undefined){
  312. var data = {"rows":[]};
  313. initSearchGrid3(data);
  314. return;
  315. }
  316. var group_id = treeNode.id;
  317. $.ajax({
  318. data:{
  319. "group_id":group_id
  320. },
  321. type:'post',
  322. timeout:60000,
  323. dataType:'json',
  324. url:"/nwyj/ws/newsendsms/NewSendSmsService/getGroupData",
  325. success:function(data){
  326. initSearchGrid3(data);
  327. result = data;
  328. },
  329. error:function(){
  330. top.Dialog.alert("获取群组人员数据失败!");
  331. }
  332. });
  333. getNum();
  334. return result;
  335. }
  336. /*
  337. * 不知道为什么一次点击会触发两次事件,这里这把第二次事件过滤掉
  338. */
  339. function percolate(grid,rowdata,flag){
  340. var gridData = grid.getData();
  341. for(var i=0;i<gridData.length;i++){
  342. if(rowdata.userId==gridData[i].userId){
  343. flag = 1 ;
  344. break;
  345. }
  346. }
  347. return flag;
  348. }
  349. /*
  350. * 全部添加
  351. */
  352. function selectAll(){
  353. var rows = searchGrid3.data.rows;
  354. for(var i=0;i<rows.length;i++){
  355. selectPeo(rows[i]);
  356. }
  357. }
  358. /*
  359. * 添加人员
  360. */
  361. function selectPeo(rowdata, rowindex, rowDomElement){
  362. var flag = 0;
  363. var type = rowdata.type;
  364. var selData ={
  365. "type":type,
  366. "group_id":rowdata.group_id,
  367. "userId":rowdata.userId,
  368. "userName":rowdata.userName,
  369. "org_name":rowdata.org_name,
  370. "dept_name":rowdata.dept_name,
  371. "phone":rowdata.phone
  372. };
  373. flag = percolate(selectedGrid,rowdata,flag);
  374. if(flag==1){
  375. return;
  376. }
  377. var first = selectedGrid.getRow(0);
  378. selectedGrid.addRow(selData,first,true);
  379. if(type==1){
  380. searchGrid1.loadData();
  381. }else if(type==2){
  382. searchGrid2.loadData();
  383. }else{
  384. searchGrid3.loadData();
  385. }
  386. var length=(selectedGrid.getData().length);
  387. $("#number").html(length+"人");
  388. getNum();
  389. }
  390. /*
  391. * 全部删除
  392. */
  393. function deleteAll(){
  394. var rows = selectedGrid.getData();
  395. for(var i=rows.length-1;i>-1;i--){
  396. selectedGrid.deleteRow(i);
  397. }
  398. for(var i=rows.length-1;i>-1;i--){
  399. var rowdata = rows[i];
  400. deletePeo(rowdata,null,null);
  401. }
  402. var length=(selectedGrid.getData().length);
  403. $("#number").html(length+"人");
  404. $("#peoNum").html("0");
  405. }
  406. /*
  407. *删除
  408. */
  409. function deletePeo(rowdata, rowindex, rowDomElement){
  410. var flag = 0;
  411. var type = rowdata.type;
  412. var index = rowdata.__index;
  413. selectedGrid.deleteRow(index);
  414. var length=(selectedGrid.getData().length);
  415. $("#number").html(length+"人");
  416. if(type==1){
  417. flag = percolate(searchGrid1,rowdata,flag);
  418. if(flag==1){
  419. searchGrid1.loadData();
  420. return;
  421. }
  422. }else if(type==2){
  423. flag = percolate(searchGrid2,rowdata,flag);
  424. if(flag==1){
  425. searchGrid2.loadData();
  426. return;
  427. }
  428. }else{
  429. getNum();
  430. flag = percolate(searchGrid3,rowdata,flag);
  431. if(flag==1){
  432. searchGrid3.loadData();
  433. return;
  434. }
  435. }
  436. }
  437. /*
  438. * 取消
  439. */
  440. function cancle(){
  441. top.Dialog.confirm("确定不选择人员?",function(){
  442. $(parent.document.body).find("#frmrightChild").height($(window.document.body).height()+30);
  443. $(top.document.body).find("#frmright").height($(parent.document.body).height()+30);
  444. top.Dialog.close();
  445. });
  446. }
  447. /*
  448. *选择人员
  449. */
  450. function getSelectPeople(){
  451. var rows = selectedGrid.getData();
  452. var grid = top.frmright.grid;
  453. for(var i=0;i<rows.length;i++){
  454. var row={
  455. "userId":rows[i].userId,
  456. "userName" : rows[i].userName,
  457. "org_name" : rows[i].org_name,
  458. "dept_name" : rows[i].dept_name,
  459. "phone" : rows[i].phone
  460. };
  461. var data =grid.getData();
  462. /**
  463. * 看表格里是否已经有本条数据
  464. */
  465. for(var j=0 ;j<data.length;j++){
  466. if(data[j].userId==rows[i].userId){
  467. top.Dialog.alert("您要选着的第"+i+"行的"+rows[i].userName+"已经在表中,请先删除");
  468. return;
  469. };
  470. }
  471. top.frmright.addData(row);
  472. }
  473. top.Dialog.close();
  474. }
  475. function reload(){
  476. var temp = selectedGrid.getData();//为了分页刷新表格
  477. var json = "{\"pageSize\":"+10+",\"pageNo\":"+1+",\"totalRow:\":"+temp.length+",\"rows\":[";
  478. for(var i=0;i<temp.length;i++){
  479. json += "{";
  480. json += "\"userId\":\""+temp[i].userId+"\",";
  481. json += "\"userName\":\""+temp[i].userName+"\",";
  482. json += "\"org_name\":\""+temp[i].org_name+"\",";
  483. json += "\"dept_name\":\""+temp[i].dept_name+"\",";
  484. json += "\"phone\":\""+temp[i].phone+"\"";
  485. json += "},";
  486. }
  487. json = json.substr(0,json.length-1);
  488. json += "]}";
  489. initSelectedGrid(JSON.parse(json));
  490. }
  491. /*
  492. * 更新群组
  493. */
  494. function updateGroup(rowindex){
  495. var iframeHeight = $(window.document.body).height();
  496. $(top.document.body).find("#frmright").height(iframeHeight+30);
  497. var diag = new parent.Dialog();
  498. var rowdata = null;
  499. //短信管理按新增按钮时跳转地址
  500. var url = '/nwyj/page/system/sms/updateGroup.html';
  501. if(rowindex==undefined||rowindex==null){
  502. diag.Title = "添加群组";
  503. }else{
  504. diag.Title = "修改群组";
  505. rowdata = groupGrid.getRow(rowindex);
  506. url = '/nwyj/page/system/sms/updateGroup.html?'+rowdata.group_id+"?"+rowdata.group_name;
  507. }
  508. diag.URL = encodeURI(url);
  509. diag.Top = "25%";
  510. diag.ID="updateGroup";
  511. diag.Height = 450;
  512. diag.Width = 1000;
  513. diag.Left = "50%";
  514. diag.ShowOkButton=false;// 不显示确认按钮
  515. diag.ShowCancelButton=false;// 不显示取消按钮
  516. diag.ButtonAlign = 'center';
  517. diag.show();
  518. diag.addButton("close","取消",function(){
  519. diag.innerFrame.contentWindow.cancle();
  520. $(top.document.body).find("#frmright").height(iframeHeight+30);
  521. });
  522. diag.addButton("add","确定",function(){
  523. if(rowindex==undefined||rowindex==null){
  524. diag.innerFrame.contentWindow.saveGroupData();
  525. }else{
  526. diag.innerFrame.contentWindow.updateGroupData(rowdata.group_id);
  527. }
  528. $(top.document.body).find("#frmright").height(iframeHeight+30);
  529. reloadGroup();
  530. });
  531. }
  532. /*
  533. * 删除群组
  534. */
  535. function deleteGroup(rowindex){
  536. var rowdata = groupGrid.getRow(rowindex);
  537. var group_id = rowdata.group_id;
  538. var group_name = rowdata.group_name;
  539. top.Dialog.confirm("确定要删除"+group_name+"吗?",function(){
  540. $.ajax({
  541. data:{"group_id":group_id},
  542. type:'post',
  543. timeout:60000,
  544. dataType:'json',
  545. url:"/nwyj/ws/newsendsms/NewSendSmsService/deleteGroup",
  546. async:false,
  547. success:function(result){
  548. if(result.Msg.info=="success"){
  549. top.Dialog.alert("删除"+group_name+"成功!");
  550. }
  551. reloadGroup();
  552. },
  553. error:function(){
  554. top.Dialog.alert("删除"+group_name+"失败!");
  555. }
  556. });
  557. });
  558. }
  559. /*
  560. * 重新加载群组数据
  561. */
  562. function reloadGroup(){
  563. initGroup();
  564. // 获取第一行数据
  565. var firstRow = getGroupData(0);
  566. initSearchGrid3(firstRow);
  567. }
  568. function getNum(){
  569. var num = 0;
  570. var list = group_tree.getSelectedNodes();
  571. var rows = selectedGrid.data.rows;
  572. var group_rows = searchGrid3.data.rows;
  573. for(var i=0;i<group_rows.length;i++){
  574. for(var j=0;j<rows.length;j++){
  575. if(group_rows[i].userId==rows[j].userId){
  576. num++;
  577. }
  578. }
  579. }
  580. if(list.length>0){
  581. $("#group_name").html(list[0].name);
  582. $("#peoNum").html(num);
  583. }
  584. }