苍穹代码笔记

文章目录

一、弹窗操作

1、获取父页面的视图和模型
IFormView parentView = this.getView().getParentView();
IDataModel parentModel = parentView.getModel();
2、父页面给子页面传值
1、FormShowParameter
--父页面
FormShowParameter formShowParameter = this.getView().getFormShowParameter();
formShowParameter.setCustomParam("你要传过去的标识","你要传过去的内容")
--子页面
FormShowParameter formShowParameter = this.getView().getFormShowParameter();
formShowParameter.getCustomParam("你传过来的标识")

2、把数据放在缓存中
--父页面
this.getView.getPageCache.put("放在缓存的key值","放在缓存的value值");
--子页面
IFormView parentView = this.getView().getParentView();//通过父类的view获取父类的缓存
IPageCache pageCache = parentView.getPageCache();
pageCache.get("放在缓存的key值");
3、给点击事件新增弹窗
1、
2、新增弹窗
 //创建弹出页面对象,FormShowParameter表示弹出页面为动态表单
FormShowParameter ShowParameter = new FormShowParameter();
//设置弹出页面的编码
ShowParameter.setFormId(KEY_POP_FORM);
//设置弹出页面标题
ShowParameter.setCaption("您的请假天数大于3天,请填写工作交接安排说明");
//设置页面关闭回调方法
//CloseCallBack参数:回调插件,回调标识
ShowParameter.setCloseCallBack(new CloseCallBack(this, KEY_LEAVE_DAYS));
//设置弹出页面打开方式,支持模态,新标签等
ShowParameter.getOpenStyle().setShowType(ShowType.Modal);
//弹出页面对象赋值给父页面
 this.getView().showForm(ShowParameter);

// 1、显示表单界面
// FormShowParameter formShowParameter = new FormShowParameter();
// //显示样式(内嵌)
// formShowParameter.getOpenStyle().setShowType(ShowType.InContainer);
// //将页面嵌入哪个容器,容器标识
// formShowParameter.getOpenStyle().setTargetKey(targetKey);

4、从子页面中对父页面操作
1、获取父页面的视图和模型
IFormView parentView = this.getView().getParentView();
IDataModel parentModel = parentView.getModel();
2、操作代码
。。。。。。
例:parentModel.setVisible(false,"需要隐藏的控件");
3、将上述操作的修改完的内容发送给父页面
this.getView().sendFormAction(parentView);
5、弹窗回调事件
 /**
  * 页面关闭回调事件
  * @param closedCallBackEvent
  */
  @Override
public void closedCallBack(ClosedCallBackEvent closedCallBackEvent) {
    super.closedCallBack(closedCallBackEvent);
    //判断标识是否匹配,并验证返回值不为空,不验证返回值可能会报空指针
    if (StringUtils.equals(closedCallBackEvent.getActionId(), KEY_LEAVE_DAYS) && null != closedCallBackEvent.getReturnData()) {
        //这里返回对象为Object,可强转成相应的其他类型,
        // 单条数据可用String类型传输,返回多条数据可放入map中,也可使用json等方式传输
        HashMap<String, String> returnData = (HashMap<String, String>) closedCallBackEvent.getReturnData();
        this.getModel().setValue(KEY_WORK_ARRANGE, returnData.get(KEY_WORK_ARRANGE));
        this.getModel().setValue(KEY_REMARK, returnData.get(KEY_REMARK));
    }
}
6、获取父页面的标识符
FormShowParameter formShowParameter = this.getView().getFormShowParameter();
String formId = formShowParameter.getParentFormId();
7、确定消息弹窗 - showConfirm
该事件我目前只在表单中操作,其他的可以尝试
一、
1、触发事件代码
this.getView().showConfirm("提示消息内容",MessageBoxOptions.YesNo(弹窗下按钮数量),new ConfirmCallBackListener("callBackId"(唯一标识)));
2、弹窗操作
@Override
public void confirmCallBack(MessageBoxClosedEvent evt){
		super.confirmCallBack(evt);
		String callBackId = evt.getCallBackId();
		if("callBackId"(这个标识符和上面的唯一标识为同一个).equals(callBackId)){
		    if(MessageBoxResult.Yes.equals(evt.getResult())){
				//操作为Yes的操作代码
		    }else if(MessageBoxResult.No.equals(evt.getResult())){
				//操作为NO的操作代码 - 目前我知道的是点击弹窗右上角执行的也是这个
		    }
		}
}
二、
1、触发事件代码
this.getView().showConfirm("提示消息内容",MessageBoxOptions.YesNo(弹窗下按钮数量),confirmCallBackListener);
2、弹窗操作
@Override
public void confirmCallBack(MessageBoxClosedEvent evt){
		super.confirmCallBack(evt);
		if(MessageBox.Yes.equals(evt.getResult())){
				//操作为Yes的操作代码
		}else if(MessageBox.No.equals(evt.getResult())){
				//操作为NO的操作代码 - 目前我知道的是点击弹窗右上角执行的也是这个
		}
}
8、查看弹窗页面来源页面

具体操作(图文)

