import { d as re, V as ie, f as ce, bk as ue, a4 as k, r as p, aw as pe, ay as P, c as w, o as _, w as o, j as l, W as me, i as D, l as s, H as de, D as I, aI as _e, p as O, A, B as fe, x as ve, ds as ge, h as ke, F as we, a9 as ye, y as be, aE as R, aF as F, cC as he, X as Te, cZ as Se, gL as Pe, __tla as __tla_0 } from "./index-9PRMimni.js";
import { B as De } from "./BasicForm-dL_oCSPM.js";
import L from "./MarkScale-DkuSSiws.js";
import { c as Ie, a as xe, u as Be, b as Ce, g as Ne, __tla as __tla_1 } from "./rankTaskPlan-DnrrYaY5.js";
import { w as M, g as y, T as z } from "./helper-ByM4DLer.js";
import { u as Ve } from "./useForm-CKmgcynv.js";
import { i as q } from "./isEmpty-BUg1OsQj.js";
import { f as U } from "./flatten-DeoUZLdb.js";
import "./Render.vue_vue_type_script_lang-DKUYY0Zw.js";
import "./SingleImageUpload-CNx4b9eC.js";
import "./ImageUpload.vue_vue_type_style_index_0_scoped_cb086928_lang-D-28kXvw.js";
import "./componentSetting-DVhNDBTO.js";
import "./ImageUpload-DUsnro3W.js";
import "./vuedraggable.umd-Co2xEC3p.js";
import "./BasicUpload.vue_vue_type_style_index_0_scoped_a4d0e930_lang-DxRbtP01.js";
import "./tabsView-BXskTdVh.js";
import "./BasicForm.vue_vue_type_style_index_0_scoped_b9e995ec_lang-CEvcLwxD.js";
import "./propTypes-CebMRUpe.js";
import "./BasicSelect-C_uwzMkE.js";
import "./BasicSelect.vue_vue_type_style_index_0_scoped_772d51cc_lang-Brp6PjEU.js";
import "./dictionary-BRse4lkf.js";
import "./index-DkvzUEqh.js";
import "./index-kKnqLkWM.js";
import "./AutoComplete-Dv1Bqed4.js";
import "./TreeSelect-BZh2DeCh.js";
import "./crewDailyTask-CA-vJisZ.js";
import "./columns-BGwNjcbZ.js";
import "./_createRound-MlkJBLNh.js";
import "./toInteger-DQeH-nF-.js";
import "./list-table.vue-BMAnwqtG.js";
import "./tslib.es6-CSJU3tT9.js";
import "./usePageCache-DluHn7Yy.js";
let _a;
let __tla = Promise.all([
    (()=>{
        try {
            return __tla_0;
        } catch  {}
    })(),
    (()=>{
        try {
            return __tla_1;
        } catch  {}
    })()
]).then(async ()=>{
    let We;
    We = {
        class: "flex justify-between"
    };
    _a = re({
        __name: "index",
        setup (je) {
            const { t: b } = ie(), h = ce(), x = Se(), Y = ue(), B = k(()=>Y.getLocale === "en" ? "Please select template or add" : "请选择一个模板或者新增"), { infoSchemas: $, initShipValue: T, updateTemplateOptions: G } = Ie({
                handleChangeTemplate: ee
            }), { tabsSchemas: H } = xe(), r = p("Monday"), S = p(), C = p(), f = p(), v = p(), N = k(()=>h.query?.vesselId || T), n = p(), m = p(!1), X = k(()=>S.value?.filter((a)=>a.value.includes("Port"))), Z = k(()=>S.value?.filter((a)=>a.value.includes("Sea"))), [J, { setFieldsValue: K }] = Ve({
                gridProps: {
                    cols: 3
                },
                schemas: $,
                labelPlacement: "left",
                labelWidth: 80,
                showAdvancedButton: !1
            });
            async function Q() {
                if (!n.value) return x.warning(B.value), !1;
                const e = U(U(Object.values(n.value.detail)).map((t)=>Object.values(t))).filter((t)=>t.taskId).map((t)=>({
                        id: t?.id,
                        taskId: t?.taskId,
                        weekDay: t?.weekDay,
                        planTime: t?.planTime
                    }));
                n.value?.raw?.id ? await Be({
                    ...n.value?.raw,
                    details: e
                }) : await Ce({
                    ...n.value?.raw,
                    details: e
                }), m.value = !1, x.success(b("common.saveSuccessText")), await j();
            }
            function Ee() {
                V();
            }
            function ee(a, e) {
                if (!a) {
                    n.value = null;
                    return;
                }
                n.value = {
                    raw: e.raw,
                    detail: Object.fromEntries(M.map((t)=>[
                            t,
                            [
                                Object.fromEntries(y().map((i)=>[
                                        i,
                                        g(e, i, t, [
                                            "SeaWatch",
                                            "SeaNormal"
                                        ])
                                    ])),
                                Object.fromEntries(y().map((i)=>[
                                        i,
                                        g(e, i, t, [
                                            "PortWatch",
                                            "PortNormal"
                                        ])
                                    ]))
                            ]
                        ]))
                }, f.value = n.value.detail[r.value][0], v.value = n.value.detail[r.value][1];
            }
            function V() {
                n.value.detail = Object.fromEntries(M.map((a)=>[
                        a,
                        [
                            Object.fromEntries(y().map((e)=>[
                                    e,
                                    g({
                                        raw: {}
                                    }, e, a, [
                                        "SeaWatch",
                                        "SeaNormal"
                                    ])
                                ])),
                            Object.fromEntries(y().map((e)=>[
                                    e,
                                    g({
                                        raw: {}
                                    }, e, a, [
                                        "PortWatch",
                                        "PortNormal"
                                    ])
                                ]))
                        ]
                    ])), f.value = n.value.detail[r.value][0], v.value = n.value.detail[r.value][1];
            }
            function g(a, e, t, i) {
                const d = !q(a?.raw.details) && a?.raw.details.filter((c)=>c.weekDay === t && i.includes(c.taskType)).find((c)=>c.planTime === e);
                return d ? new z({
                    ...d,
                    planTime: e,
                    raw: d
                }) : new z({
                    weekDay: t,
                    planTime: e
                });
            }
            function W({ row: a, weekDay: e }, t) {
                m.value = !0, t === "Sea" ? n.value.detail[e][0] = a : n.value.detail[e][1] = a;
            }
            async function ae() {
                S.value = await Pe("schedule_task_type"), await j();
            }
            async function j() {
                C.value = await Ne({
                    vesselId: N.value,
                    planYear: h.query?.planYear || 2025,
                    planMoth: h.query?.planMoth || 11
                });
            }
            return pe(()=>{
                ae(), K({
                    vesselId: N.value
                });
            }), P(C, (a)=>{
                const e = a.map((t)=>({
                        value: t.id,
                        label: t.templateName,
                        labelEn: t.templateName,
                        raw: t
                    }));
                G(e);
            }), P(r, (a)=>{
                f.value = n.value?.detail[a][0], v.value = n.value?.detail[a][1];
            }), P(n, (a)=>{
                if (q(a)) {
                    m.value = !1;
                    return;
                }
                m.value = !0;
            }), (a, e)=>{
                const t = De, i = fe, d = _e, c = de, E = me, te = be, ne = ve, se = he, oe = Te;
                return _(), w(oe, null, {
                    default: o(()=>[
                            l(E, {
                                bordered: !1,
                                class: "proCard mt-2"
                            }, {
                                default: o(()=>[
                                        D("div", We, [
                                            l(t, {
                                                class: "w-[50%]",
                                                onRegister: s(J),
                                                showActionButtonGroup: !1
                                            }, null, 8, [
                                                "onRegister"
                                            ]),
                                            l(c, null, {
                                                default: o(()=>[
                                                        (!s(n) && s(m), I("", !0)),
                                                        s(n) ? (_(), w(d, {
                                                            key: 1,
                                                            trigger: "hover"
                                                        }, {
                                                            trigger: o(()=>[
                                                                    l(i, {
                                                                        type: "primary",
                                                                        strong: "",
                                                                        bordered: "",
                                                                        secondary: "",
                                                                        class: "size-7",
                                                                        onClick: V
                                                                    }, {
                                                                        icon: o(()=>e[4] || (e[4] = [
                                                                                D("i", {
                                                                                    class: "iconfont icon-gengxin1"
                                                                                }, null, -1)
                                                                            ])),
                                                                        _: 1
                                                                    })
                                                                ]),
                                                            default: o(()=>[
                                                                    O(" " + A(s(b)("common.resetBtnText")), 1)
                                                                ]),
                                                            _: 1
                                                        })) : I("", !0),
                                                        s(m) ? (_(), w(d, {
                                                            key: 2,
                                                            trigger: "hover"
                                                        }, {
                                                            trigger: o(()=>[
                                                                    l(i, {
                                                                        type: "primary",
                                                                        strong: "",
                                                                        bordered: "",
                                                                        secondary: "",
                                                                        class: "size-7",
                                                                        onClick: Q
                                                                    }, {
                                                                        icon: o(()=>e[5] || (e[5] = [
                                                                                D("i", {
                                                                                    class: "iconfont icon-Save"
                                                                                }, null, -1)
                                                                            ])),
                                                                        _: 1
                                                                    })
                                                                ]),
                                                            default: o(()=>[
                                                                    O(" " + A(s(b)("common.saveText")), 1)
                                                                ]),
                                                            _: 1
                                                        })) : I("", !0)
                                                    ]),
                                                _: 1
                                            })
                                        ])
                                    ]),
                                _: 1
                            }),
                            l(E, {
                                bordered: !1,
                                class: "proCard mt-2"
                            }, {
                                default: o(()=>[
                                        l(ne, {
                                            class: "card-tabs",
                                            value: s(r),
                                            "onUpdate:value": e[0] || (e[0] = (u)=>ge(r) ? r.value = u : null),
                                            size: "large",
                                            animated: "",
                                            type: "line"
                                        }, {
                                            default: o(()=>[
                                                    (_(!0), ke(we, null, ye(s(H), (u, le)=>(_(), w(te, {
                                                            name: u.field,
                                                            tab: u.title,
                                                            key: le
                                                        }, null, 8, [
                                                            "name",
                                                            "tab"
                                                        ]))), 128))
                                                ]),
                                            _: 1
                                        }, 8, [
                                            "value"
                                        ]),
                                        l(c, {
                                            vertical: ""
                                        }, {
                                            default: o(()=>[
                                                    R(l(c, {
                                                        vertical: ""
                                                    }, {
                                                        default: o(()=>[
                                                                l(L, {
                                                                    "scene-types": s(Z),
                                                                    "vessel-id": s(T),
                                                                    currentWeekDay: s(r),
                                                                    taskPlanItem: s(f),
                                                                    onUpdateRow: e[1] || (e[1] = (u)=>W(u, "Sea"))
                                                                }, null, 8, [
                                                                    "scene-types",
                                                                    "vessel-id",
                                                                    "currentWeekDay",
                                                                    "taskPlanItem"
                                                                ]),
                                                                l(L, {
                                                                    "scene-types": s(X),
                                                                    "vessel-id": s(T),
                                                                    currentWeekDay: s(r),
                                                                    taskPlanItem: s(v),
                                                                    onUpdateRow: e[2] || (e[2] = (u)=>W(u, "Port"))
                                                                }, null, 8, [
                                                                    "scene-types",
                                                                    "vessel-id",
                                                                    "currentWeekDay",
                                                                    "taskPlanItem"
                                                                ])
                                                            ]),
                                                        _: 1
                                                    }, 512), [
                                                        [
                                                            F,
                                                            s(n)
                                                        ]
                                                    ]),
                                                    R(l(se, {
                                                        description: s(B)
                                                    }, null, 8, [
                                                        "description"
                                                    ]), [
                                                        [
                                                            F,
                                                            !s(n)
                                                        ]
                                                    ])
                                                ]),
                                            _: 1
                                        })
                                    ]),
                                _: 1
                            })
                        ]),
                    _: 1
                });
            };
        }
    });
});
export { _a as default, __tla };
