单据转换.二开案例.选单界面 默认过滤方案设置
【场景】选单界面 默认过滤方案设置
目前系统不支持针对选单预设企业过滤方案
【原因】不同的业务对象,关联源单的实体不一样;
如采购订单,有些单据是跟明细关联,有些跟付款计划关联,不便于设置同一的选单过滤方案
【变通方案案例】
(a)针对选单对象,由管理员设置过滤方案,并共享给所有用户
![image.webp](/download/01007d464caa83de46bdaf4fe69f99ed4168.webp)
(b)准备表结构,存储源单、目标单、单据类型和预设方案id
```ksql
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_Custom_DrawDefaultScheme')
CREATE TABLE T_Custom_DrawDefaultScheme (
FID VARCHAR(36) NOT NULL,
FSrcFormId VARCHAR(36) DEFAULT ' ' NOT NULL,
FTgtFormId VARCHAR(36) DEFAULT ' ' NOT NULL,
FBillTypeId VARCHAR(36) DEFAULT ' ' NOT NULL,
FSchemeId VARCHAR(36) DEFAULT ' ' NOT NULL
);
EXEC P_ALTERPK 'PK_Custom_DrawDefaultScheme', 'T_Custom_DrawDefaultScheme', 'FID', '1'
IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_Custom_DrawDefaultScheme')
CREATE INDEX IDX_Custom_DrawDefaultScheme ON T_Custom_DrawDefaultScheme ( FSrcFormId, FTgtFormId, FBillTypeId);
```
(c)通过表单插件,干预单据转换界面BOS_ConvertOpForm,干预源单修改时的值更新,设置过滤方案的值
![image.webp](/download/01003c0bc388c85e41328fe73ff822a05744.webp)
```csharp
using Kingdee.BOS;
using Kingdee.BOS.Core.Bill;
using Kingdee.BOS.Core.DynamicForm;
using Kingdee.BOS.Core.DynamicForm.PlugIn;
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DynamicFormPlugIn.BillConvert
{
[Kingdee.BOS.Util.HotUpdate]
[System.ComponentModel.Description("选单界面, 过滤方案设置")]
public class FormPlugIn_DrawSetDefaultSchemePlugIn : AbstractDynamicFormPlugIn
{
/*
* 选单界面,根据源单、目标单、目标单据类型,自动跳转到设置的过滤方案上
*
* 表结构 ksql
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_Custom_DrawDefaultScheme')
CREATE TABLE T_Custom_DrawDefaultScheme (
FID VARCHAR(36) NOT NULL,
FSrcFormId VARCHAR(36) DEFAULT ' ' NOT NULL,
FTgtFormId VARCHAR(36) DEFAULT ' ' NOT NULL,
FBillTypeId VARCHAR(36) DEFAULT ' ' NOT NULL,
FSchemeId VARCHAR(36) DEFAULT ' ' NOT NULL
);
EXEC P_ALTERPK 'PK_Custom_DrawDefaultScheme', 'T_Custom_DrawDefaultScheme', 'FID', '1'
IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_Custom_DrawDefaultScheme')
CREATE INDEX IDX_Custom_DrawDefaultScheme ON T_Custom_DrawDefaultScheme ( FSrcFormId, FTgtFormId, FBillTypeId);
*
*/
private bool IsDraw = false;
private string BillTypeId = null;
private string TargetFormId = null;
/// <summary>
/// 初始化事件
/// </summary>
/// <param name="e"></param>
public override void OnInitialize(InitializeEventArgs e)
{
if (this.View.ParentFormView == null)
return;
var opNumber = this.View.OpenParameter.GetCustomParameter("OperationNumber");
if (opNumber != null && (FormOperationEnum)opNumber == FormOperationEnum.Draw)
{
IsDraw = true;
}
if (!IsDraw)
return;
var billModel = this.View.ParentFormView.Model as IBillModel;
if (billModel == null)
return;
TargetFormId = this.View.ParentFormView.BillBusinessInfo.GetForm().Id;
var billTypeField = this.View.ParentFormView.BillBusinessInfo.GetBillTypeField();
if (billTypeField == null)
return;
var billTypeObj = billModel.GetValue(billTypeField) as Kingdee.BOS.Orm.DataEntity.DynamicObject;
if (billTypeObj != null)
{
BillTypeId = Convert.ToString(billTypeObj[0]);
}
}
/// <summary>
/// 值更新事件
/// </summary>
/// <param name="e"></param>
public override void DataChanged(DataChangedEventArgs e)
{
if (string.Equals(e.Field.Key, "FrdBills", StringComparison.OrdinalIgnoreCase))
{
SetDefaultScheme();
}
}
/// <summary>
/// 加载默认方案
/// </summary>
private void SetDefaultScheme()
{
if (!IsDraw)
return;
var srcFormId = this.Model.GetValue("FrdBills");
StringBuilder strSql = new StringBuilder();
strSql.Append("SELECT FSchemeId FROM T_Custom_DrawDefaultScheme WHERE FSrcFormId = @FSrcFormId AND FTgtFormId = @FTgtFormId");
List<SqlParam> paramList = new List<SqlParam>();
paramList.Add(new SqlParam("@FSrcFormId", KDDbType.AnsiString, srcFormId));
paramList.Add(new SqlParam("@FTgtFormId", KDDbType.AnsiString, TargetFormId));
if (BillTypeId != null)
{
strSql.Append(" AND FBillTypeId = @FBillTypeId");
paramList.Add(new SqlParam("@FBillTypeId", KDDbType.AnsiString, BillTypeId));
}
string schemeId = null;
using (var dr = Kingdee.BOS.ServiceHelper.DBServiceHelper.ExecuteReader(this.Context, strSql.ToString(), paramList))
{
if (dr.Read())
{
schemeId = dr.GetString(0);
}
}
if (schemeId == null)
return;
this.View.Model.SetValue("FSchemeList", schemeId);
this.View.UpdateView("FSchemeList");
}
}
}
```
【效果】
(a)预插数据准备
```sql
--<0>准备sql
--单据类型
select lang.fname, billtype.* from t_bas_billtype billtype
left join t_bas_billtype_l lang on billtype.fbilltypeid = lang.fbilltypeid and lang.flocaleid = 2052
where fbillformid = 'PUR_PurchaseOrder'
--过滤方案,选单界面的过滤方案标识为 对象标识+_SelBill
select * from T_BAS_FILTERSCHEME where fformid = 'PUR_Requisition_SelBill'
--<1>预设选单默认方案,如有条件可以定义为表单进行修改
select * from T_Custom_DrawDefaultScheme;
--预设 源单:采购申请单, 目标单:采购订单, 单据类型:标准采购订单, 默认过滤:aaaaaaa
insert into T_Custom_DrawDefaultScheme values(newid(), 'PUR_Requisition','PUR_PurchaseOrder','83d822ca3e374b4ab01e5dd46a0062bd','644794ce05bdba');
--预设 源单:采购申请单, 目标单:采购订单, 单据类型:标准委外订单, 默认过滤:bbb
insert into T_Custom_DrawDefaultScheme values(newid(), 'PUR_Requisition','PUR_PurchaseOrder','6d01d059713d42a28bb976c90a121142','644794db05bdbc');
```
(b)选单时,当源单为采购申请,目标单为采购且单据类型为标准委外订单时,自动过滤方案为bbb
![image.webp](/download/01004053e8e983b140ba8e285601b8a6bc7a.webp)
单据转换.二开案例.选单界面 默认过滤方案设置
【场景】选单界面 默认过滤方案设置目前系统不支持针对选单预设企业过滤方案【原因】不同的业务对象,关联源单的实体不一样;如采购订单,...
点击下载文档
本文2024-09-16 18:22:12发表“云星空知识”栏目。
本文链接:https://wenku.my7c.com/article/kingdee-k3cloud-21692.html
您需要登录后才可以发表评论, 登录登录 或者 注册
最新文档
热门文章