package nckd.jimin.jyyy.fi.plugin.form;

import kd.bos.bill.BillOperationStatus;
import kd.bos.bill.BillShowParameter;
import kd.bos.bill.OperationStatus;
import kd.bos.entity.datamodel.ListSelectedRow;
import kd.bos.form.ShowType;
import kd.bos.form.events.BillListHyperLinkClickEvent;
import kd.bos.form.events.HyperLinkClickArgs;
import kd.bos.list.plugin.AbstractListPlugin;

/**
 * 插件描述：列表插件，根据不同页面类型，打开不同的pc布局
 * 表单标识：对公报销单(nckd_er_publicreimbur_ext)
 * @author wanghaiwu_kd
 * @date 2025/05/20
 */
public class PublicReimburseBillListPlugin extends AbstractListPlugin {
    @Override
    public void billListHyperLinkClick(HyperLinkClickArgs args) {
//        super.billListHyperLinkClick(args);

        if ("billno".equals(args.getFieldName())) {
            //获取当前数据行
            BillListHyperLinkClickEvent evt = (BillListHyperLinkClickEvent) args.getHyperLinkClickEvent();
            ListSelectedRow currentRow = evt.getCurrentRow();

            Long billId = (Long) currentRow.getPrimaryKeyValue();
            String billStatus = currentRow.getBillStatus();

            String formId= "er_publicreimbursebill";
            //跳转到指定PC布局
            BillShowParameter showParameter = new BillShowParameter();
            showParameter.setFormId(formId);
            showParameter.setPkId(billId);
            showParameter.getOpenStyle().setShowType(ShowType.MainNewTabPage);

            if("A".equals(billStatus) || "D".equals(billStatus)) {
                showParameter.setStatus(OperationStatus.EDIT);
                showParameter.setBillStatus(BillOperationStatus.EDIT);
            } else {
                showParameter.setStatus(OperationStatus.VIEW);
                showParameter.setBillStatus(BillOperationStatus.VIEW);
            }

            this.getView().showForm(showParameter);
        }
    }
}
