import { r as u, V as y, bk as q, cO as T, cq as x, l as _, fm as F, d as O, f as C, aw as k, c as E, o as L, X as I, w as U, j as A, cZ as M, __tla as __tla_0 } from "./index-9PRMimni.js";
import { B as V } from "./BasicForm-dL_oCSPM.js";
import { O as j, j as G, Y as K } from "./template-rpthWlT9.js";
import { f as b } from "./hook-C9rOLWu_.js";
import { g as W } from "./account-C850CBTF.js";
import { u as z } from "./useForm-CKmgcynv.js";
let se;
let __tla = Promise.all([
    (()=>{
        try {
            return __tla_0;
        } catch  {}
    })()
]).then(async ()=>{
    const m = q(), { t: e } = y(), X = await j(), Y = await G();
    function Z() {
        const a = u(!1), d = u(null), l = [
            {
                field: "shipId",
                component: "NSelect",
                label: e("hsqe.nc.name"),
                componentProps: {
                    options: X,
                    "value-field": "id",
                    "label-field": m.getLocale === "en" ? "shipNameEn" : "shipName",
                    disabled: !0
                },
                rules: [
                    {
                        required: !0,
                        validator: (o, t)=>t != null,
                        message: `${e("hsqe.nc.name")} ${e("common.required")}`,
                        trigger: [
                            "blur",
                            "change"
                        ]
                    }
                ]
            },
            {
                field: "masterName",
                component: "NInput",
                label: e("hsqe.nc.master"),
                componentProps: {
                    disabled: !0
                },
                rules: [
                    {
                        required: !0,
                        validator: (o, t)=>t != null,
                        message: `${e("hsqe.nc.master")} ${e("common.required")}`,
                        trigger: [
                            "blur",
                            "change"
                        ]
                    }
                ]
            },
            {
                field: "natureNonComformity",
                component: "BasicSelect",
                label: e("hsqe.nc.nature"),
                componentProps: {
                    cacheKey: "nature_non_comformity",
                    block: !0,
                    cache: !1,
                    disabled: a,
                    labelField: m.getLocale === "en" ? "labelEn" : "label"
                },
                rules: [
                    {
                        required: !0,
                        validator: (o, t)=>t != null,
                        message: `${e("hsqe.nc.nature")} ${e("common.required")}`,
                        trigger: [
                            "blur",
                            "change"
                        ]
                    }
                ]
            },
            {
                field: "source",
                component: "BasicSelect",
                label: e("hsqe.nc.source"),
                componentProps: {
                    cacheKey: "source",
                    block: !0,
                    cache: !1,
                    disabled: !0,
                    labelField: m.getLocale === "en" ? "labelEn" : "label"
                },
                rules: [
                    {
                        required: !0,
                        validator: (o, t)=>t != null,
                        message: `${e("hsqe.nc.source")} ${e("common.required")}`,
                        trigger: [
                            "blur",
                            "change"
                        ]
                    }
                ]
            },
            {
                field: "roleName",
                component: "NInput",
                label: e("hsqe.nc.reportedBy"),
                componentProps: {
                    disabled: !0
                },
                rules: [
                    {
                        required: !0,
                        validator: (o, t)=>t != null,
                        message: `${e("hsqe.nc.reportedBy")} ${e("common.required")}`,
                        trigger: [
                            "blur",
                            "change"
                        ]
                    }
                ]
            },
            {
                field: "verifiedByDict",
                component: "NSelect",
                label: e("hsqe.nc.verifiedBy"),
                componentProps: {
                    options: Y,
                    disabled: a,
                    labelField: m.getLocale === "en" ? "nameEn" : "name",
                    valueField: "code"
                },
                rules: [
                    {
                        required: !0,
                        validator: (o, t)=>t != null,
                        message: `${e("hsqe.nc.verifiedBy")} ${e("common.required")}`,
                        trigger: [
                            "blur",
                            "change"
                        ]
                    }
                ]
            },
            {
                field: "reportDate",
                component: "NDatePicker",
                label: e("hsqe.nc.reportDate"),
                componentProps: {
                    valueFormat: "yyyy-MM-dd",
                    type: "date",
                    disabled: !0
                },
                rules: [
                    {
                        required: !0,
                        validator: (o, t)=>t != null,
                        message: `${e("hsqe.nc.reportDate")} ${e("common.required")}`,
                        trigger: [
                            "blur",
                            "change"
                        ]
                    }
                ]
            },
            {
                field: "dateToRectify",
                component: "NDatePicker",
                label: e("hsqe.nc.rectifyData"),
                componentProps: {
                    valueFormat: "yyyy-MM-dd",
                    type: "date",
                    disabled: a
                },
                rules: [
                    {
                        required: !0,
                        validator: (o, t)=>t != null,
                        message: `${e("hsqe.nc.rectifyData")} ${e("common.required")}`,
                        trigger: [
                            "blur",
                            "change"
                        ]
                    }
                ]
            },
            {
                field: "basicDescription",
                component: "NInput",
                label: e("hsqe.nc.describe"),
                componentProps: {
                    type: "textarea",
                    disabled: a,
                    maxlength: 300,
                    showCount: !0
                },
                giProps: {
                    span: 5
                },
                rules: [
                    {
                        required: !0,
                        validator: (o, t)=>t != null,
                        message: `${e("hsqe.nc.describe")} ${e("common.required")}`,
                        trigger: [
                            "blur",
                            "change"
                        ]
                    }
                ]
            },
            {
                field: "limitOfRequirements",
                component: "NInput",
                label: e("hsqe.nc.require"),
                componentProps: {
                    type: "textarea",
                    disabled: a,
                    maxlength: 300,
                    showCount: !0
                },
                rules: [
                    {
                        required: !0,
                        validator: (o, t)=>t != null,
                        message: `${e("hsqe.nc.require")} ${e("common.required")}`,
                        trigger: [
                            "blur",
                            "change"
                        ]
                    }
                ],
                giProps: {
                    span: 5
                }
            },
            {
                field: "deficiencyPhotoUrlPhoto",
                label: e("hsqe.nc.attachment"),
                component: "SingleImageUpload",
                componentProps: ({ model: o })=>({
                        disabled: _(a),
                        action: `${x().urlPrefix}/files`,
                        headers: {
                            timestamp: new Date().getTime(),
                            authorization: `${T.get(F)}`
                        },
                        onUploadChange: (t, c)=>{
                            o.deficiencyPhotoUrl = c;
                        }
                    }),
                giProps: {
                    span: 1
                }
            },
            {
                field: "id",
                component: "NInput",
                label: e("hsqe.nc.master"),
                hidden: !0
            },
            {
                field: "masterId",
                component: "NInput",
                label: e("hsqe.nc.master"),
                hidden: !0
            },
            {
                field: "reportBy",
                component: "NInput",
                label: e("hsqe.nc.master"),
                hidden: !0
            }
        ];
        return {
            schemas: l,
            methods: {
                setReadOnly: (o)=>{
                    a.value = o;
                },
                setReportType: (o)=>{
                    d.value = o;
                },
                getSchemas: ()=>l
            }
        };
    }
    se = O({
        __name: "index",
        props: {
            btnsDisabled: {
                type: Object,
                default: ()=>({
                        export: !1,
                        formApproval: !1,
                        formReject: !1,
                        formSave: !1,
                        formSubmit: !0,
                        submit: !1
                    })
            }
        },
        emits: [
            "saveCallBack",
            "getBaseInfo"
        ],
        setup (a, { expose: d }) {
            const l = u([]), { methods: g } = Z(), { getSchemas: o, setReadOnly: t } = g, c = C(), v = M(), f = q(), { t: N } = y(), [D, { getFieldsValue: P, setFieldsValue: p, submit: R }] = z({
                schemas: l,
                labelWidth: "auto",
                layout: "horizontal",
                gridProps: {
                    cols: 5,
                    xGap: 15
                },
                showActionButtonGroup: !1
            }), $ = u({}), S = a;
            async function h(r) {
                c.query.type === "view" || S.btnsDisabled.formApproval ? t(!0) : t(!1);
                const s = o();
                l.value = s, r ? (r.reportDate = b(new Date(r.reportDate)), r.dateToRectify && typeof r.dateToRectify == "string" && (r.dateToRectify = r.dateToRectify.split(/T| /)[0]), r.roleName = f.getLocale === "en" ? r.reportByRoleNamesEn : r.reportByRoleNames, await p(r)) : (await w(), p({
                    reportDate: b(new Date),
                    source: "4"
                }));
            }
            async function w() {
                let r = await K(), s = await W();
                console.log(s), p({
                    shipId: r.vesselId,
                    masterName: r.crewName,
                    masterId: r.sysUserId,
                    reportBy: s.id,
                    roleName: f.getLocale === "en" ? s.roleNamesEn : s.roleNames
                });
            }
            async function B(r) {
                let s = P();
                delete s.deficiencyPhotoUrl_Photo;
                const n = {
                    ...$.value,
                    ...s
                };
                n.reportDate && (n.reportDate += "T00:00:00"), n.dateToRectify && (n.dateToRectify += "T00:00:00");
                let i = !0;
                return !await R() && r ? (i = !1, v.warning(N("hsqe.nc.baseVerification")), !1) : (i = !0, {
                    params: n,
                    res: i
                });
            }
            return k(()=>{
                c.query.type === "add" && h();
            }), d({
                getData: B,
                initData: h
            }), (r, s)=>{
                const n = V, i = I;
                return L(), E(i, null, {
                    default: U(()=>[
                            A(n, {
                                class: "mt-3",
                                onRegister: _(D)
                            }, null, 8, [
                                "onRegister"
                            ])
                        ]),
                    _: 1
                });
            };
        }
    });
});
export { se as _, __tla };
