import { r as P, V as y, l as d, aD as g, gL as S, bk as q, __tla as __tla_0 } from "./index-9PRMimni.js";
import { a as f } from "./sparePartsStock-8NzBm-vI.js";
import { a as w, D as I } from "./vesselEquipmentDetails-CJeqdW1Z.js";
import { i as k } from "./isEmpty-BUg1OsQj.js";
import { h as m } from "./has-CjqcrIOV.js";
let B, U, F, z;
let __tla = Promise.all([
    (()=>{
        try {
            return __tla_0;
        } catch  {}
    })()
]).then(async ()=>{
    let N, e, L, h, v, R, C;
    N = q();
    ({ t: e } = y());
    L = await S("storage_type");
    h = await S("types_spare_parts");
    v = await S("outInventory_Type");
    R = L.filter((t)=>![
            "4",
            "7",
            "8"
        ].includes(t.value));
    C = v.filter((t)=>![
            "4",
            "7",
            "8",
            "9",
            "10"
        ].includes(t.value));
    F = (t)=>{
        const p = P(!1), i = P(!1), r = P(!1), l = g(async (n)=>{
            try {
                p.value = !0;
                const s = await w({
                    shipId: d(t.shipId),
                    productName: n
                });
                t.equipmentList.value = s.map((o)=>({
                        ...o,
                        key: o.productCode + (o.model || "") + (o.serialNumber || "")
                    })), t.sparePartsList.value = [], p.value = !1;
            } catch  {
                p.value = !1;
            }
        }, 1e3), u = g(async (n, s)=>{
            try {
                s.value = !0;
                const o = await I({
                    shipId: d(t.shipId),
                    page: 1,
                    pageSize: -1,
                    showSub: !0,
                    ...n
                });
                t.sparePartsList.value = o.list.map((a)=>({
                        value: a,
                        label: `${a.partNumber}---${a.itemDescription}`
                    })), s.value = !1;
            } catch  {
                s.value = !1;
            }
        }, 1e3);
        return {
            schemas: [
                {
                    field: "itemId",
                    hidden: !0
                },
                {
                    field: "shipId",
                    hidden: !0
                },
                {
                    field: "equipmentCode",
                    label: e("sparePartsStock.equipmentCode"),
                    component: "NInput",
                    componentProps: {
                        disabled: !0
                    }
                },
                {
                    field: "equipmentName",
                    label: e("sparePartsStock.equipmentName"),
                    component: "NSelect",
                    componentProps: ({ formAction: n })=>{
                        const { setFieldsValue: s, resetFields: o } = n;
                        return {
                            filterable: !0,
                            remote: !0,
                            options: d(t.equipmentList),
                            loading: d(p),
                            clearable: !1,
                            labelField: "productName",
                            valueField: "key",
                            onSearch: async (a)=>{
                                if (!a.length) {
                                    p.value = !1;
                                    return;
                                }
                                l(a);
                            },
                            onUpdateValue: (a, b)=>{
                                console.log(a, b), t.sparePartsList.value = [], t.equipmentInfo.value = b, o(), s({
                                    equipmentCode: b.productCode
                                });
                            }
                        };
                    },
                    rules: [
                        {
                            required: !0,
                            message: e("sparePartsStock.equipmentName") + e("sparePartsStock.required"),
                            trigger: "blur"
                        }
                    ]
                },
                {
                    field: "partNumber",
                    label: e("sparePartsStock.partNumber"),
                    component: "NSelect",
                    componentProps: ({ formAction: n })=>{
                        const { setFieldsValue: s } = n;
                        return {
                            disabled: k(t.equipmentInfo.value),
                            filterable: !0,
                            remote: !0,
                            loading: d(i),
                            options: d(t.sparePartsList),
                            clearable: !1,
                            onSearch: async (o)=>{
                                if (!o.length) {
                                    p.value = !1;
                                    return;
                                }
                                const a = {
                                    model: t.equipmentInfo.value.model,
                                    serialNumber: t.equipmentInfo.value.serialNumber,
                                    belongToModel: t.equipmentInfo.value.belongToModel,
                                    productCode: t.equipmentInfo.value.productCode,
                                    productName: t.equipmentInfo.value.productName,
                                    partNumber: o
                                };
                                u(a, i);
                            },
                            onUpdateValue: async (o)=>{
                                t.purchaseRequisitionList.value = await t.getRequisitionList(o.itemId), s({
                                    partNumber: o.partNumber,
                                    itemDescription: o.itemDescription,
                                    itemId: o.itemId,
                                    equipmentCode: o.productCode,
                                    equipmentName: o.productName
                                });
                            }
                        };
                    },
                    rules: [
                        {
                            required: !0,
                            message: e("sparePartsStock.partNumber") + e("sparePartsStock.required"),
                            trigger: "blur"
                        }
                    ]
                },
                {
                    field: "itemDescription",
                    label: e("sparePartsStock.itemDescription"),
                    component: "NSelect",
                    componentProps: ({ formAction: n })=>{
                        const { setFieldsValue: s } = n;
                        return {
                            disabled: k(t.equipmentInfo.value),
                            filterable: !0,
                            remote: !0,
                            loading: d(r),
                            options: d(t.sparePartsList),
                            clearable: !1,
                            onSearch: async (o)=>{
                                if (!o.length) {
                                    p.value = !1;
                                    return;
                                }
                                const a = {
                                    model: t.equipmentInfo.value.model,
                                    serialNumber: t.equipmentInfo.value.serialNumber,
                                    belongToModel: t.equipmentInfo.value.belongToModel,
                                    productCode: t.equipmentInfo.value.productCode,
                                    productName: t.equipmentInfo.value.productName,
                                    itemDescription: o
                                };
                                u(a, r);
                            },
                            onUpdateValue: async (o)=>{
                                t.purchaseRequisitionList.value = await t.getRequisitionList(o.itemId), s({
                                    partNumber: o.partNumber,
                                    itemDescription: o.itemDescription,
                                    itemId: o.itemId,
                                    equipmentCode: o.productCode,
                                    equipmentName: o.productName
                                });
                            }
                        };
                    },
                    rules: [
                        {
                            required: !0,
                            message: e("sparePartsStock.itemDescription") + e("sparePartsStock.required"),
                            trigger: "blur"
                        }
                    ]
                },
                {
                    field: "requisitionNo",
                    label: e("sparePartsStock.purchaseRequisition"),
                    component: "NSelect",
                    componentProps: {
                        filterable: !0,
                        options: t.purchaseRequisitionList,
                        onUpdateValue: (n)=>{}
                    }
                },
                {
                    field: "sourceCode",
                    label: e("sparePartsStock.sourceCode"),
                    component: "NInput",
                    componentProps: {
                        disabled: !0
                    }
                },
                {
                    field: "remarks",
                    label: e("sparePartsStock.remarks"),
                    component: "NInput",
                    giProps: {
                        span: 4
                    },
                    componentProps: {
                        type: "textarea"
                    },
                    rules: [
                        {
                            required: !0,
                            message: e("sparePartsStock.remarks") + e("sparePartsStock.required"),
                            trigger: "blur"
                        }
                    ]
                }
            ]
        };
    };
    B = (t)=>({
            columns: [
                {
                    title: e("common.messagedefine.Num"),
                    key: "num",
                    width: 60,
                    render: (i, r)=>r + 1
                },
                {
                    title: e("sparePartsStock.inboundType"),
                    key: "operationType",
                    width: 180,
                    editComponent: "NSelect",
                    editComponentProps: {
                        options: R,
                        class: "w-[170px]",
                        "label-field": N.getLocale === "en" ? "labelEn" : "label"
                    },
                    editRow: !0,
                    editRule: !0,
                    edit: !0
                },
                {
                    title: e("sparePartsStock.quantity"),
                    key: "quantity",
                    width: 90,
                    editComponent: "NInputNumber",
                    editComponentProps: {
                        placeholder: e("sparePartsStock.quantity"),
                        min: 1,
                        precision: 0,
                        keyboard: {
                            ArrowUp: !1,
                            ArrowDown: !1
                        },
                        showButton: !1
                    },
                    editRow: !0,
                    editRule: (i, r)=>i == null || i === "" ? Promise.resolve(e("sparePartsStock.quantityRequired")) : Promise.resolve(""),
                    edit: !0
                },
                {
                    title: e("sparePartsStock.stockType"),
                    key: "itemType",
                    width: 180,
                    editComponent: "NSelect",
                    editComponentProps: {
                        options: h,
                        class: "w-[170px]",
                        "label-field": N.getLocale === "en" ? "labelEn" : "label"
                    },
                    editRow: !0,
                    editRule: !0,
                    edit: !0
                },
                {
                    title: e("sparePartsStock.storageLocationRoom"),
                    key: "roomNo",
                    width: 180,
                    editComponent: "NSelect",
                    editComponentProps: {
                        options: t.storageLocationRoom,
                        class: "w-[170px]"
                    },
                    editRow: !0,
                    edit: !0
                },
                {
                    title: e("sparePartsStock.storageLocationShelf"),
                    key: "shelfNo",
                    width: 180,
                    editComponent: "NSelect",
                    editComponentProps: {
                        options: t.storageLocationShelf,
                        class: "w-[170px]"
                    },
                    editRow: !0,
                    editRule: (i, r)=>{
                        if (console.log(r), m(r.editValueRefs, "roomNo") || m(r.editValueRefs, "shelfNo") || m(r.editValueRefs, "boxNo")) {
                            const l = (s)=>s == null || s === "", u = l(r.editValueRefs.roomNo), c = l(r.editValueRefs.shelfNo), n = l(r.editValueRefs.boxNo);
                            if (u && c && n) return Promise.resolve(e("sparePartsStock.storageLocationRequired"));
                        } else return Promise.resolve(e("sparePartsStock.storageLocationRequired"));
                        return Promise.resolve("");
                    },
                    edit: !0
                },
                {
                    title: e("sparePartsStock.storageLocationBox"),
                    key: "boxNo",
                    width: 180,
                    editComponent: "NSelect",
                    editComponentProps: {
                        options: t.storageLocationBox,
                        class: "w-[170px]"
                    },
                    editRow: !0,
                    edit: !0
                }
            ]
        });
    U = (t)=>({
            schemas: [
                {
                    field: "itemId",
                    hidden: !0
                },
                {
                    field: "shipId",
                    hidden: !0
                },
                {
                    field: "equipmentName",
                    label: e("sparePartsStock.equipmentName"),
                    component: "NInput",
                    componentProps: {
                        disabled: !0
                    }
                },
                {
                    field: "partNumber",
                    label: e("sparePartsStock.partNumber"),
                    component: "NInput",
                    componentProps: {
                        disabled: !0
                    }
                },
                {
                    field: "itemDescription",
                    label: e("sparePartsStock.itemDescription"),
                    component: "NInput",
                    componentProps: {
                        disabled: !0
                    }
                },
                {
                    field: "inboundType",
                    label: e("sparePartsStock.outboundType"),
                    component: "NSelect",
                    componentProps: {
                        options: C,
                        "label-field": N.getLocale === "en" ? "labelEn" : "label"
                    },
                    rules: [
                        {
                            required: !0,
                            message: e("sparePartsStock.outboundType") + e("sparePartsStock.required"),
                            trigger: "blur"
                        }
                    ]
                },
                {
                    field: "roomNo",
                    label: e("sparePartsStock.storageLocationRoom"),
                    component: "NSelect",
                    componentProps: ({ formAction: i })=>{
                        const { getFieldsValue: r, setFieldsValue: l } = i;
                        return {
                            options: t.storageLocationRoom.value,
                            onUpdateValue: async (u)=>{
                                console.log(t);
                                const { shipId: c, itemId: n } = t.currentParams, { shelfNo: s, boxNo: o } = r(), a = await f({
                                    shipId: c.value,
                                    itemId: n.value,
                                    roomNo: u,
                                    shelfNo: s,
                                    boxNo: o
                                });
                                l({
                                    roomNo: u
                                }), t.updateStorageNumber(a);
                            }
                        };
                    },
                    rules: [
                        {
                            required: !0,
                            validator: ()=>{
                                const i = t.validateStorageLocation();
                                return console.log(i), i ? !0 : new Error("");
                            },
                            trigger: "change"
                        }
                    ]
                },
                {
                    field: "shelfNo",
                    label: e("sparePartsStock.storageLocationShelf"),
                    component: "NSelect",
                    componentProps: ({ formAction: i })=>{
                        const { getFieldsValue: r, setFieldsValue: l } = i;
                        return {
                            options: t.storageLocationShelf.value,
                            onUpdateValue: async (u)=>{
                                console.log(t);
                                const { shipId: c, itemId: n } = t.currentParams, { roomNo: s, boxNo: o } = r(), a = await f({
                                    shipId: c.value,
                                    itemId: n.value,
                                    roomNo: s,
                                    shelfNo: u,
                                    boxNo: o
                                });
                                l({
                                    shelfNo: u
                                }), t.updateStorageNumber(a);
                            }
                        };
                    },
                    rules: [
                        {
                            required: !0,
                            validator: ()=>t.validateStorageLocation() ? !0 : new Error(e("sparePartsStock.storageLocationRequired")),
                            trigger: "change"
                        }
                    ]
                },
                {
                    field: "boxNo",
                    label: e("sparePartsStock.storageLocationBox"),
                    component: "NSelect",
                    componentProps: ({ formAction: i })=>{
                        const { getFieldsValue: r, setFieldsValue: l } = i;
                        return {
                            options: t.storageLocationBox.value,
                            onUpdateValue: async (u)=>{
                                console.log(t);
                                const { shipId: c, itemId: n } = t.currentParams, { roomNo: s, shelfNo: o } = r(), a = await f({
                                    shipId: c.value,
                                    itemId: n.value,
                                    roomNo: s,
                                    shelfNo: o,
                                    boxNo: u
                                });
                                l({
                                    boxNo: u
                                }), t.updateStorageNumber(a);
                            }
                        };
                    },
                    rules: [
                        {
                            required: !0,
                            validator: ()=>t.validateStorageLocation() ? !0 : new Error(""),
                            trigger: "change"
                        }
                    ]
                },
                {
                    field: "itemType",
                    label: e("sparePartsStock.stockType"),
                    component: "NSelect",
                    componentProps: ({ formAction: i })=>{
                        const { getFieldsValue: r } = i;
                        return {
                            options: h,
                            "label-field": N.getLocale === "en" ? "labelEn" : "label",
                            defaultValue: "0",
                            onUpdateValue: async ()=>{
                                const { shipId: l, itemId: u } = t.currentParams, { roomNo: c, shelfNo: n, boxNo: s } = r(), o = await f({
                                    shipId: l.value,
                                    itemId: u.value,
                                    roomNo: c,
                                    shelfNo: n,
                                    boxNo: s
                                });
                                t.updateStorageNumber(o);
                            }
                        };
                    },
                    rules: [
                        {
                            required: !0,
                            message: e("sparePartsStock.stockType") + e("sparePartsStock.required"),
                            trigger: "blur"
                        }
                    ]
                },
                {
                    field: "currencyInventory",
                    label: e("sparePartsStock.currencyInventory"),
                    component: "NInput",
                    componentProps: {
                        disabled: !0
                    }
                },
                {
                    field: "quantity",
                    label: e("sparePartsStock.quantity"),
                    component: "NInputNumber",
                    componentProps: {
                        min: 1,
                        precision: 0,
                        keyboard: {
                            ArrowUp: !1,
                            ArrowDown: !1
                        },
                        showButton: !1
                    },
                    rules: [
                        {
                            required: !0,
                            validator: (i, r)=>(console.log(r), r == null || r === "" || r === 0 ? new Error(e("sparePartsStock.quantity") + e("sparePartsStock.required")) : !0),
                            trigger: "blur"
                        }
                    ]
                },
                {
                    field: "remarks",
                    label: e("sparePartsStock.remarks"),
                    component: "NInput",
                    giProps: {
                        span: 4
                    },
                    componentProps: {
                        type: "textarea"
                    },
                    rules: [
                        {
                            required: !0,
                            message: e("sparePartsStock.remarks") + e("sparePartsStock.required"),
                            trigger: "blur"
                        }
                    ]
                }
            ]
        });
    z = (t)=>({
            columns: [
                {
                    title: "No.",
                    key: "num",
                    width: 60,
                    render: (i, r)=>r + 1
                },
                {
                    title: e("sparePartsStock.partNumber"),
                    key: "partNumber",
                    width: 100
                },
                {
                    title: e("sparePartsStock.itemDescription"),
                    key: "itemDescription",
                    width: 110
                },
                {
                    title: e("sparePartsStock.drawingPlateNo"),
                    key: "drawingPlateNo",
                    width: 120
                },
                {
                    title: e("sparePartsStock.storageLocationRoom"),
                    key: "roomName",
                    width: 200,
                    editComponent: "NSelect",
                    editComponentProps: {
                        options: t.storageLocationRoom,
                        clearable: !0,
                        class: "w-[195px]"
                    },
                    editRow: !0,
                    edit: !0
                },
                {
                    title: e("sparePartsStock.storageLocationShelf"),
                    key: "shelfName",
                    width: 200,
                    editComponent: "NSelect",
                    editComponentProps: {
                        options: t.storageLocationShelf,
                        clearable: !0,
                        class: "w-[195px]"
                    },
                    editRow: !0,
                    editRule: (i, r)=>{
                        if (m(r, "roomNo") || m(r, "shelfNo") || m(r, "boxNo")) {
                            const l = (s)=>s == null || s === "", u = l(r.roomNo), c = l(r.shelfNo), n = l(r.boxNo);
                            if (u && c && n) return Promise.resolve(e("sparePartsStock.storageLocationRequired"));
                        } else return Promise.resolve(e("sparePartsStock.storageLocationRequired"));
                        return Promise.resolve("");
                    },
                    edit: !0
                },
                {
                    title: e("sparePartsStock.storageLocationBox"),
                    key: "boxName",
                    width: 200,
                    editComponent: "NSelect",
                    editComponentProps: {
                        options: t.storageLocationBox,
                        clearable: !0,
                        class: "w-[195px]"
                    },
                    editRow: !0,
                    edit: !0
                },
                {
                    title: e("sparePartsStock.quantity"),
                    key: "quantity",
                    width: 90
                },
                {
                    title: e("sparePartsStock.normalStock"),
                    key: "normalStock",
                    width: 100
                },
                {
                    title: e("sparePartsStock.normalFrozenStock"),
                    key: "freezeNormalStock",
                    width: 140
                },
                {
                    title: e("sparePartsStock.reconditionStock"),
                    key: "reconditionedStock",
                    width: 120
                },
                {
                    title: e("sparePartsStock.reconditionedFrozenStock"),
                    key: "freezeReconditionedStock",
                    width: 140
                }
            ]
        });
});
export { B as a, U as b, F as c, z as d, __tla };
