SetLabelTemplate.js 14 KB

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