AcceptNotify.js 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.scm.purchase.AcceptNotify', {
  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:[
  8. 'core.form.Panel','scm.purchase.AcceptNotify','core.grid.Panel2','core.toolbar.Toolbar','core.form.MultiField',
  9. 'core.button.Save','core.button.Add','core.button.Submit','core.button.Print','core.button.ResAudit',
  10. 'core.button.Audit','core.button.Close','core.button.Delete','core.button.Update','core.button.DeleteDetail',
  11. 'core.button.ResSubmit','core.button.Flow','core.trigger.MultiDbfindTrigger','core.button.VastTurnAccept',
  12. 'core.button.GridWin','core.button.TurnPurcProdIO','core.button.BackAll',
  13. 'core.trigger.DbfindTrigger','core.trigger.TextAreaTrigger','core.form.YnField'
  14. ],
  15. init:function(){
  16. var me = this;
  17. this.control({
  18. 'erpGridPanel2': {
  19. itemclick: this.onGridItemClick
  20. },
  21. '#updateacceptqty': {
  22. click: function(btn) {
  23. var record = btn.ownerCt.ownerCt.getSelectionModel().getLastSelected();
  24. me.updatebackqty(record);
  25. }
  26. },
  27. 'erpBackAllButton':{
  28. click:function(btn){
  29. warnMsg('该操作将拒收明细所有物料,确认拒收?', function(btn){
  30. if(btn == 'yes'){
  31. me.FormUtil.setLoading(true);
  32. var id=Ext.getCmp('an_id').getValue();
  33. Ext.Ajax.request({
  34. url : basePath + 'scm/purchase/backAll.action',
  35. params: {
  36. id: id
  37. },
  38. method : 'post',
  39. callback : function(options,success,response){
  40. me.FormUtil.setLoading(false);
  41. var localJson = new Ext.decode(response.responseText);
  42. if(localJson.exceptionInfo){
  43. showError(localJson.exceptionInfo);return;
  44. }
  45. if(localJson.success){
  46. showMessage('提示', '拒收成功!', 1000);
  47. window.location.reload();
  48. } else {
  49. delFailure();
  50. }
  51. }
  52. });
  53. }
  54. });
  55. }
  56. },
  57. 'erpGridWinButton':{
  58. afterrender: function(btn){
  59. var id = Ext.getCmp('an_id').value;
  60. btn.setConfig({
  61. text: '费用明细',
  62. caller: 'ProdChargeDetail!AN',
  63. condition: 'pd_anid=' + id,
  64. paramConfig: {
  65. pd_anid: id
  66. }
  67. });
  68. },
  69. beforesave : function(btn) {
  70. var f = btn.ownerCt.ownerCt, p = f.down('field[name=an_statuscode]');
  71. if (p && 'TURNIN' == p.getValue()) {
  72. Ext.Msg.alert("提示","该单据已入库,不能修改费用明细!");
  73. return false;
  74. }
  75. return true;
  76. }
  77. },
  78. 'erpSaveButton': {
  79. click: function(btn){
  80. var me = this;
  81. var form = me.getForm(btn);
  82. var grid = Ext.getCmp('grid'), items = grid.store.data.items;
  83. var whcode = Ext.getCmp('an_whcode'), whname = Ext.getCmp('an_whname');
  84. if(Ext.getCmp(form.codeField).value == null || Ext.getCmp(form.codeField).value == ''){
  85. me.BaseUtil.getRandomNumber();//自动添加编号
  86. }
  87. Ext.Array.each(items, function(item){
  88. if(!Ext.isEmpty(item.data['and_prodcode'])){
  89. if(whcode && item.data['and_whcode'] == null || item.data['and_whcode'] == ''){
  90. item.set('and_whcode', whcode.value);
  91. item.set('and_whname', whname.value);
  92. }
  93. }
  94. });
  95. this.FormUtil.beforeSave(this);
  96. }
  97. },
  98. 'erpDeleteButton' : {
  99. click: function(btn){
  100. me.FormUtil.onDelete(Ext.getCmp('an_id').value);
  101. }
  102. },
  103. 'erpUpdateButton': {
  104. click: function(btn){
  105. var me = this;
  106. var grid = Ext.getCmp('grid'), items = grid.store.data.items;
  107. var whcode = Ext.getCmp('an_whcode'), whname = Ext.getCmp('an_whname');
  108. Ext.Array.each(items, function(item){
  109. if(!Ext.isEmpty(item.data['and_prodcode'])){
  110. if(whcode && item.data['and_whcode'] == null || item.data['and_whcode'] == ''){
  111. item.set('and_whcode', whcode.value);
  112. item.set('and_whname', whname.value);
  113. }
  114. }
  115. });
  116. this.FormUtil.onUpdate(this);
  117. }
  118. },
  119. 'erpAddButton': {
  120. click: function(){
  121. me.FormUtil.onAdd('addAcceptNotify', '新增采购通知单', 'jsps/scm/purchase/acceptNotify.jsp');
  122. }
  123. },
  124. 'erpCloseButton': {
  125. click: function(btn){
  126. me.FormUtil.beforeClose(me);
  127. }
  128. },
  129. 'erpSubmitButton': {
  130. afterrender: function(btn){
  131. var status = Ext.getCmp('an_statuscode');
  132. if(status && status.value != 'ENTERING'){
  133. btn.hide();
  134. }
  135. },
  136. click: function(btn){
  137. me.FormUtil.onSubmit(Ext.getCmp('an_id').value);
  138. }
  139. },
  140. 'erpResSubmitButton': {
  141. afterrender: function(btn){
  142. var status = Ext.getCmp('an_statuscode');
  143. if(status && status.value != 'COMMITED'){
  144. btn.hide();
  145. }
  146. },
  147. click: function(btn){
  148. me.FormUtil.onResSubmit(Ext.getCmp('an_id').value);
  149. }
  150. },
  151. 'erpAuditButton': {
  152. afterrender: function(btn){
  153. var status = Ext.getCmp('an_statuscode');
  154. if(status && status.value != 'COMMITED'){
  155. btn.hide();
  156. }
  157. },
  158. click: function(btn){
  159. me.FormUtil.onAudit(Ext.getCmp('an_id').value);
  160. }
  161. },
  162. 'erpResAuditButton': {
  163. afterrender: function(btn){
  164. var status = Ext.getCmp('an_statuscode');
  165. if(status && status.value != 'AUDITED'){
  166. btn.hide();
  167. }
  168. },
  169. click: function(btn){
  170. me.FormUtil.onResAudit(Ext.getCmp('an_id').value);
  171. }
  172. },
  173. 'erpPrintButton': {
  174. click: function(btn){
  175. var reportName = '';
  176. reportName = "vendororder";
  177. var condition = '{AcceptNotify.an_id}=' + Ext.getCmp('an_id').value + '';
  178. var id = Ext.getCmp('an_id').value;
  179. me.FormUtil.onwindowsPrint(id, reportName, condition);
  180. }
  181. },
  182. 'field[name=an_currency]': {
  183. beforetrigger: function(field) {
  184. var t = field.up('form').down('field[name=an_date]'),
  185. value = t.getValue();
  186. if(value) {
  187. field.findConfig = 'cm_yearmonth=' + Ext.Date.format(value, 'Ym');
  188. }
  189. }
  190. },
  191. 'erpVastTurnAcceptButton':{
  192. afterrender: function(btn){
  193. var status = Ext.getCmp('an_statuscode');
  194. if(status && status.value != 'AUDITED' && status.value != 'PART2VA'){
  195. btn.hide();
  196. }
  197. },
  198. click: function(btn){
  199. warnMsg("确定要转入采购收料单吗?", function(btn){
  200. if(btn == 'yes'){
  201. me.FormUtil.getActiveTab().setLoading(true);//loading...
  202. Ext.Ajax.request({
  203. url : basePath + 'scm/purchase/turnVerifyApply.action',
  204. params: {
  205. id: Ext.getCmp('an_id').value
  206. },
  207. method : 'post',
  208. callback : function(options,success,response){
  209. me.FormUtil.getActiveTab().setLoading(false);
  210. var r = new Ext.decode(response.responseText);
  211. if(r.exceptionInfo){
  212. showError(r.exceptionInfo);
  213. }
  214. if(r.success){
  215. turnSuccess(function(){
  216. var id = r.id;
  217. var url = "jsps/scm/purchase/verifyApply.jsp?whoami=VerifyApply&formCondition=va_id=" + id + "&gridCondition=vad_vaid=" + id;
  218. me.FormUtil.onAdd('VerifyApply' + id, '采购收料单' + id, url);
  219. });
  220. }
  221. }
  222. });
  223. }
  224. });
  225. }
  226. },
  227. 'erpTurnPurcProdIOButton':{
  228. afterrender: function(btn){
  229. var status = Ext.getCmp('an_statuscode');
  230. if(status && status.value != 'AUDITED'){
  231. btn.hide();
  232. }
  233. },
  234. click: function(btn){
  235. warnMsg("确定要转入采购验收单吗?", function(btn){
  236. if(btn == 'yes'){
  237. var id = Ext.getCmp('an_id').value;
  238. me.FormUtil.setLoading(true);//loading...
  239. Ext.Ajax.request({
  240. url : basePath + 'scm/purchase/turnProdio.action',
  241. params: {
  242. id: id
  243. },
  244. method : 'post',
  245. callback : function(options,success,response){
  246. me.FormUtil.setLoading(false);
  247. var r = new Ext.decode(response.responseText);
  248. if(r.exceptionInfo){
  249. showError(r.exceptionInfo);
  250. } else {
  251. if(r.log) {
  252. showMessage('提示', r.log);
  253. var grid = Ext.getCmp('grid');
  254. grid.GridUtil.loadNewStore(grid, {
  255. caller: caller,
  256. condition: 'and_anid=' + id
  257. });
  258. }
  259. }
  260. }
  261. });
  262. }
  263. });
  264. }
  265. },
  266. 'dbfindtrigger[name=and_ordercode]': {
  267. focus: function(t){
  268. t.setHideTrigger(false);
  269. t.setReadOnly(false);
  270. if(Ext.getCmp('an_vendcode')){
  271. var code = Ext.getCmp('an_vendcode').value;
  272. if(code != null && code != ''){
  273. t.dbBaseCondition = "pu_vendcode" + "='" + code + "'";
  274. }
  275. }
  276. },
  277. aftertrigger: function(t, r) {
  278. if(Ext.getCmp('an_vendcode')){
  279. var obj = me.getCodeCondition();
  280. if(obj && obj.fields){
  281. me.FormUtil.getFieldsValue(obj.tablename, obj.fields, obj.myfield + "='" + t.value + "'", obj.tFields);
  282. }
  283. }
  284. }
  285. },
  286. 'multidbfindtrigger[name=and_orderdetno]': {
  287. focus: function(t){
  288. t.setHideTrigger(false);
  289. t.setReadOnly(false);//用disable()可以,但enable()无效
  290. var record = Ext.getCmp('grid').selModel.lastSelected;
  291. var code = record.data['and_ordercode'];
  292. if(code == null || code == ''){
  293. showError("请先选择关联单号!");
  294. t.setHideTrigger(true);
  295. t.setReadOnly(true);
  296. } else {
  297. t.dbBaseCondition = "pd_code='" + code + "'";
  298. }
  299. }
  300. },
  301. 'dbfindtrigger[name=and_orderdetno]': {
  302. focus: function(t){
  303. t.setHideTrigger(false);
  304. t.setReadOnly(false);//用disable()可以,但enable()无效
  305. var record = Ext.getCmp('grid').selModel.lastSelected;
  306. var code = record.data['and_ordercode'];
  307. if(code == null || code == ''){
  308. showError("请先选择关联单号!");
  309. t.setHideTrigger(true);
  310. t.setReadOnly(true);
  311. } else {
  312. t.dbBaseCondition = "pd_code='" + code + "'";
  313. }
  314. }
  315. }
  316. });
  317. },
  318. getCodeCondition: function(){
  319. var field = "pu_vendcode";
  320. var tFields = 'an_cardcode,an_vendname,an_currency,an_rate,an_paymentcode,an_payment,an_transport,an_paydate,an_receivecode,an_receivename';
  321. var fields = 'pu_vendcode,pu_vendname,pu_currency,pu_rate,pu_paymentscode,pu_payments,pu_transport,pu_suredate,pu_receivecode,pu_receivename';
  322. var tablename = 'Purchase';
  323. var myfield = 'pu_code';
  324. var obj = new Object();
  325. obj.field = field;
  326. obj.fields = fields;
  327. obj.tFields = tFields;
  328. obj.tablename = tablename;
  329. obj.myfield = myfield;
  330. return obj;
  331. },
  332. updatebackqty: function(record) {
  333. var me = this;
  334. var win=Ext.create('Ext.window.Window', {
  335. width: 430,
  336. height: 250,
  337. closeAction: 'destroy',
  338. title: '<h1>更改收料数量</h1>',
  339. layout: {
  340. type: 'vbox'
  341. },
  342. items: [{
  343. margin: '5 0 0 5',
  344. xtype: 'numberfield',
  345. fieldLabel: '数量',
  346. name: 'QTYREPLY',
  347. hideTrigger: true,
  348. value: record.data.and_inqty,
  349. id: 'QTYREPLY'
  350. }],
  351. buttonAlign: 'center',
  352. buttons: [{
  353. xtype: 'button',
  354. text: '保存',
  355. width: 60,
  356. iconCls: 'x-button-icon-save',
  357. handler: function(btn) {
  358. var w = btn.up('window');
  359. me.saveInfo(w);
  360. win.close();
  361. win.destroy();
  362. }
  363. },
  364. {
  365. xtype: 'button',
  366. columnWidth: 0.1,
  367. text: '关闭',
  368. width: 60,
  369. iconCls: 'x-button-icon-close',
  370. margin: '0 0 0 10',
  371. handler: function(btn) {
  372. var win = btn.up('window');
  373. win.close();
  374. win.destroy();
  375. }
  376. }]
  377. });
  378. win.show();
  379. },
  380. saveInfo: function(w) {
  381. var qty = w.down('field[name=QTYREPLY]').getValue();
  382. grid = Ext.getCmp('grid'),
  383. record = grid.getSelectionModel().getLastSelected();
  384. if (qty == null || qty < 0) {
  385. showError('请先设置修改数量');
  386. return;
  387. } else {
  388. var dd = {
  389. and_id: record.data.and_id,
  390. and_inqty: qty ? qty: 0
  391. };
  392. Ext.Ajax.request({
  393. url: basePath + 'scm/purchase/saveAcceptNotifyQty.action',
  394. params: {
  395. data: unescape(Ext.JSON.encode(dd)),
  396. caller: caller
  397. },
  398. method: 'post',
  399. callback: function(opt, s, res) {
  400. var r = new Ext.decode(res.responseText);
  401. if (r.success) {
  402. grid.GridUtil.loadNewStore(grid, {
  403. caller: caller,
  404. condition: gridCondition
  405. });
  406. showMessage('提示', '更新成功!', 1000);
  407. } else if (r.exceptionInfo) {
  408. showError(r.exceptionInfo);
  409. } else {
  410. saveFailure();
  411. }
  412. }
  413. });
  414. }
  415. },
  416. onGridItemClick: function(selModel, record) { //grid行选择
  417. if (record.data.and_id != 0 && record.data.and_id != null && record.data.and_id != '' && (record.data.and_yqty==0 || record.data.and_yqty==null )) {
  418. var btn = Ext.getCmp('updateacceptqty');
  419. btn && btn.setDisabled(false);
  420. }
  421. this.GridUtil.onGridItemClick(selModel, record);
  422. },
  423. getForm: function(btn){
  424. return btn.ownerCt.ownerCt;
  425. }
  426. });