SysCheckTreeScan.js 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.ma.SysCheckTreeScan', {
  3. extend: 'Ext.app.Controller',
  4. requires: ['erp.util.FormUtil', 'erp.util.GridUtil', 'erp.util.BaseUtil'],
  5. views:[ 'ma.SysCheckTreeGrid',
  6. 'core.form.Panel','ma.SysCheckFormula','core.grid.Panel2','core.toolbar.Toolbar','core.form.MultiField','core.form.YnField','ma.SysCheckGrid',
  7. 'core.button.Save','core.button.Add','core.button.Submit','core.button.Print','core.button.PrintA4','core.button.Upload','core.button.ResAudit',
  8. 'core.button.Audit','core.button.Close','core.button.Delete','core.button.Update','core.button.DeleteDetail','core.button.ResSubmit','ma.SysCheckWinGrid',
  9. 'core.trigger.DbfindTrigger','core.trigger.TextAreaTrigger','core.grid.YnColumn','ma.SysCheckTree','ma.SysCheckForm','core.form.ConDateField'
  10. ],
  11. init:function(){
  12. var me = this;
  13. this.control({
  14. 'erpSysCheckTreePanel':{
  15. itemmousedown: function(selModel, record){
  16. if(record.get('leaf')){
  17. //人员点进去的 查看个人明细信息
  18. var main = parent.Ext.getCmp("content-panel");
  19. if(!main)
  20. main = parent.parent.Ext.getCmp("content-panel");
  21. if(main){
  22. main.getActiveTab().setLoading(true);//loading...
  23. }
  24. Ext.getCmp('sysgrid').hide();
  25. var grid=Ext.getCmp('gridpanel');
  26. if(grid){
  27. grid.show();
  28. grid.store.clearFilter(true);
  29. grid.store.filter("scd_emname", record.data.text);
  30. me.setToolbarValue(grid);
  31. main.getActiveTab().setLoading(false);
  32. }else {
  33. Ext.getCmp('mainplace').add({
  34. anchor:'100% 93%',
  35. layout:'fit',
  36. autoScroll:true,
  37. id:'gridpanel',
  38. xtype : 'erpGridPanel2',
  39. caller : 'SysCheckData',
  40. condition:'1=1',
  41. listeners:{
  42. 'afterrender':function(grid){
  43. grid.store.filter("scd_emname", record.data.text);
  44. }
  45. }
  46. });
  47. }
  48. }else {
  49. //组织点进去的 查看合计信息
  50. if(record.data.parentId=='root'){
  51. var sysgrid=Ext.getCmp('sysgrid');
  52. sysgrid.loadNewStore(sysgrid,{_noc:1,parentid:0});
  53. sysgrid.show();
  54. var grid= Ext.getCmp('gridpanel');
  55. if (grid) grid.hide();
  56. }else if(record.data.cls&&record.data.cls=='org'){
  57. //说明点开的还是
  58. var grid= Ext.getCmp('gridpanel');
  59. if (grid) grid.hide();
  60. var sysgrid=Ext.getCmp('sysgrid');
  61. sysgrid.loadNewStore(sysgrid,{_noc:1,parentid:record.data.id});
  62. sysgrid.show();
  63. }else {
  64. //需要重新发送请求 加载数据
  65. var params={
  66. caller:'SysCheckData',
  67. condition: 'scd_orid='+record.data.id.replace(/org/g,"")
  68. };
  69. var sysgrid=Ext.getCmp('sysgrid');
  70. sysgrid.loadNewStore(sysgrid,{_noc:1,parentid:record.data.id,type:'employee'});
  71. sysgrid.show();
  72. var grid=Ext.getCmp('gridpanel');
  73. grid.hide();
  74. grid.store.clearFilter(true);
  75. me.loadNewStore(grid,params);
  76. }
  77. }
  78. }
  79. },
  80. 'button[id=more]':{
  81. 'afterrender':function(btn){
  82. btn.hide();
  83. }
  84. },
  85. 'button[id=scan]':{
  86. beforerender:function(){
  87. var treegrid=Ext.getCmp('treegrid');
  88. treegrid.getTreeGridNode("scd_indate "+Ext.getCmp('date').value);
  89. }
  90. },
  91. 'erpSysCheckTreeGrid':{
  92. itemmousedown:function(selModel,record){
  93. if(!Ext.getCmp('win')){
  94. if(record&&record.data.leaf){
  95. var win = new Ext.window.Window({
  96. id:'win',
  97. title: "添加特征明细",
  98. height: "70%",
  99. width: "80%",
  100. maximizable : false,
  101. buttonAlign : 'center',
  102. layout : 'anchor',
  103. items: [{
  104. xtype: 'erpSysCheckWinGrid',
  105. anchor: '100% 100%',
  106. id:'grid3',
  107. condition: 'scd_emid='+record.data.orgid +" AND scd_indate "+Ext.getCmp('date').value,
  108. readOnly: false,
  109. caller:'SysCheckData',
  110. }],
  111. bbar: ['->',{
  112. xtype:'button',
  113. text:'生成惩罚单',
  114. cls: 'x-btn-gray',
  115. iconCls: 'x-button-icon-save',
  116. handler:Ext.getCmp('turnpunish').handler
  117. },{
  118. xtype:'erpCloseButton',
  119. style: {
  120. marginLeft: '14px'
  121. },
  122. handler:function(){
  123. Ext.getCmp('win').close();
  124. }
  125. },'->']
  126. });
  127. win.show();
  128. }
  129. }
  130. }
  131. },
  132. 'condatefield':{
  133. afterrender:function(field){
  134. field.setDateFieldValue(2);
  135. }
  136. }
  137. });
  138. },
  139. loadNewStore: function(grid, param){
  140. var me = this;
  141. var main = parent.Ext.getCmp("content-panel");
  142. if(!main)
  143. main = parent.parent.Ext.getCmp("content-panel");
  144. if(main){
  145. main.getActiveTab().setLoading(true);//loading...
  146. }
  147. Ext.Ajax.request({//拿到grid的columns
  148. url : basePath + "common/loadNewGridStore.action",
  149. params: param,
  150. method : 'post',
  151. callback : function(options,success,response){
  152. if(main){
  153. main.getActiveTab().setLoading(false);
  154. }
  155. var res = new Ext.decode(response.responseText);
  156. if(res.exceptionInfo){
  157. showError(res.exceptionInfo);return;
  158. }
  159. var data = res.data;
  160. if(!res.data || res.data.length == 0){
  161. grid.store.removeAll();
  162. } else {
  163. grid.store.loadData(data);
  164. }
  165. //自定义event
  166. grid.addEvents({
  167. storeloaded: true
  168. });
  169. me.setToolbarValue(grid);
  170. grid.fireEvent('storeloaded', grid, data);
  171. }
  172. });
  173. },
  174. getParamData:function(){
  175. var grid=Ext.getCmp('gridpanel');
  176. var items=grid.store.data.items;
  177. var data=new Array();
  178. for(var i=0;i<items.length;i++){
  179. var o=new Object();
  180. if(items[i].data.scd_ispunished==0&&items[i].data.scd_id!=0&&items[i].data.scd_id!='0'&&items[i].data.scd_method==-1){
  181. o.scd_id=items[i].data.scd_id;
  182. o.scd_punishamount=items[i].data.scd_punishamount;
  183. o.scd_title=items[i].data.scd_title;
  184. o.scd_emname=items[i].data.scd_emname;
  185. o.scd_sourcecode=items[i].data.scd_sourcecode;
  186. data.push(o);
  187. }
  188. }
  189. return unescape(Ext.JSON.encode(data).replace(/\\/g,"%"));
  190. },
  191. setToolbarValue:function(grid){
  192. var store=grid.getStore();
  193. var warncount=0,publishcount=0,publishamount=0,count=0;
  194. for(var i=0;i<store.data.items.length;i++){
  195. count++;
  196. if(store.data.items[i].data.scd_method=='-1'){
  197. publishcount++;
  198. publishamount+=store.data.items[i].data.scd_punishamount;
  199. }else if(store.data.items[i].data.scd_method=='0'){
  200. warncount++;
  201. }
  202. }
  203. Ext.getCmp('scd_count').setText('记录总数:' + count);
  204. Ext.getCmp('scd_warn_sum').setText('提醒:'+warncount);
  205. Ext.getCmp('scd_publish_sum').setText('扣分:'+publishcount);
  206. Ext.getCmp('scd_publishamount_sum').setText('扣分总数:'+publishamount);
  207. },
  208. getForm: function(btn){
  209. return btn.ownerCt.ownerCt;
  210. },
  211. save: function(btn){
  212. var me = this;
  213. var form = me.getForm(btn);
  214. if(Ext.getCmp(form.codeField).value == null || Ext.getCmp(form.codeField).value == ''){
  215. me.BaseUtil.getRandomNumber();//自动添加编号
  216. }
  217. me.FormUtil.beforeSave(me);
  218. }
  219. });