1、在可触发弹出弹窗的页面上右键,选择点击检查
2、选择Network选项卡
3、触发弹出弹窗事件
4、点击所有请求,打开详细
5、选择请求头,找到第一个General
6、对于苍穹来说请求参数f为请求单据。
7、一般来说,Name中最后一个请求的参数f为最终弹出窗标识
9、打开某个单据的一条数据的详情
//创建单据弹窗
BillShowParameter billShowParameter = new BillShowParameter();
//设置弹出页面的标识符
billShowParameter.setFormId("子单据标识符");
//设置需要被弹出的页面中数据的PKID
billShowParameter.setPkId("需要被展示的数据id");
//设置弹窗标题
billShowParameter.setCaption("标题");
//设置弹出窗页面的打开方式,支持模块、新标签等
billShowParameter.getOpenStyle().setShowType(ShowType.Model);
//设置弹出窗页面样式
StyleCss styleCss = new StyleCss();
styleCss.setHeight("600");
styleCss .setWidth("800");
billShowParameter.getOpenStyle().setInlineStyleCss(styleCss );
//弹出页面对象赋值给父页面
this.getView().showForm(billShowParameter);
10、查询弹窗点击事件来源
找到kd.bos.mvc.form.FormView 类
找到showForm方法,在第一行打断点,运行弹窗,查看堆栈
11、滑动弹窗
/**
  * 打开滑动动态表单,从页面左边出来
  * @param view 页面视图
  * @param paramObj 需要传给弹窗的参数
  * @param cacheKey 需要传给弹窗的缓存key值
  * @param cacheMapKey 需要传给弹窗的缓存中的key值
  * @param formId 需要打开的动态表单
  */
public static void showCustomerInfo(IFormView view,Object paramObj,String cacheKey,String cacheMapKey,String formId){
        RequestContext requestContext = RequestContext.get();
        String globalSessionId = requestContext.getGlobalSessionId();
        Map<String,Object> map = new HashMap<>();
        map.put("paramObj", paramObj);
        Banana<Map<String,Object>, Integer> param = new Banana<>();
        param.setItem1(map);
        AppCacheFactory.get(cacheKey).put(cacheMapKey, globalSessionId, param, 15 * 1000);

        IClientViewProxy proxy = (IClientViewProxy) view.getService(IClientViewProxy.class);
        HashMap<String,Object> o = new HashMap<>(1);
        o.put("formId", formId);
        proxy.addAction(ClientActions.setSlideBillFormId,o);
        proxy.addAction(ClientActions.showSlideBill, o);
    }
12、父页面获取子页面的数据
//1、子页面 - 将自己的pageid通过缓存的方式放在父页面中
this.getView().getParentView().getPageCache().put("childPageId",getView().getPageId());

//2、父页面 - 根据子页面的pageid获取子页面的iformview
IFormView childView = this.getView().getView(this.getView().getPageCache().get(childPageId));

二、单据体操作

1、给单据体的某个单元格赋值
this.getModel().setValue("单元格标识符",设置的内容,行数);
2、获取选中行
int[] selectRows = ((EntryGrid)this.getControl("单据体标识符")).getSelectRows();
3、新增行
int newRowIndex = this.getModel().createNewEntryRow("单据体标识符");
4、设置冻结列
EntryGrid entry = getView().getControl("单据体标识");   
Optional.ofNullable(entry).ifPresent(e -> {                
         e.setColumnProperty("列1", ClientProperties.IsFixed, true);  
         e.setColumnProperty("列2", ClientProperties.IsFixed, true);
});

效果图:
原:
|列1|列2|列3|列4|列5|列6|列7|列8|列9|
|数1|数2|数3|数4|数5|数6|数7|数8|数9|
|数1|数2|数3|数4|数5|数6|数7|数8|数9|
冻结:(列1和列2被冻结,不能动,其他的列可拖动)
{|列1|列2|}    列3|列4|列5|列6|列7|列8|列9|
{|数1|数2|}    数3|数4|数5|数6|数7|数8|数9|
{|数1|数2|}    数3|数4|数5|数6|数7|数8|数9|
5、超链接点击(以单据体超链接为例)
public class HyperLinkPlugin extends AbstractBillPlugin implements HyperLinkClickListener(){
	@Override
	public void registerListener(EventObject e){
		super.registerListener(e);
		//单据体超链接
		BillList billlistap = this.getView().getControl("单据体标识符");
		billlistap.addHyperClickListener(this);
	}
	@Override
	public void hyperLinkClick(HyperLinkClickEvent evt){
		String fieldName = evt.getFieldName();
		if("单据体标识符".equals(fieldName )){
			int rowIndex = evt.getRowIndex();//获取选中行
		}
	}
}
6、取消单据体选中行
((BillView)this.getView()).getClientProxy().invokeControlMethod("单据体标识符","clearSelRows");//后面clearSelRows为固定写法,取消所有选中行
7、清空单据体
this.getModel().deleteEntryData("单据体标识符")
8、子单据体获取父单据体的数据
DynamicObjectCollection collection = this.getModel().getValue("单据体标识符");//获取表单上正在展示的子单据体数据
DynamicObject parentDynamicObject = collection.getParent();//获取到的父类数据

