SubsFormula.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.common.SubsFormula', {
  3. extend: 'Ext.app.Controller',
  4. requires: ['erp.util.FormUtil', 'erp.util.GridUtil', 'erp.util.BaseUtil'],
  5. views:[
  6. 'core.form.Panel','common.subs.SubsFormula','core.grid.Panel2','core.toolbar.Toolbar','core.trigger.MultiDbfindTrigger','core.trigger.HrOrgTreeDbfindTrigger',
  7. 'core.button.Save','core.button.Add','core.button.Submit','core.button.Print','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',
  9. 'core.button.Banned','core.button.ResBanned','core.form.MultiField','core.button.Confirm','core.button.Sync',
  10. 'core.trigger.DbfindTrigger','core.trigger.TextAreaTrigger','core.form.YnField', 'core.grid.YnColumn','core.trigger.AddDbfindTrigger',
  11. 'core.form.FileField','core.form.SplitTextField','core.button.End','core.button.ResEnd',
  12. 'core.form.MonthDateField','core.form.SpecialContainField','core.button.Test'
  13. ],
  14. init:function(){
  15. var me = this;
  16. me.FormUtil = Ext.create('erp.util.FormUtil');
  17. me.GridUtil = Ext.create('erp.util.GridUtil');
  18. me.BaseUtil = Ext.create('erp.util.BaseUtil');
  19. this.control({
  20. 'erpGridPanel2': {
  21. itemclick: this.onGridItemClick,
  22. },
  23. 'erpSaveButton': {
  24. click: function(btn){
  25. var form = me.getForm(btn);
  26. if (Ext.getCmp(form.codeField).value == null
  27. || Ext.getCmp(form.codeField).value == '') {
  28. me.BaseUtil.getRandomNumber();// 自动添加编号
  29. }
  30. this.FormUtil.beforeSave(this);
  31. }
  32. },
  33. 'erpDeleteButton' : {
  34. click: function(btn){
  35. me.FormUtil.onDelete(Ext.getCmp('id_').value);
  36. }
  37. },
  38. 'erpUpdateButton': {
  39. click: function(btn){
  40. this.FormUtil.onUpdate(this);
  41. }
  42. },
  43. 'erpAddButton': {
  44. click: function(){
  45. me.FormUtil.onAdd('addSubsFormula', '新增订阅项', 'jsps/common/subsformula.jsp');
  46. }
  47. },
  48. 'erpCloseButton': {
  49. click: function(btn){
  50. me.FormUtil.beforeClose(me);
  51. }
  52. },
  53. 'erpAuditButton' : {
  54. afterrender : function(btn) {
  55. var status = Ext.getCmp('statuscode_');
  56. if (status && status.value != 'COMMITED') {
  57. btn.hide();
  58. }
  59. },
  60. click : function(btn) {
  61. this.FormUtil.onAudit(Ext.getCmp('id_').value);
  62. }
  63. },
  64. 'erpResAuditButton' : {
  65. afterrender : function(btn) {
  66. var status = Ext.getCmp('statuscode_');
  67. if (status && status.value != 'AUDITED') {
  68. btn.hide();
  69. }
  70. },
  71. click : function(btn) {
  72. this.FormUtil.onResAudit(Ext.getCmp('id_').value);
  73. }
  74. },
  75. 'erpSubmitButton' : {
  76. afterrender : function(btn) {
  77. var status = Ext.getCmp('statuscode_');
  78. if (status && status.value != 'ENTERING') {
  79. btn.hide();
  80. }
  81. },
  82. click : function(btn) {
  83. this.FormUtil.onSubmit(Ext.getCmp('id_').value);
  84. }
  85. },
  86. 'erpResSubmitButton' : {
  87. afterrender : function(btn) {
  88. var status = Ext.getCmp('statuscode_');
  89. if (status && status.value != 'COMMITED') {
  90. btn.hide();
  91. }
  92. },
  93. click : function(btn) {
  94. this.FormUtil.onResSubmit(Ext.getCmp('id_').value);
  95. }
  96. },
  97. 'erpTestButton': {
  98. afterrender : function(btn) {
  99. var status = Ext.getCmp('statuscode_');
  100. if (status && status.value != 'AUDITED') {
  101. btn.hide();
  102. }
  103. },
  104. click: function(btn){
  105. Ext.Ajax.request({
  106. url: basePath + 'common/charts/testSubsFormula.action',
  107. params: {
  108. id: Ext.getCmp('id_').value,
  109. caller:caller
  110. },
  111. method: 'post',
  112. callback: function(options, success, response){
  113. var res = new Ext.decode(response.responseText);
  114. if(res.exceptionInfo) {
  115. showError(res.exceptionInfo);
  116. } else {
  117. Ext.MessageBox.confirm('提示', '测试通过,是否需要预览数据?', del);
  118. function del(btn) {
  119. if(btn == 'yes'){
  120. // 弹出win预览数据
  121. var win = new Ext.window.Window({
  122. title: '预 览',
  123. height: "100%",
  124. width: "80%",
  125. maximizable : true,
  126. resizable:true,
  127. buttonAlign : 'center',
  128. layout : 'anchor',
  129. bodyStyle: 'background:#f1f1f1;',
  130. items:[{
  131. xtype: 'form',
  132. id:'paramsForm',
  133. anchor: '100% 20%',
  134. autoScroll:true,
  135. bodyStyle: 'background:#f1f1f1;',
  136. layout: 'column',
  137. items:[ {
  138. margin: '5 0 0 5',
  139. xtype: 'textfield',
  140. fieldLabel: '员工ID',
  141. name: 'EMID',
  142. value: EMID,
  143. id: 'EMID'
  144. },{
  145. margin: '5 0 0 5',
  146. xtype: 'textfield',
  147. fieldLabel: '编号',
  148. name: 'EMCODE',
  149. value: EMCODE,
  150. id: 'EMCODE'
  151. },{
  152. margin: '5 0 0 5',
  153. xtype: 'textfield',
  154. fieldLabel: '姓名',
  155. name: 'EMNAME',
  156. value: EMNAME,
  157. id: 'EMNAME'
  158. },{
  159. margin: '5 0 0 5',
  160. xtype: 'textfield',
  161. fieldLabel: '组织',
  162. name: 'EMDEFAULTORNAME',
  163. value: EMDEFAULTORNAME,
  164. id: 'EMDEFAULTORNAME'
  165. },{
  166. margin: '5 0 0 5',
  167. xtype: 'textfield',
  168. fieldLabel: '部门',
  169. name: 'EMDEPART',
  170. value: EMDEPART,
  171. id: 'EMDEPART'
  172. },{
  173. margin: '5 0 0 5',
  174. xtype: 'numberfield',
  175. fieldLabel: '预览行数',
  176. minValue: 0,
  177. allowDecimals:false,
  178. name: 'RN',
  179. value: 10,
  180. id: 'RN'
  181. }]},{
  182. xtype: 'grid',
  183. anchor: '100% 80%',
  184. id : 'configGrid',
  185. name : 'configGrid',
  186. columns : [],
  187. emptyText : "暂无数据",
  188. store:[],
  189. items : []
  190. }],
  191. buttons:[{
  192. text : '预览',
  193. flag : 'confirm',
  194. height : 26,
  195. handler : function(b) {
  196. var params=Ext.getCmp('paramsForm').getValues();
  197. var keys = Ext.Object.getKeys(params);
  198. var reg = /[!@#$%^&*()'":,\/?]/;
  199. Ext.each(keys, function(k){
  200. params[k] = params[k].trim().toUpperCase().replace(reg, '');
  201. });
  202. Ext.Ajax.request({
  203. url: basePath + 'common/charts/getPreviewDatas.action',
  204. params: {
  205. id: Ext.getCmp('id_').value,
  206. caller:caller,
  207. params:Ext.JSON.encode(params)
  208. },
  209. method: 'post',
  210. callback: function(options, success, response){
  211. var res = new Ext.decode(response.responseText);
  212. if(res.exceptionInfo) {
  213. showError(res.exceptionInfo);
  214. } else {
  215. var datas = res.datas; //获得后台传递json
  216. var fieldsNames=[];
  217. var columModle=[];
  218. if (datas.length>0){
  219. for(var item in datas[0]){
  220. fieldsNames.push({"name":item});
  221. columModle.push({"header":item,"dataIndex":item,"flex":1,"draggable":false});
  222. }
  223. }
  224. var store = Ext.create('Ext.data.Store', {
  225. fields :fieldsNames,
  226. data : datas
  227. });
  228. Ext.getCmp("configGrid").reconfigure(store, columModle); //定义grid的store和column
  229. Ext.getCmp("configGrid").render();
  230. }
  231. }});
  232. }
  233. },{
  234. text : '关 闭',
  235. flag : 'cancel',
  236. height : 26,
  237. handler : function(b) {
  238. b.ownerCt.ownerCt.close();
  239. }
  240. }]
  241. });
  242. win.show();
  243. }else window.location.reload();
  244. }
  245. }
  246. }
  247. });
  248. }
  249. }
  250. });
  251. },
  252. onGridItemClick: function(selModel, record){// grid行选择
  253. this.GridUtil.onGridItemClick(selModel, record);
  254. },
  255. getForm: function(btn){
  256. return btn.ownerCt.ownerCt;
  257. }
  258. });