import { _ as T } from "./basicModal.vue_vue_type_script_setup_true_lang-CsJydKhW.js";
import "./basicModal.vue_vue_type_style_index_0_lang-8QZP7ApW.js";
import { u as M } from "./useModal-CO65vga3.js";
import { B as S } from "./BasicForm-dL_oCSPM.js";
import { u as N } from "./useForm-CKmgcynv.js";
import { g as d, a as o, f as A, __tla as __tla_0 } from "./helper-CNwA55dE.js";
import { V as p, d as E, r as _, c as I, o as w, l as n, w as x, j as k, cZ as B, ac as C, __tla as __tla_1 } from "./index-9PRMimni.js";
import { f as V } from "./requisitionOrder-D0IG9N7e.js";
let J;
let __tla = Promise.all([
    (()=>{
        try {
            return __tla_0;
        } catch  {}
    })(),
    (()=>{
        try {
            return __tla_1;
        } catch  {}
    })()
]).then(async ()=>{
    const { t: r } = p();
    function L(t) {
        const e = d(t?.procurementCategory ?? "");
        switch(e){
            case o.SPARE_PARTS:
                return [
                    {
                        field: "reqQuality",
                        component: "BasicSelect",
                        label: r("requisitionOrder.editModal.requiredQuality"),
                        componentProps: {
                            style: {
                                width: "100%"
                            },
                            placeholder: r("requisitionOrder.editModal.requiredQuality"),
                            options: A
                        },
                        rules: [
                            {
                                required: !0,
                                message: r("requisitionOrder.editModal.requiredQualityRequired"),
                                trigger: [
                                    "change",
                                    "blur"
                                ]
                            }
                        ]
                    },
                    {
                        field: "approveQuantity",
                        component: "NInputNumber",
                        label: r("requisitionOrder.editModal.approveQuantity"),
                        componentProps: {
                            min: 1,
                            precision: 0,
                            placeholder: r("requisitionOrder.editModal.approveQuantity")
                        },
                        rules: [
                            {
                                required: !0,
                                message: r("requisitionOrder.editModal.approveQuantityRequired"),
                                trigger: [
                                    "change",
                                    "blur"
                                ],
                                type: "number"
                            }
                        ]
                    },
                    {
                        field: "mdRequired",
                        component: "BasicSelect",
                        label: r("requisitionOrder.editModal.mdRequired"),
                        componentProps: {
                            style: {
                                width: "100%"
                            },
                            placeholder: r("common.autoPlaceholderText"),
                            options: [
                                {
                                    label: "是",
                                    labelEn: "YES",
                                    value: 1
                                },
                                {
                                    label: "否",
                                    labelEn: "NO",
                                    value: 0
                                }
                            ]
                        }
                    },
                    {
                        field: "sdocRequired",
                        component: "BasicSelect",
                        label: r("requisitionOrder.editModal.sdocRequired"),
                        componentProps: {
                            style: {
                                width: "100%"
                            },
                            placeholder: r("common.autoPlaceholderText"),
                            options: [
                                {
                                    label: "是",
                                    labelEn: "YES",
                                    value: 1
                                },
                                {
                                    label: "否",
                                    labelEn: "NO",
                                    value: 0
                                }
                            ]
                        }
                    },
                    {
                        field: "remarkToVendor",
                        component: "NInput",
                        label: r("requisitionOrder.editModal.remarksToVendor"),
                        giProps: {
                            span: 2
                        },
                        componentProps: {
                            placeholder: r("requisitionOrder.editModal.remarksToVendor"),
                            type: "textarea",
                            autosize: {
                                minRows: 3,
                                maxRows: 3
                            }
                        }
                    }
                ];
            case o.MATERIALS:
                return [
                    {
                        field: "approveQuantity",
                        component: "NInputNumber",
                        label: r("requisitionOrder.editModal.approveQuantity"),
                        componentProps: {
                            min: 1,
                            precision: 0,
                            placeholder: r("requisitionOrder.editModal.approveQuantity")
                        },
                        rules: [
                            {
                                required: !0,
                                message: r("requisitionOrder.editModal.approveQuantityRequired"),
                                trigger: [
                                    "change",
                                    "blur"
                                ],
                                type: "number"
                            }
                        ]
                    },
                    {
                        field: "mdRequired",
                        component: "BasicSelect",
                        label: r("requisitionOrder.editModal.mdRequired"),
                        componentProps: {
                            style: {
                                width: "100%"
                            },
                            placeholder: r("common.autoPlaceholderText"),
                            options: [
                                {
                                    label: "是",
                                    labelEn: "YES",
                                    value: 1
                                },
                                {
                                    label: "否",
                                    labelEn: "NO",
                                    value: 0
                                }
                            ]
                        }
                    },
                    {
                        field: "sdocRequired",
                        component: "BasicSelect",
                        label: r("requisitionOrder.editModal.sdocRequired"),
                        componentProps: {
                            style: {
                                width: "100%"
                            },
                            placeholder: r("common.autoPlaceholderText"),
                            options: [
                                {
                                    label: "是",
                                    labelEn: "YES",
                                    value: 1
                                },
                                {
                                    label: "否",
                                    labelEn: "NO",
                                    value: 0
                                }
                            ]
                        }
                    },
                    {
                        field: "remarkToVendor",
                        component: "NInput",
                        label: r("requisitionOrder.editModal.remarksToVendor"),
                        giProps: {
                            span: 2
                        },
                        componentProps: {
                            placeholder: r("requisitionOrder.editModal.remarksToVendor"),
                            type: "textarea",
                            autosize: {
                                minRows: 3,
                                maxRows: 3
                            }
                        }
                    }
                ];
            case o.CHARTS_AND_PUBLICATIONS:
                return [
                    {
                        field: "approveQuantity",
                        component: "NInputNumber",
                        label: r("requisitionOrder.editModal.approveQuantity"),
                        giProps: {
                            span: 2
                        },
                        componentProps: {
                            min: 1,
                            precision: 0,
                            placeholder: r("requisitionOrder.editModal.approveQuantity")
                        },
                        rules: [
                            {
                                required: !0,
                                message: r("requisitionOrder.editModal.approveQuantityRequired"),
                                trigger: [
                                    "change",
                                    "blur"
                                ],
                                type: "number"
                            }
                        ]
                    }
                ];
            default:
                return console.warn(`No schemas defined for procurement type: ${e}`), [];
        }
    }
    const { t: u } = p();
    function D({ props: t, record: e }) {
        if (!e) return {};
        const a = d(t.procurementCategory);
        if (!a) return console.warn("Invalid procurement category:", t.procurementCategory), {};
        switch(a){
            case o.SPARE_PARTS:
                return {
                    reqQuality: e?.reqQuality ? e.reqQuality + "" : "",
                    approveQuantity: e?.approveQuantity ? +e.approveQuantity : e?.reqQuantity ? +e?.reqQuantity : void 0,
                    mdRequired: e.mdRequired,
                    sdocRequired: e.sdocRequired,
                    remarkToVendor: e.remarkToVendor
                };
            case o.MATERIALS:
                return {
                    approveQuantity: e?.approveQuantity ? +e.approveQuantity : e?.reqQuantity ? +e?.reqQuantity : void 0,
                    mdRequired: e.mdRequired,
                    sdocRequired: e.sdocRequired,
                    remarkToVendor: e.remarkToVendor
                };
            case o.CHARTS_AND_PUBLICATIONS:
                return {
                    approveQuantity: e?.approveQuantity ? +e.approveQuantity : e?.reqQuantity ? +e?.reqQuantity : void 0
                };
            default:
                return console.warn("Unsupported procurement type:", a), {};
        }
    }
    function F(t) {
        const e = d(t);
        return e ? {
            modalName: e === o.SPARE_PARTS ? u("requisitionOrder.approveModal.sparePartsDetail") : e === o.MATERIALS ? u("requisitionOrder.approveModal.materialsDetail") : e === o.CHARTS_AND_PUBLICATIONS ? u("requisitionOrder.approveModal.chartsAndPublicationsDetail") : ""
        } : (console.warn("Invalid procurement category:", t), {});
    }
    J = E({
        __name: "index",
        props: {
            vesselValue: {},
            procurementCategory: {},
            reqFormOtherInfo: {}
        },
        emits: [
            "refresh"
        ],
        setup (t, { expose: e, emit: a }) {
            const { t: c } = p(), l = t, m = a, s = _(null), [y, { openModal: q, closeModal: R, setSubLoading: f }] = M({
                width: 500,
                title: F(l.procurementCategory)?.modalName
            }), [h, { setFieldsValue: v, getFieldsValue: b, validate: g, updateSchema: U }] = N({
                schemas: L(l),
                labelWidth: "auto",
                layout: "horizontal",
                gridProps: {
                    cols: 2,
                    xGap: 15
                },
                showActionButtonGroup: !1
            });
            async function O() {
                g().then(()=>{
                    const i = b();
                    V({
                        id: s.value,
                        ...i
                    }).then((Q)=>{
                        B().success(c("common.optionsEditSuccessText")), m("refresh"), R();
                    });
                }).finally(()=>{
                    f(!1);
                });
            }
            function P(i) {
                s.value = null, q(), s.value = i.id, C(()=>{
                    v(D({
                        record: i,
                        props: l
                    }));
                });
            }
            return e({
                handleOpenModal: P
            }), (i, Q)=>(w(), I(n(T), {
                    onRegister: n(y),
                    onOnOk: O
                }, {
                    default: x(()=>[
                            k(n(S), {
                                onRegister: n(h)
                            }, null, 8, [
                                "onRegister"
                            ])
                        ]),
                    _: 1
                }, 8, [
                    "onRegister"
                ]));
        }
    });
});
export { J as _, __tla };
