SysCheckScan.js 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.ma.SysCheckScan', {
  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=scan]':{
  81. 'click':function(btn){
  82. var f=Ext.getCmp('date');
  83. var v = Ext.Date.format(new Date(f.value), 'Y-m-d');
  84. var condition="scd_indate "+f.value;
  85. }
  86. },
  87. 'button[id=turnpunish]':{
  88. 'click':function(btn){
  89. Ext.Ajax.request({
  90. url:basePath+'ma/SysCheck/TurnReandpunish.action',
  91. method:'post',
  92. params:{
  93. data:data
  94. },
  95. callback:function(options,success,response){
  96. var local=new Ext.decode(response.responseText);
  97. if(local.exceptionInfo){
  98. showError(local.exceptionInfo);
  99. return
  100. }
  101. if(local.success){
  102. saveSuccess();
  103. }
  104. }
  105. });
  106. }
  107. },
  108. 'erpSysCheckGrid':{
  109. itemclick:function(selModel,record){
  110. if(!Ext.getCmp('win')){
  111. if(record&&record.data.details=='autoshow'&&(record.data.warncount>0||record.data.publishcount>0)){
  112. var win = new Ext.window.Window({
  113. id:'win',
  114. title: "添加特征明细",
  115. height: "70%",
  116. width: "80%",
  117. maximizable : false,
  118. buttonAlign : 'center',
  119. layout : 'anchor',
  120. items: [{
  121. xtype: 'erpSysCheckWinGrid',
  122. anchor: '100% 100%',
  123. id:'grid3',
  124. condition: 'scd_emid='+record.data.orgid +" AND scd_indate "+Ext.getCmp('date').value,
  125. readOnly: false,
  126. caller:'SysCheckData',
  127. }],
  128. bbar: ['->',{
  129. xtype:'button',
  130. text:'生成惩罚单',
  131. cls: 'x-btn-gray',
  132. iconCls: 'x-button-icon-save',
  133. handler:Ext.getCmp('turnpunish').handler
  134. },{
  135. xtype:'erpCloseButton',
  136. style: {
  137. marginLeft: '14px'
  138. },
  139. handler:function(){
  140. Ext.getCmp('win').close();
  141. }
  142. },'->']
  143. });
  144. win.show();
  145. }
  146. }
  147. }
  148. },
  149. 'condatefield':{
  150. afterrender:function(field){
  151. field.setDateFieldValue(2);
  152. }
  153. }
  154. });
  155. },
  156. loadNewStore: function(grid, param){
  157. var me = this;
  158. var main = parent.Ext.getCmp("content-panel");
  159. if(!main)
  160. main = parent.parent.Ext.getCmp("content-panel");
  161. if(main){
  162. main.getActiveTab().setLoading(true);//loading...
  163. }
  164. Ext.Ajax.request({//拿到grid的columns
  165. url : basePath + "common/loadNewGridStore.action",
  166. params: param,
  167. method : 'post',
  168. callback : function(options,success,response){
  169. if(main){
  170. main.getActiveTab().setLoading(false);
  171. }
  172. var res = new Ext.decode(response.responseText);
  173. if(res.exceptionInfo){
  174. showError(res.exceptionInfo);return;
  175. }
  176. var data = res.data;
  177. if(!res.data || res.data.length == 0){
  178. grid.store.removeAll();
  179. } else {
  180. grid.store.loadData(data);
  181. }
  182. //自定义event
  183. grid.addEvents({
  184. storeloaded: true
  185. });
  186. me.setToolbarValue(grid);
  187. grid.fireEvent('storeloaded', grid, data);
  188. }
  189. });
  190. },
  191. getParamData:function(){
  192. var grid=Ext.getCmp('gridpanel');
  193. var items=grid.store.data.items;
  194. var data=new Array();
  195. for(var i=0;i<items.length;i++){
  196. var o=new Object();
  197. 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){
  198. o.scd_id=items[i].data.scd_id;
  199. o.scd_punishamount=items[i].data.scd_punishamount;
  200. o.scd_title=items[i].data.scd_title;
  201. o.scd_emname=items[i].data.scd_emname;
  202. o.scd_sourcecode=items[i].data.scd_sourcecode;
  203. data.push(o);
  204. }
  205. }
  206. return unescape(Ext.JSON.encode(data).replace(/\\/g,"%"));
  207. },
  208. setToolbarValue:function(grid){
  209. var store=grid.getStore();
  210. var warncount=0,publishcount=0,publishamount=0,count=0;
  211. for(var i=0;i<store.data.items.length;i++){
  212. count++;
  213. if(store.data.items[i].data.scd_method=='-1'){
  214. publishcount++;
  215. publishamount+=store.data.items[i].data.scd_punishamount;
  216. }else if(store.data.items[i].data.scd_method=='0'){
  217. warncount++;
  218. }
  219. }
  220. Ext.getCmp('scd_count').setText('记录总数:' + count);
  221. Ext.getCmp('scd_warn_sum').setText('提醒:'+warncount);
  222. Ext.getCmp('scd_publish_sum').setText('扣分:'+publishcount);
  223. Ext.getCmp('scd_publishamount_sum').setText('扣分总数:'+publishamount);
  224. },
  225. getForm: function(btn){
  226. return btn.ownerCt.ownerCt;
  227. },
  228. save: function(btn){
  229. var me = this;
  230. var form = me.getForm(btn);
  231. if(Ext.getCmp(form.codeField).value == null || Ext.getCmp(form.codeField).value == ''){
  232. me.BaseUtil.getRandomNumber();//自动添加编号
  233. }
  234. me.FormUtil.beforeSave(me);
  235. }
  236. });