- 如何对Ureport源码启动以及进行二次开发流程记录
**
一、启动UReport 2 V2.2.9
二、增加不依附于单元格的浮动图片
三、增加不依附于单元格的浮动(直)线段【新增】
- 运行后图片
代码修改记录
java修改
public class NoneExpandBuilder implements CellBuilder {
@Override
public Cell buildCell(List<BindData> dataList, Cell cell, Context context) {
if(dataList.size()==1){
BindData bindData=dataList.get(0);
cell.setData(bindData.getValue());
cell.setFormatData(bindData.getLabel());
cell.setBindData(bindData.getDataList());
}else{
Object obj=null;
List<Object> bindData=null;
for(BindData data:dataList){
if(obj==null){
if(data.getLabel()==null){
obj=data.getValue();
}else{
obj=data.getLabel();
}
}else{
if(data.getLabel()==null){
obj=obj+","+data.getValue();
}else{
obj=obj+","+data.getLabel();
}
}
bindData=data.getDataList();
}
cell.setData(obj);
cell.setBindData(bindData);
}
List<ConditionPropertyItem> conditionPropertyItems=cell.getConditionPropertyItems();
if(conditionPropertyItems!=null && conditionPropertyItems.size()>0){
context.getReport().getLazyComputeCells().add(cell);
}else{
cell.doFormat();
cell.doDataWrapCompute(context);
}
return cell;
}
}
JavaScript修改
export default class PrintLine{
constructor(context){
context.printLine=this;
this.context=context;
const height=$(window).height()-90;
const rightHr=$(`<hr title="打印线" class="ureport-right-hr-for-print" style="height: ${height}px;width:0px;border-left:dashed 1px #999999;position: absolute;left: 300pt;top: 35px;z-index: 10">`);
$(document.body).append(rightHr);
this.refresh();
}
refresh(){
const paper=this.context.reportDef.paper;
const orientation=paper.orientation;
let width=paper.width;
if(orientation==='landscape'){
width=paper.height;
}
width=width-paper.leftMargin-paper.rightMargin+38;
window.pageWidthcw = width;
$('.ureport-right-hr-for-print').css('left',width+"pt");
}
};
export default class FileInfo{
setFile(name){
if(!this.fileInfo){
this.fileInfo=$(`<div style="float: right;font-size: 12px;color: #009688;margin-top: 8px;margin-right: 5px"></div>`);
$('.ud-toolbar').append(this.fileInfo);
}
let suffix='.ureport.xml';
let pos=name.indexOf(suffix);
if(pos>-1){
name=name.substring(0,pos);
}
name=decodeURI(decodeURI(name));
this.fileInfo.html('报表:'+name);
}
};
CSS修改
.handsontable tr{
background: transparent;
}
.handsontable td, .handsontable th{
background: transparent;
}
.handsontable table.htCore{
border-collapse:collapse
}
.ud-toolbar{
width: 100%;
background: #f8f8f8;
}
.ud-property-panel{
width: 406px;
border: solid 1px #999;
border-radius: 5px;
top: 35px;
left: 710px;
z-index: 105;
position: absolute;
background: #ffffff;
box-shadow: 5px 5px 5px #888888;
}
.ud-select-color{
background: #000000;
width: 14px;
height: 4px;
display: block;
}
.ud-select-bgcolor{
background: #fff;
width: 14px;
height: 4px;
display: block;
}