三、多选基础资料

1、通过基础资料id查询单据id
QFilter qfilter = new QFilter("单据下的多选基础资料标识符.fbasedataid.id",QCP.equals,基础资料id);
DynamicObjectCollection collection = 
	QueryServiceHelper.query("单据标识符",
	"id,单据下的多选基础资料标识符,单据下的多选基础资料标识符.fbasedataid,单据下的多选基础资料标识符.fbasedataid.id",
	new QFilter[]{qfilter});
long id = collection.getLong("id");
2、

四、表单操作

1、隐藏、锁定控件和控件的必录
1、隐藏、锁定控件
IFormView view = this.getView();
view.setVisible(false,"需要隐藏的控件标识符");//false - 隐藏 true - 关闭隐藏
view.setVisible(false,"需要隐藏的控件标识符","需要隐藏的控件标识符2");//false - 隐藏 true - 关闭隐藏
view.setEnable(false,"需要锁定的控件标识符");//false - 关闭锁定
view.setEnable(false,"需要锁定的控件标识符","需要锁定的控件标识符2");//false - 锁定 true - 关闭锁定

2、控件的必录
控件的必录目前知道的是字段、单据体等可以设置
    1.获取控件的视图模型
FieldGrid fieldGrid = this.getView().getControl("字段的标识符");
EntryGrid entryGrid = this.getView().getControl("单据的标识符");
...Grid ...Grid = this.getView().getControl("其它类型的标识符");

fieldGrid.setMustInput(true);//设置字段的必录
fieldGrid.setMustInput(false);//取消字段的必录
entryGrid.setMustInput("单据字段的标识符",true);//设置单据的必录
entryGrid.setMustInput("单据字段的标识符",false);//取消单据的必录
...Grid.setMustInput(true);//设置其他类型的必录 - 根据具体设置
...Gridt.setMustInput(false);//取消其他类型的必录 - 根据具体设置
2、获取当前登入人 - 信息
long userId = UserServiceHelper.getCurrentUserId();
2、获取当前登入人公司
UserServiceHelper.getUserMainOrgId(userId)
3、获取当前登入人部门
@SuppressWarnings("deprecation")
Map<String, Object> mapOrg = OrgServiceHelper.getCompanyfromOrg(Long.valueOf(UserServiceHelper.getUserMainOrgId(userId)));
3、给标签赋值
Label label = this.getView().getControl("标签的标识符");
label.setText("要设置的值");
4、从应用的页面跳转到开发者门户的开发页面
ctrl + Alt + G
5、代码调用前端页面操作
OperationResult operationResult = this.getView().invokeOperation("需要调用的操作,比如submit");
//调用指定单据的操作
 OperationServiceHelper.executeOperate("pushandsave_probation_control", "ynzy_rzfwtemplate", rzfwObjectArr, OperateOption.create());
6、苍穹判断字符为空
import kd.bos.dataentity.utils.StringUtils;
StringUtils.isNotBlack("需要判断的字符串");
7、返回错误信息和返回信息
this.getView().showErrorNotification("错误信息");
this.getView().showSuccessNotification("成功信息");
8、设置日期范围控件的最大最小值
DateRangeEdit headFieldEdit = this.getView().getControl("日期控件标识"); 
1、最小值
headFieldEdit.setMinDate(new Date());
2、最大值
headFieldEdit.setMaxDate(new Date());
9、F7过滤点击事件
1、实现监听类
implements BeforeF7SelectListener
2、添加监听事件
BasedataEdit basedataEdit = this.getView().getControl("需要过滤的控件");
basedataEdit.addBeforeF7SelectListener(this);
3、判断当前操作是否为当前控件
FormOperate formOperate = (FormOperate) args.getSource();
String operateKey = formOperate.getOperateKey();
4、给过滤添加过滤条件
QFilter qFilter = new QFilter(过滤条件);
//设置列表过滤条件
ListShowParameter showParameter=(ListShowParameter)evt.getFormShowParameter();
showParameter.getListFilterParameter().setFilter(qFilter);
10、设置徽标
1、获取设置徽标的控件 - 这里是列表上的按钮,使用的标识符为toolbarap
Toolbar toolbar = this.getView().getControl("toolbarap");
2、设置徽标格式,具体的到社区搜索徽标
toolbar.setBadgeInfo(USER_LIST_TBMAIN_DIS_BEGIN, getBadgeInfo());
3、徽标设置
    private BadgeInfo getBadgeInfo () {
        BadgeInfo badgeInfo = new BadgeInfo();
        badgeInfo.setCount(1);//设置数量
        return badgeInfo;
    }
11、判断用户是否为车间责任人
public Boolean isIncharge () {
        //获取当前操作人
        long userId = UserServiceHelper.getCurrentUserId();
        List<Long> userIds = new ArrayList<>();
        userIds.add(userId);
        List<Map<String, Object>> list = UserServiceHelper.get(userIds);
        Map<String, Object> userEntity = list.get(0);
        List<Map<String, Object>> posList = (List<Map<String, Object>>) userEntity.get("entryentity");
        boolean isincharge = (boolean) posList.get(0).get("isincharge"); // 是否为负责人
        return isincharge;
    }
