package yem.wm.cm.fwdb.form;

import kd.bos.bill.AbstractBillPlugIn;
import kd.bos.form.control.Toolbar;
import kd.bos.form.control.events.ItemClickEvent;

import java.util.EventObject;

public class ClickButtonOpenURLBill extends AbstractBillPlugIn {
    @Override
    public void registerListener(EventObject e) {
        Toolbar yemOpenmobilurl = (Toolbar)this.getControl("yem_openmobilurl");
        if(yemOpenmobilurl != null) {
            yemOpenmobilurl.addItemClickListener(this);
        }
        this.addItemClickListeners(new String[]{"tbmain"});
    }
    

    @Override
    public void itemClick(ItemClickEvent evt) {
        super.itemClick(evt);
        String itemKey = evt.getItemKey();
        String pcURL = (String)this.getModel().getValue("yem_pcaddress");
        String mobURL = (String)this.getModel().getValue("yem_mobileaddress");

        switch (itemKey){
            case "yem_openpcurl":
                this.getView().openUrl(pcURL);
                break;
            case "yem_openmobilurl":
                this.getView().openUrl(mobURL);
                break;
        }
    }
}
