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