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