import { d as se, V as ne, r as c, a as ie, Z as E, h as ce, o as g, j as d, w as n, l as t, ds as x, c as w, D as P, H as ue, aI as pe, p as q, A, B as de, ca as U, gW as $, gX as N, X as me, F as fe, ac as z, __tla as __tla_0 } from "./index-9PRMimni.js";
import { _ as ve } from "./TableSelect.vue_vue_type_script_setup_true_lang-BAU5mgvB.js";
import { c as _e, __tla as __tla_1 } from "./columns-DY6kUOTk.js";
import { B as ye } from "./Table-0PViRYCf.js";
import { _ as ge } from "./TableAction.vue_vue_type_script_setup_true_lang-Bj_Y4LtN.js";
import { B as he } from "./BasicForm-dL_oCSPM.js";
import { u as we } from "./useForm-CKmgcynv.js";
import { o as Fe, __tla as __tla_2 } from "./schemas-BqGurRC_.js";
import { _ as be, __tla as __tla_3 } from "./UploadFile.vue_vue_type_script_setup_true_lang--uWupa0a.js";
import { aa as Ie } from "./template-rpthWlT9.js";
import { g as De } from "./planner-BebmniHR.js";
let xe;
let __tla = Promise.all([
    (()=>{
        try {
            return __tla_0;
        } catch  {}
    })(),
    (()=>{
        try {
            return __tla_1;
        } catch  {}
    })(),
    (()=>{
        try {
            return __tla_2;
        } catch  {}
    })(),
    (()=>{
        try {
            return __tla_3;
        } catch  {}
    })()
]).then(async ()=>{
    let Pe;
    Pe = {
        name: "OilIMOCrewlist"
    };
    xe = se({
        ...Pe,
        props: {
            readonly: {
                type: Boolean,
                default: !1
            }
        },
        emits: [
            "send-data"
        ],
        setup (W, { expose: X, emit: K }) {
            const { t: i } = ne(), V = W, _ = c(), u = c([]), y = c(), b = c(V.readonly), R = c([]), T = c(), B = c(!0), S = _e(), m = c({}), h = c(!1), { methods: { updateIsEditOilTab3: k } } = S, { oilIMOregister: j, methods: G } = Fe(), [H, { getFieldsValue: F, setFieldsValue: Z }] = we({
                gridProps: {
                    cols: 10
                },
                schemas: j,
                labelPlacement: "top",
                showActionButtonGroup: !1,
                showAdvancedButton: !1
            }), J = K, Q = ie({
                width: 200,
                title: i("common.optionsText"),
                key: "action",
                fixed: "right",
                align: "center",
                render (o, e) {
                    return E(ge, {
                        style: "text",
                        actions: [
                            {
                                label: i("hsqe.rs.uploadText"),
                                labelShow: !1,
                                icon: E("i", {
                                    class: "iconfont icon-upload1 text-[#3F7AE9] text-[20px]"
                                }),
                                onClick: Y.bind(null, o, e)
                            }
                        ]
                    });
                }
            }), f = c({}), C = {
                gridProps: {
                    cols: "2"
                },
                labelWidth: 80,
                submitButtonText: i("common.searchText"),
                showAdvancedButton: !1,
                schemas: [
                    {
                        field: "namePrefix",
                        component: "NInput",
                        label: i("hsqe.planner.modal.planPort")
                    }
                ]
            }, O = [
                {
                    title: i("hsqe.planner.modal.port"),
                    key: "port"
                },
                {
                    title: i("hsqe.planner.modal.country"),
                    key: "country"
                }
            ];
            function M(o) {
                return De({
                    ...o,
                    ...t(f)
                });
            }
            function Y(o, e) {
                const l = m.value[e] || o.crewMonthlyReportDetailImoDetailFileVoList || [];
                T.value?.handleOpenModal(l, e, B.value);
            }
            function ee(o) {
                const { currentIndex: e, fileList: l } = o;
                h.value ? (m.value[e] = [
                    ...l
                ], u.value[e] && (u.value[e] = {
                    ...u.value[e],
                    crewMonthlyReportDetailImoDetailFileVoList: [
                        ...l
                    ],
                    crewMonthlyReportDetailImoDetailFileDtoList: [
                        ...l
                    ]
                })) : (m.value[e] = [
                    ...l
                ], u.value[e] && (u.value[e].crewMonthlyReportDetailImoDetailFileVoList = [
                    ...l
                ])), J("send-data", {
                    ...o,
                    isEdit: h.value
                });
            }
            function te() {
                y.value = !0, k(t(y));
            }
            function L() {
                y.value = !1, k(t(y));
            }
            function oe() {
                let o = _.value?.getDataSource();
                return !o || !o.length ? [] : (o = o.map((e, l)=>{
                    const v = m.value[l] || e.crewMonthlyReportDetailImoDetailFileVoList || [];
                    return {
                        ...e,
                        crewMonthlyReportDetailImoDetailFileVoList: [
                            ...v
                        ],
                        crewMonthlyReportDetailImoDetailFileDtoList: [
                            ...v
                        ]
                    };
                }), o);
            }
            function ae() {
                return {
                    ...F(),
                    onBroadPortEn: F().onBroadPort,
                    upBroadPortEn: F().upBroadPort,
                    portArrivalFromEn: F().portArrivalFrom
                };
            }
            async function le(o, e, l, v, p = {}, I = !1) {
                B.value = v, h.value = I, await L(), G.updateIsEditIMO(V.readonly), Z({
                    vesselId: o.id,
                    ...e,
                    flagStateId: o.flagStateId
                });
                let D = await Promise.all(l.map(async (a, r)=>(a.nationalId ? a.provinceList = await Ie({
                        countryId: a.nationalId
                    }) : a.provinceList = [], h.value && p[r] ? (a.crewMonthlyReportDetailImoDetailFileVoList = [
                        ...p[r]
                    ], m.value[r] = [
                        ...p[r]
                    ]) : !h.value && p[r] && (a.crewMonthlyReportDetailImoDetailFileVoList = [
                        ...p[r]
                    ], m.value[r] = [
                        ...p[r]
                    ]), a)));
                u.value = D, R.value = S.OilIMOCrewlistColumns, z(()=>{
                    _.value?.reload(), _.value?.setBordered(!0), _.value?.setStriped(!1);
                });
            }
            function re(o, e) {
                m.value[o] = [
                    ...e
                ], u.value[o] && (u.value[o].crewMonthlyReportDetailImoDetailFileVoList = [
                    ...e
                ], z(()=>{
                    _.value?.reload();
                }));
            }
            return X({
                handleOpen: le,
                infoVo: ae,
                voList: oe,
                updateFileList: re
            }), (o, e)=>{
                const l = ve, v = de, p = pe, I = ue, D = me;
                return g(), ce(fe, null, [
                    d(D, null, {
                        default: n(()=>[
                                d(t(he), {
                                    onRegister: t(H)
                                }, {
                                    onBroadPort: n(({ model: a, field: r })=>[
                                            d(l, {
                                                ref: "portTableSelectRef",
                                                labelField: "port",
                                                valueField: "id",
                                                value: a[r],
                                                "onUpdate:value": (s)=>a[r] = s,
                                                formValues: t(f),
                                                "onUpdate:formValues": e[0] || (e[0] = (s)=>x(f) ? f.value = s : null),
                                                multiple: !1,
                                                formProps: C,
                                                disabled: t(b),
                                                selectTitle: t(i)("hsqe.planner.modal.selectPort"),
                                                class: "w-full",
                                                tableProps: {
                                                    rowKey: (s)=>s.id,
                                                    request: M,
                                                    columns: O,
                                                    pagination: {
                                                        simple: !0
                                                    }
                                                }
                                            }, null, 8, [
                                                "value",
                                                "onUpdate:value",
                                                "formValues",
                                                "disabled",
                                                "selectTitle",
                                                "tableProps"
                                            ])
                                        ]),
                                    portArrivalFrom: n(({ model: a, field: r })=>[
                                            d(l, {
                                                ref: "portTableSelectRef",
                                                labelField: "port",
                                                valueField: "id",
                                                value: a[r],
                                                "onUpdate:value": (s)=>a[r] = s,
                                                formValues: t(f),
                                                "onUpdate:formValues": e[1] || (e[1] = (s)=>x(f) ? f.value = s : null),
                                                multiple: !1,
                                                formProps: C,
                                                disabled: t(b),
                                                selectTitle: t(i)("hsqe.planner.modal.selectPort"),
                                                class: "w-full",
                                                tableProps: {
                                                    rowKey: (s)=>s.id,
                                                    request: M,
                                                    columns: O,
                                                    pagination: {
                                                        simple: !0
                                                    }
                                                }
                                            }, null, 8, [
                                                "value",
                                                "onUpdate:value",
                                                "formValues",
                                                "disabled",
                                                "selectTitle",
                                                "tableProps"
                                            ])
                                        ]),
                                    _: 1
                                }, 8, [
                                    "onRegister"
                                ]),
                                d(t(ye), {
                                    ref_key: "crewTableRef",
                                    ref: _,
                                    columns: t(R),
                                    dataSource: t(u),
                                    "row-key": (a)=>a.id,
                                    autoScrollX: !0,
                                    immediate: !0,
                                    pagination: !1,
                                    actionColumn: t(Q),
                                    "can-resize": !1,
                                    "show-table-setting": !1
                                }, {
                                    toolbar: n(()=>[
                                            t(b) ? P("", !0) : (g(), w(I, {
                                                key: 0,
                                                reverse: ""
                                            }, {
                                                default: n(()=>[
                                                        t(y) ? P("", !0) : (g(), w(p, {
                                                            key: 0,
                                                            trigger: "hover"
                                                        }, {
                                                            trigger: n(()=>[
                                                                    d(v, {
                                                                        type: "primary",
                                                                        strong: "",
                                                                        bordered: "",
                                                                        secondary: "",
                                                                        class: "size-7",
                                                                        onClick: te
                                                                    }, {
                                                                        icon: n(()=>[
                                                                                (g(), w(U(t($)(t(N).edit))))
                                                                            ]),
                                                                        _: 1
                                                                    })
                                                                ]),
                                                            default: n(()=>[
                                                                    q(" " + A(t(i)("common.optionsEditText")), 1)
                                                                ]),
                                                            _: 1
                                                        })),
                                                        t(y) ? (g(), w(p, {
                                                            key: 1,
                                                            trigger: "hover"
                                                        }, {
                                                            trigger: n(()=>[
                                                                    d(v, {
                                                                        type: "primary",
                                                                        strong: "",
                                                                        bordered: "",
                                                                        secondary: "",
                                                                        class: "size-7",
                                                                        onClick: e[2] || (e[2] = (a)=>L())
                                                                    }, {
                                                                        icon: n(()=>[
                                                                                (g(), w(U(t($)(t(N).save))))
                                                                            ]),
                                                                        _: 1
                                                                    })
                                                                ]),
                                                            default: n(()=>[
                                                                    q(" " + A(t(i)("common.saveText")), 1)
                                                                ]),
                                                            _: 1
                                                        })) : P("", !0)
                                                    ]),
                                                _: 1
                                            }))
                                        ]),
                                    _: 1
                                }, 8, [
                                    "columns",
                                    "dataSource",
                                    "row-key",
                                    "actionColumn"
                                ])
                            ]),
                        _: 1
                    }),
                    d(be, {
                        ref_key: "uploadFileRef",
                        ref: T,
                        onSuccess: ee
                    }, null, 512)
                ], 64);
            };
        }
    });
});
export { xe as _, __tla };
