套打.二开案例.针对部分单据选择模板界面强制单选
【场景】针对部分单据选择模板界面强制单选
【案例】指定单据,选择套打模板界面单选
(0)在选择套打模板界面增加表单插件
![image.webp](/download/01008677ce4102ed48d3a2696275fe5fb2bf.webp)
(1)c#
```csharp
using Kingdee.BOS.Core.DynamicForm.PlugIn;
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
using System;
using System.Linq;
namespace DynamicFormPlugIn.NotePrint
{
[Kingdee.BOS.Util.HotUpdate]
public class NotePrint_SelectTemplate : AbstractDynamicFormPlugIn
{
/*
* 控制某些表单套打选择模板,选择模板界面仅单选
*/
/// <summary>
/// 控制的表单列表
/// </summary>
private string[] controlFormIds = { "PUR_PurchaseOrder" };
private string Key_Entity = "FTemplateEntity";
private string Key_Check = "FCheckBox";
public override void OnInitialize(InitializeEventArgs e)
{
base.OnInitialize(e);
if (this.View.ParentFormView == null)
return;
var formid = this.View.ParentFormView.BillBusinessInfo.GetForm().Id;
bool val = controlFormIds.Contains(formid);
this.View.Session["Custom_OnlySingleSelect"] = val;
}
/// <summary>
/// 控制复选框不可使用
/// </summary>
/// <param name="e"></param>
public override void AfterBindData(EventArgs e)
{
bool val = (bool)this.View.Session["Custom_OnlySingleSelect"];
if(val == true)
{
this.View.GetControl(Key_Entity).Enabled = !val;
this.View.UpdateView(Key_Entity);
}
}
/// <summary>
/// 选中行自动选中
/// </summary>
/// <param name="e"></param>
public override void EntityRowClick(EntityRowClickEventArgs e)
{
if ((bool)this.View.Session["Custom_OnlySingleSelect"] == false)
return;
if (!string.Equals(Key_Entity, e.Key, StringComparison.OrdinalIgnoreCase))
return;
int rowIdx = e.Row;
var entity = this.View.BillBusinessInfo.GetEntity(Key_Entity);
var newRow = this.View.Model.GetEntityDataObject(entity, rowIdx);
if ((bool)newRow[Key_Check] == true)
return;
newRow[Key_Check] = true;
this.View.UpdateView(Key_Check, rowIdx);
var entityDataObjs = this.View.Model.GetEntityDataObject(entity);
for (int i = 0; i < entityDataObjs.Count; ++i)
{
var rowObj = entityDataObjs[i];
if (i == rowIdx)
{
continue;
}
if ((bool)rowObj[Key_Check] == true)
{
rowObj[Key_Check] = false;
this.View.UpdateView(Key_Check, i);
//break;
}
}
}
}
}
```
(2)python
```python
#引入clr运行库
import clr
#添加对cloud插件开发的常用组件的引用
clr.AddReference("mscorlib")
clr.AddReference("Kingdee.BOS")
clr.AddReference("Kingdee.BOS.ServiceHelper")
clr.AddReference("Kingdee.BOS.Core")
#导入cloud基础库中的常用实体对象(分命名空间导入,不会递归导入)
from System import *
from System.Collections.Generic import *
from Kingdee.BOS.Util import *
from Kingdee.BOS.JSON import *
def OnInitialize(e):
##使用单选的表单id
formIds = {"PUR_PurchaseOrder"};
if this.View.ParentFormView == None:
return;
formid = this.View.ParentFormView.BillBusinessInfo.GetForm().Id;
this.View.Session["Custom_OnlySingleSelect"] = (formid in formIds);
def AfterBindData(e):
if this.View.Session["Custom_OnlySingleSelect"] == True:
Key_Entity = "FTemplateEntity";
this.View.GetControl(Key_Entity).Enabled = False;
this.View.UpdateView(Key_Entity);
def EntityRowClick(e):
if this.View.Session["Custom_OnlySingleSelect"] == False:
return;
if not e.Key.Equals("FTEMPLATEENTITY",StringComparison.OrdinalIgnoreCase):
return;
checkKey = "FCheckBox";
entity = this.View.BillBusinessInfo.GetEntity("FTemplateEntity");
newRow = this.View.Model.GetEntityDataObject(entity, e.Row);
if newRow[checkKey] == True:
return;
newRow[checkKey] = True;
this.View.UpdateView(checkKey, e.Row);
entityDataObjs = this.View.Model.GetEntityDataObject(entity);
for index in range(len(entityDataObjs)):
if index == e.Row:
continue;
rowObj = entityDataObjs[index];
if rowObj[checkKey] == True:
rowObj[checkKey] = False;
this.View.UpdateView(checkKey, index);
break;
```
【效果】
![动画10.webp](/download/010034dec7f5f3104b2693b8a42d0619a35a.webp)
套打.二开案例.针对部分单据选择模板界面强制单选
【场景】针对部分单据选择模板界面强制单选【案例】指定单据,选择套打模板界面单选(0)在选择套打模板界面增加表单插件![image.webp](/down...
点击下载文档
本文2024-09-16 18:19:21发表“云星空知识”栏目。
本文链接:https://wenku.my7c.com/article/kingdee-k3cloud-21392.html
您需要登录后才可以发表评论, 登录登录 或者 注册
最新文档
热门文章