【套打】不弹出套打导出界面,自动设置为按预览分页导出PDF原创
金蝶云社区-_Tmp
_Tmp
30人赞赏了该文章 2078次浏览 未经作者许可,禁止转载编辑于2020年12月23日 11:46:50

<0>场景:不弹出套打导出界面,自动设置为按预览分页导出PDF


<1>方案:套打导出选择界面加表单插件,实现自动关闭和数据返回到父视图逻辑


<2>示例,采购订单套打导出,不弹出套打导出界面,自动设置为按预览分页导出PDF

表单标识:套打导出设置

BOS_SELECTEXPORTFORMATE

image.png

插件

image.png

代码:

using System;

using System.ComponentModel;

using Kingdee.BOS.Core.DynamicForm.PlugIn;

using Kingdee.BOS.JSON;

using Kingdee.BOS.Util;

using System.Web;

using Kingdee.BOS.Core;


namespace NotePrintPlugin.Sample

{

    [Kingdee.BOS.Util.HotUpdate]

    [Description("自动关闭套打导出类型选择界面")]

    public class AutoClosePrintExportTypeSample : AbstractDynamicFormPlugIn

    {

        public override void BeforeBindData(EventArgs e)

        {

            base.BeforeBindData(e);

            if (this.View.ParentFormView != null &&

                this.View.ParentFormView.BillBusinessInfo.GetForm().Id.EqualsIgnoreCase("PUR_PurchaseOrder"))

            {

                string fileType = Kingdee.BOS.Core.NotePrint.ExportFileType.PDF.ToString();


                string serverPath = "~" + PathUtils.GetServerPath(KeyConst.TEMPFILEPATH);

                string dictionary = HttpContext.Current.Server.MapPath(serverPath);

                string fileName = string.Format("{0}_{1}_{2}",

                    Kingdee.BOS.Resource.ResManager.LoadKDString("套打", "002012030025359",

                        Kingdee.BOS.Resource.SubSystemType.BOS),

                    this.View.ParentFormView.BillBusinessInfo.GetForm().Name.ToString().Replace("+", string.Empty),

                    DateTime.Now.ToString("yyyyMMddHHmmssff"));

                fileName = fileName + "." + fileType;

                fileName = PathUtils.GetValidFileName(fileName);


                //下载时的路径,需要encode

                string outServerPath = PathUtils.GetServerPath(KeyConst.TEMPFILEPATH, PathUtils.UrlEncode(fileName));

                string filePath = PathUtils.GetPhysicalPath(KeyConst.TEMPFILEPATH, fileName);


                JSONObject jo = new JSONObject();

                //文件类型

                jo.Add("fileType", fileType);

                //导出方式

                jo.Add("exportType", (int) Kingdee.BOS.Core.NotePrint.ExportType.ByPage);

                jo.Add("directioy", dictionary);

                jo.Add("outServerPath", outServerPath);

                jo.Add("filePath", filePath);


                this.View.ReturnToParentWindow(jo);

                this.View.Close();

            }

        }

    }

}


赞 30