import { _ as K } from "./basicModal.vue_vue_type_script_setup_true_lang-CsJydKhW.js";
import "./basicModal.vue_vue_type_style_index_0_lang-8QZP7ApW.js";
import { aH as Z, aI as Q, aJ as X, e as Y } from "./template-rpthWlT9.js";
import { B as ee } from "./BasicForm-dL_oCSPM.js";
import { u as ae } from "./useForm-CKmgcynv.js";
import { g as le } from "./management-DjeaRnx2.js";
import { V, l as o, bk as oe, d as te, r as n, aw as se, c as re, o as b, ds as ie, w as m, j as p, i as x, h as S, a9 as ne, A as de, _ as pe, aA as ce, F as ue, ch as me, aj as ve, cZ as fe, v as Le, __tla as __tla_0 } from "./index-9PRMimni.js";
import { g as _e } from "./role-DXhO1zOz.js";
import { u as he } from "./useModal-CO65vga3.js";
import "./index-kKnqLkWM.js";
import "./Render.vue_vue_type_script_lang-DKUYY0Zw.js";
import "./SingleImageUpload-CNx4b9eC.js";
import "./ImageUpload.vue_vue_type_style_index_0_scoped_cb086928_lang-D-28kXvw.js";
import "./componentSetting-DVhNDBTO.js";
import "./ImageUpload-DUsnro3W.js";
import "./vuedraggable.umd-Co2xEC3p.js";
import "./BasicUpload.vue_vue_type_style_index_0_scoped_a4d0e930_lang-DxRbtP01.js";
import "./tabsView-BXskTdVh.js";
import "./BasicForm.vue_vue_type_style_index_0_scoped_b9e995ec_lang-CEvcLwxD.js";
import "./propTypes-CebMRUpe.js";
import "./BasicSelect-C_uwzMkE.js";
import "./BasicSelect.vue_vue_type_style_index_0_scoped_772d51cc_lang-Brp6PjEU.js";
import "./dictionary-BRse4lkf.js";
import "./index-DkvzUEqh.js";
import "./AutoComplete-Dv1Bqed4.js";
import "./TreeSelect-BZh2DeCh.js";
import "./usePageCache-DluHn7Yy.js";
let Qe;
let __tla = Promise.all([
    (()=>{
        try {
            return __tla_0;
        } catch  {}
    })()
]).then(async ()=>{
    const { t } = V(), ge = oe(), be = await le();
    function ye(h = {}) {
        return {
            schemas: [
                {
                    field: "approvalLevel",
                    label: t("mdm.approval.approvalLevel"),
                    defaultValue: 1,
                    slot: "levelSlot",
                    rules: [
                        {
                            required: !0,
                            message: t("mdm.approval.approvalLevelPlaceholder"),
                            trigger: [
                                "blur",
                                "change"
                            ],
                            validator: (C, c)=>c >= 1 && c <= 6
                        }
                    ]
                },
                {
                    field: "moduleCode",
                    component: "NSelect",
                    label: t("mdm.approval.moduleCode"),
                    componentProps: ()=>({
                            placeholder: t("mdm.approval.moduleCodePlaceholder"),
                            options: be,
                            "value-field": "code",
                            "label-field": "name",
                            disabled: o(h.isEdit)
                        }),
                    rules: [
                        {
                            required: !0,
                            message: t("mdm.approval.moduleCodePlaceholder"),
                            trigger: [
                                "blur"
                            ]
                        }
                    ]
                },
                {
                    field: "subModuleCode",
                    component: "NInput",
                    label: t("mdm.approval.subModuleCode"),
                    componentProps: ()=>({
                            placeholder: t("mdm.approval.subModuleCodePlaceholder"),
                            disabled: o(h.isEdit)
                        })
                },
                {
                    field: "rejectOperation",
                    component: "BasicSelect",
                    label: t("mdm.approval.rejectOperation"),
                    defaultValue: null,
                    componentProps: {
                        placeholder: t("mdm.approval.rejectOperationPlaceholder"),
                        cache: !1,
                        cacheKey: "RejectOperation",
                        block: !0,
                        labelField: ge.getLocale === "en" ? "labelEn" : "label"
                    },
                    rules: [
                        {
                            required: !0,
                            message: t("mdm.approval.rejectOperationPlaceholder"),
                            trigger: [
                                "blur",
                                "change"
                            ]
                        }
                    ]
                },
                {
                    field: "description",
                    component: "NInput",
                    label: t("mdm.approval.description"),
                    defaultValue: "",
                    componentProps: {
                        placeholder: t("mdm.approval.descriptionPlaceholder")
                    }
                },
                {
                    field: "detailList",
                    label: t("mdm.approval.detailList"),
                    slot: "detailSlot",
                    defaultValue: []
                }
            ]
        };
    }
    let Ce, Te;
    Ce = {
        class: "detail"
    };
    Te = te({
        __name: "Modal",
        emits: [
            "success"
        ],
        setup (h, { expose: y, emit: C }) {
            const c = C, { t: i } = V(), T = n(), v = fe(), k = n(""), R = n([]), g = n(!1), { schemas: B } = ye({
                isEdit: g
            }), f = n(), e = n({
                approvalLevel: 1,
                moduleCode: "",
                isReturnFirst: null,
                description: "",
                detailList: [
                    {
                        level: 1,
                        roleCode: "",
                        roleType: null
                    }
                ]
            }), O = {
                approvalLevel: 1,
                moduleCode: "",
                isReturnFirst: null,
                description: "",
                detailList: [
                    {
                        level: 1,
                        roleCode: "",
                        roleType: null
                    }
                ]
            }, [E, { getFieldsValue: w, setFieldsValue: I }] = ae({
                gridProps: {
                    cols: 1
                },
                layout: "horizontal",
                showActionButtonGroup: !1,
                schemas: B,
                labelWidth: "140px"
            }), [j, { openModal: A, closeModal: M, setProps: D, setSubLoading: L }] = he({
                title: i("common.addText"),
                subBtuText: i("common.okText"),
                cancelText: i("common.cancelText"),
                width: 650
            }), F = n([]);
            async function U(a) {
                k.value = a, A();
            }
            async function N(a) {
                if (a) {
                    f.value = a.id;
                    const l = await Z(a.id);
                    I(l), e.value = l, l.detailList.forEach((s, _)=>{
                        e.value.detailList[_] = s;
                    }), g.value = !0;
                } else f.value = null, e.value = ve(O), g.value = !1;
            }
            async function $() {
                try {
                    await T.value?.validate();
                    let a = !1;
                    if (e.value.detailList.forEach((l, s)=>{
                        l.roleType === null && (v.error(i("mdm.approval.detailListPlaceholder")), a = !0), l.roleCode === "" && (v.error(i("mdm.approval.detailListPlaceholder")), a = !0);
                    }), a) {
                        L(!1);
                        return;
                    }
                    q();
                } catch  {
                    L(!1);
                }
            }
            async function q() {
                if (f.value) {
                    const a = {
                        ...w(),
                        detailList: e.value.detailList,
                        approvalLevel: e.value.approvalLevel,
                        id: f.value
                    };
                    await X(a), v.success(i("common.optionsEditSuccessText")), c("success"), L(!1), M();
                } else {
                    const a = {
                        ...w(),
                        detailList: e.value.detailList,
                        approvalLevel: e.value.approvalLevel
                    };
                    await Q(a), v.success(i("common.optionsAddSuccessText")), c("success"), L(!1), M();
                }
            }
            function G(a) {
                const l = [];
                for(let s = 0; s < a; s++)l.push({
                    level: s + 1,
                    roleCode: e.value.detailList[s]?.roleCode || "",
                    roleType: e.value.detailList[s]?.roleType || null
                });
                e.value.detailList = l, e.value.approvalLevel = a;
            }
            async function W() {
                const a = await _e();
                R.value = (a || []).map((l)=>({
                        ...l,
                        value: +l.value
                    }));
            }
            async function z() {
                const a = await Y({});
                F.value = (a || []).map((l)=>({
                        label: l.name,
                        value: l.code,
                        ...l
                    }));
            }
            async function H() {
                await W(), await z();
            }
            return se(()=>{
                H();
            }), y({
                showModal: U,
                setProps: D,
                getData: N
            }), (a, l)=>{
                const s = me, _ = ce, P = pe, J = K;
                return b(), re(J, {
                    ref: "modalRef",
                    onRegister: o(j),
                    class: "basicModal basicFormModal",
                    onOnOk: $,
                    modelValue: o(e),
                    "onUpdate:modelValue": l[1] || (l[1] = (u)=>ie(e) ? e.value = u : null)
                }, {
                    default: m(()=>[
                            p(o(ee), {
                                ref_key: "contentFromRef",
                                ref: T,
                                onRegister: o(E),
                                model: o(e),
                                "label-placement": "left"
                            }, {
                                levelSlot: m(()=>[
                                        p(s, {
                                            value: o(e).approvalLevel,
                                            "onUpdate:value": [
                                                l[0] || (l[0] = (u)=>o(e).approvalLevel = u),
                                                G
                                            ],
                                            min: 1,
                                            max: 10,
                                            clearable: ""
                                        }, null, 8, [
                                            "value"
                                        ])
                                    ]),
                                detailSlot: m(()=>[
                                        x("div", Ce, [
                                            (b(!0), S(ue, null, ne(o(e).approvalLevel, (u, r)=>(b(), S("div", {
                                                    key: r,
                                                    class: "detailList"
                                                }, [
                                                    x("span", null, de(u) + ": ", 1),
                                                    p(P, {
                                                        path: `detailList.${r}.roleType`
                                                    }, {
                                                        default: m(()=>[
                                                                p(_, {
                                                                    value: o(e).detailList[r].roleType,
                                                                    "onUpdate:value": [
                                                                        (d)=>o(e).detailList[r].roleType = d,
                                                                        (d)=>o(e).detailList[r].roleCode = ""
                                                                    ],
                                                                    options: o(R)
                                                                }, null, 8, [
                                                                    "value",
                                                                    "onUpdate:value",
                                                                    "options"
                                                                ])
                                                            ]),
                                                        _: 2
                                                    }, 1032, [
                                                        "path"
                                                    ]),
                                                    p(P, {
                                                        path: `detailList[${r}].roleCode`
                                                    }, {
                                                        default: m(()=>[
                                                                p(_, {
                                                                    value: o(e).detailList[r].roleCode,
                                                                    "onUpdate:value": (d)=>o(e).detailList[r].roleCode = d,
                                                                    options: o(F).filter((d)=>+d.roleType == +o(e).detailList[r].roleType),
                                                                    disabled: !o(e).detailList[r].roleType
                                                                }, null, 8, [
                                                                    "value",
                                                                    "onUpdate:value",
                                                                    "options",
                                                                    "disabled"
                                                                ])
                                                            ]),
                                                        _: 2
                                                    }, 1032, [
                                                        "path"
                                                    ])
                                                ]))), 128))
                                        ])
                                    ]),
                                _: 1
                            }, 8, [
                                "onRegister",
                                "model"
                            ])
                        ]),
                    _: 1
                }, 8, [
                    "onRegister",
                    "modelValue"
                ]);
            };
        }
    });
    Qe = Le(Te, [
        [
            "__scopeId",
            "data-v-98013a2e"
        ]
    ]);
});
export { Qe as default, __tla };
