SetLabelTemplate.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.scm.reserve.SetLabelTemplate', {
  3. extend: 'Ext.app.Controller',
  4. requires: ['erp.util.FormUtil', 'erp.util.GridUtil', 'erp.util.BaseUtil'],
  5. views:[
  6. 'core.form.Panel','scm.reserve.SetLabelTemplate','core.grid.Panel2','scm.reserve.setLabelTemplate.LabelForm','core.toolbar.Toolbar','core.form.MultiField','core.form.YnField',
  7. 'core.button.Save','core.button.Add','core.button.Submit','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.Parameter','core.button.LabelPreview'
  10. ],
  11. init:function(){
  12. var me = this;
  13. me.FormUtil = Ext.create('erp.util.FormUtil');
  14. me.GridUtil = Ext.create('erp.util.GridUtil');
  15. me.BaseUtil = Ext.create('erp.util.BaseUtil');
  16. this.control({
  17. 'erpGridPanel2': {
  18. afterrender: function(grid){},
  19. itemclick: function(selModel, record){
  20. var lp_id = record.data['lp_id'];
  21. if(lp_id != null && lp_id != 0){
  22. var formCondition ="lp_id IS"+lp_id;
  23. var linkCaller='LabelTemplateBarcode';
  24. var win = new Ext.window.Window(
  25. {
  26. id : 'win',
  27. height : '55%',
  28. width : '70%',
  29. maximizable : true,
  30. buttonAlign : 'center',
  31. layout : 'anchor',
  32. items : [ {
  33. tag : 'iframe',
  34. frame : true,
  35. anchor : '100% 100%',
  36. layout : 'fit',
  37. html : '<iframe id="iframe_'+linkCaller+'" src="'+basePath+'jsps/scm/reserve/LabelParameter.jsp?_noc=1&whoami='+linkCaller+'&formCondition='+formCondition+'" height="100%" width="100%" frameborder="0" scrolling="auto"></iframe>'
  38. } ],
  39. listeners:{
  40. 'beforeclose':function(view ,opt){
  41. //更新参数,刷新界面避免缓存造成预览重叠
  42. formCondition = getUrlParam('formCondition');
  43. gridCondition = getUrlParam('gridCondition');
  44. formCondition = (formCondition == null) ? "" : formCondition.replace(/IS/g,"=");
  45. gridCondition = (gridCondition == null) ? "" : gridCondition.replace(/IS/g,"=");
  46. window.location.href = basePath +'jsps/scm/reserve/setLabelTemplate.jsp?_noc=1&whoami='+caller+'&formCondition='+formCondition+'&gridCondition='+gridCondition;
  47. }
  48. }
  49. });
  50. win.show();
  51. }
  52. }
  53. },
  54. 'erpParameterButton':{
  55. click : function(btn){
  56. var id = Ext.getCmp("la_id").value;
  57. var formCondition = ' ';
  58. var linkCaller='LabelTemplateBarcode';
  59. var win = new Ext.window.Window(
  60. {
  61. id : 'win',
  62. height : '55%',
  63. width : '70%',
  64. maximizable : true,
  65. buttonAlign : 'center',
  66. layout : 'anchor',
  67. items : [ {
  68. tag : 'iframe',
  69. frame : true,
  70. anchor : '100% 100%',
  71. layout : 'fit',
  72. html : '<iframe id="iframe_'+linkCaller+'" src="'+basePath+'jsps/scm/reserve/LabelParameter.jsp?_noc=1&whoami='+linkCaller+'&lp_laid='+id+'" height="100%" width="100%" frameborder="0" scrolling="auto"></iframe>'
  73. } ],
  74. listeners:{
  75. 'beforeclose':function(view ,opt){
  76. //更新参数,刷新界面避免缓存造成预览重叠
  77. formCondition = getUrlParam('formCondition');
  78. gridCondition = getUrlParam('gridCondition');
  79. formCondition = (formCondition == null) ? "" : formCondition.replace(/IS/g,"=");
  80. gridCondition = (gridCondition == null) ? "" : gridCondition.replace(/IS/g,"=");
  81. window.location.href = basePath +'jsps/scm/reserve/setLabelTemplate.jsp?_noc=1&whoami='+caller+'&formCondition='+formCondition+'&gridCondition='+gridCondition;
  82. }
  83. }
  84. });
  85. win.show();
  86. },
  87. afterrender: function(btn){
  88. var form = me.getForm(btn);
  89. var status = Ext.getCmp(form.statuscodeField);
  90. if(status && status.value != "ENTERING"){
  91. btn.hide();
  92. }
  93. }
  94. },
  95. 'erpSaveButton': {
  96. click: function(btn){
  97. me.FormUtil.beforeSave(me);
  98. }
  99. },
  100. 'erpDeleteButton' : {
  101. click: function(btn){
  102. me.FormUtil.onDelete({id: Number(Ext.getCmp('la_id').value)});
  103. }
  104. },
  105. 'erpUpdateButton': {
  106. afterrender: function(btn){
  107. var status = Ext.getCmp(me.getForm(btn).statuscodeField);
  108. if(status && status.value != 'ENTERING'){
  109. btn.hide();
  110. }
  111. },
  112. click: function(btn){
  113. this.FormUtil.onUpdate(this);
  114. }
  115. },
  116. 'erpAddButton': {
  117. click: function(){
  118. me.FormUtil.onAdd('add' + caller, '新增模板打印设置', "jsps/scm/reserve/setLabelTemplate.jsp?whoami=" + caller);
  119. }
  120. },
  121. 'erpCloseButton': {
  122. click: function(btn){
  123. me.FormUtil.beforeClose(me);
  124. }
  125. },
  126. 'erpAuditButton': {
  127. afterrender: function(btn){
  128. var status = Ext.getCmp(me.getForm(btn).statuscodeField);
  129. if(status && status.value != 'COMMITED'){
  130. btn.hide();
  131. }
  132. },
  133. click: function(btn){
  134. me.FormUtil.onAudit(Ext.getCmp('la_id').value);
  135. }
  136. },
  137. 'erpResAuditButton': {
  138. afterrender: function(btn){
  139. var status = Ext.getCmp(me.getForm(btn).statuscodeField);
  140. if((status && status.value != 'AUDITED')){
  141. btn.hide();
  142. }
  143. },
  144. click: function(btn){
  145. me.FormUtil.onResAudit(Ext.getCmp('la_id').value);
  146. }
  147. },
  148. 'erpSubmitButton': {
  149. afterrender: function(btn){
  150. var status = Ext.getCmp(me.getForm(btn).statuscodeField);
  151. if(status && status.value != 'ENTERING'){
  152. btn.hide();
  153. }
  154. },
  155. click: function(btn){
  156. me.FormUtil.onSubmit(Ext.getCmp('la_id').value);
  157. }
  158. },
  159. 'erpResSubmitButton': {
  160. afterrender: function(btn){
  161. var status = Ext.getCmp(me.getForm(btn).statuscodeField);
  162. if(status && status.value != 'COMMITED'){
  163. btn.hide();
  164. }
  165. },
  166. click: function(btn){
  167. me.FormUtil.onResSubmit(Ext.getCmp('la_id').value);
  168. }
  169. },
  170. 'erpBannedButton': {
  171. afterrender: function(btn){
  172. var status = Ext.getCmp(me.getForm(btn).statuscodeField);
  173. if(status && status.value == 'DISABLE'){
  174. btn.hide();
  175. }
  176. },
  177. click: function(btn){
  178. this.FormUtil.onBanned(Ext.getCmp('la_id').value);
  179. }
  180. },
  181. 'erpResBannedButton': {
  182. afterrender: function(btn){
  183. var status = Ext.getCmp(me.getForm(btn).statuscodeField);
  184. if(status && status.value != 'DISABLE'){
  185. btn.hide();
  186. }
  187. },
  188. click: function(btn){
  189. this.FormUtil.onResBanned(Ext.getCmp('la_id').value);
  190. }
  191. },
  192. 'erpLabelPreviewButton':{//模板预览维护,修改样式,不具有增减打印项的
  193. afterrender: function(btn){
  194. var status = Ext.getCmp(me.getForm(btn).statuscodeField);
  195. if(status && status.value != 'ENTERING'){
  196. btn.hide();
  197. }
  198. },
  199. click:function(btn){
  200. //检测是否安装了插件,没有提示安装
  201. var LODOP = getLodop(document.getElementById('LODOP_OB'),document.getElementById('LODOP_EM'));
  202. //获取模板参数
  203. Ext.Ajax.request({
  204. url : basePath + "scm/reserve/getdetail.action",
  205. params : {
  206. condition:'la_id='+Ext.getCmp("la_id").value,
  207. caller:caller
  208. },
  209. method : 'post',
  210. callback : function(options, success, response) {
  211. var res = new Ext.decode(response.responseText);
  212. if (res.exceptionInfo != null) {
  213. showError(res.exceptionInfo);
  214. return null;
  215. } else if(res.data != null){
  216. //LODOP.PRINT_INIT("标签模板维护");
  217. var strs= new Array(); //定义一数组
  218. strs = res.data[0]['LA_PAGESIZE'].split("*"); //字符分割
  219. LODOP.SET_PRINT_PAGESIZE(1, strs[0]*10, strs[1]*10, "");
  220. Ext.each(res.data,function(data,index){
  221. LODOP.SET_PRINT_STYLE("FontSize",data['LP_SIZE']);
  222. if(data['LP_VALUETYPE'] == 'barcode'){
  223. LODOP.ADD_PRINT_BARCODE(data['LP_TOPRATE']+"mm",data['LP_LEFTRATE']+"mm",data['LP_WIDTH']+"mm",data['LP_HEIGHT']+"mm",data['LP_ENCODE'],data['LP_VALUETYPE']+data['LP_ID']);
  224. LODOP.SET_PRINT_STYLEA(0,"ShowBarText",data['LP_IFSHOWNOTE']);
  225. LODOP.SET_PRINT_STYLEA(0,"AlignJustify",data['LP_NOTEALIGNJUSTIFY']);
  226. }else if(data['LP_VALUETYPE'] == 'text'){
  227. LODOP.SET_PRINT_STYLE("FontName",data['LP_FONT']);
  228. LODOP.ADD_PRINT_TEXT(data['LP_TOPRATE']+"mm",data['LP_LEFTRATE']+"mm",data['LP_WIDTH']+"mm",data['LP_HEIGHT']+"mm",data['LP_VALUETYPE']+data['LP_ID']);
  229. }
  230. });
  231. LODOP.SET_SHOW_MODE("HIDE_ABUTTIN_SETUP",1);
  232. LODOP.SET_SHOW_MODE("HIDE_RBUTTIN_SETUP",1);
  233. LODOP.PRINT_SETUP();
  234. var params = new Object();
  235. var gridData = new Array();
  236. Ext.each(res.data,function(data,index){
  237. var o = new Object();
  238. o['lp_id'] = data['LP_ID'];
  239. o['lp_laid'] = data['LP_LAID'];
  240. o['lp_leftrate'] = LODOP.GET_VALUE('ItemLeft',index+1).replace(/"/g, "").replace("mm", "");
  241. o['lp_toprate'] = LODOP.GET_VALUE('ItemTop',index+1).replace(/"/g, "").replace("mm", "");
  242. o['lp_size'] = LODOP.GET_VALUE('ItemFontSize',index+1);
  243. o['lp_width'] = LODOP.GET_VALUE('ItemWidth',index+1).replace(/"/g, "").replace("mm", "");
  244. o['lp_height'] = LODOP.GET_VALUE('ItemHeight',index+1).replace(/"/g, "").replace("mm", "");
  245. if(LODOP.GET_VALUE('ItemContent',index+1) == 'barcode'+data['LP_ID']){
  246. o['lp_ifshownote'] = LODOP.GET_VALUE('ItemShowBarText',index+1);
  247. o['lp_notealignjustify'] = LODOP.GET_VALUE('ItemAlignJustify',index+1);
  248. o['lp_encode'] = LODOP.GET_VALUE('ItemFontName',index+1);
  249. //ItemAlignJustify -该打印项文本两端是否靠齐
  250. }else if(LODOP.GET_VALUE('ItemContent',index+1) == 'text'+data['LP_ID']){
  251. o['lp_font'] = LODOP.GET_VALUE('ItemFontName',index+1);
  252. }
  253. gridData.push(o);
  254. });
  255. params.gridStore = unescape(Ext.JSON.encode(gridData).replace(/\\/g,"%"));
  256. Ext.Ajax.request({
  257. url : basePath + "scm/reserve/updateLabelT.action",
  258. params: params,
  259. method : 'post',
  260. callback : function(options,success,response){
  261. var res = new Ext.decode(response.responseText);
  262. if(res.exceptionInfo != null){
  263. showError(res.exceptionInfo);return;
  264. }else {
  265. //更新参数,刷新界面避免缓存造成预览重叠
  266. formCondition = getUrlParam('formCondition');
  267. gridCondition = getUrlParam('gridCondition');
  268. formCondition = (formCondition == null) ? "" : formCondition.replace(/IS/g,"=");
  269. gridCondition = (gridCondition == null) ? "" : gridCondition.replace(/IS/g,"=");
  270. window.location.href = basePath +'jsps/scm/reserve/setLabelTemplate.jsp?_noc=1&whoami='+caller+'&formCondition='+formCondition+'&gridCondition='+gridCondition;
  271. }
  272. }
  273. });
  274. }
  275. }
  276. });
  277. }
  278. }
  279. });
  280. },
  281. getForm: function(btn){
  282. return btn.ownerCt.ownerCt;
  283. }
  284. });