import { _ as b } from "./basicModal.vue_vue_type_script_setup_true_lang-CsJydKhW.js";
import "./basicModal.vue_vue_type_style_index_0_lang-8QZP7ApW.js";
import { V as p, bk as S, d as v, f as B, r as O, c as q, o as L, l, w as R, j as I, cZ as V, __tla as __tla_0 } from "./index-9PRMimni.js";
import { B as E } from "./Table-0PViRYCf.js";
import { i as j, g as A } from "./victualingDetail-CLhgLkA4.js";
import { f as s, __tla as __tla_1 } from "./helper-DMSByp-X.js";
import { u as F } from "./useModal-CO65vga3.js";
let K;
let __tla = Promise.all([
    (()=>{
        try {
            return __tla_0;
        } catch  {}
    })(),
    (()=>{
        try {
            return __tla_1;
        } catch  {}
    })()
]).then(async ()=>{
    let w, m, W;
    w = S();
    ({ t: m } = p());
    W = ()=>[
            {
                title: m("common.management.Num"),
                key: "num",
                width: 60,
                render: (t, c)=>c + 1
            },
            {
                title: m("victualingDetail.newCrewModal.crew"),
                key: "crewName",
                width: 160,
                render: (t)=>w.getLocale === "en" ? t.crewNameEn : t.crewName
            },
            {
                title: m("victualingDetail.newCrewModal.rank"),
                key: "rankName",
                width: 160,
                render: (t)=>w.getLocale === "en" ? t.rankNameEn : t.rankName
            }
        ];
    K = v({
        __name: "index",
        emits: [
            "refresh"
        ],
        setup (t, { expose: c, emit: h }) {
            const { t: r } = p(), g = V(), _ = h, u = B(), k = O([]), [y, { openModal: D, closeModal: x, setSubLoading: d }] = F({
                title: r("victualingDetail.newCrewModal.title"),
                subBtuText: r("common.okText"),
                cancelText: r("common.cancelText"),
                width: 600
            });
            async function M() {
                const { shipId: n, year: o, month: e, startDate: a, endDate: i } = u.query;
                try {
                    await j({
                        shipId: n,
                        year: o,
                        month: e,
                        startDate: s(a),
                        endDate: s(i)
                    }), g.success(r("common.optionsAddSuccessText")), d(!1), _("refresh"), x();
                } catch  {
                    d(!1);
                }
            }
            function N() {
                const { id: n, shipId: o, year: e, month: a, startDate: i, endDate: f } = u.query;
                return {
                    shipId: o,
                    year: e,
                    month: a,
                    startDate: s(i),
                    endDate: s(f)
                };
            }
            async function C(n, o) {
                try {
                    const e = await A({
                        ...o,
                        ...n
                    });
                    return k.value = e, {
                        list: e,
                        total: e.length
                    };
                } catch  {
                    return {
                        list: [],
                        total: 0
                    };
                }
            }
            function T() {
                D();
            }
            return c({
                handleOpenModal: T
            }), (n, o)=>{
                const e = b;
                return L(), q(e, {
                    onRegister: l(y),
                    onOnOk: M
                }, {
                    default: R(()=>[
                            I(l(E), {
                                columns: l(W)(),
                                request: (a)=>C(a, N()),
                                "row-key": (a)=>a.id,
                                autoScrollX: !0,
                                showTableSetting: !1,
                                "virtual-scroll": "",
                                "max-height": 400,
                                pagination: !1
                            }, null, 8, [
                                "columns",
                                "request",
                                "row-key"
                            ])
                        ]),
                    _: 1
                }, 8, [
                    "onRegister"
                ]);
            };
        }
    });
});
export { K as _, __tla };
