package com.yem.wm.es.exportpresent;

import com.yem.wm.es.contractamtlist.util.FunUtil;
import com.yem.wm.utils.FunctionalCommon;
import kd.bos.bill.AbstractBillPlugIn;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.entity.datamodel.IDataModel;
import kd.bos.entity.datamodel.events.PropertyChangedArgs;
import kd.bos.form.IFormView;
import kd.bos.form.control.Control;
import kd.bos.form.events.AfterDoOperationEventArgs;
import kd.bos.form.field.FieldEdit;

/**
 * @author xwudd
 * @Description
 * @date 16:41
 **/
public class ExportPresentEdit extends AbstractBillPlugIn
{
    @Override
    public void afterDoOperation(AfterDoOperationEventArgs e)
    {
        super.afterDoOperation(e);
        IFormView view = this.getView();
        String operateKey = e.getOperateKey();
        switch (operateKey) {
            case "contractamtview":
                FunUtil.viewForm("yem_contractamtlistrealit", null, view);
                break;
        }
    }

    @Override
    public void propertyChanged(PropertyChangedArgs e)
    {
        super.propertyChanged(e);
        String name = e.getProperty().getName();
        IDataModel model = this.getModel();
        IFormView view = this.getView();
        DynamicObject dataEntity = model.getDataEntity();
        if ("yem_paymenttype".equals(name)) {
            // 款项类型为B 特殊情况 备注必录
            String paymenttype = dataEntity.getString("yem_paymenttype");
            FieldEdit control = view.getControl("yem_remark");
            if ("B".equals(paymenttype)) {
                control.setMustInput(true);
            } else {
                control.setMustInput(false);
            }
        }
    }
}
