如何父窗口向子窗口传递参数
showParameter.CustomParams.Add("参数名",value);
如何在子窗口接收父窗口参数
1.View.ParentFormView.OpenParameter.GetCustomParameter("参数名");
2.e.Paramter.GetCustomParameter("参数名"); //在OnInitialize事件中获取参数
如何在父窗口接收子窗口的返回参数
//子窗口插件
public override void BeforeClosed(BeforeClosedEventArgs e)
{
base.BeforeClosed(e);
this.View.ReturnToParentWindow(new FormResult("返回参数"));
}
//父窗口插件
this.View.ShowForm(showParameter,(FormResult frt)=>{
var value = frt.ReturnData;
});
如何关闭打开的视图
IDynamicFormView myView = View.GetView("parameter的PageId");
if (myView != null)
{
myView.Close();
View.SendDynamicFormAction(myView);
}
1.应用场景:移动单据列表单击弹出移动表单
if(ListView.CurrentSelectedRowInfo != null && ListView.CurrentSelectedRowInfo.PrimaryKeyValue != null){
MobileShowParameter showParameter = new MobileShowParameter();
showParameter.FormId = "移动表单标识";
showParameter.PKey = ListView.CurrentSelectedRowInfo.PrimaryKeyValue;
showParameter.ParentPageId = this.View.PageId;
this.View.ShowForm(showParameter,(res)=>{
View.Refresh();
});
}
2.应用场景:PC单据弹窗
private void ShowBill(string formId,string billNo){
//根据单据编号到数据库中读取单据内码
QueryBuilderParemeter queryParam = new QueryBuilderParemeter();
queryParam.FormId = formId;
queryParam.SelectItems.Add(new SelectorItemInfo("FID"));
queryParam.FilterClauseWihtKey = $" FBILLNO = '{billNo}' ";
var objs = QueryServiceHelper.GetDynamicObjectCollection(this.Context, queryParam);
if (objs != null && objs.Count > 0)
{
long billId = Convert.ToInt64(objs[0][0]);
BillShowParameter parameter = new BillShowParameter();
parameter.FormId = formId;//必填
parameter.Status = OperationStatus.VIEW;//必填。设置打开单据的状态,比如查看、修改。
parameter.PKey = billId.ToString();//如果不是新增状态,为必填。
parameter.CustomParams.Add("参数名",value);//传参
View.ShowForm(parameter);
}
}
3.应用场景:PC列表弹窗
private void ShowList(string formId,string containerKey){
ListShowParameter parameter = new ListShowParameter();
parameter.FormId = formId;//必填
parameter.OpenStyle.ShowType = ShowType.Modal;//打开方式 Modal[新窗口打开,不需要容器key];InContainer[容器中打开,需要传入容器key];NewTabPage[页签中打开,需要传入页签key]
parameter.OpenStyle.TagetKey = containerKey;//需要显示列表的容器标识:面板、页签
parameter.ListFilterParameter.Filter = "FID = 123";//过滤参数
parameter.Width = 800;
parameter.Height = 600;
//HOffset和VOffset设置显示位置
parameter.PageId = Guid.NewGuid().ToString();
parameter.IsLookUp= false;//是否显示快速过滤
parameter.MultiSelect = false;
parameter.PermissionItemId = Kingdee.BOS.Core.Permission.PermissionConst.View;//控制查看权限
parameter.IsShowQuickFilter = false;//是否显示过滤
View.ShowForm(parameter);
}
4.应用场景:弹出第三方网页
//PC端
JSONObject webobj = new JSONObject();
webobj["source"] = @"https://www.baidu.com";
webobj["height"] = 768;
webobj["width"] = 810;
webobj["isweb"] = false;
webobj["title"] = "百度一下";
this.View.AddAction("ShowKDWebbrowseForm", webobj);
this.View.SendDynamicFormAction(this.View);
//移动端
JSONArray paras = new JSONArray();
JSONObject webobj = new JSONObject();
webobj["url"] = "https://www.baidu.com";
webobj["title"] = "百度一下";
paras.Add(webobj);
this.View.AddAction("openUrlWindow", paras);
5.应用场景:批量提示
IOperationResult opResult = new OperationResult();
opResult.OperateResult.Add(new OperateResult{
Message = "错误原因",
Name = "执行操作/关键字段",
MessageType = MessageType.Normal,
SuccessStatus = false
});
this.View.ShowOperateResult(opResult.OperateResult);
6.应用场景:普通提示
this.View.showMessage("这是绿框提示!");
this.View.showWarnningMessage("这是黄框警示!");
this.View.showErrMessage("这是红框警告!");
this.View.showMessage("是否选项",MessageBoxOptions.YesNo,(res)=>{
if(res == MessageBoxResult.Yes){
View.showMessage("你选了是!");
}
else if(res == MessageBoxResult.No){
View.showMessage("你选了否!");
}
},"标题");