AttentionMain.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.oa.attention.AttentionMain', {
  3. extend: 'Ext.app.Controller',
  4. requires: ['erp.util.FormUtil', 'erp.util.GridUtil', 'erp.util.BaseUtil', 'erp.util.RenderUtil'],
  5. views:[
  6. 'oa.attention.AttentionMain','oa.attention.AttentionMainGrid','oa.attention.Form','core.form.ColorField','core.button.Save','core.button.Close','oa.attention.AttentionManageGrid',
  7. 'core.form.ScopeField','core.grid.Panel2','core.trigger.MultiDbfindTrigger','oa.addrBook.AddrBookTree','oa.attention.AttentionMainTreePanel','common.datalist.Toolbar','core.form.PhotoField'
  8. ],
  9. init:function(){
  10. var me=this;
  11. this.control({
  12. 'AttentionMainTreePanel':{
  13. afterrender:function(panel){
  14. var button=new Object();
  15. button.xtype='button';
  16. button.cls='btn-cls';
  17. button.text='查看所有';
  18. button.iconCls='x-button-icon-addgroup';
  19. button.style='margin-left:20px;';
  20. button.handler=function open(){
  21. me.addGroup();
  22. };
  23. panel.add(button);
  24. },
  25. itemmousedown:function(view,record ){
  26. var grid=Ext.getCmp('grid');
  27. var data=record.data;
  28. var value='';
  29. if(!data.leaf){
  30. value=data.qtip;
  31. }else value=data.id;
  32. if(record.data.parentId=='root'){
  33. if(grid.isHidden()){
  34. grid.show();
  35. }
  36. }else {
  37. me.createForm(value);
  38. // me.createGrid();
  39. grid.hide();
  40. }
  41. }
  42. } ,
  43. 'erpAttentionMainGridPanel':{
  44. afterrender:function(panel){
  45. }
  46. },
  47. 'button[id=accredit]':{
  48. click:function(){
  49. me.accreditAttention();
  50. }
  51. },
  52. 'button[id=delete]':{
  53. click:function(){
  54. me.Delete();
  55. }
  56. },
  57. 'button[id=rank]':{
  58. click:function(){
  59. me.Rank();
  60. }
  61. }
  62. });
  63. },
  64. AddAttention:function(){
  65. var selectedemid=null;
  66. var condition='';
  67. if(selectedemid){
  68. condition="ap_attentedemid="+selectedemid+" AND ap_emid="+emid;
  69. }else condition= "ap_emid="+0;
  70. var win = new Ext.window.Window(
  71. {
  72. id : 'win',
  73. height : '80%',
  74. title:'关注项设置',
  75. width : '65%',
  76. maximizable : true,
  77. buttonAlign : 'center',
  78. layout : 'anchor',
  79. items : [ {
  80. tag : 'iframe',
  81. frame : true,
  82. anchor : '100% 100%',
  83. layout : 'fit',
  84. html : '<iframe id="iframe_'+ caller+ '" src="'+ basePath+ 'jsps/oa/attention/AttentionSub.jsp?urlcondition='+condition+'&caller=AttentionPerson" height="100%" width="100%" frameborder="0" scrolling="no"></iframe>'
  85. } ],
  86. });
  87. win.show();
  88. },
  89. Rank:function(){
  90. var win = new Ext.window.Window(
  91. {
  92. id : 'win',
  93. height : '80%',
  94. title:'等级设置',
  95. width : '60%',
  96. maximizable : true,
  97. buttonAlign : 'center',
  98. layout : 'anchor',
  99. items : [ {
  100. tag : 'iframe',
  101. frame : true,
  102. anchor : '100% 100%',
  103. layout : 'fit',
  104. html : '<iframe id="iframe_'+ caller+ '" src="'+ basePath+ 'jsps/oa/attention/AttentionGrade.jsp'+ '" height="100%" width="100%" frameborder="0" scrolling="no"></iframe>'
  105. } ],
  106. });
  107. win.show();
  108. },
  109. accreditAttention:function(){
  110. var selectedemid=null;
  111. var condition='';
  112. if(selectedemid){
  113. condition="ap_accreditedemid="+selectedemid+" AND aa_emid="+emid;
  114. }else condition= "aa_emid="+0;
  115. var win = new Ext.window.Window(
  116. {
  117. id : 'win',
  118. height : '80%',
  119. title:'授权设置',
  120. width : '65%',
  121. maximizable : true,
  122. buttonAlign : 'center',
  123. layout : 'anchor',
  124. items : [ {
  125. tag : 'iframe',
  126. frame : true,
  127. anchor : '100% 100%',
  128. layout : 'fit',
  129. html : '<iframe id="iframe_'+ caller+ '" src="'+ basePath+ 'jsps/oa/attention/AttentionSub.jsp?urlcondition='+condition+'&caller=AccreditAttention" height="100%" width="100%" frameborder="0" scrolling="no"></iframe>'
  130. } ],
  131. });
  132. win.show();
  133. },
  134. Delete:function(){
  135. var grid=Ext.getCmp('AttentionGridPanel');
  136. var data=grid.getMultiSelected();
  137. var param=new Object();
  138. param.data=data;
  139. Ext.Ajax.request({//拿到form的items
  140. url : basePath + 'oa/attention/deleteAttentions.action',
  141. params: param,
  142. method : 'post',
  143. callback : function(options,success,response){
  144. var res = new Ext.decode(response.responseText);
  145. if(res.success){
  146. saveSuccess(
  147. grid.loadNewStore(grid,{caller:caller,condition: "ap_emid="+emid})
  148. );
  149. }
  150. }
  151. });
  152. },
  153. createForm:function(value){
  154. var me = this;
  155. var data=null;
  156. Ext.Ajax.request({
  157. url : basePath + 'oa/attention/getAttentionEmployeeByParam.action',
  158. params: {
  159. caller: 'AttentionEmployee',
  160. param:value
  161. },
  162. method : 'post',
  163. async: false,
  164. callback : function(options,success,response){
  165. var res = new Ext.decode(response.responseText);
  166. if(res.exception || res.exceptionInfo){
  167. showError(res.exceptionInfo);
  168. return;
  169. }
  170. data = res.data != null ? Ext.decode(res.data.replace(/,}/g, '}').replace(/,]/g, ']')) : new Array();
  171. }
  172. });
  173. var form=Ext.getCmp('form')
  174. if(form){
  175. form.destroy();
  176. }
  177. var keyValue=data.em_id;
  178. var keyField='ap_attentedemid';
  179. var url='jsps/oa/attention/AttentionManageDetail.jsp';
  180. var title='详细信息';
  181. var panel= Ext.create('Ext.form.Panel', {
  182. title: '<font color=green>关注人查看 >>'+data.em_name+'</font>',
  183. bodyPadding: 5,
  184. iconCls: 'main-activeuser',
  185. layout: 'column',
  186. id:'form',
  187. defaults: {
  188. anchor: '100%',
  189. readOnly:true,
  190. columnWidth:0.5,
  191. fieldStyle : 'background:#f0f0f0;border-bottom:none;padding:2px 2px;vertical-align:middle;border-top:none;border-right:none;color:#CD661D;border-bottom-style:1px solid;border-left:none;font-weight: bold; ',
  192. },
  193. frame:true,
  194. defaultType: 'textfield',
  195. items: [{
  196. html:'<div style="font-weight:bold; font-size:15px">基本信息</div>',
  197. columnWidth:1
  198. },{
  199. fieldLabel: '姓名',
  200. name: 'em_name',
  201. id:'em_name',
  202. },{
  203. fieldLabel: '编号',
  204. name: 'em_code',
  205. },{
  206. fieldLabel:'照片',
  207. fieldStyle:'margin-right:0',
  208. name:'em_photourl',
  209. xtype:'photofield',
  210. value:data.em_photourl,
  211. },{
  212. fieldLabel:'性别',
  213. name:'em_sex',
  214. },{
  215. fieldLabel:'出生年月',
  216. name:'em_birthday'
  217. },{
  218. fieldLabel:'联系电话',
  219. name:'em_tel',
  220. },{
  221. fieldLabel: '移动电话',
  222. name: 'em_mobile',
  223. },{
  224. fieldLabel: '默认邮箱',
  225. name: 'em_email',
  226. },{
  227. fieldLabel: 'UU号',
  228. name: 'em_uu',
  229. },{
  230. fieldLabel:'籍贯',
  231. name:'em_native'
  232. },{
  233. fieldLabel:'工作年限',
  234. name:'em_worktime',
  235. },{
  236. xtype:'button',
  237. layout:'fit',
  238. columnWidth:0,
  239. iconCls:'x-button-icon-paging',
  240. listeners:{
  241. click:function(btn,e){
  242. var othername=Ext.getCmp('em_name').getValue();
  243. showDialogBox(e,null,emid,othername);
  244. }
  245. }
  246. },{
  247. xtype:'button',
  248. layout:'fit',
  249. columnWidth:0,
  250. iconCls:'x-button-icon-paging',
  251. listeners:{
  252. click:function(btn,e){
  253. console.log(data);
  254. if(data.em_uu!=null){
  255. var jid =data.em_uu+"@58.61.153.82";
  256. var url = 'uas:'+jid;
  257. window.location = url;
  258. }
  259. }
  260. }
  261. },{
  262. html:'<div style="font-weight:bold; font-size:15px">组织信息</div>',
  263. columnWidth:1
  264. },{
  265. fieldLabel:'所属组织',
  266. name:'em_worktime',
  267. },{
  268. fieldLabel:'所属部门',
  269. name:'em_birthday'
  270. },{
  271. fieldLabel:'部门负责人',
  272. name:'or_headmanname'
  273. },{
  274. html:'<a style="text-decoration: none||blink;font-size:16px;text-align:left;font-weight: bold; " href="javascript:openUrl(' + keyValue + ',\''+keyField+'\',\''+url+'\',\''+title+'\''+ ');">查看详细</a>',
  275. }],
  276. renderTo: Ext.get('employeedata'),
  277. listeners:{
  278. afterrender:function(btn,e){
  279. Ext.getCmp('photobutton').hide();
  280. }
  281. }
  282. });
  283. panel.getForm().setValues(data);
  284. var gridfields="";
  285. var griddata="";
  286. var gridcolumns="";
  287. Ext.Ajax.request({
  288. url : basePath + 'oa/attention/getDataAndColumnsByParam.action',
  289. params: {
  290. caller: 'AttentionManageDetail',
  291. param:value
  292. },
  293. method : 'post',
  294. async: false,
  295. callback : function(options,success,response){
  296. var res = new Ext.decode(response.responseText);
  297. if(res.exception || res.exceptionInfo){
  298. showError(res.exceptionInfo);
  299. return;
  300. }
  301. griddata = res.data != null ? Ext.decode(res.data.replace(/,}/g, '}').replace(/,]/g, ']')) : new Array();
  302. gridfields=res.fields;
  303. gridcolumns=res.columns;
  304. }
  305. });
  306. var store=Ext.create('Ext.data.Store',{
  307. fields:gridfields,
  308. data:griddata
  309. });
  310. if(Ext.getCmp('detaigrid')){
  311. Ext.getCmp('detaigrid').getView().bindStore(store);
  312. return;
  313. }
  314. var grid= Ext.create('Ext.grid.Panel', {
  315. id:'detaigrid',
  316. store: Ext.create('Ext.data.Store',{
  317. fields:gridfields,
  318. data:griddata,
  319. }),
  320. autoScroll:true,
  321. columnLines:true,
  322. title: '<font color=green>关注明细</font>',
  323. height:window.innerHeight*0.35,
  324. layout:'auto',
  325. columns:gridcolumns,
  326. renderTo: Ext.get('details'),
  327. });
  328. },
  329. showDialogBox: function (e,id, otherId, other, date, context){
  330. var panel = Ext.getCmp('dialog-win-' + otherId);
  331. if(!panel){
  332. panel = Ext.create('erp.view.core.window.DialogBox', {
  333. other: other,
  334. autoShow: false,
  335. otherId: otherId
  336. });
  337. panel.showAt(e.getXY());
  338. }
  339. if(!Ext.isEmpty(id)){
  340. panel.insertDialogItem(other, date, context);
  341. if(Ext.getCmp('dialog-min-' + otherId)){
  342. Ext.getCmp('dialog-min-' + otherId).setText("<font color=red>有新消息...</font>" );
  343. } else {
  344. updatePagingStatus(id, 1);
  345. }
  346. }
  347. },
  348. mergeCells:function(grid,cols){
  349. var arrayTr=document.getElementById(grid.getId()+"-body").firstChild.firstChild.firstChild.getElementsByTagName('tr');
  350. var trCount = arrayTr.length;
  351. var arrayTd;
  352. var td;
  353. var merge = function(rowspanObj,removeObjs){ //定义合并函数
  354. if(rowspanObj.rowspan != 1){
  355. arrayTd =arrayTr[rowspanObj.tr].getElementsByTagName("td"); //合并行
  356. td=arrayTd[rowspanObj.td-1];
  357. td.rowSpan=rowspanObj.rowspan;
  358. td.vAlign="middle";
  359. td.style="text-align:center";
  360. Ext.each(removeObjs,function(obj){ //隐身被合并的单元格
  361. arrayTd =arrayTr[obj.tr].getElementsByTagName("td");
  362. arrayTd[obj.td-1].style.display='none';
  363. });
  364. }
  365. };
  366. var rowspanObj = {}; //要进行跨列操作的td对象{tr:1,td:2,rowspan:5}
  367. var removeObjs = []; //要进行删除的td对象[{tr:2,td:2},{tr:3,td:2}]
  368. var col;
  369. Ext.each(cols,function(colIndex){ //逐列去操作tr
  370. var rowspan = 1;
  371. var divHtml = null;
  372. for(var i=1;i<trCount;i++){
  373. arrayTd = arrayTr[i].getElementsByTagName("td");
  374. var cold=0;
  375. // Ext.each(arrayTd,function(Td){ //获取RowNumber列和check列
  376. // if(Td.getAttribute("class").indexOf("x-grid-cell-special") != -1)
  377. // cold++;
  378. // });
  379. col=colIndex+cold;//跳过RowNumber列和check列
  380. if(!divHtml){
  381. divHtml = arrayTd[col-1].innerHTML;
  382. rowspanObj = {tr:i,td:col,rowspan:rowspan}
  383. }else{
  384. var cellText = arrayTd[col-1].innerHTML;
  385. var addf=function(){
  386. rowspanObj["rowspan"] = rowspanObj["rowspan"]+1;
  387. removeObjs.push({tr:i,td:col});
  388. if(i==trCount-1)
  389. merge(rowspanObj,removeObjs);
  390. };
  391. var mergef=function(){
  392. merge(rowspanObj,removeObjs);
  393. divHtml = cellText;
  394. rowspanObj = {tr:i,td:col,rowspan:rowspan}
  395. removeObjs = [];
  396. };
  397. if(cellText == divHtml){
  398. if(colIndex!=cols[0]){
  399. var leftDisplay=arrayTd[col-2].style.display;
  400. if(leftDisplay=='none')
  401. addf();
  402. else
  403. mergef();
  404. }else
  405. addf();
  406. }else
  407. mergef();
  408. }
  409. }
  410. });
  411. }
  412. });