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 { B as W } from "./BasicForm-dL_oCSPM.js";
import { V as k, h8 as Z, d as H, b as J, r as u, a as K, c as Q, o as g, w as _, i as h, j as v, l as o, h as L, F as X, a9 as Y, A as ee, _ as se, k as te, ds as ae, ac as oe, i_ as ne, cZ as le, j3 as re, __tla as __tla_0 } from "./index-9PRMimni.js";
import { u as ce } from "./useForm-CKmgcynv.js";
import { u as ie } from "./useModal-CO65vga3.js";
let ye;
let __tla = Promise.all([
    (()=>{
        try {
            return __tla_0;
        } catch  {}
    })()
]).then(async ()=>{
    let n, me, M, ue, de;
    ({ t: n } = k());
    me = await Z();
    M = [
        {
            field: "msgname",
            component: "NInput",
            label: n("common.messagedefine.MessageType"),
            componentProps: {
                placeholder: n("common.messagedefine.placeholderMessageType"),
                type: "textarea",
                readonly: !0
            },
            rules: [
                {
                    required: !0,
                    type: "string",
                    message: n("common.messagedefine.placeholderMessageType"),
                    trigger: [
                        "change"
                    ]
                }
            ]
        },
        {
            field: "receiverId",
            component: "NSelect",
            label: n("common.messagedefine.Recipient"),
            componentProps: {
                placeholder: n("common.messagedefine.placeholderRecipient"),
                options: me,
                "value-field": "value",
                "label-field": "label",
                filterable: !0
            },
            rules: [
                {
                    required: !0,
                    message: n("common.messagedefine.placeholderRecipient"),
                    trigger: [
                        "change"
                    ]
                }
            ]
        },
        {
            field: "paramList",
            label: n("common.messagedefine.MessageParameter"),
            slot: "detailSlot",
            defaultValue: []
        }
    ];
    ue = {
        class: "pt-6"
    };
    de = {
        class: "detail"
    };
    ye = H({
        __name: "sendModal",
        props: {
            title: {
                type: String,
                default: ""
            },
            isEdit: {
                type: Boolean,
                default: !1
            }
        },
        emits: [
            "success"
        ],
        setup (S, { expose: B, emit: F }) {
            const { t: l } = k(), d = le(), T = J(), y = S, I = F, w = u(), V = u(null), E = u(y.title), e = K({
                msgId: "",
                receiverId: "",
                paramList: [
                    {
                        key: "",
                        value: ""
                    }
                ],
                msgname: ""
            }), c = u([]), [P, { submit: N, setFieldsValue: R, getFieldsValue: b, setSchema: U }] = ce({
                gridProps: {
                    cols: 1
                },
                collapsed: !1,
                collapsedRows: 12,
                labelWidth: 120,
                layout: "horizontal",
                submitButtonText: "确定",
                showActionButtonGroup: !1,
                schemas: M
            }), [A, { openModal: D, closeModal: x, setSubLoading: i, setProps: j }] = ie({
                title: E,
                subBtuText: l("common.okText"),
                cancelText: l("common.cancelText"),
                width: 650
            });
            async function q(s) {
                if (console.log("id", s), V.value = s, await oe(), s) {
                    const t = await ne(s);
                    e.msgId = t.id, e.msgname = t.content, c.value = t.params.split(",");
                    const r = [];
                    for(let a = 0; a < c.value.length; a++)r.push({
                        key: c.value[a],
                        value: ""
                    });
                    e.paramList = r, R({
                        ...e
                    });
                    const p = M.map((a)=>a);
                    U(p);
                }
            }
            async function z() {
                if (await N()) {
                    const { isEdit: t } = y;
                    e.receiverId = b().receiverId, console.log("表单值：", b()), await re(e), await T.getmsg(), d.success(l(t ? "common.optionsEditSuccessText" : "common.optionsAddSuccessText")), I("success"), i(!1), x();
                } else d.error("验证失败，请填写完整信息"), i(!1);
            }
            async function C() {
                try {
                    await w.value?.validate();
                    let s = !1;
                    if (e.paramList.forEach((t, r)=>{
                        t.value || (d.error(l("common.messagedefine.placeholderMessageParameter")), s = !0);
                    }), s) {
                        i(!1);
                        return;
                    }
                    z();
                } catch  {
                    i(!1);
                }
            }
            return B({
                openModal: D,
                closeModal: x,
                setFieldsValue: R,
                setProps: j,
                getData: q
            }), (s, t)=>{
                const r = te, p = se, a = W, O = G;
                return g(), Q(O, {
                    onRegister: o(A),
                    ref: "modalRef",
                    onOnOk: C,
                    modelValue: o(e),
                    "onUpdate:modelValue": t[0] || (t[0] = (f)=>ae(e) ? e.value = f : null)
                }, {
                    default: _(()=>[
                            h("div", ue, [
                                v(a, {
                                    ref_key: "contentFromRef",
                                    ref: w,
                                    onRegister: o(P),
                                    model: o(e)
                                }, {
                                    detailSlot: _(()=>[
                                            h("div", de, [
                                                (g(!0), L(X, null, Y(o(c), (f, m)=>(g(), L("div", {
                                                        key: m,
                                                        class: "detailList"
                                                    }, [
                                                        h("span", null, ee(f) + ": ", 1),
                                                        v(p, {
                                                            path: `paramList.${m}.value`
                                                        }, {
                                                            default: _(()=>[
                                                                    v(r, {
                                                                        value: o(e).paramList[m].value,
                                                                        "onUpdate:value": ($)=>o(e).paramList[m].value = $,
                                                                        style: {
                                                                            width: "1000px"
                                                                        }
                                                                    }, null, 8, [
                                                                        "value",
                                                                        "onUpdate:value"
                                                                    ])
                                                                ]),
                                                            _: 2
                                                        }, 1032, [
                                                            "path"
                                                        ])
                                                    ]))), 128))
                                            ])
                                        ]),
                                    _: 1
                                }, 8, [
                                    "onRegister",
                                    "model"
                                ])
                            ])
                        ]),
                    _: 1
                }, 8, [
                    "onRegister",
                    "modelValue"
                ]);
            };
        }
    });
});
export { ye as _, __tla };
