项目云-项目一览表二开教程(面向实施与二开人员)原创
金蝶云社区-云社区用户456N1273
云社区用户456N1273
1人赞赏了该文章 166次浏览 未经作者许可,禁止转载编辑于2023年12月28日 15:26:05

一、二开扩展项目一览表。

元数据添加两个字段,需要在上方报表列表与下面单据体都需要添加。

image.png

如果只是添加已有基础资料字段的应用属性,则可以添加基础资料属性。

image.png

二、新增的字段赋值则需要在报表的插件内配置一个二开插件。

image.png


插件代码参考下面的代码示例即可。


public class ProjectBookReportFormTplPluginExt extends AbstractReportFormPlugin {

    //例子:二开字段
    //报表的字段
    private String textfield = "textfield";
    //单据体的字段
    private String ebtextfield = "ebtextfield";

    @Override
    public void processRowData(String gridPK, DynamicObjectCollection rowData, ReportQueryParam queryParam) {
        super.processRowData(gridPK, rowData, queryParam);
        for (DynamicObject row : rowData) {
            DynamicObject org = row.getDynamicObject("businessorg");
            DynamicObject kind = row.getDynamicObject("prokind");
            String billno = row.getString("pronum");
            //demo,赋值
            row.set(textfield, org.getString("name") + billno);
        }
    }

    @Override
    public void afterQuery(ReportQueryParam queryParam) {
        super.afterQuery(queryParam);
        ReportList list = this.getControl("reportlistap");
        ReportListModel reportModel = (ReportListModel) list.getReportModel();
        DynamicObjectCollection allProcessedData = new DynamicObjectCollection();
        int rowCount = reportModel.getRowCount();
        int begin = 0;
        String maxsize = System.getProperty("orm.opt.in.maxsize");
        int length = StringUtils.isEmpty(maxsize) ? rowCount : Integer.parseInt(maxsize);
        // 批量处理数据(避免in查询超出平台限制报错)
        while (begin < rowCount) {
            DynamicObjectCollection rowDataCol = reportModel.getRowData(begin, length);
            allProcessedData.addAll(rowDataCol);
            begin = begin + length;
        }

        int rowIndex = 0;
        //获取单据体的分录,最终渲染二开字段。
        DynamicObjectCollection entryentity = this.getModel().getEntryEntity("entryentity");
        for (DynamicObject row : allProcessedData) {
            if (entryentity.get(rowIndex) != null) {
                //把报表赋值到单据体。
                entryentity.get(rowIndex).set(ebtextfield, row.get(textfield));
            }
            rowIndex++;
        }
        this.getModel().updateEntryCache(entryentity);
        this.getView().updateView("entryentity");
    }
}



赞 1