GetMaster.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. /**
  2. * 选择账套
  3. */
  4. Ext.define('erp.view.core.button.GetMaster', {
  5. extend : 'Ext.Button',
  6. alias : 'widget.erpGetMasterButton',
  7. iconCls : 'x-button-icon-query',
  8. cls : 'x-btn-gray',
  9. text : $I18N.common.button.erpGetMasterButton,
  10. style : {
  11. marginLeft : '10px'
  12. },
  13. width : 80,
  14. initComponent : function() {
  15. this.callParent(arguments);
  16. this.addEvents({'confirm': true});
  17. },
  18. handler: function(btn) {
  19. var win = btn.win;
  20. if (!win) {
  21. win = Ext.create('Ext.Window', {
  22. title: btn.text,
  23. width: 700,
  24. height: 400,
  25. layout: 'fit',
  26. items: [{
  27. xtype: 'form',
  28. autoScroll: true,
  29. bodyStyle: 'background: #f1f1f1;',
  30. layout: 'column',
  31. defaults: {
  32. xtype: 'checkbox',
  33. columnWidth: .5,
  34. margin: '5 0 0 5'
  35. },
  36. items: [{
  37. boxLabel: '全选',
  38. id: 'selectall',
  39. columnWidth: 1,
  40. listeners: {
  41. change: function(f) {
  42. var form = f.up('form');
  43. form.getForm().getFields().each(function(a){
  44. if(a.id != f.id) {
  45. a.setValue(f.value);
  46. }
  47. });
  48. }
  49. }
  50. }]
  51. }],
  52. buttonAlign: 'center',
  53. buttons: [{
  54. text: $I18N.common.button.erpConfirmButton,
  55. cls: 'x-btn-blue',
  56. handler: function(b) {
  57. b.up('window').hide();
  58. btn.fireEvent('confirm', btn, btn.getCheckData());
  59. }
  60. }, {
  61. text: $I18N.common.button.erpCloseButton,
  62. cls: 'x-btn-blue',
  63. handler: function(b) {
  64. b.up('window').hide();
  65. }
  66. }]
  67. });
  68. btn.win = win;
  69. this.getMasters();
  70. }
  71. win.show();
  72. },
  73. getMasters: function() {
  74. if (this.win) {
  75. var form = this.win.down('form');
  76. // 取账套配置,以及账套权限配置
  77. Ext.Ajax.request({
  78. url: basePath + 'common/getMasters.action',
  79. method: 'GET',
  80. callback: function(opt, s, r) {
  81. if (s) {
  82. var rs = Ext.decode(r.responseText),
  83. c = rs.currentMaster,
  84. g = rs.group,
  85. t = rs._type,
  86. m = rs._master,
  87. ms = new Array(),
  88. items = new Array();
  89. if(t != 'admin' && m != null) {
  90. ms = m.split(',');
  91. }
  92. for(var i in rs.masters) {
  93. var s = rs.masters[i];
  94. if("true" === g && "admin" !== t && !Ext.Array.contains(ms, s.ma_name))
  95. continue;
  96. if(s.ma_type == 3 || s.ma_type == 1) {
  97. var o = {
  98. boxLabel: s.ma_name + '(' + s.ma_function + ')',
  99. ma_user: s.ma_user
  100. };
  101. if (s.ma_name == c)
  102. o.checked = true;
  103. items.push(o);
  104. }
  105. }
  106. form.add(items);
  107. }
  108. }
  109. });
  110. }
  111. },
  112. getCheckData: function() {
  113. if (this.win) {
  114. var form = this.win.down('form'),
  115. items = form.query('checkbox[checked=true]'),
  116. data = new Array();
  117. Ext.each(items, function(item){
  118. if(item.ma_user)
  119. data.push(item.ma_user);
  120. });
  121. return data.join(',');
  122. }
  123. return null;
  124. }
  125. });