import { hc as Y, V as I, bk as Z, Z as _, d as G, e as J, f as ee, r as u, a as te, gW as h, gX as y, aw as oe, c as V, o as M, w as m, j as l, W as re, l as c, aI as ne, p as ie, A as ae, B as se, ca as le, X as ce, __tla as __tla_0 } from "./index-9PRMimni.js";
import { B as pe } from "./BasicForm-dL_oCSPM.js";
import { u as ue } from "./useForm-CKmgcynv.js";
import { B as me } from "./Table-0PViRYCf.js";
import { _ as de } from "./TableAction.vue_vue_type_script_setup_true_lang-Bj_Y4LtN.js";
import { c as fe } from "./sparePartsStock-8NzBm-vI.js";
import { a as $ } from "./requisitionOrder-D0IG9N7e.js";
import { r as ke } from "./dictUtils-D8jA3mBt.js";
import { _ as Se, __tla as __tla_1 } from "./InboundModal.vue_vue_type_script_setup_true_lang-BLLdgf7a.js";
import { _ as be, __tla as __tla_2 } from "./OutboundModal.vue_vue_type_script_setup_true_lang-YjVUuC-M.js";
import { _ as he, __tla as __tla_3 } from "./StockDetailsModal.vue_vue_type_script_setup_true_lang-B3V--_lK.js";
import { h as F } from "./has-CjqcrIOV.js";
import { i as ye } from "./isEmpty-BUg1OsQj.js";
import "./Render.vue_vue_type_script_lang-DKUYY0Zw.js";
import "./SingleImageUpload-CNx4b9eC.js";
import "./ImageUpload.vue_vue_type_style_index_0_scoped_cb086928_lang-D-28kXvw.js";
import "./componentSetting-DVhNDBTO.js";
import "./ImageUpload-DUsnro3W.js";
import "./vuedraggable.umd-Co2xEC3p.js";
import "./BasicUpload.vue_vue_type_style_index_0_scoped_a4d0e930_lang-DxRbtP01.js";
import "./tabsView-BXskTdVh.js";
import "./BasicForm.vue_vue_type_style_index_0_scoped_b9e995ec_lang-CEvcLwxD.js";
import "./propTypes-CebMRUpe.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";
import "./usePageCache-DluHn7Yy.js";
import "./Table.vue_vue_type_style_index_0_scoped_7b9e6ece_lang-BoW2DV_e.js";
import "./componentMap-CElCaWis.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 "./useTimeout-BxFilWvD.js";
import "./Flex-CTSf12gq.js";
import "./storageLocation-CpgPSQOH.js";
import { __tla as __tla_4 } from "./modalSchemas-qMFWMNWN.js";
import "./vesselEquipmentDetails-CJeqdW1Z.js";
import "./isNumber-D5aBrEhN.js";
let bt;
let __tla = Promise.all([
    (()=>{
        try {
            return __tla_0;
        } catch  {}
    })(),
    (()=>{
        try {
            return __tla_1;
        } catch  {}
    })(),
    (()=>{
        try {
            return __tla_2;
        } catch  {}
    })(),
    (()=>{
        try {
            return __tla_3;
        } catch  {}
    })(),
    (()=>{
        try {
            return __tla_4;
        } catch  {}
    })()
]).then(async ()=>{
    let W, H, _e, d, B, w, z, we, Pe, o, Ne;
    W = [
        {
            label: "是",
            labelEn: "YES",
            value: 1
        },
        {
            label: "否",
            labelEn: "NO",
            value: 0
        }
    ];
    H = {
        VESSEL: "vessel"
    };
    _e = H.VESSEL;
    ({ t: d } = I());
    B = Z();
    w = await Y();
    z = w && w.length > 0 ? w[0].id : "";
    we = async ({ shipId: p, code: e = "0", model: t = "0", serialNumber: a = "0" })=>(await $({
            shipId: p,
            code: e,
            model: t,
            serialNumber: a
        })).map((s)=>({
                label: s.name,
                value: s.code + "-" + s.model + "-" + s.serialNumber,
                isLeaf: s.ifLeaf,
                raw: s
            }));
    Pe = (p)=>({
            schemas: [
                {
                    field: "componentType",
                    hidden: !0
                },
                {
                    field: "componentSubType",
                    hidden: !0
                },
                {
                    field: "shipId",
                    component: "NSelect",
                    label: d("sparePartsStock.vessel"),
                    componentProps: {
                        options: w,
                        defaultValue: z,
                        clearable: !1,
                        filterable: !0,
                        "label-field": B.getLocale === "en" ? "shipNameEn" : "shipName",
                        "value-field": "id",
                        onUpdateValue: (t)=>{
                            p.initCodePrefixOptions(t), p.shipId.value = t;
                        }
                    }
                },
                {
                    field: "equipmentCodeOrName",
                    component: "NInput",
                    label: d("sparePartsStock.equipmentCodeName"),
                    componentProps: {}
                },
                {
                    field: "equipmentType",
                    component: "NCascader",
                    label: d("sparePartsStock.equipmentType"),
                    componentProps: {
                        checkStrategy: "parent",
                        showPath: !1,
                        allowCheckingNotLoaded: !0,
                        options: p.codePrefixOptions,
                        remote: !0,
                        onLoad: async (t)=>{
                            t.children = await we({
                                shipId: p.shipId.value,
                                code: t.raw.code,
                                model: t.raw.model,
                                serialNumber: t.raw.serialNumber
                            });
                        }
                    }
                },
                {
                    field: "critical",
                    component: "NSelect",
                    label: d("sparePartsStock.critical"),
                    componentProps: {
                        options: W,
                        "label-field": B.getLocale === "en" ? "labelEn" : "label"
                    }
                },
                {
                    field: "rob",
                    component: "BasicSelect",
                    label: d("sparePartsStock.rob"),
                    componentProps: {
                        block: !0,
                        cacheKey: "rob_condition"
                    }
                },
                {
                    field: "partNumberOrDescription",
                    component: "NInput",
                    label: d("sparePartsStock.partNumberOrDescription"),
                    componentProps: {}
                }
            ],
            initShipValue: z
        });
    ({ t: o } = I());
    Ne = ()=>({
            columns: [
                {
                    title: o("common.messagedefine.Num"),
                    key: "num",
                    width: 60,
                    render: (e, t)=>t + 1
                },
                {
                    title: o("sparePartsStock.equipmentCode"),
                    key: "equipmentCode",
                    width: 140
                },
                {
                    title: o("sparePartsStock.equipmentName"),
                    key: "equipmentName",
                    width: 140
                },
                {
                    title: o("sparePartsStock.partNumber"),
                    key: "partNumber",
                    width: 140
                },
                {
                    title: o("sparePartsStock.description"),
                    key: "itemDescription",
                    width: 140
                },
                {
                    title: o("sparePartsStock.drawingPlateNo"),
                    key: "drawingPlateNo",
                    width: 140
                },
                {
                    title: o("sparePartsStock.critical"),
                    key: "critical",
                    width: 100,
                    render: (e)=>ke(W, e.critical)
                },
                {
                    title: o("sparePartsStock.uom"),
                    key: "uom",
                    width: 100
                },
                {
                    title: o("sparePartsStock.rob"),
                    key: "rob",
                    width: 100,
                    render: (e)=>{
                        const t = Number(e.rob), a = Number(e.minStock);
                        return a === 0 && t === 0 ? _("div", {
                            style: {
                                color: "red"
                            }
                        }, 0) : t < a ? _("div", {
                            style: {
                                color: "red"
                            }
                        }, e.rob) : t === a ? _("div", {
                            style: {
                                color: "yellow"
                            }
                        }, e.rob) : e.rob ? t : 0;
                    }
                },
                {
                    title: o("sparePartsStock.normalStock"),
                    key: "normalStock",
                    width: 140,
                    render: (e)=>e.normalStock ? Number(e.normalStock).toFixed(0) : 0
                },
                {
                    title: o("sparePartsStock.normalFrozenStock"),
                    key: "freezeNormalStock",
                    width: 140,
                    render: (e)=>e.freezeNormalStock ? Number(e.freezeNormalStock).toFixed(0) : 0
                },
                {
                    title: o("sparePartsStock.reconditionedStock"),
                    key: "reconditionedStock",
                    width: 140,
                    render: (e)=>e.reconditionedStock ? Number(e.reconditionedStock).toFixed(0) : 0
                },
                {
                    title: o("sparePartsStock.reconditionedFrozenStock"),
                    key: "freezeReconditionedStock",
                    width: 140,
                    render: (e)=>e.freezeReconditionedStock ? Number(e.freezeReconditionedStock).toFixed(0) : 0
                },
                {
                    title: o("sparePartsStock.stockTakenDate"),
                    key: "stockTakenDate",
                    width: 140
                },
                {
                    title: o("sparePartsStock.minStock"),
                    key: "minStock",
                    width: 140
                }
            ]
        });
    bt = G({
        __name: "index",
        setup (p) {
            const { t: e } = I(), t = J(), a = ee(), { columns: C } = Ne(), s = u(), R = u(), T = u(), q = u(), f = u(void 0), L = u([]), P = u(!1), E = u(!1), X = te({
                width: 180,
                title: e("common.optionsText"),
                key: "action",
                fixed: "right",
                align: "center",
                render (n) {
                    return _(de, {
                        style: "text",
                        actions: [
                            {
                                label: e("sparePartsStock.outStock"),
                                labelShow: !1,
                                icon: h(y.outbound, "text-[24px]"),
                                onClick: ()=>T.value?.handleOpenModal(n),
                                ifShow: _e === H.VESSEL
                            },
                            {
                                label: e("sparePartsStock.inventoryHistory"),
                                labelShow: !1,
                                icon: h(y.inventoryHistory, "text-[20px]"),
                                onClick: ()=>t.push({
                                        name: "inventoryHistorySparePart",
                                        query: {
                                            itemId: n.itemId,
                                            shipId: n.shipId
                                        }
                                    })
                            },
                            {
                                label: e("common.optionsViewText"),
                                labelShow: !1,
                                icon: h(y.inventoryDetail, "text-[20px]"),
                                onClick: ()=>q.value?.handleOpenModal(n)
                            }
                        ]
                    });
                }
            });
            function A() {
                R.value?.handleOpenModal(f.value);
            }
            function U() {
                if (ye(a.query) || E.value) return {};
                const { partNumber: n, shipId: r, criticalToSafety: i, productCode: v, statusId: g } = a.query, b = {
                    shipId: r ? Number(r) : f.value,
                    partNumberOrDescription: n,
                    critical: i,
                    equipmentCodeOrName: v,
                    rob: g === "2" ? "1" : void 0
                };
                return N(b), E.value = !0, b;
            }
            async function O(n) {
                if (!n) return;
                const r = await $({
                    shipId: n.toString() || k.toString(),
                    code: "0",
                    model: "0",
                    serialNumber: "0"
                });
                L.value = r.map((i)=>({
                        label: i.name,
                        value: i.code + "-" + i.model + "-" + i.serialNumber,
                        isLeaf: i.ifLeaf,
                        raw: i
                    }));
            }
            async function j(n, r) {
                return !F(D(), "shipId") && !P.value && !F(a.query, "shipId") && (N({
                    shipId: k
                }), r.shipId = k, P.value = !0), r.equipmentType && (r.equipmentType = r.equipmentType.split("-")[0]), f.value = r.shipId, N({
                    shipId: r.shipId
                }), await fe({
                    ...n,
                    ...U(),
                    ...r
                });
            }
            const { schemas: K, initShipValue: k } = Pe({
                codePrefixOptions: L,
                shipId: f,
                initCodePrefixOptions: O
            }), [Q, { getFieldsValue: D, setFieldsValue: N }] = ue({
                gridProps: {
                    cols: 6
                },
                schemas: K
            });
            function S() {
                P.value = !1, s.value?.restReload();
            }
            return oe(async ()=>{
                await O(k);
            }), (n, r)=>{
                const i = re, v = se, g = ne, b = ce;
                return M(), V(b, null, {
                    default: m(()=>[
                            l(i, {
                                bordered: !1,
                                class: "proCard"
                            }, {
                                default: m(()=>[
                                        l(c(pe), {
                                            onRegister: c(Q),
                                            onSubmit: S,
                                            onReset: S
                                        }, null, 8, [
                                            "onRegister"
                                        ])
                                    ]),
                                _: 1
                            }),
                            l(i, {
                                bordered: !1,
                                class: "proCard mt-2"
                            }, {
                                default: m(()=>[
                                        l(c(me), {
                                            ref_key: "basicTableRef",
                                            ref: s,
                                            columns: c(C),
                                            request: (x)=>j(x, c(D)()),
                                            "row-key": (x)=>x.id,
                                            autoScrollX: !0,
                                            actionColumn: c(X),
                                            "virtual-scroll": ""
                                        }, {
                                            toolbar: m(()=>[
                                                    l(g, {
                                                        trigger: "hover"
                                                    }, {
                                                        trigger: m(()=>[
                                                                l(v, {
                                                                    type: "primary",
                                                                    strong: "",
                                                                    secondary: "",
                                                                    class: "px-[5px] h-[28px] rounded-md",
                                                                    onClick: A
                                                                }, {
                                                                    icon: m(()=>[
                                                                            (M(), V(le(c(h)(c(y).inbound, "text-[24px]"))))
                                                                        ]),
                                                                    _: 1
                                                                })
                                                            ]),
                                                        default: m(()=>[
                                                                ie(" " + ae(c(e)("sparePartsStock.inStock")), 1)
                                                            ]),
                                                        _: 1
                                                    })
                                                ]),
                                            _: 1
                                        }, 8, [
                                            "columns",
                                            "request",
                                            "row-key",
                                            "actionColumn"
                                        ])
                                    ]),
                                _: 1
                            }),
                            l(Se, {
                                ref_key: "inboundModalRef",
                                ref: R,
                                onSuccess: S
                            }, null, 512),
                            l(be, {
                                ref_key: "outboundModalRef",
                                ref: T,
                                onSuccess: S
                            }, null, 512),
                            l(he, {
                                ref_key: "stockDetailsModalRef",
                                ref: q
                            }, null, 512)
                        ]),
                    _: 1
                });
            };
        }
    });
});
export { bt as default, __tla };
