package nckd.jimin.jyyy.hr.swc.hcdm.formplugin.web;

import com.google.common.collect.Lists;
import kd.bos.dataentity.OperateOption;
import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
import kd.bos.entity.plugin.AddValidatorsEventArgs;
import kd.bos.entity.plugin.PreparePropertysEventArgs;
import kd.bos.entity.plugin.args.BeforeOperationArgs;
import kd.hr.hbp.common.util.HRStringUtils;
import kd.sdk.plugin.Plugin;
import kd.tdc.tjga.opplugin.validator.quickchange.BatchChangeGradeLevelSaveValidator;
import nckd.jimin.jyyy.hr.swc.hcdm.formplugin.validator.AdjustJobBillSaveValidator;

/**
 * 单据操作插件
 */
public class AdjustJobBillSaveCheckOp extends AbstractOperationServicePlugIn implements Plugin {
    public void onPreparePropertys(PreparePropertysEventArgs eventArgs) {
        eventArgs.getFieldKeys().addAll(Lists.newArrayList(new String[]{"billstatus", "changeentry"}));
    }

    public void onAddValidators(AddValidatorsEventArgs eventArgs) {
        super.onAddValidators(eventArgs);
        eventArgs.addValidator(new AdjustJobBillSaveValidator());
    }

    public void beforeExecuteOperationTransaction(BeforeOperationArgs e) {
        super.beforeExecuteOperationTransaction(e);
        OperateOption operateOption = this.getOption();
        String isOpCancel = operateOption.getVariableValue("isopcancel", (String)null);
        if (HRStringUtils.equals(isOpCancel, "1")) {
            e.setCancel(true);
        }

    }
}