TurnMakeWin.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. Ext.define('make.view.sale.saleforecast.TurnMakeWin', {
  2. extend: 'Ext.window.Window',
  3. xtype: 'sale-saleforecast-turnmakewin',
  4. cls: 'x-window-dbfind',
  5. modal: true,
  6. // width: 1300,
  7. // minHeight: 500,
  8. scrollable: true,
  9. bodyPadding: 10,
  10. constrain: true,
  11. closable: true,
  12. layout: 'fit',
  13. title: '转工单',
  14. _id:0,
  15. initComponent: function () {
  16. var me = this;
  17. Ext.apply(me, {
  18. baseUrl : '/api/sale/saleforecast/getTurnMakeData/',
  19. items:[{
  20. xtype: 'grid',
  21. selModel: {
  22. checkOnly: true,
  23. type: 'checkboxmodel',
  24. mode: "MULTI",
  25. ignoreRightMouseSelection: false
  26. },
  27. columns: [{
  28. text: 'ID',
  29. dataIndex: 'st_sdid',
  30. hidden: true,
  31. },{
  32. text: '本次数量',
  33. dataIndex: 'st_thisqty',
  34. width: 100,
  35. xtype: 'widgetcolumn',
  36. /*renderer : function(val, meta, record, x, y, store, view) {
  37. return val;
  38. }, */
  39. widget: {
  40. xtype: "numberfield",
  41. bind: '{record.st_thisqty}',
  42. decimalPrecision: 6,
  43. minValue: 0
  44. }
  45. },{
  46. text: '行号',
  47. dataIndex: 'st_sddetno',
  48. width: 80
  49. }, {
  50. text: '物料编号',
  51. dataIndex: 'st_prodcode',
  52. width: 150
  53. }, {
  54. text: '物料名称',
  55. dataIndex: 'st_proddetail',
  56. width: 150
  57. },{
  58. text: '型号',
  59. dataIndex: 'st_prodorispec',
  60. width: 150,
  61. renderer: function (v, m, r) {
  62. var str = '';
  63. if(r.data['st_prodbrand']){
  64. str += '厂家/品牌:'+ r.data['st_prodbrand'] + '<br>';
  65. }
  66. if(r.data['st_prodspec']){
  67. str += '规格:' + r.data['st_prodspec'];
  68. }
  69. if(str) m.tdAttr = 'data-qtip="'+ str +'"';
  70. return v;
  71. }
  72. },{
  73. text: '备货数量',
  74. dataIndex: 'st_sdqty',
  75. xtype: 'numbercolumn',
  76. renderer: function(v, m, r) {
  77. return saas.util.BaseUtil.numberFormat(v, 6, true);
  78. },
  79. },{
  80. text: '已核销数',
  81. dataIndex: 'st_yqty',
  82. xtype: 'numbercolumn',
  83. renderer: function(v, m, r) {
  84. return saas.util.BaseUtil.numberFormat(v, 6, true);
  85. },
  86. },{
  87. text: '已下达数量',
  88. dataIndex: 'st_tomakeqty',
  89. xtype: 'numbercolumn',
  90. renderer: function(v, m, r) {
  91. return saas.util.BaseUtil.numberFormat(v, 6, true);
  92. },
  93. },{
  94. text: '订单冲减工单数',
  95. dataIndex: 'sd_maqty',
  96. xtype: 'numbercolumn',
  97. width:140.0,
  98. renderer: function(v, m, r) {
  99. return saas.util.BaseUtil.numberFormat(v, 6, true);
  100. },
  101. },{
  102. text: '安全库存',
  103. dataIndex: 'st_prodsafetystock',
  104. xtype: 'numbercolumn',
  105. renderer: function(v, m, r) {
  106. return saas.util.BaseUtil.numberFormat(v, 6, true);
  107. },
  108. },{
  109. text: '总需求数',
  110. dataIndex: 'st_needqty',
  111. xtype: 'numbercolumn',
  112. renderer: function (v, m, r) {
  113. return saas.util.BaseUtil.numberFormat(v, 6, true);
  114. }
  115. }, {
  116. text: '总供应数',
  117. dataIndex: 'st_supplyqty',
  118. xtype: 'numbercolumn',
  119. renderer: function (v, m, r) {
  120. return saas.util.BaseUtil.numberFormat(v, 6, true);
  121. }
  122. }, {
  123. text: '供需平衡',
  124. dataIndex: 'st_balance',
  125. xtype: 'numbercolumn',
  126. renderer: function (v, m, r) {
  127. v = (r.get('st_supplyqty')||0) - (r.get('st_needqty')||0),
  128. v = saas.util.BaseUtil.numberFormat(v, 6, true);
  129. return v<0?'<font color="#FF0000">'+v+'</font>':v;
  130. }
  131. }],
  132. store: {
  133. autoLoad: true,
  134. fields: [
  135. { name: 'st_thisqty', type: 'float' },
  136. { name: 'st_sddetno', type: 'int' },
  137. { name: 'st_sdid', type: 'int' },
  138. { name: 'st_prodcode', type: 'string' },
  139. { name: 'st_proddetail', type: 'string' },
  140. { name: 'st_prodspec', type: 'string' },
  141. { name: 'st_prodorispec', type: 'string' },
  142. { name: 'st_prodbrand', type: 'string' },
  143. { name: 'st_produnit', type: 'string' },
  144. { name: 'st_sdqty', type: 'float' },
  145. { name: 'st_tomakeqty', type: 'float' },
  146. { name: 'st_needqty', type: 'float' },
  147. { name: 'st_supplyqty', type: 'float' },
  148. { name: 'st_prodid', type: 'int' },
  149. { name: 'st_said', type: 'int' },
  150. { name: 'st_sfid', type: 'int' },
  151. { name: 'st_yqty', type: 'float' },
  152. { name: 'sd_maqty', type: 'float' },
  153. ],
  154. proxy: {
  155. type: 'ajax',
  156. url: '/api/sale/saleforecast/getTurnMakeData',
  157. timeout: 8000,
  158. actionMethods: {
  159. read: 'GET'
  160. },
  161. reader: {
  162. type: 'json',
  163. rootProperty: 'data',
  164. totalProperty: '',
  165. },
  166. listeners: {
  167. exception: function (proxy, response, operation, eOpts) {
  168. if (operation.success) {
  169. if (response.timedout) {
  170. saas.util.BaseUtil.showErrorToast('请求超时');
  171. }
  172. } else {
  173. if (response.timedout) {
  174. saas.util.BaseUtil.showErrorToast('请求超时');
  175. } else {
  176. console.error('exception: ', response);
  177. var message = response.responseJson ? (response.responseJson.message == null ? '没有数据' : response.responseJson.message) : '请求超时';
  178. saas.util.BaseUtil.showErrorToast('查询失败:' + message);
  179. }
  180. }
  181. }
  182. }
  183. },
  184. listeners: {
  185. beforeload: function (store, op) {
  186. store.getProxy().url = me.baseUrl + me._id;
  187. },
  188. load: function (store, records, successful, operation, eOpts) {
  189. }
  190. }
  191. },
  192. buttonAlign: 'center',
  193. buttons: [{
  194. text: '确认',
  195. handler: me.handleSave
  196. }, {
  197. text: '关闭',
  198. handler: me.handleClose
  199. }]
  200. }],
  201. })
  202. me.callParent();
  203. },
  204. handleClose: function(btn){
  205. btn.ownerCt.ownerCt.ownerCt.close();
  206. },
  207. handleSave:function(btn){
  208. var me = this,
  209. win = me.ownerCt.ownerCt.ownerCt;
  210. var data = win.getGridSelected();
  211. if(data && data.length>0){
  212. win.setLoading(true);
  213. var params = JSON.stringify(data);
  214. saas.util.BaseUtil.request({
  215. url: '/api/sale/saleforecast/turnMake',
  216. params: params,
  217. method: 'POST',
  218. async:false
  219. })
  220. .then(function(res) {
  221. if (res.success) {
  222. win.setLoading(false);
  223. win.handleClose(btn);
  224. //刷新销售订单页面
  225. saas.util.FormUtil.loadData(win._parent);
  226. saas.util.BaseUtil.showSuccessToast('生成工单成功,单号:'+res.data);
  227. }
  228. })
  229. .catch(function(res) {
  230. win.setLoading(false);
  231. saas.util.BaseUtil.showErrorToast(('操作失败: ') + res.message);
  232. });
  233. }else{
  234. saas.util.BaseUtil.showErrorToast('请勾选至少一条有效明细。');
  235. }
  236. },
  237. /**
  238. *获取grid 数据
  239. */
  240. getGridSelected:function(){
  241. var me = this,
  242. grid = me.down('grid');
  243. items = grid.selModel.getSelection(),
  244. data = new Array() ;
  245. var ids=[];
  246. Ext.each(items, function(item, index){
  247. var o = new Object();
  248. if(item.data['st_thisqty']>0){
  249. o['st_thisqty'] = item.data['st_thisqty'];
  250. o['st_sdid'] = item.data['st_sdid'];
  251. o['st_sfid'] = item.data['st_sfid'];
  252. o['st_prodid'] = item.data['st_prodid'];
  253. o['st_prodcode'] = item.data['st_prodcode'];
  254. o['st_planenddate'] = item.data['st_planenddate'];
  255. data.push(o);
  256. }
  257. });
  258. return data;
  259. }
  260. })