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.viewName || !param.taskId) {
      context.dom.$Message.info("请配置跳转页面的参数");
      return;
    }
    const uuid = getUUID();
    const billState = param.canEdit ? '': 'readOnly'
    let index = context.selects[0]._index||(context.selects[0]._serialIndex)*1-1;
    setQueryTag(context.currentDataQueryConditionSet,index,param.viewName,uuid);//上张下张用 
    let templateName = param.viewName;
    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 {
      GMS.$hideContainer.addComponent(typesBill, {}, function(c) {
        c.templateName = templateName;
        c.billId = billId;
        c.state = billState;
        c.init = true;
        c.modal_visible = true;
      });
    }
  },
};