import { _ } 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 T } from "./BasicForm-dL_oCSPM.js";
import { g as $ } from "./schemas-Cam1kIsU.js";
import { V as L, l as r, cO as O, cq as k, fm as E, d as R, r as b, c as D, o as F, w as V, j as A, ac as B, cZ as U, __tla as __tla_0 } from "./index-9PRMimni.js";
import { e as z } from "./material-Fe1jAspV.js";
import { O as Q, P as G } from "./vesselEquipmentDetails-CJeqdW1Z.js";
import { u as j } from "./useModal-CO65vga3.js";
import { u as K } from "./useForm-CKmgcynv.js";
let ie, H;
let __tla = Promise.all([
    (()=>{
        try {
            return __tla_0;
        } catch  {}
    })()
]).then(async ()=>{
    const { t: e } = L(), { yesOrNoOptions: m } = $(), Z = await z({
        category: 1
    });
    H = function(a = {}) {
        const u = [
            {
                field: "productCode",
                component: "NInput",
                label: e("equipmentLibrary.equipmentMainLibrary.equipmentCode"),
                componentProps: ()=>({
                        disabled: !0
                    }),
                giProps: {
                    span: "3 m:3 l:3 xl:2 2xl:2"
                }
            },
            {
                field: "productName",
                component: "NInput",
                label: e("equipmentLibrary.equipmentMainLibrary.equipmentName"),
                componentProps: ()=>({
                        disabled: !0
                    }),
                giProps: {
                    span: "3 m:3 l:3 xl:2 2xl:2"
                }
            },
            {
                field: "showSub",
                component: "NSwitch",
                label: e("equipmentLibrary.equipmentMainLibrary.spareParts.showSubEquipment"),
                giProps: {
                    span: "5 m:5 l:5 xl:4 2xl:3"
                }
            },
            {
                field: "critical",
                component: "NSwitch",
                label: e("equipmentLibrary.equipmentMainLibrary.spareParts.showCriticalOnly"),
                giProps: {
                    span: "3 m:3 l:3 xl:2 2xl:2"
                }
            },
            {
                field: "Active",
                component: "NSwitch",
                label: e("equipmentLibrary.equipmentMainLibrary.spareParts.active")
            }
        ], d = [
            {
                field: "productCode",
                component: "NInput",
                label: e("equipmentLibrary.equipmentMainLibrary.equipmentCode"),
                componentProps: ()=>({
                        disabled: !0
                    })
            },
            {
                field: "productName",
                component: "NInput",
                label: e("equipmentLibrary.equipmentMainLibrary.equipmentName"),
                componentProps: ()=>({
                        disabled: !0
                    })
            },
            {
                field: "model",
                component: "NInput",
                label: e("equipmentLibrary.equipmentMainLibrary.spareParts.modelEquipment"),
                componentProps: ()=>({
                        disabled: !0
                    })
            },
            {
                field: "partNumber",
                component: "NInput",
                label: e("equipmentLibrary.equipmentMainLibrary.spareParts.partNumber"),
                componentProps: ()=>({
                        disabled: r(a.readonly) || r(a.formType) !== "add"
                    }),
                rules: [
                    {
                        required: !0,
                        message: `${e("equipmentLibrary.equipmentMainLibrary.spareParts.partNumber")} ${e("common.required")}`,
                        trigger: [
                            "blur"
                        ]
                    }
                ]
            },
            {
                field: "plateDrawingNumber",
                component: "NInput",
                label: e("equipmentLibrary.equipmentMainLibrary.spareParts.drawingPlateNumber"),
                componentProps: ()=>({
                        disabled: r(a.readonly)
                    }),
                rules: [
                    {
                        required: !0,
                        message: `${e("equipmentLibrary.equipmentMainLibrary.spareParts.drawingPlateNumber")} ${e("common.required")}`,
                        trigger: [
                            "blur"
                        ]
                    }
                ]
            },
            {
                field: "partName",
                component: "NInput",
                label: e("equipmentLibrary.equipmentMainLibrary.spareParts.partName"),
                componentProps: ()=>({
                        disabled: r(a.readonly)
                    })
            },
            {
                field: "maker",
                component: "NInput",
                label: e("equipmentLibrary.equipmentMainLibrary.spareParts.maker"),
                componentProps: ()=>({
                        disabled: r(a.readonly)
                    })
            },
            {
                field: "partModel",
                component: "NInput",
                label: e("equipmentLibrary.equipmentMainLibrary.spareParts.modelSpareParts"),
                componentProps: ()=>({
                        disabled: r(a.readonly)
                    })
            },
            {
                field: "itemCode",
                component: "NInput",
                label: e("equipmentLibrary.equipmentMainLibrary.spareParts.itemCode"),
                componentProps: ()=>({
                        placeholder: e("common.autoPlaceholderText"),
                        disabled: !0
                    })
            },
            {
                field: "uom",
                component: "NSelect",
                label: e("equipmentLibrary.equipmentMainLibrary.spareParts.UOM"),
                componentProps: ()=>({
                        disabled: r(a.readonly),
                        options: Z,
                        valueField: "id",
                        labelField: "name"
                    }),
                rules: [
                    {
                        type: "number",
                        required: !0,
                        message: `${e("equipmentLibrary.equipmentMainLibrary.spareParts.UOM")} ${e("common.required")}`,
                        trigger: [
                            "change"
                        ]
                    }
                ]
            },
            {
                field: "critical",
                component: "NSelect",
                label: e("equipmentLibrary.equipmentMainLibrary.spareParts.critical"),
                componentProps: ()=>({
                        disabled: r(a.readonly),
                        options: m
                    }),
                rules: [
                    {
                        required: !0,
                        type: "boolean",
                        message: `${e("equipmentLibrary.equipmentMainLibrary.spareParts.critical")} ${e("common.required")}`,
                        trigger: [
                            "change"
                        ]
                    }
                ]
            },
            {
                field: "active",
                component: "NSelect",
                label: e("equipmentLibrary.equipmentMainLibrary.spareParts.active"),
                componentProps: ()=>({
                        disabled: r(a.readonly),
                        options: m
                    }),
                rules: [
                    {
                        required: !0,
                        type: "boolean",
                        message: `${e("equipmentLibrary.equipmentMainLibrary.spareParts.active")} ${e("common.required")}`,
                        trigger: [
                            "change"
                        ]
                    }
                ]
            },
            {
                field: "workingQuantity",
                component: "NInputNumber",
                label: e("equipmentLibrary.equipmentMainLibrary.spareParts.workingQty"),
                componentProps: ()=>({
                        disabled: r(a.readonly),
                        precision: 0
                    })
            },
            {
                field: "classEssentialQuantity",
                component: "NInputNumber",
                label: e("equipmentLibrary.equipmentMainLibrary.spareParts.classEssentialQty"),
                componentProps: ()=>({
                        disabled: r(a.readonly),
                        precision: 0
                    })
            },
            {
                field: "unit",
                component: "NInput",
                label: e("equipmentLibrary.equipmentMainLibrary.spareParts.unit"),
                componentProps: ()=>({
                        disabled: r(a.readonly)
                    })
            },
            {
                field: "minStock",
                component: "NInputNumber",
                label: e("equipmentLibrary.equipmentMainLibrary.spareParts.minStock"),
                componentProps: ()=>({
                        disabled: r(a.readonly),
                        precision: 0
                    })
            },
            {
                field: "maxStock",
                component: "NInputNumber",
                label: e("equipmentLibrary.equipmentMainLibrary.spareParts.maxStock"),
                componentProps: ()=>({
                        disabled: r(a.readonly),
                        precision: 0
                    })
            },
            {
                field: "material",
                component: "NInput",
                label: e("equipmentLibrary.equipmentMainLibrary.spareParts.material"),
                componentProps: ()=>({
                        disabled: r(a.readonly)
                    })
            },
            {
                field: "dimensions",
                component: "NInput",
                label: e("equipmentLibrary.equipmentMainLibrary.spareParts.dimensions"),
                componentProps: ()=>({
                        disabled: r(a.readonly)
                    })
            },
            {
                field: "hazardousMaterial",
                component: "NSelect",
                label: e("equipmentLibrary.equipmentMainLibrary.spareParts.hazardousMaterial"),
                componentProps: ()=>({
                        disabled: r(a.readonly),
                        options: m
                    })
            },
            {
                field: "itemDescription",
                component: "NInput",
                label: e("equipmentLibrary.equipmentMainLibrary.spareParts.itemDescription"),
                componentProps: ()=>({
                        type: "textarea",
                        disabled: r(a.readonly)
                    }),
                rules: [
                    {
                        required: !0,
                        message: `${e("equipmentLibrary.equipmentMainLibrary.spareParts.itemDescription")} ${e("common.required")}`,
                        trigger: [
                            "blur"
                        ]
                    }
                ],
                giProps: {
                    span: 2
                }
            },
            {
                field: "itemSpecification",
                component: "NInput",
                label: e("equipmentLibrary.equipmentMainLibrary.spareParts.itemSpecification"),
                componentProps: ()=>({
                        type: "textarea",
                        disabled: r(a.readonly)
                    }),
                giProps: {
                    span: 2
                }
            },
            {
                field: "oemItem",
                component: "NSelect",
                label: e("equipmentLibrary.equipmentMainLibrary.spareParts.OEMItem"),
                componentProps: ()=>({
                        disabled: r(a.readonly),
                        options: m
                    })
            },
            {
                field: "eccnEcn",
                component: "NSelect",
                label: e("equipmentLibrary.equipmentMainLibrary.spareParts.CCNECN"),
                componentProps: ()=>({
                        disabled: r(a.readonly),
                        options: m
                    })
            },
            {
                field: "drawingUrl",
                label: e("equipmentLibrary.equipmentMainLibrary.spareParts.drawing"),
                component: "SingleImageUpload",
                componentProps: ({ model: t })=>({
                        disabled: r(a.readonly),
                        action: `${k().urlPrefix}/files`,
                        headers: {
                            timestamp: new Date().getTime(),
                            authorization: `${O.get(E)}`
                        },
                        onUploadChange: (y, p)=>{
                            t.drawing = p;
                        }
                    }),
                giProps: {
                    span: 1
                }
            },
            {
                field: "drawing",
                hidden: !0
            }
        ];
        return {
            searchSchemas: u,
            formSchemas: d
        };
    };
    ie = R({
        __name: "FormModal",
        props: {
            selectedTreeItem: {}
        },
        emits: [
            "success"
        ],
        setup (a, { expose: u, emit: d }) {
            const t = a, y = d, { t: p } = L(), q = U(), o = b(), s = b(""), P = b(!1), [g, { openModal: N, closeModal: M, setSubLoading: c, setProps: h }] = j({
                title: "",
                width: 1200
            }), { formSchemas: I } = H({
                readonly: P,
                formType: s
            }), [S, { submit: w, setFieldsValue: f }] = K({
                gridProps: {
                    cols: 4
                },
                layout: "horizontal",
                schemas: I,
                showActionButtonGroup: !1
            });
            async function x(i, n, l) {
                s.value = l, o.value = n, h({
                    title: i
                }), N(), await B(), f(l === "add" ? {
                    productCode: t.selectedTreeItem?.code,
                    productName: t.selectedTreeItem?.name,
                    model: t.selectedTreeItem?.model,
                    shipId: t.selectedTreeItem?.shipId,
                    active: !0
                } : o.value || {}), P.value = s.value === "view";
            }
            async function C() {
                const i = await w();
                if (!i) {
                    c(!1);
                    return;
                }
                try {
                    if (s.value === "add") {
                        const n = {
                            ...i,
                            productCode: t.selectedTreeItem?.code,
                            model: t.selectedTreeItem?.model,
                            shipId: t.selectedTreeItem?.shipId
                        };
                        await Q(n), q.success(p("common.optionsAddSuccessText"));
                    } else {
                        const n = {
                            ...i,
                            productCode: o.value?.productCode,
                            model: o.value?.model,
                            shipId: o.value?.shipId
                        };
                        await G(n), q.success(p("common.optionsEditSuccessText"));
                    }
                    M(), c(!1), y("success");
                } catch  {
                    c(!1);
                }
            }
            return u({
                handleOpenModal: x
            }), (i, n)=>{
                const l = T, v = _;
                return F(), D(v, {
                    ref: "modalRef",
                    showAction: r(s) !== "view",
                    onRegister: r(g),
                    onOnOk: C
                }, {
                    default: V(()=>[
                            A(l, {
                                ref: "formRef",
                                onRegister: r(S)
                            }, null, 8, [
                                "onRegister"
                            ])
                        ]),
                    _: 1
                }, 8, [
                    "showAction",
                    "onRegister"
                ]);
            };
        }
    });
});
export { ie as _, H as c, __tla };
