import typesBill from "../components-control/typesBill.vue";
import { getUUID } from "./util/lib.js";
import {setQueryTag} from './util/queryTag.js';
export default {
  execute(context, param) {
    if (!param.billId || !param.taskId) {
      context.dom.$Message.info("请配置跳转页面的参数");
      return;
    }
    const uuid = getUUID();
    const billState = param.canEdit ? '': 'readOnly';
    let templateName = param.billName ? context.selects[0][param.billName]:param.viewName;
    if(!templateName){
      context.dom.$Message.info("请配置跳转页面的参数");
      return;
    }
    let index = context.selects[0]._index||(context.selects[0]._serialIndex)*1-1;
    setQueryTag(context.currentDataQueryConditionSet,index,templateName,uuid);//上张下张用 
    let billId = context.selects[0][param.billId];
    window.GMS.workflowTaskId = context.selects[0][param.taskId]
    if (
      window.osConfig.appOpenMode &&
      window.osConfig.appOpenMode == "apploader"
    ) {
      GMS.$hideContainer.$portalAPI.emit(
        "open-new-page", //打开一个新的页签
        uuid,
        "runner-bill-form",
        {
          templateName: templateName,
          id: billId,
          state: billState
        },
        {
          openWay: "FUNCTAB",
          title: param.displayName || "单据审批",
        }
      );
    } else {
      let component = null;
      let name = GMS.$hideContainer.addComponent(typesBill, {}, function(c) {
        component = c;
        c.templateName = templateName;
        c.billId = billId;
        c.state = billState;
        c.init = true;
        c.modal_visible = true;
        c.$nextTick(()=>{
          component.addListener({
            close: function() {
              GMS.$hideContainer.remove(name);
            }
          });
        })
      });
    }
  },
};