import { _ as j } 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 q } from "./BasicForm-dL_oCSPM.js";
import { g as m } from "./storageLocation-CpgPSQOH.js";
import { o as G } from "./sparePartsStock-8NzBm-vI.js";
import { b as W, __tla as __tla_0 } from "./modalSchemas-qMFWMNWN.js";
import { d as Z, V as $, r as a, c as z, o as H, l as w, w as v, j as S, W as J, ac as K, cZ as Q, __tla as __tla_1 } from "./index-9PRMimni.js";
import { u as U } from "./useModal-CO65vga3.js";
import { u as X } from "./useForm-CKmgcynv.js";
import { h as p } from "./has-CjqcrIOV.js";
let lo;
let __tla = Promise.all([
    (()=>{
        try {
            return __tla_0;
        } catch  {}
    })(),
    (()=>{
        try {
            return __tla_1;
        } catch  {}
    })()
]).then(async ()=>{
    lo = Z({
        __name: "OutboundModal",
        emits: [
            "success"
        ],
        setup (Y, { expose: T, emit: B }) {
            const N = B, { t: n } = $(), f = Q(), [b, { openModal: x, closeModal: I, setSubLoading: d }] = U({
                title: n("sparePartsStock.outbound"),
                subBtuText: n("common.saveText"),
                width: 1200
            }), y = a(), g = a(), h = a(), t = a(), _ = a();
            async function k(e) {
                x(), K(async ()=>{
                    t.value = e.shipId, _.value = e.itemId, e.itemType = "0", A();
                    try {
                        await D();
                    } catch (o) {
                        console.log(o);
                    }
                    r(e);
                });
            }
            async function L() {
                try {
                    await C();
                    const e = [
                        {
                            field: "normalStock",
                            value: "0"
                        },
                        {
                            field: "reconditionedStock",
                            value: "1"
                        }
                    ], o = i();
                    if (e.find((s)=>o.itemType === s.value) && o.currencyInventory < o.quantity) {
                        d(!1), f.warning(n("sparePartsStock.stockNotEnoughText"));
                        return;
                    }
                    await G({
                        ...o
                    }), f.success(n("common.optionsSuccessText")), N("success"), I();
                } catch  {
                    d(!1);
                }
            }
            async function R() {
                const e = await m({
                    shipId: t.value,
                    warehouseType: "0"
                });
                y.value = e.list.map((o)=>({
                        label: o.warehouseName,
                        value: o.id,
                        item: o
                    }));
            }
            async function F() {
                const e = await m({
                    shipId: t.value,
                    warehouseType: "1"
                });
                g.value = e.list.map((o)=>({
                        label: o.warehouseName,
                        value: o.id,
                        item: o
                    }));
            }
            async function M() {
                const e = await m({
                    shipId: t.value,
                    warehouseType: "2"
                });
                h.value = e.list.map((o)=>({
                        label: o.warehouseName,
                        value: o.id,
                        item: o
                    }));
            }
            function O(e) {
                const o = i();
                o.itemType ? o.itemType === "0" ? r({
                    currencyInventory: e.normalStock
                }) : o.itemType === "1" && r({
                    currencyInventory: e.reconditionedStock
                }) : r({
                    currencyInventory: 0
                });
            }
            async function D() {
                await R(), await F(), await M();
            }
            function E() {
                const e = i();
                if (p(e, "roomNo") || p(e, "shelfNo") || p(e, "boxNo")) {
                    const o = (l)=>l == null || l === "", c = o(e.roomNo), s = o(e.shelfNo), u = o(e.boxNo);
                    if (c && s && u) return !1;
                } else return console.log("formData", e), !1;
                return !0;
            }
            const { schemas: P } = W({
                storageLocationRoom: y,
                storageLocationShelf: g,
                storageLocationBox: h,
                validateStorageLocation: E,
                currentParams: {
                    shipId: t,
                    itemId: _
                },
                updateStorageNumber: O
            }), [V, { setFieldsValue: r, validate: C, getFieldsValue: i, resetFields: A }] = X({
                gridProps: {
                    cols: 4
                },
                schemas: P,
                showAdvancedButton: !1
            });
            return T({
                handleOpenModal: k
            }), (e, o)=>{
                const c = q, s = J, u = j;
                return H(), z(u, {
                    ref: "modalRef",
                    onRegister: w(b),
                    onOnOk: L
                }, {
                    default: v(()=>[
                            S(s, {
                                class: "proCard"
                            }, {
                                default: v(()=>[
                                        S(c, {
                                            onRegister: w(V),
                                            showActionButtonGroup: !1,
                                            showSubmitButton: !1,
                                            showResetButton: !1
                                        }, null, 8, [
                                            "onRegister"
                                        ])
                                    ]),
                                _: 1
                            })
                        ]),
                    _: 1
                }, 8, [
                    "onRegister"
                ]);
            };
        }
    });
});
export { lo as _, __tla };
