package nckd.jimin.jyyy.hr.tsc.tso.formplugin.web.offer.cardinfo;

import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.entity.DynamicObjectCollection;
import kd.bos.entity.datamodel.IDataModel;
import kd.bos.form.plugin.AbstractFormPlugin;
import kd.bos.orm.query.QCP;
import kd.bos.orm.query.QFilter;
import kd.bos.servicehelper.QueryServiceHelper;
import kd.sdk.plugin.Plugin;
import kd.tsc.tso.formplugin.web.offer.AbstractOfferDynamicFramePlugin;
import kd.tsc.tso.formplugin.web.offer.cardinfo.OfferInfoCardPlugin;

import java.math.BigDecimal;
import java.util.EventObject;

/**
 * 候选人管理-Offer卡片动态表单插件
 * 携带二开字段
 * Tyx
 * 2025-07-29
 */
public class OfferInfoCardPluginEx extends AbstractOfferDynamicFramePlugin {

    @Override
    public void beforeBindData(EventObject e) {
        super.beforeBindData(e);
        IDataModel model = this.getModel();
        int rowCount = model.getEntryRowCount("offer_entity");
        String selectFields = "nckd_zzhnx,nckd_ncoefficient,nckd_sxqxs,nckd_sxqyx,nckd_syqxs,nckd_nzjl";
        for(int i = 0; i < rowCount; i++) {
            String offerNumber = model.getValue("offer_number", i).toString();
            //获取Offer上字段
            QFilter filter = new QFilter("number", QCP.equals, offerNumber);
            DynamicObject offerDyn = QueryServiceHelper.queryOne("tso_somk_offerbase", selectFields, new QFilter[]{filter});
            model.setValue("nckd_zzhnx",offerDyn.getBigDecimal("nckd_zzhnx"), i);
            model.setValue("nckd_ncoefficient",offerDyn.getBigDecimal("nckd_ncoefficient"), i);
            model.setValue("nckd_sxqxs",offerDyn.getBigDecimal("nckd_sxqxs"), i);
            model.setValue("nckd_sxqyx",offerDyn.getBigDecimal("nckd_sxqyx"), i);
            model.setValue("nckd_syqxs",offerDyn.getBigDecimal("nckd_syqxs"), i);
            model.setValue("nckd_nzjl",offerDyn.getBigDecimal("nckd_nzjl"), i);
        }
    }

    @Override
    public void afterBindData(EventObject e) {
        super.afterBindData(e);
    }
}