Index: ssts-web/src/main/webapp/disinfectsystem/labelTemplateDesign/printCustomDesign.js =================================================================== diff -u -r15105 -r15107 --- ssts-web/src/main/webapp/disinfectsystem/labelTemplateDesign/printCustomDesign.js (.../printCustomDesign.js) (revision 15105) +++ ssts-web/src/main/webapp/disinfectsystem/labelTemplateDesign/printCustomDesign.js (.../printCustomDesign.js) (revision 15107) @@ -97,9 +97,15 @@ LODOP.ADD_PRINT_TEXTA('a', 0, 0, 75, 30, '文本'); } function insertTableToLodop(tableConfig){ - DisplayDesign(); +// alert(tableConfig) + if(tableConfig == null){ + return; + } + saveTableConfig(tableConfig);// 自动保存表格属性 +// DisplayDesign(); var itemName = 'table1'; var tableHtml = createTableHtmlByConfig(tableConfig,dataSource1); +// alert(tableHtml) LODOP.ADD_PRINT_TABLE(tableConfig.topforPrint,tableConfig.leftforPrint,tableConfig.widthforPrint,tableConfig.heightforPrint,tableHtml); LODOP.SET_PRINT_STYLEA(0, "ItemType",4);// 多页项 LODOP.SET_PRINT_STYLEA(0, "ItemName",'table1');// 多页项 @@ -222,6 +228,8 @@ // alert(currentConfig.programCodes) eval(currentConfig.programCodes);// 执行eval方法,装载模板 } + // 生成预览表格 + insertTableToLodop(currentTableConfig); LODOP.PREVIEW(); DisplayDesign(); @@ -336,7 +344,7 @@ } },{ text : '打印', - hidden : false, + hidden : true, handler : function() { prn_Preview(); } @@ -663,11 +671,6 @@ // 显示表格窗口 var tableDesignWindow = null; function showTableDesignWindow(){ - if(currentTableConfig == null){ - if(currentConfig.templateInfo.tableConfigs.length > 0){ - currentTableConfig = currentConfig.templateInfo.tableConfigs[0]; - } - } if(tableDesignWindow != null){ if(tableDesignWindow.isHidden()){ tableDesignWindow.show(); @@ -908,19 +911,14 @@ // 初始化template function initTemplate(template){ // alert(template.templateInfo) - if(isUndefinedOrNullOrEmpty(template.templateInfo)){ - template.templateInfo = {}; - }else{ - template.templateInfo = JSON.parse(template.templateInfo); + transformTemplateConfigObjs(template); + if(currentTableConfig == null){ + if(currentConfig.templateInfo.tableConfigs.length > 0){ + currentTableConfig = currentConfig.templateInfo.tableConfigs[0]; + } } - var templateInfo = template.templateInfo; - if(isUndefinedOrNullOrEmpty(templateInfo.tableConfigs)){ - templateInfo.tableConfigs = []; - }else{ -// var tableConfigs = Ext4.JSON.decode(templateInfo.tableConfigs); - templateInfo.tableConfigs = TableConfig.convertFromJsonObjs(templateInfo.tableConfigs); - } } + function getTemplateInfoStr(){ var tableConfigs = currentConfig.templateInfo.tableConfigs; currentConfig.templateInfo.tableConfigs = TableConfig.convertToJsonObjs(tableConfigs); @@ -967,272 +965,8 @@ }); -Ext4.define("StyleConfig", { - getStyleStr: function(){ - return ''; - } -}); -Ext4.define("FontConfig", { - config: { - fontStyle: 'normal', - fontVariant: 'normal', - fontWeight: 'normal', - fontSize: '16px', - fontSizeValue: '16', - fontSizeUnit: 'px', - fontFamily: '宋体', - }, - extend: 'StyleConfig', - constructor: function(config){ - this.initConfig(config); - this.callParent(arguments); - }, - getStyleStr: function(){ - return this.fontStyle +' '+ this.fontVariant +' '+ this.fontWeight +' '+ this.fontSize +' '+ this.fontFamily+';'; - }, - saveFontConfig: function(cmpIdPrefix){ - var family = ''; - var size = ''; - var cmpFamily = Ext4.getCmp('cmpIdPrefix_family'); - var cmpSize = Ext4.getCmp('cmpIdPrefix_size'); - if(cmpFamily != null){ - family = cmpFamily.getValue(); - } - if(cmpSize != null){ - size = cmpSize.getValue(); - } - if(family != ''){ - this.fontFamily = family; - } - if(size != ''){ - this.fontSize = size; - } - }, - loadFontConfig: function(cmpIdPrefix){ - var cmpFamily = Ext4.getCmp('cmpIdPrefix_family'); - var cmpSize = Ext4.getCmp('cmpIdPrefix_size'); - if(cmpFamily != null){ - cmpFamily.setValue(this.fontFamily); - } - if(cmpSize != null){ - cmpSize.setValue(this.fontSize); - } - }, - convertToJsonObj: function(){ - var obj = { - fontStyle: this.fontStyle, - fontVariant: this.fontVariant, - fontWeight: this.fontWeight, - fontSize: this.fontSize, - fontFamily: this.fontFamily - } - return obj; - }, - statics: { - convertFromJsonObj: function(obj){ - var newObj = new FontConfig({ - fontStyle: obj.fontStyle, - fontVariant: obj.fontVariant, - fontWeight: obj.fontWeight, - fontSize: obj.fontSize, - fontFamily: obj.fontFamily - }); - return newObj; - } - } -}); -Ext4.define("BorderConfig", { - extend: 'StyleConfig', - getStyleStr: function(){ - return this.borderWidth +' '+ this.borderStyle +' '+ this.borderColor+';'; - }, - constructor: function(){ - this.callParent(arguments); - this.borderWidth = '1px'; - this.borderStyle = 'solid'; - this.borderColor = 'black'; - }, - convertToJsonObj: function(){ - var obj = { - borderWidth: this.borderWidth, - borderStyle: this.borderStyle, - borderColor: this.borderColor - }; - return obj; - }, - statics: { - convertFromJsonObj: function(obj){ - var newObj = new BorderConfig({ - borderWidth: obj.borderWidth, - borderStyle: obj.borderStyle, - borderColor: obj.borderColor - }); - return newObj; - } - } -}); -Ext4.define("TableColumnConfig", { - config:{ - align: 'center', - width: '30%', - innerHTML:'', - fontConfig: new FontConfig(), - borderConfig: new BorderConfig() - }, - constructor: function(config){ - this.initConfig(config); - this.callParent(arguments); - }, - getStyleStr: function(){ - return this.borderConfig.getStyleStr() + this.fontConfig.getStyleStr(); - }, - statics: { - convertFromJsonObjs: function(objs){ - var newObjs = []; - for(var i=0;i 0){ - for(var r=0;r'; - for(var c=0;c'+columnConfig.innerHTML+''; - tableHtml += fillPropertiesFromObj(columnConfig,tempStr); - } - tableHtml += ''; - } - } - // 数据项 - var dataRowConfig = tableConfig.getTableDataItemRowConfig(); - if(dataRowConfig != null){ - var itemsPerRow = tableConfig.itemsPerRow; - var dataItems = obj.dataItems; - var mod = dataItems.length % itemsPerRow; - var itemsCount = dataItems.length; - var rowsCount = parseInt(itemsCount/itemsPerRow); - if(mod != 0){ - rowsCount++; - } - if(rowsCount > 0){ - var columnConfigs = dataRowConfig.columnConfigs; - for(var row=0;row'; - for(var c=0;c'+columnConfig.innerHTML+''; - tableHtml += fillPropertiesFromObj(itemsObj,tempStr); - } - tableHtml += ""; - } - } - } - - // 结束表格 - tableHtml += ''; - return tableHtml; -}