2025-09-13 09:42:55 +00:00
|
|
|
package tqq9.lc123.cloud.app.plugin.form.pm;
|
|
|
|
|
|
|
|
|
|
import kd.bos.bill.AbstractBillPlugIn;
|
|
|
|
|
import kd.bos.bill.BillShowParameter;
|
2025-09-19 08:50:17 +00:00
|
|
|
import kd.bos.dataentity.OperateOption;
|
2025-09-13 09:42:55 +00:00
|
|
|
import kd.bos.dataentity.entity.DynamicObject;
|
2025-09-15 10:26:35 +00:00
|
|
|
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
2025-09-13 09:42:55 +00:00
|
|
|
import kd.bos.dataentity.utils.StringUtils;
|
2025-09-19 08:50:17 +00:00
|
|
|
import kd.bos.entity.operate.result.OperationResult;
|
2025-09-13 09:42:55 +00:00
|
|
|
import kd.bos.form.CloseCallBack;
|
|
|
|
|
import kd.bos.form.ShowType;
|
2025-09-19 08:50:17 +00:00
|
|
|
import kd.bos.form.events.BeforeDoOperationEventArgs;
|
|
|
|
|
import kd.bos.form.events.ClosedCallBackEvent;
|
2025-09-15 10:26:35 +00:00
|
|
|
import kd.bos.form.field.BasedataEdit;
|
|
|
|
|
import kd.bos.form.field.events.BeforeF7SelectEvent;
|
|
|
|
|
import kd.bos.form.field.events.BeforeF7SelectListener;
|
2025-09-19 08:50:17 +00:00
|
|
|
import kd.bos.form.operate.FormOperate;
|
2025-09-15 10:26:35 +00:00
|
|
|
import kd.bos.list.ListShowParameter;
|
2025-09-13 09:42:55 +00:00
|
|
|
import kd.bos.logging.Log;
|
|
|
|
|
import kd.bos.logging.LogFactory;
|
|
|
|
|
import kd.bos.orm.query.QCP;
|
|
|
|
|
import kd.bos.orm.query.QFilter;
|
|
|
|
|
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
2025-09-19 08:50:17 +00:00
|
|
|
import kd.bos.servicehelper.operation.OperationServiceHelper;
|
|
|
|
|
import kd.bos.servicehelper.operation.SaveServiceHelper;
|
|
|
|
|
import tqq9.lc123.cloud.app.api.utils.Constants;
|
2025-09-13 09:42:55 +00:00
|
|
|
|
|
|
|
|
import java.util.EventObject;
|
2025-09-19 08:50:17 +00:00
|
|
|
import java.util.HashMap;
|
2025-09-13 09:42:55 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 采购退货界面插件
|
|
|
|
|
*/
|
2025-09-15 10:26:35 +00:00
|
|
|
public class PurRefundApplyBillPlugin extends AbstractBillPlugIn implements BeforeF7SelectListener {
|
2025-09-13 09:42:55 +00:00
|
|
|
private final static Log logger = LogFactory.getLog(PurorderEntryIntroPaybillPlugin.class);
|
2025-09-19 08:50:17 +00:00
|
|
|
|
2025-09-13 09:42:55 +00:00
|
|
|
@Override
|
|
|
|
|
public void registerListener(EventObject e) {
|
|
|
|
|
super.registerListener(e);
|
|
|
|
|
this.addItemClickListeners("tbmain");
|
2025-09-15 10:26:35 +00:00
|
|
|
BasedataEdit control = this.getControl("tqq9_ph");
|
|
|
|
|
control.addBeforeF7SelectListener(this);
|
2025-09-19 08:50:17 +00:00
|
|
|
// this.addClickListeners("tqq9_ydthno");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void closedCallBack(ClosedCallBackEvent closedCallBackEvent) {
|
|
|
|
|
super.closedCallBack(closedCallBackEvent);
|
|
|
|
|
String actionId = closedCallBackEvent.getActionId();
|
|
|
|
|
Object returnData = closedCallBackEvent.getReturnData();
|
|
|
|
|
if (StringUtils.equals("tqq9_otheroutapply", actionId) && returnData != null) {
|
|
|
|
|
String billno = ((HashMap) returnData).get("billno").toString();
|
|
|
|
|
DynamicObject tqq9_otheroutapply = BusinessDataServiceHelper.loadSingle("tqq9_otheroutapply", new QFilter[]{new QFilter("billno", QCP.equals, billno)});
|
|
|
|
|
this.getModel().setValue("tqq9_yythbillno", tqq9_otheroutapply);
|
|
|
|
|
}
|
|
|
|
|
SaveServiceHelper.save(new DynamicObject[]{this.getModel().getDataEntity(true)});
|
|
|
|
|
this.getView().updateView();
|
2025-09-13 09:42:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2025-09-19 08:50:17 +00:00
|
|
|
* 异地退货返回事件
|
2025-09-13 09:42:55 +00:00
|
|
|
*/
|
2025-09-19 08:50:17 +00:00
|
|
|
|
|
|
|
|
|
2025-09-13 09:42:55 +00:00
|
|
|
@Override
|
2025-09-19 08:50:17 +00:00
|
|
|
public void beforeDoOperation(BeforeDoOperationEventArgs args) {
|
|
|
|
|
super.beforeDoOperation(args);
|
|
|
|
|
FormOperate Operate = (FormOperate) args.getSource();
|
|
|
|
|
Boolean tqq9_isydth = (Boolean) this.getModel().getValue("tqq9_isydth");//是否异地退货
|
2025-10-17 09:48:44 +00:00
|
|
|
DynamicObject tqq9_yythbillno = (DynamicObject) this.getModel().getValue("tqq9_yythbillno");//异地退货单号
|
|
|
|
|
String tqq9_ydthno = null;
|
|
|
|
|
if (tqq9_yythbillno != null) {
|
|
|
|
|
tqq9_ydthno = tqq9_yythbillno.getString("billno");
|
2025-09-19 08:50:17 +00:00
|
|
|
}
|
|
|
|
|
if (StringUtils.equals("save", Operate.getOperateKey()) && tqq9_isydth && StringUtils.isBlank(tqq9_ydthno)) {
|
2025-09-13 09:42:55 +00:00
|
|
|
BillShowParameter param = new BillShowParameter();
|
|
|
|
|
param.setFormId("tqq9_otheroutapply");
|
|
|
|
|
param.setCustomParam("tqq9_otheroutapplybillno", this.getModel().getValue("billno"));//采购退货申请单号
|
|
|
|
|
param.setCloseCallBack(new CloseCallBack(this, "tqq9_otheroutapply"));
|
|
|
|
|
param.getOpenStyle().setShowType(ShowType.Modal);
|
|
|
|
|
this.getView().showForm(param);
|
2025-09-19 08:50:17 +00:00
|
|
|
} else if (StringUtils.equals("submit", Operate.getOperateKey()) && tqq9_isydth && StringUtils.isNotBlank(tqq9_ydthno)) {
|
|
|
|
|
DynamicObject tqq9_otheroutapply = BusinessDataServiceHelper.loadSingle("tqq9_otheroutapply", new QFilter[]{new QFilter("billno", QCP.equals, tqq9_ydthno)});
|
|
|
|
|
if (StringUtils.equals(tqq9_otheroutapply.getString("billstatus"), "A")) {
|
|
|
|
|
args.setCancel(true);
|
|
|
|
|
String billno = this.getModel().getValue("billno").toString();
|
|
|
|
|
this.getView().showErrorNotification("采购退货单:" + billno + ",对应的异地退货单号:" + tqq9_ydthno + "未提交");
|
|
|
|
|
}
|
2025-10-17 09:48:44 +00:00
|
|
|
} else if (StringUtils.equals("audit", Operate.getOperateKey()) && tqq9_isydth && StringUtils.isNotBlank(tqq9_ydthno)) {
|
2025-09-19 08:50:17 +00:00
|
|
|
DynamicObject tqq9_otheroutapply = BusinessDataServiceHelper.loadSingle("tqq9_otheroutapply", new QFilter[]{new QFilter("billno", QCP.equals, tqq9_ydthno)});
|
|
|
|
|
String billstatus = tqq9_otheroutapply.getString("billstatus");
|
2025-10-17 09:48:44 +00:00
|
|
|
if (StringUtils.equals("B", billstatus)) {
|
2025-09-19 08:50:17 +00:00
|
|
|
OperateOption operateOption = OperateOption.create();
|
2025-10-17 09:48:44 +00:00
|
|
|
OperationResult auditResult = OperationServiceHelper.executeOperate(Constants.TYPE_AUDIT, "tqq9_otheroutapply", new DynamicObject[]{tqq9_otheroutapply}, operateOption);
|
2025-09-19 08:50:17 +00:00
|
|
|
if (auditResult.isSuccess()) {
|
|
|
|
|
this.getView().showMessage("异地退货审核成功");
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-09-13 09:42:55 +00:00
|
|
|
}
|
|
|
|
|
}
|
2025-09-15 10:26:35 +00:00
|
|
|
|
2025-09-19 08:50:17 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 出库批号根据了做筛选
|
2025-09-15 10:26:35 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void beforeF7Select(BeforeF7SelectEvent beforeF7SelectEvent) {
|
|
|
|
|
int index = this.getModel().getEntryCurrentRowIndex("billentry");
|
|
|
|
|
DynamicObjectCollection entryentity = this.getModel().getDataEntity(true).getDynamicObjectCollection("billentry");
|
|
|
|
|
DynamicObject dynamicObject = entryentity.get(index);
|
|
|
|
|
DynamicObject material = dynamicObject.getDynamicObject("material");//物料采购信息
|
|
|
|
|
if (material == null) {
|
|
|
|
|
beforeF7SelectEvent.setCancel(true);
|
|
|
|
|
this.getView().showMessage("请先填物料信息");
|
|
|
|
|
} else {
|
|
|
|
|
DynamicObject masterid = material.getDynamicObject("masterid");//物料
|
|
|
|
|
DynamicObject bd_materialinventoryinfo = BusinessDataServiceHelper.loadSingle("bd_materialinventoryinfo", new QFilter[]{new QFilter("masterid", QCP.equals, masterid.getLong("id"))});
|
|
|
|
|
|
|
|
|
|
Boolean enablelot = bd_materialinventoryinfo.getBoolean("enablelot");//是否启用批号管理
|
|
|
|
|
if (enablelot) {
|
|
|
|
|
ListShowParameter param = (ListShowParameter) beforeF7SelectEvent.getFormShowParameter();
|
|
|
|
|
QFilter qF1 = new QFilter("material.number", QCP.equals, masterid.getString("number"));
|
|
|
|
|
param.getListFilterParameter().getQFilters().add(qF1);
|
|
|
|
|
} else {
|
|
|
|
|
beforeF7SelectEvent.setCancel(true);
|
|
|
|
|
this.getView().showMessage("该物料未启用批号管理");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-09-13 09:42:55 +00:00
|
|
|
}
|