package com.yem.wm.sys.formplugin.form;

import kd.bos.bill.AbstractBillPlugIn;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.entity.datamodel.IDataModel;
import kd.bos.form.IFormView;
import kd.bos.form.events.BeforeDoOperationEventArgs;
import kd.bos.form.operate.FormOperate;

/**
 * @author zhouc
 * @date 2024/1/30 17:21
 * @className PushNewVersionForm
 * @description 变更单未审核时，不允许下推单据
 */
public class PushNewVersionForm extends AbstractBillPlugIn {
    @Override
    public void beforeDoOperation(BeforeDoOperationEventArgs e) {
        super.beforeDoOperation(e);
        FormOperate operate = (FormOperate) e.getSource();
        String OperateKey = operate.getOperateKey();
        DynamicObject dataEntity = this.getModel().getDataEntity(true);
        IFormView view = this.getView();
        IDataModel model = this.getModel();
        if("push".equals(OperateKey)){
            boolean yem_changing = dataEntity.getBoolean("yem_changing");
            if(yem_changing){
                this.getView().showErrorNotification("当前单据正在变更中，禁止下推！");
               e.setCancel(true);
            }
        }
    }
}
