package com.yem.wm.im.intauditbusa.op;

import com.yem.wm.im.intauditbusa.validator.IntAuditBuSaDelValidator;
import com.yem.wm.utils.FunctionalCommon;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
import kd.bos.entity.plugin.AddValidatorsEventArgs;
import kd.bos.entity.plugin.PreparePropertysEventArgs;
import kd.bos.entity.plugin.args.EndOperationTransactionArgs;
import kd.bos.entity.plugin.args.ValidatePrefixArgs;

import java.util.List;

/**
 * @author xwudd
 * @date 20:15
 * @Description
 **/
public class IntAuditBuSaDelOp extends AbstractOperationServicePlugIn {

    @Override
    public void validatePrefix(ValidatePrefixArgs validatePrefixArgs) {
        super.validatePrefix(validatePrefixArgs);
    }

    @Override
    public void onPreparePropertys(PreparePropertysEventArgs e) {
        List<String> fieldKeys = e.getFieldKeys();
        fieldKeys.add("yem_sourcebilltype");
        fieldKeys.add("yem_sourcebillid");
        fieldKeys.add("yem_sourceentryid");
        fieldKeys.add("yem_needbillintauditno");
    }

    @Override
    public void endOperationTransaction(EndOperationTransactionArgs e) {
        super.endOperationTransaction(e);
        DynamicObject[] dataEntities = e.getDataEntities();
        for(DynamicObject dataEntitie : dataEntities){
            FunctionalCommon.delDetailRowCalcuInfo(dataEntitie);
        }
    }


    @Override
    public void onAddValidators(AddValidatorsEventArgs e) {
        super.onAddValidators(e);
        e.addValidator(new IntAuditBuSaDelValidator());
    }
}
