package nckd.jxccl.hr.hstu.plugin.form;

import kd.bos.dataentity.entity.DynamicObjectCollection;
import kd.bos.form.control.Control;
import kd.bos.form.plugin.AbstractFormPlugin;
import kd.sdk.plugin.Plugin;
import nckd.jxccl.hr.hstu.common.HonorStudentConstant;

import java.util.EventObject;

/**
* 同级评分人组织范围选择（弹窗）插件
* @author W.Y.C
* @date 2025/7/15 14:45
* @version 1.0
*/
public class EvalQuestSelectOrg extends AbstractFormPlugin implements Plugin {

    @Override
    public void registerListener(EventObject e) {
        this.addClickListeners(HonorStudentConstant.BTN_OK_OP);
    }

    @Override
    public void afterCreateNewData(EventObject e) {
        super.afterCreateNewData(e);
        //获取综合评测问卷已选的组织范围赋值到弹窗中
        DynamicObjectCollection mulSelectOrg = this.getView().getParentView().getModel().getDataEntity().getDynamicObjectCollection(HonorStudentConstant.NCKD_MULSELECTORG);
        this.getModel().setValue(HonorStudentConstant.NCKD_MULSELECTORG, mulSelectOrg);
    }

    @Override
    public void click(EventObject evt) {
        Control source = (Control) evt.getSource();
        if (HonorStudentConstant.BTN_OK_OP.equals(source.getKey())) {
            //获取选择的组织范围
            DynamicObjectCollection mulSelectOrg = (DynamicObjectCollection)this.getModel().getValue(HonorStudentConstant.NCKD_MULSELECTORG);
            //将选择的数据返回给父页面
            this.getView().returnDataToParent(mulSelectOrg);
            this.getView().close();
        }
    }

}