ProdInOut.js 139 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073
  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', 'core.form.SpecialContainField',
  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.PrintBKT', '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', 'core.button.TurnYPOutReturn',
  15. 'core.button.TurnOtherIn', 'core.button.TurnOtherOut', 'core.button.TurnOtherPurcOut', 'core.button.TurnAppropriationOut', 'core.button.TurnCustReturnOut', 'core.button.TurnPurcOut',
  16. 'core.button.ClearSubpackage', 'core.button.Subpackage', 'core.grid.YnColumn', 'core.button.CatchBatch', 'core.button.Printnosale', 'core.button.PrintNoCustomer', 'core.button.PrintBZT', 'core.button.PrintInvoice',
  17. 'core.button.SetMMQTY', 'core.button.TurnSaleReturn', 'core.button.TurnRenewApply', 'core.button.TurnMrb', 'core.button.UpdateInfo', 'core.button.Barcode', 'core.button.UpdateRemark', 'core.button.ZxbzsBarcode',
  18. 'core.button.PrintAll', 'core.form.CheckBoxGroup', 'core.button.PrintByCondition', 'core.button.CreateBill', 'core.button.TurnGoodsOut', 'core.button.PrintMT', 'core.button.CatchBatchByOrder',
  19. 'core.button.CatchBatchByClient', 'core.button.CatchBatchByCust'
  20. ],
  21. init: function() {
  22. var me = this;
  23. var grid = Ext.getCmp('grid');
  24. me.FormUtil = Ext.create('erp.util.FormUtil');
  25. me.GridUtil = Ext.create('erp.util.GridUtil');
  26. me.BaseUtil = Ext.create('erp.util.BaseUtil');
  27. this.control({
  28. 'erpCreateBillButton': {
  29. afterrender: function(btn) {
  30. var status = Ext.getCmp('pi_statuscode'),
  31. url = "";;
  32. if (status && status.value != 'POSTED') {
  33. btn.hide();
  34. }
  35. if (caller == 'ProdInOut!Sale' || caller == 'ProdInOut!SaleReturn') {
  36. me.BaseUtil.getSetting('sys', 'autoCreateArBill', function(bool) {
  37. if (!bool) {
  38. btn.hide();
  39. }
  40. });
  41. }
  42. if (caller == 'ProdInOut!PurcCheckin' || caller == 'ProdInOut!PurcCheckout' || caller == 'ProdInOut!OutesideCheckReturn' || caller == 'ProdInOut!OutsideCheckIn' || caller == 'ProdInOut!GoodsOut' || caller == 'ProdInOut!GoodsIn') {
  43. me.BaseUtil.getSetting('sys', 'autoCreateApBill', function(bool) {
  44. if (!bool) {
  45. btn.hide();
  46. }
  47. });
  48. }
  49. },
  50. click: function(btn) {
  51. Ext.Ajax.request({
  52. url: basePath + 'scm/reserve/createBill.action',
  53. params: {
  54. caller: caller,
  55. id: Ext.getCmp('pi_id').value
  56. },
  57. method: 'post',
  58. callback: function(options, success, response) {
  59. var res = new Ext.decode(response.responseText);
  60. if (res) {
  61. if (res.exceptionInfo) {
  62. showMessage('提示', res.exceptionInfo);
  63. } else {
  64. if (res.log == null || res.log == '')
  65. showMessage('提示', '产生形式发票成功');
  66. }
  67. } else {
  68. showMessage('提示', '产生形式发票失败');
  69. }
  70. }
  71. });
  72. }
  73. },
  74. 'erpCatchBatchButton': {
  75. afterrender: function(btn) {
  76. var status = Ext.getCmp('pi_statuscode');
  77. if (status && status.value == 'POSTED') {
  78. btn.hide();
  79. }
  80. },
  81. click: function(btn) {
  82. Ext.Ajax.request({
  83. url: basePath + 'scm/reserve/catchBatch.action',
  84. params: {
  85. caller: caller,
  86. id: Ext.getCmp('pi_id').value
  87. },
  88. method: 'post',
  89. callback: function(options, success, response) {
  90. var res = new Ext.decode(response.responseText);
  91. if (res) {
  92. if (res.exceptionInfo) {
  93. showMessage('提示', res.exceptionInfo);
  94. } else {
  95. if (res.log == null || res.log == '')
  96. showMessage('提示', '抓取成功');
  97. me.GridUtil.loadNewStore(grid, {
  98. caller: caller,
  99. condition: gridCondition
  100. });
  101. }
  102. } else {
  103. showMessage('提示', '抓取失败');
  104. }
  105. }
  106. });
  107. }
  108. },
  109. 'erpGridPanel2': {
  110. afterrender: function(grid) {
  111. grid.plugins[0].on('beforeedit', function(args) {
  112. if (args.field == "pd_inqty") {
  113. return me.isAllowUpdateQty(args.record);
  114. }
  115. if (caller == 'ProdInOut!SaleAppropriationOut' || 'ProdInOut!OtherOut' == caller) {
  116. if (args.field == "pd_ordercode") {
  117. return me.isAllowSale(args.record);
  118. }
  119. if (args.field == "pd_plancode") {
  120. return me.isAllowForeCast(args.record);
  121. }
  122. }
  123. });
  124. if (caller == 'ProdInOut!SaleReturn') {
  125. if (Ext.getCmp('pi_sourcecode') && Ext.getCmp('pi_sourcecode').value != "") {
  126. grid.readOnly = true;
  127. }
  128. }
  129. },
  130. itemclick: function(selModel, record) {
  131. var bool = me.hasSource(selModel.ownerCt);
  132. if (caller == 'ProdInOut!OtherIn' || caller == 'ProdInOut!OtherPurcIn') {
  133. if (record.data.pd_id > 0) {
  134. var btn = selModel.ownerCt.down('#erpEditSubpackageButton');
  135. if (btn && !btn.hidden)
  136. btn.setDisabled(false);
  137. }
  138. }
  139. if (caller == 'ProdInOut!Sale' || caller == 'ProdInOut!SaleReturn') {
  140. if (record.data.pd_id > 0) {
  141. var btn = Ext.getCmp('UpdateProdInoutrateButton');
  142. if (btn && !btn.hidden)
  143. btn && btn.setDisabled(false);
  144. }
  145. }
  146. if (caller == 'ProdInOut!PurcCheckout') {
  147. if (record.data.pd_id > 0 &&  Ext.getCmp('pi_statuscode').value != 'POSTED' &&  Ext.isEmpty(record.data.pd_ordercode)) {
  148. var btn = selModel.ownerCt.down('#erpGetPurcPrice');
  149. if (btn && !btn.hidden)
  150. btn.setDisabled(false);
  151. }
  152. }
  153. if (record.data.pd_id != 0 && record.data.pd_id != null && record.data.pd_id != '') {
  154. var btn = Ext.getCmp('updatebgxh');
  155. btn && btn.setDisabled(false);
  156. btn = Ext.getCmp('erpSaveOrdercodeButton');
  157. btn && btn.setDisabled(false);
  158. btn = Ext.getCmp('barcodebtn');
  159. btn && btn.setDisabled(false);
  160. btn = Ext.getCmp('erpUpdateDetailWHCode');
  161. btn && btn.setDisabled(false);
  162. btn = Ext.getCmp('erpUpdateBatchCode');
  163. btn && btn.setDisabled(false);
  164. btn = Ext.getCmp('splitdetail');
  165. btn && btn.setDisabled(false);
  166. if (Ext.getCmp('pi_statuscode').value != 'POSTED' && !Ext.isEmpty(record.data.pd_pocode)) {
  167. btn = Ext.getCmp('catchBatchByOrder');
  168. btn && btn.setDisabled(false);
  169. }
  170. }
  171. if (!bool)
  172. this.GridUtil.onGridItemClick(selModel, record);
  173. }
  174. },
  175. /**
  176. * 明细分拆
  177. */
  178. '#splitdetail': {
  179. afterrender: function(btn) {
  180. var status = Ext.getCmp('pi_invostatuscode'), poststatus = Ext.getCmp('pi_statuscode');
  181. if (status && status.value == 'AUDITED') {
  182. btn.hide();
  183. }
  184. if (poststatus && poststatus.value == 'POSTED') {
  185. btn.hide();
  186. }
  187. },
  188. click: function(btn) {
  189. var record=btn.ownerCt.ownerCt.getSelectionModel().getLastSelected();
  190. me.SplitDetail(record);
  191. }
  192. },
  193. '#UpdateProdInoutrateButton': {
  194. click: function(btn) {
  195. var record = btn.ownerCt.ownerCt.getSelectionModel().getLastSelected();
  196. me.updatepdscaleremark(record);
  197. }
  198. },
  199. /**
  200. * 更改报关型号
  201. */
  202. '#updatebgxh': {
  203. click: function(btn) {
  204. var record = btn.ownerCt.ownerCt.getSelectionModel().getLastSelected();
  205. me.Updatebgxh(record);
  206. }
  207. },
  208. 'erpDeleteDetailButton': {
  209. afterrender: function(btn) {
  210. btn.ownerCt.add({
  211. xtype: 'erpBarcodeButton'
  212. });
  213. }
  214. },
  215. 'erpUpdateRemarkButton': {
  216. beforerender: function(btn) {
  217. var status = Ext.getCmp('pi_invostatuscode'),
  218. poststatus = Ext.getCmp('pi_statuscode');
  219. if (caller == 'ProdInOut!OtherIn') {
  220. if (status && status.value == 'COMMITED') {
  221. Ext.getCmp('pi_remark').setReadOnly(false);
  222. } else {
  223. btn.hide();
  224. }
  225. }
  226. if (caller == 'ProdInOut!PurcCheckin') {
  227. if (poststatus && poststatus.value == 'POSTED') {
  228. Ext.getCmp('pi_remark').setReadOnly(false);
  229. } else {
  230. btn.hide();
  231. }
  232. }
  233. if (caller == 'ProdInOut!PurcCheckout') {
  234. if (status && status.value == 'AUDITED') {
  235. Ext.getCmp('pi_remark').setReadOnly(false);
  236. } else {
  237. btn.hide();
  238. }
  239. }
  240. if (caller == 'ProdInOut!OutesideCheckReturn') {
  241. if (status && status.value == 'AUDITED') {
  242. Ext.getCmp('pi_remark').setReadOnly(false);
  243. } else {
  244. btn.hide();
  245. }
  246. }
  247. },
  248. click: function(btn) {
  249. var remark = Ext.getCmp('pi_remark').value;
  250. var id = Ext.getCmp('pi_id').value;
  251. Ext.Ajax.request({
  252. url: basePath + 'scm/sale/updateProdInOutOtherInRemark.action',
  253. params: {
  254. id: id,
  255. remark: remark
  256. },
  257. method: 'post',
  258. callback: function(options, success, response) {
  259. var res = new Ext.decode(response.responseText);
  260. if (res.exceptionInfo) {
  261. showError(rs.exceptionInfo);
  262. } else {
  263. showMessage('提示', '更新备注成功!');
  264. window.location.reload();
  265. }
  266. }
  267. });
  268. }
  269. },
  270. 'erpBarcodeButton': {
  271. click: function(btn) {
  272. var pdid = btn.ownerCt.ownerCt.ownerCt.items.items[1].selModel.selected.items[0].data["pd_id"];
  273. var id = Ext.getCmp("pi_id").value;
  274. var formCondition1 = "pd_idIS" + pdid + " and pi_idIS'" + id + "'";
  275. var gridCondition1 = "bi_pdidIS" + pdid + " and bi_piidIS'" + id + "'";
  276. var linkCaller = '';
  277. //获取出入库单DS_INOROUT字段判读是出库单还是入库单
  278. Ext.Ajax.request({
  279. url: basePath + 'common/getFieldData.action',
  280. params: {
  281. caller: "documentsetup",
  282. field: 'ds_inorout',
  283. condition: "ds_name='" + Ext.getCmp("pi_class").value + "'"
  284. },
  285. method: 'post',
  286. callback: function(options, success, response) {
  287. var res = new Ext.decode(response.responseText);
  288. if (res.exceptionInfo) {
  289. showError(rs.exceptionInfo);
  290. } else {
  291. var inOrOut = res.data;
  292. if (inOrOut == "IN" || inOrOut == "-OUT") {
  293. linkCaller = "ProdInOut!BarcodeIn";
  294. } else if (inOrOut == "-IN" || inOrOut == "OUT") {
  295. linkCaller = "ProdInOut!BarcodeOut";
  296. }
  297. var win = new Ext.window.Window({
  298. id: 'win',
  299. height: '90%',
  300. width: '95%',
  301. maximizable: true,
  302. buttonAlign: 'center',
  303. layout: 'anchor',
  304. items: [{
  305. tag: 'iframe',
  306. frame: true,
  307. anchor: '100% 100%',
  308. layout: 'fit',
  309. 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>'
  310. }],
  311. listeners: {
  312. 'beforeclose': function(view, opt) {
  313. var postStatus = Ext.getCmp('pi_statuscode');
  314. if (postStatus && postStatus.value != 'POSTED') {
  315. var grid = Ext.getCmp("grid");
  316. me.GridUtil.loadNewStore(grid, {
  317. caller: caller,
  318. condition: gridCondition
  319. });
  320. }
  321. }
  322. }
  323. });
  324. win.show();
  325. }
  326. }
  327. });
  328. },
  329. afterrender: function(btn) {
  330. btn.setDisabled(true);
  331. }
  332. },
  333. '#erpEditSubpackageButton': {
  334. afterrender: function(btn) {
  335. var status = Ext.getCmp('pi_invostatuscode');
  336. if (status && status.value != 'AUDITED') {
  337. btn.hide();
  338. }
  339. },
  340. click: function(btn) {
  341. var record = btn.ownerCt.ownerCt.getSelectionModel().getLastSelected();
  342. me.EditSubpackage(record);
  343. }
  344. },
  345. '#erpGetPurcPrice': {
  346. click: function(btn) {
  347. var record = btn.ownerCt.ownerCt.getSelectionModel().getLastSelected();
  348. me.getPurcPrice(record);
  349. }
  350. },
  351. '#erpUpdateBatchCode': {
  352. afterrender: function(btn) {
  353. var status = Ext.getCmp('pi_invostatuscode'),
  354. poststatus = Ext.getCmp('pi_statuscode');
  355. if (status && status.value == 'ENTERING') {
  356. btn.hide();
  357. }
  358. if (poststatus && poststatus.value == 'POSTED') {
  359. btn.hide();
  360. }
  361. },
  362. click: function(btn) {
  363. var record = btn.ownerCt.ownerCt.getSelectionModel().getLastSelected();
  364. me.updateBatchCode(record);
  365. }
  366. },
  367. '#erpSaveOrdercodeButton': {
  368. afterrender: function(btn) {
  369. var status = Ext.getCmp('pi_invostatuscode'),
  370. poststatus = Ext.getCmp('pi_statuscode');
  371. if (status && status.value == 'ENTERING') {
  372. btn.hide();
  373. }
  374. if (poststatus && poststatus.value == 'POSTED') {
  375. btn.hide();
  376. }
  377. },
  378. click: function(btn) {
  379. var record = btn.ownerCt.ownerCt.getSelectionModel().getLastSelected();
  380. me.updateOrderCode(record);
  381. }
  382. },
  383. 'erpTurnProdinoutReturnButton': {
  384. click: function(btn) {
  385. var id = Ext.getCmp('pi_id').value;
  386. Ext.Ajax.request({
  387. url: basePath + 'scm/sale/turnTurnProdinoutReturn.action',
  388. params: {
  389. id: id
  390. },
  391. method: 'post',
  392. callback: function(options, success, response) {
  393. var res = new Ext.decode(response.responseText);
  394. if (res.exceptionInfo) {
  395. showError(rs.exceptionInfo);
  396. } else {
  397. if (res.log)
  398. showMessage('提示', res.log);
  399. }
  400. }
  401. });
  402. }
  403. },
  404. 'erpSplitButton': {
  405. afterrender: function(btn) {
  406. var poststatus = Ext.getCmp('pi_statuscode');
  407. if (poststatus && poststatus.value == 'POSTED') {
  408. btn.hide();
  409. }
  410. },
  411. click: function(btn) {
  412. warnMsg("确定拆分单据?", function(btn) {
  413. if (btn == 'yes') {
  414. var id = Ext.getCmp('pi_id').value;
  415. var piclass = Ext.getCmp('pi_class').value;
  416. Ext.Ajax.request({
  417. url: basePath + 'scm/reserve/split.action',
  418. params: {
  419. id: id,
  420. caller: caller,
  421. cls: piclass
  422. },
  423. method: 'post',
  424. callback: function(options, success, response) {
  425. var res = new Ext.decode(response.responseText);
  426. if (res.exceptionInfo) {
  427. showError(res.exceptionInfo);
  428. } else {
  429. if (res.log)
  430. showMessage('提示', res.log);
  431. }
  432. }
  433. });
  434. }
  435. });
  436. }
  437. },
  438. 'erpGridWinButton': {
  439. afterrender: function(btn) {
  440. var id = Ext.getCmp('pi_id').value,
  441. piclass = Ext.getCmp('pi_class').value,
  442. cal;
  443. if (piclass == '采购验收单') {
  444. cal = 'ProdChargeDetail!CGYS';
  445. } else if (piclass == '采购验退单') {
  446. cal = 'ProdChargeDetail!CGYT';
  447. } else if (piclass == '出货单') {
  448. cal = 'ProdChargeDetail!XSCH';
  449. } else if (piclass == '销售退货单') {
  450. cal = 'ProdChargeDetail!XSTH';
  451. }
  452. btn.setConfig({
  453. text: '费用明细',
  454. caller: cal,
  455. condition: 'pd_piid=' + id,
  456. paramConfig: {
  457. pd_piid: id
  458. }
  459. });
  460. },
  461. beforesave: function(btn) {
  462. var f = btn.ownerCt.ownerCt,
  463. p = f.down('field[name=pi_statuscode]');
  464. if (p && 'POSTED' == p.getValue()) {
  465. Ext.Msg.alert("提示", "该单据已经过账,不能修改费用明细!");
  466. return false;
  467. }
  468. return true;
  469. }
  470. },
  471. 'field[name=pi_testcolumn1]': {
  472. beforerender: function(field) {
  473. field.labelWidth = 800;
  474. }
  475. },
  476. 'erpSaveButton': {
  477. click: function(btn) {
  478. var form = me.getForm(btn);
  479. if (Ext.getCmp(form.codeField).value == null || Ext.getCmp(form.codeField).value == '') {
  480. me.BaseUtil.getRandomNumber(caller, 2, form.codeField); //自动添加编号
  481. }
  482. me.save(btn);
  483. }
  484. },
  485. 'erpPrintA4Button': {
  486. click: function(btn) {
  487. var reportName = '';
  488. var kind = Ext.getCmp('pi_class').value;
  489. if (kind == '拨出单') {
  490. reportName = "piolist_bc4"
  491. } else if (kind == '出货单') {
  492. reportName = "sendlist"
  493. } else if (kind == '生产退料单') {
  494. reportName = "PIOLISTM_BackA4"
  495. } else if (kind == '生产补料单') {
  496. reportName = "PIOLIST_blA4"
  497. } else if (kind == '生产领料单') {
  498. reportName = "PIOLISTMA4"
  499. } else if (kind == '其它出库单') {
  500. reportName = "piolist_outA4"
  501. } else if (kind == '其它入库单') {
  502. reportName = "piolist_inA4"
  503. } else if (kind == '报废单') {
  504. reportName = "piolist_bfA4"
  505. }
  506. var condition = '{prodinout.pi_id}=' + Ext.getCmp('pi_id').value + '';
  507. var id = Ext.getCmp('pi_id').value;
  508. me.FormUtil.onwindowsPrint(id, reportName, condition);
  509. }
  510. },
  511. 'erpUpdatePdpriceButton': {
  512. click: function(btn) {
  513. var p = Ext.getCmp('pi_statuscode');
  514. if (p && 'POSTED' == p.getValue()) {
  515. Ext.Msg.alert("提示", "该单据已经过账,不能修改费用明细!");
  516. return;
  517. }
  518. var id = Ext.getCmp('pi_id').value;
  519. Ext.Ajax.request({
  520. url: basePath + 'scm/reserve/updatepdPrice.action',
  521. params: {
  522. id: id
  523. },
  524. method: 'post',
  525. callback: function(options, success, response) {
  526. var res = new Ext.decode(response.responseText);
  527. window.location.reload();
  528. if (!res.bool) {
  529. btn.hide();
  530. }
  531. }
  532. });
  533. }
  534. },
  535. 'erpDeleteButton': {
  536. afterrender: function(btn) {
  537. var status = Ext.getCmp(me.getForm(btn).statuscodeField),
  538. poststatus = Ext.getCmp('pi_statuscode');
  539. if (status && status.value == 'DELETED') {
  540. btn.hide();
  541. }
  542. if (poststatus && poststatus.value == 'POSTED') {
  543. btn.hide();
  544. }
  545. },
  546. click: function(btn) {
  547. me.FormUtil.onDelete({
  548. pu_id: Number(Ext.getCmp('pi_id').value)
  549. });
  550. }
  551. },
  552. 'erpResetbatchButton': {
  553. afterrender: function(btn) {
  554. var status = Ext.getCmp('pi_statuscode');
  555. if (status && status.value != 'UNPOST') {
  556. btn.hide();
  557. }
  558. },
  559. click: function(btn) {
  560. Ext.Ajax.request({
  561. url: basePath + 'scm/reserve/resetBatchcode.action',
  562. params: {
  563. caller: caller,
  564. id: Ext.getCmp('pi_id').value
  565. },
  566. method: 'post',
  567. callback: function(options, success, response) {
  568. var res = new Ext.decode(response.responseText);
  569. if (res.exceptionInfo) {
  570. showError(res.exceptionInfo);
  571. return;
  572. } else if (res.success) {
  573. showMessage("提示", "批号重置成功!");
  574. window.location.reload();
  575. }
  576. }
  577. });
  578. }
  579. },
  580. 'erpUpdateButton': {
  581. afterrender: function(btn) {
  582. var status = Ext.getCmp(me.getForm(btn).statuscodeField);
  583. if (status && status.value != 'ENTERING') {
  584. btn.hide();
  585. }
  586. status = Ext.getCmp('pi_statuscode');
  587. if (status && 'POSTED' == status.value) {
  588. btn.hide();
  589. }
  590. },
  591. click: function(btn) {
  592. var grid = Ext.getCmp('grid'),
  593. items = grid.store.data.items,
  594. c = Ext.getCmp('pi_inoutno').value;
  595. var piclass = Ext.getCmp('pi_class').value,
  596. date = Ext.getCmp('pi_date').value;
  597. var bool = true;
  598. if (caller == 'ProdInOut!PurcCheckout') {
  599. Ext.each(items, function(item) {
  600. if (!Ext.isEmpty(item.data['pd_ordercode'])) {
  601. if (item.data['pd_outqty'] > item.data['pd_acceptqty']) {
  602. bool = false;
  603. showError('明细表第' + item.data['pd_pdno'] + '数量大于采购单的验收数量');
  604. return;
  605. }
  606. }
  607. });
  608. }
  609. if (caller == 'ProdInOut!OtherPurcIn') {
  610. Ext.each(items, function(item) {
  611. if (!Ext.isEmpty(item.data['pd_ordercode'])) {
  612. if (Ext.Date.format(item.data['pd_vendorreplydate'], 'Ymd') < Ext.Date.format(new Date(), 'Ymd')) {
  613. bool = false;
  614. showError('明细表第' + item.data['pd_pdno'] + '还料日期小于系统当前日期');
  615. return;
  616. }
  617. }
  618. });
  619. }
  620. Ext.Array.each(items, function(item) {
  621. if (!Ext.isEmpty(item.data['pd_prodcode'])) {
  622. item.set('pd_inoutno', c);
  623. item.set('pd_piclass', piclass);
  624. }
  625. if (caller == 'ProdInOut!OtherIn' || caller == 'ProdInOut!OtherPurcIn') {
  626. if (item.data['pd_unitpackage'] == null || item.data['pd_unitpackage'] == '' ||
  627. item.data['pd_unitpackage'] == '0' || item.data['pd_unitpackage'] == 0) {
  628. item.set('pd_unitpackage', item.data['pd_inqty']);
  629. }
  630. }
  631. });
  632. if (caller != 'ProdInOut!AppropriationOut' && caller != 'ProdInOut!AppropriationIn') {
  633. var whcode = Ext.getCmp('pi_whcode'),
  634. whname = Ext.getCmp('pi_whname');
  635. if (whcode && whname) {
  636. Ext.Array.each(items, function(item) {
  637. if (!Ext.isEmpty(item.data['pd_prodcode'])) {
  638. if (Ext.isEmpty(item.data['pd_whcode'])) {
  639. item.set('pd_whcode', whcode.value);
  640. item.set('pd_whname', whname.value);
  641. }
  642. }
  643. });
  644. }
  645. }
  646. if (caller == 'ProdInOut!SaleAppropriationOut' || 'ProdInOut!OtherOut' == caller) {
  647. Ext.Array.each(items, function(item) {
  648. if (!Ext.isEmpty(item.data['pd_plancode'])) {
  649. if (item.data['pd_outqty'] > item.data['pd_sfdqty']) {
  650. bool = false;
  651. showError('明细表第' + item.data['pd_pdno'] + '数量大于销售预测单数量');
  652. return;
  653. }
  654. }
  655. if (!Ext.isEmpty(item.data['pd_ordercode'])) {
  656. if (item.data['pd_outqty'] > item.data['sd_qty']) {
  657. bool = false;
  658. showError('明细表第' + item.data['pd_pdno'] + '数量大于销售单数量');
  659. return;
  660. }
  661. }
  662. });
  663. }
  664. if (caller == 'ProdInOut!SaleAppropriationOut' || 'ProdInOut!AppropriationOut' == caller) {
  665. var pi_purpose = Ext.getCmp('pi_purpose'),
  666. pi_purposename = Ext.getCmp('pi_purposename');
  667. var pi_whcode = Ext.getCmp('pi_whcode'),
  668. pi_whname = Ext.getCmp('pi_whname');
  669. if (pi_whcode && pi_whname) {
  670. Ext.Array.each(items, function(item) {
  671. if (!Ext.isEmpty(item.data['pd_prodcode'])) {
  672. if (Ext.isEmpty(item.data['pd_whcode'])) {
  673. item.set('pd_whcode', pi_whcode.value);
  674. item.set('pd_whname', pi_whname.value);
  675. }
  676. }
  677. });
  678. }
  679. if (pi_purpose && pi_purposename) {
  680. Ext.Array.each(items, function(item) {
  681. if (!Ext.isEmpty(item.data['pd_prodcode'])) {
  682. if (Ext.isEmpty(item.data['pd_inwhcode'])) {
  683. item.set('pd_inwhcode', pi_purpose.value);
  684. item.set('pd_inwhname', pi_purposename.value);
  685. }
  686. }
  687. });
  688. }
  689. }
  690. // 拨入单、拨出单,默认第一行的仓库
  691. me.setDetailWarehouse(grid);
  692. if (caller == 'ProdInOut!Make!Return' || caller == 'ProdInOut!OutsideReturn' || caller == 'ProdInOut!Make!Useless') {
  693. var firstItem = grid.store.getAt(0);
  694. if (firstItem) {
  695. var desc = firstItem.get('pd_description'),
  696. dc = firstItem.get('pd_departmentcode'),
  697. dn = firstItem.get('pd_departmentname'),
  698. whcode = firstItem.get('pd_whcode'),
  699. whname = firstItem.get('pd_whname'),
  700. pd_textbox = firstItem.get('pd_textbox');
  701. Ext.Array.each(items, function(item) {
  702. if (!Ext.isEmpty(item.data['pd_prodcode'])) {
  703. if (Ext.isEmpty(item.data['pd_description'])) {
  704. item.set('pd_description', desc);
  705. }
  706. if (Ext.isEmpty(item.data['pd_departmentcode'])) {
  707. item.set('pd_departmentcode', dc);
  708. item.set('pd_departmentname', dn);
  709. }
  710. if (Ext.isEmpty(item.data['pd_whcode'])) {
  711. item.set('pd_whcode', whcode);
  712. item.set('pd_whname', whname);
  713. }
  714. if (caller == 'ProdInOut!Make!Useless') {
  715. if (Ext.isEmpty(item.data['pd_textbox'])) {
  716. item.set('pd_textbox', pd_textbox);
  717. }
  718. }
  719. }
  720. });
  721. }
  722. }
  723. if (bool) {
  724. me.FormUtil.onUpdate(me);
  725. }
  726. }
  727. },
  728. 'erpAddButton': {
  729. click: function() {
  730. me.FormUtil.onAdd('add' + caller, '新增出入库单', "jsps/scm/reserve/prodInOut.jsp?whoami=" + caller);
  731. }
  732. },
  733. 'erpCloseButton': {
  734. click: function(btn) {
  735. me.FormUtil.beforeClose(me);
  736. }
  737. },
  738. 'field[name=pi_currency]': {
  739. beforetrigger: function(field) {
  740. var t = field.up('form').down('field[name=pi_date]'),
  741. value = t.getValue();
  742. if (value) {
  743. field.findConfig = 'cm_yearmonth=' + Ext.Date.format(value, 'Ym');
  744. }
  745. }
  746. },
  747. 'erpSubmitButton': {
  748. afterrender: function(btn) {
  749. var status = Ext.getCmp(me.getForm(btn).statuscodeField),
  750. poststatus = Ext.getCmp('pi_statuscode');
  751. if (status && status.value != 'ENTERING') {
  752. btn.hide();
  753. }
  754. if (poststatus && poststatus.value == 'POSTED') {
  755. btn.hide();
  756. }
  757. },
  758. click: function(btn) {
  759. var grid = Ext.getCmp('grid');
  760. var items = grid.store.data.items;
  761. var bool = true;
  762. var date = Ext.getCmp('pi_date').value;
  763. if (caller == 'ProdInOut!OtherIn' || caller == 'ProdInOut!OtherOut') {
  764. var type = Ext.getCmp('pi_type').value;
  765. if (type == null || type == '') {
  766. showError("主表类型字段未填写,不能提交!");
  767. return;
  768. }
  769. }
  770. if (caller == 'ProdInOut!PurcCheckout') {
  771. Ext.each(items, function(item) {
  772. if (!Ext.isEmpty(item.data['pd_ordercode'])) {
  773. if (item.data['pd_outqty'] > item.data['pd_acceptqty']) {
  774. bool = false;
  775. showError('明细表第' + item.data['pd_pdno'] + '数量大于采购单的验收数量');
  776. return;
  777. }
  778. }
  779. });
  780. }
  781. if (caller == 'ProdInOut!OtherPurcIn') {
  782. Ext.each(items, function(item) {
  783. if (!Ext.isEmpty(item.data['pd_ordercode'])) {
  784. if (Ext.Date.format(item.data['pd_vendorreplydate'], 'Ymd') < Ext.Date.format(new Date(), 'Ymd')) {
  785. bool = false;
  786. showError('明细表第' + item.data['pd_pdno'] + '还料日期小于系统当前日期');
  787. return;
  788. }
  789. }
  790. });
  791. }
  792. /*Ext.each(items, function(item){
  793. if(item.data[grid.necessaryField] != null && item.data[grid.necessaryField] != ''){
  794. if(item.data['pd_outqty'] == null || item.data['pd_outqty'] == ''){
  795. bool = false;
  796. showError("明细第" + item.data['pd_pdno'] + "行出库数量未填写,不能提交");return;
  797. }
  798. }
  799. });*/
  800. if (caller == 'ProdInOut!SaleAppropriationOut' || 'ProdInOut!OtherOut' == caller) {
  801. Ext.Array.each(items, function(item) {
  802. if (!Ext.isEmpty(item.data['pd_plancode'])) {
  803. if (item.data['pd_outqty'] > item.data['pd_sfdqty']) {
  804. bool = false;
  805. showError('明细表第' + item.data['pd_pdno'] + '数量大于销售预测单数量');
  806. return;
  807. }
  808. }
  809. if (!Ext.isEmpty(item.data['pd_ordercode'])) {
  810. if (item.data['pd_outqty'] > item.data['sd_qty']) {
  811. bool = false;
  812. showError('明细表第' + item.data['pd_pdno'] + '数量大于销售单数量');
  813. return;
  814. }
  815. }
  816. });
  817. }
  818. if (caller == 'ProdInOut!AppropriationOut') {
  819. Ext.each(items, function(item) {
  820. if (item.data[grid.necessaryField] != null && item.data[grid.necessaryField] != '') {
  821. if (Ext.getCmp('pd_outqty') && item.data['pd_outqty'] == null || item.data['pd_outqty'] == '') {
  822. bool = false;
  823. showError("明细第" + item.data['pd_pdno'] + "行出库数量未填写,不能提交");
  824. return;
  825. }
  826. }
  827. });
  828. }
  829. if (bool) {
  830. me.FormUtil.onSubmit(Ext.getCmp('pi_id').value);
  831. }
  832. }
  833. },
  834. 'erpResSubmitButton': {
  835. afterrender: function(btn) {
  836. var status = Ext.getCmp(me.getForm(btn).statuscodeField),
  837. poststatus = Ext.getCmp('pi_statuscode');
  838. if (status && status.value != 'COMMITED') {
  839. btn.hide();
  840. }
  841. if (poststatus && poststatus.value == 'POSTED') {
  842. btn.hide();
  843. }
  844. },
  845. click: function(btn) {
  846. me.FormUtil.onResSubmit(Ext.getCmp('pi_id').value);
  847. }
  848. },
  849. 'erpAuditButton': {
  850. afterrender: function(btn) {
  851. var status = Ext.getCmp(me.getForm(btn).statuscodeField),
  852. poststatus = Ext.getCmp('pi_statuscode');
  853. if (status && status.value != 'COMMITED') {
  854. btn.hide();
  855. }
  856. if (poststatus && poststatus.value == 'POSTED') {
  857. btn.hide();
  858. }
  859. },
  860. click: function(btn) {
  861. var grid = Ext.getCmp('grid');
  862. var items = grid.store.data.items;
  863. var bool = true;
  864. if (caller == 'ProdInOut!OtherPurcIn') {
  865. Ext.each(items, function(item) {
  866. if (!Ext.isEmpty(item.data['pd_ordercode'])) {
  867. if (Ext.Date.format(item.data['pd_vendorreplydate'], 'Ymd') < Ext.Date.format(new Date(), 'Ymd')) {
  868. bool = false;
  869. showError('明细表第' + item.data['pd_pdno'] + '还料日期小于系统当前日期');
  870. return;
  871. }
  872. }
  873. });
  874. }
  875. if (caller == 'ProdInOut!SaleAppropriationOut' || 'ProdInOut!OtherOut' == caller) {
  876. Ext.Array.each(items, function(item) {
  877. if (!Ext.isEmpty(item.data['pd_plancode'])) {
  878. if (item.data['pd_outqty'] > item.data['pd_sfdqty']) {
  879. bool = false;
  880. showError('明细表第' + item.data['pd_pdno'] + '数量大于销售预测单数量');
  881. return;
  882. }
  883. }
  884. if (!Ext.isEmpty(item.data['pd_ordercode'])) {
  885. if (item.data['pd_outqty'] > item.data['sd_qty']) {
  886. bool = false;
  887. showError('明细表第' + item.data['pd_pdno'] + '数量大于销售单数量');
  888. return;
  889. }
  890. }
  891. });
  892. }
  893. if (bool)
  894. me.FormUtil.onAudit(Ext.getCmp('pi_id').value);
  895. }
  896. },
  897. 'erpResAuditButton': {
  898. afterrender: function(btn) {
  899. var status = Ext.getCmp(me.getForm(btn).statuscodeField),
  900. postStatus = Ext.getCmp('pi_statuscode');
  901. if ((status && status.value != 'AUDITED') || (postStatus && postStatus.value == 'POSTED')) {
  902. btn.hide();
  903. }
  904. },
  905. click: function(btn) {
  906. me.FormUtil.onResAudit(Ext.getCmp('pi_id').value);
  907. }
  908. },
  909. 'erpPrintButton': {
  910. click: function(btn) {
  911. me.onPrint();
  912. }
  913. },
  914. 'erpPrintotherinButton': { // 返修机入仓单
  915. click: function(btn) {
  916. var reportName = "piolist_otherin";
  917. var condition = '{prodinout.pi_id}=' + Ext.getCmp('pi_id').value + '';
  918. var id = Ext.getCmp('pi_id').value;
  919. me.FormUtil.onwindowsPrint(id, reportName, condition);
  920. }
  921. },
  922. 'erpPrintotheroutButton': { // 返修机出仓单
  923. click: function(btn) {
  924. var reportName = "piolist_otherout";
  925. var condition = '{prodinout.pi_id}=' + Ext.getCmp('pi_id').value + '';
  926. var id = Ext.getCmp('pi_id').value;
  927. me.FormUtil.onwindowsPrint(id, reportName, condition);
  928. }
  929. },
  930. 'erpPrintwithPriceButton': { // 无价打印==erpPrintButton
  931. click: function(btn) {
  932. var reportName = "sendlist_yessale_yesprice";
  933. var condition = '{prodinout.pi_id}=' + Ext.getCmp('pi_id').value + '';
  934. var id = Ext.getCmp('pi_id').value;
  935. me.FormUtil.onwindowsPrint(id, reportName, condition);
  936. }
  937. },
  938. 'erpPrintBKTButton': { // 打印补客退==erpPrintButton
  939. click: function(btn) {
  940. var reportName = "sendlist_bh";
  941. var condition = '{prodinout.pi_id}=' + Ext.getCmp('pi_id').value + '';
  942. var id = Ext.getCmp('pi_id').value;
  943. me.FormUtil.onwindowsPrint(id, reportName, condition);
  944. }
  945. },
  946. 'erpPrintPriceButton': { // (有价)打印,和erpPrintwithPriceButton一样,某些客户需要默认为有效
  947. click: function(btn) {
  948. var reportName = "sendlist_yessale_yesprice";
  949. var condition = '{prodinout.pi_id}=' + Ext.getCmp('pi_id').value + '';
  950. var id = Ext.getCmp('pi_id').value;
  951. me.FormUtil.onwindowsPrint(id, reportName, condition);
  952. }
  953. },
  954. 'erpPrintnosaleButton': { // 无PO打印
  955. click: function(btn) {
  956. var reportName = "sendlist_nosale";
  957. var condition = '{prodinout.pi_id}=' + Ext.getCmp('pi_id').value + '';
  958. var id = Ext.getCmp('pi_id').value;
  959. me.FormUtil.onwindowsPrint(id, reportName, condition);
  960. }
  961. },
  962. 'erpPrintBZTButton': {
  963. click: function(btn) {
  964. var reportName = "sale_packing";
  965. var condition = '{prodinout.pi_id}=' + Ext.getCmp('pi_id').value + '';
  966. me.FormUtil.onwindowsPrint(Ext.getCmp('pi_id').value, reportName, condition);
  967. }
  968. },
  969. 'erpPrintInvoiceButton': {
  970. click: function(btn) {
  971. var reportName = "sale_invoice";
  972. var condition = '{prodinout.pi_id}=' + Ext.getCmp('pi_id').value + '';
  973. var id = Ext.getCmp('pi_id').value;
  974. me.FormUtil.onwindowsPrint(id, reportName, condition);
  975. }
  976. },
  977. 'erpPrintNoCustomerButton': { // 无客户打印
  978. click: function(btn) {
  979. var reportName = "sendlist_yessale_nocustomer";
  980. var condition = '{prodinout.pi_id}=' + Ext.getCmp('pi_id').value + '';
  981. var id = Ext.getCmp('pi_id').value;
  982. me.FormUtil.onwindowsPrint(id, reportName, condition);
  983. }
  984. },
  985. 'erpPrintNoPriceButton': { // 无价打印==erpPrintButton
  986. click: function(btn) {
  987. me.onPrint();
  988. }
  989. },
  990. 'erpPostButton': {
  991. afterrender: function(btn) {
  992. var status = Ext.getCmp('pi_statuscode');
  993. if (status && status.value != 'UNPOST') {
  994. btn.hide();
  995. }
  996. },
  997. buffer: 1000,
  998. click: function(btn) {
  999. var grid = Ext.getCmp('grid'),
  1000. items = grid.store.data.items,
  1001. bool = true;
  1002. var date = Ext.getCmp('pi_date').value;
  1003. if (caller == 'ProdInOut!OtherIn' || caller == 'ProdInOut!OtherOut') {
  1004. var type = Ext.getCmp('pi_type').value;
  1005. if (type == null || type == '') {
  1006. showError("主表类型字段未填写,不能提交!");
  1007. return;
  1008. }
  1009. }
  1010. if (caller == 'ProdInOut!PurcCheckout') {
  1011. Ext.each(items, function(item) {
  1012. if (!Ext.isEmpty(item.data['pd_ordercode'])) {
  1013. if (item.data['pd_outqty'] > item.data['pd_acceptqty']) {
  1014. bool = false;
  1015. showError('明细表第' + item.data['pd_pdno'] + '数量大于采购单的验收数量');
  1016. return;
  1017. }
  1018. }
  1019. });
  1020. }
  1021. if (caller == 'ProdInOut!OtherPurcIn') {
  1022. Ext.each(items, function(item) {
  1023. if (!Ext.isEmpty(item.data['pd_ordercode'])) {
  1024. if (Ext.Date.format(item.data['pd_vendorreplydate'], 'Ymd') < Ext.Date.format(new Date(), 'Ymd')) {
  1025. bool = false;
  1026. showError('明细表第' + item.data['pd_pdno'] + '还料日期小于系统当前日期');
  1027. return;
  1028. }
  1029. }
  1030. });
  1031. }
  1032. /*Ext.each(items, function(item){
  1033. if(item.data[grid.necessaryField] != null && item.data[grid.necessaryField] != ''){
  1034. if(item.data['pd_outqty'] == null || item.data['pd_outqty'] == ''){
  1035. bool = false;
  1036. showError("明细第" + item.data['pd_pdno'] + "行出库数量未填写,不能提交");return;
  1037. }
  1038. }
  1039. });*/
  1040. if (caller == 'ProdInOut!AppropriationOut') {
  1041. Ext.each(items, function(item) {
  1042. if (item.data[grid.necessaryField] != null && item.data[grid.necessaryField] != '') {
  1043. if (Ext.getCmp('pd_outqty') && item.data['pd_outqty'] == null || item.data['pd_outqty'] == '') {
  1044. bool = false;
  1045. showError("明细第" + item.data['pd_pdno'] + "行出库数量未填写,不能提交");
  1046. return;
  1047. }
  1048. }
  1049. });
  1050. }
  1051. if (caller == 'ProdInOut!SaleAppropriationOut' || 'ProdInOut!OtherOut' == caller) {
  1052. Ext.Array.each(items, function(item) {
  1053. if (!Ext.isEmpty(item.data['pd_plancode'])) {
  1054. if (item.data['pd_outqty'] > item.data['pd_sfdqty']) {
  1055. bool = false;
  1056. showError('明细表第' + item.data['pd_pdno'] + '数量大于销售预测单数量');
  1057. return;
  1058. }
  1059. }
  1060. if (!Ext.isEmpty(item.data['pd_ordercode'])) {
  1061. if (item.data['pd_outqty'] > item.data['sd_qty']) {
  1062. bool = false;
  1063. showError('明细表第' + item.data['pd_pdno'] + '数量大于销售单数量');
  1064. return;
  1065. }
  1066. }
  1067. });
  1068. }
  1069. if (bool) {
  1070. me.FormUtil.onPost(Ext.getCmp('pi_id').value);
  1071. }
  1072. }
  1073. },
  1074. 'erptecaiButton': {
  1075. afterrender: function(btn) {
  1076. var status = Ext.getCmp('pi_statuscode');
  1077. if (caller != 'ProdInOut!DefectIn' || status.value != 'POSTED') {
  1078. btn.hide();
  1079. }
  1080. },
  1081. click: function(btn) {
  1082. var pi_id = Ext.getCmp('pi_id').value;
  1083. me.batchdeal('ProdIN!ToProdOtherOut!Deal', ' pd_piid=' + Ext.getCmp('pi_id').value + ' and nvl(pd_yqty,0) < nvl(pd_inqty,0) + nvl(pd_outqty,0)', 'scm/reserve/erptecai.action');
  1084. //之前是判断单据状态 现在取消 需要根据明细数量来确定是否可以特采
  1085. /*Ext.Ajax.request({
  1086. url: basePath + 'scm/reserve/erptecai.action',
  1087. params: {
  1088. caller: caller,
  1089. id: pi_id
  1090. },
  1091. callback: function(opt, s, r) {
  1092. var rs = Ext.decode(r.responseText);
  1093. if(rs.exceptionInfo) {
  1094. showError(rs.exceptionInfo);
  1095. } else {
  1096. if(rs.log)
  1097. showMessage('提示', rs.log);
  1098. }
  1099. }
  1100. });*/
  1101. }
  1102. },
  1103. 'erpResPostButton': {
  1104. afterrender: function(btn) {
  1105. var status = Ext.getCmp('pi_statuscode');
  1106. if (status && status.value != 'POSTED') {
  1107. btn.hide();
  1108. }
  1109. },
  1110. click: function(btn) {
  1111. me.FormUtil.onResPost(Ext.getCmp('pi_id').value);
  1112. }
  1113. },
  1114. 'erpTurnProdinoutIn': {
  1115. afterrender: function(btn) {
  1116. var status = Ext.getCmp(me.getForm(btn).statuscodeField);
  1117. if (caller == 'ProdInOut!OtherOut' && status.value != 'AUDITED') {
  1118. btn.hide();
  1119. }
  1120. },
  1121. click: function(btn) {
  1122. var id = Ext.getCmp('pi_id').value;
  1123. Ext.Ajax.request({
  1124. url: basePath + 'scm/reserve/turnProdinoutIn.action',
  1125. params: {
  1126. id: id
  1127. },
  1128. callback: function(opt, s, r) {
  1129. var rs = Ext.decode(r.responseText);
  1130. if (rs.exceptionInfo) {
  1131. showError(rs.exceptionInfo);
  1132. } else {
  1133. if (rs.log)
  1134. showMessage('提示', rs.log);
  1135. }
  1136. }
  1137. });
  1138. }
  1139. },
  1140. 'erpSetMMQTYButton': {
  1141. click: function(btn) {
  1142. warnMsg("确认本次发料数为当前维护的实际可发数?", function(btn) {
  1143. if (btn == 'yes') {
  1144. me.FormUtil.setLoading(true); //loading...
  1145. Ext.Ajax.request({
  1146. url: basePath + 'scm/reserve/SetMMQTY.action',
  1147. params: {
  1148. id: Ext.getCmp('pi_id').value,
  1149. caller: caller
  1150. },
  1151. method: 'post',
  1152. callback: function(opt, s, r) {
  1153. me.FormUtil.setLoading(false);
  1154. var rs = Ext.decode(r.responseText);
  1155. if (rs.exceptionInfo) {
  1156. showError(rs.exceptionInfo);
  1157. } else {
  1158. if (rs.log)
  1159. showMessage('提示', rs.log);
  1160. }
  1161. window.location.reload();
  1162. }
  1163. });
  1164. }
  1165. });
  1166. }
  1167. },
  1168. 'dbfindtrigger[name=pd_ordercode]': {
  1169. focus: function(t) {
  1170. t.setHideTrigger(false);
  1171. t.setReadOnly(false);
  1172. if (Ext.getCmp('pi_cardcode')) {
  1173. var code = Ext.getCmp('pi_cardcode').value;
  1174. if (code != null && code != '') {
  1175. var obj = me.getCodeCondition();
  1176. if (obj && obj.field) {
  1177. t.dbBaseCondition = obj.field + "='" + code + "'";
  1178. }
  1179. }
  1180. }
  1181. if (caller == 'ProdInOut!OutReturn') { //借货归还单
  1182. var code = Ext.getCmp('pi_cardcode').value;
  1183. if (code != null && code != '') {
  1184. if (t.dbBaseCondition == null || t.dbBaseCondition == '') {
  1185. t.dbBaseCondition = "pi_cardcode='" + code + "'";
  1186. } else {
  1187. t.dbBaseCondition = t.dbBaseCondition + " and pi_cardcode='" + code + "'";
  1188. }
  1189. }
  1190. }
  1191. },
  1192. aftertrigger: function(t) {
  1193. if (Ext.getCmp('pi_cardcode')) {
  1194. var obj = me.getCodeCondition();
  1195. if (obj && obj.fields) {
  1196. me.FormUtil.getFieldsValue(obj.tablename, obj.fields, obj.myfield + "='" + t.value + "'", obj.tFields);
  1197. }
  1198. }
  1199. }
  1200. },
  1201. 'dbfindtrigger[name=pd_orderdetno]': {
  1202. focus: function(t) {
  1203. t.setHideTrigger(false);
  1204. t.setReadOnly(false); //用disable()可以,但enable()无效
  1205. var record = Ext.getCmp('grid').selModel.lastSelected;
  1206. var code = record.data['pd_ordercode'];
  1207. if (code == null || code == '') {
  1208. showError("请先选择关联单号!");
  1209. t.setHideTrigger(true);
  1210. t.setReadOnly(true);
  1211. } else {
  1212. var field = me.getBaseCondition();
  1213. if (field) {
  1214. t.dbBaseCondition = field + "='" + code + "'";
  1215. }
  1216. }
  1217. }
  1218. },
  1219. 'multidbfindtrigger[name=pd_orderdetno]': {
  1220. focus: function(t) {
  1221. t.setHideTrigger(false);
  1222. t.setReadOnly(false); //用disable()可以,但enable()无效
  1223. var record = Ext.getCmp('grid').selModel.lastSelected;
  1224. var code = record.data['pd_ordercode'];
  1225. if (code == null || code == '') {
  1226. showError("请先选择关联单号!");
  1227. t.setHideTrigger(true);
  1228. t.setReadOnly(true);
  1229. } else {
  1230. var field = me.getBaseCondition();
  1231. if (field) {
  1232. t.dbBaseCondition = field + "='" + code + "'";
  1233. }
  1234. }
  1235. }
  1236. },
  1237. 'dbfindtrigger[name=pd_batchcode1]': {
  1238. afterrender: function(t) {
  1239. var record = Ext.getCmp('grid').selModel.lastSelected;
  1240. var pr = record.data['pd_prodcode'],
  1241. wh = record.data['pd_whcode'];
  1242. if (pr == null || pr == '') {
  1243. showError("请先选择料号!");
  1244. return;
  1245. }
  1246. if (wh == null || wh == '') {
  1247. if (Ext.getCmp('pi_whcode')) {
  1248. wh = Ext.getCmp('pi_whcode').value;
  1249. if (wh == null || wh == '') {
  1250. showError("请先选择仓库!");
  1251. return;
  1252. }
  1253. }
  1254. }
  1255. t.dbBaseCondition = "ba_whcode='" + wh + "' AND ba_prodcode='" + pr + "'";
  1256. }
  1257. },
  1258. 'dbfindtrigger[name=pd_batchcode]': {
  1259. focus: function(t) {
  1260. t.setHideTrigger(false);
  1261. t.setReadOnly(false); //用disable()可以,但enable()无效
  1262. var record = Ext.getCmp('grid').selModel.lastSelected;
  1263. var pr = record.data['pd_prodcode'];
  1264. if (pr == null || pr == '') {
  1265. showError("请先选择料号!");
  1266. t.setHideTrigger(true);
  1267. t.setReadOnly(true);
  1268. } else {
  1269. var code = record.data['pd_whcode'];
  1270. if (code == null || code == '') {
  1271. if (Ext.getCmp('pi_whcode')) {
  1272. code = Ext.getCmp('pi_whcode').value;
  1273. if (code == null || code == '') {
  1274. showError("请先选择仓库!");
  1275. t.setHideTrigger(true);
  1276. t.setReadOnly(true);
  1277. } else {
  1278. t.dbBaseCondition = "ba_whcode='" + code + "' AND ba_prodcode='" + pr + "'";
  1279. }
  1280. } else {
  1281. t.dbBaseCondition = "ba_prodcode='" + pr + "'";
  1282. }
  1283. } else {
  1284. t.dbBaseCondition = "ba_whcode='" + code + "' AND ba_prodcode='" + pr + "'";
  1285. }
  1286. }
  1287. }
  1288. },
  1289. 'multidbfindtrigger[name=pd_batchcode]': {
  1290. focus: function(t) {
  1291. t.setHideTrigger(false);
  1292. t.setReadOnly(false); //用disable()可以,但enable()无效
  1293. var record = Ext.getCmp('grid').selModel.lastSelected;
  1294. var pr = record.data['pd_prodcode'];
  1295. if (pr == null || pr == '') {
  1296. showError("请先选择料号!");
  1297. t.setHideTrigger(true);
  1298. t.setReadOnly(true);
  1299. } else {
  1300. var code = record.data['pd_whcode'];
  1301. if (code == null || code == '') {
  1302. if (Ext.getCmp('pi_whcode')) {
  1303. code = Ext.getCmp('pi_whcode').value;
  1304. if (code == null || code == '') {
  1305. showError("请先选择仓库!");
  1306. t.setHideTrigger(true);
  1307. t.setReadOnly(true);
  1308. } else {
  1309. t.dbBaseCondition = "ba_whcode='" + code + "' AND ba_prodcode='" + pr + "'";
  1310. }
  1311. } else {
  1312. t.dbBaseCondition = "ba_prodcode='" + pr + "'";
  1313. }
  1314. } else {
  1315. t.dbBaseCondition = "ba_whcode='" + code + "' AND ba_prodcode='" + pr + "'";
  1316. }
  1317. }
  1318. }
  1319. },
  1320. /*'field[name=pi_whcode]': {
  1321. aftertrigger: function(f){
  1322. if(f.value != null && f.value != ''){
  1323. var grid = Ext.getCmp('grid');
  1324. var whname = Ext.getCmp('pi_whname');
  1325. Ext.Array.each(grid.store.data.items, function(item){
  1326. if(item.data['pd_whcode'] == null || item.data['pd_whcode'] == ''){
  1327. item.set('pd_whcode', f.value);
  1328. item.set('pd_whname', whname.value);
  1329. }
  1330. });
  1331. }
  1332. }
  1333. },
  1334. 'field[name=pi_purpose]': {
  1335. aftertrigger: function(f){
  1336. if(f.value != null && f.value != ''){
  1337. var grid = Ext.getCmp('grid');
  1338. var posename = Ext.getCmp('pi_purposename');
  1339. Ext.Array.each(grid.store.data.items, function(item){
  1340. if(item.data['pd_inwhcode'] == null || item.data['pd_inwhcode'] == ''){
  1341. item.set('pd_inwhcode', f.value);
  1342. if(posename){
  1343. item.set('pd_inwhname', posename.value);
  1344. }
  1345. }
  1346. });
  1347. }
  1348. }
  1349. },*/
  1350. 'dbfindtrigger[name=pi_paymentcode]': {
  1351. afterrender: function(trigger) {
  1352. if (trigger.fieldConfig == 'PT') {
  1353. trigger.dbKey = 'pi_cardcode';
  1354. if (caller == 'ProdInOut!Sale' || caller == 'ProdInOut!SaleReturn' || caller == 'ProdInOut!SaleBorrow') {
  1355. trigger.mappingKey = 'cu_code';
  1356. trigger.dbMessage = '请先选客户编号!';
  1357. }
  1358. }
  1359. }
  1360. },
  1361. 'dbfindtrigger[name=pi_address]': {
  1362. afterrender: function(trigger) {
  1363. if (trigger.fieldConfig == 'PT') {
  1364. trigger.dbKey = 'pi_cardcode';
  1365. if (caller == 'ProdInOut!Sale' || caller == 'ProdInOut!SaleReturn' || caller == 'ProdInOut!SaleBorrow') {
  1366. trigger.mappingKey = 'cu_code';
  1367. trigger.dbMessage = '请先选客户编号!';
  1368. }
  1369. }
  1370. }
  1371. },
  1372. 'dbfindtrigger[name=pi_custcode2]': {
  1373. afterrender: function(trigger) {
  1374. trigger.dbKey = 'pi_cardcode';
  1375. trigger.mappingKey = 'cu_code';
  1376. trigger.dbMessage = '请先选客户编号!';
  1377. }
  1378. },
  1379. 'dbfindtrigger[name=pi_invoiceremark]': {
  1380. afterrender: function(trigger) {
  1381. trigger.dbKey = 'pi_cardcode';
  1382. trigger.mappingKey = 'cu_code';
  1383. trigger.dbMessage = '请先选客户编号!';
  1384. }
  1385. },
  1386. 'dbfindtrigger[name=pi_packingremark]': {
  1387. afterrender: function(trigger) {
  1388. trigger.dbKey = 'pi_cardcode';
  1389. trigger.mappingKey = 'cu_code';
  1390. trigger.dbMessage = '请先选客户编号!';
  1391. }
  1392. },
  1393. /* 'dbfindtrigger[name=pi_receivecode]': {
  1394. afterrender:function(trigger){
  1395. if (caller == 'ProdInOut!Sale') {
  1396. trigger.dbKey='pi_cardcode';
  1397. trigger.mappingKey='cu_code';
  1398. trigger.dbMessage='请先选客户编号!';
  1399. }
  1400. }
  1401. },*/ //万利达收货客户可以随意改成其他客户
  1402. 'erpGetPriceButton': {
  1403. click: function() {
  1404. }
  1405. },
  1406. //转其它出库单
  1407. 'erpTurnOtherOutButton': {
  1408. afterrender: function(btn) {
  1409. var status = Ext.getCmp("pi_statuscode");
  1410. if (status && status.value != 'POSTED') {
  1411. btn.hide();
  1412. }
  1413. },
  1414. click: function(m) {
  1415. me.batchdeal('ProdIN!ToProdOtherOut!Deal', ' pd_piid=' + Ext.getCmp('pi_id').value + ' and nvl(pd_yqty,0) < nvl(pd_inqty,0) + nvl(pd_outqty,0)', 'scm/reserve/turnDefectOut.action?type=ProdInOut!OtherOut');
  1416. }
  1417. },
  1418. '#erpUpdateDetailWHCode': {
  1419. afterrender: function(btn) {
  1420. var status = Ext.getCmp('pi_invostatuscode'),
  1421. poststatus = Ext.getCmp('pi_statuscode');
  1422. if (status && status.value == 'ENTERING') {
  1423. btn.hide();
  1424. }
  1425. if (poststatus && poststatus.value == 'POSTED') {
  1426. btn.hide();
  1427. }
  1428. },
  1429. click: function(btn) {
  1430. var record = btn.ownerCt.ownerCt.getSelectionModel().getLastSelected();
  1431. this.UpdateDetailWHCode(record);
  1432. }
  1433. },
  1434. //转出货单
  1435. 'erpTurnProdOutButton': {
  1436. afterrender: function(btn) {
  1437. var status = Ext.getCmp("pi_statuscode");
  1438. if (status && status.value != 'POSTED') {
  1439. btn.hide();
  1440. }
  1441. },
  1442. click: function(m) {
  1443. me.batchdeal('ProdIN!ToProdOut!Deal', ' pd_piid=' + Ext.getCmp('pi_id').value + ' and nvl(pd_yqty,0) < nvl(pd_inqty,0) + nvl(pd_outqty,0)', 'scm/reserve/turnDefectOut.action?type=ProdInOut!Sale');
  1444. }
  1445. },
  1446. //转换货出库单
  1447. 'erpTurnExOutButton': {
  1448. afterrender: function(btn) {
  1449. var status = Ext.getCmp("pi_statuscode");
  1450. if (status && status.value != 'POSTED') {
  1451. btn.hide();
  1452. }
  1453. },
  1454. click: function(m) {
  1455. me.batchdeal('ProdInOut!ToExchangeOut!Deal', ' pd_piid=' + Ext.getCmp('pi_id').value + ' and nvl(pd_yqty,0) < nvl(pd_inqty,0) + nvl(pd_outqty,0)', 'scm/reserve/turnDefectOut.action?type=ProdInOut!ExchangeOut');
  1456. }
  1457. },
  1458. //转借货归还单
  1459. 'erpTurnOutReturnButton': {
  1460. afterrender: function(btn) {
  1461. var status = Ext.getCmp("pi_statuscode");
  1462. if (status && status.value != 'POSTED') {
  1463. btn.hide();
  1464. }
  1465. },
  1466. click: function(m) {
  1467. me.batchdeal('ProdIN!ToProdOutReturn!Deal', ' pd_piid=' + Ext.getCmp('pi_id').value + ' and nvl(pd_yqty,0) < nvl(pd_inqty,0) + nvl(pd_outqty,0)', 'scm/reserve/turnDefectIn.action?type=ProdInOut!OutReturn');
  1468. }
  1469. },
  1470. //转用品退仓单
  1471. 'erpTurnGoodsOutButton': {
  1472. afterrender: function(btn) {
  1473. var status = Ext.getCmp("pi_statuscode");
  1474. if (status && status.value != 'POSTED') {
  1475. btn.hide();
  1476. }
  1477. },
  1478. click: function(m) {
  1479. me.batchdeal('ProdIN!ToProdOutGoodsOut!Deal', ' pd_piid=' + Ext.getCmp('pi_id').value + ' and nvl(pd_yqty,0) < nvl(pd_inqty,0) + nvl(pd_outqty,0)', 'scm/reserve/turnDefectIn.action?type=ProdInOut!GoodsShutout');
  1480. }
  1481. },
  1482. 'erpTurnMrbButton': {
  1483. afterrender: function(btn) {
  1484. var status = Ext.getCmp("pi_statuscode");
  1485. if (status && status.value != 'POSTED') {
  1486. btn.hide();
  1487. }
  1488. },
  1489. click: function(btn) {
  1490. me.batchdeal('ProdIO!ToMRB!Deal', 'pd_piid=' + Ext.getCmp('pi_id').value + ' AND nvl(pd_yqty,0)<nvl(pd_inqty,0) + nvl(pd_outqty,0)', 'scm/reserve/turnMRB.action');
  1491. }
  1492. },
  1493. 'erpSubpackageButton': {
  1494. afterrender: function(btn) {
  1495. var status = Ext.getCmp('pi_invostatuscode');
  1496. if (status && status.value != 'AUDITED') {
  1497. btn.hide();
  1498. }
  1499. },
  1500. click: function(btn) {
  1501. warnMsg("确定分装?", function(btn) {
  1502. if (btn == 'yes') {
  1503. me.FormUtil.setLoading(true); //loading...
  1504. Ext.Ajax.request({
  1505. url: basePath + 'scm/reserve/Subpackage.action',
  1506. params: {
  1507. id: Ext.getCmp('pi_id').value
  1508. },
  1509. method: 'post',
  1510. callback: function(opt, s, r) {
  1511. me.FormUtil.setLoading(false);
  1512. var rs = Ext.decode(r.responseText);
  1513. if (rs.exceptionInfo) {
  1514. showError(rs.exceptionInfo);
  1515. } else {
  1516. if (rs.log)
  1517. showMessage('提示', rs.log);
  1518. }
  1519. }
  1520. });
  1521. }
  1522. });
  1523. }
  1524. },
  1525. 'erpClearSubpackageButton': {
  1526. afterrender: function(btn) {
  1527. var status = Ext.getCmp('pi_invostatuscode');
  1528. if (status && status.value != 'AUDITED') {
  1529. btn.hide();
  1530. }
  1531. },
  1532. click: function(btn) {
  1533. warnMsg("确定清除分装?", function(btn) {
  1534. if (btn == 'yes') {
  1535. me.FormUtil.setLoading(true); //loading...
  1536. Ext.Ajax.request({
  1537. url: basePath + 'scm/reserve/ClearSubpackage.action',
  1538. params: {
  1539. id: Ext.getCmp('pi_id').value
  1540. },
  1541. method: 'post',
  1542. callback: function(opt, s, r) {
  1543. me.FormUtil.setLoading(false);
  1544. var rs = Ext.decode(r.responseText);
  1545. if (rs.exceptionInfo) {
  1546. showError(rs.exceptionInfo);
  1547. } else {
  1548. if (rs.log)
  1549. showMessage('提示', rs.log);
  1550. }
  1551. }
  1552. });
  1553. }
  1554. });
  1555. }
  1556. },
  1557. 'erpPrintBarButton': {
  1558. click: function(btn) {
  1559. var reportName = "bar_53";
  1560. var condition = '{ProdIODetailBar.pdb_inoutno}=' + "'" + Ext.getCmp('pi_inoutno').value + "'";
  1561. var id = Ext.getCmp('pi_id').value;
  1562. me.FormUtil.onwindowsPrint(id, reportName, condition);
  1563. }
  1564. },
  1565. 'erpUpdateInfoButton': {
  1566. afterrender: function(btn) {
  1567. var status = Ext.getCmp('pi_invostatuscode'),
  1568. poststatus = Ext.getCmp('pi_statuscode');
  1569. if (status && status.value == 'ENTERING') {
  1570. btn.hide();
  1571. }
  1572. if (poststatus && poststatus.value == 'POSTED') {
  1573. btn.hide();
  1574. }
  1575. },
  1576. click: function(btn) {
  1577. var me = this,
  1578. win = Ext.getCmp('borrowCargoType-win');
  1579. if (!win) {
  1580. var type = Ext.getCmp('pi_outtype'),
  1581. remark = Ext.getCmp('pi_remark'),
  1582. val1 = type ? type.value : '',
  1583. val2 = remark ? remark.value : '';
  1584. win = Ext.create('Ext.Window', {
  1585. id: 'borrowCargoType-win',
  1586. title: '更新借货出货单 ' + Ext.getCmp('pi_inoutno').value + ' 的借货类型',
  1587. height: 200,
  1588. width: 400,
  1589. items: [{
  1590. xtype: 'form',
  1591. height: '100%',
  1592. width: '100%',
  1593. bodyStyle: 'background:#f1f2f5;',
  1594. items: [{
  1595. margin: '10 0 0 0',
  1596. xtype: 'dbfindtrigger',
  1597. fieldLabel: '借货类型',
  1598. name: 'pi_outtype',
  1599. allowBlank: false,
  1600. value: val1
  1601. }, {
  1602. margin: '3 0 0 0',
  1603. xtype: 'textfield',
  1604. name: 'pi_remark',
  1605. fieldLabel: '备注',
  1606. value: val2
  1607. }],
  1608. closeAction: 'hide',
  1609. buttonAlign: 'center',
  1610. layout: {
  1611. type: 'vbox',
  1612. align: 'center'
  1613. },
  1614. buttons: [{
  1615. text: $I18N.common.button.erpConfirmButton,
  1616. cls: 'x-btn-blue',
  1617. handler: function(btn) {
  1618. var form = btn.ownerCt.ownerCt,
  1619. a = form.down('dbfindtrigger[name=pi_outtype]'),
  1620. b = form.down('textfield[name=pi_remark]');
  1621. if (form.getForm().isDirty()) {
  1622. me.updateInfo(Ext.getCmp('pi_id').value, a.value, b.value);
  1623. }
  1624. }
  1625. }, {
  1626. text: $I18N.common.button.erpCloseButton,
  1627. cls: 'x-btn-blue',
  1628. handler: function(btn) {
  1629. btn.up('window').hide();
  1630. }
  1631. }]
  1632. }]
  1633. });
  1634. }
  1635. win.show();
  1636. }
  1637. },
  1638. 'erpZxbzsBarcodeButton': { //按最小包装数生成条码
  1639. afterrender: function(btn) {
  1640. var poststatus = Ext.getCmp('pi_statuscode');
  1641. if (poststatus && poststatus.value == 'POSTED') {
  1642. btn.hide();
  1643. }
  1644. },
  1645. click: function(btn) {
  1646. warnMsg("确定生成?", function(btn) {
  1647. if (btn == 'yes') {
  1648. me.FormUtil.setLoading(true); //loading...
  1649. Ext.Ajax.request({
  1650. url: basePath + 'scm/reserve/GenerateBarcodeByZxbzs.action',
  1651. params: {
  1652. pi_id: Ext.getCmp('pi_id').value,
  1653. pi_class: Ext.getCmp("pi_class").value,
  1654. caller: caller
  1655. },
  1656. method: 'post',
  1657. callback: function(opt, s, r) {
  1658. me.FormUtil.setLoading(false);
  1659. var rs = Ext.decode(r.responseText);
  1660. if (rs.exceptionInfo) {
  1661. showError(rs.exceptionInfo);
  1662. } else {
  1663. Ext.MessageBox.alert('系统提示', '按最小包装数批量生成条码成功!');
  1664. }
  1665. }
  1666. });
  1667. }
  1668. });
  1669. }
  1670. },
  1671. 'erpPrintAllButton': {
  1672. afterrender: function(btn) {
  1673. btn.setText('打印全部条码');
  1674. },
  1675. click: function(btn) {
  1676. var lps_barcaller = 'ProdIO!BarPrintAll';
  1677. var win = new Ext.window.Window({
  1678. id: 'win',
  1679. maximizable: true,
  1680. buttonAlign: 'center',
  1681. layout: 'anchor',
  1682. title: '打印模板选择',
  1683. modal: true,
  1684. items: [{
  1685. tag: 'iframe',
  1686. frame: true,
  1687. anchor: '100% 100%',
  1688. layout: 'fit',
  1689. html: '<iframe id="iframe_' + caller + '" src="' + basePath + 'jsps/scm/reserve/selPrintTemplate.jsp?whoami=' + lps_barcaller + '" height="100%" width="100%" frameborder="0" scrolling="no"></iframe>'
  1690. }]
  1691. });
  1692. win.show();
  1693. }
  1694. },
  1695. 'erpCatchBatchByOrderButton': {
  1696. click: function(btn) {
  1697. var grid = btn.ownerCt.ownerCt;
  1698. var record = grid.getSelectionModel().getLastSelected();
  1699. var id = Ext.getCmp("pi_id").value;
  1700. //选择明细行按订单抓取批号
  1701. Ext.Ajax.request({
  1702. url: basePath + '/scm/reserve/catchBatchByOrder.action',
  1703. params: {
  1704. pd_id: record.data.pd_id,
  1705. pd_piid: record.data.pd_piid,
  1706. caller: caller
  1707. },
  1708. method: 'post',
  1709. callback: function(options, success, response) {
  1710. var res = new Ext.decode(response.responseText);
  1711. if (res.exceptionInfo) {
  1712. showError(res.exceptionInfo);
  1713. } else if (res.success) {
  1714. showMessage('提示', '按订单号抓取批次成功!', 1000);
  1715. me.GridUtil.loadNewStore(grid, {
  1716. caller: caller,
  1717. condition: "pd_piid=" + id
  1718. });
  1719. }
  1720. }
  1721. });
  1722. },
  1723. afterrender: function(btn) {
  1724. btn.setDisabled(true);
  1725. }
  1726. },
  1727. 'erpCatchBatchByClientButton': {
  1728. afterrender: function(btn) {
  1729. var poststatus = Ext.getCmp('pi_statuscode');
  1730. if (poststatus && poststatus.value == 'POSTED') {
  1731. btn.hide();
  1732. }
  1733. },
  1734. click: function(btn) {
  1735. var grid = Ext.getCmp('grid');
  1736. Ext.Ajax.request({
  1737. url: basePath + 'scm/reserve/catchBatchByClient.action',
  1738. params: {
  1739. type : 'ByClient',
  1740. pi_id: Ext.getCmp('pi_id').value,
  1741. caller: caller
  1742. },
  1743. method: 'post',
  1744. callback: function(options, success, response) {
  1745. var res = new Ext.decode(response.responseText);
  1746. if (res) {
  1747. if (res.exceptionInfo) {
  1748. showMessage('提示', res.exceptionInfo);
  1749. } else {
  1750. if (res.log == null || res.log == ''){
  1751. grid.GridUtil.loadNewStore(grid, {
  1752. caller: caller,
  1753. condition: gridCondition
  1754. });
  1755. showMessage('提示', '按委托方抓取成功');
  1756. }
  1757. }
  1758. } else {
  1759. showMessage('提示', '按委托方抓取失败');
  1760. }
  1761. }
  1762. });
  1763. }
  1764. },
  1765. 'erpCatchBatchByCustButton': {
  1766. afterrender: function(btn) {
  1767. var poststatus = Ext.getCmp('pi_statuscode');
  1768. if (poststatus && poststatus.value == 'POSTED') {
  1769. btn.hide();
  1770. }
  1771. },
  1772. click: function(btn) {
  1773. var grid = Ext.getCmp('grid');
  1774. Ext.Ajax.request({
  1775. url: basePath + 'scm/reserve/catchBatchByClient.action',
  1776. params: {
  1777. type : 'ByCust',
  1778. pi_id: Ext.getCmp('pi_id').value,
  1779. caller: caller
  1780. },
  1781. method: 'post',
  1782. callback: function(options, success, response) {
  1783. var res = new Ext.decode(response.responseText);
  1784. if (res) {
  1785. if (res.exceptionInfo) {
  1786. showMessage('提示', res.exceptionInfo);
  1787. } else {
  1788. if (res.log == null || res.log == ''){
  1789. grid.GridUtil.loadNewStore(grid, {
  1790. caller: caller,
  1791. condition: gridCondition
  1792. });
  1793. showMessage('提示', '按客户抓取成功');
  1794. }
  1795. }
  1796. } else {
  1797. showMessage('提示', '按客户抓取失败');
  1798. }
  1799. }
  1800. });
  1801. }
  1802. }
  1803. });
  1804. },
  1805. getForm: function(btn) {
  1806. return btn.ownerCt.ownerCt;
  1807. },
  1808. save: function(btn) {
  1809. var me = this;
  1810. var bool = true;
  1811. var form = me.getForm(btn);
  1812. if (Ext.getCmp('Fin_Code')) {
  1813. Ext.getCmp('Fin_Code').setValue(Ext.getCmp(form.codeField).value); //流水号
  1814. }
  1815. var grid = Ext.getCmp('grid'),
  1816. items = grid.store.data.items,
  1817. c = Ext.getCmp('pi_inoutno').value;
  1818. var piclass = Ext.getCmp('pi_class').value,
  1819. date = Ext.getCmp('pi_date').value;
  1820. Ext.Array.each(items, function(item) {
  1821. if (!Ext.isEmpty(item.data['pd_prodcode'])) {
  1822. item.set('pd_inoutno', c);
  1823. item.set('pd_piclass', piclass);
  1824. }
  1825. });
  1826. if (caller == 'ProdInOut!OtherPurcIn') {
  1827. Ext.each(items, function(item) {
  1828. if (!Ext.isEmpty(item.data['pd_ordercode'])) {
  1829. if (Ext.Date.format(item.data['pd_vendorreplydate'], 'Ymd') < Ext.Date.format(new Date(), 'Ymd')) {
  1830. bool = false;
  1831. showError('明细表第' + item.data['pd_pdno'] + '还料日期小于系统当前日期');
  1832. return;
  1833. }
  1834. }
  1835. });
  1836. }
  1837. if (caller == 'ProdInOut!PurcCheckout') {
  1838. Ext.each(items, function(item) {
  1839. if (!Ext.isEmpty(item.data['pd_ordercode'])) {
  1840. if (item.data['pd_outqty'] > item.data['pd_acceptqty']) {
  1841. bool = false;
  1842. showError('明细表第' + item.data['pd_pdno'] + '数量大于采购单的验收数量');
  1843. return;
  1844. }
  1845. }
  1846. });
  1847. }
  1848. if (caller == 'ProdInOut!AppropriationOut') {
  1849. var recorder = Ext.getCmp('pi_recordman');
  1850. if (recorder) {
  1851. Ext.Array.each(items, function(item) {
  1852. if (!Ext.isEmpty(item.data['pd_prodcode'])) {
  1853. if (Ext.isEmpty(item.data['pd_seller'])) {
  1854. item.set('pd_seller', recorder.value);
  1855. }
  1856. }
  1857. });
  1858. }
  1859. }
  1860. if (caller != 'ProdInOut!AppropriationOut' && caller != 'ProdInOut!AppropriationIn') {
  1861. var whcode = Ext.getCmp('pi_whcode'),
  1862. whname = Ext.getCmp('pi_whname');
  1863. if (whcode && whname) {
  1864. Ext.Array.each(items, function(item) {
  1865. if (!Ext.isEmpty(item.data['pd_prodcode'])) {
  1866. if (Ext.isEmpty(item.data['pd_whcode'])) {
  1867. item.set('pd_whcode', whcode.value);
  1868. item.set('pd_whname', whname.value);
  1869. }
  1870. if (caller == 'ProdInOut!OtherIn' || caller == 'ProdInOut!OtherPurcIn') {
  1871. if (item.data['pd_unitpackage'] == null || item.data['pd_unitpackage'] == '' ||
  1872. item.data['pd_unitpackage'] == '0' || item.data['pd_unitpackage'] == 0) {
  1873. item.set('pd_unitpackage', item.data['pd_inqty']);
  1874. }
  1875. }
  1876. }
  1877. });
  1878. }
  1879. }
  1880. if (caller == 'ProdInOut!SaleAppropriationOut' || 'ProdInOut!OtherOut' == caller) {
  1881. Ext.Array.each(items, function(item) {
  1882. if (!Ext.isEmpty(item.data['pd_plancode'])) {
  1883. if (item.data['pd_outqty'] > item.data['pd_sfdqty']) {
  1884. bool = false;
  1885. showError('明细表第' + item.data['pd_pdno'] + '数量大于销售预测单数量');
  1886. return;
  1887. }
  1888. }
  1889. if (!Ext.isEmpty(item.data['pd_ordercode'])) {
  1890. if (item.data['pd_outqty'] > item.data['sd_qty']) {
  1891. bool = false;
  1892. showError('明细表第' + item.data['pd_pdno'] + '数量大于销售单数量');
  1893. return;
  1894. }
  1895. }
  1896. });
  1897. }
  1898. if (caller == 'ProdInOut!SaleAppropriationOut' || 'ProdInOut!AppropriationOut' == caller) {
  1899. var pi_purpose = Ext.getCmp('pi_purpose'),
  1900. pi_purposename = Ext.getCmp('pi_purposename');
  1901. var pi_whcode = Ext.getCmp('pi_whcode'),
  1902. pi_whname = Ext.getCmp('pi_whname');
  1903. if (pi_whcode && pi_whname) {
  1904. Ext.Array.each(items, function(item) {
  1905. if (!Ext.isEmpty(item.data['pd_prodcode'])) {
  1906. if (Ext.isEmpty(item.data['pd_whcode'])) {
  1907. item.set('pd_whcode', pi_whcode.value);
  1908. item.set('pd_whname', pi_whname.value);
  1909. }
  1910. }
  1911. });
  1912. }
  1913. if (pi_purpose && pi_purposename) {
  1914. Ext.Array.each(items, function(item) {
  1915. if (!Ext.isEmpty(item.data['pd_prodcode'])) {
  1916. if (Ext.isEmpty(item.data['pd_inwhcode'])) {
  1917. item.set('pd_inwhcode', pi_purpose.value);
  1918. item.set('pd_inwhname', pi_purposename.value);
  1919. }
  1920. }
  1921. });
  1922. }
  1923. }
  1924. // 拨入单、拨出单,默认第一行的仓库
  1925. me.setDetailWarehouse(grid);
  1926. if (caller == 'ProdInOut!Make!Return' || caller == 'ProdInOut!OutsideReturn' || caller == 'ProdInOut!Make!Useless') {
  1927. var firstItem = grid.store.getAt(0);
  1928. if (firstItem) {
  1929. var desc = firstItem.get('pd_description'),
  1930. dc = firstItem.get('pd_departmentcode'),
  1931. dn = firstItem.get('pd_departmentname'),
  1932. whcode = firstItem.get('pd_whcode'),
  1933. whname = firstItem.get('pd_whname'),
  1934. pd_textbox = firstItem.get('pd_textbox');
  1935. Ext.Array.each(items, function(item) {
  1936. if (!Ext.isEmpty(item.data['pd_prodcode'])) {
  1937. if (Ext.isEmpty(item.data['pd_description'])) {
  1938. item.set('pd_description', desc);
  1939. }
  1940. if (Ext.isEmpty(item.data['pd_departmentcode'])) {
  1941. item.set('pd_departmentcode', dc);
  1942. item.set('pd_departmentname', dn);
  1943. }
  1944. if (Ext.isEmpty(item.data['pd_whcode'])) {
  1945. item.set('pd_whcode', whcode);
  1946. item.set('pd_whname', whname);
  1947. }
  1948. if (caller == 'ProdInOut!Make!Useless') {
  1949. if (Ext.isEmpty(item.data['pd_textbox'])) {
  1950. item.set('pd_textbox', pd_textbox);
  1951. }
  1952. }
  1953. }
  1954. });
  1955. }
  1956. }
  1957. if (bool)
  1958. me.FormUtil.beforeSave(me);
  1959. },
  1960. setDetailWarehouse: function(grid) {
  1961. var me = this;
  1962. if ('ProdInOut!AppropriationIn' == caller || 'ProdInOut!AppropriationOut' == caller || 'ProdInOut!SaleAppropriationOut' == caller) {
  1963. var firstItem = grid.store.getAt(0);
  1964. if (firstItem) {
  1965. var whcode = firstItem.get('pd_whcode'),
  1966. whname = firstItem.get('pd_whname'),
  1967. inwhcode = firstItem.get('pd_inwhcode'),
  1968. inwhname = firstItem.get('pd_inwhname');
  1969. grid.store.each(function() {
  1970. if (!me.GridUtil.isBlank(grid, this.data)) {
  1971. if (!Ext.isEmpty(this.get('pd_prodcode'))) {
  1972. if (Ext.isEmpty(this.get('pd_whcode'))) {
  1973. this.set('pd_whcode', whcode);
  1974. this.set('pd_whname', whname);
  1975. }
  1976. if (Ext.isEmpty(this.get('pd_inwhcode'))) {
  1977. this.set('pd_inwhcode', inwhcode);
  1978. this.set('pd_inwhname', inwhname);
  1979. }
  1980. }
  1981. }
  1982. });
  1983. }
  1984. }
  1985. },
  1986. /**
  1987. *修改明细仓库
  1988. * */
  1989. UpdateDetailWHCode: function(record) {
  1990. var me = this;
  1991. var win = Ext.create('Ext.window.Window', {
  1992. width: 430,
  1993. height: 250,
  1994. closeAction: 'destroy',
  1995. title: '<h1>修改仓库信息</h1>',
  1996. layout: {
  1997. type: 'vbox'
  1998. },
  1999. items: [{
  2000. margin: '5 0 0 5',
  2001. xtype: 'dbfindtrigger',
  2002. fieldLabel: '仓库编号',
  2003. name: 'whcode',
  2004. value: record.data.pd_whcode,
  2005. id: 'whcode'
  2006. }, {
  2007. margin: '5 0 0 5',
  2008. xtype: 'textfield',
  2009. fieldLabel: '仓库名称',
  2010. name: 'whname',
  2011. value: record.data.pd_whname,
  2012. id: 'whname'
  2013. }, {
  2014. margin: '5 0 0 5',
  2015. xtype: 'checkbox',
  2016. fieldLabel: '是否修改所有明细',
  2017. labelWidth: 120,
  2018. name: 'isalldetail',
  2019. id: 'isalldetail'
  2020. }],
  2021. buttonAlign: 'center',
  2022. buttons: [{
  2023. xtype: 'button',
  2024. text: '保存',
  2025. width: 60,
  2026. iconCls: 'x-button-icon-save',
  2027. handler: function(btn) {
  2028. var w = btn.up('window');
  2029. me.saveWhInfo(w);
  2030. win.close();
  2031. win.destroy();
  2032. }
  2033. }, {
  2034. xtype: 'button',
  2035. columnWidth: 0.1,
  2036. text: '关闭',
  2037. width: 60,
  2038. iconCls: 'x-button-icon-close',
  2039. margin: '0 0 0 10',
  2040. handler: function(btn) {
  2041. var win = btn.up('window');
  2042. win.close();
  2043. win.destroy();
  2044. }
  2045. }]
  2046. });
  2047. win.show();
  2048. },
  2049. saveWhInfo: function(w) {
  2050. var whcode = w.down('field[name=whcode]').getValue();
  2051. var isalldetail = w.down('field[name=isalldetail]').getValue();
  2052. grid = Ext.getCmp('grid'),
  2053. record = grid.getSelectionModel().getLastSelected();
  2054. if (!whcode) {
  2055. showError('请先设置仓库信息!');
  2056. return;
  2057. } else {
  2058. var dd = {
  2059. whcode: whcode,
  2060. whname: w.down('field[name=whname]').getValue(),
  2061. pd_id: record.data.pd_id,
  2062. isalldetail: isalldetail
  2063. };
  2064. Ext.Ajax.request({
  2065. url: basePath + 'scm/reserve/updateWhCodeInfo.action',
  2066. params: {
  2067. data: unescape(Ext.JSON.encode(dd)),
  2068. caller: caller
  2069. },
  2070. method: 'post',
  2071. callback: function(opt, s, res) {
  2072. var r = new Ext.decode(res.responseText);
  2073. if (r.success) {
  2074. grid.GridUtil.loadNewStore(grid, {
  2075. caller: caller,
  2076. condition: gridCondition
  2077. });
  2078. showMessage('提示', '更新成功!', 1000);
  2079. } else if (r.exceptionInfo) {
  2080. showError(r.exceptionInfo);
  2081. } else {
  2082. saveFailure();
  2083. }
  2084. }
  2085. });
  2086. }
  2087. },
  2088. /**
  2089. * pd_orderdetno的限制条件
  2090. */
  2091. getBaseCondition: function() {
  2092. var field = null;
  2093. switch (caller) {
  2094. case 'ProdInOut!PurcCheckin': //采购验收单
  2095. field = "pd_code";
  2096. break;
  2097. case 'ProdInOut!PurcCheckout': //采购验退单
  2098. field = "pd_code";
  2099. break;
  2100. case 'ProdInOut!Sale': //出货单
  2101. field = "sd_code";
  2102. break;
  2103. case 'ProdInOut!Make!Return': //生产退料单
  2104. field = "mm_code";
  2105. break;
  2106. case 'ProdInOut!Make!Give': //生产补料单
  2107. field = "mm_code";
  2108. break;
  2109. case 'ProdInOut!Picking': //生产领料单
  2110. field = "mm_code";
  2111. break;
  2112. case 'ProdInOut!Make!Consume': //生产耗料单
  2113. field = "mm_code";
  2114. break;
  2115. case 'ProdInOut!Make!Useless': //生产报废单
  2116. field = "mm_code";
  2117. break;
  2118. case 'ProdInOut!SaleAppropriationOut': //销售拨出单
  2119. field = "sd_code";
  2120. break;
  2121. case 'ProdInOut!SaleReturn': //销售退货单
  2122. field = "sd_code";
  2123. break;
  2124. case 'ProdInOut!OtherOut': //其它出库单
  2125. field = "sd_code";
  2126. break;
  2127. case 'ProdInOut!OutsidePicking': //委外领料单
  2128. field = "ma_code";
  2129. break;
  2130. case 'ProdInOut!OutsideReturn': //委外退料单
  2131. field = "mm_code";
  2132. break;
  2133. case 'ProdInOut!DefectIn': //不良品入库单
  2134. field = "pd_code";
  2135. break;
  2136. case 'ProdInOut!DefectOut': //不良品入库单
  2137. field = "pd_code";
  2138. break;
  2139. case 'ProdInOut!OutsideCheckIn': //委外验收单
  2140. field = "mm_code";
  2141. break;
  2142. case 'ProdInOut!OSMake!Give': //委外补料单
  2143. field = "mm_code";
  2144. break;
  2145. case 'ProdInOut!SampleSale': //样品出货单
  2146. field = "sd_code";
  2147. break;
  2148. case 'ProdInOut!SampleMake!Give': //工程补料单
  2149. field = "mm_code";
  2150. break;
  2151. case 'ProdInOut!SamplePicking': //工程领料单
  2152. field = "mm_code";
  2153. break;
  2154. case 'ProdInOut!PurcCheckin!PLM': //研发采购验收单
  2155. field = "pd_code";
  2156. break;
  2157. case 'ProdInOut!PurcCheckout!PLM': //研发采购验退单
  2158. field = "pd_code";
  2159. break;
  2160. case 'ProdInOut!PartitionStockIn': //拆件入库单
  2161. field = "mm_code";
  2162. break;
  2163. }
  2164. return field;
  2165. },
  2166. /**
  2167. * pd_ordercode的限制条件
  2168. */
  2169. updatepdscaleremark: function(record) {
  2170. var win = Ext.create('Ext.Window', {
  2171. id: 'win',
  2172. title: '发货比例信息维护',
  2173. height: 300,
  2174. width: 400,
  2175. items: [{
  2176. margin: '3 0 0 0',
  2177. id: 'pd_scaleremark',
  2178. xtype: 'textfield',
  2179. fieldLabel: '比例备注',
  2180. name: 'pd_scaleremark',
  2181. value: record.data.pd_scaleremark
  2182. }],
  2183. closeAction: 'hide',
  2184. buttonAlign: 'center',
  2185. layout: {
  2186. type: 'vbox',
  2187. align: 'center'
  2188. },
  2189. buttons: [{
  2190. text: '保存信息',
  2191. cls: 'x-btn-blue',
  2192. handler: function(btn) {
  2193. var id = record.data.pd_id;
  2194. Ext.Ajax.request({
  2195. url: basePath + 'scm/sale/updatepdscaleremark.action',
  2196. params: {
  2197. id: id,
  2198. field: 'pd_id',
  2199. data: Ext.getCmp('pd_scaleremark').value
  2200. },
  2201. callback: function(opt, s, r) {
  2202. var rs = Ext.decode(r.responseText);
  2203. if (rs.exceptionInfo) {
  2204. showMessage('提示', rs.exceptionInfo.replace('AFTERSUCCESS', ''));
  2205. } else {
  2206. saveSuccess(function() {
  2207. window.location.reload();
  2208. });
  2209. }
  2210. }
  2211. });
  2212. }
  2213. }, {
  2214. text: '保存全部',
  2215. cls: 'x-btn-blue',
  2216. handler: function(btn) {
  2217. var id = record.data.pd_piid;
  2218. Ext.Ajax.request({
  2219. url: basePath + 'scm/sale/updatepdscaleremark.action',
  2220. params: {
  2221. id: id,
  2222. field: 'pd_piid',
  2223. data: Ext.getCmp('pd_scaleremark').value
  2224. },
  2225. callback: function(opt, s, r) {
  2226. var rs = Ext.decode(r.responseText);
  2227. if (rs.exceptionInfo) {
  2228. showMessage('提示', rs.exceptionInfo.replace('AFTERSUCCESS', ''));
  2229. } else {
  2230. saveSuccess(function() {
  2231. window.location.reload();
  2232. });
  2233. }
  2234. }
  2235. });
  2236. }
  2237. }, {
  2238. text: $I18N.common.button.erpCloseButton,
  2239. cls: 'x-btn-blue',
  2240. handler: function(btn) {
  2241. btn.ownerCt.ownerCt.hide();
  2242. }
  2243. }]
  2244. });
  2245. win.show();
  2246. },
  2247. getCodeCondition: function() {
  2248. var field = null;
  2249. var fields = '';
  2250. var tablename = '';
  2251. var myfield = '';
  2252. var tFields = '';
  2253. switch (caller) {
  2254. case 'ProdInOut!PurcCheckin': //采购验收单
  2255. field = "pu_vendcode";
  2256. tFields = 'pi_cardid,pi_cardcode,pi_title,pi_currency,pi_rate,pi_payment,pi_paymentcode,pi_transport,pi_paydate,pi_receivecode,pi_receivename';
  2257. fields = 'pu_vendid,pu_vendcode,pu_vendname,pu_currency,pu_rate,pu_payments,pu_paymentscode,pu_transport,pu_suredate,pu_receivecode,pu_receivename';
  2258. tablename = 'Purchase';
  2259. myfield = 'pu_code';
  2260. break;
  2261. case 'ProdInOut!PurcCheckout': //采购验退单
  2262. field = "pu_vendcode";
  2263. tFields = 'pi_cardid,pi_cardcode,pi_title,pi_currency,pi_rate,pi_payment,pi_paymentcode,pi_transport,pi_paydate,pi_receivecode,pi_receivename';
  2264. fields = 'pu_vendid,pu_vendcode,pu_vendname,pu_currency,pu_rate,pu_payments,pu_paymentscode,pu_transport,pu_suredate,pu_receivecode,pu_receivename';
  2265. tablename = 'Purchase';
  2266. myfield = 'pu_code';
  2267. break;
  2268. case 'ProdInOut!Sale': //出货单
  2269. tFields = 'pi_cardid,pi_cardcode,pi_title,pi_currency,pi_rate,pi_payment,pi_paymentcode,pi_transport,pi_sellercode,pi_belongs,pi_receivecode,pi_receivename,pi_transport';
  2270. fields = 'sa_custid,sa_custcode,sa_custname,sa_currency,sa_rate,sa_payments,sa_paymentscode,sa_transport,sa_sellercode,sa_seller,sa_shcustcode,sa_shcustname,sa_transport';
  2271. tablename = 'Sale';
  2272. myfield = 'sa_code';
  2273. field = "sa_custcode";
  2274. break;
  2275. case 'ProdInOut!AppropriationIn': //拨入单
  2276. tFields = 'pi_cardcode,pi_title';
  2277. fields = 'ma_custcode,ma_custname';
  2278. tablename = 'Make';
  2279. myfield = 'ma_code';
  2280. field = "ma_custcode";
  2281. break;
  2282. case 'ProdInOut!SaleAppropriationOut': //销售拨出单
  2283. tFields = 'pi_cardid,pi_cardcode,pi_title';
  2284. fields = 'sa_custid,sa_custcode,sa_custname';
  2285. tablename = 'Sale';
  2286. myfield = 'sa_code';
  2287. field = "sa_custcode";
  2288. break;
  2289. case 'ProdInOut!SaleReturn': //销售退货单
  2290. tFields = 'pi_cardid,pi_cardcode,pi_title,pi_currency,pi_rate,pi_paymentcode,pi_payment,pi_transport,pi_sellercode,pi_belongs,pi_receivecode,pi_receivename,pi_transport';
  2291. fields = 'sa_custid,sa_custcode,sa_custname,sa_currency,sa_rate,sa_paymentscode,sa_payments,sa_transport,sa_sellercode,sa_seller,sa_shcustcode,sa_shcustname,sa_transport';
  2292. tablename = 'Sale';
  2293. myfield = 'sa_code';
  2294. field = "sa_custcode";
  2295. break;
  2296. case 'ProdInOut!AppropriationOut': //拨出单
  2297. tFields = 'pi_cardcode,pi_title';
  2298. fields = 'ma_custcode,ma_custname';
  2299. tablename = 'Make';
  2300. myfield = 'ma_code';
  2301. field = "ma_custcode";
  2302. break;
  2303. case 'ProdInOut!DefectIn': //不良品入库单
  2304. field = "pu_vendcode";
  2305. tFields = 'pi_cardid,pi_cardcode,pi_title,pi_currency,pi_rate,pi_payment,pi_transport,pi_paydate';
  2306. fields = 'pu_vendid,pu_vendcode,pu_vendname,pu_currency,pu_rate,pu_payments,pu_transport,pu_suredate';
  2307. tablename = 'Purchase';
  2308. myfield = 'pu_code';
  2309. break;
  2310. case 'ProdInOut!DefectOut': //不良品出库单
  2311. field = "pu_vendcode";
  2312. tFields = 'pi_cardid,pi_cardcode,pi_title,pi_currency,pi_rate,pi_payment,pi_transport,pi_paydate';
  2313. fields = 'pu_vendid,pu_vendcode,pu_vendname,pu_currency,pu_rate,pu_payments,pu_transport,pu_suredate';
  2314. tablename = 'Purchase';
  2315. myfield = 'pu_code';
  2316. break;
  2317. case 'ProdInOut!OutsidePicking': //委外领料单
  2318. field = "ma_vendcode";
  2319. tFields = 'pi_cardcode,pi_title,pi_departmentcode,pi_departmentname';
  2320. fields = 'ma_vendcode,ma_vendname,ma_departmentcode,ma_departmentname';
  2321. tablename = 'Make';
  2322. myfield = 'ma_code';
  2323. break;
  2324. case 'ProdInOut!OutsideReturn': //委外退料单
  2325. field = "ma_vendcode";
  2326. tFields = 'pi_cardcode,pi_title,pi_departmentcode,pi_departmentname';
  2327. fields = 'ma_vendcode,ma_vendname,ma_departmentcode,ma_departmentname';
  2328. tablename = 'Make';
  2329. myfield = 'ma_code';
  2330. break;
  2331. case 'ProdInOut!OutsideCheckIn': //委外验收单
  2332. field = "ma_vendcode";
  2333. tFields = 'pi_cardcode,pi_title,pi_departmentcode,pi_departmentname';
  2334. fields = 'ma_vendcode,ma_vendname,ma_departmentcode,ma_departmentname';
  2335. tablename = 'Make';
  2336. myfield = 'ma_code';
  2337. break;
  2338. case 'ProdInOut!OutesideCheckReturn': //委外验退单
  2339. field = "ma_vendcode";
  2340. tFields = 'pi_cardcode,pi_title,pi_departmentcode,pi_departmentname,pi_currency,pi_rate';
  2341. fields = 'ma_vendcode,ma_vendname,ma_departmentcode,ma_departmentname,ma_currency,ma_rate';
  2342. tablename = 'Make';
  2343. myfield = 'ma_code';
  2344. break;
  2345. case 'ProdInOut!OutReturn': //借货归还单
  2346. tFields = 'pi_sellercode,pi_belongs,pi_cop,pi_shr,pi_expresscode,pi_emcode,pi_emname,pi_address';
  2347. fields = 'pi_emcode,pi_emname,pi_cop,pi_shr,pi_expresscode,pi_emcode,pi_emname,pi_address';
  2348. tablename = 'ProdInOut';
  2349. myfield = 'pi_inoutno';
  2350. break;
  2351. case 'ProdInOut!PurcCheckin!PLM': //研发采购验收单
  2352. field = "pu_vendcode";
  2353. tFields = 'pi_cardid,pi_cardcode,pi_title,pi_currency,pi_rate,pi_payment,pi_transport,pi_paydate,pi_receivecode,pi_receivename';
  2354. fields = 'pu_vendid,pu_vendcode,pu_vendname,pu_currency,pu_rate,pu_payments,pu_transport,pu_suredate,pu_receivecode,pu_receivename';
  2355. tablename = 'Purchase';
  2356. myfield = 'pu_code';
  2357. break;
  2358. case 'ProdInOut!PurcCheckout!PLM': //研发采购验退单
  2359. field = "pu_vendcode";
  2360. tFields = 'pi_cardid,pi_cardcode,pi_title,pi_currency,pi_rate,pi_payment,pi_transport,pi_paydate,pi_receivecode,pi_receivename';
  2361. fields = 'pu_vendid,pu_vendcode,pu_vendname,pu_currency,pu_rate,pu_payments,pu_transport,pu_suredate,pu_receivecode,pu_receivename';
  2362. tablename = 'Purchase';
  2363. myfield = 'pu_code';
  2364. break;
  2365. case 'ProdInOut!ExchangeOut': //换货出库单
  2366. 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';
  2367. 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';
  2368. tablename = 'Sale';
  2369. myfield = 'sa_code';
  2370. field = "sa_custcode";
  2371. break;
  2372. case 'ProdInOut!GoodsOut': //用品验退单
  2373. tFields = 'pi_cardid,pi_cardcode,pi_title,pi_payment,pi_receivecode,pi_receivename,pi_paymentcode';
  2374. fields = 've_id,ve_code,ve_name,ve_payment,ve_apvendcode,ve_apvendname,ve_paymentcode';
  2375. tablename = 'Vendor left join Oapurchase on op_vecode=ve_code';
  2376. myfield = 'op_code';
  2377. field = "op_vecode";
  2378. break;
  2379. }
  2380. var obj = new Object();
  2381. obj.field = field;
  2382. obj.fields = fields;
  2383. obj.tFields = tFields;
  2384. obj.tablename = tablename;
  2385. obj.myfield = myfield;
  2386. return obj;
  2387. },
  2388. /**
  2389. * 有来源不能新增明细
  2390. */
  2391. hasSource: function(grid) {
  2392. var bool = false,
  2393. field = null;
  2394. switch (caller) {
  2395. // case 'ProdInOut!Sale'://出货单
  2396. // field = 'pd_snid';
  2397. // break;
  2398. case 'ProdInOut!PurcCheckin': //采购验收单
  2399. field = 'pd_qcid';
  2400. break;
  2401. case 'ProdInOut!OutsideCheckIn': //委外验收单
  2402. field = 'pd_qcid';
  2403. break;
  2404. case 'ProdInOut!DefectIn': //不良品入库单
  2405. field = 'pd_qcid';
  2406. break;
  2407. }
  2408. if (field != null) {
  2409. var s = null;
  2410. grid.store.each(function(item) {
  2411. s = item.get(field);
  2412. if (s != null && s != '' && s > 0) {
  2413. bool = true;
  2414. return;
  2415. }
  2416. });
  2417. }
  2418. return bool;
  2419. },
  2420. isAllowUpdateQty: function(record) {
  2421. var bool = true;
  2422. switch (caller) {
  2423. case 'ProdInOut!PurcCheckin': //采购验收单
  2424. if (record.get('pd_qcid') != null && record.get('pd_qcid') > 0)
  2425. bool = false;
  2426. break;
  2427. case 'ProdInOut!OutsideCheckIn': //委外验收单
  2428. if (record.get('pd_qcid') != null && record.get('pd_qcid') > 0)
  2429. bool = false;
  2430. break;
  2431. case 'ProdInOut!DefectIn': //不良品入库单
  2432. if (record.get('pd_qcid') != null && record.get('pd_qcid') > 0)
  2433. bool = false;
  2434. break;
  2435. case 'ProdInOut!Make!In': //完工入库单
  2436. if (record.get('pd_qcid') != null && record.get('pd_qcid') > 0)
  2437. bool = false;
  2438. break;
  2439. }
  2440. return bool;
  2441. },
  2442. onPrint: function() {
  2443. var me = this,
  2444. whichKind = Ext.getCmp('pi_class').value;
  2445. var reportName = '';
  2446. if (whichKind == "出货单") {
  2447. reportName = "sendlist_yessale";
  2448. } else if (whichKind == "无订单出货单") {
  2449. reportName = "sendlist_nosale";
  2450. } else if (whichKind == "不良品入库单") {
  2451. reportName = "pio_notokin";
  2452. } else if (whichKind == "不良品出库单") {
  2453. reportName = "pio_notokout";
  2454. } else if (whichKind == "其它采购入库单") {
  2455. reportName = "piolist_opin";
  2456. } else if (whichKind == "其它采购出库单") {
  2457. reportName = "piolist_opout";
  2458. } else if (whichKind == "拨入单") {
  2459. reportName = "piolist_br";
  2460. } else if (whichKind == "拨出单") {
  2461. reportName = "piolist_bc";
  2462. } else if (whichKind == "其它入库单") {
  2463. reportName = "piolist_in";
  2464. } else if (whichKind == "其它出库单") {
  2465. reportName = "piolist_out";
  2466. } else if (whichKind == "报废单") {
  2467. reportName = "piolist_bf";
  2468. } else if (whichKind == "换货入库单") {
  2469. reportName = "pio_changein";
  2470. } else if (whichKind == "换货出库单") {
  2471. reportName = "pio_changeout";
  2472. } else if (whichKind == "销售退货单") {
  2473. reportName = "retulist";
  2474. } else if (whichKind == "采购验收单") {
  2475. reportName = "acclist";
  2476. } else if (whichKind == "采购验退单") {
  2477. reportName = "piolist_yt";
  2478. } else if (whichKind == "销售拨入单") {
  2479. reportName = "piolist";
  2480. } else if (whichKind == "销售拨出单") {
  2481. reportName = "piolist_salebc";
  2482. } else if (whichKind == "生产领料单") {
  2483. reportName = "PIOLISTM";
  2484. } else if (whichKind == "生产退料单") {
  2485. reportName = "PIOLISTM_Back";
  2486. } else if (whichKind == "完工入库单") {
  2487. reportName = "finish";
  2488. } else if (whichKind == "结余退料单") {
  2489. reportName = "PIOLISTM_JY";
  2490. } else if (whichKind == "拆件入库单") {
  2491. reportName = "chaijian";
  2492. } else if (whichKind == "生产补料单") {
  2493. reportName = "PIOLIST_bl";
  2494. } else if (whichKind == "生产耗料单") {
  2495. reportName = "PIOLISTM_HL";
  2496. } else if (whichKind == "委外领料单") {
  2497. reportName = "Expiolist";
  2498. } else if (whichKind == "委外退料单") {
  2499. reportName = "PIOLIST_wwtl";
  2500. } else if (whichKind == "委外验收单") {
  2501. reportName = "EXPLIST_ys";
  2502. } else if (whichKind == "委外验退单") {
  2503. reportName = "EXPLIST_yt";
  2504. } else if (whichKind == "生产报废单") {
  2505. reportName = "MakeScrap";
  2506. } else if (whichKind == "无订单退货单") {
  2507. reportName = "retulist_nosale";
  2508. } else if (whichKind == "委外补料单") {
  2509. reportName = "Expiolist";
  2510. } else if (whichKind == "盘盈调整单") {
  2511. reportName = "piolist_tz";
  2512. } else if (whichKind == "盘亏调整单") {
  2513. reportName = "piolist_tz";
  2514. } else if (whichKind == "辅料入库单") {
  2515. reportName = "piolist_flr";
  2516. } else if (whichKind == "辅料出库单") {
  2517. reportName = "piolist_flc";
  2518. } else if (whichKind == "研发领料单") {
  2519. reportName = "piolist_yfll";
  2520. } else if (whichKind == "研发退料单") {
  2521. reportName = "piolist_yftl";
  2522. } else if (whichKind == "借货出货单") {
  2523. reportName = "sendlist_jh";
  2524. } else if (whichKind == "借货归还单") {
  2525. reportName = "sendlist_jhgh";
  2526. } else if (whichKind == "用品验收单") {
  2527. reportName = "piolist_ypys";
  2528. } else if (whichKind == "用品验退单") {
  2529. reportName = "piolist_ypyt";
  2530. } else if (whichKind == "用品领用单") {
  2531. reportName = "piolist_yply";
  2532. } else if (whichKind == "用品借用单") {
  2533. reportName = "piolist_ypjy";
  2534. } else if (whichKind == "用品归还单") {
  2535. reportName = "piolist_ypgh";
  2536. } else if (whichKind == "用品退仓单") {
  2537. reportName = "piolist_ypgh";
  2538. }
  2539. var condition = '{prodinout.pi_id}=' + Ext.getCmp('pi_id').value + '';
  2540. var id = Ext.getCmp('pi_id').value;
  2541. me.FormUtil.onwindowsPrint2(id, reportName, condition, function() {
  2542. if (whichKind == '生产退料单' || whichKind == '拆件入库单' || whichKind == '拆件完工入库单')
  2543. window.location.reload();
  2544. });
  2545. },
  2546. /**
  2547. *编辑分装明细
  2548. **/
  2549. EditSubpackage: function(record) {
  2550. var width = Ext.isIE ? screen.width * 0.7 * 0.9 : '80%',
  2551. height = Ext.isIE ? screen.height * 0.75 : '100%';
  2552. var pd_id = record.get('pd_id');
  2553. Ext.create('Ext.Window', {
  2554. width: width,
  2555. height: height,
  2556. autoShow: true,
  2557. layout: 'anchor',
  2558. items: [{
  2559. tag: 'iframe',
  2560. frame: true,
  2561. anchor: '100% 100%',
  2562. layout: 'fit',
  2563. html: '<iframe id="iframe_dbfind" src="' + basePath + 'jsps/scm/reserve/prodIODetail.jsp?formCondition=pd_id=' +
  2564. pd_id + '&gridCondition=pdb_pdid=' + pd_id + '" height="100%" width="100%" frameborder="0" scrolling="no"></iframe>'
  2565. }]
  2566. });
  2567. },
  2568. loadOnHandQty: function(grid, id) {
  2569. Ext.Ajax.request({
  2570. url: basePath + 'scm/reserve/loadOnHandQty.action',
  2571. params: {
  2572. caller: caller,
  2573. id: id
  2574. },
  2575. callback: function(opt, s, r) {
  2576. var rs = Ext.decode(r.responseText);
  2577. if (rs.exceptionInfo) {
  2578. showMessage('提示', rs.exceptionInfo.replace('AFTERSUCCESS', ''));
  2579. } else {
  2580. var data = [];
  2581. if (!rs.data || rs.data.length == 2) {
  2582. grid.GridUtil.add10EmptyData(grid.detno, data);
  2583. grid.GridUtil.add10EmptyData(grid.detno, data);
  2584. } else {
  2585. data = Ext.decode(rs.data.replace(/,}/g, '}').replace(/,]/g, ']'));
  2586. }
  2587. grid.store.loadData(data);
  2588. }
  2589. }
  2590. });
  2591. },
  2592. Updatebgxh: function(record) {
  2593. var win = this.bgxhwindow;
  2594. if (!win) {
  2595. win = this.getBgxhWindow();
  2596. }
  2597. win.show();
  2598. },
  2599. getBgxhWindow: function() {
  2600. var me = this;
  2601. return Ext.create('Ext.window.Window', {
  2602. width: 330,
  2603. height: 180,
  2604. closeAction: 'hide',
  2605. cls: 'custom-blue',
  2606. title: '<h1>更改报关型号</h1>',
  2607. layout: {
  2608. type: 'vbox'
  2609. },
  2610. items: [{
  2611. margin: '5 0 0 5',
  2612. xtype: 'textfield',
  2613. fieldLabel: '报关型号',
  2614. name: 'pd_bgxh',
  2615. id: 'pd_bgxh'
  2616. }, {
  2617. margin: '5 0 0 5',
  2618. xtype: 'fieldcontainer',
  2619. fieldLabel: '全部更新',
  2620. combineErrors: false,
  2621. defaults: {
  2622. hideLabel: true
  2623. },
  2624. layout: {
  2625. type: 'column',
  2626. defaultMargins: {
  2627. top: 0,
  2628. right: 5,
  2629. bottom: 0,
  2630. left: 0
  2631. }
  2632. },
  2633. items: [{
  2634. xtype: 'checkbox',
  2635. columnidth: 0.4,
  2636. fieldLabel: '全部更新',
  2637. name: 'allupdate',
  2638. id: 'allupdate'
  2639. }, {
  2640. xtype: 'displayfield',
  2641. fieldStyle: 'color:red',
  2642. columnidth: 0.6,
  2643. value: ' *更改当前所有明细'
  2644. }]
  2645. }],
  2646. buttonAlign: 'center',
  2647. buttons: [{
  2648. xtype: 'button',
  2649. text: '保存',
  2650. width: 60,
  2651. iconCls: 'x-button-icon-save',
  2652. handler: function(btn) {
  2653. var w = btn.up('window');
  2654. me.saveBgxh(w);
  2655. w.hide();
  2656. }
  2657. }, {
  2658. xtype: 'button',
  2659. columnWidth: 0.1,
  2660. text: '关闭',
  2661. width: 60,
  2662. iconCls: 'x-button-icon-close',
  2663. margin: '0 0 0 10',
  2664. handler: function(btn) {
  2665. btn.up('window').hide();
  2666. }
  2667. }]
  2668. });
  2669. },
  2670. saveBgxh: function(w) {
  2671. var pd_bgxh = w.down('field[name=pd_bgxh]').getValue(),
  2672. grid = Ext.getCmp('grid'),
  2673. record = grid.getSelectionModel().getLastSelected();
  2674. if (!pd_bgxh) {
  2675. showError('请先设置报关型号.');
  2676. return;
  2677. } else {
  2678. var allupdate = w.down('field[name=allupdate]').getValue();
  2679. var dd = {
  2680. pd_id: record.data.pd_id,
  2681. pd_piid: record.data.pd_piid,
  2682. pd_bgxh: pd_bgxh ? pd_bgxh : null,
  2683. allupdate: allupdate ? 1 : 0,
  2684. caller: caller
  2685. };
  2686. Ext.Ajax.request({
  2687. url: basePath + 'scm/reserve/updatebgxh.action',
  2688. params: {
  2689. _noc: 1,
  2690. data: unescape(Ext.JSON.encode(dd))
  2691. },
  2692. method: 'post',
  2693. callback: function(opt, s, res) {
  2694. var r = new Ext.decode(res.responseText);
  2695. if (r.success) {
  2696. grid.GridUtil.loadNewStore(grid, {
  2697. caller: caller,
  2698. condition: 'pd_piid=' + record.data.pd_piid
  2699. });
  2700. showMessage('提示', '更新成功!', 1000);
  2701. } else if (r.exceptionInfo) {
  2702. showError(r.exceptionInfo);
  2703. } else {
  2704. saveFailure();
  2705. }
  2706. }
  2707. });
  2708. }
  2709. },
  2710. getPurcPrice: function(record) {
  2711. warnMsg("确定要获取采购单价吗?", function(btn) {
  2712. if (btn == 'yes') {
  2713. var pdid = record.data.pd_id,
  2714. prod = record.data.pd_prodcode,
  2715. piid = record.data.pd_piid,
  2716. vend = Ext.getCmp('pi_cardcode').value,
  2717. curr = Ext.getCmp('pi_currency').value,
  2718. grid = Ext.getCmp('grid');
  2719. if (Ext.isEmpty(vend)) {
  2720. showError('请先选择供应商!');
  2721. return;
  2722. }
  2723. if (Ext.isEmpty(curr)) {
  2724. showError('请先选择币别!');
  2725. return;
  2726. }
  2727. if (Ext.isEmpty(prod)) {
  2728. showError('请先选择物料!');
  2729. return;
  2730. }
  2731. Ext.Ajax.request({
  2732. url: basePath + 'scm/reserve/getPrice.action',
  2733. params: {
  2734. pdid: pdid,
  2735. piid: piid,
  2736. caller: caller
  2737. },
  2738. method: 'post',
  2739. callback: function(opt, s, res) {
  2740. var r = new Ext.decode(res.responseText);
  2741. if (r.success) {
  2742. grid.GridUtil.loadNewStore(grid, {
  2743. caller: caller,
  2744. condition: 'pd_piid=' + piid
  2745. });
  2746. showMessage('提示', '更新成功!', 1000);
  2747. } else if (r.exceptionInfo) {
  2748. showError(r.exceptionInfo);
  2749. } else {
  2750. saveFailure();
  2751. }
  2752. }
  2753. });
  2754. }
  2755. });
  2756. },
  2757. updateOrderCode: function(record) {
  2758. var win = this.orderwindow;
  2759. if (!win) {
  2760. win = this.getOrderWindow(record);
  2761. }
  2762. win.show();
  2763. },
  2764. getOrderWindow: function(record) {
  2765. var me = this;
  2766. return Ext.create('Ext.window.Window', {
  2767. width: 330,
  2768. height: 250,
  2769. closeAction: 'hide',
  2770. cls: 'custom-blue',
  2771. title: '<h1>更改关联单号</h1>',
  2772. layout: {
  2773. type: 'vbox'
  2774. },
  2775. items: [{
  2776. margin: '5 0 0 5',
  2777. xtype: 'dbfindtrigger',
  2778. fieldLabel: '关联单号',
  2779. value: record.data.pd_ordercode,
  2780. name: 'pd_ordercode',
  2781. id: 'pd_ordercode'
  2782. }, {
  2783. margin: '5 0 0 5',
  2784. xtype: 'textfield',
  2785. fieldLabel: '关联序号',
  2786. value: record.data.pd_orderdetno,
  2787. name: 'pd_orderdetno',
  2788. id: 'pd_orderdetno',
  2789. readOnly: true
  2790. }, {
  2791. margin: '5 0 0 5',
  2792. xtype: 'textfield',
  2793. fieldLabel: '物料编号',
  2794. value: record.data.pd_prodcode,
  2795. name: 'pd_prodcode',
  2796. id: 'pd_prodcode',
  2797. readOnly: true
  2798. }, {
  2799. margin: '5 0 0 5',
  2800. xtype: 'textfield',
  2801. fieldLabel: '采购单价',
  2802. value: record.data.pd_orderprice,
  2803. name: 'pd_orderprice',
  2804. id: 'pd_orderprice'
  2805. }, {
  2806. margin: '5 0 0 5',
  2807. xtype: 'textfield',
  2808. fieldLabel: '税率%',
  2809. value: record.data.pd_taxrate,
  2810. name: 'pd_taxrate',
  2811. id: 'pd_taxrate'
  2812. }],
  2813. buttonAlign: 'center',
  2814. buttons: [{
  2815. xtype: 'button',
  2816. text: '保存',
  2817. width: 60,
  2818. iconCls: 'x-button-icon-save',
  2819. handler: function(btn) {
  2820. var w = btn.up('window');
  2821. me.saveOrder(w);
  2822. w.hide();
  2823. }
  2824. }, {
  2825. xtype: 'button',
  2826. columnWidth: 0.1,
  2827. text: '关闭',
  2828. width: 60,
  2829. iconCls: 'x-button-icon-close',
  2830. margin: '0 0 0 10',
  2831. handler: function(btn) {
  2832. btn.up('window').hide();
  2833. }
  2834. }]
  2835. });
  2836. },
  2837. saveOrder: function(w) {
  2838. var pd_ordercode = w.down('field[name=pd_ordercode]').getValue(),
  2839. pd_orderdetno = w.down('field[name=pd_orderdetno]').getValue(),
  2840. pd_prodcode = w.down('field[name=pd_prodcode]').getValue(),
  2841. pd_orderprice = w.down('field[name=pd_orderprice]').getValue(),
  2842. pd_taxrate = w.down('field[name=pd_taxrate]').getValue(),
  2843. grid = Ext.getCmp('grid'),
  2844. record = grid.getSelectionModel().getLastSelected();
  2845. if (!pd_ordercode) {
  2846. showError('请先选择关联单号!');
  2847. return;
  2848. } else {
  2849. var dd = {
  2850. pd_id: record.data.pd_id,
  2851. pd_piid: record.data.pd_piid,
  2852. pd_ordercode: pd_ordercode ? pd_ordercode : null,
  2853. pd_orderdetno: pd_orderdetno ? pd_orderdetno : 0,
  2854. pd_prodcode: pd_prodcode,
  2855. pd_orderprice: pd_orderprice ? pd_orderprice : 0,
  2856. pd_taxrate: pd_taxrate ? pd_taxrate : 0,
  2857. caller: caller
  2858. };
  2859. Ext.Ajax.request({
  2860. url: basePath + 'scm/reserve/updateOrderCode.action',
  2861. params: {
  2862. _noc: 1,
  2863. data: unescape(Ext.JSON.encode(dd))
  2864. },
  2865. method: 'post',
  2866. callback: function(opt, s, res) {
  2867. var r = new Ext.decode(res.responseText);
  2868. if (r.success) {
  2869. grid.GridUtil.loadNewStore(grid, {
  2870. caller: caller,
  2871. condition: 'pd_piid=' + record.data.pd_piid
  2872. });
  2873. showMessage('提示', '更新成功!', 1000);
  2874. } else if (r.exceptionInfo) {
  2875. showError(r.exceptionInfo);
  2876. } else {
  2877. saveFailure();
  2878. }
  2879. }
  2880. });
  2881. }
  2882. },
  2883. updateBatchCode: function(record) {
  2884. var me = this;
  2885. var win = Ext.create('Ext.window.Window', {
  2886. width: 430,
  2887. height: 250,
  2888. closeAction: 'destroy',
  2889. title: '<h1>修改批号信息</h1>',
  2890. layout: {
  2891. type: 'vbox'
  2892. },
  2893. items: [{
  2894. margin: '5 0 0 5',
  2895. xtype: 'dbfindtrigger',
  2896. fieldLabel: '批号',
  2897. value: record.data.pd_batchcode,
  2898. name: 'pd_batchcode1',
  2899. id: 'pd_batchcode1'
  2900. }, {
  2901. margin: '5 0 0 5',
  2902. xtype: 'textfield',
  2903. fieldLabel: '批号ID',
  2904. value: record.data.pd_batchid,
  2905. name: 'pd_batchid',
  2906. id: 'pd_batchid',
  2907. readOnly: true
  2908. }],
  2909. buttonAlign: 'center',
  2910. buttons: [{
  2911. xtype: 'button',
  2912. text: '保存',
  2913. width: 60,
  2914. iconCls: 'x-button-icon-save',
  2915. handler: function(btn) {
  2916. var w = btn.up('window');
  2917. me.saveBatch(w);
  2918. w.hide();
  2919. }
  2920. }, {
  2921. xtype: 'button',
  2922. columnWidth: 0.1,
  2923. text: '关闭',
  2924. width: 60,
  2925. iconCls: 'x-button-icon-close',
  2926. margin: '0 0 0 10',
  2927. handler: function(btn) {
  2928. btn.up('window').hide();
  2929. }
  2930. }]
  2931. });
  2932. win.show();
  2933. },
  2934. saveBatch: function(w) {
  2935. var pd_batchcode = w.down('field[name=pd_batchcode1]').getValue(),
  2936. pd_batchid = w.down('field[name=pd_batchid]').getValue(),
  2937. grid = Ext.getCmp('grid'),
  2938. record = grid.getSelectionModel().getLastSelected();
  2939. if (!pd_batchcode) {
  2940. showError('请先选择批号!');
  2941. return;
  2942. } else {
  2943. var dd = {
  2944. pd_id: record.data.pd_id,
  2945. pd_piid: record.data.pd_piid,
  2946. pd_batchcode: pd_batchcode ? pd_batchcode : null,
  2947. pd_batchid: pd_batchid ? pd_batchid : 0,
  2948. caller: caller
  2949. };
  2950. Ext.Ajax.request({
  2951. url: basePath + 'scm/reserve/updateBatchCode.action',
  2952. params: {
  2953. _noc: 1,
  2954. data: unescape(Ext.JSON.encode(dd))
  2955. },
  2956. method: 'post',
  2957. callback: function(opt, s, res) {
  2958. var r = new Ext.decode(res.responseText);
  2959. if (r.success) {
  2960. grid.GridUtil.loadNewStore(grid, {
  2961. caller: caller,
  2962. condition: 'pd_piid=' + record.data.pd_piid
  2963. });
  2964. showMessage('提示', '更新成功!', 1000);
  2965. } else if (r.exceptionInfo) {
  2966. showError(r.exceptionInfo);
  2967. } else {
  2968. saveFailure();
  2969. }
  2970. }
  2971. });
  2972. }
  2973. },
  2974. batchdeal: function(nCaller, condition, url) {
  2975. var win = new Ext.window.Window({
  2976. id: 'win',
  2977. height: "100%",
  2978. width: "80%",
  2979. maximizable: true,
  2980. buttonAlign: 'center',
  2981. layout: 'anchor',
  2982. items: [{
  2983. tag: 'iframe',
  2984. frame: true,
  2985. anchor: '100% 100%',
  2986. layout: 'fit',
  2987. html: '<iframe id="iframe_' + caller + '" src="' + basePath + 'jsps/common/editorColumn.jsp?caller=' + nCaller +
  2988. "&condition=" + condition + '" height="100%" width="100%" frameborder="0" scrolling="no"></iframe>'
  2989. }],
  2990. buttons: [{
  2991. name: 'confirm',
  2992. text: $I18N.common.button.erpConfirmButton,
  2993. iconCls: 'x-button-icon-confirm',
  2994. cls: 'x-btn-gray',
  2995. listeners: {
  2996. buffer: 500,
  2997. click: function(btn) {
  2998. var grid = Ext.getCmp('win').items.items[0].body.dom.getElementsByTagName('iframe')[0].contentWindow.Ext.getCmp("editorColumnGridPanel");
  2999. btn.setDisabled(true);
  3000. grid.updateAction(url);
  3001. }
  3002. }
  3003. }, {
  3004. text: $I18N.common.button.erpCloseButton,
  3005. iconCls: 'x-button-icon-close',
  3006. cls: 'x-btn-gray',
  3007. handler: function() {
  3008. Ext.getCmp('win').close();
  3009. }
  3010. }]
  3011. });
  3012. win.show();
  3013. },
  3014. updateInfo: function(id, val1, val2) {
  3015. Ext.Ajax.request({
  3016. url: basePath + 'scm/reserve/updateBorrowCargoType.action',
  3017. params: {
  3018. id: id,
  3019. type: val1,
  3020. remark: val2
  3021. },
  3022. callback: function(opt, s, r) {
  3023. var rs = Ext.decode(r.responseText);
  3024. if (rs.exceptionInfo) {
  3025. showError(rs.exceptionInfo);
  3026. } else {
  3027. Ext.Msg.alert("提示", "更新成功!");
  3028. window.location.reload();
  3029. }
  3030. }
  3031. });
  3032. },
  3033. isAllowSale: function(record) {
  3034. var bool = true;
  3035. if (!Ext.isEmpty(record.get('pd_plancode'))) bool = false;
  3036. return bool;
  3037. },
  3038. isAllowForeCast: function(record) {
  3039. var bool = true;
  3040. if (!Ext.isEmpty(record.get('pd_ordercode'))) bool = false;
  3041. return bool;
  3042. },
  3043. /**
  3044. *明细拆分
  3045. * */
  3046. SplitDetail:function(record){
  3047. var width = Ext.isIE ? screen.width * 0.7 * 0.9 : '80%',
  3048. height = Ext.isIE ? screen.height * 0.75 : '100%';
  3049. var pd_id = record.get('pd_id');
  3050. Ext.create('Ext.Window', {
  3051. width: width,
  3052. height: height,
  3053. autoShow: true,
  3054. layout: 'anchor',
  3055. items: [{
  3056. tag: 'iframe',
  3057. frame: true,
  3058. anchor: '100% 100%',
  3059. layout: 'fit',
  3060. html: '<iframe id="iframe_dbfind" src="' + basePath + 'jsps/scm/reserve/splitProdIODetail.jsp?formCondition=pd_id=' +
  3061. pd_id + '&gridCondition=pd_id=' + pd_id + '&whoami=' +caller+ '-Detail&_noc=1" height="100%" width="100%" frameborder="0" scrolling="no"></iframe>'
  3062. }]
  3063. });
  3064. }
  3065. });