package com.yem.tws.form;

import kd.bos.bill.AbstractBillPlugIn;
import kd.bos.dataentity.entity.LocaleString;
import kd.bos.entity.EntityMetadataCache;
import kd.bos.entity.EntityTypeUtil;
import kd.bos.entity.MainEntityType;
import kd.bos.entity.datamodel.events.PropertyChangedArgs;
import kd.bos.form.control.events.ItemClickListener;
import kd.bos.form.field.ComboEdit;
import kd.bos.form.field.ComboItem;
import kd.sdk.plugin.Plugin;

import java.util.*;

/**
 * @author zhouc
 * @date 2023/7/22 10:43
 * @className InvoicingRemarksEdit
 * @description
 */
public class InvoicingRemarksEdit extends AbstractBillPlugIn implements Plugin, ItemClickListener {

    @Override
    public void afterBindData(EventObject e) {
        super.afterBindData(e);
        // 初始化实体字段选择下拉框
        ComboEdit comboEdit = this.getControl("yem_customsfield");
        ComboEdit comboEdit1 = this.getControl("yem_customsfield1");
        ComboEdit comboEdit2 = this.getControl("yem_customsfield2");
        List<ComboItem> data = new ArrayList<>();
        MainEntityType entityType = EntityMetadataCache.getDataEntityType("yem_ca_cusdec");
        EntityTypeUtil helper = new EntityTypeUtil();
        // 字段标识
        List cols = helper.getFilterColumns(entityType, true);
        Iterator colsIterator = cols.iterator();
        while (colsIterator.hasNext()) {
            Map indexs = (Map) colsIterator.next();
            String fieldName = (String) indexs.get("fieldName");
            String fieldCaption = (String) indexs.get("fieldCaption");
            data.add(new ComboItem(new LocaleString("" + fieldCaption + ""), "" + fieldName + ""));
        }
        comboEdit.setComboItems(data);
        comboEdit1.setComboItems(data);
        comboEdit2.setComboItems(data);

    }

    @Override
    public void click(EventObject evt) {
        super.click(evt);
    }

    @Override
    public void propertyChanged(PropertyChangedArgs e) {
        super.propertyChanged(e);
    }
}
