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

import kd.bos.entity.datamodel.ListSelectedRow;
import kd.bos.form.events.BeforeCreateListDataProviderArgs;
import kd.bos.form.events.HyperLinkClickArgs;
import kd.bos.list.BillList;
import kd.bos.list.plugin.AbstractListPlugin;
import kd.bos.servicehelper.workflow.WorkflowServiceHelper;
import kd.sdk.plugin.Plugin;
import nckd.jimin.jyyy.fi.plugin.form.common.CurApproveNodeListProvider;

/**
 * 标准单据列表插件
 */
public class BusTravelCheckBillList extends AbstractListPlugin implements Plugin {
    @Override
    public void beforeCreateListDataProvider(BeforeCreateListDataProviderArgs args) {
        super.beforeCreateListDataProvider(args);
        args.setListDataProvider(new CurApproveNodeListProvider());
    }


    @Override
    public void billListHyperLinkClick(HyperLinkClickArgs args) {
        super.billListHyperLinkClick(args);
        String fieldName = args.getFieldName();
        BillList billList = (BillList) args.getHyperLinkClickEvent().getSource();
        ListSelectedRow selectedRow = billList.getCurrentSelectedRowInfo();
        if("nckd_curapprovenode".equals(fieldName)){
            if(selectedRow != null){
                args.setCancel(true);
                // 打开单据
                WorkflowServiceHelper.viewFlowchart(getView().getPageId(), selectedRow.getPrimaryKeyValue());
            }
        }
    }
}