import { _ as j } from "./basicModal.vue_vue_type_script_setup_true_lang-CsJydKhW.js";
import "./basicModal.vue_vue_type_style_index_0_lang-8QZP7ApW.js";
import { B as z } from "./Table-0PViRYCf.js";
import { r as n, V as C, bk as I, d as X, a as Z, a4 as G, c as g, o as q, l as a, w as H, D as J, j as Q, ac as U, cZ as Y, __tla as __tla_0 } from "./index-9PRMimni.js";
import { B as ee } from "./BasicForm-dL_oCSPM.js";
import { u as te } from "./useForm-CKmgcynv.js";
import { c as N, __tla as __tla_1 } from "./schemas-DEsCEng-.js";
import { f as h } from "./dateUtil-BtafrT1f.js";
import { j as ae, k as se } from "./workpermit-ycq2YJDA.js";
import { u as re } from "./useModal-CO65vga3.js";
let ye, ne;
let __tla = Promise.all([
    (()=>{
        try {
            return __tla_0;
        } catch  {}
    })(),
    (()=>{
        try {
            return __tla_1;
        } catch  {}
    })()
]).then(async ()=>{
    const { t } = C(), b = I(), { methodList: ie, statusList: oe } = N(), le = [
        {
            value: 0,
            label: t("hsqe.workpermit.statusExpired")
        },
        {
            value: 1,
            label: t("hsqe.workpermit.statusActive")
        },
        {
            value: 2,
            label: t("hsqe.workpermit.ineffective")
        }
    ];
    ne = function() {
        const c = n(), u = n(), f = [
            {
                title: t("hsqe.workpermit.tableNum"),
                key: "",
                width: 60,
                render (e, i) {
                    return (c.value - 1) * u.value + i + 1;
                }
            },
            {
                title: t("hsqe.workpermit.permitNo"),
                key: "workPermitsNo",
                width: 200
            },
            {
                title: t("hsqe.workpermit.vessel"),
                key: "shipName",
                width: 200,
                render (e) {
                    return b.getLocale === "en" ? e.shipNameEn : e.shipName;
                }
            },
            {
                title: t("hsqe.workpermit.permit"),
                key: "permitsTypeName",
                width: 400,
                render (e) {
                    return b.getLocale === "en" ? e.permitsTypeNameEn : e.permitsTypeName;
                }
            },
            {
                title: t("hsqe.workpermit.Status"),
                key: "workPermitsStatus",
                width: 200,
                render (e) {
                    return oe.find((s)=>s.value === e?.workPermitsStatus)?.label;
                }
            },
            {
                title: t("hsqe.workpermit.applicationMethod"),
                key: "processType",
                width: 200,
                render (e) {
                    return ie.find((s)=>s.value === e.processType)?.label;
                }
            },
            {
                title: t("hsqe.workpermit.validateTime"),
                key: "validateTime",
                width: 350,
                render (e) {
                    return e.validateTimeStart && e.validateTimeEnd ? h(e.validateTimeStart) + " - " + h(e.validateTimeEnd) : "";
                }
            },
            {
                title: t("hsqe.workpermit.validateStatus"),
                key: "validateStatus",
                width: 200,
                render (e) {
                    return le.find((s)=>s.value === e?.validateStatus)?.label;
                }
            },
            {
                title: t("hsqe.workpermit.requestBy"),
                key: "roleNameEn",
                width: 200,
                render (e) {
                    return b.getLocale === "en" ? e.roleNameEn : e.roleName;
                }
            },
            {
                title: t("hsqe.workpermit.requestTime"),
                key: "submitTime",
                width: 200
            }
        ], p = [
            {
                type: "selection",
                key: "selection",
                multiple: !1,
                width: 80
            },
            {
                title: t("hsqe.workpermit.tableNum"),
                key: "workPermitsNo",
                width: 200
            },
            {
                title: t("hsqe.workpermit.validateTime"),
                key: "validateTime",
                width: 350,
                render (e) {
                    return e.validateTimeStart && e.validateTimeEnd ? h(e.validateTimeStart) + " - " + h(e.validateTimeEnd) : "";
                }
            }
        ];
        return {
            columns: f,
            selectPermitTableColumns: p,
            selectRaReportTableColumns: [],
            methods: {
                setPage: (e)=>{
                    c.value = e.pageNum, u.value = e.pageSize;
                }
            }
        };
    };
    ye = X({
        __name: "SelectDataModal",
        props: {
            type: {},
            params: {},
            treeData: {}
        },
        emits: [
            "success"
        ],
        setup (c, { expose: u, emit: f }) {
            const p = c, k = f, R = Y(), { t: e } = C(), i = n(), s = n([]), S = n([]), w = n(), [P, { openModal: D, closeModal: _, setSubLoading: v, setProps: B }] = re({
                title: "",
                width: 800
            }), { selectPermitSearchSchemas: x } = N(p), { selectPermitTableColumns: E, selectRaReportTableColumns: L } = ne(), M = Z({
                permit: {
                    columns: E,
                    title: e("hsqe.workpermit.selectPermitTitle"),
                    tableKey: "id",
                    func: se,
                    schemas: x
                },
                raReport: {
                    columns: L,
                    title: e("hsqe.workpermit.selectRaReportTitle"),
                    tableKey: "id",
                    func: ae
                }
            }), l = G(()=>M[p.type] || {}), [K, { setFieldsValue: me, getFieldsValue: T, setSchema: F }] = te({
                gridProps: {
                    cols: 2
                },
                schemas: l.value?.schemas || [],
                labelWidth: "auto",
                labelPlacement: "top",
                showAdvancedButton: !1
            });
            async function O(r, o) {
                console.error(T(), "getFieldsValue().workPermitsType");
                const d = await l.value?.func({
                    ...r,
                    ...o,
                    workPermitsType: T().workPermitsType || "SSC021801"
                });
                return S.value = d.list, d;
            }
            function V() {
                B({
                    title: l.value?.title
                }), D(), U(()=>{
                    y();
                });
            }
            function y(r) {
                i.value.restReload(), F(l.value?.schemas);
            }
            function A(r) {
                s.value = a(r);
            }
            async function W() {
                if (!s.value?.length) {
                    R.error(e("hsqe.workpermit.selectTips")), v(!1);
                    return;
                }
                try {
                    const r = s.value?.[0];
                    _(), v(!1), w.value = S.value.filter((o)=>o.id == r), console.error("currentData.value", w.value), k("success", {
                        ...w.value[0],
                        selectedId: r
                    });
                } catch  {
                    v(!1);
                }
            }
            function $() {
                i.value?.restCheckedRowKeys(), k("success", "");
            }
            return u({
                handleOpenModal: V
            }), (r, o)=>{
                const d = j;
                return q(), g(d, {
                    ref: "modalRef",
                    onRegister: a(P),
                    onOnOk: W,
                    onOnClose: $,
                    subBtuText: a(e)("common.confirmText")
                }, {
                    default: H(()=>[
                            a(l)?.schemas ? (q(), g(a(ee), {
                                key: 0,
                                onRegister: a(K),
                                onSubmit: o[0] || (o[0] = (m)=>y(!0)),
                                onReset: o[1] || (o[1] = (m)=>y(!0))
                            }, null, 8, [
                                "onRegister"
                            ])) : J("", !0),
                            Q(a(z), {
                                ref_key: "basicTableRef",
                                ref: i,
                                columns: a(l)?.columns,
                                request: (m)=>O(m, a(T)()),
                                "row-key": (m)=>m[a(l)?.tableKey],
                                immediate: !1,
                                showTableSetting: !1,
                                autoScrollX: "",
                                virtualScroll: "",
                                isKeepRowKeys: "",
                                checkedRowAlert: "",
                                onCheckedRowChange: A
                            }, null, 8, [
                                "columns",
                                "request",
                                "row-key"
                            ])
                        ]),
                    _: 1
                }, 8, [
                    "onRegister",
                    "subBtuText"
                ]);
            };
        }
    });
});
export { ye as _, ne as c, __tla };
