package nckd.jxccl.hr.tsc.plugin.form.position;

import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.utils.ObjectUtils;
import kd.bos.entity.datamodel.events.PropertyChangedArgs;
import kd.bos.form.plugin.AbstractFormPlugin;
import kd.sdk.plugin.Plugin;

/**
 * 动态表单插件
 */
public class PositionBillFromPluginEx extends AbstractFormPlugin implements Plugin {

    /**
     * 携带所属行政组织->用人部门(多选）
     * @param e
     */
    @Override
    public void propertyChanged(PropertyChangedArgs e) {
        super.propertyChanged(e);
        String key = e.getProperty().getName();
        if(key.equals("adminorg")) {
            DynamicObject value = (DynamicObject) e.getChangeSet()[0].getNewValue();
            if(!ObjectUtils.isEmpty(value)) {
                Long[] ids = new Long[1];
                ids[0] = value.getLong("id");
                this.getModel().setValue("adminorgsdpt", ids);
            }
            else {
                this.getModel().setValue("adminorgsdpt", null);
            }
        }
    }
}