LabelPrintSetting.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.scm.reserve.LabelPrintSetting', {
  3. extend : 'Ext.app.Controller',
  4. FormUtil : Ext.create('erp.util.FormUtil'),
  5. GridUtil : Ext.create('erp.util.GridUtil'),
  6. BaseUtil : Ext.create('erp.util.BaseUtil'),
  7. views : ['scm.reserve.labelPrintSetting.Viewport','scm.reserve.labelPrintSetting.labelPrintSettingGrid','core.toolbar.Toolbar', 'core.button.Save', 'core.button.Add',
  8. 'core.button.Close', 'core.button.Update','core.button.DeleteDetail', 'core.button.Delete','core.trigger.DbfindTrigger', 'core.trigger.TextAreaTrigger',
  9. 'core.form.YnField'],
  10. init : function() {
  11. var me = this;
  12. this.control({
  13. 'erpLabelPrintSettingGrid' : {
  14. select : function(selModel, record, index) {
  15. var grid = Ext.getCmp('grid');
  16. if (index == grid.store.data.items.length - 1) {// 如果选择了最后一行
  17. me.add10EmptyData(grid);
  18. }
  19. me.itemclick(grid);
  20. }
  21. },
  22. 'erpSaveButton' : {
  23. click : function(btn) {
  24. var grid = Ext.getCmp('grid');
  25. var params = grid.getGridStore();
  26. if (params.length == 0) {
  27. showError("没有需要保存的数据!");
  28. return;
  29. }
  30. Ext.Ajax.request({
  31. url : basePath
  32. + 'scm/reserve/saveLabelPrintSetting.action',
  33. params : {
  34. param : params,
  35. caller : caller
  36. },
  37. method : 'post',
  38. callback : function(options, success, response) {
  39. // me.getActiveTab().setLoading(false);
  40. var res = new Ext.decode(response.responseText);
  41. if (res && res.exceptionInfo) {
  42. showError(res.exceptionInfo);
  43. return;
  44. } else {
  45. gridCondition = (gridCondition == null) ? "":gridCondition.replace(/IS/g,"=");
  46. grid.GridUtil.loadNewStore(grid, {caller : caller,condition : gridCondition});
  47. }
  48. }
  49. });
  50. }
  51. },
  52. 'text[name=lps_lasql]' : {
  53. focus : function() {
  54. var record = Ext.getCmp('grid').selModel.getLastSelected();
  55. var code = record.data['lps_lacode'];
  56. if (type == '' || type == null) {
  57. showError("请先选择标签编号 !");
  58. }
  59. }
  60. },
  61. 'erpCloseButton' : {
  62. click : function(btn) {
  63. me.FormUtil.beforeClose(me);
  64. }
  65. },
  66. 'erpDeleteButton' : {
  67. click : function(btn) {
  68. var grid = Ext.getCmp('grid');
  69. var s = grid.getStore().data.items;
  70. var bool = false;
  71. Ext.each(s,function (item,index){
  72. if(this.data['lps_id'] != ''&& this.data['lps_id'] != '0' && this.data['lps_id'] != 0){
  73. bool = true;
  74. }
  75. });
  76. if(!bool){
  77. showError("没有需要删除的数据!");
  78. return;
  79. }
  80. warnMsg($I18N.common.msg.ask_del_main, function(btn){
  81. if(btn == 'yes'){
  82. Ext.Ajax.request({
  83. url : basePath+ 'scm/reserve/deleteLabelPrintSetting.action',
  84. params : {
  85. lps_caller : lps_caller,
  86. caller : caller
  87. },
  88. method : 'post',
  89. callback : function(options, success, response) {
  90. // me.getActiveTab().setLoading(false);
  91. var res = new Ext.decode(response.responseText);
  92. if (res && res.exceptionInfo) {
  93. showError(res.exceptionInfo);return;
  94. } else {
  95. delSuccess(function(){
  96. this.onClose();
  97. });//
  98. gridCondition = (gridCondition == null)? "": gridCondition.replace(/IS/g,"=");
  99. grid.getGridColumnsAndStore({caller :caller,condition : gridCondition});}
  100. }
  101. });
  102. }
  103. });
  104. }
  105. }
  106. });
  107. },
  108. add10EmptyData : function(grid) {
  109. var data = new Array();
  110. var items = grid.store.data.items;
  111. for (var i = 0; i < 10; i++) {
  112. var o = new Object();
  113. o.lps_caller = lps_caller;
  114. o.lps_laid = null;
  115. o.lps_lacode = null;
  116. o.lps_id = null;
  117. o.lps_sql = null;
  118. data.push(o);
  119. }
  120. grid.store.insert(items.length, data);
  121. },
  122. itemclick : function(grid) {
  123. var btn = grid.down('erpDeleteDetailButton');
  124. if (btn)
  125. btn.setDisabled(false);
  126. btn = grid.down('erpAddDetailButton');
  127. if (btn)
  128. btn.setDisabled(false);
  129. btn = grid.down('copydetail');
  130. if (btn)
  131. btn.setDisabled(false);
  132. btn = grid.down('pastedetail');
  133. if (btn)
  134. btn.setDisabled(false);
  135. btn = grid.down('updetail');
  136. if (btn)
  137. btn.setDisabled(false);
  138. btn = grid.down('downdetail');
  139. if (btn)
  140. btn.setDisabled(false);
  141. }
  142. });