package kd.bos.zqform.plugin;
import java.util.ArrayList;
import java.util.EventObject;
import kd.bos.bill.AbstractBillPlugIn;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.utils.StringUtils;
import kd.bos.form.CloseCallBack;
import kd.bos.form.ShowFormHelper;
import kd.bos.form.control.Control;
import kd.bos.form.events.ClosedCallBackEvent;
import kd.bos.form.field.events.BeforeF7SelectEvent;
import kd.bos.form.field.events.BeforeF7SelectListener;
import kd.bos.list.ListShowParameter;
import kd.bos.servicehelper.BusinessDataServiceHelper;
/**
* 养殖合同单据
* @author mz
*
*/
public class ContractBillPlugin extends AbstractBillPlugIn implements BeforeF7SelectListener {
//父页面养殖合同--弹出列表控件标识
private static final String KEY_POP_LEAVE_TYPE = "farmedqualification";
//子页面(养殖资质单)标识
private static final String KEY_POP_LEAVE_TYPE_PAGE = "mz_farmedqualification";
//子页面养殖资质单单据号标识
private static final String KEY_TYPE_NAME = "billno";
@Override
public void registerListener(EventObject e) {
super.registerListener(e);
this.addClickListeners(KEY_POP_LEAVE_TYPE);
}
@Override
public void click(EventObject evt) {
super.click(evt);
//获取被点击控件
Control source = (Control) evt.getSource();
if (null != source) {
if (StringUtils.equals(KEY_POP_LEAVE_TYPE, source.getKey())) {
//第一个参数为列表的单据标识,第二个参数为是否支持多选
ListShowParameter showParameter = ShowFormHelper.createShowListForm(KEY_POP_LEAVE_TYPE_PAGE, false);
//设置弹出页面的样式
showParameter.setCloseCallBack(new CloseCallBack(this, KEY_POP_LEAVE_TYPE));
this.getView().showForm(showParameter);
}
}
}
@Override
public void closedCallBack(ClosedCallBackEvent e) {
super.closedCallBack(e);
if (e.getReturnData() != null && StringUtils.equals(KEY_POP_LEAVE_TYPE, e.getActionId())) {
//如果返回值不为空且标识一致,则获取返回值,此处返回值为所选数据的主键id
// String returnData = e.getReturnData().toString().replace("[", "").replace("]", "");//这种方法也可以
String returnData = ((ArrayList) (e.getReturnData())).get(0).toString();
if (StringUtils.isNotBlank(returnData)) {
//根据主键id去请假类型单据中获取单条数据
DynamicObject leaveType = BusinessDataServiceHelper.loadSingle(returnData, KEY_POP_LEAVE_TYPE_PAGE, KEY_TYPE_NAME);
//获取到养殖资质单单编码的属性值
String typename = leaveType.get(KEY_TYPE_NAME).toString();
//给页面“养殖资质单--弹出列表”赋值类型名称的值
this.getModel().setValue(KEY_POP_LEAVE_TYPE, typename);
}
}
}
@Override
public void beforeF7Select(BeforeF7SelectEvent arg0) {
// TODO Auto-generated method stub
}
}
参考链接: