import { d as ve, V as _e, f as he, u as ye, cq as be, r as p, a4 as _, l as a, cO as Te, fm as we, aw as Ce, c as d, o as f, w as i, j as r, D as V, W as Ie, H as Le, aI as Se, p as R, A as F, B as Re, ca as N, gW as B, gX as U, h6 as Fe, h7 as Ne, aH as De, X as ke, hc as xe, bR as Ve, R as Be, __tla as __tla_0 } from "./index-9PRMimni.js";
import { _ as Ue } from "./BackButtonText.vue_vue_type_script_setup_true_lang-Dtx94mZF.js";
import { B as P } from "./BasicForm-dL_oCSPM.js";
import { u as z } from "./useForm-CKmgcynv.js";
import { o as Ae, __tla as __tla_1 } from "./schemas-DF6duLaU.js";
import { c as qe } from "./componentSetting-DVhNDBTO.js";
import { a as O, s as G, b as $e } from "./training-DVATRQCh.js";
import { _ as Ee, __tla as __tla_2 } from "./OtherMasterEngineer.vue_vue_type_script_setup_true_lang-CISqmfQD.js";
import { _ as Pe, __tla as __tla_3 } from "./OtherChiefEngineer.vue_vue_type_style_index_0_lang-x4UMevQB.js";
import { u as ze } from "./useTags-C1thGhjF.js";
import { v as Oe, __tla as __tla_4 } from "./schemas-DzvLPsci.js";
import { b as Ge, u as He, c as We, N as Me } from "./template-rpthWlT9.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 "./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 "./usePageCache-DluHn7Yy.js";
import "./illnessInjury-CN3bQPcI.js";
import { __tla as __tla_5 } from "./columns--0qKB6VJ.js";
import "./format-DgF6KtHk.js";
import "./Table-0PViRYCf.js";
import "./Table.vue_vue_type_style_index_0_scoped_7b9e6ece_lang-BoW2DV_e.js";
import "./componentMap-CElCaWis.js";
import "./omit-B2_8Y6O_.js";
import "./_flatRest-DBrd2CHT.js";
import "./flatten-DeoUZLdb.js";
import "./print-CT_2hrjP.js";
import "./basicModal.vue_vue_type_script_setup_true_lang-CsJydKhW.js";
import "./basicModal.vue_vue_type_style_index_0_lang-8QZP7ApW.js";
import "./useModal-CO65vga3.js";
import "./useTimeout-BxFilWvD.js";
import "./Flex-CTSf12gq.js";
import "./isEmpty-BUg1OsQj.js";
let Et;
let __tla = Promise.all([
    (()=>{
        try {
            return __tla_0;
        } catch  {}
    })(),
    (()=>{
        try {
            return __tla_1;
        } catch  {}
    })(),
    (()=>{
        try {
            return __tla_2;
        } catch  {}
    })(),
    (()=>{
        try {
            return __tla_3;
        } catch  {}
    })(),
    (()=>{
        try {
            return __tla_4;
        } catch  {}
    })(),
    (()=>{
        try {
            return __tla_5;
        } catch  {}
    })()
]).then(async ()=>{
    Et = ve({
        __name: "otherTrainingAdd",
        setup (Xe) {
            const { t: n } = _e(), h = he(), m = ye(), { closeCurrentTabToBack: H } = ze(), { urlPrefix: W } = be(), y = p(), w = _(()=>h.query.type === "view"), g = p(""), v = p(0), b = p(0), c = p(), C = p([]), l = p({
                templateUid: "",
                templateCode: "",
                moduleCode: "",
                approveFlag: !1,
                submitFlag: !0,
                editFlag: !0,
                id: 0,
                createTime: "",
                updateTime: "",
                isDeleted: 0,
                type: "",
                status: "",
                trainingResult: "",
                participantsVoList: [
                    {
                        id: 0,
                        proposedShipId: 0,
                        proposedShipName: "",
                        proposedShipNameEn: "",
                        seafarerId: 0,
                        seafarerName: "",
                        seafarerNameEn: "",
                        shortNameEn: "",
                        traningId: 0
                    }
                ],
                trainersVoList: [],
                timestamp: 0
            }), A = p({}), D = p(""), M = p(null), k = _(()=>g.value === "2_1" && [
                    16,
                    20
                ].includes(a(v) || 0)), X = _(()=>l.value.editFlag && !w.value), j = _(()=>l.value.submitFlag && !w.value), K = _(()=>w.value || !l.value.editFlag), J = _(()=>{
                switch(a(v)){
                    case 16:
                        return Ee;
                    case 20:
                        return Pe;
                    default:
                        return null;
                }
            }), Q = `${W}/files`, Y = _(()=>({
                    timestamp: new Date().getTime(),
                    authorization: `${Te.get(we)}`
                })), { schemasOtherTrainingBase: Z, schemasUpload: ee, methods: I } = Ae($, ne, se, re), [te, { setFieldsValue: L, getFieldsValue: q, submit: ae }] = z({
                gridProps: {
                    cols: 12
                },
                schemas: Z,
                showActionButtonGroup: !1,
                showAdvancedButton: !1
            }), [oe] = z({
                schemas: ee,
                labelWidth: "auto",
                layout: "horizontal",
                collapsed: !0,
                gridProps: {
                    cols: 4,
                    xGap: 15
                },
                showActionButtonGroup: !1
            });
            async function ie() {
                try {
                    const t = await xe();
                    if (t.length > 0 && (L({
                        proposedShipId: t[0].id
                    }), $(t[0].id)), h.query.id) {
                        const o = Number(h.query.id), e = await O(o);
                        l.value = e, b.value = e.id;
                        const s = {
                            ...e,
                            proposedShipId: e.participantsVoList[0]?.proposedShipId,
                            type: e.type,
                            trainingLocation: e.trainersVoList[0]?.trainingLocation,
                            applyDutyId: e.participantsVoList[0]?.applyDutyId,
                            seafarerId: e.participantsVoList[0]?.seafarerId,
                            remark: e.remark
                        };
                        if (L(s), v.value = s.applyDutyId, g.value = s.type, await I.updateCrewNameList(c.value?.id, v.value, g.value), e.templateUid) {
                            const u = await Ge({
                                templateCode: e.templateCode,
                                uuid: e.templateUid
                            });
                            y.value?.initData(u.list);
                        }
                        e.relationVoList && e.relationVoList.length > 0 && (C.value = e.relationVoList.map((u)=>({
                                id: u.fileName || "",
                                url: u.fileUrl || "",
                                name: u.fileName?.split("/").pop() || "",
                                thumbnailUrl: u.fileName || "",
                                status: h.query.type === "edit" ? "finished" : void 0
                            })));
                    } else L({
                        trainingType: "4"
                    });
                } catch (t) {
                    console.error("初始化数据失败:", t), m.error(n("common.loadFailed"));
                }
            }
            async function $(t) {
                c.value = Oe.find((o)=>o.id === t) || void 0, await I.updateTypeList(c.value?.shipTypeId);
            }
            function ne(t) {
                g.value = t, L({
                    seafarerId: ""
                }), I.updateCrewNameList(c.value?.id, v.value, t);
            }
            function se(t) {
                v.value = t, L({
                    seafarerId: ""
                }), I.updateCrewNameList(c.value?.id, t, g.value);
            }
            function re(t, o) {
                M.value = t, A.value = o.find((e)=>e.crewId === t) || {}, k.value && y.value && y.value.handleOpen(c.value, A.value);
            }
            function E() {
                const t = q(), o = C.value.map((s)=>({
                        fileName: s.thumbnailUrl || ""
                    })), e = {
                    type: t.type,
                    category: 4,
                    trainingResult: t.trainingResult,
                    trainingType: t.trainingType,
                    remark: t.remark,
                    participantsDtoList: [
                        {
                            ...t
                        }
                    ],
                    trainersDtoList: [
                        {
                            trainingLocation: t.trainingLocation
                        }
                    ],
                    fileRelationDtos: o
                };
                return (h.query.id || b.value) && (e.id = Number(h.query.id) || b.value, e.templateUid = D.value, e.templateCode = l.value?.templateCode), e;
            }
            async function le() {
                if (!await ae()) {
                    m.warning(n("configureForm.pleaseCheckIfTheContentHasBeenFilledInCompletely"));
                    return;
                }
                try {
                    const o = await G(E()), e = Number(o), s = await O(e);
                    if (l.value = s, b.value = e, k.value && y.value) {
                        const u = y.value.voList(), { templateUid: S, templateCode: T } = l.value;
                        S ? (await He({
                            template_code: T,
                            uuid: S,
                            list: u
                        }), D.value = S) : D.value = await We({
                            template_code: T,
                            list: u
                        });
                    }
                    await G(E()), m.success(n("common.saveSuccessText"));
                } catch (o) {
                    console.error("保存失败:", o), m.error(n("common.saveFailedText"));
                }
            }
            async function ue() {
                if (!b.value) {
                    m.warning(n("common.pleaseSaveFirst"));
                    return;
                }
                try {
                    const t = q(), o = C.value.map((u)=>({
                            fileName: u.thumbnailUrl || ""
                        })), e = {
                        isSubmit: g.value !== "2_1" ? 1 : 0,
                        type: t.type,
                        trainingResult: t.trainingResult,
                        trainingType: t.trainingType,
                        remark: t.remark,
                        participantsDtoList: [
                            {
                                ...t
                            }
                        ],
                        trainersDtoList: [
                            {
                                trainingLocation: t.trainingLocation
                            }
                        ],
                        id: b.value,
                        fileRelationDtos: o
                    };
                    await $e(e), (c.value?.shipTypeId === 1 || c.value?.shipTypeId !== 1 && g.value === "2_1" && [
                        16,
                        20
                    ].includes(a(v) || 0)) && l.value.id && l.value.moduleCode && await Me({
                        shipId: c.value?.id,
                        busId: l.value.id,
                        moduleCode: l.value.moduleCode
                    }), m.success(n("common.submitSuccessText")), pe();
                } catch (t) {
                    console.error("提交失败:", t), m.error(n("common.submitFailedText"));
                }
            }
            function pe() {
                H();
            }
            function me({ file: t, event: o }) {
                try {
                    const e = Ve("(" + o.target.response + ")"), { infoField: s } = qe.upload.apiSetting;
                    e.code === Be.SUCCESS && e[s] ? t.thumbnailUrl = e[s].name : m.error(e.msg || e.message || n("common.uploadFailed"));
                } catch (e) {
                    console.error("处理上传结果失败:", e), m.error(n("common.uploadParseFailed"));
                }
            }
            return Ce(()=>{
                I.updateReadOnly(!l.value.editFlag || w.value), ie();
            }), (t, o)=>{
                const e = Re, s = Se, u = Ue, S = Le, T = Ie, ce = Ne, de = Fe, fe = De, ge = ke;
                return f(), d(ge, null, {
                    default: i(()=>[
                            r(T, {
                                bordered: !1,
                                class: "proCard mb-3",
                                title: a(n)("common.basicInformation"),
                                segmented: {
                                    content: !0,
                                    footer: "soft"
                                }
                            }, {
                                "header-extra": i(()=>[
                                        r(S, null, {
                                            default: i(()=>[
                                                    a(X) ? (f(), d(s, {
                                                        key: 0,
                                                        trigger: "hover"
                                                    }, {
                                                        trigger: i(()=>[
                                                                r(e, {
                                                                    type: "primary",
                                                                    strong: "",
                                                                    bordered: "",
                                                                    secondary: "",
                                                                    class: "size-7",
                                                                    onClick: o[0] || (o[0] = (x)=>le())
                                                                }, {
                                                                    icon: i(()=>[
                                                                            (f(), d(N(a(B)(a(U).save))))
                                                                        ]),
                                                                    _: 1
                                                                })
                                                            ]),
                                                        default: i(()=>[
                                                                R(" " + F(a(n)("common.saveText")), 1)
                                                            ]),
                                                        _: 1
                                                    })) : V("", !0),
                                                    a(j) ? (f(), d(s, {
                                                        key: 1,
                                                        trigger: "hover"
                                                    }, {
                                                        trigger: i(()=>[
                                                                r(e, {
                                                                    type: "primary",
                                                                    strong: "",
                                                                    bordered: "",
                                                                    secondary: "",
                                                                    class: "size-7",
                                                                    onClick: o[1] || (o[1] = (x)=>ue())
                                                                }, {
                                                                    icon: i(()=>[
                                                                            (f(), d(N(a(B)(a(U).submit))))
                                                                        ]),
                                                                    _: 1
                                                                })
                                                            ]),
                                                        default: i(()=>[
                                                                R(" " + F(a(n)("common.optionsSubmitText")), 1)
                                                            ]),
                                                        _: 1
                                                    })) : V("", !0),
                                                    r(s, {
                                                        trigger: "hover"
                                                    }, {
                                                        trigger: i(()=>[
                                                                r(u)
                                                            ]),
                                                        default: i(()=>[
                                                                R(" " + F(a(n)("common.back")), 1)
                                                            ]),
                                                        _: 1
                                                    })
                                                ]),
                                            _: 1
                                        })
                                    ]),
                                default: i(()=>[
                                        r(a(P), {
                                            onRegister: a(te)
                                        }, null, 8, [
                                            "onRegister"
                                        ])
                                    ]),
                                _: 1
                            }, 8, [
                                "title"
                            ]),
                            a(k) ? (f(), d(T, {
                                key: 0,
                                bordered: !1,
                                class: "proCard mb-3",
                                title: a(n)("crewTraining.content"),
                                segmented: {
                                    content: !0,
                                    footer: "soft"
                                }
                            }, {
                                default: i(()=>[
                                        r(de, null, {
                                            default: i(()=>[
                                                    r(ce, {
                                                        span: 24
                                                    }, {
                                                        default: i(()=>[
                                                                (f(), d(N(a(J)), {
                                                                    ref_key: "trainingComponentRef",
                                                                    ref: y,
                                                                    readonly: l.value.editFlag && !a(w)
                                                                }, null, 8, [
                                                                    "readonly"
                                                                ]))
                                                            ]),
                                                        _: 1
                                                    })
                                                ]),
                                            _: 1
                                        })
                                    ]),
                                _: 1
                            }, 8, [
                                "title"
                            ])) : V("", !0),
                            r(T, {
                                bordered: !1,
                                class: "proCard mb-3",
                                title: a(n)("noticeCircular.general.Attachment"),
                                segmented: {
                                    content: !0,
                                    footer: "soft"
                                }
                            }, {
                                default: i(()=>[
                                        r(a(P), {
                                            onRegister: a(oe)
                                        }, {
                                            attachment: i(()=>[
                                                    r(fe, {
                                                        action: Q,
                                                        accept: ".doc,.docx,.pdf,.xls,.xlsx",
                                                        headers: a(Y),
                                                        max: 15,
                                                        "file-list": C.value,
                                                        "onUpdate:fileList": o[2] || (o[2] = (x)=>C.value = x),
                                                        onFinish: me,
                                                        class: "uploadStyle",
                                                        "file-list-style": {
                                                            margin: 0,
                                                            flex: 1
                                                        },
                                                        disabled: a(K)
                                                    }, {
                                                        default: i(()=>[
                                                                r(s, {
                                                                    trigger: "hover"
                                                                }, {
                                                                    trigger: i(()=>[
                                                                            r(e, {
                                                                                strong: "",
                                                                                secondary: "",
                                                                                class: "size-7"
                                                                            }, {
                                                                                icon: i(()=>[
                                                                                        (f(), d(N(a(B)(a(U).upload))))
                                                                                    ]),
                                                                                _: 1
                                                                            })
                                                                        ]),
                                                                    default: i(()=>[
                                                                            R(" " + F(a(n)("hsqe.rs.uploadText")), 1)
                                                                        ]),
                                                                    _: 1
                                                                })
                                                            ]),
                                                        _: 1
                                                    }, 8, [
                                                        "headers",
                                                        "file-list",
                                                        "disabled"
                                                    ])
                                                ]),
                                            _: 1
                                        }, 8, [
                                            "onRegister"
                                        ])
                                    ]),
                                _: 1
                            }, 8, [
                                "title"
                            ])
                        ]),
                    _: 1
                });
            };
        }
    });
});
export { Et as default, __tla };
