import typesBill from "../../components-control/typesBill.vue";
import {getUUID} from "../util/lib.js";

/**
 * 查看原单
 * jump2BillTemplate
 */
export default {
    execute(context, param) {
        if (!param.billId || !param.viewName) {
            context.dom.$Message.info("查看原单按钮尚未配置按钮参数");
            return;
        }
        let billId = context.selects[0][param.billId]
        let billTemplateName = context.selects[0][param.viewName]
        if (window.osConfig.appOpenMode && window.osConfig.appOpenMode === "apploader") {
            GMS.$hideContainer.$portalAPI.emit(
                "open-new-page",
                getUUID(),
                "gms-app-runner-bill-form",
                {
                    templateName: billTemplateName,
                    id: billId,
                    state: 'readOnly'
                },
                {
                    openWay: "FUNCTAB",
                    title: "单据详情",
                }
            );
        } else {
            GMS.$hideContainer.addComponent(typesBill, {}, function (c) {
                c.templateName = billTemplateName;
                c.billId = billId;
                c.init = true;
                c.modal_visible = true;
                c.isReadOnly = true;
            });
        }
    },
};
