--父页面弹出子页面f7列表,F7列表以父页面某个字段过滤
/**
* 养殖合同单据
* @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_POP_LEAVE_TYPE2 = "recbill";
//子页面(收款单)标识
private static final String KEY_POP_LEAVE_TYPE_PAGE2 = "cas_recbill";
//子页面养殖资质单单据号标识
private static final String KEY_TYPE_NAME = "billno";
//子页面收款单单据号标识
private static final String KEY_TYPE_NAME2 = "billno";
//父页面养殖合同--弹出列表控件标识-特批单字段
private static final String KEY_POP_LEAVE_TYPE3 = "permission";
//子页面(特批单)标识
private static final String KEY_POP_LEAVE_TYPE_PAGE3 = "mz_permission";
//子页面特批单号标识
private static final String KEY_TYPE_NAME3 = "billno";
@Override
public void registerListener(EventObject e) {
super.registerListener(e);
this.addClickListeners(KEY_POP_LEAVE_TYPE);
this.addClickListeners(KEY_POP_LEAVE_TYPE2);
this.addClickListeners(KEY_POP_LEAVE_TYPE3);
}
@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));
showParameter.setCaption("养殖资质单列表");
//添加过滤条件
if(null!=this.getModel().getValue("secondparty")) {
DynamicObject secondpartyInfo = (DynamicObject) this.getModel().getValue("secondparty");//
String secondpartyNumber = secondpartyInfo.getString("number");
//对于基础资料 直接用.
QFilter qFilter = new QFilter("farmers.number",QFilter.equals, secondpartyNumber);
showParameter.getListFilterParameter().setFilter(qFilter);
}
this.getView().showForm(showParameter);
}
if (StringUtils.equals(KEY_POP_LEAVE_TYPE2, source.getKey())) {
//第一个参数为列表的单据标识,第二个参数为是否支持多选
ListShowParameter showParameter = ShowFormHelper.createShowListForm(KEY_POP_LEAVE_TYPE_PAGE2, false);
//设置弹出子页面的样式
showParameter.setCloseCallBack(new CloseCallBack(this, KEY_POP_LEAVE_TYPE2));
showParameter.setCaption("收款单列表");
this.getView().showForm(showParameter);
}
if (StringUtils.equals(KEY_POP_LEAVE_TYPE3, source.getKey())) {
ListShowParameter showParameter = ShowFormHelper.createShowListForm(KEY_POP_LEAVE_TYPE_PAGE3, false);
showParameter.setCloseCallBack(new CloseCallBack(this, KEY_POP_LEAVE_TYPE3));
showParameter.setCaption("特批单列表");
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);
}
}
if (e.getReturnData() != null && StringUtils.equals(KEY_POP_LEAVE_TYPE2, e.getActionId())) {
//如果返回值不为空且标识一致,则获取返回值,此处返回值为所选数据的主键id
String returnData = ((ArrayList) (e.getReturnData())).get(0).toString();
if (StringUtils.isNotBlank(returnData)) {
//根据主键id获取单条数据
DynamicObject recbill = BusinessDataServiceHelper.loadSingle(returnData, KEY_POP_LEAVE_TYPE_PAGE2);//第三个参数不传,查询这个id的整条记录
String number = recbill.get(KEY_TYPE_NAME2).toString();
String actrecamt = recbill.get("actrecamt").toString();
this.getModel().setValue(KEY_POP_LEAVE_TYPE2, number);//保证金收款单赋值
this.getModel().setValue("depositamount", actrecamt);//保证金余额赋值
}
}
if (e.getReturnData() != null && StringUtils.equals(KEY_POP_LEAVE_TYPE3, e.getActionId())) {
//如果返回值不为空且标识一致,则获取返回值,此处返回值为所选数据的主键id
String returnData = ((ArrayList) (e.getReturnData())).get(0).toString();
if (StringUtils.isNotBlank(returnData)) {
//根据主键id获取单条数据
DynamicObject recbill = BusinessDataServiceHelper.loadSingle(returnData, KEY_POP_LEAVE_TYPE_PAGE3);
String number = recbill.get(KEY_TYPE_NAME3).toString();
this.getModel().setValue(KEY_POP_LEAVE_TYPE3, number);
}
}
}
--监听事件 获取客户资料下面联系人页签中联系方式
/**
* 值监听事件
*/
@Override
public void propertyChanged(PropertyChangedArgs e) {
// TODO Auto-generated method stub
super.propertyChanged(e);
String fieldKey = e.getProperty().getName();
//乙方 带出乙方的联系方式 身份证号
if(StringUtils.equals("secondparty", fieldKey) ) {
DynamicObject customerInfo = (DynamicObject) this.getModel().getValue("secondparty");
DynamicObject bd_customer = BusinessDataServiceHelper.loadSingle(customerInfo.getString("id"), "bd_customer");//第三个参数不传,查询这个id的整条记录
DynamicObjectCollection DynamicObjects = (DynamicObjectCollection) bd_customer.get("entry_linkman");
DynamicObject dynamicObject = DynamicObjects.get(0);// 客户资料联系人页签取分录中的第一条记录
String phone = dynamicObject.get(7).toString();//联系电话
this.getModel().setValue("phone", phone);
}
}
--单据初始化
//单据初始化分录
@Override
public void afterCreateNewData(EventObject e) {
int rowCount = this.getModel().getEntryRowCount("entryentity");
if (rowCount < 6){
// 给单据体补足6行
this.getModel().batchCreateNewEntryRow("entryentity", 6 - rowCount);
rowCount = 6;
}
// 逐行给整数字段设置默认值
// for(int row = 0; row < rowCount ; row++){
// this.getModel().setValue("material", "", row);
// }
this.getModel().setValue("material", "小鸭料", 0);
this.getModel().setValue("material", "大鸭料", 1);
this.getModel().setValue("material", "初产鸭料", 2);
this.getModel().setValue("material", "产蛋鸭料", 3);
this.getModel().setValue("material", "合格蛋", 4);
this.getModel().setValue("material", "菜蛋", 5);
}