BomCompareGrid.js 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. Ext.define('saas.view.make.bom.BomCompareGrid', {
  2. extend: 'Ext.grid.Panel',
  3. xtype: 'make-bom-bomcomparegrid',
  4. requires: [
  5. 'Ext.grid.plugin.Exporter'
  6. ],
  7. cls: 'core-base-gridpanel',
  8. plugins: [{
  9. ptype: 'gridexporter',
  10. }, {
  11. ptype: 'menuclipboard'
  12. }, {
  13. ptype: 'cellediting',
  14. clicksToEdit: 1
  15. }],
  16. layout: 'fit',
  17. border: 1,
  18. width: '100%',
  19. loadMask: true,
  20. columns: [{
  21. text: '物料编号',
  22. dataIndex: 'bc_soncode',
  23. width: 180
  24. }, {
  25. text: '物料名称',
  26. dataIndex: 'pr_detail',
  27. width: 150
  28. }, {
  29. text: '型号',
  30. dataIndex: 'pr_orispeccode',
  31. width: 200
  32. }, {
  33. text: '单位',
  34. dataIndex: 'pr_unit',
  35. width: 65
  36. }, {
  37. text: '产品编号1',
  38. dataIndex: 'bc_code1',
  39. width: 150
  40. }, {
  41. text: '产品编号2',
  42. dataIndex: 'bc_code2',
  43. width: 150
  44. }, {
  45. text: '产品编号3',
  46. dataIndex: 'bc_code3',
  47. width: 150
  48. }, {
  49. text: '产品编号4',
  50. dataIndex: 'bc_code4',
  51. width: 150
  52. }, {
  53. text: '产品编号5',
  54. dataIndex: 'bc_code5',
  55. width: 150
  56. }, {
  57. text: '产品位号1',
  58. dataIndex: 'bc_location1',
  59. width: 150
  60. }, {
  61. text: '产品位号2',
  62. dataIndex: 'bc_location2',
  63. width: 150
  64. }, {
  65. text: '产品位号3',
  66. dataIndex: 'bc_location3',
  67. width: 150
  68. }, {
  69. text: '产品位号4',
  70. dataIndex: 'bc_location4',
  71. width: 150
  72. }, {
  73. text: '产品位号5',
  74. dataIndex: 'bc_location5',
  75. width: 150
  76. }],
  77. initComponent: function () {
  78. var me = this;
  79. var fields = me.columns.map(column => column.dataIndex);
  80. me.store = Ext.create('Ext.data.Store', {
  81. fields: fields,
  82. autoLoad: true,
  83. data: []
  84. });
  85. Ext.apply(me, {
  86. dockedItems: [{
  87. xtype: 'toolbar',
  88. dock: 'top',
  89. items: [{
  90. xtype: 'checkbox',
  91. name: 'single',
  92. columnWidth: 0.3,
  93. margin: '0 5 0 5',
  94. isFilter: true,
  95. boxLabel: '单阶对比',
  96. checked: false,
  97. bind:'{single}',
  98. getFilter: function () {
  99. },
  100. listeners: {
  101. change: function () {
  102. }
  103. }
  104. }, {
  105. xtype: 'checkbox',
  106. name: 'differ',
  107. boxLabel: '只显示有差异物料',
  108. checked: false,
  109. margin: '0 5 0 5',
  110. columnWidth: 0.3,
  111. bind:'{differ}',
  112. getFilter: function () {
  113. },
  114. listeners: {
  115. change: function () {
  116. }
  117. }
  118. }, {
  119. xtype: 'checkbox',
  120. name: 'noCompareLocation',
  121. boxLabel: '不考虑位号',
  122. checked: false,
  123. margin: '0 5 0 5',
  124. columnWidth: 0.3,
  125. bind:'{noCompareLocation}',
  126. getFilter: function () {
  127. },
  128. listeners: {
  129. change: function () {
  130. }
  131. }
  132. }, '->', {
  133. text: '查询',
  134. cls: 'x-formpanel-btn-blue',
  135. handler: me.onQuery
  136. }, {
  137. text: '导出',
  138. handler: me.onExport
  139. }]
  140. }]
  141. });
  142. me.callParent(arguments);
  143. },
  144. onQuery: function () {
  145. var grid = this.ownerCt.ownerCt;
  146. panel = this.up('make-bom-bomcompare'),
  147. vm = panel.getViewModel();
  148. vmCodes = panel.getViewModel().get("form");
  149. var codes = [];
  150. for (var index in vmCodes) {
  151. var da = vmCodes[index];
  152. if("" != da && null != da && codes.indexOf(da) == -1){
  153. codes.push(da);
  154. }
  155. }
  156. if(codes.length == 0){
  157. saas.util.BaseUtil.showErrorToast("请选择需要对比的产品编号");
  158. }
  159. var params = JSON.stringify( {codes:codes.toString(),differ:vm.get('differ'),single:vm.get('single'),noCompareLocation:vm.get('noCompareLocation')});
  160. panel.setLoading(true);
  161. saas.util.BaseUtil.request({
  162. url: '/api/make/bom/bomCompare',
  163. params : params,
  164. method: 'POST',
  165. })
  166. .then(function (localJson) {
  167. panel.setLoading(false);
  168. if (localJson.success) {
  169. grid.store.loadData(localJson.data);
  170. }
  171. })
  172. .catch(function (e) {
  173. panel.setLoading(false);
  174. saas.util.BaseUtil.showErrorToast('对比失败 ' + e.message);
  175. });
  176. },
  177. onExport: function () {
  178. var grid = this.ownerCt.ownerCt;
  179. var cfg = {
  180. type: 'xlsx',
  181. title: 'BOM差异比对',
  182. fileName: 'BOM差异比对' + Ext.Date.format(new Date(), 'Y-m-d_H-i-s') + '.xlsx'
  183. };
  184. grid.setLoading(true);
  185. grid.saveDocumentAs(cfg);
  186. Ext.defer(function () {
  187. grid.setLoading(false);
  188. }, 5000);
  189. }
  190. });