tpl_dept.html 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>选择人员</title>
  6. <link rel="stylesheet" type="text/css" href="<?=$da['p']?>/css/css.css"/>
  7. <script type="text/javascript" src="js/jquery.js"></script>
  8. <script type="text/javascript" src="js/js.js"></script>
  9. <script type="text/javascript">
  10. function initbody(){
  11. c.init();
  12. }
  13. companymode = <?=(getconfig('companymode')? 'true' : 'false')?>;
  14. uidid = <?=$da['adminid']?>;
  15. var c = {
  16. maxshow:300,
  17. grouparr:[],
  18. userarr:[],
  19. deptarr:[],
  20. firstpid:0,
  21. init:function(){
  22. this.changevalue = js.request('changevalue');//默认值
  23. this.changerange = js.request('changerange');
  24. var us = js.getoption('userjson');
  25. if(us)this.userarr = js.decode(us);
  26. us = js.getoption('groupjson');
  27. if(us)this.grouparr = js.decode(us);
  28. us = js.getoption('deptjson');
  29. if(us)this.deptarr = js.decode(us);
  30. if(!us || this.changerange!=''){
  31. this.loaddata(true);
  32. }else{
  33. this.firstpid = this.deptarr[0].pid;
  34. this.showlist(this.firstpid,0);
  35. this.initxuan();
  36. }
  37. this.resets();
  38. $(window).resize(this.resets);
  39. $('#keywords').keydown(function(e){
  40. c._searchkeys(e)
  41. });
  42. $('#keywords').keyup(function(e){
  43. c._searchkeys(e)
  44. });
  45. },
  46. resets:function(lx){
  47. var he = winHb()-80;
  48. $('#zxuandiv').css('height',''+he+'px');
  49. $('#xuandiv').css('height',''+he+'px');
  50. $('#showtype').css('height',''+he+'px');
  51. },
  52. loaddata:function(iscs){
  53. var url = js.getajaxurl('deptuserjson','dept','system',{'changerange':this.changerange,'gtype':'change'});
  54. $('#showdiv_0').html('<div align="center" style="margin-top:30px"><img src="images/mloading.gif"></div>')
  55. $.get(url,function(ret){
  56. var d = js.decode(ret);
  57. ret = d.data;
  58. if(c.changerange==''){
  59. if(ret.iscache=='1'){
  60. js.setoption('deptjson', '');
  61. js.setoption('userjson', '');
  62. js.setoption('groupjson', '');
  63. }else{
  64. js.setoption('deptjson', ret.deptjson);
  65. js.setoption('userjson', ret.userjson);
  66. js.setoption('groupjson', ret.groupjson);
  67. }
  68. }
  69. c.userarr = js.decode(ret.userjson);
  70. c.deptarr = js.decode(ret.deptjson);
  71. c.grouparr = js.decode(ret.groupjson);
  72. c.firstpid = 0;
  73. if(c.deptarr[0])c.firstpid=c.deptarr[0].pid;
  74. c.showlist(c.firstpid,0);
  75. if(iscs)c.initxuan();
  76. });
  77. },
  78. showlist:function(pid,oi){
  79. var a=this.deptarr,len=a.length,i,s='',ssu='',wjj,s2='',hw=24;
  80. var s1='<div style="width:'+(hw*oi)+'px"></div>';
  81. this.fid = 1;
  82. for(i=0;i<len;i++){
  83. if(a[i].pid==pid){
  84. if(this.fid==1)this.fid = a[i].id;
  85. wjj= 'images/files.png';
  86. if(a[i].ntotal=='0')wjj= 'images/file.png';
  87. s+='<div id="showssd'+a[i].id+'" class="listss">';
  88. s+='<table width="100%"><tr><td height="36">'+s1+'</td><td><img deptxu="'+i+'_'+oi+'" align="absmiddle" height="20" height="20" src="'+wjj+'"></td><td onclick="c.deptstr('+a[i].id+','+i+', \'showssd'+a[i].id+'\')" width="100%">'+a[i].name+'</td></tr></table>';
  89. s+='</div>';
  90. s+='<span show="false" id="showdiv_'+a[i].id+'"></span>';
  91. }
  92. }
  93. var xud = (oi==0)?'0' : pid;
  94. $('#showdiv_'+xud+'').html(s).attr('show','true');
  95. if(oi==0){
  96. this.showlist(this.fid, 1);
  97. this.showgroup();
  98. }
  99. $('#showdiv_0 [deptxu]').unbind('click').click(function(){
  100. c._deptclicks(this);
  101. });
  102. },
  103. showgroup:function(){
  104. var a = this.grouparr,len=a.length,i,s='';
  105. for(i=0;i<len;i++){
  106. s+='<div onclick="c.groupstr('+a[i].id+','+i+', this.id)" id="showssg'+a[i].id+'" class="listsss">';
  107. s+=''+a[i].name+'';
  108. s+='</div>';
  109. }
  110. $('#groupshow').html(s);
  111. },
  112. _deptclicks:function(o){
  113. var sxu = $(o).attr('deptxu').split('_');
  114. var a = this.deptarr[sxu[0]];
  115. var o1 = $('#showdiv_'+a.id+'');
  116. var lx = o1.attr('show');
  117. if(lx=='false'){
  118. this.showlist(a.id, parseFloat(sxu[1])+1);
  119. }else{
  120. o1.toggle();
  121. }
  122. },
  123. initxuan:function(){
  124. var val = this.changevalue;
  125. if(!val)return;
  126. var vals = ','+val+',';
  127. var a = this.deptarr,i,len=a.length,d,s='';
  128. for(i=0;i<len;i++){
  129. d = a[i];
  130. if(vals.indexOf(',d'+d.id+',')>-1){
  131. this.xuan('d',i);
  132. }
  133. }
  134. a = this.userarr;len=a.length;
  135. for(i=0;i<len;i++){
  136. d = a[i];
  137. if(vals.indexOf(',u'+d.id+',')>-1){
  138. this.xuan('u',i);
  139. }
  140. }
  141. a = this.grouparr;len=a.length;
  142. for(i=0;i<len;i++){
  143. d = a[i];
  144. if(vals.indexOf(',g'+d.id+',')>-1){
  145. this.xuan('g',i);
  146. }
  147. }
  148. },
  149. chcangdi:function(ids){
  150. $('#'+ids+'').addClass('tract');
  151. if(this.changeids)$('#'+this.changeids+'').removeClass('tract');
  152. this.changeids = ids;
  153. },
  154. deptstr:function(did,oi, ids){
  155. this.chcangdi(ids);
  156. var d = this.deptarr[oi];
  157. var s = '<div onclick="c.xuan(\'d\','+oi+',this)" class="listsss">['+d.id+'.部门]'+d.name+'</div>';
  158. var a=this.userarr,len=a.length,i,oi=0;
  159. for(i=0;i<len;i++){
  160. if(a[i].deptpath && a[i].deptpath.indexOf('['+did+']')>-1){
  161. oi++;
  162. if(oi>this.maxshow)break;
  163. s+='<div temuoi="'+i+'" onclick="c.xuan(\'u\','+i+',this)" class="listsss"><img src="'+a[i].face+'" height="24" width="24" align="absmiddle"> &nbsp;'+a[i].name+'<span style="font-size:12px;color:#888888">('+a[i].ranking+')</span></div>';
  164. }
  165. }
  166. $('#showtype').html(s);
  167. },
  168. groupstr:function(did,oi,ids){
  169. this.chcangdi(ids);
  170. var d = this.grouparr[oi];
  171. var s = '<div onclick="c.xuan(\'g\','+oi+',this)" class="listsss">['+d.id+'.组]'+d.name+'</div>';
  172. var a=this.userarr,len=a.length,i,oi=0,gids;
  173. for(i=0;i<len;i++){
  174. gids = a[i].groupname;
  175. if(isempt(gids))continue;
  176. gids = ','+gids+',';
  177. if(gids.indexOf(','+did+',')>-1){
  178. oi++;
  179. s+='<div temuoi="'+i+'" onclick="c.xuan(\'u\','+i+',this)" class="listsss"><img src="'+a[i].face+'" height="24" width="24" align="absmiddle"> &nbsp;'+a[i].name+'<span style="font-size:12px;color:#888888">('+a[i].ranking+')</span></div>';
  180. }
  181. }
  182. $('#showtype').html(s);
  183. },
  184. quanx:function(){
  185. $('#showtype div[temuoi]').each(function(){
  186. var o1 = $(this);
  187. c.xuan('u', parseFloat(o1.attr('temuoi')), this);
  188. });
  189. },
  190. xuan:function(lx,oi,o1){
  191. var d = false,s='',id='',s1;
  192. if(lx=='d'){
  193. d = this.deptarr[oi];
  194. id= d.id;
  195. s1='['+d.id+'.部门]';
  196. if(id==1)s1='<span class="label">全员</span>';
  197. s='<div id="d_'+d.id+'" onclick="$(this).remove()" class="listsss">'+s1+'<font>'+d.name+'</font></div>';
  198. if(companymode && id==1 && uidid>1){
  199. s='';
  200. js.msg('msg','多单位模式下不能选择最高的顶级部门');
  201. }
  202. if(this.changerange && id==1){
  203. s='';
  204. js.msg('msg','不能选最顶级部门');
  205. }
  206. }
  207. if(lx=='g'){
  208. d = this.grouparr[oi];
  209. id= d.id;
  210. s1='['+d.id+'.组]';
  211. s='<div id="g_'+d.id+'" onclick="$(this).remove()" class="listsss">'+s1+'<font>'+d.name+'</font></div>';
  212. }
  213. if(lx=='u'){
  214. d = this.userarr[oi];
  215. id= d.id;
  216. s='<div id="u_'+d.id+'" onclick="$(this).remove()" class="listsss"><img src="'+d.face+'" height="24" width="24" align="absmiddle"> &nbsp;<font>'+d.name+'</font><span style="font-size:12px;color:#888888">('+d.ranking+')</span></div>';
  217. }
  218. if(!d)return;
  219. var sid = ''+lx+'_'+id+'';
  220. if(sid!='d_1' && get('d_1')){
  221. js.msg('msg','已经选了最顶级部门,已包含全体人员了');
  222. return;
  223. }
  224. if(get(sid))return;
  225. $('#'+lx+'_'+id+'').remove();
  226. $('#xuandiv').append(s);
  227. },
  228. queding:function(){
  229. var sid='',sna='';
  230. $('#xuandiv').find('div').each(function(){
  231. var id = this.id.replace('_','');
  232. sid+=','+id+'';
  233. sna+=','+$(this).find('font').text();
  234. });
  235. if(sid!=''){
  236. sid = sid.substr(1);
  237. sna = sna.substr(1);
  238. }
  239. var call = js.request('callback');
  240. if(call){
  241. try{parent[call](sna,sid);}catch(e){}
  242. }else{
  243. console.log(sna+'|'+sid);
  244. }
  245. },
  246. cancel:function(){
  247. try{
  248. parent.js.tanclose('changeaction');
  249. }catch(e){}
  250. },
  251. _searchkeys:function(e){
  252. clearTimeout(this._searchkeystime);
  253. this._searchkeystime=setTimeout(function(){
  254. c._searchkey(false);
  255. },500);
  256. },
  257. _searchkey:function(bo){
  258. var key = $('#keywords').val(),a=[],d=[],len,i,oi=0,s='';
  259. a=this.userarr;
  260. if(bo && key=='')return;
  261. len=a.length;
  262. if(key!='')for(i=0;i<len;i++)if(a[i].name.indexOf(key)>-1 || a[i].pingyin.indexOf(key)==0 || a[i].deptname.indexOf(key)>-1 || a[i].ranking.indexOf(key)>-1){
  263. s+='<div onclick="c.xuan(\'u\','+i+',this)" class="listsss"><img src="'+a[i].face+'" height="24" width="24" align="absmiddle"> &nbsp;'+a[i].name+'<span style="font-size:12px;color:#888888">('+a[i].ranking+')</span></div>';
  264. }
  265. if(bo && s=='' && key!='')js.msg('msg','无相关['+key+']的记录', 2);
  266. $('#showtype').html(s);
  267. }
  268. };
  269. </script>
  270. <style>
  271. *{font-size:14px}
  272. .headers{line-height:30px; background-color:#dddddd;color:#1389D3;font-size:14px;height:30px;overflow:hidden}
  273. .lists{line-height:34px; background-color:white;font-size:14px;padding-left:5px;border-bottom:1px #eeeeee solid;color:#888888;height:34px;overflow:hidden}
  274. .active{ background-color:#eeeeee;color:#000000;font-weight:bold}
  275. .listsss{padding:8px; background:white;border-bottom:1px #eeeeee solid;cursor:default;font-size:14px}
  276. .listsss:hover{background-color:#f1f1f1}
  277. .listss{background:white;border-bottom:1px #eeeeee solid;cursor:default;font-size:14px;padding:0px 5px}
  278. .listss:hover{background-color:#f1f1f1}
  279. .listhui{color:#888888}
  280. .listhui img{opacity:0.5}
  281. .changeuserbotton{height:30px;width:50px; background:#d9534f;color:white;font-size:14px;border:none;padding:0px;margin:0px;line-height:20px;cursor:pointer;opacity:1;outline:none;border-radius:5px}
  282. .changeuserbotton:hover{color:white;border:none;opacity:0.8}
  283. .label{font-size:12px;background:#1389D3;color:white;padding:1px 3px;border-radius:5px}
  284. .tract{ background-color:#d6edf9;}
  285. .tract:hover{background-color:#d6edf9;}
  286. </style>
  287. </head>
  288. <body style="padding:0px;margin:0px; overflow:hidden;" scroll="no">
  289. <table height="100%" width="100%">
  290. <tr>
  291. <td valign="top" width="35%" style="border:1px #eeeeee solid">
  292. <div class="headers">&nbsp;选择部门/组</div>
  293. <div style="height:300px;overflow:auto" id="zxuandiv">
  294. <div class="lists active">根据部门选择 v</div>
  295. <div id="showdiv_0"></div>
  296. <div class="lists">根据组选择 v</div>
  297. <div id="groupshow"></div>
  298. </div>
  299. </td>
  300. <td valign="top" width="30%" style="border:1px #eeeeee solid">
  301. <div class="headers">&nbsp;选择人员</div>
  302. <div style="height:300px;overflow:auto" id="showtype"></div>
  303. </td>
  304. <td style="padding:5px;width:10px" valign="center">
  305. <div><input type="button" onclick="c.quanx()" value="全选"></div>
  306. <div style="height:20px"></div>
  307. <div><input type="button" onclick="$('#xuandiv').html('')" value="清空"></div>
  308. </td>
  309. <td valign="top" width="35%" style="border:1px #eeeeee solid">
  310. <div class="headers">&nbsp;√已选择</div>
  311. <div style="height:300px;overflow:auto" id="xuandiv"></div>
  312. </td>
  313. </tr>
  314. <tr>
  315. <td style="background-color:#dddddd" colspan="5">
  316. <table width="100%">
  317. <tr>
  318. <td height="50" width="10" nowrap>&nbsp;</td>
  319. <td width="100%">
  320. <input type="text" id="keywords" style="border:1px #cccccc solid;height:26px;padding:2px;width:180px" placeholder="关键词搜索人员"><input onclick="c._searchkey(true)" type="button" value="搜索" style="background:#888888" class="changeuserbotton">
  321. </td>
  322. <td><input style="width:70px;border:none" type="button" onclick="c.loaddata()" class="changeuserbotton" value="刷新数据" ></td>
  323. <td width="20" nowrap>&nbsp;</td>
  324. <td><input class="changeuserbotton" type="button" onclick="c.cancel()" value="取消" ></td>
  325. <td width="20" nowrap>&nbsp;</td>
  326. <td height="50"><input style="background:#1389D3;" onclick="c.queding()" type="button" value="确定" class="changeuserbotton"></td>
  327. <td width="10" nowrap>&nbsp;</td>
  328. </tr>
  329. </table>
  330. </td>
  331. </tr>
  332. </table>
  333. </body>
  334. </html>