c03d6cc4913f58c1a142ac783b4fb7300bce09ef.svn-base 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  1. var searchGrid2=null;
  2. var selectedGrid=null;
  3. var temp_dept_id = null;
  4. var user_id=top.com.sinosoft.lz.system.user.LoginInfo.getUser_id();
  5. var CorpArea = top.com.sinosoft.lz.system.user.LoginInfo.getCorp_ids();
  6. var initDept_id=top.com.sinosoft.lz.system.user.LoginInfo.getDept_id();
  7. var isAdd = false;
  8. var loadCorp = "";
  9. var setloadtype_in=["deptId", CorpArea,"type","","loadCorp",loadCorp,"deptLevel",getDeptLevel2(CorpArea)];
  10. var setting;
  11. var gridData = {"rows" : []};//用于表格初始化
  12. $(function(){
  13. //初始化树
  14. setting = {
  15. view : {
  16. selectedMulti : false
  17. },
  18. async : {
  19. enable : true,
  20. dataType : 'JSON',
  21. dataName : 'treeNodes',
  22. aysnc : false,
  23. url : getAsyncUrl ,
  24. autoParam : [ "id", "name", "orgLevel" ],
  25. otherParam : setloadtype_in
  26. },
  27. callback: {
  28. onClick:zTreeSelect,
  29. }
  30. };
  31. $.fn.zTree.init($("#treeDept-gzfw"), setting);
  32. //初始化表格
  33. initSelectedGrid(gridData);
  34. //获取第一行数据
  35. initSearchGrid2(gridData);
  36. orgSearch();
  37. /*
  38. * 监听
  39. */
  40. $("#search_name").live("click",nameSearch);
  41. $("#deleteAll").live("click",deleteAll);
  42. });
  43. function getDeptLevel2(dpids){
  44. var dept_level = "";
  45. $.ajax({
  46. url : $.pathname()+ "/ws/planService/PlanService/getDeptLevel",
  47. type : 'post',
  48. timeout : 60000,
  49. data : {id:dpids},
  50. dataType : 'text',
  51. async: false,
  52. success : function(data){
  53. dept_level = data;
  54. }
  55. });
  56. return dept_level;
  57. }
  58. function zTreeSelect(event,treeId,treeNode) {
  59. zTreeCompId = treeNode.id;
  60. if(zTreeCompId=="benbu999"){//如果是点击本部,则查改单位
  61. zTreeCompId += "|"+treeNode.parentId;
  62. }
  63. orgSearch(zTreeCompId);
  64. }
  65. function getAsyncUrl(treeId, treeNode) {
  66. return isAdd ? $.pathname() + "/ws/OrganizationsService/OrganizationsService/addOrgInfoById?targetOrg=" + targetOrg
  67. : $.pathname() + "/ws/OrganizationsService/OrganizationsService/loadSysOrgInfo2";
  68. }
  69. function initSearchGrid2(data){
  70. searchGrid2 = $("#search_result").quiGrid({
  71. columns:[
  72. {display:'表格类型',name:'type',hide:true},
  73. {display:'用户id',name:'userId',hide:true },
  74. {display:'姓名', name:'userName', align:'center',width:'20%',showTitle:true},
  75. {display:'所属单位', name:'org_name',width:'20%',showTitle:true},
  76. {display:'所属部门', name:'dept_name',width:'27%',showTitle:true},
  77. {display:'手机号码', name:'phone', align:'center',width:'33%',showTitle:true}
  78. ],
  79. height:'370px',
  80. width:'520px',
  81. data:data,
  82. pageSize:10,
  83. showPageInfo:false,
  84. //rownumbers:true,
  85. percentWidthMode:true,
  86. onSelectRow:selectPeo,
  87. alternatingRow:false,
  88. rowAttrRender:valPeo
  89. });
  90. }
  91. function valPeo(rowdata,rowid){
  92. var rows = selectedGrid.getData();
  93. for(var i=0;i<rows.length;i++){
  94. if(rows[i].userId==rowdata.userId){
  95. return "style='background-color:#ebfb69;' title='该人选已被选定'" ;
  96. }
  97. }
  98. }
  99. function initSelectedGrid(data){
  100. selectedGrid=$("#selectedPeo").quiGrid({
  101. columns:[
  102. {display:'群组id',name:'group_id',hide:true},
  103. {display:'表格类型',name:'type',hide:true},
  104. {display:'用户id',name:'userId',hide:true },
  105. {display:'姓名', name:'userName', align:'center',width:'20%',showTitle:true},
  106. {display:'所属单位', name:'org_name', align:'center',width:'20%',showTitle:true},
  107. {display:'所属部门', name:'dept_name', align:'center',width:'27%',showTitle:true},
  108. {display:'手机号码', name:'phone', align:'left',width:'33%',showTitle:true}
  109. ],
  110. height:'370px',
  111. width:'390px',
  112. data:data,
  113. pageSize:5,
  114. rownumbers:true,
  115. percentWidthMode:true,
  116. usePager:false,
  117. showPageInfo:false,
  118. showPageSize:false,
  119. onSelectRow:deletePeo
  120. });
  121. }
  122. /*
  123. * 查询人员(组织机构)
  124. */
  125. function orgSearch(zTreeCompId){
  126. if((zTreeCompId== undefined||zTreeCompId=="")&&(temp_dept_id==null)||(temp_dept_id=="")){
  127. temp_dept_id = initDept_id;//贵州电网公司
  128. }else if(((temp_dept_id!=null)&&(temp_dept_id!=""))&&(zTreeCompId!=undefined&&zTreeCompId!="")){//点击组织机构
  129. temp_dept_id = zTreeCompId;
  130. }
  131. $.ajax({
  132. data:{
  133. "dept_id":temp_dept_id
  134. },
  135. type:'post',
  136. timeout:60000,
  137. dataType:'json',
  138. url:"/nwyj/ws/newsendsms/NewSendSmsService/getOrgData",
  139. success:function(result){
  140. initSearchGrid2(result);
  141. },
  142. error:function(){
  143. top.Dialog.alert("根据组织结构查询人员失败!");
  144. }
  145. });
  146. }
  147. /*
  148. * 根据姓名或者账号查询人员
  149. */
  150. function nameSearch(){
  151. var name = $("#name_org").val();
  152. var pattern = new RegExp("[`~!#$^&*()=|{}:;,\\[\\]<>/?~!#¥……&*()——|{}【】‘;:”“。,、?]");
  153. if (pattern.test(name)) {
  154. top.Dialog.alert("不能输入非法字符");
  155. return;
  156. }
  157. if(name=="请输入姓名或4A账号查询"){
  158. top.Dialog.alert("请输入姓名或4A账号!");
  159. return;
  160. }
  161. $.ajax({
  162. data:{
  163. "name":name
  164. },
  165. type:'post',
  166. timeout:60000,
  167. dataType:'json',
  168. url:"/nwyj/ws/newsendsms/NewSendSmsService/getNameData",
  169. success:function(result){
  170. initSearchGrid2(result);
  171. },
  172. error:function(){
  173. top.Dialog.alert("根据组织结构查询人员失败!");
  174. }
  175. });
  176. }
  177. /*
  178. * 不知道为什么一次点击会触发两次事件,这里这把第二次事件过滤掉
  179. */
  180. function percolate(grid,rowdata,flag){
  181. var gridData = grid.getData();
  182. for(var i=0;i<gridData.length;i++){
  183. if(rowdata.userId==gridData[i].userId){
  184. flag = 1 ;
  185. break;
  186. }
  187. }
  188. return flag;
  189. }
  190. /*
  191. * 添加人员
  192. */
  193. function selectPeo(rowdata, rowindex, rowDomElement){
  194. var flag = 0;
  195. var type = rowdata.type;
  196. var selData ={
  197. "type":type,
  198. "group_id":rowdata.group_id,
  199. "userId":rowdata.userId,
  200. "userName":rowdata.userName,
  201. "org_name":rowdata.org_name,
  202. "dept_name":rowdata.dept_name,
  203. "phone":rowdata.phone
  204. };
  205. flag = percolate(selectedGrid,rowdata,flag);
  206. if(flag==1){
  207. return;
  208. }
  209. var first = selectedGrid.getRow(0);
  210. selectedGrid.addRow(selData,first,true);
  211. searchGrid2.loadData();
  212. var length=(selectedGrid.getData().length);
  213. $("#number").val(length);
  214. }
  215. /*
  216. * 全部删除
  217. */
  218. function deleteAll(){
  219. var rows = selectedGrid.getData();
  220. for(var i=rows.length-1;i>-1;i--){
  221. selectedGrid.deleteRow(i);
  222. }
  223. for(var i=rows.length-1;i>-1;i--){
  224. var rowdata = rows[i];
  225. deletePeo(rowdata,null,null);
  226. }
  227. var length=(selectedGrid.getData().length);
  228. $("#number").val(length);
  229. }
  230. /*
  231. *删除
  232. */
  233. function deletePeo(rowdata, rowindex, rowDomElement){
  234. var flag = 0;
  235. var index = rowdata.__index;
  236. selectedGrid.deleteRow(index);
  237. var length=(selectedGrid.getData().length);
  238. $("#number").val(length);
  239. flag = percolate(searchGrid2,rowdata,flag);
  240. if(flag==1){
  241. searchGrid2.loadData();
  242. return;
  243. }
  244. }
  245. /*
  246. * 取消
  247. */
  248. function cancle(){
  249. top.Dialog.confirm("确定不选择人员?",function(){
  250. $(parent.document.body).find("#frmrightChild").height($(window.document.body).height()+30);
  251. $(top.document.body).find("#frmright").height($(parent.document.body).height()+30);
  252. top.Dialog.close();
  253. });
  254. }
  255. /*
  256. *选择人员
  257. */
  258. function getSelectPeople(){
  259. var rows = selectedGrid.getData();
  260. var grid = top.frmright.grid;
  261. for(var i=0;i<rows.length;i++){
  262. var row={
  263. "userId":rows[i].userId,
  264. "userName" : rows[i].userName,
  265. "org_name" : rows[i].org_name,
  266. "dept_name" : rows[i].dept_name,
  267. "phone" : rows[i].phone
  268. };
  269. var data =grid.getData();
  270. /**
  271. * 看表格里是否已经有本条数据
  272. */
  273. for(var j=0 ;j<data.length;j++){
  274. if(data[j].userId==rows[i].userId){
  275. top.Dialog.alert("您要选着的第"+i+"行的"+rows[i].userName+"已经在表中,请先删除");
  276. return;
  277. };
  278. }
  279. top.frmright.addData(row);
  280. }
  281. top.Dialog.close();
  282. }