import { d as we, V as Ie, f as Me, a4 as x, r as p, aw as Ce, ay as Re, aC as be, c as _, o as d, w as l, j as u, D as W, W as Se, U as Oe, M as Ve, l as y, H as Ne, aI as Pe, p as X, A as Y, B as Fe, ca as G, gW as oe, gX as ie, x as Te, h as Je, F as xe, a9 as $e, y as Ue, h6 as Be, h7 as Ae, aa as Ee, X as je, ac as P, hc as qe, cZ as ze, __tla as __tla_0 } from "./index-9PRMimni.js";
import { _ as We } from "./BackButtonText.vue_vue_type_script_setup_true_lang-Dtx94mZF.js";
import { B as Xe } from "./BasicForm-dL_oCSPM.js";
import { u as Ye } from "./useForm-CKmgcynv.js";
import { c as Ge, __tla as __tla_1 } from "./schemas-BqGurRC_.js";
import { _ as C, __tla as __tla_2 } from "./CrewContactMethod.vue_vue_type_script_setup_true_lang-CKWUMcqj.js";
import { _ as R, __tla as __tla_3 } from "./OilCrewCertificatesChecklist.vue_vue_type_script_setup_true_lang-DHnrThko.js";
import { _ as v, __tla as __tla_4 } from "./OilIMOCrewlist.vue_vue_type_script_setup_true_lang-Bam5G8Z0.js";
import { v as He, __tla as __tla_5 } from "./schemas-DzvLPsci.js";
import { g as Ke, s as Ze, c as Qe, m as et, a as tt } from "./monthlyReport-SEBHAx0s.js";
import { _ as L, __tla as __tla_6 } from "./IMOCrewlist.vue_vue_type_script_setup_true_lang-D_pDSb2q.js";
import { _ as b, __tla as __tla_7 } from "./CrewCertificatesChecklist.vue_vue_type_script_setup_true_lang-DpYJSp7q.js";
import { _ as D, __tla as __tla_8 } from "./MonthlyReport.vue_vue_type_script_setup_true_lang-gaTdyAxv.js";
import { b as se, u as at, c as ot, N as it } from "./template-rpthWlT9.js";
import { u as st } from "./useTags-C1thGhjF.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 "./usePageCache-DluHn7Yy.js";
import { __tla as __tla_9 } from "./columns-DY6kUOTk.js";
import "./Table-0PViRYCf.js";
import "./Table.vue_vue_type_style_index_0_scoped_7b9e6ece_lang-BoW2DV_e.js";
import "./componentMap-CElCaWis.js";
import "./format-DgF6KtHk.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 "./TableSelect.vue_vue_type_script_setup_true_lang-BAU5mgvB.js";
import "./props-CLtNejQT.js";
import "./TableAction.vue_vue_type_script_setup_true_lang-Bj_Y4LtN.js";
import { __tla as __tla_10 } from "./UploadFile.vue_vue_type_script_setup_true_lang--uWupa0a.js";
import "./planner-BebmniHR.js";
import "./isEmpty-BUg1OsQj.js";
let na;
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  {}
    })(),
    (()=>{
        try {
            return __tla_6;
        } catch  {}
    })(),
    (()=>{
        try {
            return __tla_7;
        } catch  {}
    })(),
    (()=>{
        try {
            return __tla_8;
        } catch  {}
    })(),
    (()=>{
        try {
            return __tla_9;
        } catch  {}
    })(),
    (()=>{
        try {
            return __tla_10;
        } catch  {}
    })()
]).then(async ()=>{
    na = we({
        __name: "crudeOilTanker",
        setup (nt) {
            const { t: m } = Ie(), $ = ze(), S = Me(), { closeCurrentTabToBack: ne } = st(), w = x(()=>S.query.type === "view"), I = x(()=>!!S.query.id), r = p("1"), U = p("1"), g = p(), F = p(""), T = p(!0), B = p(), i = p({
                editFlag: !0,
                submitFlag: !0
            }), A = p({}), n = p({
                1: {},
                2: {},
                3: {}
            }), H = p(!0), h = x(()=>g.value?.shipTypeId === 1 ? [
                    {
                        key: "1",
                        label: m("monthlyReport.monthlyReport"),
                        component: D,
                        dataKey: {}
                    },
                    {
                        key: "2",
                        label: m("monthlyReport.crewCertificatesChecklist"),
                        component: b,
                        initParams: {
                            certificatesList: "crewMonthlyReportDetailCertificatesVoList"
                        },
                        dataKey: {
                            voList: "crewMonthlyReportDetailCertificatesDtoList"
                        }
                    },
                    {
                        key: "3",
                        label: m("monthlyReport.iMOCrewlist"),
                        component: L,
                        initParams: {
                            imoVessel: "vesselItem",
                            imoInfo: "crewMonthlyReportDetailImoInfoVo",
                            imoDetailList: "crewMonthlyReportDetailImoDetailVoList"
                        },
                        dataKey: {
                            infoVo: "crewMonthlyReportDetailImoInfoDto",
                            voList: "crewMonthlyReportDetailImoDetailDtoList"
                        }
                    }
                ] : [
                    {
                        key: "1",
                        label: m("monthlyReport.crewCertificatesChecklist"),
                        component: R,
                        initParams: {
                            certificatesList: "crewMonthlyReportDetailCertificatesVoList"
                        },
                        dataKey: {
                            voList: "crewMonthlyReportDetailCertificatesDtoList"
                        }
                    },
                    {
                        key: "2",
                        label: m("monthlyReport.crewContactMethod"),
                        component: C,
                        initParams: {
                            contactList: "crewMonthlyReportDetailContactMethodVoList"
                        },
                        dataKey: {
                            voList: "crewMonthlyReportDetailContactMethodDtoList"
                        }
                    },
                    {
                        key: "3",
                        label: m("monthlyReport.iMOCrewlist"),
                        component: v,
                        initParams: {
                            imoVessel: "vesselItem",
                            imoInfo: "crewMonthlyReportDetailImoInfoVo",
                            imoDetailList: "crewMonthlyReportDetailImoDetailVoList",
                            editable: !w.value && i.value?.editFlag
                        },
                        dataKey: {
                            infoVo: "crewMonthlyReportDetailImoInfoDto",
                            voList: "crewMonthlyReportDetailImoDetailDtoList"
                        }
                    }
                ]), k = x(()=>h.value.find((t)=>t.key === r.value)), { contentSchemas: le, methods: { updateView: K } } = Ge(ee, ye), [re, { getFieldsValue: ce, setFieldsValue: Z }] = Ye({
                gridProps: {
                    cols: 10
                },
                schemas: le,
                showActionButtonGroup: !1,
                showAdvancedButton: !1
            });
            function ue(t) {
                t && k.value && (A.value[k.value.key] = t, P(()=>{
                    O(k.value.key);
                }));
            }
            function me(t) {
                const e = {
                    readonly: T.value
                };
                return t.component === v && (e.editable = !w.value && i.value?.editFlag), e;
            }
            function J(t) {
                const e = A.value[t], o = h.value.find((s)=>s.key === t);
                if (!e || !o) return;
                const a = JSON.parse(JSON.stringify(pe(e, o)));
                n.value[t] = a;
            }
            function pe(t, e) {
                switch(e.component){
                    case D:
                        return {
                            list: t.voList?.() || [],
                            list2: t.voList2?.() || []
                        };
                    case b:
                    case R:
                        return t.voList?.() || [];
                    case C:
                        return t.voList?.() || [];
                    case L:
                    case v:
                        return {
                            info: t.infoVo?.() || {},
                            detailList: t.voList?.() || [],
                            fileListMap: n.value[e.key]?.fileListMap || {}
                        };
                    default:
                        return {};
                }
            }
            function O(t) {
                const e = A.value[t], o = h.value.find((c)=>c.key === t);
                if (!e || !o) return;
                if (!H.value) {
                    ve(e, o, t);
                    return;
                }
                const a = n.value[t], s = I.value;
                switch(o.component){
                    case D:
                        I.value && i.value?.templateUid ? a.list?.length ? e.listInfo(a.list, a.list2) : Q(e, i.value, t) : (e.handleOpen?.(), a.list?.length && e.listInfo(a.list, a.list2));
                        break;
                    case b:
                    case R:
                        const c = s && a.length ? a : i.value?.[o.initParams?.certificatesList] || [];
                        e.handleOpen(JSON.parse(JSON.stringify(c)));
                        break;
                    case C:
                        const V = s && a.length ? a : i.value?.[o.initParams?.contactList] || [];
                        e.handleOpen(JSON.parse(JSON.stringify(V)));
                        break;
                    case L:
                    case v:
                        const N = s && Object.keys(a.info).length ? a.info : i.value?.[o.initParams?.imoInfo] || {}, M = s && a.detailList.length ? a.detailList : i.value?.[o.initParams?.imoDetailList] || [], E = g.value, j = o.initParams?.editable;
                        e.handleOpen(E, JSON.parse(JSON.stringify(N)), JSON.parse(JSON.stringify(M)), j, a.fileListMap || {}, I.value), a.fileListMap && Object.entries(a.fileListMap).forEach(([q, z])=>{
                            e.updateFileList?.(Number(q), JSON.parse(JSON.stringify(z)));
                        });
                        break;
                }
            }
            function ve(t, e, o) {
                switch(n.value[o] = e.component === L || e.component === v ? {
                    info: {},
                    detailList: [],
                    fileListMap: {}
                } : e.component === D ? {
                    list: [],
                    list2: []
                } : [], e.component){
                    case D:
                        i.value?.templateUid ? Q(t, i.value, o, !0) : t.handleOpen?.();
                        break;
                    case b:
                    case R:
                        const a = i.value?.[e.initParams?.certificatesList] || [];
                        t.handleOpen(JSON.parse(JSON.stringify(a)));
                        break;
                    case C:
                        const s = i.value?.[e.initParams?.contactList] || [];
                        t.handleOpen(JSON.parse(JSON.stringify(s)));
                        break;
                    case L:
                    case v:
                        const c = i.value?.[e.initParams?.imoInfo] || {}, V = i.value?.[e.initParams?.imoDetailList] || [], N = g.value, M = e.initParams?.editable;
                        t.handleOpen(N, JSON.parse(JSON.stringify(c)), JSON.parse(JSON.stringify(V)), M, {}, I.value);
                        break;
                }
            }
            async function Q(t, e, o, a = !1) {
                try {
                    const s = await se({
                        templateCode: e.templateCode,
                        uuid: e.templateUid,
                        ...a && {
                            refresh: !0
                        }
                    });
                    t.listInfo(s.list, s.list2), n.value[o] = {
                        list: s.list,
                        list2: s.list2
                    };
                } catch (s) {
                    console.error(`加载模板数据失败（tabKey: ${o}）`, s), t.listInfo([], []);
                }
            }
            function fe(t, e) {
                if (k.value.component === v) {
                    const o = {
                        ...n.value[r.value]?.fileListMap,
                        [e.currentIndex]: [
                            ...e.fileList
                        ]
                    };
                    n.value[r.value] = {
                        ...n.value[r.value],
                        fileListMap: o,
                        detailList: n.value[r.value]?.detailList.map((a, s)=>s === e.currentIndex ? {
                                ...a,
                                crewMonthlyReportDetailImoDetailFileVoList: [
                                    ...e.fileList
                                ],
                                crewMonthlyReportDetailImoDetailFileDtoList: [
                                    ...e.fileList
                                ]
                            } : a)
                    }, console.log("编辑场景文件更新：", n.value[r.value].fileListMap), de(e);
                }
            }
            function de(t) {
                i.value && i.value.crewMonthlyReportDetailImoDetailVoList && i.value.crewMonthlyReportDetailImoDetailVoList[t.currentIndex] && (i.value.crewMonthlyReportDetailImoDetailVoList[t.currentIndex] = {
                    ...i.value.crewMonthlyReportDetailImoDetailVoList[t.currentIndex],
                    crewMonthlyReportDetailImoDetailFileVoList: [
                        ...t.fileList
                    ],
                    crewMonthlyReportDetailImoDetailFileDtoList: [
                        ...t.fileList
                    ]
                });
            }
            function ee(t) {
                g.value = He.find((e)=>e.id === t);
            }
            async function ye(t) {
                if (F.value = te(t), g.value?.id) {
                    const e = await tt({
                        vesselId: g.value.id,
                        yearMonthStr: F.value
                    });
                    i.value = e, h.value.forEach((o)=>{
                        const a = o;
                        if (!(I.value && Object.keys(n.value[o.key]).length)) switch(a.component){
                            case D:
                                n.value[o.key] = {
                                    list: [],
                                    list2: []
                                };
                                break;
                            case b:
                            case R:
                                n.value[o.key] = e[a.initParams?.certificatesList] || [];
                                break;
                            case C:
                                n.value[o.key] = e[a.initParams?.contactList] || [];
                                break;
                            case L:
                            case v:
                                n.value[o.key] = {
                                    info: e[a.initParams?.imoInfo] || {},
                                    detailList: e[a.initParams?.imoDetailList] || [],
                                    fileListMap: {}
                                };
                                break;
                        }
                    }), await P(()=>{
                        r.value = "1", O(r.value);
                    });
                }
            }
            async function he(t) {
                J(U.value), r.value = t, U.value = t, await P(()=>{
                    O(t);
                });
            }
            function te(t) {
                t.toString().length === 10 && (t *= 1e3);
                const e = new Date(t), o = e.getFullYear(), a = (e.getMonth() + 1).toString().padStart(2, "0");
                return `${o}-${a}`;
            }
            async function _e() {
                const t = await qe();
                if (Z({
                    vesselId: t[0].id
                }), ee(t[0].id), r.value = "1", U.value = "1", I.value) {
                    K(!0);
                    const e = await Ke(Number(S.query.id));
                    i.value = e, T.value = w.value || !i.value.editFlag, Z({
                        vesselId: i.value.vesselId,
                        yearMonthStr: i.value.yearMonthStr
                    }), F.value = te(i.value.yearMonthStr), h.value.forEach((o)=>{
                        const a = o, s = n.value[o.key];
                        if (!(Array.isArray(s) && s.length || typeof s == "object" && s !== null && Object.keys(s).length)) switch(a.component){
                            case D:
                                i.value?.templateUid ? se({
                                    templateCode: i.value.templateCode,
                                    uuid: i.value.templateUid
                                }).then((c)=>{
                                    n.value[o.key] = {
                                        list: c.list,
                                        list2: c.list2
                                    };
                                }) : n.value[o.key] = {
                                    list: [],
                                    list2: []
                                };
                                break;
                            case b:
                            case R:
                                n.value[o.key] = e[a.initParams?.certificatesList] || [];
                                break;
                            case C:
                                n.value[o.key] = e[a.initParams?.contactList] || [];
                                break;
                            case L:
                            case v:
                                n.value[o.key] = {
                                    info: e[a.initParams?.imoInfo] || {},
                                    detailList: e[a.initParams?.imoDetailList] || [],
                                    fileListMap: {}
                                };
                                break;
                        }
                    });
                } else K(!1), T.value = w.value || !i.value.editFlag;
                await P(()=>{
                    O(r.value);
                });
            }
            function Le() {
                const t = {};
                return h.value.forEach((e)=>{
                    const o = n.value[e.key];
                    if (!e.dataKey || !o) return;
                    const { dataKey: a } = e;
                    a.voList && (e.component === D ? t[a.voList] = o.list : e.component === L || e.component === v ? t[a.voList] = o.detailList.map((s, c)=>o.fileListMap?.[c] ? {
                            ...s,
                            crewMonthlyReportDetailImoDetailFileVoList: o.fileListMap[c],
                            crewMonthlyReportDetailImoDetailFileDtoList: o.fileListMap[c]
                        } : s) : t[a.voList] = o), a.infoVo && o.info && (t[a.infoVo] = {
                        ...i.value?.[e.initParams?.imoInfo],
                        ...o.info
                    });
                }), t;
            }
            async function ae() {
                if (J(r.value), g.value?.shipTypeId === 1) {
                    const a = n.value[1];
                    i.value?.templateUid ? (await at({
                        template_code: i.value.templateCode,
                        uuid: i.value.templateUid,
                        list: a.list,
                        list2: a.list2
                    }), B.value = i.value.templateUid) : B.value = await ot({
                        template_code: i.value?.templateCode,
                        list: a.list,
                        list2: a.list2
                    });
                }
                const t = Le(), e = {
                    ...ce(),
                    scene: i.value?.scene,
                    templateUid: B.value,
                    ...S.query.id && {
                        id: Number(S.query.id)
                    } || {
                        id: i.value?.id
                    },
                    ...t
                }, o = await Ze(e);
                i.value = o, $.success(m("common.saveSuccessText"));
            }
            async function De() {
                await ae();
                const t = await Qe(Number(i.value?.id));
                i.value = t, i.value?.isCurrent ? (await et({
                    id: i.value.id
                }), await it({
                    shipId: i.value.vesselId,
                    busId: i.value.id,
                    moduleCode: i.value.moduleCode
                }), $.success(m("common.submitApproveText1")), ge()) : (H.value = !1, $.success(m("monthlyReport.initializeTheLatestMonthlyReport")), await P(()=>{
                    O(r.value);
                }));
            }
            function ge() {
                ne();
            }
            return Ce(()=>{
                _e();
            }), Re(()=>k.value, (t, e)=>{
                e && J(e.key);
            }, {
                deep: !0
            }), be(()=>{
                h.value.forEach((t)=>{
                    J(t.key);
                });
            }), (t, e)=>{
                const o = Ve, a = We, s = Pe, c = Fe, V = Ne, N = Oe, M = Se, E = Ue, j = Te, q = Ae, z = Be, ke = je;
                return d(), _(ke, null, {
                    default: l(()=>[
                            u(M, {
                                bordered: !1,
                                class: "proCard mb-3"
                            }, {
                                default: l(()=>[
                                        u(N, {
                                            "x-gap": "12",
                                            cols: 4
                                        }, {
                                            default: l(()=>[
                                                    u(o, {
                                                        span: 3
                                                    }, {
                                                        default: l(()=>[
                                                                u(y(Xe), {
                                                                    onRegister: y(re)
                                                                }, null, 8, [
                                                                    "onRegister"
                                                                ])
                                                            ]),
                                                        _: 1
                                                    }),
                                                    u(o, null, {
                                                        default: l(()=>[
                                                                u(V, {
                                                                    reverse: ""
                                                                }, {
                                                                    default: l(()=>[
                                                                            u(s, {
                                                                                trigger: "hover"
                                                                            }, {
                                                                                trigger: l(()=>[
                                                                                        u(a)
                                                                                    ]),
                                                                                default: l(()=>[
                                                                                        X(" " + Y(y(m)("common.back")), 1)
                                                                                    ]),
                                                                                _: 1
                                                                            }),
                                                                            !w.value && i.value?.submitFlag ? (d(), _(s, {
                                                                                key: 0,
                                                                                trigger: "hover"
                                                                            }, {
                                                                                trigger: l(()=>[
                                                                                        u(c, {
                                                                                            type: "primary",
                                                                                            strong: "",
                                                                                            bordered: "",
                                                                                            secondary: "",
                                                                                            class: "size-7",
                                                                                            onClick: e[0] || (e[0] = (f)=>De())
                                                                                        }, {
                                                                                            icon: l(()=>[
                                                                                                    (d(), _(G(y(oe)(y(ie).submit))))
                                                                                                ]),
                                                                                            _: 1
                                                                                        })
                                                                                    ]),
                                                                                default: l(()=>[
                                                                                        X(" " + Y(y(m)("common.optionsSubmitText")), 1)
                                                                                    ]),
                                                                                _: 1
                                                                            })) : W("", !0),
                                                                            !w.value && i.value?.editFlag ? (d(), _(s, {
                                                                                key: 1,
                                                                                trigger: "hover"
                                                                            }, {
                                                                                trigger: l(()=>[
                                                                                        u(c, {
                                                                                            type: "primary",
                                                                                            strong: "",
                                                                                            bordered: "",
                                                                                            secondary: "",
                                                                                            class: "size-7",
                                                                                            onClick: e[1] || (e[1] = (f)=>ae())
                                                                                        }, {
                                                                                            icon: l(()=>[
                                                                                                    (d(), _(G(y(oe)(y(ie).save))))
                                                                                                ]),
                                                                                            _: 1
                                                                                        })
                                                                                    ]),
                                                                                default: l(()=>[
                                                                                        X(" " + Y(y(m)("common.saveText")), 1)
                                                                                    ]),
                                                                                _: 1
                                                                            })) : W("", !0)
                                                                        ]),
                                                                    _: 1
                                                                })
                                                            ]),
                                                        _: 1
                                                    })
                                                ]),
                                            _: 1
                                        })
                                    ]),
                                _: 1
                            }),
                            F.value ? (d(), _(M, {
                                key: 0
                            }, {
                                default: l(()=>[
                                        u(j, {
                                            value: r.value,
                                            "onUpdate:value": [
                                                e[2] || (e[2] = (f)=>r.value = f),
                                                he
                                            ]
                                        }, {
                                            default: l(()=>[
                                                    (d(!0), Je(xe, null, $e(h.value, (f)=>(d(), _(E, {
                                                            key: f.key,
                                                            name: f.key,
                                                            tab: f.label
                                                        }, null, 8, [
                                                            "name",
                                                            "tab"
                                                        ]))), 128))
                                                ]),
                                            _: 1
                                        }, 8, [
                                            "value"
                                        ]),
                                        u(z, {
                                            class: "mt-4"
                                        }, {
                                            default: l(()=>[
                                                    u(q, {
                                                        span: 24
                                                    }, {
                                                        default: l(()=>[
                                                                (d(), _(G(k.value.component), Ee({
                                                                    ref: ue,
                                                                    readonly: T.value
                                                                }, me(k.value), {
                                                                    onSendData: e[3] || (e[3] = (f)=>fe("sendData", f))
                                                                }), null, 16, [
                                                                    "readonly"
                                                                ]))
                                                            ]),
                                                        _: 1
                                                    })
                                                ]),
                                            _: 1
                                        })
                                    ]),
                                _: 1
                            })) : W("", !0)
                        ]),
                    _: 1
                });
            };
        }
    });
});
export { na as default, __tla };
