import { V as O, d as b, f as P, e as S, a4 as c, r as k, c as w, o as D, l as s, w as L, j as V, cZ as m, c_ as B, ac as f, __tla as __tla_0 } from "./index-9PRMimni.js";
import { u as N } from "./useTags-C1thGhjF.js";
import { _ as G } 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 z } from "./useModal-CO65vga3.js";
import { B as Q } from "./BasicForm-dL_oCSPM.js";
import { u as U } from "./useForm-CKmgcynv.js";
import { r as W, p as Z } from "./requisitionOrder-D0IG9N7e.js";
import { P as a, M as $, e as H, C as J, __tla as __tla_1 } from "./helper-CNwA55dE.js";
import { i as K } from "./includes-DdMWPj0t.js";
let ue;
let __tla = Promise.all([
    (()=>{
        try {
            return __tla_0;
        } catch  {}
    })(),
    (()=>{
        try {
            return __tla_1;
        } catch  {}
    })()
]).then(async ()=>{
    const { t: u } = O();
    function X({ type: i }) {
        return [
            {
                field: "comment",
                component: "NInput",
                label: u("requisitionOrder.passOrRejectModal.comment"),
                componentProps: {
                    type: "textarea",
                    placeholder: u("requisitionOrder.passOrRejectModal.comment"),
                    autosize: {
                        minRows: 3,
                        maxRows: 3
                    }
                },
                rules: [
                    {
                        required: i === "reject",
                        message: u("requisitionOrder.passOrRejectModal.commentRequired")
                    }
                ]
            }
        ];
    }
    ue = b({
        __name: "index",
        props: {
            reqFormOtherInfo: {},
            subModuleCode: {}
        },
        emits: [
            "finish"
        ],
        setup (i, { expose: q, emit: v }) {
            const { t: e } = O(), o = i, h = v, g = P(), l = S(), { closeCurrent: R } = N(), C = c(()=>g.query.type ?? a.CREATE), r = k("pass"), _ = c(()=>r.value === "pass" ? e("requisitionOrder.passOrRejectModal.passTitle") : r.value === "reject" ? e("requisitionOrder.passOrRejectModal.rejectTitle") : ""), [T, { openModal: j, setSubLoading: E }] = z({
                width: 500,
                title: _
            }), y = c(()=>X({
                    type: r.value
                })), [M, { getFieldsValue: x, validate: A }] = U({
                schemas: y,
                labelWidth: "auto",
                layout: "horizontal",
                gridProps: {
                    cols: 1,
                    xGap: 15
                },
                showActionButtonGroup: !1
            });
            async function F({ type: t }) {
                r.value = t, j();
            }
            function I() {
                A().then(()=>{
                    const { comment: t } = x(), d = {
                        pass: Z,
                        reject: W
                    }[r.value];
                    d?.({
                        busId: o.reqFormOtherInfo.id,
                        moduleCode: $,
                        comment: t,
                        subModuleCode: o.subModuleCode
                    }).then(()=>{
                        if (m().success(r.value === "pass" ? e("requisitionOrder.approveSuccess") : r.value === "reject" ? e("requisitionOrder.rejectSuccess") : ""), H === J.OFFICE && K(C.value, a.APPROVE) && r.value === "pass") {
                            B().warning({
                                title: e("requisitionOrder.approvedDialog.title"),
                                content: e("requisitionOrder.approvedDialog.content"),
                                positiveText: e("requisitionOrder.approvedDialog.confirmText"),
                                negativeText: e("requisitionOrder.approvedDialog.cancelText"),
                                onPositiveClick: ()=>{
                                    try {
                                        R(), f(()=>{
                                            l.replace({
                                                name: "Add_RFQ_PageList",
                                                query: {
                                                    reqId: o.reqFormOtherInfo.id,
                                                    type: a.CREATE
                                                }
                                            });
                                        });
                                    } catch (n) {
                                        console.error("Close tab failed:", n), f(()=>{
                                            l.replace({
                                                name: "Add_RFQ_PageList",
                                                query: {
                                                    reqId: o.reqFormOtherInfo.id,
                                                    type: a.CREATE
                                                }
                                            });
                                        });
                                    }
                                },
                                onNegativeClick: ()=>{
                                    p();
                                }
                            });
                            return;
                        }
                        p();
                    }).catch((n)=>{
                        m().error(r.value === "pass" ? e("requisitionOrder.approveFailed") : r.value === "reject" ? e("requisitionOrder.rejectFailed") : ""), console.error("Return failed:", n);
                    });
                }).finally(()=>{
                    E(!1);
                });
            }
            function p() {
                h("finish");
            }
            return q({
                handleOpenModal: F
            }), (t, d)=>(D(), w(s(G), {
                    onRegister: s(T),
                    onOnOk: I
                }, {
                    default: L(()=>[
                            V(s(Q), {
                                onRegister: s(M)
                            }, null, 8, [
                                "onRegister"
                            ])
                        ]),
                    _: 1
                }, 8, [
                    "onRegister"
                ]));
        }
    });
});
export { ue as _, __tla };
