import { _ as $ } 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 j } from "./BasicForm-dL_oCSPM.js";
import { g as E } from "./role-DXhO1zOz.js";
import { aQ as Q, e as w, ao as W, aR as H, aS as J } from "./template-rpthWlT9.js";
import { r as n, V as K, d as X, aw as Y, c as Z, o as ee, l as a, w as d, j as c, h6 as oe, h7 as se, aA as te, ac as ae, __tla as __tla_0 } from "./index-9PRMimni.js";
import { u as ne } from "./useModal-CO65vga3.js";
import { u as le } from "./useForm-CKmgcynv.js";
let ye;
let __tla = Promise.all([
    (()=>{
        try {
            return __tla_0;
        } catch  {}
    })()
]).then(async ()=>{
    const { t: s } = K(), ie = await Q(), re = await w({}), ce = await W("audit_permission");
    function ue() {
        const u = n(!1);
        return {
            modalSchemas: [
                {
                    field: "auditId",
                    component: "NSelect",
                    label: s("mdm.smsInspectionTypeConfig.inspectionType"),
                    componentProps: {
                        options: ie,
                        "label-field": "content",
                        "value-field": "id",
                        disabled: u
                    },
                    rules: [
                        {
                            required: !0,
                            validator: (t, o)=>o != null,
                            message: s("common.chooseText") + " " + s("mdm.smsInspectionTypeConfig.inspectionType"),
                            trigger: [
                                "blur",
                                "change"
                            ]
                        }
                    ]
                },
                {
                    field: "roleId",
                    slot: "detailSlot",
                    component: "NSelect",
                    label: s("mdm.role.role"),
                    componentProps: {
                        options: re,
                        "label-field": "name",
                        "value-field": "id",
                        disabled: u
                    },
                    rules: [
                        {
                            required: !0,
                            validator: (t, o)=>o != null,
                            message: s("common.chooseText") + " " + s("mdm.role.role"),
                            trigger: [
                                "blur",
                                "change"
                            ]
                        }
                    ]
                },
                {
                    field: "permission",
                    component: "NSelect",
                    label: s("mdm.role.permission"),
                    componentProps: {
                        options: ce,
                        disabled: u
                    },
                    rules: [
                        {
                            required: !0,
                            validator: (t, o)=>o != null,
                            message: s("common.chooseText") + " " + s("mdm.role.permission"),
                            trigger: [
                                "blur",
                                "change"
                            ]
                        }
                    ]
                }
            ],
            methods: {
                updataReadOnly: (t)=>{
                    u.value = t;
                }
            }
        };
    }
    ye = X({
        __name: "Modal",
        emits: [
            "success"
        ],
        setup (u, { expose: R, emit: T }) {
            const t = n(!1), o = T, [A, { openModal: C, closeModal: b, setSubLoading: g, setProps: x }] = ne({
                title: "",
                width: 600
            }), S = n([]), v = n([]);
            async function D() {
                const l = await w({});
                v.value = (l || []).map((e)=>({
                        label: e.name,
                        value: e.id,
                        ...e
                    }));
            }
            async function k() {
                const l = await E();
                S.value = (l || []).map((e)=>({
                        ...e,
                        value: +e.value
                    }));
            }
            const { modalSchemas: I, methods: M } = ue(), { updataReadOnly: O } = M, p = n({
                roleType: null
            }), [B, { submit: F, setFieldsValue: L, getFieldsValue: f }] = le({
                gridProps: {
                    cols: 1
                },
                layout: "horizontal",
                labelWidth: "auto",
                schemas: I,
                showActionButtonGroup: !1
            }), P = n(), N = n(), _ = n(null);
            function U(l, e, i) {
                x({
                    title: l
                }), C(), O(!1), t.value = !1, e ? (_.value = e.id, v.value.forEach((m)=>{
                    e.roleId === m.id && (p.value.roleType = m.roleType);
                }), ae(()=>{
                    e.permission = e.permission + "", L({
                        ...e,
                        isDOCRole: e.ifDoc
                    });
                }), i && (t.value = i, O(i))) : _.value = null;
            }
            async function V() {
                if (!await F()) return g(!1);
                _.value ? (await J({
                    id: _.value,
                    ...f(),
                    ifDoc: f().isDOCRole || !1
                }), g(!1), b(), o("success")) : (await H({
                    ...f(),
                    ifDoc: f().isDOCRole || !1
                }), g(!1), b(), o("success"));
            }
            return Y(()=>{
                D(), k();
            }), R({
                showModal: U
            }), (l, e)=>{
                const i = te, m = se, q = oe, G = j, z = $;
                return ee(), Z(z, {
                    ref_key: "modalRef",
                    ref: P,
                    onRegister: a(A),
                    onOnOk: V,
                    showAction: !a(t)
                }, {
                    default: d(()=>[
                            c(G, {
                                ref_key: "formRef",
                                ref: N,
                                onRegister: a(B)
                            }, {
                                detailSlot: d(({ model: h, field: y })=>[
                                        c(q, {
                                            gutter: "6"
                                        }, {
                                            default: d(()=>[
                                                    c(m, {
                                                        span: 12
                                                    }, {
                                                        default: d(()=>[
                                                                c(i, {
                                                                    value: a(p).roleType,
                                                                    "onUpdate:value": [
                                                                        e[0] || (e[0] = (r)=>a(p).roleType = r),
                                                                        (r)=>h[y] = ""
                                                                    ],
                                                                    options: a(S)
                                                                }, null, 8, [
                                                                    "value",
                                                                    "options",
                                                                    "onUpdate:value"
                                                                ])
                                                            ]),
                                                        _: 2
                                                    }, 1024),
                                                    c(m, {
                                                        span: 12
                                                    }, {
                                                        default: d(()=>[
                                                                c(i, {
                                                                    value: h[y],
                                                                    "onUpdate:value": (r)=>h[y] = r,
                                                                    options: a(v).filter((r)=>+r.roleType == +a(p).roleType)
                                                                }, null, 8, [
                                                                    "value",
                                                                    "onUpdate:value",
                                                                    "options"
                                                                ])
                                                            ]),
                                                        _: 2
                                                    }, 1024)
                                                ]),
                                            _: 2
                                        }, 1024)
                                    ]),
                                _: 1
                            }, 8, [
                                "onRegister"
                            ])
                        ]),
                    _: 1
                }, 8, [
                    "onRegister",
                    "showAction"
                ]);
            };
        }
    });
});
export { ye as _, __tla };