12、循环 iterator
Iterator<String> it=map.iterator();
while(it.hasNext()) {
	String key = it.next();
	System.out.println("key="+key+",value="+setting.get(key));
}
13、设置颜色
@Override
    public void afterBindData(EventObject e) {
        super.afterBindData(e);
        HashMap<String, Object> item = new HashMap<>();
        HashMap<String, Object> map = new HashMap<>();
        if (this.getModel().getValue("billstatus") != null) {
            if (this.getModel().getValue("billstatus").equals("A")) {
                map.put(ClientProperties.ForeColor, "yellow");
            } else if (this.getModel().getValue("billstatus").equals("B")) {
                map.put(ClientProperties.ForeColor, "blue");
            } else if (this.getModel().getValue("billstatus").equals("C")) {
                map.put(ClientProperties.ForeColor, "orange");
            } else if (this.getModel().getValue("billstatus").equals("D")) {
                map.put(ClientProperties.ForeColor, "pink");
            } else if (this.getModel().getValue("billstatus").equals("E")) {
                map.put(ClientProperties.ForeColor, "grey");
            } else if (this.getModel().getValue("billstatus").equals("F")) {
                map.put(ClientProperties.ForeColor, "red");
            } else {
                map.put(ClientProperties.ForeColor, "#fffff");
            }
            item.put("item", map);
            this.getView().updateControlMetadata("billstatus", item);
        }
    }
