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

import kd.bos.form.control.AttachmentPanel;
import kd.bos.form.events.BeforeDoOperationEventArgs;
import kd.bos.form.operate.FormOperate;
import kd.bos.form.plugin.AbstractFormPlugin;
import kd.hr.hbp.common.util.HRStringUtils;
import nckd.jxccl.hr.sdm.common.SanDingConstant;

/**
 * 三定任务表单插件
 * @entity: nckd_sandingtask
 * @author: jtd
 * @date: 2025/12/18 20:12
 */
public class SanDingTaskFormPlugin extends AbstractFormPlugin {

    @Override
    public void beforeDoOperation(BeforeDoOperationEventArgs args) {
        super.beforeDoOperation(args);

        FormOperate formOperate = (FormOperate)args.getSource();
        String operateKey = formOperate.getOperateKey();
        if (HRStringUtils.equals(SanDingConstant.SUBMIT_OP, operateKey)) {
            AttachmentPanel attachmentPanel = getControl(SanDingConstant.ATTACHMENTPANEL_KEY);
            if (attachmentPanel.getAttachmentData().isEmpty()) {
                getView().showTipNotification("请按要求上传附件。");
                args.setCancel(true);
            }
        }
    }
}
