package yem.wmc.ydn.formplugin.form;

import kd.bos.entity.datamodel.IDataModel;
import kd.bos.form.CloseCallBack;
import kd.bos.form.FormShowParameter;
import kd.bos.form.ShowType;
import kd.bos.form.events.AfterDoOperationEventArgs;
import kd.bos.form.events.ClosedCallBackEvent;
import kd.bos.form.plugin.AbstractFormPlugin;
import kd.bos.form.plugin.IFormPlugin;

import java.util.HashMap;
import java.util.Map;

import static yem.wmc.ydn.formplugin.dynamic.QueryshipdyDynamicForm.getQueryShipInfo;

/**
 * @author 金亮
 * @date 2024/4/30 17:02
 * @relevantfile 提单（yem_ydn_testbilllad）
 * @description 点击按钮，弹出动态表单，双击选择分录某行之后，自动给 MMSI号 赋值
 * @versions 1.0
 */
public class TestbillladFrom extends AbstractFormPlugin {

    @Override
    public void afterDoOperation(AfterDoOperationEventArgs e) {
        super.afterDoOperation(e);
        String operateKey = e.getOperateKey();
        if(operateKey.equals("shipssearch")){ //船名搜索
            IDataModel model = this.getModel();
            String yemShipname = (String) model.getValue("yem_shipname");//船名
            if (yemShipname.isEmpty()){
                this.getView().showErrorNotification("船名为空");
                return;
            }
            FormShowParameter showParameter = new FormShowParameter();
            showParameter.setFormId("yem_viewshipping");
            showParameter.setCustomParam("shipssearch",yemShipname);
            showParameter.setCloseCallBack(new CloseCallBack((IFormPlugin) this, "shipssearch"));
            showParameter.getOpenStyle().setShowType(ShowType.MainNewTabPage);
            this.getView().showForm(showParameter);
        }
    }

    @Override
    public void closedCallBack(ClosedCallBackEvent c) {
        super.closedCallBack(c);
        Object returnData = c.getReturnData();
        if (returnData != null && c.getActionId().equals("shipssearch")){

        }
    }
}