14、BigDecimal值比较
1、判断正负数
int r=amount1.compareTo(BigDecimal.ZERO);
if(r < 0){//为负,amount1 < 0}
2、BigDecimal比较大小
int r=amount1.compareTo(amount2);
if(r < 0){//为负,amount1 < amount2}
else if(r = 0){//为负,amount1 = amount2}
else if(r > 0){//为负,amount1 > amount2}
15、刷新界面
this.getView().updateView();
16、应用首页设置

具体操作(图文)

首页样式:左树右界面 (左边为各个单据的超链接,右边为点击超链接后的详情界面)
1、添加左树单据超链接(在应用首页添加单据的超链接)
	1.打开开发者平台云的界面,找到需要设置的应用,点击应用下的三行
	2.打开界面之后选择新增
	3.设置需要展示在应用上的具体详情
2、添加首页右边默认页面
	具体目标设置
	1.设置卡片内容 - 新增应用首页页面 - 蓝色的控件为栅格容器
	2.点击添加
	3.点击齿轮设置展示的界面(值为界面的标识符)
17、获取当前页面的FormId
String entityId = this.getView().getEntityId();
18、设置值时防止触发值更新事件
this.getModel().beginInit();
this.getModel().setValue("需要设置的字段",设置的值);
this.getView().updateView("需要设置的字段");
this.getModel().endInit();
19、表单编码规则
//创建新的付款申请单类型的对象
DynamicObject dynamicObject = BusinessDataServiceHelper.newDynamicObject("单据标识符");
//设置单据编号,获取编码规则生成的编码
String finappbill = CodeRuleServiceHelper.getNumber("单据标识符",dynamicObject ,null);
dynamicObject .set("billno",finappbill );
20、系统参数获取
ErCommonUtils.getEMParameter( )
21、
[列表笔记](https://club.kdcloud.com/knowledge/specialDetail/218022218066869248?category=304943845760755712&id=303910298371494144&productLineId=29)
22、引入数据干预操作
https://developer.kingdee.com/article/235459954822682112?productLineId=29&isKnowledge=2
23、
24、

五、列表操作

1、刷新列表
((IListView) this.getView()).refresh();
2、列表自定义过滤(一打开列表就是自己想看到的数据)
public class ListPlugin extends AbstractListPlugin(){
    @Override
    public void setFilter(SetFilterEvent e){
    	List<QFilter> qFilters = e.getQFilters();//获取列表原来的过滤分案
    	//创建新的过滤
        //写法一(单条件):Qfilter qfilter = new Qfilter(条件);
        //写法二(多条件 - 两个条件互不影响):Qfilter qfilter = new Qfilter(条件).or(第二个条件);
        //写法三(多条件 - 两个条件互相影响(未测试)):Qfilter qfilter = new Qfilter(条件).and(第二个条件);
        qFilters.add(qfilter);//把自定义的过滤条件加入列表的过滤方案之中
    }
}
3、列表代码设置选中行
//列表控件,或者单据列表 
BillList list = (BillList) evt.getSource();
BillList list = this.getView().getControl("kded_billlistap");//构造
listListSelectedRowCollection test = new ListSelectedRowCollection();//放置需要选中的数据fid,fid为单据的fid
ListSelectedRow row1 = new ListSelectedRow("870199265954115584");
test.add(row1);
//设置选中
list.putSelectedRows(test);
//刷新列表
list.refresh();
this.getView().updateView();
4、列表代码获取选中行以及选中行数据
BillList billList = this.getControl("billlistap");//列表的统一标识符为billlistap
ListSelectRowCollection selectedRows = billList.getSelectedRows();//获取选中行
Object[] primaryKeyValues = selectedRows.getPrimaryKeyValues();//获取选中行的在数据库中的id
1、选单行:QFilter qFilter = new QFilter("id",QCP.equals,primaryKeyValues[0]);
2、选多行:QFilter qFilter = new QFilter("id",QCP.in,primaryKeyValues);
DynamicObject[] load = BusinessDataServiceHelper.load("当前表单的标识符","需要查询的字段",new QFilter[](qFilter ));//获取选中行单据数据
5、列表监听工具栏代码
@Override
public void registerListener(EventObject e){
	this.addItemClickListeners("toolbarap");
}
6、列表操作列操作
https://vip.kingdee.com/article/344790618524508416?productLineId=29

六、工作流

1、当前审批人
1、列表插件中引入工作流插件
    public void beforeCreateListDataProvider(BeforeCreateListDataProviderArgs args) {
        //获取当前工作流审核人
        args.setListDataProvider(new UserApplyWorkFlowPlugin());
    }
2、工作流插件
public class UserApplyWorkFlowPlugin extends ListDataProvider {
	//当前审批人在列表上的字段
    private String USER_APPLY_NEXTOR = DisEnum.KEY_USER_APPLY_NEXTOR.getName();
    /*加载数据列表*/
    @Override
    public DynamicObjectCollection getData(int start, int limit) {
        DynamicObjectCollection rows = super.getData(start, limit);
        if (rows.isEmpty()){return rows;}
        if (!rows.get(0).getDataEntityType().getProperties().containsKey(USER_APPLY_NEXTOR)) {
            //无列,无需处理
            return rows;
        }
        for (DynamicObject row:rows){
            Map<String, List<BizProcessStatus>> map = WorkflowServiceHelper.getBizProcessStatus(new String[]{row.get("id").toString()});
            List<BizProcessStatus> value = map.get(row.get("id").toString());
            if (value != null && value.size() > 0){
                BizProcessStatus biz = value.get(0);
                if (biz.getParticipantName()!= null){
                    row.set(USER_APPLY_NEXTOR,biz.getCurrentNodeName() + "|" + biz.getParticipantName());
                }
            }
        }
        return rows;
    }
}
2、

七、金蝶页面控件业务以及样式配置

1、整数控件
1、正整数配置:
        数值范围    [0,]
(推测(仅限猜测,没有测试):
		[] 中括号为等于   () 小括号为小于或者等于   内容为最大值,最小值   当内容为空白时,为无穷
举例:
		[0,]	---	大于可等于0,小于可等于无穷
		[,0]	---	大于可等于无穷,小于可等于0
		[2,10]	---	大于可等于2,小于可等于10
		[2.0,10.0]	---	(非整数)大于可等于2的所有数,小于可等于10的所有数
)
2、

八、基础资料

1、给基础资料赋值
1、PC端(如果id赋值不了,一定要使用DynamicObject类型!!!)
this.getModel().setValue("基础资料标识符","动态实体的id(Long类型)");
2、移动端
this.getModel().setValue("基础资料标识符","动态实体(DynamicObject类型)");
2、基础资料根据组织进行管控
BaseDataServiceHelper.getBaseDataFilter(formId,orgId)

3、当前创建组织为管控组织才允许添加数据
/* 1、当前创建组织为管控组织才允许添加数据 */
                //Long ctrlUnitByOrgId = OrgServiceHelper.getCtrlUnitByOrgId(BaseDataConstants.MASTER_DATA_CONTROL_VIEW, orgId);
                /* 2、判断当前创建组织为管控组织 */
                BaseDataServiceHelper.getBaseDataIdInFilter(formId,orgId);

九、操作代码

1、在表单操作中注册的插件校验,在表单插件中处理
1、注册至操作代码中
@Override
public void beforeExecuteOperationTransaction(BeforeOperationArgs e){
    this.operationResult.addErrorInfo();//添加数据
}

2、注册至表单中的插件
@Override
public void afterDoOperation(AfterDoOperationEventArgs args){
	super.afterDoOperation(args);
	OperationResult operationResult = args.getOperationResult();//获取来自操作的数据
}
2、操作代码中获取操作入口
String name = e.getDataEntities()[0].getDataEntityType().getName();
3、操作校验
1、使用方法:
@Override
public void onAddValidators(AddValidatorsEventArgs e){
	e.addValidator(new AbstractValidator(){
		@Override
		public void validate(){
			ExtendedDataEntity[] dataEntities = this.getDataEntities();
			for(ExtendedDataEntity dataEntity : dataEntities){
				//TODO 校验代码 ,可以使用this.addErrorMessage(dataEntity ,"报错信息")取消操作
			}
		}
	});
}

2、扩展
在校验过程中,表单的
ExtendedDataEntity[] dataEntities = this.getDataEntities();
可以获取整张单据的所有数据,但是在列表进行操作的时候,该代码只能获取到billno和另外一个(忘记了)两个字段的数值,所以在校验的时候需要添加需要的字段,该代码才会从数据库中带出
	2.1  具体操作:
		@Override
		public void onPreparePropertys(PreparePropertysEventArgs e){
			List<String> fieldKeys = e.getFieldKeys();
			fieldKeys .add("字段名");
		}
	2.2  举例
		原:dataEntities : 单据标识符["billno,另外一个字段"]["billno的数值","另外一个字段的数值"]
		添加字段后:dataEntities : 单据标识符["billno,另外一个字段,添加的字段"]["billno的数值","另外一个字段的数值","添加的字段的值(从数据库中查询过来的)"]

4、

十、下推

1、隐藏下推时的确定弹窗
有些业务下推的时候需要直接下推,不需要弹窗来确定是否下推
在转换路线中有个不显示弹窗的复选框关闭会导致下推的时候会报无转换规则,所以无办法在转换规则中关闭确认弹窗
正确方法:在push操作中选择修改,在参数设置下有哥跳出下推界面的复选框,关闭复选框即可
2、

十一、下拉列表

1、给下拉列表添加下拉值
//1、获取下拉列表控件
MulComboEdit mulComboEdit = this.getControl("控件标识符");
//MulComboProp mulComboProp = this.getControl("控件标识符");
//2、设置下拉值
List<ComboItem> data = new ArrayList<>();
data.add(new ComboItem(new LocaleString("下拉标题"),"下拉值"));
//3、绑定下拉值
mulComboEdit.setComboItems(data);
2、

十二、afterBindData

1、
@Override
public void afterBindData(EventObject e) {
    super.afterBindData(e);

    DynamicObject dataEntities = this.getModel().getDataEntity(true);

    long billId = dataEntities.getLong(BaseFieldConst.ID);
    // 查询上游单
    Map<String, HashSet<Long>> sourceBills = BFTrackerServiceHelper.findSourceBills(InvMetaDataConst.INTRO_RECORD, new Long[]{billId});

    //如果当前单据是由上游<入场盘点>单关联生成,则"引种类型"字段的值对应上游单据中的“引种类型”字段,且字段锁定不可修改;
    HashSet<Long> callOut = sourceBills.get(InvMetaDataConst.ENTRY_INVENTORY);

    if (callOut != null && callOut.size() >0) {
        this.getView().setEnable(false, IntroRecordConst.INTRO_TYPE);
    }
}
2、

十三、不同服务之间互相调用接口

1、
public class ServiceFactory(){
	private static Map<String,String> serviceMap = new HashMap<>();
	private ServiceFactory(){}
	
	@SuppressWarnings("unchecked")
	public static <T> T getService(Class<T> clazz){
		return <T> getService(clazz.getSimpleName());
	}

	public static Object getService(String serviceName){
		String className = serviceMap.get(serviceName);
		if(className == null){
			throw new RuntimeException(ResManager.loadKDString("%s对应的服务实现未找到","ServiceFactory_0","em_ext"),serviceName));
		}else{
			reture TypesContainer.getOrRegisterSingletonInstance(className);
		}
	}

	static {
		serviceMap.put("服务名","服务接口实现类");
	}
}
2、

十四、基础信息

1、获取当前登录人
long userId = RequestContext.get().getCurrUserId();
2、服务云之间的缓存
RequestContext requestContext = RequestContext.get();
        String globalSessionId = requestContext.getGlobalSessionId();
        Banana<Map<String, Object>, Integer> param = AppCacheFactory.get(CacheKeyConstants.VDM.getName()).get(CacheKeyConstants.VDM.BASEPRICEIMPORT, globalSessionId, Banana.class);

十五、报表开发

1、创建空DataSet
	/**
     * 创建空DataSet - 只有一个数据的结构
     * @return
     */
    public static  DataSet createNullDataSet(String algo,String pk){
        //创建空DataSet
        Collection<Object[]> coll = new ArrayList<>();
        RowMeta rowMeta = RowMetaFactory.createRowMeta(new String[]{pk}, new DataType[]{DataType.StringType});
        CollectionInput input = new CollectionInput(rowMeta,coll);
        return Algo.create(algo).createDataSet(input);
    }
2、计算字段数据 - 同一行的数据
1、加减:
    /**
     * 添加求和字段
     * @param dataSet
     * @param sumName 求和字段别名
     * @param needSumCol 需要添加的求和字段数组
     * @return
     */
    public static DataSet addNewColSum(DataSet dataSet,String sumName,String... needSumCol){
        String needSumColStr = String.format("%s as %s",String.join("+",needSumCol),sumName);
        if(DTF.isNotEmpty(dataSet)){
            dataSet = dataSet.copy().select(addNewSelectors(dataSet.getRowMeta().getFieldNames(),needSumColStr));
        }
        return dataSet;
    }
    /**
     * 添加除数字段
     * @param dataSet
     * @param numerator 分子
     * @param denominator 分母
	 * @param divName 别名
     * @return
     */
    public static DataSet addNewColDiv(DataSet dataSet,String numerator,String denominator,String divName){
        String totalStr = String.format("round(cast(%s as BigDecimal)/cast(%s as BigDecimal),4) as %s",numerator,denominator,divName);
        if(DTF.isNotEmpty(dataSet)){
            dataSet = dataSet.copy().select(ReportTableHeadHelper.addNewSelectors(dataSet.getRowMeta().getFieldNames(), totalStr));
        }
        return dataSet;
    }

十六、组件

1、颜色选择器
1、使用自定义控件
控件方案名称:common_colorpicker
2、

十七、网址

1、动态创建控件
https://developer.kingdee.com/article/187263796321238016?channel_level=%E9%87%91%E8%9D%B6%E4%BA%91%E7%A4%BE%E5%8C%BA%7C%E6%90%9C%E7%B4%A2%7C%E7%BB%BC%E5%90%88&productLineId=29
2、获取hr人员信息
Map<String, Object> hruser = DispatchServiceHelper.invokeBizService("hrmp","hrpi", "IHRPIPersonService", "getPersonModelIdByUserId",1807592245168224256L);
Map<String,Object> asd = (Map<String, Object>) hruser.get("data");
Map<String, Object> personInfo = DispatchServiceHelper.invokeBizService("hrmp", "hrpi", "IHRPIPersonService", "getPersonInfo", asd.get("person"));

十八、

1、
2、

十九、

1、
2、

二十、

1、
2、

二十一、

1、
2、

二十二、

1、
2、

二十三、

1、
2、

∞、金蝶报错记录

1、at kd.bos.entity.formula.IMemberValueHandler.findPropertys
界面规则报错
1、kd.bos.exception.KDException:实体。。。。单据不存在字段。。。
原先某个字段配置了界面规则,但是后面把它给删除掉了,会报这个错误
2、

负六、金蝶插件基类

动态表单应用场景插件基类
动态表单PC端界面AbstractFormPlugin
移动端界面AbstractMobFormPlugin
单据/基础资料单据界面AbstractBillPlugIn
标准单据列表AbstractListPlugin
左树右表单据列表AbstractTreeListPlugin
树型基础资料列表StandardTreeListPlugin
移动端单据列表AbstractMobListPlugin
单据操作AbstractOperationServicePlugIn
单据转换AbstractConvertPlugIn
报表插件报表界面插件AbstractReportFormPlugin
报表查询插件AbstractReportListDataPlugin
工作流工作流参与人插件IWorkflowPlugin
工作流服务插件IWorkflowPlugin
工作流条件插件IWorkflowPlugin
开放接口自定义开放接口插件IBillWebApiPlugin
打印插件打印数据处理插件AbstractPrintServicePlugin
引入插件引入数据加工IImportPlugin

负五、选用事件源,事件

分类序号事件触发时机
界面显示前1setPluginName显示界面前,准备构建界面显示参数之前,创建插件后,触发此事件
2preOpenForm显示界面前,准备构建界面显示参数之前,触发此事件
3loadCustomControlMetas显示界面前,构建界面显示参数时,触发此事件
界面初始化4setView表单视图模型初始化,创建插件时,调用此方法,向插件传入表单视图模型IFormView实例;
5initialize表单视图模型初始化,创建插件后,触发此事件
6registerListener用户与界面上的控件交互时,触发此事件
7getEntityType表单基于实体模型,创建数据包之前,触发此事件
8createNewData界面初始化或刷新,开始新建数据包时触发此事件
9afterCreateNewData界面初始化或刷新,新建数据包完毕后,触发此事件
10beforeBindData界面数据包构建完毕,开始生成指令,刷新前端字段值、控件状态之前,触发此事件
11afterBindData界面数据包构建完毕,生成指令,刷新前端字段值、控件状态之后,触发此事件
用户交互12beforeItemClick用户点击界面菜单按钮时,执行绑定的操作前,触发此事件
13itemClick用户点击界面菜单按钮时触发此事件
14beforeDoOperation用户点击按钮、菜单,执行绑定的操作前,触发此事件
15afterDoOperation用户点击按钮、菜单,执行完绑定的操作后,不论成功与否,均会触发此事件
16confirmCallBack前端交互提示确认后,通知插件进行后续处理
17closedCallBack子界面关闭时,如果回调函数由父界面处理,则会触发父界面的此事件
18beforeClick用户点击按钮,标签,执行绑定的操作前,触发此事件
19click用户点击界面按钮或者标签时触发此事件
20flexBeforeClosed弹性域维护界面关闭时,触发父界面此事件
21onGetControl在有代码尝试获取控件的编程模型时,触发此事件
22onGetControl触发自定义控件的定制事件
23TimerElapsed定时触发此事件
24afterDeleteRow删除单据体行后触发此事件
25afterAddRow新增单据体行后触发此事件
26propertyChanged字段值更新后触发此事件
27beforeF7SelectF7字段打开时触发
界面关闭28beforeClosed界面关闭之前触发此事件
29beforeClosed界面关闭后,释放资源时,触发此事件
30pageRelease界面关闭后,释放资源时,触发此事件

负四、IFormView提供的常用接口

方法说明
getPageId获取界面实例的唯一标识 pageId
getView获取其他界面的视图模型
getEntityId获取表单的主实体编码,如bd_material
getModel获取表单数据模型
getParentView获取父表单视图模型
getMainView获取主界面视图模型
updateView把数据模型中的数据,发送到前端界面
getControl获取控件编程模型
getRootControl获取表单编程模型
getService获取服务实例
invokeOperation执行操作
activate激活表单
close关闭表单
setEnable设置控件可用性
setVisible设置控件可见性
showForm传入表单显示参数,打开一个新的表单,作为本表单的子表单
getFormShowParameter获取表单显示参数
cacheFormShowParameter修改表单显示参数对象属性值之后,调用本方法把参数更新到缓存
returnDataToParent设置返回到父表单的返回值
openUrl打开一个新窗口链接到指定的URL
showUpload显示一个文件上传界面;文件上传完毕,触发插件afterUpload事件;
showMessage单据内悬浮消息框,默认没有按钮,自动消失
showErrMessage显示错误消息
showOperationResult显示操作结果
showConfirm显示确认消息;用户确认完毕,会触发confirmCallBack事件;
showSuccessNotification单据内成功悬浮消息框,默认2秒自动消失;消息内容,不能超过50字
showErrorNotification单据内失败悬浮消息框,需要手动关闭
showTipNotification单据内提示类别悬浮消息框,提示类会显示按钮,需要手动关闭
showRobotMessage发送消息给机器人助手
closeRobotMessage关闭消息给机器人助手
showFieldTip字段上显示提示信息

负三、IDataModel提供的常用方法

方法说明
getDataEntityType获取运行时表单实体元数据对象,又称为主实体模型
getProperty获取运行时字段元数据对象,又称为实体的属性对象
createNewData根据表单主实体模型,创建表单新的数据包,字段填写好默认值
getDataEntity获取表单数据包
updateCache提交当前表单数据包到缓存
getValue获取字段值
setValue设置字段值
setItemValueByNumber根据基础资料的编码,设置基础资料字段值
setItemValueByID根据基础资料的内码,设置基础资料字段值
getContextVariable获取上下文变量
putContextVariable添加上下文变量
removeContextVariable删除上下文变量
addDataModelListener订阅模型相关事件
addDataModelChangeListener订阅模型改变事件
createNewEntryRow创建分录行
batchCreateNewEntryRow批量创建分录行

负二、bos-servicehelper工程含大量工具类

方法说明
SaveServiceHelper保存服务
DeleteServiceHelper删除服务
BusinessDataServiceHelper单据、基础资料读取
QueryServiceHelper查询服务
DBServiceHelper生成全局唯一的数据内码(字符型、长整型)
TimeServiceHelper获取系统时间
BaseDataServiceHelper基础资料服务
ConvertServiceHelper单据转换服务
CodeRuleServiceHelper单据编号服务
OperationServiceHelper单据各种操作服务(保存、提交、审核、反审核、禁用、作废等)

负一、AbstractReportFormPlugin 报表表单插件

方法说明
getQueryParam获取查询参数
filterContainerInit初始化过滤容器触发方法
filterContainerBeforeF7Select过滤容器内F7弹出前的处理方法
initDefaultQueryParam初始化默认查询参数
processRowData行数据处理
说明:参数gridPK为表格控件标识,参数rowData为一页数据,参数queryParam为查询参数
packageData打包数据给前端时触发
formatDisplayFilterField格式化主界面显示的筛选过滤字段信息
verifyQuery查询前条件验证
beforeQuery查询前置处理
afterQuery查询后置处理
afterCreateColumn表格列创建完成后置事件
query查询数据
说明:参数queryParam为查询参数,selectedObj为左树(表)右表时选中左树(表)对象,左树时为节点ID,左表时为选中行数据
getColumns改变列信息
说明:参数columns为报表设计列,返回值为页面显示列
getQueryParam获取查询条件
getSelectedObj获取左表、左树选择行或节点
setProgress设置进度

零、转换插件执行顺序 - AbstractConvertPlugIn

时期方法说明
//出现下推信息弹窗afterGetSourceData初始化变量事件
beforeBuildRowCondition置忽略规则原生的条件,改用插件定制条件,或者在规则条件基础上,追加定制条件
beforeBuildGroupMode调整分单、合并策略及依赖的字段
//点击下推后beforeBuildRowCondition设置忽略规则原生的条件,改用插件定制条件,或者在规则条件基础上,追加定制条件
beforeBuildGroupMode调整分单、合并策略及依赖的字段
afterBuildQueryParemeter添加额外的字段、过滤条件
beforeGetSourceData修改取数语句、取数条件
afterCreateTarget这个事件,只在下推时触发,把根据分单规则创建好的目标单,传递给插件
afterFieldMapping插件可以在此基础上,继续填写目标字段值
beforeCreateLink取消记录关联关系
afterCreateLink根据系统自动记录的关联关系,进行相关数据的同步携带,如携带其他子单据体数据
afterConvert插件可以在这个事件中,对生成的目标单数据,进行最后的修改
  • 44
    点赞
  • 78
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值