import { r as n, V as T, bk as w, gK as W, d as K, co as G, f as H, aw as Z, c as j, o as z, X, w as S, j as $, l, ds as J, cZ as Q, __tla as __tla_0 } from "./index-9PRMimni.js";
import { B as Y } from "./BasicForm-dL_oCSPM.js";
import { O as ee, G as se, Z as ae } from "./template-rpthWlT9.js";
import { f as re } from "./hook-C9rOLWu_.js";
import { g as oe } from "./planner-BebmniHR.js";
import { g as te } from "./account-C850CBTF.js";
import { _ as ne } from "./TableSelect.vue_vue_type_script_setup_true_lang-BAU5mgvB.js";
import "./Table.vue_vue_type_style_index_0_scoped_7b9e6ece_lang-BoW2DV_e.js";
import "./print-CT_2hrjP.js";
import "./basicModal.vue_vue_type_style_index_0_lang-8QZP7ApW.js";
import "./vuedraggable.umd-Co2xEC3p.js";
import { u as le } from "./useForm-CKmgcynv.js";
let Se;
let __tla = Promise.all([
    (()=>{
        try {
            return __tla_0;
        } catch  {}
    })()
]).then(async ()=>{
    const { t: e } = T(), ie = n([]), p = w(), ue = await ee(), P = await W(), N = [
        {
            label: "干散",
            labelEn: "Dry Cargo",
            value: "1"
        },
        {
            label: "油化",
            labelEn: "Tanker",
            value: "2"
        }
    ], B = n([]), C = n([]), D = n([]);
    async function de() {
        const r = await se("NearMiss_Sire_Category");
        D.value = r, B.value = r.map((i)=>{
            const { children: u, ...g } = i;
            return {
                ...g,
                children: i.children.map((a)=>({
                        label: a.label,
                        labelEn: a.labelEn,
                        value: a.value
                    }))
            };
        });
    }
    function ce() {
        const r = n(!1), i = n(null);
        de();
        const u = [
            {
                title: e("hsqe.nearMiss.BasicDetails"),
                cardProps: {
                    headerClass: "pl-0 pt-0",
                    contentStyle: "padding: 10px 0 0px 0",
                    bordered: !1,
                    hoverable: !1
                },
                columns: [
                    {
                        field: "shipId",
                        component: "NSelect",
                        label: e("hsqe.nearMiss.ShipName"),
                        componentProps: {
                            disabled: !0,
                            options: ue,
                            "value-field": "id",
                            "label-field": p.getLocale === "en" ? "shipNameEn" : "shipName"
                        },
                        rules: [
                            {
                                required: !0,
                                validator: (a, s)=>s != null,
                                message: `${e("hsqe.nearMiss.ShipName")} ${e("common.required")}`,
                                trigger: [
                                    "blur",
                                    "change"
                                ]
                            }
                        ]
                    },
                    {
                        field: "callSign",
                        component: "NInput",
                        label: e("hsqe.nearMiss.CallSign"),
                        componentProps: {
                            disabled: !0
                        },
                        rules: [
                            {
                                required: !0,
                                validator: (a, s)=>s != null,
                                message: `${e("hsqe.nearMiss.CallSign")} ${e("common.required")}`,
                                trigger: [
                                    "blur",
                                    "change"
                                ]
                            }
                        ]
                    },
                    {
                        field: "nationality",
                        component: "NInput",
                        label: e("hsqe.nearMiss.Nationality"),
                        componentProps: {
                            disabled: !0
                        },
                        rules: [
                            {
                                required: !0,
                                validator: (a, s)=>s != null,
                                message: `${e("hsqe.nearMiss.Nationality")} ${e("common.required")}`,
                                trigger: [
                                    "blur",
                                    "change"
                                ]
                            }
                        ]
                    },
                    {
                        field: "nearMissDateTime",
                        component: "NDatePicker",
                        label: e("hsqe.nearMiss.DateAndTime"),
                        componentProps: ()=>({
                                disabled: r.value,
                                type: "datetime",
                                valueFormat: "yyyy-MM-dd hh:mm:ss",
                                filterable: !0
                            }),
                        rules: [
                            {
                                required: !0,
                                validator: (a, s)=>s != null,
                                message: `${e("hsqe.nearMiss.DateAndTime")} ${e("common.required")}`,
                                trigger: [
                                    "blur",
                                    "change"
                                ]
                            }
                        ]
                    },
                    {
                        field: "reportedBy",
                        component: "NInput",
                        label: e("hsqe.nearMiss.ReportedBy"),
                        componentProps: {
                            disabled: !0
                        }
                    },
                    {
                        field: "rank",
                        component: "NInput",
                        label: e("hsqe.nearMiss.Rank"),
                        componentProps: {
                            disabled: !0
                        }
                    },
                    {
                        field: "nearMissCategory",
                        component: "NCascader",
                        label: e("hsqe.nearMiss.NearMissCategory"),
                        hidden: P == 1,
                        componentProps: ()=>({
                                options: B.value,
                                disabled: r.value,
                                showPath: !1,
                                checkStrategy: "child",
                                onUpdateValue: (a)=>{
                                    const s = D.value[0].children;
                                    C.value = s.find((b)=>b.value === a)?.children || [];
                                }
                            })
                    },
                    {
                        field: "subCategory",
                        component: "NSelect",
                        label: e("hsqe.nearMiss.SubCategory"),
                        hidden: P == 1,
                        componentProps: ()=>({
                                options: C.value,
                                disabled: r.value
                            })
                    },
                    {
                        field: "impactPotential",
                        component: "BasicSelect",
                        label: e("hsqe.nearMiss.ImpactPotential"),
                        componentProps: ()=>({
                                cacheKey: "nm_impact_potential",
                                block: !0,
                                cache: !1,
                                labelField: p.getLocale === "en" ? "labelEn" : "label",
                                disabled: r.value
                            })
                    },
                    {
                        field: "areaOfNearMiss",
                        component: "BasicSelect",
                        label: e("hsqe.nearMiss.Area"),
                        componentProps: ()=>({
                                cacheKey: "nm_miss_area",
                                block: !0,
                                cache: !1,
                                labelField: p.getLocale === "en" ? "labelEn" : "label",
                                disabled: r.value
                            }),
                        rules: [
                            {
                                required: !0,
                                validator: (a, s)=>s != null,
                                message: `${e("hsqe.nearMiss.Area")} ${e("common.required")}`,
                                trigger: [
                                    "blur",
                                    "change"
                                ]
                            }
                        ]
                    },
                    {
                        field: "nearMissType",
                        component: "BasicSelect",
                        label: e("hsqe.nearMiss.NearMissType"),
                        componentProps: ()=>({
                                cacheKey: "nm_miss_type",
                                block: !0,
                                cache: !1,
                                labelField: p.getLocale === "en" ? "labelEn" : "label",
                                disabled: r.value
                            }),
                        rules: [
                            {
                                required: !0,
                                validator: (a, s)=>s != null,
                                message: `${e("hsqe.nearMiss.Area")} ${e("common.required")}`,
                                trigger: [
                                    "blur",
                                    "change"
                                ]
                            }
                        ]
                    },
                    {
                        field: "officeResponsible",
                        component: "BasicSelect",
                        label: e("hsqe.nearMiss.OfficeResponsible"),
                        componentProps: ()=>({
                                cacheKey: "nc_verified_by",
                                block: !0,
                                cache: !1,
                                labelField: p.getLocale === "en" ? "labelEn" : "label",
                                disabled: r.value
                            }),
                        rules: [
                            {
                                required: !0,
                                validator: (a, s)=>s != null,
                                message: `${e("hsqe.nearMiss.OfficeResponsible")} ${e("common.required")}`,
                                trigger: [
                                    "blur",
                                    "change"
                                ]
                            }
                        ]
                    },
                    {
                        field: "nearMissTitle",
                        component: "NInput",
                        label: e("hsqe.nearMiss.NearMissTitle"),
                        componentProps: ()=>({
                                maxlength: 100,
                                showCount: !0,
                                disabled: r.value
                            }),
                        giProps: {
                            span: 3
                        },
                        rules: [
                            {
                                required: !0,
                                message: `${e("hsqe.nearMiss.NearMissTitle")} ${e("common.required")}`,
                                trigger: [
                                    "blur",
                                    "change"
                                ]
                            }
                        ]
                    },
                    {
                        field: "nearMissDescription",
                        component: "NInput",
                        label: e("hsqe.nearMiss.NearMissDescription"),
                        componentProps: ()=>({
                                type: "textarea",
                                disabled: r.value,
                                maxlength: 300,
                                showCount: !0
                            }),
                        rules: [
                            {
                                required: !0,
                                message: `${e("hsqe.nearMiss.NearMissDescription")} ${e("common.required")}`,
                                trigger: [
                                    "blur",
                                    "change"
                                ]
                            }
                        ],
                        giProps: {
                            span: 5
                        }
                    }
                ]
            },
            {
                title: e("hsqe.nearMiss.PositionCondition"),
                cardProps: {
                    headerClass: "pl-0 pt-0",
                    contentStyle: "padding: 10px 0 0px 0",
                    bordered: !1,
                    hoverable: !1
                },
                columns: [
                    {
                        field: "positionType",
                        label: e("hsqe.nearMiss.PositionCondition"),
                        component: "NRadioGroup",
                        componentProps: ({ formAction: a })=>{
                            const { setFieldsValue: s } = a;
                            return {
                                disabled: r.value,
                                options: [
                                    {
                                        label: e("hsqe.nearMiss.AtSea"),
                                        value: "At Sea"
                                    },
                                    {
                                        label: e("hsqe.nearMiss.AtPort"),
                                        value: "At Port"
                                    }
                                ],
                                onUpdateValue: ()=>{
                                    s({
                                        positionDescription: null
                                    });
                                }
                            };
                        },
                        rules: [
                            {
                                required: !0,
                                validator: (a, s)=>s != null,
                                message: `${e("hsqe.nearMiss.PositionCondition")} ${e("common.required")}`,
                                trigger: [
                                    "blur",
                                    "change"
                                ]
                            }
                        ]
                    },
                    {
                        field: "positionDescription",
                        component: "NInput",
                        hidden: (a)=>a.model.positionType === "At Port" || !a.model.positionType,
                        componentProps: ()=>({
                                maxlength: 100,
                                showCount: !0,
                                disabled: r.value
                            }),
                        rules: [
                            {
                                required: !0,
                                validator: (a, s)=>s != null,
                                message: `${e("hsqe.nearMiss.Position")} ${e("common.required")}`,
                                trigger: [
                                    "blur",
                                    "change"
                                ]
                            }
                        ]
                    },
                    {
                        field: "positionDescription",
                        slot: "visitPlace",
                        hidden: (a)=>a.model.positionType === "At Sea" || a.model.positionType === void 0,
                        rules: [
                            {
                                required: !0,
                                message: `${e("hsqe.nearMiss.Position")} ${e("common.required")}`,
                                trigger: [
                                    "blur"
                                ]
                            }
                        ]
                    },
                    {
                        field: "planVoyage",
                        component: "NInput",
                        label: e("hsqe.nearMiss.PlanVoyage"),
                        componentProps: ()=>({
                                maxlength: 100,
                                showCount: !0,
                                disabled: r.value
                            }),
                        rules: [
                            {
                                required: !0,
                                validator: (a, s)=>s != null,
                                message: `${e("hsqe.nearMiss.PlanVoyage")} ${e("common.required")}`,
                                trigger: [
                                    "blur",
                                    "change"
                                ]
                            }
                        ]
                    },
                    {
                        field: "courseSpeed",
                        component: "NInput",
                        label: e("hsqe.nearMiss.CourseSpeed"),
                        componentProps: ()=>({
                                maxlength: 100,
                                showCount: !0,
                                disabled: r.value
                            }),
                        rules: [
                            {
                                required: !0,
                                validator: (a, s)=>s != null,
                                message: `${e("hsqe.nearMiss.CourseSpeed")} ${e("common.required")}`,
                                trigger: [
                                    "blur",
                                    "change"
                                ]
                            }
                        ]
                    },
                    {
                        field: "weather",
                        component: "NInput",
                        label: e("hsqe.nearMiss.Weather"),
                        componentProps: ()=>({
                                maxlength: 100,
                                showCount: !0,
                                disabled: r.value
                            }),
                        rules: [
                            {
                                required: !0,
                                validator: (a, s)=>s != null,
                                message: `${e("hsqe.nearMiss.Weather")} ${e("common.required")}`,
                                trigger: [
                                    "blur",
                                    "change"
                                ]
                            }
                        ]
                    },
                    {
                        field: "wind",
                        component: "NInput",
                        label: e("hsqe.nearMiss.Wind"),
                        componentProps: ()=>({
                                maxlength: 100,
                                showCount: !0,
                                disabled: r.value
                            }),
                        rules: [
                            {
                                required: !0,
                                validator: (a, s)=>s != null,
                                message: `${e("hsqe.nearMiss.Wind")} ${e("common.required")}`,
                                trigger: [
                                    "blur",
                                    "change"
                                ]
                            }
                        ]
                    },
                    {
                        field: "sea",
                        component: "NInput",
                        label: e("hsqe.nearMiss.Sea"),
                        componentProps: ()=>({
                                disabled: r.value,
                                maxlength: 100,
                                showCount: !0
                            }),
                        rules: [
                            {
                                required: !0,
                                validator: (a, s)=>s != null,
                                message: `${e("hsqe.nearMiss.Sea")} ${e("common.required")}`,
                                trigger: [
                                    "blur",
                                    "change"
                                ]
                            }
                        ]
                    },
                    {
                        field: "loa",
                        component: "NInput",
                        label: e("hsqe.nearMiss.LOA"),
                        componentProps: ()=>({
                                maxlength: 100,
                                showCount: !0,
                                disabled: r.value
                            }),
                        rules: [
                            {
                                required: !0,
                                validator: (a, s)=>s != null,
                                message: `${e("hsqe.nearMiss.LOA")} ${e("common.required")}`,
                                trigger: [
                                    "blur",
                                    "change"
                                ]
                            }
                        ]
                    },
                    {
                        field: "breadth",
                        component: "NInput",
                        label: e("hsqe.nearMiss.Breadth"),
                        componentProps: ()=>({
                                maxlength: 100,
                                showCount: !0,
                                disabled: r.value
                            }),
                        rules: [
                            {
                                required: !0,
                                validator: (a, s)=>s != null,
                                message: `${e("hsqe.nearMiss.Breadth")} ${e("common.required")}`,
                                trigger: [
                                    "blur",
                                    "change"
                                ]
                            }
                        ]
                    },
                    {
                        field: "draft",
                        component: "NInput",
                        label: e("hsqe.nearMiss.Draft"),
                        componentProps: ()=>({
                                maxlength: 100,
                                showCount: !0,
                                disabled: r.value
                            }),
                        rules: [
                            {
                                required: !0,
                                validator: (a, s)=>s != null,
                                message: `${e("hsqe.nearMiss.Draft")} ${e("common.required")}`,
                                trigger: [
                                    "blur",
                                    "change"
                                ]
                            }
                        ]
                    },
                    {
                        field: "shipType",
                        component: "NSelect",
                        defaultValue: N[P - 1]?.value,
                        label: e("hsqe.nearMiss.ShipType"),
                        componentProps: {
                            disabled: !0,
                            options: N,
                            "value-field": "value",
                            "label-field": p.getLocale === "en" ? "labelEn" : "label"
                        },
                        rules: [
                            {
                                required: !0,
                                validator: (a, s)=>s != null,
                                message: `${e("hsqe.nearMiss.ShipType")} ${e("common.required")}`,
                                trigger: [
                                    "blur",
                                    "change"
                                ]
                            }
                        ]
                    },
                    {
                        field: "id",
                        hidden: !0
                    },
                    {
                        field: "ReportedBy",
                        hidden: !0
                    }
                ]
            }
        ];
        return {
            schemas: u,
            methods: {
                setReadOnly: (a)=>{
                    r.value = a, console.log(r.value);
                },
                setReportType: (a)=>{
                    i.value = a;
                },
                setDefectList: (a)=>{
                    ie.value = a.list;
                },
                getSchemas: ()=>u
            }
        };
    }
    Se = K({
        __name: "index",
        emits: [
            "saveCallBack",
            "getBaseInfo"
        ],
        setup (r, { expose: i }) {
            const u = G({
                storage: localStorage
            }), { methods: g, schemas: a } = ce(), { setReadOnly: s } = g, b = H(), x = Q(), I = w(), { t: d } = T(), [R, { setFieldsValue: f, getFieldsValue: O, submit: k }] = le({
                gridProps: {
                    cols: 5,
                    xGap: 15
                },
                collapsed: !1,
                collapsedRows: 12,
                labelWidth: 80,
                layout: "horizontal",
                submitButtonText: "sure",
                showActionButtonGroup: !1,
                showSubmitButton: !1,
                showResetButton: !1
            }), V = {
                gridProps: {
                    cols: "2"
                },
                labelWidth: 80,
                submitButtonText: d("common.searchText"),
                showAdvancedButton: !1,
                schemas: [
                    {
                        field: "namePrefix",
                        component: "NInput",
                        label: d("hsqe.planner.modal.planPort")
                    }
                ]
            }, A = [
                {
                    title: d("hsqe.planner.modal.port"),
                    key: "port"
                },
                {
                    title: d("hsqe.planner.modal.country"),
                    key: "country"
                }
            ], v = n(!1), F = n({}), q = n({});
            async function _(o) {
                b.query.type === "view" ? (v.value = !0, s(!0)) : (v.value = !1, s(!1)), o ? (o.nearMissDateTime && (o.nearMissDateTime = o.nearMissDateTime.replace("T", " ")), console.log(o), await f(o)) : (await L(), f({
                    reportDate: re(new Date)
                }));
            }
            async function L() {
                let o = await ae(u.get("SHIP-LIST")[0].id), t = await te();
                console.log(o), f({
                    shipId: u.get("SHIP-LIST")[0].id,
                    callSign: o.callSign,
                    nationality: o.flag,
                    reportBy: t.id,
                    reportByName: t.username,
                    rank: I.getLocale === "en" ? t.roleNamesEn : t.roleNames,
                    breadth: typeof o.beam == "number" ? o.beam.toString() : o.beam
                });
            }
            function E(o) {
                return oe({
                    ...o,
                    ...l(q)
                });
            }
            async function U(o) {
                let t = O();
                delete t.deficiencyPhotoUrl_Photo;
                const c = {
                    ...F.value,
                    ...t
                };
                c.nearMissDateTime && (c.nearMissDateTime = c.nearMissDateTime.replace(" ", "T"));
                let m = !0;
                return !await k() && o ? (m = !1, x.warning(d("hsqe.nc.baseVerification")), !1) : (m = !0, {
                    params: c,
                    res: m
                });
            }
            return Z(()=>{
                b.query.type === "add" && _();
            }), i({
                getData: U,
                initData: _
            }), (o, t)=>{
                const c = Y, m = X;
                return z(), j(m, null, {
                    default: S(()=>[
                            $(c, {
                                group: l(a),
                                onRegister: l(R)
                            }, {
                                visitPlace: S(({ model: y, field: M })=>[
                                        $(l(ne), {
                                            class: "w-full",
                                            labelField: "port",
                                            valueField: "id",
                                            value: y[M],
                                            "onUpdate:value": (h)=>y[M] = h,
                                            formValues: l(q),
                                            "onUpdate:formValues": t[0] || (t[0] = (h)=>J(q) ? q.value = h : null),
                                            onClear: ()=>l(f)({
                                                    [M]: void 0
                                                }),
                                            multiple: !1,
                                            formProps: V,
                                            selectTitle: l(d)("hsqe.auditInspection.vesselInspection.formReportPortHint"),
                                            disabled: l(v),
                                            tableProps: {
                                                rowKey: (h)=>h.id,
                                                request: E,
                                                columns: A,
                                                pagination: {}
                                            }
                                        }, null, 8, [
                                            "value",
                                            "onUpdate:value",
                                            "formValues",
                                            "onClear",
                                            "selectTitle",
                                            "disabled",
                                            "tableProps"
                                        ])
                                    ]),
                                _: 1
                            }, 8, [
                                "group",
                                "onRegister"
                            ])
                        ]),
                    _: 1
                });
            };
        }
    });
});
export { Se as _, __tla };
