import { _ as J } from "./TableSelect.vue_vue_type_script_setup_true_lang-BAU5mgvB.js";
import { V as O, bk as Q, gD as V, d as X, f as Y, r as N, c as F, o as S, l as s, w, j as k, ds as ee, h as T, p as te, A as x, a9 as ae, i as P, D as se, F as ne, W as oe, cZ as le, ac as B, __tla as __tla_0 } from "./index-9PRMimni.js";
import { _ as re } from "./basicModal.vue_vue_type_script_setup_true_lang-CsJydKhW.js";
import "./basicModal.vue_vue_type_style_index_0_lang-8QZP7ApW.js";
import { u as ie } from "./useModal-CO65vga3.js";
import { B as ue } from "./BasicForm-dL_oCSPM.js";
import { u as ce } from "./useForm-CKmgcynv.js";
import { a as de, b as pe } from "./victualingDetail-CLhgLkA4.js";
import { g as me } from "./goodsReceiptNoteDetail-DWFnSNrx.js";
import { f as R, __tla as __tla_1 } from "./helper-DMSByp-X.js";
import { g as ge } from "./equipmentMainLibrary-bJTzj5mC.js";
import { _ as fe } from "./Flex-CTSf12gq.js";
let Be;
let __tla = Promise.all([
    (()=>{
        try {
            return __tla_0;
        } catch  {}
    })(),
    (()=>{
        try {
            return __tla_1;
        } catch  {}
    })()
]).then(async ()=>{
    function he({ data: o, standardInfo: v }) {
        return o ? {
            ...o,
            total: o.total ? +o.total : void 0
        } : {};
    }
    const De = await ge("finance_ship_ledger_belong"), W = Q(), { t: e } = O(), be = {
        gridProps: {
            cols: "2"
        },
        labelWidth: 80,
        submitButtonText: e("common.searchText"),
        showAdvancedButton: !1,
        schemas: [
            {
                field: "namePrefix",
                component: "NInput",
                label: e("common.portModal.port")
            }
        ]
    };
    function we() {
        return [
            {
                title: e("common.portModal.port"),
                key: "port"
            },
            {
                title: e("common.portModal.country"),
                key: "country"
            }
        ];
    }
    function ve({ startDate: o, endDate: v, standardInfo: _ }) {
        return [
            {
                field: "id",
                hidden: !0
            },
            {
                field: "breakfastStandard",
                hidden: !0
            },
            {
                field: "lunchStandard",
                hidden: !0
            },
            {
                field: "dinnerStandard",
                hidden: !0
            },
            {
                field: "detailDate",
                component: "NDatePicker",
                label: e("victualingDetail.crewGuestDetails.guestModal.date"),
                defaultValue: o ? R(o) : void 0,
                componentProps: {
                    type: "date",
                    valueFormat: "yyyy-MM-dd",
                    placeholder: e("victualingDetail.crewGuestDetails.guestModal.date"),
                    isDateDisabled: (t)=>{
                        if (o && v) {
                            const l = V(R(o)), r = V(R(v));
                            return t < l.toDate() || t > r.toDate();
                        }
                    }
                },
                rules: [
                    {
                        required: !0,
                        message: e("victualingDetail.crewGuestDetails.guestModal.dateRequired")
                    }
                ]
            },
            {
                field: "port",
                label: e("victualingDetail.crewGuestDetails.guestModal.port"),
                slot: "portSlot",
                rules: [
                    {
                        required: !0,
                        message: e("victualingDetail.crewGuestDetails.guestModal.portRequired")
                    }
                ]
            },
            {
                field: "person",
                component: "NInputNumber",
                label: e("victualingDetail.crewGuestDetails.guestModal.persons"),
                componentProps: {
                    placeholder: e("victualingDetail.crewGuestDetails.guestModal.persons"),
                    style: {
                        width: "100%"
                    },
                    precision: 0,
                    step: 1,
                    min: 1
                },
                rules: [
                    {
                        required: !0,
                        type: "number",
                        message: e("victualingDetail.crewGuestDetails.guestModal.personsRequired")
                    }
                ]
            },
            {
                field: "belong",
                component: "NSelect",
                label: e("victualingDetail.crewGuestDetails.guestModal.toWhich"),
                componentProps: {
                    placeholder: e("victualingDetail.crewGuestDetails.guestModal.toWhich"),
                    labelField: W.getLocale === "en" ? "labelEn" : "label",
                    options: De
                },
                rules: [
                    {
                        required: !0,
                        message: e("victualingDetail.crewGuestDetails.guestModal.toWhichRequired")
                    }
                ]
            },
            {
                field: "guest",
                component: "NInput",
                giProps: {
                    span: 4
                },
                label: e("victualingDetail.crewGuestDetails.guestModal.guest"),
                componentProps: {
                    placeholder: e("victualingDetail.crewGuestDetails.guestModal.guest"),
                    type: "textarea",
                    showCount: !0,
                    maxlength: 1e3,
                    autosize: {
                        minRows: 3,
                        maxRows: 3
                    }
                },
                rules: [
                    {
                        required: !0,
                        message: e("victualingDetail.crewGuestDetails.guestModal.guestRequired")
                    }
                ]
            },
            {
                field: "breakfast",
                component: "NInputNumber",
                label: e("victualingDetail.crewGuestDetails.guestModal.breakfast"),
                componentProps: ({ model: t, formAction: l })=>({
                        placeholder: e("victualingDetail.crewGuestDetails.guestModal.breakfast"),
                        style: {
                            width: "100%"
                        },
                        precision: 0,
                        step: 1,
                        min: 1,
                        onUpdateValue: (r)=>{
                            const { guestStandard: a } = _, c = r || 0, p = Number((a.breakfast || 0) * (c || 0)) || 0, m = t.lunch || 0, g = Number((a.lunch || 0) * (m || 0)) || 0, f = t.dinner || 0, d = Number((a.dinner || 0) * (f || 0)) || 0, i = +Number(p + g + d).toFixed(2);
                            l?.setFieldsValue({
                                total: i
                            });
                        }
                    }),
                rules: [
                    {
                        required: !0,
                        type: "number",
                        message: e("victualingDetail.crewGuestDetails.guestModal.breakfastRequired")
                    }
                ]
            },
            {
                field: "lunch",
                component: "NInputNumber",
                label: e("victualingDetail.crewGuestDetails.guestModal.lunch"),
                componentProps: ({ model: t, formAction: l })=>({
                        placeholder: e("victualingDetail.crewGuestDetails.guestModal.lunch"),
                        style: {
                            width: "100%"
                        },
                        precision: 0,
                        step: 1,
                        min: 1,
                        onUpdateValue: (r)=>{
                            const { guestStandard: a } = _, c = t.breakfast || 0, p = Number((a.breakfast || 0) * (c || 0)) || 0, m = r || 0, g = Number((a.lunch || 0) * (m || 0)) || 0, f = t.dinner || 0, d = Number((a.dinner || 0) * (f || 0)) || 0, i = +Number(p + g + d).toFixed(2);
                            l?.setFieldsValue({
                                total: i
                            });
                        }
                    }),
                rules: [
                    {
                        required: !0,
                        type: "number",
                        message: e("victualingDetail.crewGuestDetails.guestModal.lunchRequired")
                    }
                ]
            },
            {
                field: "dinner",
                component: "NInputNumber",
                label: e("victualingDetail.crewGuestDetails.guestModal.supper"),
                componentProps: ({ model: t, formAction: l })=>({
                        placeholder: e("victualingDetail.crewGuestDetails.guestModal.supper"),
                        style: {
                            width: "100%"
                        },
                        precision: 0,
                        step: 1,
                        min: 1,
                        onUpdateValue: (r)=>{
                            const { guestStandard: a } = _, c = t.breakfast || 0, p = Number((a.breakfast || 0) * (c || 0)) || 0, m = t.lunch || 0, g = Number((a.lunch || 0) * (m || 0)) || 0, f = r || 0, d = Number((a.dinner || 0) * (f || 0)) || 0, i = +Number(p + g + d).toFixed(2);
                            l?.setFieldsValue({
                                total: i
                            });
                        }
                    }),
                rules: [
                    {
                        required: !0,
                        type: "number",
                        message: e("victualingDetail.crewGuestDetails.guestModal.supperRequired")
                    }
                ]
            },
            {
                field: "total",
                component: "NInputNumber",
                label: e("victualingDetail.crewGuestDetails.guestModal.ttl"),
                componentProps: {
                    disabled: !0,
                    placeholder: e("victualingDetail.crewGuestDetails.guestModal.ttl"),
                    style: {
                        width: "100%"
                    },
                    precision: 2,
                    step: .01,
                    min: 0
                }
            },
            {
                field: "remark",
                component: "NInput",
                giProps: {
                    span: 4
                },
                label: e("victualingDetail.crewGuestDetails.guestModal.remark"),
                componentProps: {
                    placeholder: e("victualingDetail.crewGuestDetails.guestModal.remark"),
                    type: "textarea",
                    showCount: !0,
                    maxlength: 1e3,
                    autosize: {
                        minRows: 3,
                        maxRows: 3
                    }
                },
                rules: [
                    {
                        required: !0,
                        message: e("victualingDetail.crewGuestDetails.guestModal.remarkRequired")
                    }
                ]
            }
        ];
    }
    let _e, Me, ke, xe;
    _e = {
        class: "text-[16px] text-gray-600"
    };
    Me = {
        class: "text-[16px] font-medium text-[#0EC06A]"
    };
    ke = {
        class: "text-[16px] text-gray-600"
    };
    xe = {
        key: 0
    };
    Be = X({
        __name: "index",
        props: {
            standardInfo: {}
        },
        emits: [
            "refresh",
            "refreshSummary"
        ],
        setup (o, { expose: v, emit: _ }) {
            const { t } = O(), l = le(), r = Y(), a = o, c = _, { year: p, month: m, startDate: g, endDate: f } = r.query, d = N("add"), i = N({}), y = N({}), z = N({});
            function L(n) {
                z.value = n;
            }
            function U(n) {
                return me({
                    ...n,
                    ...s(y)
                });
            }
            const [A, { openModal: E, closeModal: j, setSubLoading: q }] = ie({
                title: t("victualingDetail.crewGuestDetails.guestModal.title"),
                subBtuText: t("common.okText"),
                cancelText: t("common.cancelText"),
                width: 1e3
            }), [$, { submit: K, setFieldsValue: I }] = ce({
                schemas: ve({
                    startDate: g,
                    endDate: f,
                    standardInfo: a.standardInfo
                }),
                labelWidth: "auto",
                layout: "horizontal",
                gridProps: {
                    cols: 4
                },
                showActionButtonGroup: !1
            });
            async function Z() {
                try {
                    const n = await K();
                    if (!n) {
                        q(!1);
                        return;
                    }
                    const u = {
                        add: pe,
                        edit: de
                    }[d.value];
                    await u({
                        ...n,
                        year: p,
                        month: m
                    }), l.success(t("common.saveSuccessText")), q(!1), c("refresh"), c("refreshSummary"), j();
                } catch (n) {
                    console.error(n), q(!1);
                }
            }
            async function H({ type: n, data: u } = {
                type: "add"
            }) {
                if (d.value = n ?? "add", E(), n === "add") {
                    const { guestStandard: C = {} } = a.standardInfo, { breakfast: b, lunch: G, dinner: h } = C;
                    B(()=>{
                        i.value = {
                            breakfast: b,
                            lunch: G,
                            dinner: h
                        }, I({
                            breakfastStandard: b,
                            lunchStandard: G,
                            dinnerStandard: h
                        });
                    });
                } else B(()=>{
                    i.value = {
                        breakfast: u?.breakfastStandard,
                        lunch: u?.lunchStandard,
                        dinner: u?.dinnerStandard
                    }, I(he({
                        data: u,
                        standardInfo: a.standardInfo
                    }));
                });
            }
            return v({
                handleOpenModal: H
            }), (n, u)=>{
                const C = J, b = fe, G = oe;
                return S(), F(s(re), {
                    onRegister: s(A),
                    onOnOk: Z
                }, {
                    default: w(()=>[
                            k(s(ue), {
                                onRegister: s($)
                            }, {
                                portSlot: w(({ model: h, field: M })=>[
                                        k(C, {
                                            class: "w-full",
                                            labelField: "port",
                                            valueField: "id",
                                            value: h[M],
                                            "onUpdate:value": (D)=>h[M] = D,
                                            formValues: s(y),
                                            "onUpdate:formValues": u[0] || (u[0] = (D)=>ee(y) ? y.value = D : null),
                                            onChange: L,
                                            multiple: !1,
                                            formProps: s(be),
                                            disabled: !1,
                                            selectTitle: s(t)("victualingDetail.crewGuestDetails.guestModal.selectPort"),
                                            tableProps: {
                                                rowKey: (D)=>D.id,
                                                request: U,
                                                columns: s(we)(),
                                                pagination: {
                                                    simple: !0
                                                }
                                            }
                                        }, null, 8, [
                                            "value",
                                            "onUpdate:value",
                                            "formValues",
                                            "formProps",
                                            "selectTitle",
                                            "tableProps"
                                        ])
                                    ]),
                                _: 1
                            }, 8, [
                                "onRegister"
                            ]),
                            k(G, {
                                bordered: !1,
                                class: "proCard mt-2",
                                "content-class": "px-0 pt-0"
                            }, {
                                default: w(()=>[
                                        k(b, {
                                            size: 30
                                        }, {
                                            default: w(()=>[
                                                    k(b, {
                                                        align: "center",
                                                        class: "text-[16px]",
                                                        size: 10
                                                    }, {
                                                        default: w(()=>[
                                                                te(x(s(t)("victualingDetail.crewGuestDetails.guestModal.remarksInfo.remarks")) + ": ", 1)
                                                            ]),
                                                        _: 1
                                                    }),
                                                    (S(!0), T(ne, null, ae(s(i), (h, M, D)=>(S(), F(b, {
                                                            align: "center",
                                                            key: M,
                                                            class: "text-[16px]",
                                                            size: 10
                                                        }, {
                                                            default: w(()=>[
                                                                    P("span", _e, x(s(t)(`victualingDetail.crewGuestDetails.guestModal.remarksInfo.${M}`)) + ": ", 1),
                                                                    P("span", Me, x(h), 1),
                                                                    P("span", ke, [
                                                                        P("span", null, x(s(t)("victualingDetail.crewGuestDetails.guestModal.remarksInfo.usd")), 1),
                                                                        s(W).getLocale === "zh_CN" && D + 1 === Object.keys(n.standardInfo.guestStandard).length ? (S(), T("span", xe, x("申请"))) : se("", !0)
                                                                    ])
                                                                ]),
                                                            _: 2
                                                        }, 1024))), 128))
                                                ]),
                                            _: 1
                                        })
                                    ]),
                                _: 1
                            })
                        ]),
                    _: 1
                }, 8, [
                    "onRegister"
                ]);
            };
        }
    });
});
export { Be as _, __tla };
