133 lines
		
	
	
		
			6.6 KiB
		
	
	
	
		
			Java
		
	
	
	
			
		
		
	
	
			133 lines
		
	
	
		
			6.6 KiB
		
	
	
	
		
			Java
		
	
	
	
package tqq9.lc123.cloud.app.plugin.form.pm;
 | 
						|
 | 
						|
import kd.bos.bill.AbstractBillPlugIn;
 | 
						|
import kd.bos.bill.BillShowParameter;
 | 
						|
import kd.bos.dataentity.OperateOption;
 | 
						|
import kd.bos.dataentity.entity.DynamicObject;
 | 
						|
import kd.bos.dataentity.entity.DynamicObjectCollection;
 | 
						|
import kd.bos.dataentity.utils.StringUtils;
 | 
						|
import kd.bos.entity.operate.result.OperationResult;
 | 
						|
import kd.bos.form.CloseCallBack;
 | 
						|
import kd.bos.form.ShowType;
 | 
						|
import kd.bos.form.events.BeforeDoOperationEventArgs;
 | 
						|
import kd.bos.form.events.ClosedCallBackEvent;
 | 
						|
import kd.bos.form.field.BasedataEdit;
 | 
						|
import kd.bos.form.field.events.BeforeF7SelectEvent;
 | 
						|
import kd.bos.form.field.events.BeforeF7SelectListener;
 | 
						|
import kd.bos.form.operate.FormOperate;
 | 
						|
import kd.bos.list.ListShowParameter;
 | 
						|
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;
 | 
						|
import kd.bos.servicehelper.operation.OperationServiceHelper;
 | 
						|
import kd.bos.servicehelper.operation.SaveServiceHelper;
 | 
						|
import tqq9.lc123.cloud.app.api.utils.Constants;
 | 
						|
 | 
						|
import java.util.EventObject;
 | 
						|
import java.util.HashMap;
 | 
						|
 | 
						|
/**
 | 
						|
 * 采购退货界面插件
 | 
						|
 */
 | 
						|
public class PurRefundApplyBillPlugin extends AbstractBillPlugIn implements BeforeF7SelectListener {
 | 
						|
    private final static Log logger = LogFactory.getLog(PurorderEntryIntroPaybillPlugin.class);
 | 
						|
 | 
						|
    @Override
 | 
						|
    public void registerListener(EventObject e) {
 | 
						|
        super.registerListener(e);
 | 
						|
        this.addItemClickListeners("tbmain");
 | 
						|
        BasedataEdit control = this.getControl("tqq9_ph");
 | 
						|
        control.addBeforeF7SelectListener(this);
 | 
						|
//        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();
 | 
						|
    }
 | 
						|
 | 
						|
    /**
 | 
						|
     * 异地退货返回事件
 | 
						|
     */
 | 
						|
 | 
						|
 | 
						|
    @Override
 | 
						|
    public void beforeDoOperation(BeforeDoOperationEventArgs args) {
 | 
						|
        super.beforeDoOperation(args);
 | 
						|
        FormOperate Operate = (FormOperate) args.getSource();
 | 
						|
        Boolean tqq9_isydth = (Boolean) this.getModel().getValue("tqq9_isydth");//是否异地退货
 | 
						|
        DynamicObject tqq9_yythbillno = (DynamicObject) this.getModel().getValue("tqq9_yythbillno");//异地退货单号
 | 
						|
        String tqq9_ydthno = null;
 | 
						|
        if (tqq9_yythbillno != null) {
 | 
						|
            tqq9_ydthno = tqq9_yythbillno.getString("billno");
 | 
						|
        }
 | 
						|
        if (StringUtils.equals("save", Operate.getOperateKey()) && tqq9_isydth && StringUtils.isBlank(tqq9_ydthno)) {
 | 
						|
            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);
 | 
						|
        } 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 + "未提交");
 | 
						|
            }
 | 
						|
        } else if (StringUtils.equals("audit", Operate.getOperateKey()) && tqq9_isydth && StringUtils.isNotBlank(tqq9_ydthno)) {
 | 
						|
            DynamicObject tqq9_otheroutapply = BusinessDataServiceHelper.loadSingle("tqq9_otheroutapply", new QFilter[]{new QFilter("billno", QCP.equals, tqq9_ydthno)});
 | 
						|
            String billstatus = tqq9_otheroutapply.getString("billstatus");
 | 
						|
            if (StringUtils.equals("B", billstatus)) {
 | 
						|
                OperateOption operateOption = OperateOption.create();
 | 
						|
                OperationResult auditResult = OperationServiceHelper.executeOperate(Constants.TYPE_AUDIT, "tqq9_otheroutapply", new DynamicObject[]{tqq9_otheroutapply}, operateOption);
 | 
						|
                if (auditResult.isSuccess()) {
 | 
						|
                    this.getView().showMessage("异地退货审核成功");
 | 
						|
                }
 | 
						|
            }
 | 
						|
        }
 | 
						|
    }
 | 
						|
 | 
						|
 | 
						|
    /**
 | 
						|
     * 出库批号根据了做筛选
 | 
						|
     */
 | 
						|
 | 
						|
    @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("该物料未启用批号管理");
 | 
						|
            }
 | 
						|
 | 
						|
        }
 | 
						|
    }
 | 
						|
} |