import { V as w, Z as v, aA as S, cb as se, k as D, r as d, bk as ce, d as ae, f as re, aw as le, c as k, o as L, X as pe, w as i, j as l, W as de, l as p, D as ue, i as q, A as V, cS as fe, N as me, gU as ye, as as be, S as he, p as ve, cZ as _e, __tla as __tla_0 } from "./index-9PRMimni.js";
import { B as ge } from "./BasicForm-dL_oCSPM.js";
import { m as $, n as B, K as Re, t as Ie } from "./template-rpthWlT9.js";
import { u as U } from "./useForm-CKmgcynv.js";
import { _ as xe } from "./Flex-CTSf12gq.js";
let Le;
let __tla = Promise.all([
    (()=>{
        try {
            return __tla_0;
        } catch  {}
    })()
]).then(async ()=>{
    const { t: _ } = w(), Ve = await $();
    function F(n) {
        return {
            columns: [
                {
                    title: _("hsqe.auditInspection.vesselInspection.shipVisitReport.deficiencyReport.action.actionType"),
                    key: "correctActionType",
                    render: (e)=>v(S, {
                            style: {
                                width: "150px"
                            },
                            value: e.correctActionType,
                            disabled: n?.readOnly,
                            onUpdateValue: (t)=>e.correctActionType = t,
                            options: Ve
                        })
                },
                {
                    title: _("hsqe.auditInspection.vesselInspection.shipVisitReport.deficiencyReport.action.extensionRectifiedDate"),
                    key: "rectifyTime",
                    render: (e)=>v(se, {
                            value: e.rectifyTime,
                            disabled: n?.readOnly,
                            onUpdateValue: (t)=>e.rectifyTime = t
                        })
                },
                {
                    title: _("hsqe.auditInspection.vesselInspection.shipVisitReport.deficiencyReport.action.description"),
                    key: "correctActionDescription",
                    render: (e)=>v(D, {
                            style: {
                                width: "250px"
                            },
                            type: "textarea",
                            value: e.correctActionDescription,
                            disabled: n?.readOnly,
                            onUpdateValue: (t)=>e.correctActionDescription = t
                        })
                },
                {
                    title: _("hsqe.auditInspection.vesselInspection.shipVisitReport.deficiencyReport.action.verifiedClosedON"),
                    key: "correctActionReview",
                    render: (e)=>v(S, {
                            style: {
                                width: "150px"
                            },
                            value: e.correctActionReview,
                            disabled: n?.readOnly,
                            onUpdateValue: (t)=>e.correctActionReview = t,
                            options: [
                                {
                                    label: "YES",
                                    value: "yes"
                                },
                                {
                                    label: "NO",
                                    value: "no"
                                }
                            ]
                        })
                },
                {
                    title: _("hsqe.auditInspection.vesselInspection.shipVisitReport.deficiencyReport.action.comments"),
                    key: "correctActionComment",
                    render: (e)=>v(D, {
                            style: {
                                width: "250px"
                            },
                            type: "textarea",
                            value: e.correctActionComment,
                            disabled: n?.readOnly,
                            onUpdateValue: (t)=>e.correctActionComment = t
                        })
                }
            ]
        };
    }
    const T = ce(), { t: o } = w(), Ae = await $(), qe = await B();
    function Te() {
        const n = d(!1), y = d(!1), e = d(!1), t = d(""), A = [
            {
                field: "correctiveLine",
                slot: "correctiveLine",
                giProps: {
                    span: 4
                }
            },
            {
                label: o("hsqe.auditInspection.vesselInspection.shipVisitReport.deficiencyReport.action.actionType"),
                field: "correctActionType",
                component: "NSelect",
                componentProps: ()=>({
                        options: Ae,
                        disabled: n.value,
                        "label-field": T.getLocale === "en" ? "labelEn" : "label"
                    })
            },
            {
                label: o("hsqe.auditInspection.vesselInspection.shipVisitReport.deficiencyReport.action.extensionRectifiedDate"),
                field: "rectifyTime",
                component: "NDatePicker",
                componentProps: ()=>({
                        type: "date",
                        valueFormat: "yyyy-MM-dd",
                        disabled: n.value
                    })
            },
            {
                field: "block"
            },
            {
                label: o("hsqe.auditInspection.vesselInspection.shipVisitReport.deficiencyReport.action.description"),
                field: "correctActionDescription",
                component: "NInput",
                componentProps: ()=>({
                        type: "textarea",
                        disabled: n.value,
                        maxlength: 300,
                        showCount: !0
                    }),
                giProps: {
                    span: 4
                },
                rules: [
                    {
                        required: !0,
                        validator: (s, c)=>c != null && c !== "",
                        message: `${o("hsqe.auditInspection.vesselInspection.shipVisitReport.deficiencyReport.action.description")} ${o("common.required")}`,
                        trigger: [
                            "blur",
                            "change"
                        ]
                    }
                ]
            },
            {
                field: "preventiveLine",
                slot: "preventiveLine",
                giProps: {
                    span: 4
                }
            },
            {
                label: o("hsqe.auditInspection.vesselInspection.shipVisitReport.deficiencyReport.action.actionType"),
                field: "preventActionMethod",
                component: "NSelect",
                componentProps: ()=>({
                        options: qe,
                        disabled: n.value,
                        "label-field": T.getLocale === "en" ? "labelEn" : "label"
                    })
            },
            {
                label: o("hsqe.auditInspection.vesselInspection.shipVisitReport.deficiencyReport.action.remark"),
                field: "preventActionDescription",
                component: "NInput",
                componentProps: ()=>({
                        type: "textarea",
                        disabled: n.value,
                        maxlength: 300,
                        showCount: !0
                    }),
                giProps: {
                    span: 4
                }
            }
        ], g = [
            {
                label: o("hsqe.auditInspection.vesselInspection.shipVisitReport.deficiencyReport.action.verifiedClosedON"),
                field: "correctActionReview",
                component: "NSelect",
                componentProps: ()=>({
                        disabled: y.value,
                        options: [
                            {
                                labelEn: "YES",
                                value: "yes",
                                label: "是"
                            },
                            {
                                labelEn: "NO",
                                value: "no",
                                label: "否"
                            }
                        ],
                        onUpdateValue: (s)=>{
                            e.value = s === "no";
                        },
                        "label-field": T.getLocale === "en" ? "labelEn" : "label"
                    })
            },
            {
                label: o("hsqe.auditInspection.vesselInspection.shipVisitReport.deficiencyReport.action.superintendent"),
                field: "officeResponsibleSignUrl",
                slot: "officeResponsibleSignUrl",
                hidden: ()=>t.value != "closed"
            },
            {
                label: o("hsqe.auditInspection.vesselInspection.shipVisitReport.deficiencyReport.action.comments"),
                field: "correctActionComment",
                component: "NInput",
                componentProps: ()=>({
                        type: "textarea",
                        disabled: y.value,
                        maxlength: 300,
                        showCount: !0
                    }),
                rules: [
                    {
                        validator: (s, c)=>e.value ? c != null && c !== "" : !0,
                        message: `${o("hsqe.auditInspection.vesselInspection.shipVisitReport.deficiencyReport.action.comments")} ${o("common.required")}`,
                        trigger: [
                            "blur",
                            "change",
                            "input"
                        ]
                    }
                ],
                giProps: {
                    span: 4
                }
            }
        ];
        return {
            schemas: A,
            schemasApprove: g,
            methods: {
                setReadOnly: (s)=>{
                    n.value = s;
                },
                setReviewReadOnly: (s)=>{
                    y.value = s;
                },
                setStatus: (s)=>{
                    t.value = s;
                }
            }
        };
    }
    let De, we, Ne;
    De = {
        class: "font-medium text-lg text-[#42495c] text-left relative pl-3 before:content-[''] before:absolute before:top-1/2 before:left-0 before:-translate-y-1/2 before:block before:w-[3px] before:h-3 before:bg-[#0ec06a]"
    };
    we = {
        class: "font-medium text-lg text-[#42495c] text-left relative pl-3 before:content-[''] before:absolute before:top-1/2 before:left-0 before:-translate-y-1/2 before:block before:w-[3px] before:h-3 before:bg-[#0ec06a]"
    };
    Ne = {
        class: "font-medium text-lg text-[#42495c] text-left relative pl-3 before:content-[''] before:absolute before:top-1/2 before:left-0 before:-translate-y-1/2 before:block before:w-[3px] before:h-3 before:bg-[#0ec06a]"
    };
    Le = ae({
        __name: "index",
        props: {
            btnsDisabled: {
                type: Object,
                default: ()=>({
                        hasCaptainReject: "0",
                        hasOfficerCommit: "0",
                        hasCaptainPass: "0",
                        hasDeficiencyCommit: "0",
                        hasBasicInfoEdit: "0"
                    })
            }
        },
        setup (n, { expose: y }) {
            const e = re(), { t } = w(), A = _e(), g = n, N = d(), s = d(!1), c = d(), E = F({
                readOnly: !1
            });
            c.value = E.columns;
            const { schemas: M, schemasApprove: G, methods: W } = Te(), { setReadOnly: z, setStatus: j, setReviewReadOnly: Y } = W, [Z, { setFieldsValue: O, getFieldsValue: H, submit: K }] = U({
                schemas: M,
                labelWidth: "auto",
                layout: "horizontal",
                collapsed: !0,
                gridProps: {
                    cols: 4,
                    xGap: 15
                },
                showActionButtonGroup: !1
            }), [X, { setFieldsValue: P, getFieldsValue: J }] = U({
                schemas: G,
                labelWidth: "auto",
                layout: "horizontal",
                collapsed: !0,
                gridProps: {
                    cols: 4,
                    xGap: 15
                },
                showActionButtonGroup: !1
            }), h = d();
            async function Q() {
                if (N.value = await B(), e.query.id) {
                    const a = await Re(Number(e.query.id));
                    a ? (h.value = await Ie(Number(e.query.id)), j(h.value.status), O({
                        ...a,
                        ...h.value,
                        rectifyTime: a.rectifyTime ? String(a.rectifyTime).split("T")[0] : void 0
                    }), P({
                        ...a,
                        officeResponsibleSignUrl: h.value.officeResponsibleSignUrl
                    })) : (O({}), P({}));
                }
                if (z(!e.query.isEdit || g.btnsDisabled.hasCaptainPass == 1 && g.btnsDisabled.hasOfficerCommit == 0 || e.query.status === "new"), Y(!0), !e.query.isEdit) {
                    s.value = !0;
                    const a = F({
                        readOnly: !0
                    });
                    c.value = a.columns;
                }
            }
            async function ee(a, C) {
                if (a && !await K()) return A.error(t("hsqe.auditInspection.descriptionNotNull")), !1;
                const u = H(), R = J(), r = {
                    rectifyTime: "",
                    ...u,
                    ...R,
                    reportId: e.query.reportId || C,
                    deficiencyId: e.query.id
                };
                if ("rectifyTime" in u && u.rectifyTime) {
                    let b = new Date(u.rectifyTime), f = b.getMonth() + 1;
                    f = f < 10 ? `0${f}` : f;
                    let m = b.getDate();
                    m = m < 10 ? `0${m}` : m, u.rectifyTime === "undefined" ? r.rectifyTime = "" : r.rectifyTime = b.getFullYear() + "-" + f + "-" + m + "T00:00:00";
                }
                return "id" in r && delete r.id, console.log(r), r;
            }
            return le(()=>{
                Q();
            }), y({
                getData: ee
            }), (a, C)=>{
                const u = D, R = ge, r = de, b = he, f = be, m = me, te = fe, ne = xe, ie = pe;
                return L(), k(ie, null, {
                    default: i(()=>[
                            l(ne, {
                                vertical: "",
                                size: 12
                            }, {
                                default: i(()=>[
                                        l(r, {
                                            bordered: !1,
                                            class: "proCard",
                                            "header-class": "pb-0 pl-[16px] pt-3",
                                            "content-class": "pt-0 pb-0"
                                        }, {
                                            header: i(()=>[
                                                    q("h2", De, V(p(t)("hsqe.auditInspection.vesselInspection.shipVisitReport.deficiencyReport.action.vesselAction")), 1)
                                                ]),
                                            default: i(()=>[
                                                    l(R, {
                                                        onRegister: p(Z),
                                                        "label-placement": "top"
                                                    }, {
                                                        correctiveLine: i(()=>[
                                                                q("h2", we, V(p(t)("hsqe.auditInspection.vesselInspection.shipVisitReport.deficiencyReport.action.correctiveAction")), 1)
                                                            ]),
                                                        preventiveLine: i(()=>[
                                                                q("h2", Ne, V(p(t)("hsqe.auditInspection.vesselInspection.shipVisitReport.deficiencyReport.action.preventiveAction")), 1)
                                                            ]),
                                                        officeResponsibleName: i(({ model: I, field: x })=>[
                                                                p(h)?.status == "closed" ? (L(), k(u, {
                                                                    key: 0,
                                                                    value: I[x],
                                                                    "onUpdate:value": (oe)=>I[x] = oe,
                                                                    type: "text",
                                                                    disabled: ""
                                                                }, null, 8, [
                                                                    "value",
                                                                    "onUpdate:value"
                                                                ])) : ue("", !0)
                                                            ]),
                                                        _: 1
                                                    }, 8, [
                                                        "onRegister"
                                                    ])
                                                ]),
                                            _: 1
                                        }),
                                        l(r, {
                                            bordered: !1,
                                            class: "proCard",
                                            "header-class": "pb-0 pl-[16px] pt-0",
                                            "content-class": "pt-0"
                                        }, {
                                            header: i(()=>[
                                                    l(f, null, {
                                                        default: i(()=>[
                                                                l(b, null, {
                                                                    default: i(()=>[
                                                                            ve(V(p(t)("hsqe.auditInspection.vesselInspection.shipVisitReport.deficiencyReport.action.superintendentAction")), 1)
                                                                        ]),
                                                                    _: 1
                                                                })
                                                            ]),
                                                        _: 1
                                                    })
                                                ]),
                                            default: i(()=>[
                                                    l(R, {
                                                        onRegister: p(X),
                                                        "label-placement": "top"
                                                    }, {
                                                        officeResponsibleSignUrl: i(({ model: I, field: x })=>[
                                                                l(te, {
                                                                    width: "100",
                                                                    src: I[x],
                                                                    "preview-disabled": ""
                                                                }, {
                                                                    error: i(()=>[
                                                                            l(m, {
                                                                                size: 80,
                                                                                color: "lightGrey",
                                                                                component: p(ye)
                                                                            }, null, 8, [
                                                                                "component"
                                                                            ])
                                                                        ]),
                                                                    _: 2
                                                                }, 1032, [
                                                                    "src"
                                                                ])
                                                            ]),
                                                        _: 1
                                                    }, 8, [
                                                        "onRegister"
                                                    ])
                                                ]),
                                            _: 1
                                        })
                                    ]),
                                _: 1
                            })
                        ]),
                    _: 1
                });
            };
        }
    });
});
export { Le as _, __tla };
