import { V as k, bk as A, gL as V, hc as K, d as Q, e as ee, r as u, a as te, Z as L, gW as f, gX as h, iE as oe, iF as ie, cZ as se, aw as ne, c as N, o as I, w as r, j as m, W as ae, l as a, H as le, D as ce, aI as pe, p as re, A as de, B as me, ca as ue, X as fe, __tla as __tla_0 } from "./index-9PRMimni.js";
import { B as he } from "./Table-0PViRYCf.js";
import { _ as be } from "./TableAction.vue_vue_type_script_setup_true_lang-Bj_Y4LtN.js";
import { B as ye } from "./BasicForm-dL_oCSPM.js";
import { u as ge } from "./useForm-CKmgcynv.js";
import { a as O } from "./requisitionOrder-D0IG9N7e.js";
import { i as _e, j as we, k as ve } from "./defectList-JLVZ8qtV.js";
import { u as Le } from "./useRole-C-Zpngq4.js";
import { r as Ne } from "./dictUtils-D8jA3mBt.js";
import { h as Ie } from "./has-CjqcrIOV.js";
import "./Table.vue_vue_type_style_index_0_scoped_7b9e6ece_lang-BoW2DV_e.js";
import "./vuedraggable.umd-Co2xEC3p.js";
import "./Render.vue_vue_type_script_lang-DKUYY0Zw.js";
import "./componentMap-CElCaWis.js";
import "./propTypes-CebMRUpe.js";
import "./format-DgF6KtHk.js";
import "./omit-B2_8Y6O_.js";
import "./_flatRest-DBrd2CHT.js";
import "./flatten-DeoUZLdb.js";
import "./print-CT_2hrjP.js";
import "./basicModal.vue_vue_type_script_setup_true_lang-CsJydKhW.js";
import "./basicModal.vue_vue_type_style_index_0_lang-8QZP7ApW.js";
import "./useModal-CO65vga3.js";
import "./componentSetting-DVhNDBTO.js";
import "./useTimeout-BxFilWvD.js";
import "./usePageCache-DluHn7Yy.js";
import "./tabsView-BXskTdVh.js";
import "./Flex-CTSf12gq.js";
import "./SingleImageUpload-CNx4b9eC.js";
import "./ImageUpload.vue_vue_type_style_index_0_scoped_cb086928_lang-D-28kXvw.js";
import "./ImageUpload-DUsnro3W.js";
import "./BasicUpload.vue_vue_type_style_index_0_scoped_a4d0e930_lang-DxRbtP01.js";
import "./BasicForm.vue_vue_type_style_index_0_scoped_b9e995ec_lang-CEvcLwxD.js";
import "./BasicSelect-C_uwzMkE.js";
import "./BasicSelect.vue_vue_type_style_index_0_scoped_772d51cc_lang-Brp6PjEU.js";
import "./dictionary-BRse4lkf.js";
import "./index-DkvzUEqh.js";
import "./index-kKnqLkWM.js";
import "./AutoComplete-Dv1Bqed4.js";
import "./TreeSelect-BZh2DeCh.js";
let yt;
let __tla = Promise.all([
    (()=>{
        try {
            return __tla_0;
        } catch  {}
    })()
]).then(async ()=>{
    let ke, Ce, s, Ee, Se, q, l, b, D, Pe, Re;
    ke = A();
    Ce = await V("voyage_repair_status");
    ({ t: s } = k());
    Ee = ()=>({
            columns: [
                {
                    title: s("common.messagedefine.Num"),
                    key: "num",
                    width: 60,
                    render: (t, i)=>i + 1
                },
                {
                    title: s("pms.defectList.vessel"),
                    key: ke.getLocale === "en" ? "shipNameEn" : "shipName",
                    width: 140
                },
                {
                    title: s("pms.defectList.defectNo"),
                    key: "defectNo",
                    width: 140
                },
                {
                    title: s("pms.defectList.defectTitle"),
                    key: "title",
                    width: 140
                },
                {
                    title: s("pms.defectList.equipmentName"),
                    key: "equipmentName",
                    width: 140
                },
                {
                    title: s("pms.defectList.voyageRepair"),
                    key: "serviceRequired",
                    width: 140,
                    render: (t)=>t.serviceRequired == 1 ? "YES" : "NO"
                },
                {
                    title: s("pms.defectList.defectPriority"),
                    key: "level",
                    width: 140,
                    render: (t)=>t.level == 1 ? s("pms.defectList.urgent") : t.level == 2 ? s("pms.defectList.warning") : s("pms.defectList.normal")
                },
                {
                    title: s("pms.defectList.reportDate"),
                    key: "issueDate",
                    width: 140
                },
                {
                    title: s("pms.defectList.raisedBy"),
                    key: "reporterName",
                    width: 140
                },
                {
                    title: s("pms.defectList.status"),
                    key: "vendorName",
                    width: 140,
                    render: (t)=>Ne(Ce, t.status)
                }
            ]
        });
    Se = await V("voyage_repair_status");
    q = A();
    ({ t: l } = k());
    b = await K();
    D = b && b.length > 0 ? b[0].id : "";
    Pe = async ({ shipId: c, code: t = "0", model: i = "0", serialNumber: d = "0" })=>(await O({
            shipId: c,
            code: t,
            model: i,
            serialNumber: d
        })).map((p)=>({
                label: p.name,
                value: p.code + "-" + p.model + "-" + p.serialNumber,
                isLeaf: p.ifLeaf,
                raw: p
            }));
    Re = (c)=>({
            schemas: [
                {
                    field: "shipId",
                    component: "NSelect",
                    label: l("pms.defectList.vessel"),
                    componentProps: {
                        options: b,
                        filterable: !0,
                        defaultValue: D,
                        clearable: !1,
                        "label-field": q.getLocale === "en" ? "shipNameEn" : "shipName",
                        "value-field": "id",
                        onUpdateValue: (i)=>{
                            c.initCodePrefixOptions(i), c.shipId.value = i;
                        }
                    }
                },
                {
                    field: "equipmentName",
                    component: "NInput",
                    label: l("pms.defectList.equipmentName"),
                    componentProps: {}
                },
                {
                    field: "issueDate",
                    component: "NDatePicker",
                    label: l("pms.defectList.issuedDate"),
                    componentProps: {
                        type: "daterange",
                        valueFormat: "yyyy-MM-dd"
                    }
                },
                {
                    field: "title",
                    component: "NInput",
                    label: l("pms.defectList.defectTitle"),
                    componentProps: {}
                },
                {
                    field: "status",
                    component: "NSelect",
                    label: l("pms.defectList.status"),
                    componentProps: {
                        placeholder: l("pms.defectList.status"),
                        options: Se,
                        "label-field": q.getLocale === "en" ? "labelEn" : "label"
                    }
                },
                {
                    field: "category",
                    component: "NSelect",
                    label: l("pms.defectList.defectPriority"),
                    componentProps: {
                        block: !0,
                        options: [
                            {
                                value: 1,
                                label: "HULL",
                                labelEn: "HULL"
                            },
                            {
                                value: 2,
                                label: "MACHINERY",
                                labelEn: "MACHINERY"
                            },
                            {
                                value: 3,
                                label: "ELECTRIC",
                                labelEn: "ELECTRIC"
                            },
                            {
                                value: 4,
                                label: "NAVIGATION",
                                labelEn: "NAVIGATION"
                            }
                        ]
                    }
                },
                {
                    field: "sectionName",
                    component: "NSelect",
                    label: l("pms.defectList.sectionName"),
                    componentProps: {
                        options: [
                            {
                                value: 1,
                                label: "Deck",
                                labelEn: "Deck"
                            },
                            {
                                value: 2,
                                label: "Engine Room",
                                labelEn: "Engine Room"
                            }
                        ]
                    }
                },
                {
                    field: "equipmentCode",
                    component: "NInput",
                    label: l("pms.defectList.equipmentCode"),
                    componentProps: {}
                },
                {
                    field: "equipmentType",
                    component: "NCascader",
                    label: l("pms.defectList.equipmentType"),
                    componentProps: {
                        style: {
                            width: "100%"
                        },
                        checkStrategy: "parent",
                        showPath: !1,
                        allowCheckingNotLoaded: !0,
                        options: c.codePrefixOptions,
                        remote: !0,
                        onLoad: async (i)=>{
                            i.children = await Pe({
                                shipId: c.shipId.value,
                                code: i.raw.code,
                                model: i.raw.model,
                                serialNumber: i.raw.serialNumber
                            });
                        }
                    }
                }
            ],
            initShipValue: D
        });
    yt = Q({
        __name: "index",
        setup (c) {
            const { t } = k(), i = se(), d = ee(), { hasSomeRole: C } = Le(), { columns: p } = Ee(), E = u(), B = u(), S = u([]), y = u(0), g = u(!1), F = te({
                width: 120,
                title: t("common.optionsText"),
                key: "action",
                fixed: "right",
                align: "center",
                render (e) {
                    return L(be, {
                        style: "text",
                        actions: [
                            {
                                label: t("common.optionsViewText"),
                                labelShow: !1,
                                icon: f(h.view, "blue"),
                                onClick: ()=>{
                                    P("defectFromPage", {
                                        id: e.id,
                                        jobId: e?.jobId,
                                        type: "view",
                                        canEdit: e.canEdit,
                                        canApprove: e.canApprove
                                    });
                                }
                            },
                            {
                                label: t("common.optionsEditText"),
                                labelShow: !1,
                                icon: f(h.edit),
                                onClick: ()=>{
                                    P("defectFromPage", {
                                        id: e.id,
                                        jobId: e?.jobId,
                                        type: "edit",
                                        canEdit: e.canEdit,
                                        canApprove: e.canApprove
                                    });
                                },
                                ifShow: ()=>[
                                        1,
                                        6,
                                        7
                                    ].includes(e.status) && e.canEdit
                            },
                            {
                                label: t("common.uoLoadShip"),
                                labelShow: !1,
                                icon: L(oe, {
                                    class: "text-[#0EC06A] text-[14px]"
                                }),
                                onClick: ()=>M(e),
                                ifShow: ()=>[
                                        4
                                    ].includes(e.status) && [
                                        1
                                    ].includes(e.serviceRequired)
                            },
                            {
                                label: t("pms.defectList.repairReport"),
                                labelShow: !1,
                                icon: L(ie, {
                                    class: "text-[#0EC06A] text-[14px]"
                                }),
                                onClick: ()=>j(e),
                                ifShow: ()=>[
                                        4
                                    ].includes(e.status) && [
                                        0
                                    ].includes(e.serviceRequired)
                            },
                            {
                                label: t("common.optionsDelText"),
                                labelShow: !1,
                                icon: f(h.delete, "red"),
                                ifShow: ()=>[
                                        1,
                                        6,
                                        7
                                    ].includes(e.status) && e.canEdit,
                                onPositiveClick: async ()=>{
                                    await _e(e.id), i.success(t("common.delPop.success")), _();
                                },
                                onNegativeClick: ()=>{},
                                isConfirm: !0,
                                confirmContent: t("requisitionOrder.delPop")
                            }
                        ]
                    });
                }
            });
            function j(e) {
                e.jobId ? d.push({
                    name: "unPlannedJob",
                    query: {
                        status: "edit",
                        id: e?.jobId,
                        shipId: e?.shipId || null
                    }
                }) : d.push({
                    name: "unPlannedJob",
                    query: {
                        status: "add",
                        shipId: e?.shipId || null,
                        repairId: e.id
                    }
                });
            }
            function P(e, o) {
                d.push({
                    name: e,
                    query: o
                });
            }
            function M(e) {
                d.push({
                    name: "defectFromPage",
                    query: {
                        id: e.id,
                        type: "upload",
                        canEdit: e.canEdit,
                        canApprove: e.canApprove,
                        activeTab: "Review"
                    }
                });
            }
            async function U() {
                const e = await we();
                d.push({
                    name: "defectFromPage",
                    query: {
                        id: e.id,
                        type: "add"
                    }
                });
            }
            async function H(e, o) {
                !Ie(x(), "shipId") && !g.value && (T({
                    shipId: w
                }), o.shipId = w, g.value = !0), o.issueDate && o.issueDate.length !== 0 && (o.issueDate = o.issueDate.join(",")), y.value = o.shipId, T({
                    shipId: o.shipId
                }), o.equipmentType && (o.equipmentType = o.equipmentType.split("-")[0]);
                const n = await ve({
                    ...e,
                    ...o
                });
                return n && (B.value = n.list), n;
            }
            async function R(e) {
                const o = await O({
                    shipId: e?.toString() || w.toString(),
                    code: "0",
                    model: "0",
                    serialNumber: "0"
                });
                S.value = o.map((n)=>({
                        label: n.name,
                        value: n.code,
                        isLeaf: n.ifLeaf,
                        raw: n
                    }));
            }
            function $() {
                _();
            }
            function W() {
                _();
            }
            function _() {
                g.value = !1, E.value?.restReload();
            }
            const { schemas: G, initShipValue: w } = Re({
                codePrefixOptions: S,
                shipId: y,
                initCodePrefixOptions: R
            }), [J, { getFieldsValue: x, setFieldsValue: T }] = ge({
                gridProps: {
                    cols: 6
                },
                schemas: G
            });
            return ne(async ()=>{
                await R(y.value);
            }), (e, o)=>{
                const n = ae, X = me, Y = pe, Z = le, z = fe;
                return I(), N(z, null, {
                    default: r(()=>[
                            m(n, {
                                bordered: !1,
                                class: "proCard mb-[8px]"
                            }, {
                                default: r(()=>[
                                        m(a(ye), {
                                            onRegister: a(J),
                                            onSubmit: $,
                                            onReset: W
                                        }, null, 8, [
                                            "onRegister"
                                        ])
                                    ]),
                                _: 1
                            }),
                            m(n, {
                                bordered: !1,
                                class: "proCard mt-2"
                            }, {
                                default: r(()=>[
                                        m(a(he), {
                                            columns: a(p),
                                            request: (v)=>H(v, a(x)()),
                                            "row-key": (v)=>v.id,
                                            ref_key: "basicTableRef",
                                            ref: E,
                                            autoScrollX: !0,
                                            "virtual-scroll": "",
                                            actionColumn: a(F)
                                        }, {
                                            toolbar: r(()=>[
                                                    m(Z, null, {
                                                        default: r(()=>[
                                                                a(C)([
                                                                    "captain"
                                                                ]) ? ce("", !0) : (I(), N(Y, {
                                                                    key: 0,
                                                                    trigger: "hover"
                                                                }, {
                                                                    trigger: r(()=>[
                                                                            m(X, {
                                                                                strong: "",
                                                                                secondary: "",
                                                                                class: "px-[5px] h-[28px] rounded-md",
                                                                                type: "primary",
                                                                                onClick: U
                                                                            }, {
                                                                                icon: r(()=>[
                                                                                        (I(), N(ue(a(f)(a(h).add))))
                                                                                    ]),
                                                                                _: 1
                                                                            })
                                                                        ]),
                                                                    default: r(()=>[
                                                                            re(de(a(t)("common.addText")), 1)
                                                                        ]),
                                                                    _: 1
                                                                }))
                                                            ]),
                                                        _: 1
                                                    })
                                                ]),
                                            _: 1
                                        }, 8, [
                                            "columns",
                                            "request",
                                            "row-key",
                                            "actionColumn"
                                        ])
                                    ]),
                                _: 1
                            })
                        ]),
                    _: 1
                });
            };
        }
    });
});
export { yt as default, __tla };
