import { ad as H, V as k, bk as D, gL as z, hc as Q, d as Y, e as ee, b as te, r as g, a as oe, Z as ne, gW as w, gX as v, cZ as ie, aw as se, c as x, o as J, w as u, j as m, W as ae, l as r, H as le, aI as re, p as pe, A as ue, B as ce, ca as me, X as de, __tla as __tla_0 } from "./index-9PRMimni.js";
import { B as be } from "./Table-0PViRYCf.js";
import { _ as fe } from "./TableAction.vue_vue_type_script_setup_true_lang-Bj_Y4LtN.js";
import { B as ye } from "./BasicForm-dL_oCSPM.js";
import { u as he } from "./useForm-CKmgcynv.js";
import { a as R } from "./requisitionOrder-D0IG9N7e.js";
import { k as _e } from "./unPlannedJob-BvCurP2n.js";
import { r as P } from "./dictUtils-D8jA3mBt.js";
import { h as O } 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 ct;
let __tla = Promise.all([
    (()=>{
        try {
            return __tla_0;
        } catch  {}
    })()
]).then(async ()=>{
    function ge(i) {
        return H.Get("/unplanned/basic/page", {
            params: i
        });
    }
    let B, p, V, we, ve, j, Se, Ce, d, S, E, Te, Le;
    B = D();
    ({ t: p } = k());
    V = {
        jobCategory: "unplanned_category",
        jobType: "pms_job_type",
        jobStatus: "unplanned_status",
        equipmentType: "unplanned_maintenance_cause",
        jobPriority: "pms_job_priority"
    };
    we = Object.values(V).map((i)=>z(i));
    ve = await Promise.all(we);
    j = Object.fromEntries(Object.keys(V).map((i, e)=>[
            i,
            ve[e]
        ]));
    Se = ()=>({
            columns: [
                {
                    title: p("common.messagedefine.Num"),
                    key: "num",
                    width: 60,
                    render: (e, s)=>s + 1
                },
                {
                    title: p("pms.unplannedJobList.equipmentName"),
                    key: "equipmentName",
                    width: 140
                },
                {
                    title: p("pms.unplannedJobList.jobCode"),
                    key: "jobCode",
                    width: 120
                },
                {
                    title: p("pms.unplannedJobList.jobTitle"),
                    key: "jobTitle",
                    width: 140
                },
                {
                    title: p("pms.unplannedJobList.jobCategory"),
                    key: "jobCategory",
                    width: 140,
                    render: (e)=>P(j.jobCategory, e.jobCategory)
                },
                {
                    title: p("pms.unplannedJobList.PIC"),
                    key: "disciplineName",
                    width: 140,
                    render: (e)=>e.disciplineName ? B.getLocale === "en" ? e?.disciplineNameEn : e?.disciplineName : ""
                },
                {
                    title: p("pms.unplannedJobList.jobStatus"),
                    key: "status",
                    width: 140,
                    render: (e)=>P(j.jobStatus, e.status.toString())
                },
                {
                    title: p("pms.unplannedJobList.jobPriority"),
                    key: "jobPriority",
                    width: 120,
                    render: (e)=>P(j.jobPriority, e.jobPriority)
                },
                {
                    title: p("pms.unplannedJobList.reportBy"),
                    key: B.getLocale === "en" ? "reportByNameEn" : "reportByName",
                    width: 100
                }
            ]
        });
    Ce = D();
    ({ t: d } = k());
    S = await Q();
    E = S && S.length > 0 ? S[0].id : "";
    Te = async ({ shipId: i, code: e = "0", model: s = "0", serialNumber: b = "0" })=>(await R({
            shipId: i,
            code: e,
            model: s,
            serialNumber: b
        })).map((o)=>({
                label: o.name,
                value: o.code + "-" + o.model + "-" + o.serialNumber,
                isLeaf: o.ifLeaf,
                raw: o
            }));
    Le = (i)=>({
            schemas: [
                {
                    field: "oneEquipmentSubType",
                    hidden: !0
                },
                {
                    field: "twoEquipmentSubType",
                    hidden: !0
                },
                {
                    field: "shipId",
                    component: "NSelect",
                    label: d("pms.unplannedJobList.vessel"),
                    componentProps: {
                        options: S,
                        defaultValue: E,
                        clearable: !1,
                        filterable: !0,
                        "label-field": Ce.getLocale === "en" ? "shipNameEn" : "shipName",
                        "value-field": "id"
                    }
                },
                {
                    field: "equipmentType",
                    component: "NCascader",
                    label: d("pms.unplannedJobList.equipmentType"),
                    componentProps: ({ formAction: s })=>{
                        const { getFieldsValue: b, setFieldsValue: y } = s;
                        return {
                            checkStrategy: "parent",
                            showPath: !1,
                            allowCheckingNotLoaded: !0,
                            options: i.codePrefixOptions.value,
                            remote: !0,
                            onUpdateValue: (o, C, l)=>{
                                try {
                                    const a = {};
                                    if (Array.isArray(l) && l.length > 0) {
                                        const f = l[0], h = l.length > 1 ? l[1] : null, c = l.length > 2 ? l[2] : null;
                                        a.equipmentType = f && f.value !== void 0 ? f.value : null, a.oneEquipmentSubType = h && h.value !== void 0 ? h.value : null, a.twoEquipmentSubType = c && c.value !== void 0 ? c.value : null;
                                    } else a.equipmentType = null, a.oneEquipmentSubType = null, a.twoEquipmentSubType = null;
                                    y(a);
                                } catch (a) {
                                    console.error("Error updating equipment type values:", a), y({
                                        equipmentType: null,
                                        oneEquipmentSubType: null,
                                        twoEquipmentSubType: null
                                    });
                                }
                            },
                            onLoad: async (o)=>{
                                O(b(), "shipId") && (i.shipId.value = b().shipId), o.children = await Te({
                                    shipId: i.shipId.value,
                                    code: o.raw.code,
                                    model: o.raw.model,
                                    serialNumber: o.raw.serialNumber
                                });
                            }
                        };
                    }
                },
                {
                    field: "equipmentCode",
                    component: "NInput",
                    label: d("pms.unplannedJobList.equipmentCode"),
                    componentProps: {}
                },
                {
                    field: "equipmentName",
                    component: "NInput",
                    label: d("pms.unplannedJobList.equipmentName"),
                    componentProps: {}
                },
                {
                    field: "jobPriority",
                    component: "BasicSelect",
                    label: d("pms.unplannedJobList.jobPriority"),
                    componentProps: {
                        block: !0,
                        cacheKey: "pms_job_priority"
                    }
                },
                {
                    field: "status",
                    component: "BasicSelect",
                    label: d("pms.unplannedJobList.jobStatus"),
                    componentProps: {
                        block: !0,
                        cacheKey: "unplanned_status"
                    }
                },
                {
                    field: "search",
                    component: "NInput",
                    label: d("pms.unplannedJobList.search"),
                    componentProps: {}
                }
            ],
            initShipValue: E
        });
    ct = Y({
        __name: "index",
        setup (i) {
            const e = ee(), { t: s } = k(), b = ie(), { shipList: y } = te(), { columns: o } = Se(), C = g(), l = g(!1), a = g(), f = g(), h = oe({
                width: 150,
                title: s("common.optionsText"),
                key: "action",
                fixed: "right",
                align: "center",
                render (n) {
                    return ne(fe, {
                        style: "text",
                        actions: [
                            {
                                label: s("common.optionsEditText"),
                                labelShow: !1,
                                icon: w(v.edit),
                                onClick: ()=>c("edit", n),
                                ifShow: ()=>n.editButton
                            },
                            {
                                label: s("common.optionsViewText"),
                                labelShow: !1,
                                icon: w(v.view, "blue"),
                                onClick: ()=>c("view", n)
                            },
                            {
                                label: s("common.optionsDelText"),
                                labelShow: !1,
                                ifShow: ()=>n.deleteButton,
                                icon: w(v.delete, "red"),
                                onPositiveClick: async ()=>{
                                    await _e(n.id), b.success(s("common.optionsDelSuccessText")), L();
                                },
                                onNegativeClick: ()=>{},
                                isConfirm: !0,
                                confirmContent: s("common.dialogContentDeleteText")
                            }
                        ]
                    });
                }
            });
            function c(n, t) {
                e.push({
                    name: "unPlannedJob",
                    query: {
                        status: n,
                        id: t?.id,
                        shipId: t?.shipId || y[0]?.id
                    }
                });
            }
            async function F(n, t) {
                return !O(q(), "shipId") && !l.value && (N({
                    shipId: T
                }), t.shipId = T, l.value = !0), a.value = t.shipId, N({
                    shipId: t.shipId
                }), await ge({
                    ...n,
                    ...t
                });
            }
            function A() {
                R({
                    shipId: a.value?.toString() || T.toString(),
                    code: "0",
                    model: "0",
                    serialNumber: "0"
                }).then((n)=>{
                    f.value = n.map((t)=>({
                            label: t.name,
                            value: t.code,
                            isLeaf: t.ifLeaf,
                            raw: t
                        }));
                }).catch((n)=>{
                    console.error("Failed to fetch code prefix options:", n);
                });
            }
            const { schemas: $, initShipValue: T } = Le({
                codePrefixOptions: f,
                shipId: a
            }), [M, { getFieldsValue: q, setFieldsValue: N }] = he({
                gridProps: {
                    cols: 6
                },
                schemas: $
            });
            async function U() {
                L();
            }
            function W() {
                L();
            }
            function L() {
                l.value = !1, C.value?.restReload();
            }
            return se(()=>{
                A();
            }), (n, t)=>{
                const I = ae, X = ce, K = re, Z = le, G = de;
                return J(), x(G, null, {
                    default: u(()=>[
                            m(I, {
                                bordered: !1,
                                class: "proCard"
                            }, {
                                default: u(()=>[
                                        m(r(ye), {
                                            onRegister: r(M),
                                            onSubmit: U,
                                            onReset: W
                                        }, null, 8, [
                                            "onRegister"
                                        ])
                                    ]),
                                _: 1
                            }),
                            m(I, {
                                bordered: !1,
                                class: "proCard mt-2"
                            }, {
                                default: u(()=>[
                                        m(r(be), {
                                            columns: r(o),
                                            request: (_)=>F(_, r(q)()),
                                            "row-key": (_)=>_.id,
                                            ref_key: "basicTableRef",
                                            ref: C,
                                            autoScrollX: !0,
                                            "virtual-scroll": "",
                                            actionColumn: r(h)
                                        }, {
                                            toolbar: u(()=>[
                                                    m(Z, null, {
                                                        default: u(()=>[
                                                                m(K, {
                                                                    trigger: "hover"
                                                                }, {
                                                                    trigger: u(()=>[
                                                                            m(X, {
                                                                                type: "primary",
                                                                                strong: "",
                                                                                bordered: "",
                                                                                secondary: "",
                                                                                class: "px-[5px] h-[28px] rounded-md",
                                                                                onClick: t[0] || (t[0] = (_)=>c("add"))
                                                                            }, {
                                                                                icon: u(()=>[
                                                                                        (J(), x(me(r(w)(r(v).add))))
                                                                                    ]),
                                                                                _: 1
                                                                            })
                                                                        ]),
                                                                    default: u(()=>[
                                                                            pe(" " + ue(r(s)("common.addText")), 1)
                                                                        ]),
                                                                    _: 1
                                                                })
                                                            ]),
                                                        _: 1
                                                    })
                                                ]),
                                            _: 1
                                        }, 8, [
                                            "columns",
                                            "request",
                                            "row-key",
                                            "actionColumn"
                                        ])
                                    ]),
                                _: 1
                            })
                        ]),
                    _: 1
                });
            };
        }
    });
});
export { ct as default, __tla };
