import { _ as I } 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 N } from "./BasicForm-dL_oCSPM.js";
import { ad as i, gD as r, bk as k, V as A, ac as y, d as w, e as L, c as q, o as B, l as b, w as V, j as T, cZ as Y, __tla as __tla_0 } from "./index-9PRMimni.js";
import { g as j } from "./requisitionOrder-D0IG9N7e.js";
import { u as J } from "./useForm-CKmgcynv.js";
import { u as W } from "./useModal-CO65vga3.js";
let re, le, ne, se, ae, X, oe;
let __tla = Promise.all([
    (()=>{
        try {
            return __tla_0;
        } catch  {}
    })()
]).then(async ()=>{
    const u = "";
    ae = function(e) {
        return i.Post(`${u}/financeShipLedger/page`, e);
    };
    function G(e) {
        return i.Post(`${u}/financeShipLedger`, e);
    }
    ne = function(e) {
        return i.Delete(`${u}/financeShipLedger/${e}`);
    };
    se = function(e) {
        return i.Post(`${u}/financeShipLedger/export`, e);
    };
    oe = await j().then((e)=>e.map((t)=>({
                label: t.shipName,
                labelEn: t.shipNameEn,
                value: t.id
            }))).catch((e)=>(console.error("Error fetching vessel options:", e), []));
    X = [
        {
            label: "一月",
            labelEn: "January",
            value: "1"
        },
        {
            label: "二月",
            labelEn: "February",
            value: "2"
        },
        {
            label: "三月",
            labelEn: "March",
            value: "3"
        },
        {
            label: "四月",
            labelEn: "April",
            value: "4"
        },
        {
            label: "五月",
            labelEn: "May",
            value: "5"
        },
        {
            label: "六月",
            labelEn: "June",
            value: "6"
        },
        {
            label: "七月",
            labelEn: "July",
            value: "7"
        },
        {
            label: "八月",
            labelEn: "August",
            value: "8"
        },
        {
            label: "九月",
            labelEn: "September",
            value: "9"
        },
        {
            label: "十月",
            labelEn: "October",
            value: "10"
        },
        {
            label: "十一月",
            labelEn: "November",
            value: "11"
        },
        {
            label: "十二月",
            labelEn: "December",
            value: "12"
        }
    ];
    re = !1;
    function g(e) {
        const t = parseInt(e.slice(0, 4)), o = parseInt(e.slice(5, 7)), a = r(`${t}-${o}-01`).startOf("month"), l = r(`${t}-${o}-01`).endOf("month");
        return [
            a.format("YYYY-MM-DD"),
            l.format("YYYY-MM-DD")
        ];
    }
    const C = k(), { t: s } = A();
    function Z() {
        return [
            {
                field: "year",
                component: "NDatePicker",
                label: s("shipCashAccount.monthlyShipCashAccount.year"),
                componentProps: ({ model: e, formAction: t })=>(y(()=>{
                        if (!e.year || !e.month) {
                            t.setFieldsValue({
                                dateRange: null
                            });
                            return;
                        }
                        const [o, a] = g(`${e.year}-${e.month}`);
                        t.setFieldsValue({
                            dateRange: [
                                o,
                                a
                            ]
                        });
                    }), {
                        type: "year",
                        valueFormat: "yyyy",
                        placeholder: s("shipCashAccount.monthlyShipCashAccount.year")
                    }),
                rules: [
                    {
                        required: !0,
                        message: s("shipCashAccount.monthlyShipCashAccount.yearRequired")
                    }
                ]
            },
            {
                field: "month",
                component: "NSelect",
                label: s("shipCashAccount.monthlyShipCashAccount.month"),
                componentProps: ({ model: e, formAction: t })=>(y(()=>{
                        if (!e.year || !e.month) {
                            t.setFieldsValue({
                                dateRange: null
                            });
                            return;
                        }
                        const [o, a] = g(`${e.year}-${e.month}`);
                        t.setFieldsValue({
                            dateRange: [
                                o,
                                a
                            ]
                        });
                    }), {
                        labelField: C.getLocale === "en" ? "labelEn" : "label",
                        placeholder: s("shipCashAccount.monthlyShipCashAccount.month"),
                        options: X
                    }),
                rules: [
                    {
                        required: !0,
                        message: s("shipCashAccount.monthlyShipCashAccount.monthRequired")
                    }
                ]
            },
            {
                field: "dateRange",
                component: "NDatePicker",
                label: s("shipCashAccount.monthlyShipCashAccount.dateRange"),
                componentProps: ({ model: e })=>({
                        valueFormat: "yyyy-MM-dd",
                        type: "daterange",
                        placeholder: s("shipCashAccount.monthlyShipCashAccount.dateRange"),
                        isDateDisabled (t) {
                            return !e.year || !e.month ? !0 : e.month === "1" ? r(t).month() !== 11 && r(t).year() !== parseInt(e.year) : r(t).year() !== parseInt(e.year);
                        }
                    }),
                rules: [
                    {
                        required: !0,
                        message: s("shipCashAccount.monthlyShipCashAccount.dateRangeRequired")
                    }
                ]
            }
        ];
    }
    le = w({
        __name: "index",
        emits: [
            "refresh"
        ],
        setup (e, { expose: t, emit: o }) {
            const { t: a } = A(), l = Y(), S = L(), R = o, [D, { submit: E }] = J({
                schemas: Z(),
                labelWidth: "auto",
                gridProps: {
                    cols: 3
                }
            }), [v, { openModal: _, closeModal: F, setSubLoading: h }] = W({
                title: a("shipCashAccount.monthlyShipCashAccount.title"),
                subBtuText: a("common.okText"),
                cancelText: a("common.cancelText"),
                width: 800
            });
            async function $() {
                try {
                    const n = await E();
                    if (!n) {
                        h(!1);
                        return;
                    }
                    const { id: f, shipId: p, year: m, month: M, startDate: O, endDate: P } = await G({
                        year: n.year,
                        month: n.month,
                        startDate: n.dateRange ? n.dateRange[0] : "",
                        endDate: n.dateRange ? n.dateRange[1] : ""
                    }).then((c)=>{
                        const d = C.getLocale === "en" ? "tipNameEn" : "tipName";
                        return c?.hasOwnProperty(d) && c[d] !== null ? (l.warning(c[d]), Promise.reject()) : c;
                    });
                    l.success(a("common.optionsAddSuccessText")), h(!1), R("refresh"), F(), y(()=>{
                        S.push({
                            name: "shipCashAccountDetail",
                            query: {
                                id: f,
                                shipId: p,
                                year: m,
                                month: M,
                                startDate: O,
                                endDate: P,
                                type: "edit"
                            }
                        });
                    });
                } catch  {
                    h(!1);
                }
            }
            function x() {
                _();
            }
            return t({
                handleOpenModal: x
            }), (n, f)=>{
                const p = N, m = I;
                return B(), q(m, {
                    onRegister: b(v),
                    onOnOk: $
                }, {
                    default: V(()=>[
                            T(p, {
                                onRegister: b(D),
                                showActionButtonGroup: !1
                            }, null, 8, [
                                "onRegister"
                            ])
                        ]),
                    _: 1
                }, 8, [
                    "onRegister"
                ]);
            };
        }
    });
});
export { re as I, le as _, ne as d, se as e, ae as g, X as m, oe as v, __tla };
