This commit is contained in:
parent
d7b35daa62
commit
965a162a3f
|
|
@ -0,0 +1,206 @@
|
|||
//
|
||||
// Source code recreated from a .class file by IntelliJ IDEA
|
||||
// (powered by FernFlower decompiler)
|
||||
//
|
||||
|
||||
package zcgj.zcdev.zcdev.pr.plugin.form;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EventObject;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import kd.bos.bill.AbstractBillPlugIn;
|
||||
import kd.bos.context.RequestContext;
|
||||
import kd.bos.data.ParameterHelper;
|
||||
import kd.bos.dataentity.entity.DynamicObject;
|
||||
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
||||
import kd.bos.dataentity.resource.ResManager;
|
||||
import kd.bos.entity.datamodel.ListSelectedRowCollection;
|
||||
import kd.bos.entity.list.option.ListUserOption;
|
||||
import kd.bos.entity.plugin.Plugin;
|
||||
import kd.bos.form.CloseCallBack;
|
||||
import kd.bos.form.FormConfig;
|
||||
import kd.bos.form.FormMetadataCache;
|
||||
import kd.bos.form.ShowFormHelper;
|
||||
import kd.bos.form.control.Control;
|
||||
import kd.bos.form.events.ClosedCallBackEvent;
|
||||
import kd.bos.form.field.TextEdit;
|
||||
import kd.bos.list.ListFilterParameter;
|
||||
import kd.bos.list.ListShowParameter;
|
||||
import kd.bos.orm.query.QFilter;
|
||||
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||
|
||||
/*
|
||||
* 付款申请单(项目资金)供应商银行信息字段点击系统插件二开
|
||||
*/
|
||||
public class SupplierBankInfoClickBillPluginExt extends AbstractBillPlugIn {
|
||||
public SupplierBankInfoClickBillPluginExt() {
|
||||
}
|
||||
|
||||
public void registerListener(EventObject e) {
|
||||
super.registerListener(e);
|
||||
TextEdit payeebanknum = (TextEdit) this.getView().getControl("bankaccount");
|
||||
payeebanknum.addButtonClickListener(this);
|
||||
}
|
||||
|
||||
public void click(EventObject evt) {
|
||||
super.click(evt);
|
||||
Control c = (Control) evt.getSource();
|
||||
switch (c.getKey().toLowerCase()) {
|
||||
case "bankaccount":
|
||||
this.showBankInfoF7();
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
public void closedCallBack(ClosedCallBackEvent closedCallBackEvent) {
|
||||
super.closedCallBack(closedCallBackEvent);
|
||||
String actionId = closedCallBackEvent.getActionId();
|
||||
if ("payeeaccountbank".equals(actionId)) {
|
||||
Object returnData = closedCallBackEvent.getReturnData();
|
||||
if (returnData != null) {
|
||||
int row = this.getModel().getEntryCurrentRowIndex("entryentity");
|
||||
ListSelectedRowCollection rowInfo = (ListSelectedRowCollection) returnData;
|
||||
Object entryKey = rowInfo.getEntryPrimaryKeyValues()[0];
|
||||
DynamicObject bankRowObject = this.loadBankInfo((Long) entryKey);
|
||||
this.getPageCache().put("bankaccountcache-" + row, bankRowObject.getString("bankaccount"));
|
||||
this.getModel().setValue("bankname", bankRowObject.getDynamicObject("bank").getString("name"), row);
|
||||
this.getModel().setValue("bankaccount", bankRowObject.getString("bankaccount"), row);
|
||||
this.getModel().setValue("bebank", bankRowObject.getDynamicObject("bank").getPkValue(), row);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void showBankInfoF7() {
|
||||
int row = this.getModel().getEntryCurrentRowIndex("entryentity");
|
||||
DynamicObject contract = (DynamicObject) this.getModel().getValue("contract", row);
|
||||
DynamicObject partner = null;
|
||||
if (this.isSupplier()) {
|
||||
partner = contract.getDynamicObject("partb");
|
||||
} else {
|
||||
partner = contract.getDynamicObject("parta");
|
||||
}
|
||||
|
||||
boolean hasDefaultBankInfo = this.hasDefaultBankInfo(partner);
|
||||
if (!hasDefaultBankInfo) {
|
||||
if (this.isSupplier()) {
|
||||
this.getView().showTipNotification(ResManager.loadKDString("请维护对应供应商的银行信息。", "SupplierBankInfoClickBillPlugin_0", "ec-contract-formplugin", new Object[0]));
|
||||
} else {
|
||||
this.getView().showTipNotification(ResManager.loadKDString("请维护对应客户的银行信息。", "SupplierBankInfoClickBillPlugin_1", "ec-contract-formplugin", new Object[0]));
|
||||
}
|
||||
|
||||
} else {
|
||||
ListShowParameter lsp = null;
|
||||
lsp = this.getSupplierBankInfoShowParameter(partner.getPkValue());
|
||||
CloseCallBack closeCallBack = new CloseCallBack(this, "payeeaccountbank");
|
||||
lsp.setCloseCallBack(closeCallBack);
|
||||
this.getView().showForm(lsp);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean hasDefaultBankInfo(DynamicObject supplier) {
|
||||
if (supplier == null) {
|
||||
return false;
|
||||
} else {
|
||||
String entity = supplier.getDataEntityType().getName();
|
||||
supplier = BusinessDataServiceHelper.loadSingleFromCache(supplier.getPkValue(), entity);
|
||||
DynamicObjectCollection bankColls = supplier.getDynamicObjectCollection("entry_bank");
|
||||
DynamicObject defaultBankAccountInfo = null;
|
||||
|
||||
for (int i = 0; i < bankColls.size(); ++i) {
|
||||
if (i == 0 || ((DynamicObject) bankColls.get(i)).getBoolean("isdefault_bank")) {
|
||||
defaultBankAccountInfo = (DynamicObject) bankColls.get(i);
|
||||
}
|
||||
}
|
||||
|
||||
if (defaultBankAccountInfo != null) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private ListShowParameter createDynamicListShowParameter(String entity, String entry, List<String> showFields) {
|
||||
ListShowParameter lsp = ShowFormHelper.createShowListForm(entity, false, 2);
|
||||
lsp.setCustomParam("entity", entity);
|
||||
lsp.setCustomParam("entry", entry);
|
||||
lsp.setCustomParam("isEntryMain", true);
|
||||
lsp.setCustomParam("showFields", showFields);
|
||||
this.clearPlugins(lsp);
|
||||
this.registerScript("kingdee.ec.cont.mainpage.ecdynamiclistscriptplugin", lsp);
|
||||
this.setMergeRow(false, lsp);
|
||||
lsp.setAppId("cont");
|
||||
return lsp;
|
||||
}
|
||||
|
||||
private void registerScript(String script, ListShowParameter lsp) {
|
||||
List<Plugin> plugins = this.getOrCreateFormConfig(lsp).getPlugins();
|
||||
Plugin p = new Plugin();
|
||||
p.setClassName(script);
|
||||
p.setType(1);
|
||||
plugins.add(p);
|
||||
}
|
||||
|
||||
private void clearPlugins(ListShowParameter lsp) {
|
||||
List<Plugin> plugins = this.getOrCreateFormConfig(lsp).getPlugins();
|
||||
plugins.clear();
|
||||
}
|
||||
|
||||
private void setMergeRow(boolean mergeRow, ListShowParameter lsp) {
|
||||
Map<String, Object> listUserOptions = ParameterHelper.getListOptions(Long.parseLong(RequestContext.get().getUserId()), lsp.getBillFormId(), this.getOrCreateFormConfig(lsp).getListUserOption(), (String) null);
|
||||
ListUserOption listUserOption = new ListUserOption(listUserOptions);
|
||||
listUserOption.setMergeRow(mergeRow);
|
||||
lsp.setListUserOption(listUserOption);
|
||||
}
|
||||
|
||||
private FormConfig getOrCreateFormConfig(ListShowParameter lsp) {
|
||||
FormConfig formConfig = lsp.getFormConfig();
|
||||
if (formConfig == null) {
|
||||
formConfig = FormMetadataCache.getFormConfig(lsp.getFormId());
|
||||
lsp.setFormConfig(formConfig);
|
||||
}
|
||||
|
||||
return formConfig;
|
||||
}
|
||||
|
||||
private ListShowParameter getSupplierBankInfoShowParameter(Object pk) {
|
||||
List<String> showFields = new ArrayList();
|
||||
showFields.add("bank.name");
|
||||
showFields.add("bankaccount");
|
||||
showFields.add("accountname");
|
||||
showFields.add("currency.name");
|
||||
showFields.add("isdefault_bank");
|
||||
ListShowParameter lsp = this.createDynamicListShowParameter(this.isSupplier() ? "bd_supplier" : "bd_customer", "entry_bank", showFields);
|
||||
ListFilterParameter lfp = new ListFilterParameter();
|
||||
lfp.setFilter(new QFilter("id", "=", pk));
|
||||
lsp.setListFilterParameter(lfp);
|
||||
lsp.setCaption(this.isSupplier() ? ResManager.loadKDString("供应商-银行信息", "SupplierBankInfoClickBillPlugin_2", "ec-contract-formplugin", new Object[0]) : ResManager.loadKDString("客户-银行信息", "SupplierBankInfoClickBillPlugin_3", "ec-contract-formplugin", new Object[0]));
|
||||
return lsp;
|
||||
}
|
||||
|
||||
public DynamicObject loadBankInfo(Long entryPk) {
|
||||
DynamicObject customerOrSupplier = BusinessDataServiceHelper.loadSingle(this.isSupplier() ? "bd_supplier" : "bd_customer", "bankaccount,accountname,bank,currency,isdefault_bank", new QFilter[]{new QFilter("entry_bank.id", "=", entryPk)});
|
||||
if (customerOrSupplier != null) {
|
||||
DynamicObjectCollection entryBanks = customerOrSupplier.getDynamicObjectCollection("entry_bank");
|
||||
Iterator var4 = entryBanks.iterator();
|
||||
|
||||
while (var4.hasNext()) {
|
||||
DynamicObject row = (DynamicObject) var4.next();
|
||||
if (row.getPkValue().equals(entryPk)) {
|
||||
return row;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean isSupplier() {
|
||||
String formId = this.getView().getEntityId();
|
||||
return !"ec_incomeapply".equals(formId);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue