SetBarcode.js 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418
  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 + "pm/bom/getDescription.action",
  72. params: {
  73. tablename:'setting',
  74. field:'se_value',
  75. condition:"se_what='UseLocationOrNot'"
  76. },
  77. method : 'post',
  78. callback : function(options,success,response){
  79. var res = new Ext.decode(response.responseText);
  80. if(res.description == 'N'){//不启用仓位
  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=save]': {
  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. var grid =Ext.getCmp("setBarcodeGridPanel");
  106. if( grid.selModel.getCount() == 0 ){
  107. showError("没有需要处理的数据!");
  108. return;
  109. }
  110. var params = new Object();
  111. var items = grid.selModel.getSelection();
  112. Ext.each(items, function(item, index){
  113. if(this.data[grid.keyField] != null && this.data[grid.keyField] != ''
  114. && this.data[grid.keyField] != '0' && this.data[grid.keyField] != 0){
  115. item.index = this.data[grid.keyField];
  116. grid.multiselected.push(item);
  117. }
  118. var records = Ext.Array.unique(grid.multiselected);
  119. if(records.length > 0){
  120. params.caller = caller;
  121. var data = new Array();
  122. var bool = false;
  123. Ext.each(records, function(record, index){
  124. if((grid.keyField && this.data[grid.keyField] != null && this.data[grid.keyField] != ''
  125. && this.data[grid.keyField] != '0' && this.data[grid.keyField] != 0)){
  126. bool = true;
  127. var o = new Object();
  128. if(grid.keyField){
  129. o[grid.keyField] = record.data[grid.keyField];
  130. }
  131. if(grid.toField){
  132. Ext.each(grid.toField, function(f, index){
  133. var v = Ext.getCmp(f).value;
  134. if(v != null && v.toString().trim() != '' && v.toString().trim() != 'null'){
  135. o[f] = v;
  136. }
  137. });
  138. }
  139. if(grid.necessaryFields){
  140. Ext.each(grid.necessaryFields, function(f, index){
  141. var v = record.data[f];
  142. if(Ext.isDate(v)){
  143. v = Ext.Date.toString(v);
  144. }
  145. o[f] = v;
  146. });
  147. }
  148. data.push(o);
  149. }
  150. });
  151. if(bool){
  152. params.gridStore = unescape(Ext.JSON.encode(data).replace(/\\/g,"%"));
  153. me.FormUtil.setLoading(true);
  154. Ext.Ajax.request({
  155. url : basePath + "scm/reserve/saveBarcode.action",
  156. params: params,
  157. method : 'post',
  158. callback : function(options,success,response){
  159. me.FormUtil.setLoading(false);
  160. var res = new Ext.decode(response.responseText);
  161. if(res.exceptionInfo != null){
  162. showError(res.exceptionInfo);return;
  163. }else {
  164. window.location.href = basePath +'jsps/scm/reserve/setBarcode.jsp?_noc=1&whoami='+caller+'&formCondition='+formCondition+'&gridCondition='+gridCondition;
  165. }
  166. }
  167. })
  168. } else {
  169. showError("没有需要处理的数据!");
  170. }
  171. }
  172. })
  173. }
  174. },
  175. 'button[id=batchGenBarcode]':{//批量生成条码
  176. afterrender: function(btn){
  177. if(caller == 'ProdInOut!BarcodeOut'){
  178. btn.hide();
  179. }
  180. },
  181. enable: function (btn){
  182. if(postStatuscode == 'POSTED' || postStatuscode=='已过帐'){
  183. btn.disable(true);
  184. }
  185. },
  186. click: function (btn){
  187. //产生新的条码并插到grid行中
  188. var form = Ext.getCmp("setBarcodeform");
  189. var pr_zxbzs = Ext.getCmp("pr_zxbzs").value;
  190. if((pr_zxbzs == 0) || pr_zxbzs < 0 ){
  191. showError("最小包装数必须大于0!");
  192. return ;
  193. }
  194. var pr_tracekind = Ext.getCmp("pr_tracekind").value;
  195. if(pr_tracekind == 1 || pr_tracekind == "单件管控"){
  196. if(pr_zxbzs!=1){
  197. showError("单件管控类型的物料最小包装数只能为1 !");
  198. return ;
  199. }
  200. }
  201. var pd_inqty = Ext.getCmp("pd_inqty");
  202. if(pd_inqty && (Number(pd_inqty.value)=='0' ||Number(pd_inqty.value) == 0)){
  203. showError("批总量不允许为0!");return;
  204. }
  205. if(pd_inqty && (Number(pd_inqty.value) > Number(Ext.getCmp("pd_qty").value))){
  206. showError("批总量不允许大于来料总量");return;
  207. }
  208. var r = form.getValues();
  209. var keys = Ext.Object.getKeys(r);
  210. Ext.each(keys, function(k){
  211. f = form.down('#' + k);
  212. if(f && f.logic == 'ignore') {
  213. delete r[k];
  214. }
  215. });
  216. var param = unescape(escape(Ext.JSON.encode(r)));
  217. me.FormUtil.setLoading(true);
  218. Ext.Ajax.request({
  219. url : basePath + "scm/reserve/batchGenBarcode.action",
  220. params: {
  221. caller: caller,
  222. formStore:param
  223. },
  224. method : 'post',
  225. callback : function(options,success,response){
  226. me.FormUtil.setLoading(false);
  227. var res = new Ext.decode(response.responseText);
  228. if(res.exceptionInfo != null){
  229. showError(res.exceptionInfo);return;
  230. }else {
  231. window.location.href = basePath +'jsps/scm/reserve/setBarcode.jsp?_noc=1&whoami='+caller+'&formCondition='+formCondition+'&gridCondition='+gridCondition;
  232. }
  233. }
  234. })
  235. }
  236. },
  237. 'button[id=batchGenBarOBcode]':{//批量生成条码和箱号
  238. afterrender: function(btn){
  239. if(caller == 'ProdInOut!BarcodeOut'){
  240. btn.hide();
  241. }
  242. },
  243. enable: function (btn){
  244. if(postStatuscode == 'POSTED' || postStatuscode=='已过帐'){
  245. btn.disable(true);
  246. }
  247. },
  248. click: function (btn){
  249. //产生新的条码并插到grid行中
  250. var form = Ext.getCmp("setBarcodeform");
  251. var pr_zxbzs = Ext.getCmp("pr_zxbzs").value;
  252. if((pr_zxbzs == 0) || pr_zxbzs < 0 ||pr_zxbzs ==null){
  253. showError("最小包装数必须大于0!");
  254. return ;
  255. }
  256. var pr_tracekind = Ext.getCmp("pr_tracekind").value;
  257. if(pr_tracekind == 1 || pr_tracekind == "单件管控"){
  258. if(pr_zxbzs!=1){
  259. showError("单件管控类型的物料最小包装数只能为1 !");
  260. return ;
  261. }
  262. }
  263. var pd_inqty = Ext.getCmp("pd_inqty");
  264. if(pd_inqty && (Number(pd_inqty.value)=='0' ||Number(pd_inqty.value) == 0)){
  265. showError("批总量不允许为0!");return;
  266. }
  267. if(pd_inqty && (Number(pd_inqty.value) > Number(Ext.getCmp("pd_qty").value))){
  268. showError("批总量不允许大于来料总量");return;
  269. }
  270. if(Ext.getCmp("pk_qty").value == ''|| Ext.getCmp("pk_qty").value == 0
  271. ||Ext.getCmp("pk_qty").value == '0' ||Ext.getCmp("pk_qty").value == null){
  272. showError("请输入箱内总数");return ;
  273. }else {
  274. var pk_qty = Ext.getCmp("pk_qty").value;
  275. var pr_zxbzs = Ext.getCmp("pr_zxbzs").value;
  276. if(pr_zxbzs == ''||pr_zxbzs == 0 || pr_zxbzs == '0'||pr_zxbzs ==null){
  277. showError("请输入最小包装数");return ;
  278. }else {
  279. if(pk_qty%pr_zxbzs !=0 ){
  280. showError("箱内总数必须是最小包装数的整数倍!");return ;
  281. }
  282. }
  283. }
  284. var r = form.getValues();
  285. var keys = Ext.Object.getKeys(r);
  286. Ext.each(keys, function(k){
  287. f = form.down('#' + k);
  288. if(f && f.logic == 'ignore') {
  289. delete r[k];
  290. }
  291. });
  292. var param = unescape(escape(Ext.JSON.encode(r)));
  293. me.FormUtil.setLoading(true);
  294. Ext.Ajax.request({
  295. url : basePath + "scm/reserve/batchGenBarOBcode.action",
  296. params: {
  297. caller: caller,
  298. formStore:param
  299. },
  300. method : 'post',
  301. callback : function(options,success,response){
  302. me.FormUtil.setLoading(false);
  303. var res = new Ext.decode(response.responseText);
  304. if(res.exceptionInfo != null){
  305. showError(res.exceptionInfo);return;
  306. }else {
  307. window.location.href = basePath +'jsps/scm/reserve/setBarcode.jsp?_noc=1&whoami='+caller+'&formCondition='+formCondition+'&gridCondition='+gridCondition;
  308. }
  309. }
  310. })
  311. }
  312. },
  313. //删除全部明细
  314. 'erpDeleteAllDetailsButton':{
  315. afterrender: function(btn){
  316. if(caller == 'ProdInOut!BarcodeOut'){
  317. btn.hide();
  318. }
  319. if(postStatuscode == 'POSTED' || postStatuscode=='已过帐'){
  320. btn.disable(true);
  321. }
  322. },
  323. click:function (btn){
  324. var grid =Ext.getCmp("setBarcodeGridPanel");
  325. var items = grid.store.data.items;
  326. var bool = false;
  327. Ext.each(items, function(item, index){
  328. if(this.data[grid.keyField] != null && this.data[grid.keyField] != ''
  329. && this.data[grid.keyField] != '0' && this.data[grid.keyField] != 0){
  330. bool = true;
  331. }
  332. })
  333. if(!bool){
  334. showError("没有需要处理的数据!");
  335. return;
  336. }else{
  337. warnMsg("确定清空所有明细", function(btn){
  338. if(btn == 'yes'){
  339. Ext.Ajax.request({
  340. url : basePath + "scm/reserve/deleteAllBarDetails.action",
  341. params: {
  342. caller: window.parent.caller,
  343. no:Ext.getCmp("bi_piid").value,
  344. detno:Ext.getCmp("bi_pdno").value
  345. },
  346. method : 'post',
  347. callback : function(options,success,response){
  348. var res = new Ext.decode(response.responseText);
  349. if(res.exceptionInfo != null){
  350. var str = res.exceptionInfo;
  351. if(str.trim().substr(0, 12) == 'AFTERSUCCESS'){
  352. str = str.replace('AFTERSUCCESS', '');
  353. window.location.href = basePath +'jsps/scm/reserve/setBarcode.jsp?_noc=1&whoami='+caller+'&formCondition='+formCondition+'&gridCondition='+gridCondition;
  354. }
  355. showError(str);return;
  356. }else {
  357. window.location.href = basePath +'jsps/scm/reserve/setBarcode.jsp?_noc=1&whoami='+caller+'&formCondition='+formCondition+'&gridCondition='+gridCondition;
  358. }
  359. }
  360. })
  361. }else{
  362. return ;
  363. }
  364. })
  365. }
  366. }
  367. },
  368. //打印条码
  369. 'erpPrintAllButton':{
  370. click: function (btn){
  371. var win = new Ext.window.Window({
  372. id : 'win',
  373. maximizable : true,
  374. buttonAlign : 'center',
  375. layout : 'anchor',
  376. title: '打印模板选择',
  377. modal : true,
  378. items: [{
  379. tag : 'iframe',
  380. frame : true,
  381. anchor : '100% 100%',
  382. layout : 'fit',
  383. html : '<iframe id="iframe_' + caller + '" src="' + basePath + 'jsps/scm/reserve/selPrintTemplate.jsp?whoami='+lps_barcaller +'" height="100%" width="100%" frameborder="0" scrolling="no"></iframe>'
  384. }]
  385. });
  386. win.show();
  387. }
  388. },
  389. 'erpPrintAllPackageButton':{//打印全部箱号
  390. click : function (btn){
  391. var win = new Ext.window.Window({
  392. id : 'win',
  393. maximizable : true,
  394. buttonAlign : 'center',
  395. layout : 'anchor',
  396. title: '打印模板选择',
  397. modal : true,
  398. items: [{
  399. tag : 'iframe',
  400. frame : true,
  401. anchor : '100% 100%',
  402. layout : 'fit',
  403. html : '<iframe id="iframe_' + caller + '" src="' + basePath + 'jsps/scm/reserve/selPrintTemplate.jsp?whoami='+lps_obcaller +'" height="100%" width="100%" frameborder="0" scrolling="no"></iframe>'
  404. }]
  405. });
  406. win.show();
  407. }
  408. }
  409. });
  410. }
  411. });