SetBarcode.js 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.scm.reserve.SetBarcode', {
  3. extend: 'Ext.app.Controller',
  4. requires: ['erp.util.FormUtil', 'erp.util.GridUtil', 'erp.util.BaseUtil', 'erp.util.RenderUtil'],
  5. views:[
  6. 'scm.reserve.setBarcode.Viewport','scm.reserve.setBarcode.Form','scm.reserve.setBarcode.GridPanel','core.trigger.AddDbfindTrigger',
  7. 'core.trigger.DbfindTrigger','core.form.FtField','core.form.FtFindField','core.form.ConDateField',
  8. 'core.trigger.TextAreaTrigger','core.form.YnField', 'core.form.MonthDateField','core.form.ConMonthDateField','core.button.Close',
  9. 'core.grid.YnColumn','core.form.DateHourMinuteField','core.button.GenerateBarcode','core.button.PrintAll','core.button.DeleteAllDetails',
  10. 'core.button.PrintAllPackage','core.button.GeneratePaCode'
  11. ],
  12. BaseUtil: Ext.create('erp.util.BaseUtil'),
  13. GridUtil: Ext.create('erp.util.GridUtil'),
  14. FormUtil: Ext.create('erp.util.FormUtil'),
  15. init:function(){
  16. var me = this;
  17. me.resized = false;
  18. var LODOP = null;
  19. var postStatuscode = window.parent.Ext.getCmp("pi_statuscode").value;
  20. this.control({
  21. 'erpSetBarcodeGridPanel':{
  22. itemclick : function(selModel, record){ //判断出入库是否已过帐,已过帐不允许对明细行进行操作,后台也需要判断
  23. if(caller == 'ProdInOut!BarcodeIn' && postStatuscode != 'POSTED' && postStatuscode!='已过帐'){
  24. if(record.data.bi_pdaget != 1){
  25. this.GridUtil.onGridItemClick(selModel, record);
  26. }
  27. }
  28. },
  29. afterrender:function(m){
  30. var grid =Ext.getCmp("setBarcodeGridPanel");
  31. Ext.each(grid.columns, function(c){
  32. if(c.dataIndex == 'bi_printstatus'){
  33. c.editor = null;
  34. }
  35. });
  36. },
  37. beforeedit: function(){//如果是单件管控则明细行中的入库数量不允许修改
  38. var grid =Ext.getCmp("setBarcodeGridPanel");
  39. var pr_tracekind = Ext.getCmp("pr_tracekind").value;
  40. if(pr_tracekind == 1 || pr_tracekind == "单件管控"){
  41. Ext.each(grid.columns, function(c){
  42. if(c.dataIndex == 'bi_inqty'||c.dataIndex == 'bi_outqty'){
  43. c.editor = null;
  44. }
  45. });
  46. }
  47. }
  48. },
  49. 'erpCloseButton': {
  50. click: function(btn){
  51. me.FormUtil.onClose();
  52. }
  53. },
  54. 'textfield[name=pd_outqty]':{
  55. afterrender:function(m){
  56. if(caller =='ProdInOut!BarcodeIn'){
  57. m.hide();
  58. }
  59. }
  60. },
  61. 'textfield[name=pd_qty]':{
  62. afterrender:function(m){
  63. if(caller =='ProdInOut!BarcodeOut'){
  64. m.hide();
  65. }
  66. }
  67. },
  68. 'dbfindtrigger[name=bi_location]':{
  69. afterrender:function (m){
  70. Ext.Ajax.request({//是否启用仓位
  71. url : basePath + "common/getFieldData.action",
  72. params: {
  73. caller:'configs',
  74. field:'data',
  75. condition:"code='UseLocationOrNot' and caller='BarCodeSetting'"
  76. },
  77. method : 'post',
  78. callback : function(options,success,response){
  79. var res = new Ext.decode(response.responseText);
  80. if(res.data == 'N' || res.data == 0){//不启用仓位
  81. m.allowBlank = true;
  82. m.hide();
  83. }
  84. }
  85. })
  86. }
  87. },
  88. 'textfield[name=pd_inqty]':{
  89. afterrender:function(m){
  90. if(caller == 'ProdInOut!BarcodeOut'){
  91. m.hide();
  92. }
  93. }
  94. },
  95. 'button[id=generateBarcodebtn]':{
  96. afterrender: function(btn){
  97. if(caller == 'ProdInOut!BarcodeOut'){
  98. btn.hide();
  99. }
  100. if(postStatuscode == 'POSTED' || postStatuscode=='已过帐'){
  101. btn.disable(true);
  102. }
  103. },
  104. click:function(btn){
  105. //产生新的条码并插到grid行中
  106. var form = Ext.getCmp("setBarcodeform");
  107. var pd_inqty = Ext.getCmp("pd_inqty");
  108. if(pd_inqty && (Number(pd_inqty.value)=='0' ||Number(pd_inqty.value) == 0)){
  109. showError("批总量不允许为0!");return;
  110. }
  111. if(pd_inqty && (Number(pd_inqty.value) > Number(Ext.getCmp("pd_qty").value))){
  112. showError("批总量不允许大于来料总量");return;
  113. }
  114. var r = form.getValues();
  115. var keys = Ext.Object.getKeys(r);
  116. Ext.each(keys, function(k){
  117. f = form.down('#' + k);
  118. if(f && f.logic == 'ignore') {
  119. delete r[k];
  120. }
  121. });
  122. var param = unescape(escape(Ext.JSON.encode(r)));
  123. Ext.Ajax.request({
  124. url : basePath + "scm/reserve/generateBarcode.action",
  125. params: {
  126. caller: caller,
  127. formStore:param
  128. },
  129. method : 'post',
  130. callback : function(options,success,response){
  131. var res = new Ext.decode(response.responseText);
  132. if(res.exceptionInfo != null){
  133. showError(res.exceptionInfo);return;
  134. }else {
  135. window.location.href = basePath +'jsps/scm/reserve/setBarcode.jsp?_noc=1&whoami='+caller+'&formCondition='+formCondition+'&gridCondition='+gridCondition;
  136. }
  137. }
  138. })
  139. },
  140. enable:function(btn){
  141. var pr_tracekind = Ext.getCmp("pr_tracekind").value;
  142. if(pr_tracekind == 1 || pr_tracekind == "单件管控"){
  143. btn.setDisabled(true);
  144. }
  145. }
  146. } ,
  147. 'button[id=save]': {
  148. afterrender: function(btn){
  149. if(caller == 'ProdInOut!BarcodeOut'){
  150. btn.hide();
  151. }
  152. if(postStatuscode == 'POSTED' || postStatuscode=='已过帐'){
  153. btn.disable(true);
  154. }
  155. },
  156. click: function (btn){
  157. var grid =Ext.getCmp("setBarcodeGridPanel");
  158. if( grid.selModel.getCount() == 0 ){
  159. showError("没有需要处理的数据!");
  160. return;
  161. }
  162. var params = new Object();
  163. var items = grid.selModel.getSelection();
  164. Ext.each(items, function(item, index){
  165. if(this.data[grid.keyField] != null && this.data[grid.keyField] != ''
  166. && this.data[grid.keyField] != '0' && this.data[grid.keyField] != 0){
  167. item.index = this.data[grid.keyField];
  168. grid.multiselected.push(item);
  169. }
  170. var records = Ext.Array.unique(grid.multiselected);
  171. if(records.length > 0){
  172. params.caller = caller;
  173. var data = new Array();
  174. var bool = false;
  175. Ext.each(records, function(record, index){
  176. if((grid.keyField && this.data[grid.keyField] != null && this.data[grid.keyField] != ''
  177. && this.data[grid.keyField] != '0' && this.data[grid.keyField] != 0)){
  178. bool = true;
  179. var o = new Object();
  180. if(grid.keyField){
  181. o[grid.keyField] = record.data[grid.keyField];
  182. }
  183. if(grid.toField){
  184. Ext.each(grid.toField, function(f, index){
  185. var v = Ext.getCmp(f).value;
  186. if(v != null && v.toString().trim() != '' && v.toString().trim() != 'null'){
  187. o[f] = v;
  188. }
  189. });
  190. }
  191. if(grid.necessaryFields){
  192. Ext.each(grid.necessaryFields, function(f, index){
  193. var v = record.data[f];
  194. if(Ext.isDate(v)){
  195. v = Ext.Date.toString(v);
  196. }
  197. o[f] = v;
  198. });
  199. }
  200. data.push(o);
  201. }
  202. });
  203. if(bool){
  204. params.gridStore = unescape(Ext.JSON.encode(data).replace(/\\/g,"%"));
  205. me.FormUtil.setLoading(true);
  206. Ext.Ajax.request({
  207. url : basePath + "scm/reserve/saveBarcode.action",
  208. params: params,
  209. method : 'post',
  210. callback : function(options,success,response){
  211. me.FormUtil.setLoading(false);
  212. var res = new Ext.decode(response.responseText);
  213. if(res.exceptionInfo != null){
  214. showError(res.exceptionInfo);return;
  215. }else {
  216. window.location.href = basePath +'jsps/scm/reserve/setBarcode.jsp?_noc=1&whoami='+caller+'&formCondition='+formCondition+'&gridCondition='+gridCondition;
  217. }
  218. }
  219. })
  220. } else {
  221. showError("没有需要处理的数据!");
  222. }
  223. }
  224. })
  225. }
  226. },
  227. 'button[id=batchGenBarcode]':{
  228. afterrender: function(btn){
  229. if(caller == 'ProdInOut!BarcodeOut'){
  230. btn.hide();
  231. }
  232. },
  233. enable: function (btn){
  234. if(postStatuscode == 'POSTED' || postStatuscode=='已过帐'){
  235. btn.disable(true);
  236. }
  237. },
  238. click: function (btn){
  239. //产生新的条码并插到grid行中
  240. var form = Ext.getCmp("setBarcodeform");
  241. var pr_zxbzs = Ext.getCmp("pr_zxbzs").value;
  242. if((pr_zxbzs == 0) || pr_zxbzs < 0 ){
  243. showError("最小包装数必须大于0!");
  244. return ;
  245. }
  246. var pr_tracekind = Ext.getCmp("pr_tracekind").value;
  247. if(pr_tracekind == 1 || pr_tracekind == "单件管控"){
  248. if(pr_zxbzs!=1){
  249. showError("单件管控类型的物料最小包装数只能为1 !");
  250. return ;
  251. }
  252. }
  253. var pd_inqty = Ext.getCmp("pd_inqty");
  254. if(pd_inqty && (Number(pd_inqty.value)=='0' ||Number(pd_inqty.value) == 0)){
  255. showError("批总量不允许为0!");return;
  256. }
  257. if(pd_inqty && (Number(pd_inqty.value) > Number(Ext.getCmp("pd_qty").value))){
  258. showError("批总量不允许大于来料总量");return;
  259. }
  260. var r = form.getValues();
  261. var keys = Ext.Object.getKeys(r);
  262. Ext.each(keys, function(k){
  263. f = form.down('#' + k);
  264. if(f && f.logic == 'ignore') {
  265. delete r[k];
  266. }
  267. });
  268. var param = unescape(escape(Ext.JSON.encode(r)));
  269. me.FormUtil.setLoading(true);
  270. Ext.Ajax.request({
  271. url : basePath + "scm/reserve/batchGenBarcode.action",
  272. params: {
  273. caller: caller,
  274. formStore:param
  275. },
  276. method : 'post',
  277. callback : function(options,success,response){
  278. me.FormUtil.setLoading(false);
  279. var res = new Ext.decode(response.responseText);
  280. if(res.exceptionInfo != null){
  281. showError(res.exceptionInfo);return;
  282. }else {
  283. window.location.href = basePath +'jsps/scm/reserve/setBarcode.jsp?_noc=1&whoami='+caller+'&formCondition='+formCondition+'&gridCondition='+gridCondition;
  284. }
  285. }
  286. })
  287. }
  288. },
  289. 'button[id=batchGenBarOBcode]':{
  290. afterrender: function(btn){
  291. if(caller == 'ProdInOut!BarcodeOut'){
  292. btn.hide();
  293. }
  294. },
  295. enable: function (btn){
  296. if(postStatuscode == 'POSTED' || postStatuscode=='已过帐'){
  297. btn.disable(true);
  298. }
  299. },
  300. click: function (btn){
  301. //产生新的条码并插到grid行中
  302. var form = Ext.getCmp("setBarcodeform");
  303. var pr_zxbzs = Ext.getCmp("pr_zxbzs").value;
  304. if((pr_zxbzs == 0) || pr_zxbzs < 0 ||pr_zxbzs ==null){
  305. showError("最小包装数必须大于0!");
  306. return ;
  307. }
  308. var pr_tracekind = Ext.getCmp("pr_tracekind").value;
  309. if(pr_tracekind == 1 || pr_tracekind == "单件管控"){
  310. if(pr_zxbzs!=1){
  311. showError("单件管控类型的物料最小包装数只能为1 !");
  312. return ;
  313. }
  314. }
  315. var pd_inqty = Ext.getCmp("pd_inqty");
  316. if(pd_inqty && (Number(pd_inqty.value) > Number(Ext.getCmp("pd_qty").value))){
  317. showError("批总量不允许大于来料总量");return;
  318. }
  319. if(Ext.getCmp("pk_qty").value == ''|| Ext.getCmp("pk_qty").value == 0
  320. ||Ext.getCmp("pk_qty").value == '0' ||Ext.getCmp("pk_qty").value == null){
  321. showError("请输入箱内总数");return ;
  322. }else {
  323. var pk_qty = Ext.getCmp("pk_qty").value;
  324. var pr_zxbzs = Ext.getCmp("pr_zxbzs").value;
  325. if(pr_zxbzs == ''||pr_zxbzs == 0 || pr_zxbzs == '0'||pr_zxbzs ==null){
  326. showError("请输入最小包装数");return ;
  327. }else {
  328. if(pk_qty%pr_zxbzs !=0 ){
  329. showError("箱内总数必须是最小包装数的整数倍!");return ;
  330. }
  331. }
  332. }
  333. var r = form.getValues();
  334. var keys = Ext.Object.getKeys(r);
  335. Ext.each(keys, function(k){
  336. f = form.down('#' + k);
  337. if(f && f.logic == 'ignore') {
  338. delete r[k];
  339. }
  340. });
  341. var param = unescape(escape(Ext.JSON.encode(r)));
  342. me.FormUtil.setLoading(true);
  343. Ext.Ajax.request({
  344. url : basePath + "scm/reserve/batchGenBarOBcode.action",
  345. params: {
  346. caller: caller,
  347. formStore:param
  348. },
  349. method : 'post',
  350. callback : function(options,success,response){
  351. me.FormUtil.setLoading(false);
  352. var res = new Ext.decode(response.responseText);
  353. if(res.exceptionInfo != null){
  354. showError(res.exceptionInfo);return;
  355. }else {
  356. window.location.href = basePath +'jsps/scm/reserve/setBarcode.jsp?_noc=1&whoami='+caller+'&formCondition='+formCondition+'&gridCondition='+gridCondition;
  357. }
  358. }
  359. })
  360. }
  361. },
  362. //删除全部明细
  363. 'erpDeleteAllDetailsButton':{
  364. afterrender: function(btn){
  365. if(caller == 'ProdInOut!BarcodeOut'){
  366. btn.hide();
  367. }
  368. if(postStatuscode == 'POSTED' || postStatuscode=='已过帐'){
  369. btn.disable(true);
  370. }
  371. },
  372. click:function (btn){
  373. var grid =Ext.getCmp("setBarcodeGridPanel");
  374. var items = grid.store.data.items;
  375. var bool = false;
  376. Ext.each(items, function(item, index){
  377. if(this.data[grid.keyField] != null && this.data[grid.keyField] != ''
  378. && this.data[grid.keyField] != '0' && this.data[grid.keyField] != 0){
  379. bool = true;
  380. }
  381. })
  382. if(!bool){
  383. showError("没有需要处理的数据!");
  384. return;
  385. }else{
  386. warnMsg("确定清空所有明细", function(btn){
  387. if(btn == 'yes'){
  388. Ext.Ajax.request({
  389. url : basePath + "scm/reserve/deleteAllBarDetails.action",
  390. params: {
  391. caller: window.parent.caller,
  392. no:Ext.getCmp("bi_piid").value,
  393. detno:Ext.getCmp("bi_pdno").value
  394. },
  395. method : 'post',
  396. callback : function(options,success,response){
  397. var res = new Ext.decode(response.responseText);
  398. if(res.exceptionInfo != null){
  399. var str = res.exceptionInfo;
  400. if(str.trim().substr(0, 12) == 'AFTERSUCCESS'){
  401. str = str.replace('AFTERSUCCESS', '');
  402. window.location.href = basePath +'jsps/scm/reserve/setBarcode.jsp?_noc=1&whoami='+caller+'&formCondition='+formCondition+'&gridCondition='+gridCondition;
  403. }
  404. showError(str);return;
  405. }else {
  406. window.location.href = basePath +'jsps/scm/reserve/setBarcode.jsp?_noc=1&whoami='+caller+'&formCondition='+formCondition+'&gridCondition='+gridCondition;
  407. }
  408. }
  409. })
  410. }else{
  411. return ;
  412. }
  413. })
  414. }
  415. }
  416. },
  417. //打印条码
  418. 'erpPrintAllButton':{
  419. afterrender: function(){
  420. },
  421. click: function (btn){
  422. var win = new Ext.window.Window({
  423. id : 'win',
  424. maximizable : true,
  425. buttonAlign : 'center',
  426. layout : 'anchor',
  427. title: '打印模板选择',
  428. modal : true,
  429. items: [{
  430. tag : 'iframe',
  431. frame : true,
  432. anchor : '100% 100%',
  433. layout : 'fit',
  434. html : '<iframe id="iframe_' + caller + '" src="' + basePath + 'jsps/scm/reserve/selPrintTemplate.jsp?whoami='+lps_barcaller +'" height="100%" width="100%" frameborder="0" scrolling="no"></iframe>'
  435. }]
  436. });
  437. win.show();
  438. }
  439. },
  440. 'erpGeneratePaCodeButton':{//生成包装箱号,要先提示生成条码之后再生成包装箱号
  441. afterrender: function(btn){
  442. if(caller == 'ProdInOut!BarcodeOut'){
  443. btn.hide();
  444. }
  445. if(postStatuscode == 'POSTED' || postStatuscode=='已过帐'){
  446. btn.disable(true);
  447. }
  448. },
  449. click : function (btn){
  450. if(Ext.getCmp("pk_qty").value == ''|| Ext.getCmp("pk_qty").value == 0
  451. ||Ext.getCmp("pk_qty").value == '0' ||Ext.getCmp("pk_qty").value == null){
  452. showError("请输入箱内总数");return ;
  453. }else {
  454. var pk_qty = Ext.getCmp("pk_qty").value;
  455. var pr_zxbzs = Ext.getCmp("pr_zxbzs").value;
  456. if(pr_zxbzs == ''||pr_zxbzs == 0 || pr_zxbzs == '0'||pr_zxbzs ==null){
  457. showError("请输入最小包装数");return ;
  458. }else {
  459. if(pk_qty%pr_zxbzs !=0 ){
  460. showError("箱内总数必须是最小包装数的整数倍!");return ;
  461. }
  462. }
  463. var form = Ext.getCmp("setBarcodeform");
  464. var r = form.getValues();
  465. var keys = Ext.Object.getKeys(r);
  466. Ext.each(keys, function(k){
  467. f = form.down('#' + k);
  468. if(f && f.logic == 'ignore') {
  469. delete r[k];
  470. }
  471. });
  472. var param = unescape(escape(Ext.JSON.encode(r)));
  473. Ext.Ajax.request({
  474. url : basePath + "scm/reserve/generatePaCode.action",
  475. params :{
  476. caller: caller,
  477. data : param
  478. },
  479. method : 'post',
  480. callback : function(options, success, response) {
  481. var res = new Ext.decode(response.responseText);
  482. if (res.exceptionInfo != null) {
  483. showError(res.exceptionInfo);
  484. return;
  485. }else {
  486. var grid =Ext.getCmp("setBarcodeGridPanel");
  487. gridCondition = (gridCondition == null) ? "" : gridCondition.replace(/IS/g,"=");
  488. grid.GridUtil.loadNewStore(grid,{caller:caller,condition:gridCondition});
  489. }
  490. }
  491. });
  492. }
  493. }
  494. },
  495. 'erpPrintAllPackageButton':{//打印全部箱号
  496. click : function (btn){
  497. var win = new Ext.window.Window({
  498. id : 'win',
  499. maximizable : true,
  500. buttonAlign : 'center',
  501. layout : 'anchor',
  502. title: '打印模板选择',
  503. modal : true,
  504. items: [{
  505. tag : 'iframe',
  506. frame : true,
  507. anchor : '100% 100%',
  508. layout : 'fit',
  509. html : '<iframe id="iframe_' + caller + '" src="' + basePath + 'jsps/scm/reserve/selPrintTemplate.jsp?whoami='+lps_obcaller +'" height="100%" width="100%" frameborder="0" scrolling="no"></iframe>'
  510. }]
  511. });
  512. win.show();
  513. }
  514. }
  515. });
  516. }
  517. });