import { _ as q } 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 L } from "./BasicForm-dL_oCSPM.js";
import { u as $ } from "./useForm-CKmgcynv.js";
import { c as z, __tla as __tla_0 } from "./modalSchemas-dKMYM0AT.js";
import { H as E, t as G, v as U, w as j } from "./template-rpthWlT9.js";
import { f as A } from "./helper-Czt-QYps.js";
import { d as H, V as W, r as s, c as Y, o as Z, l as r, w as T, j as v, ed as J, ac as x, cZ as K, __tla as __tla_1 } from "./index-9PRMimni.js";
import { u as Q } from "./useModal-CO65vga3.js";
import { o as X } from "./omit-B2_8Y6O_.js";
let ue;
let __tla = Promise.all([
    (()=>{
        try {
            return __tla_0;
        } catch  {}
    })(),
    (()=>{
        try {
            return __tla_1;
        } catch  {}
    })()
]).then(async ()=>{
    ue = H({
        __name: "Modal",
        emits: [
            "success",
            "changeResult"
        ],
        setup (ee, { expose: h, emit: g }) {
            const p = g, d = K(), { t: i } = W(), n = s(), { schemasPsc: _, methodsPsc: y } = z(), { setDefectList: I } = y, [R, { submit: b, setFieldsValue: w, getFieldsValue: M }] = $({
                schemas: _,
                labelWidth: "auto",
                layout: "horizontal",
                gridProps: {
                    cols: 2,
                    xGap: 15
                },
                showActionButtonGroup: !1
            }), P = s(), f = s(), a = s({}), c = s(""), m = s(""), [B, { openModal: D, closeModal: V, setProps: F, setSubLoading: l }] = Q({
                title: m,
                subBtuText: i("common.okText"),
                cancelText: i("common.cancelText"),
                width: 650
            });
            async function C(o, u, e) {
                D(), c.value = "", n.value = o, f.value = u, P.value = o.reportNum;
                let t = await E({
                    mouId: o.mouCode,
                    item: "",
                    pageNum: 1,
                    pageSize: 1e4
                });
                I(t), e ? (c.value = "edit", m.value = i("common.optionsEditText"), a.value = await G(e.id), a.value.expirationTime && typeof a.value.expirationTime == "string" && (a.value.expirationTime = a.value.expirationTime.split(/T| /)[0])) : (c.value = "add", m.value = i("common.addText"), a.value = {
                    reportNo: o.reportNum
                }), await x(), A({
                    equipmentId: a.value.equipmentId
                }), w({
                    ...a.value,
                    shipId: o.shipId
                });
            }
            async function S() {
                await x();
            }
            const k = s("");
            async function N() {
                try {
                    if (!await b()) return l(!1), !1;
                    const e = {
                        ...M()
                    };
                    if (e.expirationTime) if (typeof e.expirationTime == "string") {
                        const t = e.expirationTime.split(/T| /)[0];
                        e.expirationTime = `${t} 00:00:00`;
                    } else e.expirationTime instanceof Date && (e.expirationTime = `${e.expirationTime.toISOString().split("T")[0]} 00:00:00`);
                    if (delete e.deficiencyPhotoUrlPhoto, c.value === "add") {
                        const t = {
                            ...e,
                            reportId: f.value,
                            shipId: n.value.shipId,
                            auditTypeId: n.value.auditTypeId,
                            reportType: "pscReport",
                            mouCode: n.value.mouCode,
                            status: "new"
                        };
                        await U(t);
                    } else {
                        const t = {
                            ...X(r(a), [
                                "equipmentId",
                                "equipmentValue"
                            ]),
                            ...e
                        };
                        delete t.deficiencyPhotoUrlPhoto, await j(t);
                    }
                    d.success(i("common.saveSuccessText")), l(!1), V(), p("success");
                } catch  {
                    l(!1), d.error(i("common.saveFailedText"));
                } finally{
                    l(!1);
                }
            }
            function O() {
                p("changeResult", n.value, k.value || "Yes");
            }
            return h({
                showModal: C,
                setProps: F,
                getData: S
            }), (o, u)=>{
                const e = J, t = q;
                return Z(), Y(t, {
                    ref: "modalRef",
                    onRegister: r(B),
                    class: "basicModal basicFormModal",
                    onOnOk: N,
                    onOnClose: O
                }, {
                    default: T(()=>[
                            v(e, {
                                class: "h-[700px] px-5"
                            }, {
                                default: T(()=>[
                                        v(r(L), {
                                            onRegister: r(R),
                                            "label-placement": "top"
                                        }, null, 8, [
                                            "onRegister"
                                        ])
                                    ]),
                                _: 1
                            })
                        ]),
                    _: 1
                }, 8, [
                    "onRegister"
                ]);
            };
        }
    });
});
export { ue as _, __tla };
