import { B as se } from "./BasicForm-dL_oCSPM.js";
import { ad as d, V as x, hc as ne, bk as ae, gL as $, d8 as P, d as ie, ay as le, aw as ce, d9 as V, c as l, o as i, W as ue, w as s, j as c, aE as A, i as de, D as pe, l as n, aI as me, p as b, A as _, B as ge, ca as C, gW as I, gX as W, h as we, S as he, cC as fe, __tla as __tla_0 } from "./index-9PRMimni.js";
import { i as R } from "./isEmpty-BUg1OsQj.js";
import { u as S } from "./useForm-CKmgcynv.js";
let xe, Ie, We, Re, He;
let __tla = Promise.all([
    (()=>{
        try {
            return __tla_0;
        } catch  {}
    })()
]).then(async ()=>{
    const ye = "", w = "";
    Ie = function(t) {
        return d.Post(`${ye}/crewServiceQualification/onboardVacation/list`, t);
    };
    function be(t, r) {
        return d.Get(`${w}/ships/get-by-ship/${t}/${r}`);
    }
    We = function(t) {
        return d.Get(`${w}/scheduleCrewOvertimeSettings/getDatayVesselAndCrew`, {
            params: t
        });
    };
    Re = function(t) {
        return d.Post(`${w}/scheduleCrewOvertimeSettings/save`, t);
    };
    He = function(t) {
        return d.Put(`${w}/scheduleCrewOvertimeSettings/update`, t);
    };
    let o, g, m, k, H, _e, Se, ke, ve, De, Ne, Fe;
    ({ t: o } = x());
    g = ae();
    m = await ne();
    k = m && m.length > 0 ? m[0].id : 0;
    H = await be(k, 2);
    _e = await $("currency");
    Se = await $("schedule_crew_holidays_type");
    ke = ()=>({
            infoSchemas: [
                {
                    field: "vesselId",
                    component: "NSelect",
                    componentProps: {
                        options: m,
                        value: k,
                        "label-field": g.getLocale === "en" ? "shipNameEn" : "shipName",
                        "value-field": "id",
                        disabled: !0
                    },
                    label: o("operation.crewSettings.vessel")
                },
                {
                    field: "rankId",
                    component: "NSelect",
                    componentProps: {
                        options: H ? H.map((r)=>({
                                label: g.getLocale === "en" ? r.roleNameEn : r.roleName,
                                value: r.roleId,
                                item: r
                            })) : []
                    },
                    label: o("operation.crewSettings.rank")
                }
            ],
            initShipValue: k
        });
    ve = ()=>({
            settingSchemas: [
                {
                    field: "overtimeApplicable",
                    component: "NSwitch",
                    componentProps: {
                        checkedValue: 1,
                        uncheckedValue: 0
                    },
                    label: o("operation.crewSettings.overTimeApplicable")
                },
                {
                    field: "watchkeeper",
                    component: "NSwitch",
                    componentProps: {
                        checkedValue: 1,
                        uncheckedValue: 0
                    },
                    label: o("operation.crewSettings.watchkeeper")
                }
            ]
        });
    De = ()=>({
            basicFormSchemas: [
                {
                    field: "id",
                    hidden: !0
                },
                {
                    field: "weekDayHours",
                    component: "NInputNumber",
                    componentProps: {
                        min: 1,
                        max: 168,
                        precision: 0,
                        keyboard: {
                            ArrowUp: !1,
                            ArrowDown: !1
                        },
                        showButton: !1
                    },
                    label: o("operation.crewSettings.weekDay"),
                    rules: [
                        {
                            required: !0,
                            validator: (r, a)=>R(a) && !P(a) ? new Error(`${o("operation.crewSettings.weekDay")} ${o("common.required")}`) : !0,
                            trigger: "blur"
                        }
                    ]
                },
                {
                    field: "saturdaysHours",
                    component: "NInputNumber",
                    componentProps: {
                        min: 0,
                        precision: 0,
                        keyboard: {
                            ArrowUp: !1,
                            ArrowDown: !1
                        },
                        showButton: !1
                    },
                    label: o("operation.crewSettings.saturday")
                },
                {
                    field: "sundaysHours",
                    component: "NInputNumber",
                    componentProps: {
                        min: 0,
                        precision: 0,
                        keyboard: {
                            ArrowUp: !1,
                            ArrowDown: !1
                        },
                        showButton: !1
                    },
                    label: o("operation.crewSettings.sunday")
                },
                {
                    field: "holidaysHours",
                    component: "NInputNumber",
                    componentProps: {
                        min: 0,
                        precision: 0,
                        keyboard: {
                            ArrowUp: !1,
                            ArrowDown: !1
                        },
                        showButton: !1
                    },
                    label: o("operation.crewSettings.holiday")
                },
                {
                    field: "monthlyFixedOvertimeHours",
                    component: "NInputNumber",
                    componentProps: {
                        min: 0,
                        precision: 0,
                        keyboard: {
                            ArrowUp: !1,
                            ArrowDown: !1
                        },
                        showButton: !1
                    },
                    giProps: {
                        span: 2
                    },
                    label: o("operation.crewSettings.monthlyFIxedOverTime")
                },
                {
                    field: "hourlyRate",
                    component: "NInputNumber",
                    componentProps: {
                        min: 0,
                        precision: 0,
                        keyboard: {
                            ArrowUp: !1,
                            ArrowDown: !1
                        },
                        showButton: !1
                    },
                    giProps: {
                        span: 2
                    },
                    label: o("operation.crewSettings.hourlyRate"),
                    rules: [
                        {
                            required: !0,
                            validator: (r, a)=>R(a) && !P(a) ? new Error(`${o("operation.crewSettings.hourlyRate")} ${o("common.required")}`) : !0,
                            trigger: "blur"
                        }
                    ]
                },
                {
                    field: "currency",
                    component: "NSelect",
                    componentProps: {
                        options: _e,
                        "label-field": g.getLocale === "en" ? "labelEn" : "label"
                    },
                    giProps: {
                        span: 2
                    },
                    label: o("operation.crewSettings.currency"),
                    rules: [
                        {
                            required: !0,
                            message: `${o("operation.crewSettings.currency")} ${o("common.required")}`,
                            trigger: "blur"
                        }
                    ]
                },
                {
                    field: "holidaysType",
                    component: "NSelect",
                    componentProps: {
                        options: Se,
                        "label-field": g.getLocale === "en" ? "labelEn" : "label"
                    },
                    giProps: {
                        span: 2
                    },
                    label: o("operation.crewSettings.holidays")
                }
            ]
        });
    Ne = {
        class: "flex align-center w-full"
    };
    Fe = {
        key: 0
    };
    xe = ie({
        __name: "CrewSettingForm",
        props: {
            crewWorkDate: {},
            loading: {
                type: Boolean
            },
            crewId: {}
        },
        emits: [
            "save",
            "reload"
        ],
        setup (t, { expose: r, emit: a }) {
            const p = t, v = a, { t: h } = x(), { infoSchemas: L, initShipValue: D } = ke(), { settingSchemas: E } = ve(), { basicFormSchemas: O } = De(), [T, { setFieldsValue: q, getFieldsValue: U }] = S({
                gridProps: {
                    cols: 2
                },
                schemas: L,
                labelPlacement: "left",
                labelWidth: 80,
                showAdvancedButton: !1
            }), [G, { setFieldsValue: z, getFieldsValue: Q, resetFields: j }] = S({
                gridProps: {
                    cols: 4
                },
                schemas: E,
                showAdvancedButton: !1
            }), [M, { setFieldsValue: X, getFieldsValue: N, validate: J, resetFields: K }] = S({
                gridProps: {
                    cols: 4
                },
                schemas: O,
                showAdvancedButton: !1
            });
            le(()=>p.crewWorkDate, ()=>{
                if (j(), K(), console.log("crewWorkDate", p.crewWorkDate), !p.crewWorkDate) return;
                let e = p.crewWorkDate;
                e.weekDayHours = u(e.weekDayHours), e.saturdaysHours = u(e.saturdaysHours), e.sundaysHours = u(e.sundaysHours), e.holidaysHours = u(e.holidaysHours), e.monthlyFixedOvertimeHours = u(e.monthlyFixedOvertimeHours), e.hourlyRate = u(e.hourlyRate), z(e), X(e);
            });
            function u(e) {
                return e ? Number(e) : 0;
            }
            async function Y() {
                try {
                    await J(), v("save", {
                        data: {
                            ...Q(),
                            ...N()
                        }
                    });
                } catch (e) {
                    console.log(e);
                }
            }
            function Z() {
                v("reload");
            }
            return ce(()=>{
                q({
                    vesselId: D
                });
            }), r({
                getQueryFieldsValue: U,
                getBasisWorkFieldsValue: N,
                initShipValue: D
            }), (e, Be)=>{
                const f = se, F = ge, B = me, y = ue, ee = he, oe = fe, te = V("debounce"), re = V("loading");
                return i(), l(y, {
                    class: "w-3/4"
                }, {
                    default: s(()=>[
                            c(y, {
                                class: "proCard bg-transparent mb-4",
                                "content-class": "flex justify-between align-center p-0 pt-8"
                            }, {
                                default: s(()=>[
                                        de("div", Ne, [
                                            c(f, {
                                                class: "w-[45%] mr-2",
                                                onRegister: n(T),
                                                showActionButtonGroup: !1
                                            }, null, 8, [
                                                "onRegister"
                                            ]),
                                            c(B, {
                                                trigger: "hover"
                                            }, {
                                                trigger: s(()=>[
                                                        c(F, {
                                                            onClick: Z,
                                                            strong: "",
                                                            secondary: "",
                                                            bordered: "",
                                                            class: "size-9",
                                                            type: "primary",
                                                            loading: e.loading
                                                        }, {
                                                            icon: s(()=>[
                                                                    (i(), l(C(n(I)(n(W).serach))))
                                                                ]),
                                                            _: 1
                                                        }, 8, [
                                                            "loading"
                                                        ])
                                                    ]),
                                                default: s(()=>[
                                                        b(" " + _(n(h)("common.searchBtnText")), 1)
                                                    ]),
                                                _: 1
                                            })
                                        ]),
                                        e.crewId ? (i(), l(B, {
                                            key: 0,
                                            trigger: "hover"
                                        }, {
                                            trigger: s(()=>[
                                                    A((i(), l(F, {
                                                        type: "primary",
                                                        strong: "",
                                                        bordered: "",
                                                        secondary: "",
                                                        class: "size-9 mr-3"
                                                    }, {
                                                        icon: s(()=>[
                                                                (i(), l(C(n(I)(n(W).save))))
                                                            ]),
                                                        _: 1
                                                    })), [
                                                        [
                                                            te,
                                                            Y,
                                                            "1000"
                                                        ]
                                                    ])
                                                ]),
                                            default: s(()=>[
                                                    b(" " + _(n(h)("common.saveText")), 1)
                                                ]),
                                            _: 1
                                        })) : pe("", !0)
                                    ]),
                                _: 1
                            }),
                            A((i(), l(y, {
                                bordered: !1,
                                class: "proCard bg-transparent",
                                "content-class": "p-0"
                            }, {
                                default: s(()=>[
                                        e.crewId ? (i(), we("div", Fe, [
                                            c(f, {
                                                onRegister: n(G),
                                                showActionButtonGroup: !1
                                            }, null, 8, [
                                                "onRegister"
                                            ]),
                                            c(ee, {
                                                class: "text-2xl font-bold"
                                            }, {
                                                default: s(()=>[
                                                        b(_(n(h)("operation.crewSettings.basicWorkingHours")), 1)
                                                    ]),
                                                _: 1
                                            }),
                                            c(f, {
                                                class: "mt-4",
                                                onRegister: n(M),
                                                showActionButtonGroup: !1
                                            }, null, 8, [
                                                "onRegister"
                                            ])
                                        ])) : (i(), l(oe, {
                                            key: 1,
                                            size: "large",
                                            description: "请选择一个船员"
                                        }))
                                    ]),
                                _: 1
                            })), [
                                [
                                    re,
                                    e.loading
                                ]
                            ])
                        ]),
                    _: 1
                });
            };
        }
    });
});
export { xe as _, Ie as a, We as g, Re as s, He as u, __tla };
