import { _ as O } 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 F } from "./BasicForm-dL_oCSPM.js";
import { u as L } from "./useForm-CKmgcynv.js";
import { aj as k, e as B, j as E, i as j, v as z } from "./template-rpthWlT9.js";
import { a as A, d as I, e as G, b as H } from "./helper-Czt-QYps.js";
import { V as R, bk as W, l as r, r as f, d as U, f as Y, c as Z, o as $, w as J, j as K, ac as y, cZ as Q, __tla as __tla_0 } from "./index-9PRMimni.js";
import { u as X } from "./useModal-CO65vga3.js";
let me;
let __tla = Promise.all([
    (()=>{
        try {
            return __tla_0;
        } catch  {}
    })()
]).then(async ()=>{
    let m, o, ee, oe, te, se, l, ne;
    m = W();
    ({ t: o } = R());
    ee = await j();
    oe = await k();
    te = await B({
        roleType: 2,
        roleCategory: 1
    });
    se = await E();
    l = f(!1);
    ne = [
        {
            field: "shipId",
            hidden: !0
        },
        {
            field: "reportNo",
            component: "NInput",
            label: o("hsqe.auditInspection.vesselInspection.shipVisitReport.deficiencyReport.basicInfo.relatedReportNo"),
            componentProps: {
                disabled: !0
            }
        },
        {
            field: "severity",
            component: "NSelect",
            label: o("hsqe.auditInspection.vesselInspection.shipVisitReport.deficiencyReport.basicInfo.severity"),
            componentProps: (t, e)=>({
                    options: ee,
                    "label-field": m.getLocale === "en" ? "labelEn" : "label"
                }),
            rules: [
                {
                    required: !0,
                    validator: (t, e)=>e != null,
                    message: o("common.chooseText"),
                    trigger: [
                        "blur",
                        "change"
                    ]
                }
            ]
        },
        {
            field: "isMemo",
            component: "NSwitch",
            label: o("hsqe.auditInspection.vesselInspection.shipVisitReport.deficiencyReport.basicInfo.isMemo")
        },
        {
            field: "deficiencyCode",
            component: "NSelect",
            label: o("hsqe.auditInspection.vesselInspection.shipVisitReport.deficiencyReport.basicInfo.deficiencyCode"),
            componentProps: {
                disabled: !0,
                options: oe,
                labelField: m.getLocale === "en" ? "labelEn" : "label"
            },
            rules: [
                {
                    required: !0,
                    validator: (t, e)=>e != null,
                    message: o("common.chooseText"),
                    trigger: [
                        "blur",
                        "change"
                    ]
                }
            ]
        },
        {
            field: "equipmentId",
            component: "NSelect",
            label: o("hsqe.auditInspection.vesselInspection.shipVisitReport.deficiencyReport.basicInfo.equipment"),
            componentProps: ({ model: t, formAction: e })=>{
                const { shipId: n } = t, { setFieldsValue: p } = e;
                return {
                    show: l,
                    remote: !0,
                    clearable: !0,
                    filterable: !0,
                    loading: r(H),
                    options: r(G),
                    placeholder: o("common.inputTextToSearch"),
                    onClear: ()=>{
                        I({
                            shipId: n
                        });
                    },
                    onBlur: ()=>{
                        l.value = !1;
                    },
                    onSearch: async (i)=>{
                        i.length > 0 ? l.value = !0 : l.value = !1, I({
                            shipId: n,
                            productName: i
                        });
                    },
                    onUpdateValue: async (i)=>{
                        const h = await A(i);
                        p({
                            equipmentValue: h
                        }), l.value = !1;
                    }
                };
            }
        },
        {
            field: "equipmentValue",
            component: "NSelect",
            label: o("hsqe.auditInspection.vesselInspection.shipVisitReport.deficiencyReport.basicInfo.criticalEquipment"),
            componentProps: {
                disabled: !0,
                options: [
                    {
                        label: o("common.yes"),
                        value: "1"
                    },
                    {
                        label: o("common.no"),
                        value: "0"
                    }
                ]
            }
        },
        {
            field: "expirationTime",
            component: "NDatePicker",
            label: o("hsqe.auditInspection.vesselInspection.shipVisitReport.deficiencyReport.basicInfo.expiryDate"),
            componentProps: {
                type: "date",
                valueFormat: "yyyy-MM-dd hh:mm:ss",
                isDateDisabled: (t)=>{
                    const e = new Date;
                    e.setHours(0, 0, 0, 0);
                    const n = new Date(t);
                    return n.setHours(0, 0, 0, 0), n < e;
                }
            },
            rules: [
                {
                    required: !0,
                    validator: (t, e)=>e != null,
                    message: o("common.chooseText"),
                    trigger: [
                        "blur",
                        "change"
                    ]
                }
            ]
        },
        {
            field: "zhanwei"
        },
        {
            field: "vesselPositionCode",
            component: "NSelect",
            label: o("hsqe.auditInspection.vesselInspection.shipVisitReport.deficiencyReport.basicInfo.vesselResponsible"),
            componentProps: {
                options: te,
                "label-field": m.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: se,
                "label-field": m.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",
            label: o("hsqe.cdi.description"),
            componentProps: {
                type: "textarea",
                maxlength: 300,
                showCount: !0
            }
        }
    ];
    me = U({
        __name: "Modal",
        emits: [
            "success",
            "changeResult"
        ],
        setup (t, { expose: e, emit: n }) {
            const p = n, i = Q(), h = Y(), { t: d } = R(), [q, { openModal: _, closeModal: x, setProps: w, setSubLoading: g }] = X({
                title: d("common.addText"),
                subBtuText: d("common.okText"),
                cancelText: d("common.cancelText"),
                width: 650
            }), [T, { submit: V, setFieldsValue: C, getFieldsValue: M }] = L({
                schemas: ne,
                labelWidth: "auto",
                layout: "horizontal",
                gridProps: {
                    cols: 2,
                    xGap: 15
                },
                showActionButtonGroup: !1
            }), v = f(), c = f();
            async function N(u, s) {
                v.value = u, c.value = s, b.value = "", _(), await y();
                const a = {
                    reportNo: u,
                    deficiencyCode: s.inspectionType
                };
                C({
                    ...a,
                    shipId: s.shipId
                });
            }
            async function S() {
                await y();
            }
            const b = f("");
            async function P() {
                if (!await V()) return g(!1), !1;
                const s = M();
                delete s.equipmentId;
                const a = await z({
                    ...s,
                    reportId: h.query.uuid,
                    planId: c.value.plannerId,
                    shipId: c.value.shipId,
                    auditTypeId: c.value.visitType,
                    reportType: "vessel_inspection",
                    isMemo: s.isMemo == !0 ? "yes" : "no",
                    reportNo: v.value,
                    status: "new"
                });
                a.data.success ? (b.value = "No", i.success(d("common.saveSuccessText")), x(), p("success")) : (i.error(a.data.msg), g(!1));
            }
            function D() {
                p("changeResult", c.value, b.value || "Yes");
            }
            return e({
                showModal: N,
                setProps: w,
                getData: S
            }), (u, s)=>{
                const a = O;
                return $(), Z(a, {
                    ref: "modalRef",
                    onRegister: r(q),
                    class: "basicModal basicFormModal",
                    onOnOk: P,
                    onOnClose: D
                }, {
                    default: J(()=>[
                            K(r(F), {
                                onRegister: r(T)
                            }, null, 8, [
                                "onRegister"
                            ])
                        ]),
                    _: 1
                }, 8, [
                    "onRegister"
                ]);
            };
        }
    });
});
export { me as _, __tla };
