CopyConfig.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.ma.CopyConfig', {
  3. extend:'Ext.app.Controller',
  4. GridUtil: Ext.create('erp.util.GridUtil'),
  5. views:[
  6. 'ma.copy.CopyConfig',
  7. 'ma.copy.Form',
  8. 'ma.copy.GridPanel',
  9. 'core.button.Update',
  10. 'core.button.Close',
  11. 'core.button.DeleteDetail',
  12. 'core.trigger.DbfindTrigger'
  13. ],
  14. init:function(){
  15. var me = this;
  16. this.control({
  17. 'erpCopyGridPanel': {
  18. itemclick: me.onGridItemClick
  19. },
  20. 'erpUpdateButton': {
  21. click:me.onUpdate
  22. },
  23. 'erpDeleteDetailButton':{
  24. click:me.ondelete
  25. }
  26. });
  27. },
  28. ondelete:function(btn){
  29. var me = this;
  30. var grid = btn.grid ||btn.ownerCt.ownerCt;
  31. //解决针对两个从表无法控制多个从表的权限
  32. var records = grid.selModel.getSelection();
  33. var condition = "cc_caller='"+Ext.getCmp('cc_caller').value+"' AND cc_field='"+records[0].data['cc_field']+"' AND cc_findkind='"+records[0].data['cc_findkind']+"'";
  34. if(records.length > 0){
  35. warnMsg($I18N.common.msg.ask_del, function(btn){
  36. if(btn == 'yes'){
  37. Ext.Ajax.request({
  38. url : basePath + "/ma/setting/deleteCopyConfigs.action",
  39. params: {
  40. condition:condition
  41. },
  42. method : 'post',
  43. callback : function(options,success,response){
  44. var localJson = new Ext.decode(response.responseText);
  45. if(localJson.exceptionInfo){
  46. showError(localJson.exceptionInfo);return;
  47. }
  48. if(localJson.success){
  49. grid.store.remove(records[0]);
  50. delSuccess(function(){
  51. });//@i18n/i18n.js
  52. } else {
  53. delFailure();
  54. }
  55. }
  56. });
  57. }
  58. });
  59. }
  60. }
  61. ,
  62. onUpdate: function() {
  63. //更新
  64. var grid = Ext.getCmp('grid');
  65. var param = this.GridUtil.getGridStore();
  66. if(grid.necessaryField.length > 0 && (param == null || param == '')){
  67. showError('明细表还未添加数据');return;
  68. }
  69. if(param == null || param == '' || param.length ==0){
  70. showError('数据未发生修改');return;
  71. }
  72. Ext.Ajax.request({
  73. url : basePath + '/ma/setting/updateCopyConfigs.action',
  74. params:{
  75. gridStore:param,
  76. caller:caller,
  77. formCaller:Ext.getCmp('cc_caller').value
  78. },
  79. method : 'post',
  80. callback : function(options,success,response){
  81. var localJson = new Ext.decode(response.responseText);
  82. if(localJson.exceptionInfo){
  83. showError(localJson.exceptionInfo);return;
  84. }
  85. if(localJson.success){
  86. showMessage('提示', '更新成功!', 1000);
  87. //update成功后刷新页面进入可编辑的页面
  88. var u = String(window.location.href);
  89. if (u.indexOf('formCondition') == -1) {
  90. var value = r[form.keyField];
  91. var formCondition = form.keyField + "IS" + value ;
  92. var gridCondition = '';
  93. var grid = Ext.getCmp('grid');
  94. if(grid && grid.mainField){
  95. gridCondition = grid.mainField + "IS" + value;
  96. }
  97. if(me.contains(window.location.href, '?', true)){
  98. window.location.href = window.location.href + '&formCondition=' +
  99. formCondition + '&gridCondition=' + gridCondition;
  100. } else {
  101. window.location.href = window.location.href + '?formCondition=' +
  102. formCondition + '&gridCondition=' + gridCondition;
  103. }
  104. } else {
  105. window.location.reload();
  106. }
  107. }
  108. }
  109. });
  110. },
  111. onGridItemClick: function(selModel, record) { //grid行选择
  112. this.GridUtil.onGridItemClick(selModel, record);
  113. }
  114. });