付款申请单二开供应商-银行信息弹窗逻辑
This commit is contained in:
parent
016bd8f9aa
commit
ea83eb5a9e
|
@ -1,5 +1,9 @@
|
|||
package zcgj.zcdev.zcdev.pr.plugin.form;
|
||||
|
||||
import kd.bos.algo.DataSet;
|
||||
import kd.bos.algo.JoinDataSet;
|
||||
import kd.bos.algo.JoinType;
|
||||
import kd.bos.algo.Row;
|
||||
import kd.bos.bill.AbstractBillPlugIn;
|
||||
import kd.bos.dataentity.entity.DynamicObject;
|
||||
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
||||
|
@ -7,22 +11,101 @@ import kd.bos.entity.datamodel.RowDataEntity;
|
|||
import kd.bos.entity.datamodel.events.AfterAddRowEventArgs;
|
||||
import kd.bos.entity.datamodel.events.ChangeData;
|
||||
import kd.bos.entity.datamodel.events.PropertyChangedArgs;
|
||||
import kd.bos.form.*;
|
||||
import kd.bos.form.control.Button;
|
||||
import kd.bos.form.control.Control;
|
||||
import kd.bos.form.events.ClosedCallBackEvent;
|
||||
import kd.bos.orm.query.QCP;
|
||||
import kd.bos.orm.query.QFilter;
|
||||
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||
import kd.bos.servicehelper.QueryServiceHelper;
|
||||
import kd.sdk.plugin.Plugin;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.EventObject;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
|
||||
// 付款申请(项目资金)
|
||||
// 1:供应商赋值收款银行和收款账号
|
||||
// 1:供应商-银行信息弹窗逻辑和赋值
|
||||
// 2:关联业务单据(取用入库单)中的供应商赋值给分录中的供应商
|
||||
// 3:入库单-含税总运费+材料含税总金额赋值给付款申请单中应付字段
|
||||
public class PaymentApplySupplierPlugin extends AbstractBillPlugIn {
|
||||
public class PaymentApplySupplierPlugin extends AbstractBillPlugIn implements Plugin {
|
||||
|
||||
@Override
|
||||
public void registerListener(EventObject e) {
|
||||
super.registerListener(e);
|
||||
this.addClickListeners("zcgj_payeraccountname");//收款账户
|
||||
}
|
||||
|
||||
@Override
|
||||
public void click(EventObject evt) {
|
||||
super.click(evt);
|
||||
String zcgj_payeraccountname = this.getView().getControl("zcgj_payeraccountname").getKey();//收款账户
|
||||
if (!StringUtils.isEmpty(zcgj_payeraccountname)) {
|
||||
DynamicObject zcgj_supplier1 = (DynamicObject) this.getModel().getValue("zcgj_supplier1");//供应商
|
||||
if (zcgj_supplier1 == null){
|
||||
this.getView().showErrorNotification("请先选择供应商");
|
||||
return;
|
||||
}
|
||||
Object masterid = zcgj_supplier1.get("masterid");
|
||||
if (masterid != null) {
|
||||
HashMap<String, Object> cusMap = new HashMap<>();
|
||||
Long id = (Long) zcgj_supplier1.get("masterid");
|
||||
QFilter qFilter = new QFilter("id", QCP.equals, id);
|
||||
DataSet ds1 = QueryServiceHelper.queryDataSet("test1", "bd_supplier",
|
||||
"entry_bank.bankaccount bc,entry_bank.bank bid,entry_bank.accountname bn",
|
||||
new QFilter[]{qFilter}, null);
|
||||
DataSet ds2 = QueryServiceHelper.queryDataSet("test2", "bd_bebank", "id,name", null, null);
|
||||
JoinDataSet js = ds1.join(ds2, JoinType.LEFT);
|
||||
DataSet finish = js.on("bid", "id").select(new String[]{"bc", "bn"}, new String[]{"name"}).finish();
|
||||
Iterator<Row> iterator = finish.iterator();
|
||||
ArrayList<Object> list = new ArrayList<>();
|
||||
while (iterator.hasNext()) {
|
||||
HashMap<String, Object> mapSub = new HashMap<>();
|
||||
Row row = iterator.next();
|
||||
String value1 = row.getString("bc");
|
||||
String value2 = row.getString("bn");
|
||||
String value3 = row.getString("name");
|
||||
mapSub.put("bc", value1);
|
||||
mapSub.put("bn", value2);
|
||||
mapSub.put("name", value3);
|
||||
list.add(mapSub);
|
||||
}
|
||||
cusMap.put("test", list);
|
||||
FormShowParameter formShowParameter = new FormShowParameter();
|
||||
formShowParameter.setCaption("供应商-银行信息");
|
||||
OpenStyle openStyle = formShowParameter.getOpenStyle();
|
||||
formShowParameter.setFormId("zcgj_supplier_payer");
|
||||
formShowParameter.setCustomParams(cusMap);
|
||||
formShowParameter.setCloseCallBack(new CloseCallBack(this, "zcgj_payeraccountname"));//付款申请-收款账户
|
||||
StyleCss styleCss = new StyleCss();
|
||||
styleCss.setHeight("300");
|
||||
styleCss.setWidth("1000");
|
||||
openStyle.setShowType(ShowType.Modal);
|
||||
openStyle.setInlineStyleCss(styleCss);
|
||||
this.getView().showForm(formShowParameter);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closedCallBack(ClosedCallBackEvent closedCallBackEvent) {
|
||||
super.closedCallBack(closedCallBackEvent);
|
||||
String actionId = closedCallBackEvent.getActionId();
|
||||
DynamicObject returnData = (DynamicObject) closedCallBackEvent.getReturnData();
|
||||
if (actionId.equals("zcgj_payeraccountname") && returnData != null) {
|
||||
this.getModel().setValue("zcgj_payeraccountname", returnData.getString("zcgj_accountname"));//账户名称/收款账户
|
||||
this.getModel().setValue("zcgj_payerbank1", returnData.getString("zcgj_bankaccount"));//银行账号/收款银行
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void propertyChanged(PropertyChangedArgs e) {
|
||||
String propName = e.getProperty().getName();
|
||||
if (propName.equals("zcgj_supplier1")) {
|
||||
/* if (propName.equals("zcgj_supplier1")) {
|
||||
//供应商
|
||||
ChangeData[] changeSet = e.getChangeSet();
|
||||
ChangeData changeData = changeSet[0];
|
||||
|
@ -42,7 +125,8 @@ public class PaymentApplySupplierPlugin extends AbstractBillPlugIn {
|
|||
this.getModel().setValue("zcgj_payerbank", null, rowIndex);//开户银行
|
||||
this.getModel().setValue("zcgj_payeraccountname", null, rowIndex);//银行账号
|
||||
}
|
||||
} else if (propName.equals("zcgj_materialinb")) {
|
||||
} else*/
|
||||
if (propName.equals("zcgj_materialinb")) {
|
||||
//关联业务单据(取用入库单)
|
||||
DynamicObjectCollection itementry = this.getModel().getDataEntity(true).getDynamicObjectCollection("itementry");//非合同付款信息分录
|
||||
ChangeData[] changeSet = e.getChangeSet();
|
||||
|
|
|
@ -0,0 +1,67 @@
|
|||
package zcgj.zcdev.zcdev.pr.plugin.form;
|
||||
|
||||
import kd.bos.dataentity.entity.DynamicObject;
|
||||
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
||||
import kd.bos.form.control.Button;
|
||||
import kd.bos.form.control.Control;
|
||||
import kd.bos.form.control.EntryGrid;
|
||||
import kd.bos.form.plugin.AbstractFormPlugin;
|
||||
import kd.sdk.plugin.Plugin;
|
||||
|
||||
import java.util.EventObject;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
//付款申请单二开的供应商-银行信息弹窗插件
|
||||
|
||||
public class SupplierPayerBillPlugin extends AbstractFormPlugin implements Plugin {
|
||||
|
||||
@Override
|
||||
public void registerListener(EventObject e) {
|
||||
super.registerListener(e);
|
||||
Button btnok = this.getControl("btnok");//确定
|
||||
btnok.addClickListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterCreateNewData(EventObject e) {
|
||||
super.afterCreateNewData(e);
|
||||
Map<String, Object> customParams = this.getView().getFormShowParameter().getCustomParams();
|
||||
Object value = customParams.get("test");
|
||||
if (value != null) {
|
||||
List<com.alibaba.fastjson.JSONObject> list = (List<com.alibaba.fastjson.JSONObject>) value;
|
||||
DynamicObjectCollection et = this.getModel().getEntryEntity("zcgj_entryentity");//分录
|
||||
list.forEach(r -> {
|
||||
DynamicObject dynamicObject = et.addNew();
|
||||
dynamicObject.set("zcgj_bank", r.getString("name"));//开户银行名称
|
||||
dynamicObject.set("zcgj_bankaccount", r.getString("bc"));//银行账号
|
||||
dynamicObject.set("zcgj_accountname", r.getString("bn"));//账户名称
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void click(EventObject evt) {
|
||||
super.click(evt);
|
||||
Control source = (Control) evt.getSource();
|
||||
if ("btnok".equals(source.getKey())) {
|
||||
EntryGrid entryGrid = this.getControl("zcgj_entryentity");
|
||||
int[] selectRows = entryGrid.getSelectRows();
|
||||
int count = selectRows.length;
|
||||
//分录行数只有一条的时候才能通过接下来两个if
|
||||
if (count == 0) {
|
||||
this.getView().showErrorNotification("请选择一条银行信息!");
|
||||
return;
|
||||
}
|
||||
if (count > 1) {
|
||||
this.getView().showErrorNotification("只能选择一条银行信息!");
|
||||
return;
|
||||
}
|
||||
DynamicObjectCollection qeug_entryentity = getModel().getEntryEntity("zcgj_entryentity");//分录
|
||||
int vale = getModel().getEntryCurrentRowIndex("zcgj_entryentity");//所选的分录行
|
||||
DynamicObject dynamicObject = qeug_entryentity.get(vale);
|
||||
this.getView().returnDataToParent(dynamicObject);
|
||||
this.getView().close();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue