import { V as L, Z as u, bk as Z, d as j, f as Y, a4 as U, a as J, bl as T, cZ as O, c, o as y, X as ee, w as n, j as q, H as te, D as P, l as i, aI as re, p as F, A as w, B as ie, i as C, iG as ae, __tla as __tla_0 } from "./index-9PRMimni.js";
import { B as oe } from "./Table-0PViRYCf.js";
import { _ as ne } from "./TableAction.vue_vue_type_script_setup_true_lang-Bj_Y4LtN.js";
import { l as se, m as le, n as de } from "./requisitionOrder-D0IG9N7e.js";
import { g as ue, a as R, f as me, P as a, b as ce, e as E, C as _, __tla as __tla_1 } from "./helper-CNwA55dE.js";
import { _ as ye, __tla as __tla_2 } from "./index.vue_vue_type_script_setup_true_lang-B_S9u-OV.js";
import { _ as pe, __tla as __tla_3 } from "./index.vue_vue_type_script_setup_true_lang-CSVKsKYX.js";
import { _ as fe, __tla as __tla_4 } from "./index.vue_vue_type_script_setup_true_lang-D8OHpETW.js";
import { _ as be, __tla as __tla_5 } from "./index.vue_vue_type_script_setup_true_lang-2_KRqSQd.js";
import { i as p } from "./includes-DdMWPj0t.js";
let ve;
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  {}
    })(),
    (()=>{
        try {
            return __tla_5;
        } catch  {}
    })()
]).then(async ()=>{
    const k = Z(), { t: e } = L();
    function he(g) {
        const b = ue(g.procurementCategory);
        if (!b) return console.warn("Invalid procurement category:", g.procurementCategory), [];
        switch(b){
            case R.SPARE_PARTS:
                return [
                    {
                        title: e("requisitionOrder.detailsTab.lineNo"),
                        key: "indexNo",
                        width: 80
                    },
                    {
                        title: e("requisitionOrder.detailsTab.equipmentName"),
                        key: "spareItem.productName",
                        width: 140
                    },
                    {
                        title: e("requisitionOrder.detailsTab.maker"),
                        key: "spareItem.maker",
                        width: 140
                    },
                    {
                        title: e("requisitionOrder.detailsTab.model"),
                        key: "spareItem.model",
                        width: 140
                    },
                    {
                        title: e("requisitionOrder.detailsTab.partNumber"),
                        key: "spareItem.partNumber",
                        width: 140
                    },
                    {
                        title: e("requisitionOrder.detailsTab.itemDescription"),
                        key: "spareItem.itemDescription",
                        width: 140
                    },
                    {
                        title: e("requisitionOrder.detailsTab.plateDrawingNumber"),
                        key: "spareItem.plateDrawingNumber",
                        width: 140,
                        render: (t)=>{
                            const { plateDrawingNumber: s, drawingUrl: d } = t?.spareItem ?? {};
                            return d ? u("a", {
                                href: d,
                                target: "_blank"
                            }, s) : s;
                        }
                    },
                    {
                        title: e("requisitionOrder.detailsTab.specification"),
                        key: "specification",
                        width: 120
                    },
                    {
                        title: e("requisitionOrder.detailsTab.uom"),
                        key: "umoName",
                        width: 80
                    },
                    {
                        title: e("requisitionOrder.detailsTab.rob"),
                        key: "rob",
                        width: 80
                    },
                    {
                        title: e("requisitionOrder.detailsTab.requiredQty"),
                        key: "reqQuantity",
                        width: 104
                    },
                    {
                        title: e("requisitionOrder.detailsTab.requiredQuality"),
                        key: "reqQuality",
                        width: 140,
                        render: (t)=>{
                            if (!t.reqQuality) return "";
                            const s = me.find((d)=>+d.value === t.reqQuality);
                            return k.getLocale === "en" ? s?.labelEn : s?.label;
                        }
                    },
                    {
                        title: e("requisitionOrder.detailsTab.approvedQty"),
                        key: "approveQuantity",
                        width: 110
                    },
                    {
                        title: e("requisitionOrder.detailsTab.mdRequired"),
                        key: "mdRequired",
                        width: 140,
                        render: (t)=>t.mdRequired === 1 ? e("common.yes") : e("common.no")
                    },
                    {
                        title: e("requisitionOrder.detailsTab.sdocRequired"),
                        key: "sdocRequired",
                        width: 140,
                        render: (t)=>t.sdocRequired === 1 ? e("common.yes") : e("common.no")
                    },
                    {
                        title: e("requisitionOrder.detailsTab.remarksToOffice"),
                        key: "remarkToOffice",
                        width: 140
                    },
                    {
                        title: e("requisitionOrder.detailsTab.remarksToVendor"),
                        key: "remarkToVendor",
                        width: 140
                    },
                    {
                        title: e("requisitionOrder.detailsTab.drawing"),
                        key: "spareItem.drawingUrl",
                        width: 140,
                        render: (t)=>{
                            if (t.spareItem?.drawingUrl) return u("a", {
                                href: t?.spareItem?.drawingUrl,
                                target: "_blank"
                            }, t?.spareItem?.drawingUrl?.split("/").pop());
                        }
                    },
                    {
                        title: e("requisitionOrder.detailsTab.attachment"),
                        key: "attachUrl",
                        width: 140,
                        render: (t)=>{
                            if (t.attachUrl) return u("a", {
                                href: t.attachUrl,
                                target: "_blank"
                            }, t.attachPath?.split("/").pop());
                        }
                    }
                ];
            case R.MATERIALS:
                return [
                    {
                        title: e("requisitionOrder.detailsTab.lineNo"),
                        key: "indexNo",
                        width: 80
                    },
                    {
                        title: e("requisitionOrder.detailsTab.itemCode"),
                        key: "item.code",
                        width: 140
                    },
                    {
                        title: e("requisitionOrder.detailsTab.itemDescription"),
                        key: "item.description",
                        width: 140
                    },
                    {
                        title: e("requisitionOrder.detailsTab.specification"),
                        key: "specification",
                        width: 120
                    },
                    {
                        title: e("requisitionOrder.detailsTab.brandManufacturer"),
                        key: "brand",
                        width: 140
                    },
                    {
                        title: e("requisitionOrder.detailsTab.uom"),
                        key: "umoName",
                        width: 80
                    },
                    {
                        title: e("requisitionOrder.detailsTab.packingUom"),
                        key: "packingUmoName",
                        width: 140
                    },
                    {
                        title: e("requisitionOrder.detailsTab.rob"),
                        key: "rob",
                        width: 80
                    },
                    {
                        title: e("requisitionOrder.detailsTab.requiredQty"),
                        key: "reqQuantity",
                        width: 104
                    },
                    {
                        title: e("requisitionOrder.detailsTab.approvedQty"),
                        key: "approveQuantity",
                        width: 110
                    },
                    {
                        title: e("requisitionOrder.detailsTab.mdRequired"),
                        key: "mdRequired",
                        width: 140,
                        render: (t)=>t.mdRequired === 1 ? e("common.yes") : e("common.no")
                    },
                    {
                        title: e("requisitionOrder.detailsTab.sdocRequired"),
                        key: "sdocRequired",
                        width: 140,
                        render: (t)=>t.sdocRequired === 1 ? e("common.yes") : e("common.no")
                    },
                    {
                        title: e("requisitionOrder.detailsTab.remarksToOffice"),
                        key: "remarkToOffice",
                        width: 140
                    },
                    {
                        title: e("requisitionOrder.detailsTab.remarksToVendor"),
                        key: "remarkToVendor",
                        width: 140
                    },
                    {
                        title: e("requisitionOrder.detailsTab.attachments"),
                        key: "attachUrl",
                        width: 140,
                        render: (t)=>{
                            if (t.attachUrl) return u("a", {
                                href: t.attachUrl,
                                target: "_blank"
                            }, t.attachPath?.split("/").pop());
                        }
                    },
                    {
                        title: e("requisitionOrder.detailsTab.issaNo"),
                        key: "item.issaNo",
                        width: 140
                    },
                    {
                        title: e("requisitionOrder.detailsTab.itemCategory"),
                        key: "item.categoryName",
                        width: 140,
                        render: (t)=>k.getLocale === "en" ? t?.item?.categoryNameEn : t?.item?.categoryName
                    },
                    {
                        title: e("requisitionOrder.detailsTab.itemSubCategory"),
                        key: "item.subCategoryName",
                        width: 140,
                        render: (t)=>k.getLocale === "en" ? t?.item?.subCategoryNameEn : t?.item?.subCategoryName
                    }
                ];
            case R.CHARTS_AND_PUBLICATIONS:
                return [
                    {
                        title: e("requisitionOrder.detailsTab.lineNo"),
                        key: "indexNo",
                        width: 80
                    },
                    {
                        title: e("requisitionOrder.detailsTab.itemCode"),
                        key: "item.code",
                        width: 140
                    },
                    {
                        title: e("requisitionOrder.detailsTab.itemDescription"),
                        key: "item.description",
                        width: 140
                    },
                    {
                        title: e("requisitionOrder.detailsTab.specification"),
                        key: "specification",
                        width: 120
                    },
                    {
                        title: e("requisitionOrder.detailsTab.brandManufacturer"),
                        key: "brand",
                        width: 140
                    },
                    {
                        title: e("requisitionOrder.detailsTab.uom"),
                        key: "umoName",
                        width: 80
                    },
                    {
                        title: e("requisitionOrder.detailsTab.packingUom"),
                        key: "packingUmoName",
                        width: 140
                    },
                    {
                        title: e("requisitionOrder.detailsTab.editionOnBoard"),
                        key: "item.edition",
                        width: 140
                    },
                    {
                        title: e("requisitionOrder.detailsTab.rob"),
                        key: "rob",
                        width: 80
                    },
                    {
                        title: e("requisitionOrder.detailsTab.requiredQty"),
                        key: "reqQuantity",
                        width: 104
                    },
                    {
                        title: e("requisitionOrder.detailsTab.requiredEdition"),
                        key: "reqEdition",
                        width: 140
                    },
                    {
                        title: e("requisitionOrder.detailsTab.approvedQty"),
                        key: "approveQuantity",
                        width: 110
                    },
                    {
                        title: e("requisitionOrder.detailsTab.remarksToOffice"),
                        key: "remarkToOffice",
                        width: 140
                    },
                    {
                        title: e("requisitionOrder.detailsTab.remarksToVendor"),
                        key: "remarkToVendor",
                        width: 140
                    },
                    {
                        title: e("requisitionOrder.detailsTab.attachments"),
                        key: "attachUrl",
                        width: 140,
                        render: (t)=>{
                            if (t.attachUrl) return u("a", {
                                href: t.attachUrl,
                                target: "_blank"
                            }, t.attachPath?.split("/").pop());
                        }
                    },
                    {
                        title: e("requisitionOrder.detailsTab.issaNo"),
                        key: "item.issaNo",
                        width: 140
                    },
                    {
                        title: e("requisitionOrder.detailsTab.itemCategory"),
                        key: "item.categoryName",
                        width: 140,
                        render: (t)=>k.getLocale === "en" ? t?.item?.categoryNameEn : t?.item?.categoryName
                    },
                    {
                        title: e("requisitionOrder.detailsTab.itemSubCategory"),
                        key: "item.subCategoryName",
                        width: 140,
                        render: (t)=>k.getLocale === "en" ? t?.item?.subCategoryNameEn : t?.item?.subCategoryName
                    }
                ];
            default:
                return console.warn(`No columns defined for procurement type: ${b}`), [];
        }
    }
    let Te;
    Te = {
        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]"
    };
    ve = j({
        __name: "index",
        props: {
            vesselValue: {},
            procurementCategory: {},
            reqFormOtherInfo: {}
        },
        emits: [
            "changeKeyWordsDisabled",
            "tableListDataLengthChange"
        ],
        setup (g, { expose: b, emit: t }) {
            const s = g, d = t, Q = Y(), m = U(()=>Q.query.type ?? a.CREATE), { t: o } = L(), B = U(()=>he(s)), M = J({
                width: 150,
                title: o("common.optionsText"),
                key: "action",
                fixed: "right",
                align: "center",
                render (r) {
                    return u(ne, {
                        style: "text",
                        actions: [
                            {
                                label: o("common.optionsEditText"),
                                labelShow: !1,
                                disabled: !1,
                                icon: u("i", {
                                    class: "iconfont icon-a-Frame28"
                                }),
                                onClick: z.bind(null, r)
                            },
                            {
                                label: o("common.delText"),
                                labelShow: !1,
                                disabled: !1,
                                icon: u("i", {
                                    class: "iconfont icon-Delete red"
                                }),
                                onPositiveClick: G.bind(null, r.id),
                                isConfirm: !0,
                                confirmContent: o("common.delPop.contRole"),
                                ifShow: !(E === _.OFFICE && p([
                                    a.APPROVE
                                ], m.value))
                            }
                        ]
                    });
                }
            }), D = T("addDetailRef"), v = T("editDetailRef"), N = T("approveDetailRef"), I = T("copyDetailRef"), V = T("itemDetailsTableRef"), $ = async (r)=>{
                const l = await le({
                    ...r,
                    reqId: s.reqFormOtherInfo.id
                });
                return d("tableListDataLengthChange", l?.list?.length ?? 0), l;
            };
            function f() {
                V.value?.restReload();
            }
            function W() {
                D.value?.handleOpenModal();
            }
            function x() {
                I.value?.handleOpenModal();
            }
            function K(r) {
                de({
                    newId: s.reqFormOtherInfo.id,
                    oldId: r.id
                }).then(()=>{
                    O().success(o("common.optionsCopySuccessText")), d("changeKeyWordsDisabled", !0), f();
                }).catch((l)=>{
                    O().error(o("common.optionsCopyErrorText", {
                        error: l.message
                    }));
                });
            }
            function z(r) {
                p([
                    a.CREATE,
                    a.EDIT
                ], m.value) && v.value?.handleOpenModal(r), E === _.OFFICE && p([
                    a.APPROVE
                ], m.value) && N.value?.handleOpenModal(r);
            }
            function G(r) {
                se(r).then(()=>{
                    O().success(o("common.optionsDelSuccessText")), f();
                });
            }
            return b({
                reloadTable: f
            }), (r, l)=>{
                const S = ie, A = re, H = te, X = ee;
                return y(), c(X, {
                    class: "w-full"
                }, {
                    default: n(()=>[
                            q(i(oe), {
                                columns: B.value,
                                request: (h)=>$(h),
                                "row-key": (h)=>h.id,
                                ref_key: "itemDetailsTableRef",
                                ref: V,
                                actionColumn: i(p)([
                                    i(a).CREATE,
                                    i(a).CREATED,
                                    i(a).APPROVE,
                                    i(a).EDIT
                                ], m.value) && !(i(E) === i(_).VESSEL && i(p)([
                                    i(a).APPROVE
                                ], m.value)) ? i(M) : void 0,
                                autoScrollX: !0,
                                "virtual-scroll": "",
                                showTableSetting: !0,
                                canResize: !1
                            }, {
                                tableTitle: n(()=>[
                                        C("h2", Te, [
                                            C("div", null, w(i(o)("requisitionOrder.detailsTab.itemDetails")), 1)
                                        ])
                                    ]),
                                toolbar: n(()=>[
                                        q(H, null, {
                                            default: n(()=>[
                                                    i(p)([
                                                        i(a).CREATE,
                                                        i(a).CREATED,
                                                        i(a).EDIT
                                                    ], m.value) ? (y(), c(A, {
                                                        key: 0,
                                                        trigger: "hover"
                                                    }, {
                                                        trigger: n(()=>[
                                                                q(S, {
                                                                    type: "primary",
                                                                    strong: "",
                                                                    bordered: "",
                                                                    secondary: "",
                                                                    class: "size-7",
                                                                    onClick: W
                                                                }, {
                                                                    icon: n(()=>l[1] || (l[1] = [
                                                                            C("i", {
                                                                                class: "iconfont icon-ADD"
                                                                            }, null, -1)
                                                                        ])),
                                                                    _: 1
                                                                })
                                                            ]),
                                                        default: n(()=>[
                                                                F(" " + w(i(o)("requisitionOrder.detailsTab.add")), 1)
                                                            ]),
                                                        _: 1
                                                    })) : P("", !0),
                                                    r.procurementCategory === i(ce).GENERAL_STORES && i(p)([
                                                        i(a).CREATE,
                                                        i(a).CREATED
                                                    ], m.value) ? (y(), c(A, {
                                                        key: 1,
                                                        trigger: "hover"
                                                    }, {
                                                        trigger: n(()=>[
                                                                q(S, {
                                                                    type: "primary",
                                                                    strong: "",
                                                                    bordered: "",
                                                                    secondary: "",
                                                                    class: "size-7",
                                                                    onClick: x
                                                                }, {
                                                                    icon: n(()=>[
                                                                            q(i(ae), {
                                                                                class: "font-bold text-[#0ec06a]"
                                                                            })
                                                                        ]),
                                                                    _: 1
                                                                })
                                                            ]),
                                                        default: n(()=>[
                                                                F(" " + w(i(o)("requisitionOrder.btnCopy")), 1)
                                                            ]),
                                                        _: 1
                                                    })) : P("", !0)
                                                ]),
                                            _: 1
                                        })
                                    ]),
                                _: 1
                            }, 8, [
                                "columns",
                                "request",
                                "row-key",
                                "actionColumn"
                            ]),
                            (y(), c(ye, {
                                ref_key: "addDetailRef",
                                ref: D,
                                vesselValue: r.vesselValue,
                                reqFormOtherInfo: r.reqFormOtherInfo,
                                procurementCategory: r.procurementCategory,
                                key: r.procurementCategory,
                                onRefresh: f,
                                onChangeKeyWordsDisabled: l[0] || (l[0] = (h)=>d("changeKeyWordsDisabled", h))
                            }, null, 8, [
                                "vesselValue",
                                "reqFormOtherInfo",
                                "procurementCategory"
                            ])),
                            (y(), c(pe, {
                                ref_key: "editDetailRef",
                                ref: v,
                                vesselValue: r.vesselValue,
                                reqFormOtherInfo: r.reqFormOtherInfo,
                                procurementCategory: r.procurementCategory,
                                key: r.procurementCategory,
                                onRefresh: f
                            }, null, 8, [
                                "vesselValue",
                                "reqFormOtherInfo",
                                "procurementCategory"
                            ])),
                            (y(), c(fe, {
                                ref_key: "approveDetailRef",
                                ref: N,
                                vesselValue: r.vesselValue,
                                reqFormOtherInfo: r.reqFormOtherInfo,
                                procurementCategory: r.procurementCategory,
                                key: r.procurementCategory,
                                onRefresh: f
                            }, null, 8, [
                                "vesselValue",
                                "reqFormOtherInfo",
                                "procurementCategory"
                            ])),
                            (y(), c(be, {
                                ref_key: "copyDetailRef",
                                ref: I,
                                vesselValue: r.vesselValue,
                                reqFormOtherInfo: r.reqFormOtherInfo,
                                procurementCategory: r.procurementCategory,
                                key: r.procurementCategory,
                                onSelected: K
                            }, null, 8, [
                                "vesselValue",
                                "reqFormOtherInfo",
                                "procurementCategory"
                            ]))
                        ]),
                    _: 1
                });
            };
        }
    });
});
export { ve as _, __tla };
