Cloud开发动态列的简单账表

Posted zfangfang

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Cloud开发动态列的简单账表相关的知识,希望对你有一定的参考价值。

业务场景:客户需要根据过滤条件的不同显示不同的列。如下方式可以实现动态的列名。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Kingdee.BOS.Core.Report.PlugIn;
using Kingdee.BOS.Core.Report;
using System.Data;
using Kingdee.BOS.Contracts.Report;
using Kingdee.BOS.App.Data;
using Kingdee.BOS.Core.CommonFilter;
using Kingdee.BOS.Util;
using Kingdee.BOS;
using Kingdee.BOS.Core;
using Kingdee.BOS.Core.List;
using System.ComponentModel;
using Kingdee.BOS.Orm.DataEntity;
using Kingdee.BOS.ServiceHelper;
using System.IO;
using Excel = Microsoft.Office.Interop.Excel;
using System.Reflection;
using Kingdee.BOS.Core.DynamicForm;

namespace Report
{
    [Description("部门每月领用数量统计表")]
    public class Report : SysReportBaseService
    {
        public DataSet ds = new DataSet();
        public override void Initialize()
        {
            base.Initialize();
            this.ReportProperty.ReportType = ReportType.REPORTTYPE_NORMAL;
            this.ReportProperty.ReportName = new LocaleValue("部门每月领用数量统计表", base.Context.UserLocale.LCID);
            this.ReportProperty.BillKeyFieldName = "dept";
        }

        public override string GetTableName()
        {
            var result = base.GetTableName();
            return result;
        }

        public override void BuilderReportSqlAndTempTable(IRptParams filter, string tableName)
        {
            base.BuilderReportSqlAndTempTable(filter, tableName);
            // 获取过滤条件
            DynamicObject customFil = filter.FilterParameter.CustomFilter;
            String StartTime = customFil["F_Dev_StartTime"].ToString();
            String StopTime = customFil["F_Dev_StopTime"].ToString();

            string seqFld = string.Format(base.KSQL_SEQ, " dept ");

            KSQL_SEQ = string.Format(KSQL_SEQ, "dept asc");
            string sSQL = @"exec P_ExportToChart ‘" + StartTime + "‘,‘" + StopTime + "‘,‘{0}‘,‘{1}‘";
            string sSQLWithNoTempTable = @"exec P_ExportToChartWithNoTempTable ‘" + StartTime + "‘,‘" + StopTime + "‘";
            ds = DBServiceHelper.ExecuteDataSet(this.Context, sSQLWithNoTempTable);
            sSQL = string.Format(sSQL, this.KSQL_SEQ, tableName);
            DBUtils.Execute(this.Context, sSQL);
        }

        public override ReportTitles GetReportTitles(IRptParams filter)
        {
            ReportTitles titles = new ReportTitles();
            // 获取过滤条件
            DynamicObject customFil = filter.FilterParameter.CustomFilter;
            String StartTime = customFil["F_Dev_StartTime"].ToString();
            String StopTime = customFil["F_Dev_StopTime"].ToString();

            titles.AddTitle("FSTARTTIME", StartTime);
            titles.AddTitle("FSTOPTIME", StopTime);
            return titles;
        }
        /// <summary>
        /// 构建动态列
        /// </summary>
        /// <param name="filter"></param>
        /// <returns></returns>
        public override ReportHeader GetReportHeaders(IRptParams filter)
        {
            // TODO:fentryid,fid,fbaseunitqty,fmaterialid,fbomid,fqty
            ReportHeader header = new ReportHeader();
            //header.AddChild("fwname", new LocaleValue(Kingdee.BOS.Resource.ResManager.LoadKDString("物料", "002460030014689", Kingdee.BOS.Resource.SubSystemType.BOS), this.Context.UserLocale.LCID));
            //header.AddChild("fcustid", new LocaleValue(Kingdee.BOS.Resource.ResManager.LoadKDString("客户", "002460030014692", Kingdee.BOS.Resource.SubSystemType.BOS), this.Context.UserLocale.LCID));
            //header.AddChild("FQty", new LocaleValue(Kingdee.BOS.Resource.ResManager.LoadKDString("数量", "002460030014695", Kingdee.BOS.Resource.SubSystemType.BOS), this.Context.UserLocale.LCID), SqlStorageType.SqlDecimal);
            //header.AddChild("fprice", new LocaleValue(Kingdee.BOS.Resource.ResManager.LoadKDString("单价", "002460030014698", Kingdee.BOS.Resource.SubSystemType.BOS), this.Context.UserLocale.LCID), SqlStorageType.SqlDecimal);
            //header.AddChild("famount", new LocaleValue(Kingdee.BOS.Resource.ResManager.LoadKDString("金额", "002460030014701", Kingdee.BOS.Resource.SubSystemType.BOS), this.Context.UserLocale.LCID), SqlStorageType.SqlDecimal);
            header = this.GetHeaders(ds);
            return header;
        }

        public ReportHeader GetHeaders(DataSet ds)
        {
            ReportHeader header = new ReportHeader();
            int count = ds.Tables[0].Columns.Count;
            if (count > 0)
            {
                for (int i = 0; i < count; i++)
                {
                    header.AddChild(ds.Tables[0].Columns[i].ToString(), new LocaleValue(Kingdee.BOS.Resource.ResManager.LoadKDString(ds.Tables[0].Columns[i].ToString(), "002460030014689", Kingdee.BOS.Resource.SubSystemType.BOS), this.Context.UserLocale.LCID));
                }
            }
            return header;
        }
    }

}

 

以上是关于Cloud开发动态列的简单账表的主要内容,如果未能解决你的问题,请参考以下文章

若依vue实现动态表格,可动态控制列的显示隐藏及操作权限

具有动态列的表布局固定和整行 colspan

ireport 如何实现固定行、动态列的报表?

element-ui表格组件table实现列的动态显示与隐藏

动态列的水平总和

若依vue实现动态表格,可动态查询条件,控制列的显示隐藏及操作权限