import { _ as O } from "./basicModal.vue_vue_type_script_setup_true_lang-CsJydKhW.js";
import "./basicModal.vue_vue_type_style_index_0_lang-8QZP7ApW.js";
import { B as q } from "./BasicForm-dL_oCSPM.js";
import { u as A } from "./useForm-CKmgcynv.js";
import { c as E, __tla as __tla_0 } from "./modalSchemas-DzYfMuRt.js";
import { t as S, v as G, w as P } from "./template-rpthWlT9.js";
import { f as j } from "./helper-Czt-QYps.js";
import { d as z, V as L, r as n, c as W, o as Y, l as r, w as Z, j as $, ac as d, cZ as H, __tla as __tla_1 } from "./index-9PRMimni.js";
import { u as J } from "./useModal-CO65vga3.js";
let ne;
let __tla = Promise.all([
    (()=>{
        try {
            return __tla_0;
        } catch  {}
    })(),
    (()=>{
        try {
            return __tla_1;
        } catch  {}
    })()
]).then(async ()=>{
    ne = z({
        __name: "Modal",
        props: {
            currentType: Number
        },
        emits: [
            "success",
            "changeResult"
        ],
        setup (f, { expose: v, emit: g }) {
            const u = g, h = f, y = H(), { t } = L(), T = n(), c = n(), w = n(""), m = n(), i = n(""), a = n({}), { schemas: R } = E({
                modelType: i
            }), [x, { openModal: I, closeModal: _, setProps: p, setSubLoading: l }] = J({
                title: t("common.addText"),
                subBtuText: t("common.okText"),
                cancelText: t("common.cancelText"),
                width: 800
            }), [M, { submit: b, setFieldsValue: B, getFieldsValue: k }] = A({
                schemas: R,
                labelWidth: "auto",
                layout: "horizontal",
                gridProps: {
                    cols: 3,
                    xGap: 15
                },
                showActionButtonGroup: !1
            });
            function N(e) {
                switch(e){
                    case "0":
                        return "cargoTankReport";
                    case "1":
                        return "companyNavigationalReport";
                    case "2":
                        return "checklistEngineeringReport";
                    case "3":
                        return "companyBunkeringReport";
                    case "4":
                        return "companyMooringReport";
                }
            }
            async function V(e, o, s) {
                i.value = s, c.value = e, m.value = e.id, T.value = e.reportNo, I(), p({
                    title: {
                        add: t("common.addText"),
                        edit: t("common.optionsEditText"),
                        view: t("common.optionsViewText")
                    }[i.value]
                }), o.id ? a.value = await S(o.id) : a.value = {
                    reportNo: e.reportNo,
                    shipId: e.shipId
                }, await d(), a.value.equipmentId && j({
                    equipmentId: a.value.equipmentId
                }), B(a.value);
            }
            async function D() {
                await d();
            }
            async function F() {
                if (!await b()) return l(!1), !1;
                const o = k();
                try {
                    if (i.value === "add") await G({
                        ...o,
                        reportId: m.value,
                        planId: c.value.plannerId,
                        shipId: c.value.shipId,
                        auditTypeId: c.value.visitType,
                        reportType: N(h.currentType + ""),
                        status: "new"
                    });
                    else {
                        const s = {
                            ...a.value,
                            ...o
                        };
                        await P(s);
                    }
                    y.success(t("common.saveSuccessText")), l(!1), _(), u("success");
                } catch  {
                    l(!1);
                }
            }
            function C() {
                u("changeResult", c.value, w.value || "Yes");
            }
            return v({
                showModal: V,
                setProps: p,
                getData: D
            }), (e, o)=>{
                const s = O;
                return Y(), W(s, {
                    ref: "modalRef",
                    showAction: r(i) !== "view",
                    onRegister: r(x),
                    class: "basicModal basicFormModal",
                    onOnOk: F,
                    onOnClose: C
                }, {
                    default: Z(()=>[
                            $(r(q), {
                                onRegister: r(M),
                                "label-placement": "top"
                            }, null, 8, [
                                "onRegister"
                            ])
                        ]),
                    _: 1
                }, 8, [
                    "showAction",
                    "onRegister"
                ]);
            };
        }
    });
});
export { ne as _, __tla };
