SetLabelTemplate.js 12 KB

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