import { r as m, V as M, bk as $, l as q, cO as f, cq as h, fm as g, d as k, f as z, aw as A, c as G, o as K, X as j, w as J, j as W, cZ as H, __tla as __tla_0 } from "./index-9PRMimni.js";
import { B as Q } from "./BasicForm-dL_oCSPM.js";
import { i as X, e as E, j as F, G as Z, t as Y, H as ee } from "./template-rpthWlT9.js";
import { a as oe, d as V, e as te, b as ie, f as se } from "./helper-Czt-QYps.js";
import { c as ne, __tla as __tla_1 } from "./schemas-C0ECnkWr.js";
import { c as ae, __tla as __tla_2 } from "./modalSchemas-dKMYM0AT.js";
import { c as ce, __tla as __tla_3 } from "./modalSchemas-D9c32bW5.js";
import { c as re, __tla as __tla_4 } from "./modalSchemas-JSdK1AGK.js";
import { c as le, __tla as __tla_5 } from "./modalSchemas-DzYfMuRt.js";
import { u as pe } from "./useForm-CKmgcynv.js";
let Ce;
let __tla = Promise.all([
    (()=>{
        try {
            return __tla_0;
        } catch  {}
    })(),
    (()=>{
        try {
            return __tla_1;
        } catch  {}
    })(),
    (()=>{
        try {
            return __tla_2;
        } catch  {}
    })(),
    (()=>{
        try {
            return __tla_3;
        } catch  {}
    })(),
    (()=>{
        try {
            return __tla_4;
        } catch  {}
    })(),
    (()=>{
        try {
            return __tla_5;
        } catch  {}
    })()
]).then(async ()=>{
    const P = $(), { t } = M(), de = await X(), me = await E({
        roleType: 2,
        roleCategory: 1
    }), ue = await F(), fe = await E({
        roleType: 2,
        roleCategory: 1
    }), he = await F(), B = m([]), O = m([]), L = m([]);
    async function ge() {
        const s = await Z("CDI_Category");
        L.value = s, B.value = s.map((c)=>{
            const { children: l, ...p } = c;
            return {
                ...p,
                children: c.children.map((u)=>({
                        label: u.label,
                        labelEn: u.labelEn,
                        value: u.value
                    }))
            };
        });
    }
    function ye() {
        const s = m(!1), c = m(null), l = m(!1);
        ge();
        const p = [
            {
                field: "shipId",
                hidden: !0
            },
            {
                field: "reportNo",
                component: "NInput",
                label: t("hsqe.auditInspection.vesselInspection.shipVisitReport.deficiencyReport.basicInfo.relatedReportNo"),
                componentProps: {
                    disabled: !0
                }
            },
            {
                field: "severity",
                component: "NSelect",
                label: t("hsqe.deficiency.servity"),
                componentProps: {
                    options: de,
                    disabled: s,
                    "label-field": P.getLocale === "en" ? "labelEn" : "label"
                },
                rules: [
                    {
                        required: !0,
                        validator: (o, e)=>e != null,
                        message: t("common.chooseText"),
                        trigger: [
                            "blur",
                            "change"
                        ]
                    }
                ]
            },
            {
                field: "deficiencyCode",
                component: "BasicSelect",
                label: t("hsqe.auditInspection.vesselInspection.shipVisitReport.deficiencyReport.basicInfo.deficiencyCode"),
                componentProps: {
                    cacheKey: "inspection_checkList",
                    block: !0,
                    disabled: !0
                }
            },
            {
                field: "equipmentId",
                component: "NSelect",
                label: t("hsqe.auditInspection.vesselInspection.shipVisitReport.deficiencyReport.basicInfo.equipment"),
                componentProps: ({ model: o, formAction: e })=>{
                    const { shipId: n } = o, { setFieldsValue: d } = e;
                    return {
                        show: l,
                        remote: !0,
                        clearable: !0,
                        filterable: !0,
                        loading: q(ie),
                        options: q(te),
                        disabled: q(s),
                        placeholder: t("common.inputTextToSearch"),
                        onClear: ()=>{
                            V({
                                shipId: n
                            });
                        },
                        onBlur: ()=>{
                            l.value = !1;
                        },
                        onSearch: async (a)=>{
                            a.length > 0 ? l.value = !0 : l.value = !1, V({
                                shipId: n,
                                productName: a
                            });
                        },
                        onUpdateValue: async (a)=>{
                            const i = await oe(a);
                            d({
                                equipmentValue: i
                            }), l.value = !1;
                        }
                    };
                }
            },
            {
                field: "equipmentValue",
                component: "NSelect",
                label: t("hsqe.auditInspection.vesselInspection.shipVisitReport.deficiencyReport.basicInfo.criticalEquipment"),
                componentProps: {
                    disabled: !0,
                    options: [
                        {
                            label: t("common.yes"),
                            value: "1"
                        },
                        {
                            label: t("common.no"),
                            value: "0"
                        }
                    ]
                }
            },
            {
                field: "expirationTime",
                component: "NDatePicker",
                label: t("hsqe.auditInspection.vesselInspection.shipVisitReport.deficiencyReport.basicInfo.expiryDate"),
                componentProps: {
                    valueFormat: "yyyy-MM-dd",
                    type: "date",
                    disabled: s
                },
                rules: [
                    {
                        required: !0,
                        validator: (o, e)=>e != null,
                        message: t("common.chooseText"),
                        trigger: [
                            "blur",
                            "change"
                        ]
                    }
                ]
            },
            {
                field: "vesselPositionCode",
                component: "NSelect",
                label: t("hsqe.auditInspection.vesselInspection.shipVisitReport.deficiencyReport.basicInfo.vesselResponsible"),
                componentProps: {
                    options: me,
                    "label-field": P.getLocale === "en" ? "nameEn" : "name",
                    "value-field": "code",
                    disabled: s
                },
                rules: [
                    {
                        required: !0,
                        validator: (o, e)=>e != null,
                        message: t("common.chooseText"),
                        trigger: [
                            "blur",
                            "change"
                        ]
                    }
                ]
            },
            {
                field: "officePositionCode",
                component: "NSelect",
                label: t("hsqe.auditInspection.vesselInspection.shipVisitReport.deficiencyReport.basicInfo.officeResponsible"),
                componentProps: {
                    options: ue,
                    "label-field": P.getLocale === "en" ? "nameEn" : "name",
                    "value-field": "code",
                    disabled: s
                },
                rules: [
                    {
                        required: !0,
                        validator: (o, e)=>e != null,
                        message: t("common.chooseText"),
                        trigger: [
                            "blur",
                            "change"
                        ]
                    }
                ]
            },
            {
                field: "isMemo",
                component: "NSwitch",
                label: t("hsqe.auditInspection.vesselInspection.shipVisitReport.deficiencyReport.basicInfo.isMemo"),
                componentProps: {
                    disabled: s
                }
            },
            {
                field: "basicDescription",
                component: "NInput",
                label: t("hsqe.auditInspection.vesselInspection.shipVisitReport.deficiencyReport.basicInfo.description"),
                giProps: {
                    span: 5
                },
                componentProps: {
                    type: "textarea",
                    disabled: s,
                    maxlength: 300,
                    showCount: !0
                },
                rules: [
                    {
                        required: !0,
                        validator: (o, e)=>e != null && e !== "",
                        message: t("common.inputText"),
                        trigger: [
                            "blur",
                            "change"
                        ]
                    }
                ]
            },
            {
                field: "deficiencyPhotoUrl_Photo",
                label: t("hsqe.deficiency.deficiencyPhotos"),
                component: "SingleImageUpload",
                componentProps: ({ model: o })=>({
                        disabled: !0,
                        action: `${h().urlPrefix}/files`,
                        maxNumber: 1,
                        headers: {
                            timestamp: new Date().getTime(),
                            authorization: `${f.get(g)}`
                        },
                        onUploadChange: (e, n)=>{
                            o.deficiencyPhotoUrl = n;
                        }
                    }),
                giProps: {
                    span: 1
                }
            },
            {
                field: "deficiencyPhotoUrlTwo_Photo",
                label: t("hsqe.deficiency.deficiencyPhotos"),
                component: "SingleImageUpload",
                componentProps: ({ model: o })=>({
                        disabled: !0,
                        action: `${h().urlPrefix}/files`,
                        maxNumber: 1,
                        headers: {
                            timestamp: new Date().getTime(),
                            authorization: `${f.get(g)}`
                        },
                        onUploadChange: (e, n)=>{
                            o.deficiencyPhotoUrlTwo = n;
                        }
                    }),
                giProps: {
                    span: 1
                }
            },
            {
                field: "deficiencyPhotoUrlThree_Photo",
                label: t("hsqe.deficiency.deficiencyPhotos"),
                component: "SingleImageUpload",
                componentProps: ({ model: o })=>({
                        disabled: !0,
                        action: `${h().urlPrefix}/files`,
                        maxNumber: 1,
                        headers: {
                            timestamp: new Date().getTime(),
                            authorization: `${f.get(g)}`
                        },
                        onUploadChange: (e, n)=>{
                            o.deficiencyPhotoUrlThree = n;
                        }
                    }),
                giProps: {
                    span: 1
                }
            }
        ], u = [
            {
                field: "reportNo",
                component: "NInput",
                label: t("hsqe.auditInspection.vesselInspection.shipVisitReport.deficiencyReport.basicInfo.relatedReportNo"),
                componentProps: {
                    disabled: !0
                }
            },
            {
                field: "findingSectionCode",
                component: "NCascader",
                label: t("hsqe.cdi.findingsSection"),
                componentProps: ()=>({
                        disabled: s,
                        options: B.value,
                        showPath: !1,
                        checkStrategy: "child",
                        onUpdateValue: async (o)=>{
                            const e = L?.value[0]?.children || [];
                            O.value = e?.find((n)=>n.value === o)?.children || [];
                        }
                    }),
                rules: [
                    {
                        required: !0,
                        validator: (o, e)=>e != null,
                        message: t("common.chooseText"),
                        trigger: [
                            "blur",
                            "change"
                        ]
                    }
                ]
            },
            {
                field: "findingCode",
                component: "NSelect",
                label: t("hsqe.cdi.findingsChild"),
                componentProps: ()=>({
                        disabled: s,
                        options: O.value
                    }),
                rules: [
                    {
                        required: !0,
                        validator: (o, e)=>e != null,
                        message: t("common.chooseText"),
                        trigger: [
                            "blur",
                            "change"
                        ]
                    }
                ]
            },
            {
                field: "expirationTime",
                component: "NDatePicker",
                label: t("hsqe.cdi.expirationTime"),
                componentProps: {
                    type: "date",
                    valueFormat: "yyyy-MM-dd",
                    disabled: s
                }
            },
            {
                field: "vesselPositionCode",
                component: "NSelect",
                label: t("hsqe.auditInspection.vesselInspection.shipVisitReport.deficiencyReport.basicInfo.vesselResponsible"),
                componentProps: {
                    options: fe,
                    "label-field": P.getLocale === "en" ? "nameEn" : "name",
                    "value-field": "code",
                    disabled: s
                },
                rules: [
                    {
                        required: !0,
                        validator: (o, e)=>e != null,
                        message: t("common.chooseText"),
                        trigger: [
                            "blur",
                            "change"
                        ]
                    }
                ]
            },
            {
                field: "officePositionCode",
                component: "NSelect",
                label: t("hsqe.auditInspection.vesselInspection.shipVisitReport.deficiencyReport.basicInfo.officeResponsible"),
                componentProps: {
                    options: he,
                    "label-field": P.getLocale === "en" ? "nameEn" : "name",
                    "value-field": "code",
                    disabled: s
                },
                rules: [
                    {
                        required: !0,
                        validator: (o, e)=>e != null,
                        message: t("common.chooseText"),
                        trigger: [
                            "blur",
                            "change"
                        ]
                    }
                ]
            },
            {
                field: "basicDescription",
                component: "NInput",
                giProps: {
                    span: 4
                },
                label: t("hsqe.cdi.description"),
                componentProps: {
                    type: "textarea",
                    disabled: s,
                    maxlength: 300,
                    showCount: !0
                }
            },
            {
                field: "deficiencyPhotoUrl_Photo",
                label: t("hsqe.deficiency.deficiencyPhotos"),
                component: "SingleImageUpload",
                componentProps: ({ model: o })=>({
                        disabled: !0,
                        action: `${h().urlPrefix}/files`,
                        maxNumber: 1,
                        headers: {
                            timestamp: new Date().getTime(),
                            authorization: `${f.get(g)}`
                        },
                        onUploadChange: (e, n)=>{
                            o.deficiencyPhotoUrl = n;
                        }
                    }),
                giProps: {
                    span: 1
                }
            },
            {
                field: "deficiencyPhotoUrlTwo_Photo",
                label: t("hsqe.deficiency.deficiencyPhotos"),
                component: "SingleImageUpload",
                componentProps: ({ model: o })=>({
                        disabled: !0,
                        action: `${h().urlPrefix}/files`,
                        maxNumber: 1,
                        headers: {
                            timestamp: new Date().getTime(),
                            authorization: `${f.get(g)}`
                        },
                        onUploadChange: (e, n)=>{
                            o.deficiencyPhotoUrlTwo = n;
                        }
                    }),
                giProps: {
                    span: 1
                }
            },
            {
                field: "deficiencyPhotoUrlThree_Photo",
                label: t("hsqe.deficiency.deficiencyPhotos"),
                component: "SingleImageUpload",
                componentProps: ({ model: o })=>({
                        disabled: !0,
                        action: `${h().urlPrefix}/files`,
                        maxNumber: 1,
                        headers: {
                            timestamp: new Date().getTime(),
                            authorization: `${f.get(g)}`
                        },
                        onUploadChange: (e, n)=>{
                            o.deficiencyPhotoUrlThree = n;
                        }
                    }),
                giProps: {
                    span: 1
                }
            }
        ], { rectificationSchemas: T, methods: x } = ne({
            source: "deficiencyReport"
        }), { schemas: y } = re({
            modelType: s.value ? "edit" : "view",
            source: "deficiencyReport"
        }), { schemas: S } = le({
            modelType: s.value ? "edit" : "view",
            source: "deficiencyReport"
        }), { setRectificationOnly: v } = x, { schemasPsc: _, methodsPsc: C } = ae(), { schemasFsc: N, methodsFsc: w } = ce(), { setDefectList: U, setPscReadOnly: I } = C, { setReadOnly: D } = w;
        return {
            schemas: p,
            methods: {
                setReadOnly: (o)=>{
                    s.value = o, I(o), v(o), D(o);
                },
                setReportType: (o)=>{
                    c.value = o;
                },
                getSchemas: ()=>c.value == "cdiReport" || c.value == "rightshipReport" || c.value == "sireReport" ? (console.log(111), u) : c.value === "safetyQuality" ? (console.log(2222), T) : c.value === "pscReport" ? (console.log(3333), _) : c.value === "fscReport" ? (console.log(444), N) : c.value === "seniorVisit" ? (console.log(555), y) : c.value === "companyNavigationalReport" ? (console.log(666), S) : (console.log(777), p),
                setDefect: (o)=>{
                    U(o);
                }
            }
        };
    }
    Ce = k({
        __name: "index",
        emits: [
            "saveCallBack",
            "getBaseInfo"
        ],
        setup (s, { expose: c, emit: l }) {
            const p = z(), u = H(), { t: T } = M(), x = l, y = m([]), { methods: S } = ye(), { setReadOnly: v, setReportType: _, getSchemas: C, setDefect: N } = S, [w, { setFieldsValue: U, getFieldsValue: I, submit: D }] = pe({
                schemas: y,
                layout: "horizontal",
                gridProps: {
                    cols: 5
                },
                showActionButtonGroup: !1
            }), R = m({});
            async function o() {
                if (p.query.id) {
                    const a = await Y(Number(p.query.id));
                    let i = JSON.parse(JSON.stringify(a));
                    if (x("getBaseInfo", i), a.reportType === "pscReport") {
                        let r = await ee({
                            mouId: i.mouCode,
                            item: "",
                            pageNum: 1,
                            pageSize: 1e4
                        });
                        N(r);
                    }
                    i.expirationTime && typeof i.expirationTime == "string" && (i.expirationTime = i.expirationTime.split(/T| /)[0]), i.isMemo = i.isMemo === "yes", i.deficiencyPhotoUrl_Photo = i.deficiencyPhotoUrl ? i.deficiencyPhotoUrlPhoto : "", R.value = i, se({
                        equipmentId: i.equipmentId
                    }), U(i), _(a.reportType), p.query.type === "view" || i.status !== "new" ? v(!0) : v(!1);
                }
                const d = C();
                y.value = d;
            }
            function e() {
                let d = I();
                const a = {
                    ...R.value,
                    ...d
                };
                return a.expirationTime && (a.expirationTime += " 00:00:00"), a;
            }
            async function n(d) {
                if (d && !await D()) return u.error(T("hsqe.nc.baseVerification")), !1;
                const a = y.value.map((b)=>b.field);
                let i = I();
                a.forEach((b)=>{
                    b in i || (i[b] = "");
                }), delete i.deficiencyPhotoUrl_Photo;
                const r = {
                    ...R.value,
                    ...i
                };
                return r.expirationTime && (r.expirationTime += " 00:00:00"), r.isMemo ? r.isMemo = "yes" : r.isMemo = "no", r;
            }
            return A(()=>{
                o();
            }), c({
                submit: e,
                getData: n
            }), (d, a)=>{
                const i = Q, r = j;
                return K(), G(r, null, {
                    default: J(()=>[
                            W(i, {
                                class: "mt-3",
                                onRegister: q(w)
                            }, null, 8, [
                                "onRegister"
                            ])
                        ]),
                    _: 1
                });
            };
        }
    });
});
export { Ce as _, __tla };
