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) {
      context.dom.$Message.info("请配置跳转页面的参数");
      return;
    }
    const templateName = param.viewName;
    const index = context.selects[0]._index||(context.selects[0]._serialIndex)*1-1;
    const uuid = getUUID();
    setQueryTag(context.currentDataQueryConditionSet,index,templateName,uuid);//上张下张用
    let billId = context.selects[0][param.billId];
    if (
      window.osConfig.appOpenMode &&
      window.osConfig.appOpenMode == "apploader"
    ) {
        GMS.$hideContainer.$portalAPI.emit(
            "open-new-page", //打开一个新的页签
            uuid,
            "runner-bill-form",
            {
              templateName: templateName,
              id: billId,
              state:'readOnly',
              hideButtonGroup: param.hideButton? true: false
            },
            {
              openWay: "FUNCTAB",
              title: param.displayName || "单据详情",
            }
          );
    } else {
      GMS.$hideContainer.addComponent(typesBill, {}, function(c) {
        c.templateName = templateName;
        c.billId = billId;
        c.init = true;
        c.modal_visible = true;
        c.isReadOnly = true;
        c.state = 'readOnly'
        c.hideButtonGroup = param.hideButton? true: false
      });
    }
  },
};