package com.yem.wm.im.placeexamine.form;

import kd.bos.bill.AbstractBillPlugIn;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.entity.DynamicObjectCollection;
import kd.bos.entity.datamodel.events.ChangeData;
import kd.bos.entity.datamodel.events.PropertyChangedArgs;

import java.util.EventObject;

/**
 * @author zhouc
 * @date 2023/10/12 16:09
 * @className PlaceexamineFormEdit
 * @description 下单审批表单插件
 */
public class PlaceexamineFormEdit extends AbstractBillPlugIn {
    @Override
    public void afterBindData(EventObject e) {
        super.afterBindData(e);
        DynamicObject dataEntity = this.getModel().getDataEntity(true);
        String yem_salesordertype = dataEntity.getString("yem_salesordertype");
        //配件隐藏随机工具包   多功能页签
        if ("yem_es_salesorder_PJ".equals(yem_salesordertype) || "yem_es_salesorder_nmpj".equals(yem_salesordertype)) {
            this.getView().setVisible(false,"yem_tabpageap1","yem_tabpageap2");
        }
    }

    @Override
    public void propertyChanged(PropertyChangedArgs e)
    {
        super.propertyChanged(e);
        String name = e.getProperty().getName();
        ChangeData changeData = e.getChangeSet()[0];
        DynamicObject dataEntity = this.getModel().getDataEntity();
        int rowIndex = changeData.getRowIndex();
        if ("yem_ifreformg".equals(name)) {
            DynamicObjectCollection collection = dataEntity.getDynamicObjectCollection("yem_es_materialinfo");
            DynamicObject object = collection.get(rowIndex);
            object.set("yem_reformdesg", null);
        }
        this.getView().updateView();
    }
}
