import { _ as K } from "./basicModal.vue_vue_type_script_setup_true_lang-CsJydKhW.js";
import "./basicModal.vue_vue_type_style_index_0_lang-8QZP7ApW.js";
import { B as Z } from "./Table-0PViRYCf.js";
import { _ as $ } from "./TableAction.vue_vue_type_script_setup_true_lang-Bj_Y4LtN.js";
import { u as j, b as F } from "./sparePartsStock-8NzBm-vI.js";
import { d as U, __tla as __tla_0 } from "./modalSchemas-qMFWMNWN.js";
import { g as d } from "./storageLocation-CpgPSQOH.js";
import { d as W, V as X, r as l, a as z, Z as c, hp as G, cZ as H, c as J, o as Q, l as u, w as v, j as g, W as Y, __tla as __tla_1 } from "./index-9PRMimni.js";
import { u as ee } from "./useModal-CO65vga3.js";
let re;
let __tla = Promise.all([
    (()=>{
        try {
            return __tla_0;
        } catch  {}
    })(),
    (()=>{
        try {
            return __tla_1;
        } catch  {}
    })()
]).then(async ()=>{
    re = W({
        __name: "StockDetailsModal",
        emits: [
            "success"
        ],
        setup (oe, { expose: _, emit: ae }) {
            const { t: s } = X(), w = H(), [x, { openModal: y, closeModal: N }] = ee({
                title: s("sparePartsStock.stockDetails"),
                subBtuText: s("common.saveText"),
                width: 1600
            }), p = l(), b = l(""), i = l({
                shipId: null,
                itemId: null
            }), h = l(), m = l(), f = l(), r = l(), k = z({
                width: 90,
                title: s("common.optionsText"),
                key: "action",
                fixed: "right",
                align: "center",
                render (e) {
                    return c($, {
                        style: "text",
                        actions: S(e)
                    });
                }
            });
            function S(e) {
                return console.log(e), e.editable ? [
                    {
                        label: s("common.saveText"),
                        labelShow: !1,
                        icon: c("i", {
                            class: "iconfont icon-Save"
                        }),
                        onClick: C.bind(null, e)
                    },
                    {
                        label: s("common.cancelText"),
                        labelShow: !1,
                        icon: c(G),
                        onClick: R.bind(null, e)
                    }
                ] : [
                    {
                        label: s("common.optionsEditText"),
                        labelShow: !1,
                        icon: c("i", {
                            class: "iconfont icon-a-Frame28"
                        }),
                        onClick: T.bind(null, e)
                    }
                ];
            }
            function T(e) {
                console.log(e), b.value = e.id, e.onEdit(!0);
            }
            function R(e) {
                b.value = "", e.onEdit(!1, !1);
            }
            async function C(e) {
                if (await e.onEdit(!1, !0)) {
                    const a = {
                        id: e.id,
                        roomNo: e.roomNo,
                        shelfNo: e.shelfNo,
                        boxNo: e.boxNo
                    };
                    console.log(a), await j(a), w.success(s("common.optionsSuccessText")), q();
                }
            }
            function E({ record: e, index: o, key: a, value: t }) {
                console.log("record", e), console.log("index", o), console.log("key", a), console.log("value", t);
            }
            function L(e) {
                console.log(e);
            }
            function B({ column: e, value: o, record: a }) {
                if (e.key === "roomName") {
                    const t = m.value?.find((n)=>n.value === o);
                    a.editValueRefs.roomName.value = t?.label, a.roomName = t?.label, a.roomNo = t?.value;
                }
                if (e.key === "shelfName") {
                    const t = f.value?.find((n)=>n.value === o);
                    a.editValueRefs.shelfName.value = t?.label, a.shelfName = t?.label, a.shelfNo = t?.value;
                }
                if (e.key === "boxName") {
                    const t = r.value?.find((n)=>n.value === o);
                    a.editValueRefs.boxName.value = t?.label, a.boxName = t?.label, a.boxNo = t?.value;
                }
                console.log(e, o, a);
            }
            async function I(e) {
                console.log(e), y(), e && (i.value.shipId = e.shipId, i.value.itemId = e.itemId);
            }
            async function M() {
                N();
            }
            async function D() {
                const e = await d({
                    ...i.value,
                    warehouseType: "0"
                });
                m.value = e.list.map((o)=>({
                        label: o.warehouseName,
                        value: o.id,
                        item: o
                    }));
            }
            async function V() {
                const e = await d({
                    ...i.value,
                    warehouseType: "1"
                });
                f.value = e.list.map((o)=>({
                        label: o.warehouseName,
                        value: o.id,
                        item: o
                    }));
            }
            async function O() {
                const e = await d({
                    ...i.value,
                    warehouseType: "2"
                });
                r.value = e.list.map((o)=>({
                        label: o.warehouseName,
                        value: o.id,
                        item: o
                    }));
            }
            async function P(e) {
                return h.value = await F({
                    ...e,
                    ...i.value
                }), await D(), await V(), await O(), h.value;
            }
            function q() {
                p.value?.restReload();
            }
            const { columns: A } = U({
                storageLocationRoom: m,
                storageLocationShelf: f,
                storageLocationBox: r
            });
            return _({
                handleOpenModal: I
            }), (e, o)=>{
                const a = Y, t = K;
                return Q(), J(t, {
                    ref: "modalRef",
                    onRegister: u(x),
                    onOnOk: M,
                    showAction: !1
                }, {
                    default: v(()=>[
                            g(a, {
                                bordered: !1,
                                class: "proCard mt-2",
                                "content-class": "p-0"
                            }, {
                                default: v(()=>[
                                        g(u(Z), {
                                            ref_key: "basicTableRef",
                                            ref: p,
                                            columns: u(A),
                                            request: (n)=>P(n),
                                            "row-key": (n)=>n.id,
                                            autoScrollX: !0,
                                            actionColumn: u(k),
                                            showTableSetting: !1,
                                            "virtual-scroll": "",
                                            onEditEnd: E,
                                            onEditChange: B,
                                            "onUpdate:checkedRowKeys": L
                                        }, null, 8, [
                                            "columns",
                                            "request",
                                            "row-key",
                                            "actionColumn"
                                        ])
                                    ]),
                                _: 1
                            })
                        ]),
                    _: 1
                }, 8, [
                    "onRegister"
                ]);
            };
        }
    });
});
export { re as _, __tla };
