ProdInOut.js 63 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.scm.reserve.ProdInOut', {
  3. extend: 'Ext.app.Controller',
  4. requires: ['erp.util.FormUtil', 'erp.util.GridUtil', 'erp.util.BaseUtil'],
  5. views:[
  6. 'core.form.Panel','scm.reserve.ProdInOut','core.grid.Panel2','core.toolbar.Toolbar','core.form.MultiField','core.form.YnField',
  7. 'core.button.Save','core.button.Add','core.button.Submit','core.button.Print','core.button.PrintA4','core.button.Upload','core.button.ResAudit',
  8. 'core.button.Audit','core.button.Close','core.button.Delete','core.button.Update','core.button.DeleteDetail','core.button.ResSubmit',
  9. 'core.button.Banned','core.button.ResBanned','core.button.Post','core.button.ResPost','core.button.Query','core.button.GetPrice',
  10. 'core.button.RePrice','core.button.BussAccount','core.button.Export','core.form.FtFindField','core.form.ConDateField','core.button.UpdateWHCode',
  11. 'core.button.FeeShare', 'core.button.TurnDefectOut','core.button.Resetbatch','core.button.PrintwithPrice','core.button.tecai','core.button.GridWin',
  12. 'core.button.TurnExOut', 'core.trigger.DbfindTrigger','core.trigger.MultiDbfindTrigger','core.trigger.TextAreaTrigger','core.button.TurnProdinoutReturn',
  13. 'core.button.TurnProdinoutIn','core.button.UpdatePdprice', 'core.button.PrintNoPrice', 'core.button.PrintPrice','core.form.FileField','core.button.TurnOutReturn',
  14. 'core.button.Split','core.button.TurnReturn','core.button.PrintBar','core.button.Printotherin','core.button.Printotherout', 'core.button.TurnProdOut',
  15. 'core.button.TurnOtherIn', 'core.button.TurnOtherOut', 'core.button.TurnOtherPurcOut','core.button.TurnAppropriationOut','core.button.TurnCustReturnOut',
  16. 'core.button.ClearSubpackage','core.button.Subpackage','core.grid.YnColumn','core.button.CatchBatch','core.button.Printnosale','core.button.PrintNoCustomer',
  17. 'core.button.SetMMQTY','core.button.TurnSaleReturn','core.button.TurnMrb','core.button.Barcode','core.button.TurnReturnMake','core.button.SendData'
  18. ],
  19. init:function(){
  20. var me = this;
  21. var grid = Ext.getCmp('grid');
  22. me.FormUtil = Ext.create('erp.util.FormUtil');
  23. me.GridUtil = Ext.create('erp.util.GridUtil');
  24. me.BaseUtil = Ext.create('erp.util.BaseUtil');
  25. this.control({
  26. 'erpTurnReturnMakeButton':{//销售退货转返修工单
  27. afterrender:function(btn){
  28. var status = Ext.getCmp(me.getForm(btn).statuscodeField),
  29. postStatus = Ext.getCmp('pi_statuscode');
  30. if((status && status.value != 'AUDITED')||(postStatus&&postStatus.value!='POSTED')){
  31. btn.hide();
  32. }
  33. },
  34. click: function(btn){
  35. me.batchdeal('ProdInOut!SaleReturn', 'pd_piid=' + Ext.getCmp('pi_id').value,'scm/purchase/turnReturnMake.action');
  36. }
  37. },
  38. 'erpCatchBatchButton' : {
  39. afterrender: function(btn){
  40. var status = Ext.getCmp('pi_statuscode');
  41. if(status && status.value == 'POSTED'){
  42. btn.hide();
  43. }
  44. },
  45. click: function(btn){
  46. Ext.Ajax.request({
  47. url : basePath + 'scm/reserve/catchBatch.action',
  48. params: {
  49. id: Ext.getCmp('pi_id').value
  50. },
  51. method : 'post',
  52. callback : function(options,success,response){
  53. var res = new Ext.decode(response.responseText);
  54. if(res){
  55. if(res.exceptionInfo) {
  56. showMessage('提示', res.exceptionInfo);
  57. } else {
  58. if(res.log==null||res.log=='')
  59. showMessage('提示', '抓取成功');
  60. me.GridUtil.loadNewStore(grid,{
  61. caller:caller,
  62. condition:gridCondition
  63. });
  64. }
  65. }else{
  66. showMessage('提示', '抓取失败');
  67. }
  68. }
  69. });
  70. }
  71. },
  72. 'erpGridPanel2': {
  73. afterrender: function(grid){
  74. grid.plugins[0].on('beforeedit', function(args){
  75. if(args.field == "pd_inqty") {
  76. return me.isAllowUpdateQty(args.record);
  77. }
  78. });
  79. if(caller=='ProdInOut!SaleReturn'){
  80. if(Ext.getCmp('pi_sourcecode')&&Ext.getCmp('pi_sourcecode').value!=""){
  81. grid.readOnly = true;
  82. }
  83. }
  84. },
  85. // reconfigure: function(grid) {
  86. // var f = Ext.getCmp('pi_id');
  87. // if(caller == 'ProdInOut!OtherOut'){
  88. // if (f && !Ext.isEmpty(f.value)) {
  89. // me.loadOnHandQty(grid, f.value);
  90. // }
  91. // }
  92. // },
  93. itemclick: function(selModel, record){
  94. var bool = me.hasSource(selModel.ownerCt);
  95. if(caller == 'ProdInOut!OtherIn' || caller == 'ProdInOut!OtherPurcIn') {
  96. if(record.data.pd_id > 0){
  97. var btn = selModel.ownerCt.down('#erpEditSubpackageButton');
  98. if(btn && !btn.hidden)
  99. btn.setDisabled(false);
  100. }
  101. }
  102. if(record.data.pd_id != 0 && record.data.pd_id != null && record.data.pd_id != ''){
  103. var btn = Ext.getCmp('updatebgxh');
  104. btn && btn.setDisabled(false);
  105. btn = Ext.getCmp('barcodebtn');
  106. btn && btn.setDisabled(false);
  107. }
  108. if(!bool)
  109. this.GridUtil.onGridItemClick(selModel, record);
  110. }
  111. },
  112. /**
  113. * 更改报关型号
  114. */
  115. '#updatebgxh': {
  116. click: function(btn) {
  117. var record=btn.ownerCt.ownerCt.getSelectionModel().getLastSelected();
  118. me.Updatebgxh(record);
  119. }
  120. },
  121. 'erpBarcodeButton':{
  122. click: function(btn){
  123. var pdid=btn.ownerCt.ownerCt.ownerCt.items.items[1].selModel.selected.items[0].data["pd_id"];
  124. var id = Ext.getCmp("pi_id").value;
  125. var formCondition1="pd_idIS"+pdid+" and pi_idIS'"+id+"'";
  126. var gridCondition1="bi_pdidIS"+pdid+" and bi_piidIS'"+id+"'";
  127. var linkCaller ='';
  128. //获取出入库单DS_INOROUT字段判读是出库单还是入库单
  129. Ext.Ajax.request({
  130. url : basePath + '/pm/bom/getDescription.action',
  131. params: {
  132. tablename:"documentsetup" ,
  133. field:'ds_inorout',
  134. condition:"ds_name='"+Ext.getCmp("pi_class").value+"'",
  135. caller:caller
  136. },
  137. method : 'post',
  138. callback : function(options,success,response){
  139. var res = new Ext.decode(response.responseText);
  140. if(res.exceptionInfo) {
  141. showError(rs.exceptionInfo);
  142. } else {
  143. var inOrOut = res.description ;
  144. if(inOrOut == "IN" || inOrOut == "-OUT"){
  145. linkCaller = "ProdInOut!BarcodeIn";
  146. }else if(inOrOut == "-IN" || inOrOut == "OUT"){
  147. linkCaller = "ProdInOut!BarcodeOut";
  148. }
  149. var win = new Ext.window.Window({
  150. id : 'win',
  151. height : '90%',
  152. width : '95%',
  153. maximizable : true,
  154. buttonAlign : 'center',
  155. layout : 'anchor',
  156. items : [ {
  157. tag : 'iframe',
  158. frame : true,
  159. anchor : '100% 100%',
  160. layout : 'fit',
  161. html : '<iframe id="iframe_'+linkCaller+'" src="'+basePath+'jsps/scm/reserve/setBarcode.jsp?_noc=1&whoami='+linkCaller+'&formCondition='+formCondition1+'&gridCondition='+gridCondition1+'" height="100%" width="100%" frameborder="0" scrolling="auto"></iframe>'
  162. }],
  163. listeners:{
  164. 'beforeclose':function(view ,opt){
  165. var postStatus = Ext.getCmp('pi_statuscode');
  166. if(postStatus && postStatus.value != 'POSTED'){
  167. var grid = Ext.getCmp("grid");
  168. me.GridUtil.loadNewStore(grid,{
  169. caller:caller,
  170. condition:gridCondition
  171. });
  172. }
  173. }
  174. }
  175. });
  176. win.show();
  177. }
  178. }
  179. });
  180. },
  181. afterrender:function(btn) {
  182. btn.setDisabled(true);
  183. }
  184. },
  185. 'erpDeleteDetailButton': {
  186. afterrender: function(btn){
  187. btn.ownerCt.add({
  188. xtype: 'erpBarcodeButton'
  189. });
  190. if(caller=='ProdInOut!Sale'){
  191. btn.ownerCt.add({
  192. xtype:'button',
  193. text:'比例信息维护',
  194. width:120,
  195. iconCls: 'x-button-icon-check',
  196. cls: 'x-btn-gray',
  197. id:'UpdateProdInoutrateButton',
  198. style: {
  199. marginLeft: '10px'
  200. },
  201. handler:function(){
  202. var record=btn.ownerCt.ownerCt.getSelectionModel().getLastSelected();
  203. me.updatepdscaleremark(record);
  204. }
  205. });
  206. }
  207. }
  208. },
  209. '#erpEditSubpackageButton': {
  210. afterrender: function(btn){
  211. var status = Ext.getCmp('pi_invostatuscode');
  212. if(status && status.value != 'AUDITED'){
  213. btn.hide();
  214. }
  215. },
  216. click: function(btn){
  217. var record=btn.ownerCt.ownerCt.getSelectionModel().getLastSelected();
  218. me.EditSubpackage(record);
  219. }
  220. },
  221. 'erpTurnProdinoutReturnButton':{
  222. click:function(btn){
  223. var id = Ext.getCmp('pi_id').value;
  224. Ext.Ajax.request({
  225. url : basePath + 'scm/sale/turnTurnProdinoutReturn.action',
  226. params: {
  227. id: id
  228. },
  229. method : 'post',
  230. callback : function(options,success,response){
  231. var res = new Ext.decode(response.responseText);
  232. if(res.exceptionInfo) {
  233. showError(rs.exceptionInfo);
  234. } else {
  235. if(res.log)
  236. showMessage('提示', res.log);
  237. }
  238. }
  239. });
  240. }
  241. },
  242. 'erpTurnReturnButton':{
  243. beforerender:function(btn){
  244. btn.setText('转借货归还单');
  245. },
  246. afterrender:function(btn){
  247. var status = Ext.getCmp(me.getForm(btn).statuscodeField),
  248. postStatus = Ext.getCmp('pi_statuscode');
  249. if((status && status.value != 'AUDITED') ||(postStatus && postStatus.value == 'POSTED')){
  250. btn.hide();
  251. }
  252. },
  253. click:function(){
  254. Ext.Ajax.request({
  255. url : basePath + 'scm/reserve/turnOutReturn.action',
  256. params: {
  257. id: Ext.getCmp('pi_id').value,
  258. caller:caller
  259. },
  260. method : 'post',
  261. callback : function(options,success,response){
  262. var res = new Ext.decode(response.responseText);
  263. if(res.exceptionInfo){
  264. showError(res.exceptionInfo);return;
  265. }
  266. if(res.log)
  267. showMessage('提示', res.log);
  268. }
  269. });
  270. }
  271. },
  272. 'erpSplitButton':{
  273. click:function(btn){
  274. warnMsg("确定拆分单据?", function(btn){
  275. if(btn == 'yes'){
  276. var id = Ext.getCmp('pi_id').value;
  277. var piclass = Ext.getCmp('pi_class').value;
  278. Ext.Ajax.request({
  279. url : basePath + 'scm/reserve/split.action',
  280. params: {
  281. id: id,
  282. caller:caller,
  283. cls:piclass
  284. },
  285. method : 'post',
  286. callback : function(options,success,response){
  287. var res = new Ext.decode(response.responseText);
  288. if(res.exceptionInfo) {
  289. showError(res.exceptionInfo);
  290. } else {
  291. if(res.log)
  292. showMessage('提示', res.log);
  293. }
  294. }
  295. });
  296. }
  297. });
  298. }
  299. },
  300. 'erpGridWinButton':{
  301. afterrender: function(btn){
  302. var id = Ext.getCmp('pi_id').value;
  303. btn.setConfig({
  304. text: '费用明细',
  305. caller: 'ProdChargeDetail!CGYS',
  306. condition: 'pd_piid=' + id,
  307. paramConfig: {
  308. pd_piid: id
  309. }
  310. });
  311. },
  312. beforesave : function(btn) {
  313. var f = btn.ownerCt.ownerCt, p = f.down('field[name=pi_statuscode]');
  314. if (p && 'POSTED' == p.getValue()) {
  315. Ext.Msg.alert("提示","该单据已经过账,不能修改费用明细!");
  316. return false;
  317. }
  318. return true;
  319. }
  320. /*aftersave:function(){
  321. //验收单ID
  322. var id = Ext.getCmp('pi_id').value;
  323. Ext.Ajax.request({
  324. url : basePath + 'scm/reserve/updatepdPrice.action',
  325. params: {
  326. id: id
  327. },
  328. method : 'post',
  329. callback : function(options,success,response){
  330. var res = new Ext.decode(response.responseText);
  331. window.location.reload();
  332. if(!res.bool){
  333. btn.hide();
  334. }
  335. }
  336. });
  337. }*/
  338. //yaozx@13-12-04
  339. /*aftersave:function(btn){
  340. var items = Ext.getCmp('grid').store.data.items;
  341. var totalcount,parentCount;
  342. var rate,pd_prcie;
  343. Ext.Array.each(items, function(item){
  344. rate = item.data['pd_rate']==0?1:item.data['pd_rate'];
  345. totalcount = Number(totalcount) + rate*item.data['pd_amount'];
  346. });
  347. var parentItems = parent.Ext.getCmp('grid').store.data.items;
  348. Ext.Array.each(parentItems, function(item){
  349. parentCount = Number(parentCount)+item.data['pd_inqty']*item.data['pd_orderprice']*(1+item.data['pd_taxrate']/100);
  350. });
  351. rate = parent.Ext.getCmp('pi_rate').value==0?1:Ext.getCmp('pi_rate').value;
  352. parentCount = Number(parentCount)*rate;
  353. if(Number(parentCount)>0&&Number(parentCount)>0){
  354. Ext.Array.each(parentItems, function(item){
  355. pd_prcie = item.data['pd_orderprice']*(1+item.data['pd_taxrate']/100)+Number(parentCount)/item.data['pd_inqty']*totalcount;
  356. item.set('pd_prcie', pd_prcie );
  357. });
  358. }
  359. }*/
  360. },
  361. 'erpSaveButton': {
  362. click: function(btn){
  363. var form = me.getForm(btn);
  364. if(Ext.getCmp(form.codeField).value == null || Ext.getCmp(form.codeField).value == ''){
  365. me.BaseUtil.getRandomNumber(caller, 2, form.codeField);//自动添加编号
  366. }
  367. me.save(btn);
  368. }
  369. },
  370. 'erpPrintA4Button': {
  371. click: function(btn) {
  372. var reportName = '';
  373. var reportName = "piolist_bc4";
  374. var condition = '{prodinout.pi_id}=' + Ext.getCmp('pi_id').value + '';
  375. var id = Ext.getCmp('pi_id').value;
  376. me.FormUtil.onwindowsPrint(id, reportName, condition);
  377. }
  378. },
  379. 'erpUpdatePdpriceButton':{
  380. click:function(btn){
  381. var p = Ext.getCmp('pi_statuscode');
  382. if (p && 'POSTED' == p.getValue()) {
  383. Ext.Msg.alert("提示","该单据已经过账,不能修改费用明细!");
  384. return ;
  385. }
  386. var id = Ext.getCmp('pi_id').value;
  387. Ext.Ajax.request({
  388. url : basePath + 'scm/reserve/updatepdPrice.action',
  389. params: {
  390. id: id
  391. },
  392. method : 'post',
  393. callback : function(options,success,response){
  394. var res = new Ext.decode(response.responseText);
  395. window.location.reload();
  396. if(!res.bool){
  397. btn.hide();
  398. }
  399. }
  400. });
  401. }
  402. },
  403. 'erpDeleteButton' : {
  404. afterrender: function(btn){
  405. var status = Ext.getCmp(me.getForm(btn).statuscodeField);
  406. if(status && status.value == 'DELETED'){
  407. btn.hide();
  408. }
  409. },
  410. click: function(btn){
  411. me.FormUtil.onDelete({pu_id: Number(Ext.getCmp('pi_id').value)});
  412. }
  413. },
  414. 'erpResetbatchButton':{
  415. afterrender: function(btn){
  416. var status = Ext.getCmp('pi_statuscode');
  417. if(status && status.value != 'UNPOST'){
  418. btn.hide();
  419. }/*else{
  420. Ext.Ajax.request({
  421. url : basePath + 'scm/reserve/checkresetBatchcode.action',
  422. params: {
  423. caller: caller
  424. },
  425. method : 'post',
  426. callback : function(options,success,response){
  427. var res = new Ext.decode(response.responseText);
  428. if(!res.bool){
  429. btn.hide();
  430. }
  431. }
  432. });
  433. }*/
  434. },
  435. click: function(btn){
  436. Ext.Ajax.request({
  437. url : basePath + 'scm/reserve/resetBatchcode.action',
  438. params: {
  439. id: Ext.getCmp('pi_id').value
  440. },
  441. method : 'post',
  442. callback : function(options,success,response){
  443. var res = new Ext.decode(response.responseText);
  444. if(res.exceptionInfo){
  445. showError(res.exceptionInfo);return;
  446. } else if(res.success){
  447. Ext.Msg.alert("提示","批号重置成功!");
  448. }
  449. }
  450. });
  451. }
  452. },
  453. 'erpUpdateButton': {
  454. afterrender: function(btn){
  455. var status = Ext.getCmp(me.getForm(btn).statuscodeField);
  456. if(status && status.value != 'ENTERING'){
  457. btn.hide();
  458. }
  459. status = Ext.getCmp('pi_statuscode');
  460. if(status && 'POSTED' == status.value) {
  461. btn.hide();
  462. }
  463. },
  464. click: function(btn){
  465. var grid = Ext.getCmp('grid'), items = grid.store.data.items, c = Ext.getCmp('pi_inoutno').value;
  466. var piclass = Ext.getCmp('pi_class').value;
  467. Ext.Array.each(items, function(item){
  468. if(!Ext.isEmpty(item.data['pd_prodcode'])){
  469. item.set('pd_inoutno', c);
  470. item.set('pd_piclass', piclass);
  471. }
  472. if(caller == 'ProdInOut!OtherIn' || caller == 'ProdInOut!OtherPurcIn') {
  473. if(item.data['pd_unitpackage'] == null || item.data['pd_unitpackage'] == ''||
  474. item.data['pd_unitpackage'] == '0' || item.data['pd_unitpackage'] == 0){
  475. item.set('pd_unitpackage', item.data['pd_inqty']);
  476. }
  477. }
  478. });
  479. if(caller !='ProdInOut!AppropriationOut' && caller != 'ProdInOut!AppropriationIn' ) {
  480. var whcode = Ext.getCmp('pi_whcode'), whname = Ext.getCmp('pi_whname');
  481. if(whcode && whname) {
  482. Ext.Array.each(items, function(item){
  483. if(!Ext.isEmpty(item.data['pd_prodcode'])){
  484. if(Ext.isEmpty(item.data['pd_whcode'])){
  485. item.set('pd_whcode', whcode.value);
  486. item.set('pd_whname', whname.value);
  487. }
  488. }
  489. });
  490. }
  491. }
  492. // 拨入单、拨出单,默认第一行的仓库
  493. me.setDetailWarehouse(grid);
  494. if(caller == 'ProdInOut!Make!Return') {
  495. var firstItem = grid.store.getAt(0);
  496. if(firstItem) {
  497. var desc = firstItem.get('pd_description'), dc = firstItem.get('pd_departmentcode'),
  498. dn = firstItem.get('pd_departmentname'), whcode = firstItem.get('pd_whcode'),
  499. whname = firstItem.get('pd_whname');
  500. Ext.Array.each(items, function(item){
  501. if(!Ext.isEmpty(item.data['pd_prodcode'])){
  502. if(Ext.isEmpty(item.data['pd_description'])){
  503. item.set('pd_description', desc);
  504. }
  505. if(Ext.isEmpty(item.data['pd_departmentcode'])){
  506. item.set('pd_departmentcode', dc);
  507. item.set('pd_departmentname', dn);
  508. }
  509. if(Ext.isEmpty(item.data['pd_whcode'])){
  510. item.set('pd_whcode', whcode);
  511. item.set('pd_whname', whname);
  512. }
  513. }
  514. });
  515. }
  516. }
  517. me.FormUtil.onUpdate(me);
  518. }
  519. },
  520. 'erpAddButton': {
  521. click: function(){
  522. me.FormUtil.onAdd('add' + caller, '新增出入库单', "jsps/scm/reserve/prodInOut.jsp?whoami=" + caller);
  523. }
  524. },
  525. 'erpCloseButton': {
  526. click: function(btn){
  527. me.FormUtil.beforeClose(me);
  528. }
  529. },
  530. 'erpSubmitButton': {
  531. afterrender: function(btn){
  532. var status = Ext.getCmp(me.getForm(btn).statuscodeField);
  533. if(status && status.value != 'ENTERING'){
  534. btn.hide();
  535. }
  536. },
  537. click: function(btn){
  538. var grid = Ext.getCmp('grid');
  539. var items = grid.store.data.items;
  540. var bool = true;
  541. if(caller=='ProdInOut!OtherIn'||caller=='ProdInOut!OtherOut'){
  542. var type = Ext.getCmp('pi_type').value;
  543. if(type==null||type==''){
  544. showError("主表类型字段未填写,不能提交!");return;
  545. }
  546. }
  547. /*Ext.each(items, function(item){
  548. if(item.data[grid.necessaryField] != null && item.data[grid.necessaryField] != ''){
  549. if(item.data['pd_outqty'] == null || item.data['pd_outqty'] == ''){
  550. bool = false;
  551. showError("明细第" + item.data['pd_pdno'] + "行出库数量未填写,不能提交");return;
  552. }
  553. }
  554. });*/
  555. if(caller=='ProdInOut!AppropriationOut'){
  556. Ext.each(items, function(item){
  557. if(item.data[grid.necessaryField] != null && item.data[grid.necessaryField] != ''){
  558. if(Ext.getCmp('pd_outqty') && item.data['pd_outqty'] == null || item.data['pd_outqty'] == ''){
  559. bool = false;
  560. showError("明细第" + item.data['pd_pdno'] + "行出库数量未填写,不能提交");return;
  561. }
  562. }
  563. });
  564. }
  565. if(bool){
  566. me.FormUtil.onSubmit(Ext.getCmp('pi_id').value);
  567. }
  568. }
  569. },
  570. 'erpResSubmitButton': {
  571. afterrender: function(btn){
  572. var status = Ext.getCmp(me.getForm(btn).statuscodeField);
  573. if(status && status.value != 'COMMITED'){
  574. btn.hide();
  575. }
  576. },
  577. click: function(btn){
  578. me.FormUtil.onResSubmit(Ext.getCmp('pi_id').value);
  579. }
  580. },
  581. 'erpAuditButton': {
  582. afterrender: function(btn){
  583. var status = Ext.getCmp(me.getForm(btn).statuscodeField);
  584. if(status && status.value != 'COMMITED'){
  585. btn.hide();
  586. }
  587. },
  588. click: function(btn){
  589. me.FormUtil.onAudit(Ext.getCmp('pi_id').value);
  590. }
  591. },
  592. 'erpResAuditButton': {
  593. afterrender: function(btn){
  594. var status = Ext.getCmp(me.getForm(btn).statuscodeField),
  595. postStatus = Ext.getCmp('pi_statuscode');
  596. if((status && status.value != 'AUDITED') ||(postStatus && postStatus.value == 'POSTED')){
  597. btn.hide();
  598. }
  599. },
  600. click: function(btn){
  601. me.FormUtil.onResAudit(Ext.getCmp('pi_id').value);
  602. }
  603. },
  604. 'erpBannedButton': {
  605. afterrender: function(btn){
  606. var status = Ext.getCmp(me.getForm(btn).statuscodeField);
  607. if(status && status.value != 'COMMITED'){
  608. btn.hide();
  609. }
  610. },
  611. click: function(btn){
  612. me.FormUtil.onBanned(Ext.getCmp('pi_id').value);
  613. }
  614. },
  615. 'erpResBannedButton': {
  616. afterrender: function(btn){
  617. var status = Ext.getCmp(me.getForm(btn).statuscodeField);
  618. if(status && status.value != 'BANNED'){
  619. btn.hide();
  620. }
  621. },
  622. click: function(btn){
  623. me.FormUtil.onResBanned(Ext.getCmp('pi_id').value);
  624. }
  625. },
  626. 'erpPrintButton': {
  627. click:function(btn){
  628. me.onPrint();
  629. }
  630. },
  631. 'erpPrintotherinButton':{// 返修机入仓单
  632. click: function(btn){
  633. var reportName = "piolist_otherin";
  634. var condition = '{prodinout.pi_id}=' + Ext.getCmp('pi_id').value + '';
  635. var id = Ext.getCmp('pi_id').value;
  636. me.FormUtil.onwindowsPrint(id, reportName, condition);
  637. }
  638. },
  639. 'erpPrintotheroutButton':{// 返修机出仓单
  640. click: function(btn){
  641. var reportName = "piolist_otherout";
  642. var condition = '{prodinout.pi_id}=' + Ext.getCmp('pi_id').value + '';
  643. var id = Ext.getCmp('pi_id').value;
  644. me.FormUtil.onwindowsPrint(id, reportName, condition);
  645. }
  646. },
  647. 'erpPrintwithPriceButton':{// 无价打印==erpPrintButton
  648. click: function(btn){
  649. var reportName = "sendlist_yessale_yesprice";
  650. var condition = '{prodinout.pi_id}=' + Ext.getCmp('pi_id').value + '';
  651. var id = Ext.getCmp('pi_id').value;
  652. me.FormUtil.onwindowsPrint(id, reportName, condition);
  653. }
  654. },
  655. 'erpPrintPriceButton':{// (有价)打印,和erpPrintwithPriceButton一样,某些客户需要默认为有效
  656. click: function(btn){
  657. var reportName = "sendlist_yessale_yesprice";
  658. var condition = '{prodinout.pi_id}=' + Ext.getCmp('pi_id').value + '';
  659. var id = Ext.getCmp('pi_id').value;
  660. me.FormUtil.onwindowsPrint(id, reportName, condition);
  661. }
  662. },
  663. 'erpPrintnosaleButton':{// 无PO打印
  664. click: function(btn){
  665. var reportName = "sendlist_nosale";
  666. var condition = '{prodinout.pi_id}=' + Ext.getCmp('pi_id').value + '';
  667. var id = Ext.getCmp('pi_id').value;
  668. me.FormUtil.onwindowsPrint(id, reportName, condition);
  669. }
  670. },
  671. 'erpPrintNoCustomerButton':{// 无客户打印
  672. click: function(btn){
  673. var reportName = "sendlist_yessale_nocustomer";
  674. var condition = '{prodinout.pi_id}=' + Ext.getCmp('pi_id').value + '';
  675. var id = Ext.getCmp('pi_id').value;
  676. me.FormUtil.onwindowsPrint(id, reportName, condition);
  677. }
  678. },
  679. 'erpPrintNoPriceButton':{// 无价打印==erpPrintButton
  680. click: function(btn){
  681. me.onPrint();
  682. }
  683. },
  684. 'erpPostButton': {
  685. afterrender: function(btn){
  686. var status = Ext.getCmp('pi_statuscode');
  687. if(status && status.value != 'UNPOST'){
  688. btn.hide();
  689. }
  690. },
  691. buffer : 1000,
  692. click: function(btn){
  693. me.FormUtil.onPost(Ext.getCmp('pi_id').value);
  694. }
  695. },
  696. 'erptecaiButton':{
  697. afterrender: function(btn){
  698. var status = Ext.getCmp('pi_statuscode');
  699. if(caller!='ProdInOut!DefectIn'|| status.value != 'POSTED'){
  700. btn.hide();
  701. }
  702. },
  703. click: function(btn){
  704. var pi_id = Ext.getCmp('pi_id').value;
  705. Ext.Ajax.request({
  706. url: basePath + 'scm/reserve/erptecai.action',
  707. params: {
  708. caller: caller,
  709. id: pi_id
  710. },
  711. callback: function(opt, s, r) {
  712. var rs = Ext.decode(r.responseText);
  713. if(rs.exceptionInfo) {
  714. showError(rs.exceptionInfo);
  715. } else {
  716. if(rs.log)
  717. showMessage('提示', rs.log);
  718. }
  719. }
  720. });
  721. }
  722. },
  723. 'erpResPostButton': {
  724. afterrender: function(btn){
  725. var status = Ext.getCmp('pi_statuscode');
  726. if(status && status.value != 'POSTED'){
  727. btn.hide();
  728. }
  729. },
  730. click: function(btn){
  731. me.FormUtil.onResPost(Ext.getCmp('pi_id').value);
  732. }
  733. },
  734. 'erpTurnProdinoutIn':{
  735. afterrender: function(btn){
  736. var status = Ext.getCmp(me.getForm(btn).statuscodeField);
  737. if(caller=='ProdInOut!OtherOut' && status.value != 'AUDITED'){
  738. btn.hide();
  739. }
  740. },
  741. click: function(btn){
  742. var id = Ext.getCmp('pi_id').value;
  743. Ext.Ajax.request({
  744. url: basePath + 'scm/reserve/turnProdinoutIn.action',
  745. params: {
  746. id: id
  747. },
  748. callback: function(opt, s, r) {
  749. var rs = Ext.decode(r.responseText);
  750. if(rs.exceptionInfo) {
  751. showError(rs.exceptionInfo);
  752. } else {
  753. if(rs.log)
  754. showMessage('提示', rs.log);
  755. }
  756. }
  757. });
  758. }
  759. },
  760. 'erpSetMMQTYButton':{
  761. click:function(btn){
  762. warnMsg("确认本次发料数为当前维护的实际可发数?", function(btn){
  763. if(btn == 'yes'){
  764. me.FormUtil.setLoading(true);//loading...
  765. Ext.Ajax.request({
  766. url : basePath + 'scm/reserve/SetMMQTY.action',
  767. params: {
  768. id: Ext.getCmp('pi_id').value,
  769. caller:caller
  770. },
  771. method : 'post',
  772. callback: function(opt, s, r) {
  773. me.FormUtil.setLoading(false);
  774. var rs = Ext.decode(r.responseText);
  775. if(rs.exceptionInfo) {
  776. showError(rs.exceptionInfo);
  777. } else {
  778. if(rs.log)
  779. showMessage('提示', rs.log);
  780. }
  781. window.location.reload();
  782. }
  783. });
  784. }
  785. });
  786. }
  787. },
  788. 'dbfindtrigger[name=pd_ordercode]': {
  789. focus: function(t){
  790. t.setHideTrigger(false);
  791. t.setReadOnly(false);
  792. if(Ext.getCmp('pi_cardcode')){
  793. var code = Ext.getCmp('pi_cardcode').value;
  794. if(code != null && code != ''){
  795. var obj = me.getCodeCondition();
  796. if(obj && obj.field){
  797. t.dbBaseCondition = obj.field + "='" + code + "'";
  798. }
  799. }
  800. }
  801. if(caller=='ProdInOut!OutReturn'){//借货归还单
  802. var code = Ext.getCmp('pi_cardcode').value;
  803. if(code != null && code != ''){
  804. if(t.dbBaseCondition==null||t.dbBaseCondition==''){
  805. t.dbBaseCondition= "pi_cardcode='"+code+"'";
  806. }else{
  807. t.dbBaseCondition=t.dbBaseCondition+" and pi_cardcode='"+code+"'";
  808. }
  809. }
  810. }
  811. },
  812. aftertrigger: function(t){
  813. if(Ext.getCmp('pi_cardcode')){
  814. var obj = me.getCodeCondition();
  815. if(obj && obj.fields){
  816. me.FormUtil.getFieldsValue(obj.tablename, obj.fields, obj.myfield + "='" + t.value + "'", obj.tFields);
  817. }
  818. }
  819. }
  820. },
  821. 'dbfindtrigger[name=pd_orderdetno]': {
  822. focus: function(t){
  823. t.setHideTrigger(false);
  824. t.setReadOnly(false);//用disable()可以,但enable()无效
  825. var record = Ext.getCmp('grid').selModel.lastSelected;
  826. var code = record.data['pd_ordercode'];
  827. if(code == null || code == ''){
  828. showError("请先选择关联单号!");
  829. t.setHideTrigger(true);
  830. t.setReadOnly(true);
  831. } else {
  832. var field = me.getBaseCondition();
  833. if(field){
  834. t.dbBaseCondition = field + "='" + code + "'";
  835. }
  836. }
  837. }
  838. },
  839. 'dbfindtrigger[name=pd_whcode]':{
  840. aftertrigger: function(t){
  841. if(caller=='ProdInOut!AppropriationOut'||caller=='ProdInOut!Sale'||caller=='ProdInOut!AppropriationIn'){
  842. var inwhcode=t.value;
  843. var record = Ext.getCmp('grid').selModel.lastSelected;
  844. var prodcode=record.data['pd_prodcode'];
  845. if(prodcode&&inwhcode){
  846. var obj = {tablename:'productWH',fields:'pw_onhand'};
  847. me.FormUtil.getFieldsValue(obj.tablename, obj.fields,"pw_whcode='"+inwhcode+"' AND pw_prodcode='"+prodcode+"'" , "pd_inqty",record);
  848. }
  849. }
  850. }
  851. },
  852. 'multidbfindtrigger[name=pd_orderdetno]': {
  853. focus: function(t){
  854. t.setHideTrigger(false);
  855. t.setReadOnly(false);//用disable()可以,但enable()无效
  856. var record = Ext.getCmp('grid').selModel.lastSelected;
  857. var code = record.data['pd_ordercode'];
  858. if(code == null || code == ''){
  859. showError("请先选择关联单号!");
  860. t.setHideTrigger(true);
  861. t.setReadOnly(true);
  862. } else {
  863. var field = me.getBaseCondition();
  864. if(field){
  865. t.dbBaseCondition = field + "='" + code + "'";
  866. }
  867. }
  868. }
  869. },
  870. 'dbfindtrigger[name=pd_batchcode]': {
  871. focus: function(t){
  872. t.setHideTrigger(false);
  873. t.setReadOnly(false);//用disable()可以,但enable()无效
  874. var record = Ext.getCmp('grid').selModel.lastSelected;
  875. var pr = record.data['pd_prodcode'];
  876. if(pr == null || pr == ''){
  877. showError("请先选择料号!");
  878. t.setHideTrigger(true);
  879. t.setReadOnly(true);
  880. } else {
  881. var code = record.data['pd_whcode'];
  882. if(code == null || code == ''){
  883. if(Ext.getCmp('pi_whcode')) {
  884. code = Ext.getCmp('pi_whcode').value;
  885. if(code == null || code == ''){
  886. showError("请先选择仓库!");
  887. t.setHideTrigger(true);
  888. t.setReadOnly(true);
  889. } else {
  890. t.dbBaseCondition = "ba_whcode='" + code + "' AND ba_prodcode='" + pr + "'";
  891. }
  892. } else {
  893. t.dbBaseCondition = "ba_prodcode='" + pr + "'";
  894. }
  895. } else {
  896. t.dbBaseCondition = "ba_whcode='" + code + "' AND ba_prodcode='" + pr + "'";
  897. }
  898. }
  899. }
  900. },
  901. 'field[name=pi_whcode]': {
  902. aftertrigger: function(f){
  903. if(f.value != null && f.value != ''){
  904. var grid = Ext.getCmp('grid');
  905. var whname = Ext.getCmp('pi_whname');
  906. Ext.Array.each(grid.store.data.items, function(item){
  907. if(item.data['pd_whcode'] == null || item.data['pd_whcode'] == ''){
  908. item.set('pd_whcode', f.value);
  909. item.set('pd_whname', whname.value);
  910. }
  911. });
  912. }
  913. }
  914. },
  915. 'field[name=pi_purpose]': {
  916. aftertrigger: function(f){
  917. if(f.value != null && f.value != ''){
  918. var grid = Ext.getCmp('grid');
  919. var posename = Ext.getCmp('pi_purposename');
  920. Ext.Array.each(grid.store.data.items, function(item){
  921. if(item.data['pd_inwhcode'] == null || item.data['pd_inwhcode'] == ''){
  922. item.set('pd_inwhcode', f.value);
  923. if(posename){
  924. item.set('pd_inwhname', posename.value);
  925. }
  926. }
  927. });
  928. }
  929. }
  930. },
  931. 'dbfindtrigger[name=pi_paymentcode]': {
  932. afterrender:function(trigger){
  933. if(trigger.fieldConfig == 'PT') {
  934. trigger.dbKey='pi_cardcode';
  935. if(caller=='ProdInOut!Sale' || caller=='ProdInOut!SaleReturn' || caller=='ProdInOut!SaleBorrow'){
  936. trigger.mappingKey='cu_code';
  937. trigger.dbMessage='请先选客户编号!';
  938. }
  939. }
  940. }
  941. },
  942. 'dbfindtrigger[name=pi_custcode2]': {
  943. afterrender:function(trigger){
  944. trigger.dbKey='pi_cardcode';
  945. trigger.mappingKey='cu_code';
  946. trigger.dbMessage='请先选客户编号!';
  947. }
  948. },
  949. 'dbfindtrigger[name=pi_invoiceremark]': {
  950. afterrender:function(trigger){
  951. trigger.dbKey='pi_cardcode';
  952. trigger.mappingKey='cu_code';
  953. trigger.dbMessage='请先选客户编号!';
  954. }
  955. },
  956. 'dbfindtrigger[name=pi_packingremark]': {
  957. afterrender:function(trigger){
  958. trigger.dbKey='pi_cardcode';
  959. trigger.mappingKey='cu_code';
  960. trigger.dbMessage='请先选客户编号!';
  961. }
  962. },
  963. /* 'dbfindtrigger[name=pi_receivecode]': {
  964. afterrender:function(trigger){
  965. if (caller == 'ProdInOut!Sale') {
  966. trigger.dbKey='pi_cardcode';
  967. trigger.mappingKey='cu_code';
  968. trigger.dbMessage='请先选客户编号!';
  969. }
  970. }
  971. },*/ //万利达收货客户可以随意改成其他客户
  972. 'erpGetPriceButton': {
  973. click: function(){
  974. }
  975. },
  976. 'erpTurnMrbButton':{
  977. afterrender: function(btn){
  978. var status = Ext.getCmp("pi_statuscode");
  979. if(status && status.value != 'POSTED'){
  980. btn.hide();
  981. }
  982. },
  983. click: function(btn){
  984. me.batchdeal('ProdIO!ToMRB!Deal', 'pd_piid=' + Ext.getCmp('pi_id').value + ' AND nvl(pd_yqty,0)<pd_inqty+pd_outqty','scm/reserve/turnMRB.action');
  985. }
  986. },
  987. 'erpSubpackageButton':{
  988. afterrender: function(btn){
  989. var status = Ext.getCmp('pi_invostatuscode');
  990. if(status && status.value != 'AUDITED'){
  991. btn.hide();
  992. }
  993. },
  994. click: function(btn){
  995. warnMsg("确定分装?", function(btn){
  996. if(btn == 'yes'){
  997. me.FormUtil.setLoading(true);//loading...
  998. Ext.Ajax.request({
  999. url : basePath + 'scm/reserve/Subpackage.action',
  1000. params: {
  1001. id: Ext.getCmp('pi_id').value
  1002. },
  1003. method : 'post',
  1004. callback: function(opt, s, r) {
  1005. me.FormUtil.setLoading(false);
  1006. var rs = Ext.decode(r.responseText);
  1007. if(rs.exceptionInfo) {
  1008. showError(rs.exceptionInfo);
  1009. } else {
  1010. if(rs.log)
  1011. showMessage('提示', rs.log);
  1012. }
  1013. }
  1014. });
  1015. }
  1016. });
  1017. }
  1018. },
  1019. 'erpClearSubpackageButton':{
  1020. afterrender: function(btn){
  1021. var status = Ext.getCmp('pi_invostatuscode');
  1022. if(status && status.value != 'AUDITED'){
  1023. btn.hide();
  1024. }
  1025. },
  1026. click: function(btn){
  1027. warnMsg("确定清除分装?", function(btn){
  1028. if(btn == 'yes'){
  1029. me.FormUtil.setLoading(true);//loading...
  1030. Ext.Ajax.request({
  1031. url : basePath + 'scm/reserve/ClearSubpackage.action',
  1032. params: {
  1033. id: Ext.getCmp('pi_id').value
  1034. },
  1035. method : 'post',
  1036. callback: function(opt, s, r) {
  1037. me.FormUtil.setLoading(false);
  1038. var rs = Ext.decode(r.responseText);
  1039. if(rs.exceptionInfo) {
  1040. showError(rs.exceptionInfo);
  1041. } else {
  1042. if(rs.log)
  1043. showMessage('提示', rs.log);
  1044. }
  1045. }
  1046. });
  1047. }
  1048. });
  1049. }
  1050. },
  1051. 'erpPrintBarButton':{
  1052. click: function(btn){
  1053. var reportName = "bar_53";
  1054. var condition = '{ProdIODetailBar.pdb_inoutno}=' +"'"+ Ext.getCmp('pi_inoutno').value + "'";
  1055. var id = Ext.getCmp('pi_id').value;
  1056. me.FormUtil.onwindowsPrint(id, reportName, condition);
  1057. }
  1058. },
  1059. /**
  1060. * 发送出货单数据
  1061. */
  1062. 'erpSendDataButton': {
  1063. afterrender: function(btn){
  1064. var status = Ext.getCmp('pi_statuscode');
  1065. if(status && status.value == 'POSTED' && (caller == 'ProdInOut!Sale')){
  1066. btn.show();
  1067. }
  1068. },
  1069. click: function(btn) {
  1070. var pi_id = Ext.getCmp('pi_id').value;
  1071. var pi_class = Ext.getCmp('pi_class').value;
  1072. Ext.getBody().mask("waiting...");
  1073. if (caller == 'ProdInOut!Sale') {
  1074. Ext.Ajax.request({
  1075. url: basePath + "scm/reserve/inOutPut/syncToSqlServer.action",
  1076. params: {
  1077. id: pi_id,
  1078. caller: caller
  1079. },
  1080. method: 'post',
  1081. callback: function (options, success, response) {
  1082. Ext.getBody().unmask();
  1083. var res = new Ext.decode(response.responseText);
  1084. if (res.success) {
  1085. showMessage("提示","发送完成");
  1086. }else{
  1087. showError(res.exceptionInfo||"发送失败");
  1088. return;
  1089. }
  1090. }
  1091. });
  1092. }
  1093. }
  1094. }
  1095. });
  1096. },
  1097. getForm: function(btn){
  1098. return btn.ownerCt.ownerCt;
  1099. },
  1100. save: function(btn){
  1101. var me = this;
  1102. var form = me.getForm(btn);
  1103. if(Ext.getCmp('Fin_Code')){
  1104. Ext.getCmp('Fin_Code').setValue(Ext.getCmp(form.codeField).value);//流水号
  1105. }
  1106. var grid = Ext.getCmp('grid'), items = grid.store.data.items, c = Ext.getCmp('pi_inoutno').value;
  1107. var piclass = Ext.getCmp('pi_class').value;
  1108. Ext.Array.each(items, function(item){
  1109. if(!Ext.isEmpty(item.data['pd_prodcode'])){
  1110. item.set('pd_inoutno', c);
  1111. item.set('pd_piclass', piclass);
  1112. }
  1113. });
  1114. if(caller =='ProdInOut!AppropriationOut'){
  1115. var recorder=Ext.getCmp('pi_recordman');
  1116. if(recorder){
  1117. Ext.Array.each(items, function(item){
  1118. if(!Ext.isEmpty(item.data['pd_prodcode'])){
  1119. if(Ext.isEmpty(item.data['pd_seller'])){
  1120. item.set('pd_seller', recorder.value);
  1121. }
  1122. }
  1123. });
  1124. }
  1125. }
  1126. if(caller !='ProdInOut!AppropriationOut' && caller != 'ProdInOut!AppropriationIn' ) {
  1127. var whcode = Ext.getCmp('pi_whcode'), whname = Ext.getCmp('pi_whname');
  1128. if(whcode && whname) {
  1129. Ext.Array.each(items, function(item){
  1130. if(!Ext.isEmpty(item.data['pd_prodcode'])){
  1131. if(Ext.isEmpty(item.data['pd_whcode'])){
  1132. item.set('pd_whcode', whcode.value);
  1133. item.set('pd_whname', whname.value);
  1134. }
  1135. if(caller == 'ProdInOut!OtherIn' || caller == 'ProdInOut!OtherPurcIn') {
  1136. if(item.data['pd_unitpackage'] == null || item.data['pd_unitpackage'] == ''||
  1137. item.data['pd_unitpackage'] == '0' || item.data['pd_unitpackage'] == 0){
  1138. item.set('pd_unitpackage', item.data['pd_inqty']);
  1139. }
  1140. }
  1141. }
  1142. });
  1143. }
  1144. }
  1145. // 拨入单、拨出单,默认第一行的仓库
  1146. me.setDetailWarehouse(grid);
  1147. if(caller == 'ProdInOut!Make!Return') {
  1148. var firstItem = grid.store.getAt(0);
  1149. if(firstItem) {
  1150. var desc = firstItem.get('pd_description'), dc = firstItem.get('pd_departmentcode'),
  1151. dn = firstItem.get('pd_departmentname'), whcode = firstItem.get('pd_whcode'),
  1152. whname = firstItem.get('pd_whname');
  1153. Ext.Array.each(items, function(item){
  1154. if(!Ext.isEmpty(item.data['pd_prodcode'])){
  1155. if(Ext.isEmpty(item.data['pd_description'])){
  1156. item.set('pd_description', desc);
  1157. }
  1158. if(Ext.isEmpty(item.data['pd_departmentcode'])){
  1159. item.set('pd_departmentcode', dc);
  1160. item.set('pd_departmentname', dn);
  1161. }
  1162. if(Ext.isEmpty(item.data['pd_whcode'])){
  1163. item.set('pd_whcode', whcode);
  1164. item.set('pd_whname', whname);
  1165. }
  1166. }
  1167. });
  1168. }
  1169. }
  1170. me.FormUtil.beforeSave(me);
  1171. },
  1172. setDetailWarehouse : function(grid) {
  1173. var me = this;
  1174. if('ProdInOut!AppropriationIn' == caller || 'ProdInOut!AppropriationOut' == caller) {
  1175. var firstItem = grid.store.getAt(0);
  1176. if(firstItem) {
  1177. var whcode = firstItem.get('pd_whcode'),
  1178. whname = firstItem.get('pd_whname'),
  1179. inwhcode = firstItem.get('pd_inwhcode'),
  1180. inwhname = firstItem.get('pd_inwhname');
  1181. grid.store.each(function(){
  1182. if(!me.GridUtil.isBlank(grid, this.data)) {
  1183. if(Ext.isEmpty(this.get('pd_whcode'))) {
  1184. this.set('pd_whcode', whcode);
  1185. this.set('pd_whname', whname);
  1186. }
  1187. if(Ext.isEmpty(this.get('pd_inwhcode'))) {
  1188. this.set('pd_inwhcode', inwhcode);
  1189. this.set('pd_inwhname', inwhname);
  1190. }
  1191. }
  1192. });
  1193. }
  1194. }
  1195. },
  1196. /**
  1197. * pd_orderdetno的限制条件
  1198. */
  1199. getBaseCondition: function(){
  1200. var field = null;
  1201. switch (caller) {
  1202. case 'ProdInOut!PurcCheckin': //采购验收单
  1203. field = "pd_code";break;
  1204. case 'ProdInOut!PurcCheckout': //采购验退单
  1205. field = "pd_code";break;
  1206. case 'ProdInOut!Sale': //出货单
  1207. field = "sd_code";break;
  1208. case 'ProdInOut!Make!Return': //生产退料单
  1209. field = "mm_code";break;
  1210. case 'ProdInOut!Make!Give': //生产补料单
  1211. field = "mm_code";break;
  1212. case 'ProdInOut!Picking': //生产领料单
  1213. field = "mm_code";break;
  1214. case 'ProdInOut!Make!Consume': //生产耗料单
  1215. field = "mm_code";break;
  1216. case 'ProdInOut!Make!Useless': //生产报废单
  1217. field = "mm_code";break;
  1218. case 'ProdInOut!SaleAppropriationOut': //销售拨出单
  1219. field = "sd_code";break;
  1220. case 'ProdInOut!SaleReturn': //销售退货单
  1221. field = "sd_code";break;
  1222. case 'ProdInOut!OtherOut': //其它出库单
  1223. field = "sd_code";break;
  1224. case 'ProdInOut!OutsidePicking': //委外领料单
  1225. field = "ma_code";break;
  1226. case 'ProdInOut!OutsideReturn': //委外退料单
  1227. field = "mm_code";break;
  1228. case 'ProdInOut!DefectIn': //不良品入库单
  1229. field = "pd_code";break;
  1230. case 'ProdInOut!DefectOut': //不良品入库单
  1231. field = "pd_code";break;
  1232. case 'ProdInOut!OutsideCheckIn': //委外验收单
  1233. field = "mm_code";break;
  1234. case 'ProdInOut!OSMake!Give': //委外补料单
  1235. field = "mm_code";break;
  1236. case 'ProdInOut!SampleSale': //样品出货单
  1237. field = "sd_code";break;
  1238. case 'ProdInOut!SampleMake!Give': //工程补料单
  1239. field = "mm_code";break;
  1240. case 'ProdInOut!SamplePicking': //工程领料单
  1241. field = "mm_code";break;
  1242. case 'ProdInOut!PurcCheckin!PLM': //研发采购验收单
  1243. field = "pd_code";break;
  1244. case 'ProdInOut!PurcCheckout!PLM': //研发采购验退单
  1245. field = "pd_code";break;
  1246. case 'ProdInOut!PartitionStockIn': //拆件入库单
  1247. field = "mm_code";break;
  1248. }
  1249. return field;
  1250. },
  1251. /**
  1252. * pd_ordercode的限制条件
  1253. */
  1254. updatepdscaleremark:function(record){
  1255. var win = Ext.create('Ext.Window', {
  1256. id: 'win',
  1257. title: '发货比例信息维护',
  1258. height: 300,
  1259. width: 400,
  1260. items: [{
  1261. margin: '3 0 0 0',
  1262. id:'pd_scaleremark',
  1263. xtype: 'textfield',
  1264. fieldLabel: '比例备注',
  1265. name:'pd_scaleremark',
  1266. value:record.data.pd_scaleremark
  1267. }],
  1268. closeAction: 'hide',
  1269. buttonAlign: 'center',
  1270. layout: {
  1271. type: 'vbox',
  1272. align: 'center'
  1273. },
  1274. buttons: [{
  1275. text: '保存信息',
  1276. cls: 'x-btn-blue',
  1277. handler: function(btn) {
  1278. var id = record.data.pd_id;
  1279. Ext.Ajax.request({
  1280. url: basePath + 'scm/sale/updatepdscaleremark.action',
  1281. params: {
  1282. id: id,
  1283. field:'pd_id',
  1284. data:Ext.getCmp('pd_scaleremark').value
  1285. },
  1286. callback: function(opt, s, r) {
  1287. var rs = Ext.decode(r.responseText);
  1288. if(rs.exceptionInfo) {
  1289. showMessage('提示', rs.exceptionInfo.replace('AFTERSUCCESS', ''));
  1290. } else {
  1291. saveSuccess(function(){
  1292. window.location.reload();
  1293. });
  1294. }
  1295. }
  1296. });
  1297. }
  1298. },{
  1299. text: '保存全部',
  1300. cls: 'x-btn-blue',
  1301. handler: function(btn) {
  1302. var id = record.data.pd_piid;
  1303. Ext.Ajax.request({
  1304. url: basePath + 'scm/sale/updatepdscaleremark.action',
  1305. params: {
  1306. id: id,
  1307. field:'pd_piid',
  1308. data:Ext.getCmp('pd_scaleremark').value
  1309. },
  1310. callback: function(opt, s, r) {
  1311. var rs = Ext.decode(r.responseText);
  1312. if(rs.exceptionInfo) {
  1313. showMessage('提示', rs.exceptionInfo.replace('AFTERSUCCESS', ''));
  1314. } else {
  1315. saveSuccess(function(){
  1316. window.location.reload();
  1317. });
  1318. }
  1319. }
  1320. });
  1321. }
  1322. },{
  1323. text: $I18N.common.button.erpCloseButton,
  1324. cls: 'x-btn-blue',
  1325. handler: function(btn) {
  1326. btn.ownerCt.ownerCt.hide();
  1327. }
  1328. }]
  1329. });
  1330. win.show();
  1331. },
  1332. getCodeCondition: function(){
  1333. var field = null;
  1334. var fields = '';
  1335. var tablename = '';
  1336. var myfield = '';
  1337. var tFields = '';
  1338. switch (caller) {
  1339. case 'ProdInOut!PurcCheckin': //采购验收单
  1340. field = "pu_vendcode";
  1341. tFields = 'pi_cardid,pi_cardcode,pi_title,pi_currency,pi_rate,pi_payment,pi_transport,pi_paydate,pi_receivecode,pi_receivename';
  1342. fields = 'pu_vendid,pu_vendcode,pu_vendname,pu_currency,pu_rate,pu_payments,pu_transport,pu_suredate,pu_receivecode,pu_receivename';
  1343. tablename = 'Purchase';
  1344. myfield = 'pu_code';
  1345. break;
  1346. case 'ProdInOut!PurcCheckout': //采购验退单
  1347. field = "pu_vendcode";
  1348. tFields = 'pi_cardid,pi_cardcode,pi_title,pi_currency,pi_rate,pi_payment,pi_transport,pi_paydate,pi_receivecode,pi_receivename';
  1349. fields = 'pu_vendid,pu_vendcode,pu_vendname,pu_currency,pu_rate,pu_payments,pu_transport,pu_suredate,pu_receivecode,pu_receivename';
  1350. tablename = 'Purchase';
  1351. myfield = 'pu_code';
  1352. break;
  1353. case 'ProdInOut!Sale': //出货单
  1354. tFields = 'pi_cardid,pi_cardcode,pi_title,pi_currency,pi_rate,pi_payment,pi_transport,pi_sellercode,pi_belongs,pi_receivecode,pi_receivename,pi_transport';
  1355. fields = 'sa_custid,sa_custcode,sa_custname,sa_currency,sa_rate,sa_payments,sa_transport,sa_sellercode,sa_seller,sa_shcustcode,sa_shcustname,sa_transport';
  1356. tablename = 'Sale';
  1357. myfield = 'sa_code';
  1358. field = "sa_custcode";
  1359. break;
  1360. case 'ProdInOut!AppropriationIn': //拨入单
  1361. tFields = 'pi_cardcode,pi_title';
  1362. fields = 'ma_custcode,ma_custname';
  1363. tablename = 'Make';
  1364. myfield = 'ma_code';
  1365. field = "ma_custcode";
  1366. break;
  1367. case 'ProdInOut!SaleAppropriationOut': //销售拨出单
  1368. tFields = 'pi_cardid,pi_cardcode,pi_title';
  1369. fields = 'sa_custid,sa_custcode,sa_custname';
  1370. tablename = 'Sale';
  1371. myfield = 'sa_code';
  1372. field = "sa_custcode";
  1373. break;
  1374. case 'ProdInOut!SaleReturn': //销售退货单
  1375. tFields = 'pi_cardid,pi_cardcode,pi_title,pi_currency,pi_rate,pi_payment,pi_transport,pi_sellercode,pi_belongs,pi_receivecode,pi_receivename,pi_transport';
  1376. fields = 'sa_custid,sa_custcode,sa_custname,sa_currency,sa_rate,sa_payments,sa_transport,sa_sellercode,sa_seller,sa_shcustcode,sa_shcustname,sa_transport';
  1377. tablename = 'Sale';
  1378. myfield = 'sa_code';
  1379. field = "sa_custcode";
  1380. break;
  1381. case 'ProdInOut!AppropriationOut': //拨出单
  1382. tFields = 'pi_cardcode,pi_title';
  1383. fields = 'ma_custcode,ma_custname';
  1384. tablename = 'Make';
  1385. myfield = 'ma_code';
  1386. field = "ma_custcode";
  1387. break;
  1388. case 'ProdInOut!DefectIn': //不良品入库单
  1389. field = "pu_vendcode";
  1390. tFields = 'pi_cardid,pi_cardcode,pi_title,pi_currency,pi_rate,pi_payment,pi_transport,pi_paydate';
  1391. fields = 'pu_vendid,pu_vendcode,pu_vendname,pu_currency,pu_rate,pu_payments,pu_transport,pu_suredate';
  1392. tablename = 'Purchase';
  1393. myfield = 'pu_code';
  1394. break;
  1395. case 'ProdInOut!DefectOut': //不良品出库单
  1396. field = "pu_vendcode";
  1397. tFields = 'pi_cardid,pi_cardcode,pi_title,pi_currency,pi_rate,pi_payment,pi_transport,pi_paydate';
  1398. fields = 'pu_vendid,pu_vendcode,pu_vendname,pu_currency,pu_rate,pu_payments,pu_transport,pu_suredate';
  1399. tablename = 'Purchase';
  1400. myfield = 'pu_code';
  1401. break;
  1402. case 'ProdInOut!OutsidePicking': //委外领料单
  1403. field = "ma_vendcode";
  1404. tFields = 'pi_cardcode,pi_title,pi_departmentcode,pi_departmentname';
  1405. fields = 'ma_vendcode,ma_vendname,ma_departmentcode,ma_departmentname';
  1406. tablename = 'Make';
  1407. myfield = 'ma_code';
  1408. break;
  1409. case 'ProdInOut!OutsideReturn': //委外退料单
  1410. field = "ma_vendcode";
  1411. tFields = 'pi_cardcode,pi_title,pi_departmentcode,pi_departmentname';
  1412. fields = 'ma_vendcode,ma_vendname,ma_departmentcode,ma_departmentname';
  1413. tablename = 'Make';
  1414. myfield = 'ma_code';
  1415. break;
  1416. case 'ProdInOut!OutsideCheckIn': //委外验收单
  1417. field = "ma_vendcode";
  1418. tFields = 'pi_cardcode,pi_title,pi_departmentcode,pi_departmentname';
  1419. fields = 'ma_vendcode,ma_vendname,ma_departmentcode,ma_departmentname';
  1420. tablename = 'Make';
  1421. myfield = 'ma_code';
  1422. break;
  1423. case 'ProdInOut!OutesideCheckReturn': //委外验退单
  1424. field = "ma_vendcode";
  1425. tFields = 'pi_cardcode,pi_title,pi_departmentcode,pi_departmentname,pi_currency,pi_rate';
  1426. fields = 'ma_vendcode,ma_vendname,ma_departmentcode,ma_departmentname,ma_currency,ma_rate';
  1427. tablename = 'Make';
  1428. myfield = 'ma_code';
  1429. break;
  1430. case 'ProdInOut!OutReturn'://借货归还单
  1431. tFields = 'pi_sellercode,pi_belongs,pi_cop,pi_shr,pi_expresscode,pi_emcode,pi_emname,pi_address';
  1432. fields = 'pi_emcode,pi_emname,pi_cop,pi_shr,pi_expresscode,pi_emcode,pi_emname,pi_address';
  1433. tablename = 'ProdInOut';
  1434. myfield = 'pi_inoutno';
  1435. break;
  1436. case 'ProdInOut!PurcCheckin!PLM': //研发采购验收单
  1437. field = "pu_vendcode";
  1438. tFields = 'pi_cardid,pi_cardcode,pi_title,pi_currency,pi_rate,pi_payment,pi_transport,pi_paydate,pi_receivecode,pi_receivename';
  1439. fields = 'pu_vendid,pu_vendcode,pu_vendname,pu_currency,pu_rate,pu_payments,pu_transport,pu_suredate,pu_receivecode,pu_receivename';
  1440. tablename = 'Purchase';
  1441. myfield = 'pu_code';
  1442. break;
  1443. case 'ProdInOut!PurcCheckout!PLM': //研发采购验退单
  1444. field = "pu_vendcode";
  1445. tFields = 'pi_cardid,pi_cardcode,pi_title,pi_currency,pi_rate,pi_payment,pi_transport,pi_paydate,pi_receivecode,pi_receivename';
  1446. fields = 'pu_vendid,pu_vendcode,pu_vendname,pu_currency,pu_rate,pu_payments,pu_transport,pu_suredate,pu_receivecode,pu_receivename';
  1447. tablename = 'Purchase';
  1448. myfield = 'pu_code';
  1449. break;
  1450. }
  1451. var obj = new Object();
  1452. obj.field = field;
  1453. obj.fields = fields;
  1454. obj.tFields = tFields;
  1455. obj.tablename = tablename;
  1456. obj.myfield = myfield;
  1457. return obj;
  1458. },
  1459. /**
  1460. * 有来源不能新增明细
  1461. */
  1462. hasSource: function(grid) {
  1463. var bool = false,field = null;
  1464. switch(caller) {
  1465. // case 'ProdInOut!Sale'://出货单
  1466. // field = 'pd_snid';
  1467. // break;
  1468. case 'ProdInOut!PurcCheckin': //采购验收单
  1469. field = 'pd_qcid';
  1470. break;
  1471. case 'ProdInOut!OutsideCheckIn': //委外验收单
  1472. field = 'pd_qcid';
  1473. break;
  1474. case 'ProdInOut!DefectIn': //不良品入库单
  1475. field = 'pd_qcid';
  1476. break;
  1477. }
  1478. if(field != null) {
  1479. var s = null;
  1480. grid.store.each(function(item){
  1481. s = item.get(field);
  1482. if(s != null && s != '' && s > 0) {
  1483. bool = true;return;
  1484. }
  1485. });
  1486. }
  1487. return bool;
  1488. },
  1489. isAllowUpdateQty: function(record) {
  1490. var bool = true;
  1491. switch(caller) {
  1492. case 'ProdInOut!PurcCheckin': //采购验收单
  1493. if(record.get('pd_qcid') != null && record.get('pd_qcid') > 0)
  1494. bool = false;
  1495. break;
  1496. case 'ProdInOut!OutsideCheckIn': //委外验收单
  1497. if(record.get('pd_qcid') != null && record.get('pd_qcid') > 0)
  1498. bool = false;
  1499. break;
  1500. case 'ProdInOut!DefectIn': //不良品入库单
  1501. if(record.get('pd_qcid') != null && record.get('pd_qcid') > 0)
  1502. bool = false;
  1503. break;
  1504. case 'ProdInOut!Make!In': //完工入库单
  1505. if(record.get('pd_qcid') != null && record.get('pd_qcid') > 0)
  1506. bool = false;
  1507. break;
  1508. }
  1509. return bool;
  1510. },
  1511. onPrint : function() {
  1512. var me = this, whichKind = Ext.getCmp('pi_class').value;
  1513. var reportName = '';
  1514. if(whichKind=="出货单"){
  1515. reportName="sendlist_yessale";
  1516. }else if(whichKind=="无订单出货单"){
  1517. reportName="sendlist_nosale";
  1518. }
  1519. else if(whichKind=="不良品入库单"){
  1520. //console.log("fds");
  1521. reportName="pio_notokin";
  1522. }else if(whichKind=="不良品出库单"){
  1523. reportName="pio_notokout";
  1524. }else if(whichKind=="其它采购入库单"){
  1525. reportName="piolist_opin";
  1526. }else if(whichKind=="其它采购出库单"){
  1527. reportName="piolist_opout";
  1528. }else if(whichKind=="拨入单"){
  1529. reportName="piolist_br";
  1530. }else if(whichKind=="拨出单"){
  1531. reportName="piolist_bc";
  1532. }else if(whichKind=="其它入库单"){
  1533. reportName="piolist_in";
  1534. }else if(whichKind=="其它出库单"){
  1535. reportName="piolist_out";
  1536. }else if(whichKind=="报废单"){
  1537. reportName="piolist_bf";
  1538. }else if(whichKind=="换货入库单"){
  1539. reportName="pio_changein";
  1540. }else if(whichKind=="换货出库单"){
  1541. reportName="pio_changeout";
  1542. }else if(whichKind=="销售退货单"){
  1543. reportName="retulist";
  1544. }else if(whichKind=="采购验收单"){
  1545. reportName="acclist";
  1546. }else if(whichKind=="采购验退单"){
  1547. reportName="piolist_yt";
  1548. }else if(whichKind=="销售拨入单"){
  1549. reportName="piolist";
  1550. }else if(whichKind=="销售拨出单"){
  1551. reportName="piolist_salebc";
  1552. }else if(whichKind=="生产领料单"){
  1553. reportName="PIOLISTM";
  1554. }else if(whichKind=="生产退料单"){
  1555. reportName="PIOLISTM_Back";
  1556. }else if(whichKind=="完工入库单"){
  1557. reportName="finish";
  1558. }else if(whichKind=="结余退料单"){
  1559. reportName="PIOLISTM_JY";
  1560. }else if(whichKind=="拆件入库单"){
  1561. reportName="chaijian";
  1562. }else if(whichKind=="生产补料单"){
  1563. reportName="PIOLIST_bl";
  1564. }else if(whichKind=="生产耗料单"){
  1565. reportName="PIOLISTM_HL";
  1566. }else if(whichKind=="委外领料单"){
  1567. reportName="Expiolist";
  1568. }else if(whichKind=="委外退料单"){
  1569. reportName="PIOLIST_wwtl";
  1570. }else if(whichKind=="委外验收单"){
  1571. reportName="EXPLIST_ys";
  1572. }else if(whichKind=="委外验退单"){
  1573. reportName="EXPLIST_yt";
  1574. }else if(whichKind=="生产报废单"){
  1575. reportName="MakeScrap";
  1576. }else if(whichKind=="无订单退货单"){
  1577. reportName="retulist_nosale";
  1578. }else if(whichKind=="委外补料单"){
  1579. reportName="Expiolist";
  1580. }else if(whichKind=="盘盈调整单"){
  1581. reportName="piolist_tz";
  1582. }else if(whichKind=="盘亏调整单"){
  1583. reportName="piolist_tz";
  1584. }else if(whichKind=="辅料入库单"){
  1585. reportName="piolist_flr";
  1586. }else if(whichKind=="辅料出库单"){
  1587. reportName="piolist_flc";
  1588. }else if(whichKind=="研发领料单"){
  1589. reportName="piolist_yfll";
  1590. }else if(whichKind=="研发退料单"){
  1591. reportName="piolist_yftl";
  1592. }else if(whichKind=="借货出货单"){
  1593. reportName="sendlist_jh";
  1594. }else if(whichKind=="借货归还单"){
  1595. reportName="sendlist_jhgh";
  1596. }
  1597. var condition = '{prodinout.pi_id}=' + Ext.getCmp('pi_id').value + '';
  1598. var id = Ext.getCmp('pi_id').value;
  1599. me.FormUtil.onwindowsPrint(id, reportName, condition);
  1600. },
  1601. /**
  1602. *编辑分装明细
  1603. **/
  1604. EditSubpackage:function(record){
  1605. var width = Ext.isIE ? screen.width*0.7*0.9 : '80%',
  1606. height = Ext.isIE ? screen.height*0.75 : '100%';
  1607. var pd_id = record.get('pd_id');
  1608. Ext.create('Ext.Window', {
  1609. width: width,
  1610. height: height,
  1611. autoShow: true,
  1612. layout: 'anchor',
  1613. items: [{
  1614. tag : 'iframe',
  1615. frame : true,
  1616. anchor : '100% 100%',
  1617. layout : 'fit',
  1618. html : '<iframe id="iframe_dbfind" src="' + basePath + 'jsps/scm/reserve/prodIODetail.jsp?formCondition=pd_id='
  1619. + pd_id + '&gridCondition=pdb_pdid=' + pd_id + '" height="100%" width="100%" frameborder="0" scrolling="no"></iframe>'
  1620. }]
  1621. });
  1622. },
  1623. loadOnHandQty: function(grid, id) {
  1624. Ext.Ajax.request({
  1625. url: basePath + 'scm/reserve/loadOnHandQty.action',
  1626. params: {
  1627. caller: caller,
  1628. id: id
  1629. },
  1630. callback: function(opt, s, r) {
  1631. var rs = Ext.decode(r.responseText);
  1632. if (rs.exceptionInfo) {
  1633. showMessage('提示', rs.exceptionInfo.replace('AFTERSUCCESS', ''));
  1634. } else {
  1635. var data = [];
  1636. if (!rs.data || rs.data.length == 2) {
  1637. grid.GridUtil.add10EmptyData(grid.detno, data);
  1638. grid.GridUtil.add10EmptyData(grid.detno, data);
  1639. } else {
  1640. data = Ext.decode(rs.data.replace(/,}/g, '}').replace(/,]/g, ']'));
  1641. }
  1642. grid.store.loadData(data);
  1643. }
  1644. }
  1645. });
  1646. },
  1647. Updatebgxh:function(record){
  1648. var win = this.bgxhwindow;
  1649. if (!win) {
  1650. win = this.getBgxhWindow();
  1651. }
  1652. win.show();
  1653. },
  1654. getBgxhWindow : function() {
  1655. var me = this;
  1656. return Ext.create('Ext.window.Window',{
  1657. width: 330,
  1658. height: 180,
  1659. closeAction: 'hide',
  1660. cls: 'custom-blue',
  1661. title:'<h1>更改报关型号</h1>',
  1662. layout: {
  1663. type: 'vbox'
  1664. },
  1665. items:[{
  1666. margin: '5 0 0 5',
  1667. xtype:'textfield',
  1668. fieldLabel:'报关型号',
  1669. name:'pd_bgxh',
  1670. id:'pd_bgxh'
  1671. },{
  1672. margin: '5 0 0 5',
  1673. xtype: 'fieldcontainer',
  1674. fieldLabel: '全部更新',
  1675. combineErrors: false,
  1676. defaults: {
  1677. hideLabel: true
  1678. },
  1679. layout: {
  1680. type: 'column',
  1681. defaultMargins: {top: 0, right: 5, bottom: 0, left: 0}
  1682. },
  1683. items: [{
  1684. xtype:'checkbox',
  1685. columnidth: 0.4,
  1686. fieldLabel:'全部更新',
  1687. name:'allupdate',
  1688. id:'allupdate'
  1689. },{
  1690. xtype:'displayfield',
  1691. fieldStyle:'color:red',
  1692. columnidth: 0.6,
  1693. value:' *更改当前所有明细'
  1694. }]
  1695. }],
  1696. buttonAlign:'center',
  1697. buttons:[{
  1698. xtype:'button',
  1699. text:'保存',
  1700. width:60,
  1701. iconCls: 'x-button-icon-save',
  1702. handler:function(btn){
  1703. var w = btn.up('window');
  1704. me.saveBgxh(w);
  1705. w.hide();
  1706. }
  1707. },{
  1708. xtype:'button',
  1709. columnWidth:0.1,
  1710. text:'关闭',
  1711. width:60,
  1712. iconCls: 'x-button-icon-close',
  1713. margin:'0 0 0 10',
  1714. handler:function(btn){
  1715. btn.up('window').hide();
  1716. }
  1717. }]
  1718. });
  1719. },
  1720. saveBgxh: function(w) {
  1721. var pd_bgxh = w.down('field[name=pd_bgxh]').getValue(),
  1722. grid = Ext.getCmp('grid'),
  1723. record = grid.getSelectionModel().getLastSelected();
  1724. if(!pd_bgxh) {
  1725. showError('请先设置报关型号.') ;
  1726. return;
  1727. } else {
  1728. var allupdate = w.down('field[name=allupdate]').getValue();
  1729. var dd = {
  1730. pd_id : record.data.pd_id,
  1731. pd_piid : record.data.pd_piid,
  1732. pd_bgxh : pd_bgxh ? pd_bgxh : null,
  1733. allupdate : allupdate ? 1 : 0,
  1734. caller: caller
  1735. };
  1736. Ext.Ajax.request({
  1737. url : basePath +'scm/reserve/updatebgxh.action',
  1738. params : {
  1739. _noc: 1,
  1740. data: unescape(Ext.JSON.encode(dd))
  1741. },
  1742. method : 'post',
  1743. callback : function(opt, s, res){
  1744. var r = new Ext.decode(res.responseText);
  1745. if(r.success){
  1746. showMessage('提示', '更新成功!', 1000);
  1747. } else if(r.exceptionInfo){
  1748. showError(r.exceptionInfo);
  1749. } else{
  1750. saveFailure();
  1751. }
  1752. }
  1753. });
  1754. }
  1755. },
  1756. batchdeal: function(nCaller, condition, url){
  1757. console.log('url: '+url);
  1758. var win = new Ext.window.Window({
  1759. id : 'win',
  1760. height: "100%",
  1761. width: "80%",
  1762. maximizable : true,
  1763. buttonAlign : 'center',
  1764. layout : 'anchor',
  1765. items: [{
  1766. tag : 'iframe',
  1767. frame : true,
  1768. anchor : '100% 100%',
  1769. layout : 'fit',
  1770. html : '<iframe id="iframe_' + caller + '" src="' + basePath + 'jsps/common/editorColumn.jsp?caller=' + nCaller
  1771. + "&condition=" + condition +'" height="100%" width="100%" frameborder="0" scrolling="no"></iframe>'
  1772. }],
  1773. buttons : [{
  1774. name: 'confirm',
  1775. text : $I18N.common.button.erpConfirmButton,
  1776. iconCls: 'x-button-icon-confirm',
  1777. cls: 'x-btn-gray',
  1778. listeners: {
  1779. buffer: 500,
  1780. click: function(btn) {
  1781. var grid = Ext.getCmp('win').items.items[0].body.dom.getElementsByTagName('iframe')[0].contentWindow.Ext.getCmp("editorColumnGridPanel");
  1782. btn.setDisabled(true);
  1783. grid.updateAction(url);
  1784. win.close();
  1785. //window.location.reload();
  1786. }
  1787. }
  1788. }, {
  1789. text : $I18N.common.button.erpCloseButton,
  1790. iconCls: 'x-button-icon-close',
  1791. cls: 'x-btn-gray',
  1792. handler : function(){
  1793. Ext.getCmp('win').close();
  1794. }
  1795. }]
  1796. });
  1797. win.show();
  1798. }
  1799. });