ProdInOut.js 144 KB

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