import { B as V } from "./BasicForm-dL_oCSPM.js";
import { _ as $ } from "./basicModal.vue_vue_type_script_setup_true_lang-CsJydKhW.js";
import "./basicModal.vue_vue_type_style_index_0_lang-8QZP7ApW.js";
import { u as A } from "./useModal-CO65vga3.js";
import { B as P } from "./Table-0PViRYCf.js";
import { V as h, bk as k, d as q, r as b, bl as D, c as U, o as W, l as e, w as g, j as c, W as j, cZ as X, gI as Z, __tla as __tla_0 } from "./index-9PRMimni.js";
import { g as R } from "./equipmentMainLibrary-bJTzj5mC.js";
import { a as z, c as G } from "./helper-D9DF1oLX.js";
import { f as H } from "./find-D_h_aJYR.js";
import { i as J, g as K } from "./vesselsCertificate-Hd_5oIk8.js";
import { u as Q } from "./useForm-CKmgcynv.js";
let pe;
let __tla = Promise.all([
    (()=>{
        try {
            return __tla_0;
        } catch  {}
    })()
]).then(async ()=>{
    const { t: n } = h(), T = k(), Y = await R("certificate_category"), ee = await R("ship_certificate_type");
    function te() {
        return [
            {
                field: "category",
                component: "NSelect",
                label: n("vesselsCertificate.certificateCategory"),
                componentProps: {
                    placeholder: n("vesselsCertificate.certificateCategory"),
                    labelField: T.getLocale === "en" ? "labelEn" : "label",
                    options: Y
                }
            },
            {
                field: "type",
                component: "NSelect",
                label: n("vesselsCertificate.certificateType"),
                componentProps: {
                    placeholder: n("vesselsCertificate.certificateType"),
                    labelField: T.getLocale === "en" ? "labelEn" : "label",
                    options: ee
                }
            },
            {
                field: "status",
                hidden: !0,
                defaultValue: "0"
            }
        ];
    }
    const { t } = h(), l = k();
    function se() {
        return [
            {
                type: "selection",
                width: 40
            },
            {
                title: t("vesselsCertificate.no"),
                key: "no",
                width: 60,
                render: (o, s)=>s + 1
            },
            {
                title: t("vesselsCertificate.certificateCategory"),
                key: l.getLocale === "en" ? "categoryNameEn" : "categoryName",
                width: 160
            },
            {
                title: t("vesselsCertificate.certificateTypeNo"),
                key: "no",
                width: 160
            },
            {
                title: t("vesselsCertificate.certificateType"),
                key: l.getLocale === "en" ? "termTypeNameEn" : "termTypeName",
                width: 150
            },
            {
                title: t("vesselsCertificate.certificateNameEn"),
                key: "englishName",
                width: 170
            },
            {
                title: t("vesselsCertificate.certificateNameCn"),
                key: "chineseName",
                width: 170
            },
            {
                title: t("vesselsCertificate.validityType"),
                key: l.getLocale === "en" ? "termTypeNameEn" : "termTypeName",
                width: 120
            },
            {
                title: t("vesselsCertificate.validity"),
                key: "validity",
                width: 100,
                render (o) {
                    const { validity: s, validityUnit: f } = o, a = z(f);
                    return s ? `${s} ${a}` : "";
                }
            },
            {
                title: t("vesselsCertificate.status"),
                key: "status",
                width: 160,
                render (o) {
                    return H(G, {
                        value: o.status
                    })?.[l.getLocale === "en" ? "labelEn" : "label"] ?? "";
                }
            }
        ];
    }
    pe = q({
        __name: "index",
        emits: [
            "refresh"
        ],
        setup (o, { expose: s, emit: f }) {
            const { t: a } = h(), C = X(), N = f, d = b(0), _ = D("tableRef"), [L, { openModal: x, closeModal: S, setSubLoading: m }] = A({
                title: a("vesselsCertificate.getCertificateList"),
                subBtuText: a("common.confirmText"),
                cancelText: a("common.cancelText"),
                width: 1200
            }), [O, { getFieldsValue: B }] = Q({
                schemas: te(),
                gridProps: {
                    cols: 4
                },
                showAdvancedButton: !1
            }), u = b([]);
            function E(i, r) {
                u.value = r;
            }
            async function I() {
                try {
                    if (e(u).length === 0) {
                        C.warning(a("vesselsCertificate.selectAtLeastOneCertConfig")), m(!1);
                        return;
                    }
                    await J({
                        shipId: e(d),
                        configIds: Z(u.value, "id")
                    }), C.success(a("common.optionsAddSuccessText")), m(!1), N("refresh"), S();
                } catch  {
                    m(!1);
                }
            }
            async function F(i, r) {
                try {
                    return await K({
                        ...r,
                        ...i,
                        shipId: e(d)
                    });
                } catch  {
                    return {
                        list: [],
                        total: 0
                    };
                }
            }
            function v() {
                _.value?.restReload();
            }
            function M(i) {
                d.value = i.shipId, x();
            }
            return s({
                handleOpenModal: M
            }), (i, r)=>{
                const p = V, w = j;
                return W(), U(e($), {
                    onRegister: e(L),
                    onOnOk: I
                }, {
                    default: g(()=>[
                            c(w, {
                                bordered: !1,
                                class: "proCard",
                                "content-class": "py-0"
                            }, {
                                default: g(()=>[
                                        c(p, {
                                            onRegister: e(O),
                                            onSubmit: v,
                                            onReset: v
                                        }, null, 8, [
                                            "onRegister"
                                        ])
                                    ]),
                                _: 1
                            }),
                            c(w, {
                                bordered: !1,
                                class: "proCard mt-2"
                            }, {
                                default: g(()=>[
                                        c(e(P), {
                                            ref_key: "tableRef",
                                            ref: _,
                                            columns: e(se)(),
                                            request: (y)=>F(y, e(B)()),
                                            "row-key": (y)=>y.id,
                                            autoScrollX: !0,
                                            onCheckedRowChange: E,
                                            "virtual-scroll": ""
                                        }, null, 8, [
                                            "columns",
                                            "request",
                                            "row-key"
                                        ])
                                    ]),
                                _: 1
                            })
                        ]),
                    _: 1
                }, 8, [
                    "onRegister"
                ]);
            };
        }
    });
});
export { pe as _, __tla };
