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 { B as D } from "./BasicForm-dL_oCSPM.js";
import { ad as r, V as M, r as v, bk as k, d as q, c as I, o as x, l as h, w as B, j as G, ac as C, cZ as E, __tla as __tla_0 } from "./index-9PRMimni.js";
import { b as V } from "./dashboardManagement-DwIFZ7Hm.js";
import { u as A } from "./useModal-CO65vga3.js";
import { u as j } from "./useForm-CKmgcynv.js";
let ae, X, se, U, te;
let __tla = Promise.all([
    (()=>{
        try {
            return __tla_0;
        } catch  {}
    })()
]).then(async ()=>{
    const l = "";
    te = function(t) {
        return r.Get(`${l}/dashboard/view/page`, {
            params: t
        });
    };
    function z(t) {
        return r.Post(`${l}/dashboard/view`, t);
    }
    U = function(t) {
        return r.Put(`${l}/dashboard/view`, t);
    };
    function W(t) {
        return r.Get(`${l}/dashboard/view/${t}`);
    }
    se = function(t) {
        return r.Delete(`${l}/dashboard/view/${t}`);
    };
    const { t: e } = M(), R = k(), y = await V();
    X = function() {
        const t = [
            {
                label: e("system.dashboardManagement.statusDisable"),
                value: 0
            },
            {
                label: e("system.dashboardManagement.statusNormal"),
                value: 1
            }
        ], i = [
            {
                field: "keyword",
                component: "NInput",
                label: e("system.mergeRoleManagement.keywords")
            },
            {
                field: "status",
                component: "NSelect",
                label: e("system.mergeRoleManagement.status"),
                componentProps: {
                    options: t
                }
            }
        ], n = v([]), c = [
            {
                field: "viewName",
                component: "NInput",
                label: e("system.mergeRoleManagement.mergeRoleName"),
                rules: [
                    {
                        required: !0,
                        message: `${e("system.mergeRoleManagement.mergeRoleName")} ${e("common.required")}`,
                        trigger: [
                            "blur"
                        ]
                    }
                ]
            },
            {
                field: "viewCode",
                component: "NInput",
                label: e("system.mergeRoleManagement.mergeRoleCode"),
                rules: [
                    {
                        required: !0,
                        message: `${e("system.mergeRoleManagement.mergeRoleCode")} ${e("common.required")}`,
                        trigger: [
                            "blur"
                        ]
                    }
                ]
            },
            {
                field: "modelList",
                component: "NSelect",
                label: e("system.mergeRoleManagement.roleModelList"),
                componentProps ({ model: a }) {
                    return {
                        options: y,
                        labelField: R.getLocale === "en" ? "modelNameEn" : "modelName",
                        valueField: "id",
                        multiple: !0,
                        onUpdateValue (s, d) {
                            n.value = d || [], a.defaultList = (a.defaultList || []).filter((g)=>s?.includes(g));
                        }
                    };
                },
                rules: [
                    {
                        required: !0,
                        type: "array",
                        message: `${e("system.mergeRoleManagement.roleModelList")} ${e("common.required")}`,
                        trigger: [
                            "change"
                        ]
                    }
                ]
            },
            {
                field: "defaultList",
                component: "NSelect",
                label: e("system.mergeRoleManagement.defaultModelList"),
                componentProps: {
                    options: n,
                    labelField: R.getLocale === "en" ? "modelNameEn" : "modelName",
                    valueField: "id",
                    multiple: !0
                },
                rules: [
                    {
                        type: "array",
                        required: !0,
                        message: `${e("system.mergeRoleManagement.defaultModelList")} ${e("common.required")}`,
                        trigger: [
                            "change"
                        ]
                    }
                ]
            },
            {
                field: "priority",
                component: "NInputNumber",
                label: e("system.mergeRoleManagement.viewOrder")
            },
            {
                field: "status",
                component: "NRadioGroup",
                label: e("system.mergeRoleManagement.status"),
                componentProps: {
                    options: t
                }
            }
        ];
        return {
            searchSchemas: i,
            formSchemas: c,
            methods: {
                handleGetDefaultListOptions (a) {
                    n.value = y?.filter((s)=>a.modelList?.includes(s.id));
                }
            }
        };
    };
    ae = q({
        __name: "FormModal",
        emits: [
            "success"
        ],
        setup (t, { expose: i, emit: n }) {
            const c = n, { t: u } = M(), a = E(), s = v(""), [d, { openModal: g, closeModal: w, setSubLoading: p, setProps: L }] = A({
                title: "",
                width: 750
            }), { formSchemas: N, methods: _ } = X(), [$, { submit: S, setFieldsValue: b }] = j({
                gridProps: {
                    cols: 2
                },
                layout: "horizontal",
                schemas: N,
                showActionButtonGroup: !1
            });
            async function O(o, f) {
                if (s.value = f?.id, L({
                    title: o
                }), g(), await C(), s.value) {
                    const m = await W(s.value);
                    b(m), _?.handleGetDefaultListOptions(m);
                } else b({
                    status: 1
                });
            }
            async function F() {
                const o = await S();
                if (!o) {
                    p(!1);
                    return;
                }
                try {
                    s.value ? (await U({
                        ...o,
                        id: s.value
                    }), a.success(u("common.optionsEditSuccessText"))) : (await z(o), a.success(u("common.optionsAddSuccessText"))), w(), p(!1), c("success");
                } catch  {
                    p(!1);
                }
            }
            return i({
                handleOpenModal: O
            }), (o, f)=>{
                const m = D, P = T;
                return x(), I(P, {
                    ref: "modalRef",
                    onRegister: h(d),
                    onOnOk: F
                }, {
                    default: B(()=>[
                            G(m, {
                                ref: "formRef",
                                onRegister: h($)
                            }, null, 8, [
                                "onRegister"
                            ])
                        ]),
                    _: 1
                }, 8, [
                    "onRegister"
                ]);
            };
        }
    });
});
export { ae as _, X as c, se as d, U as e, te as g, __tla };
