import { _ as V } 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 k } from "./BasicForm-dL_oCSPM.js";
import { u as O } from "./useForm-CKmgcynv.js";
import { e as B, j as L, P as j, Q as A, v as E } from "./template-rpthWlT9.js";
import { r as l, V as R, bk as G, d as H, c as W, o as z, l as u, w as Q, j as U, ac as h, cZ as Y, __tla as __tla_0 } from "./index-9PRMimni.js";
import { u as Z } from "./useModal-CO65vga3.js";
let ie;
let __tla = Promise.all([
    (()=>{
        try {
            return __tla_0;
        } catch  {}
    })()
]).then(async ()=>{
    const b = G(), { t: o } = R(), $ = await B({
        roleType: 2,
        roleCategory: 1
    }), J = await L(), v = await j();
    function K() {
        const d = l();
        return {
            schemas: [
                {
                    field: "reportNo",
                    component: "NInput",
                    label: o("hsqe.auditInspection.vesselInspection.shipVisitReport.deficiencyReport.basicInfo.relatedReportNo"),
                    componentProps: {
                        disabled: !0
                    }
                },
                {
                    field: "findingSectionCode",
                    component: "NSelect",
                    label: o("hsqe.cdi.findingsSection"),
                    componentProps: ({ formAction: t })=>{
                        const { setFieldsValue: e } = t;
                        return {
                            options: v,
                            "label-field": "name",
                            "value-field": "name",
                            onUpdateValue: async (s)=>{
                                const a = v.filter((p)=>p.name == s);
                                d.value = await A(a[0].id), e({
                                    findingCode: null
                                });
                            }
                        };
                    },
                    rules: [
                        {
                            required: !0,
                            validator: (t, e)=>e != null,
                            message: o("common.chooseText"),
                            trigger: [
                                "blur",
                                "change"
                            ]
                        }
                    ]
                },
                {
                    field: "findingCode",
                    component: "NSelect",
                    label: o("hsqe.cdi.findingsChild"),
                    componentProps: {
                        options: d,
                        "label-field": "name",
                        "value-field": "name"
                    },
                    rules: [
                        {
                            required: !0,
                            validator: (t, e)=>e != null,
                            message: o("common.chooseText"),
                            trigger: [
                                "blur",
                                "change"
                            ]
                        }
                    ]
                },
                {
                    field: "expirationTime",
                    component: "NDatePicker",
                    label: o("hsqe.cdi.expirationTime"),
                    componentProps: {
                        type: "date",
                        valueFormat: "yyyy-MM-dd hh:mm:ss",
                        isDateDisabled: (t)=>{
                            const e = new Date;
                            e.setHours(0, 0, 0, 0);
                            const s = new Date(t);
                            return s.setHours(0, 0, 0, 0), s < e;
                        }
                    },
                    rules: [
                        {
                            required: !0,
                            validator: (t, e)=>e != null,
                            message: o("common.chooseText"),
                            trigger: [
                                "blur",
                                "change"
                            ]
                        }
                    ]
                },
                {
                    field: "vesselPositionCode",
                    component: "NSelect",
                    label: o("hsqe.auditInspection.vesselInspection.shipVisitReport.deficiencyReport.basicInfo.vesselResponsible"),
                    componentProps: {
                        options: $,
                        "label-field": b.getLocale === "en" ? "nameEn" : "name",
                        "value-field": "code"
                    },
                    rules: [
                        {
                            required: !0,
                            validator: (t, e)=>e != null,
                            message: o("common.chooseText"),
                            trigger: [
                                "blur",
                                "change"
                            ]
                        }
                    ]
                },
                {
                    field: "officePositionCode",
                    component: "NSelect",
                    label: o("hsqe.auditInspection.vesselInspection.shipVisitReport.deficiencyReport.basicInfo.officeResponsible"),
                    componentProps: {
                        options: J,
                        "label-field": b.getLocale === "en" ? "nameEn" : "name",
                        "value-field": "code"
                    },
                    rules: [
                        {
                            required: !0,
                            validator: (t, e)=>e != null,
                            message: o("common.chooseText"),
                            trigger: [
                                "blur",
                                "change"
                            ]
                        }
                    ]
                },
                {
                    field: "basicDescription",
                    component: "NInput",
                    giProps: {
                        span: 2
                    },
                    label: o("hsqe.cdi.description"),
                    componentProps: {
                        type: "textarea",
                        maxlength: 300,
                        showCount: !0
                    }
                }
            ]
        };
    }
    ie = H({
        __name: "Modal",
        emits: [
            "success",
            "changeResult"
        ],
        setup (d, { expose: m, emit: t }) {
            const e = t, s = Y(), { t: a } = R(), { schemas: p } = K(), [x, { openModal: y, closeModal: _, setProps: I, setSubLoading: f }] = Z({
                title: a("common.addText"),
                subBtuText: a("common.okText"),
                cancelText: a("common.cancelText"),
                width: 650
            }), [T, { submit: w, setFieldsValue: C, getFieldsValue: N }] = O({
                schemas: p,
                labelWidth: "auto",
                layout: "horizontal",
                gridProps: {
                    cols: 2,
                    xGap: 15
                },
                showActionButtonGroup: !1
            }), P = l(), r = l(), g = l();
            async function q(i, c) {
                r.value = i, g.value = c, P.value = i.reportNum, y();
                const n = {
                    reportNo: i.reportNum
                };
                await h(), C(n);
            }
            async function M() {
                await h();
            }
            const S = l("");
            async function D() {
                if (!await w()) return f(!1), !1;
                const c = N();
                delete c.equipmentId;
                const n = await E({
                    ...c,
                    reportId: g.value,
                    shipId: r.value.shipId,
                    auditTypeId: r.value.visitType,
                    reportType: "sireReport",
                    status: "new"
                });
                console.log(n), n.data.success ? (s.success(a("common.saveSuccessText")), _(), e("success")) : (s.error(n.data.msg), f(!1));
            }
            function F() {
                e("changeResult", r.value, S.value || "Yes");
            }
            return m({
                showModal: q,
                setProps: I,
                getData: M
            }), (i, c)=>{
                const n = V;
                return z(), W(n, {
                    ref: "modalRef",
                    onRegister: u(x),
                    class: "basicModal basicFormModal",
                    onOnOk: D,
                    onOnClose: F
                }, {
                    default: Q(()=>[
                            U(u(k), {
                                onRegister: u(T),
                                "label-placement": "top"
                            }, null, 8, [
                                "onRegister"
                            ])
                        ]),
                    _: 1
                }, 8, [
                    "onRegister"
                ]);
            };
        }
    });
});
export { ie as _, __tla };
