import { defineComponent, ref, computed, reactive, watch, unref, useSSRContext } from 'vue'; import { ssrRenderAttrs, ssrRenderStyle, ssrRenderList, ssrInterpolate, ssrRenderClass, ssrRenderAttr, ssrIncludeBooleanAttr, ssrLooseContain, ssrLooseEqual } from 'vue/server-renderer'; import { u as useApi } from './useApi-BNSkSrat.mjs'; import { u as useToast } from './useToast-MBvLaNjH.mjs'; import { _ as _export_sfc, R as ROLE_ACCESS_CEILING, A as ALL_MENU_IDS, M as MENU_GROUPS, D as DEFAULT_ADMIN_ACCESS } from './server.mjs'; import { R as REGION_OPTIONS } from './regions-D1dSykUW.mjs'; import '../nitro/nitro.mjs'; import 'node:http'; import 'node:https'; import 'node:events'; import 'node:buffer'; import 'node:fs'; import 'node:path'; import 'node:crypto'; import 'node:url'; import '../routes/renderer.mjs'; import 'vue-bundle-renderer/runtime'; import 'unhead/server'; import 'devalue'; import 'unhead/utils'; import 'pinia'; import 'perfect-debounce'; const _sfc_main = /* @__PURE__ */ defineComponent({ __name: "accounts", __ssrInlineRender: true, setup(__props) { useApi(); useToast(); const ROLE = { 1: "超管", 2: "管理员", 3: "品牌商", 4: "运营", 5: "渠道商" }; const ROLE_CLS = { 1: "badge-error", 2: "badge-primary", 3: "badge-warning", 4: "badge-info", 5: "badge-accent" }; const view = ref("list"); const rows = ref([]); const apps = ref([]); const appNames = computed( () => [...new Set(apps.value.map((a) => a.app_name || a.name).filter(Boolean))].sort() ); const loading = ref(false); const submitting = ref(false); const editId = ref(0); const form = reactive({ username: "", password: "", identity: 2, enabled: "1", remark: "", brandid: 0, channelid: "" }); const roleCeiling = computed(() => ROLE_ACCESS_CEILING[form.identity] ?? null); computed(() => roleCeiling.value ?? ALL_MENU_IDS); const menuGroupsForRole = computed(() => { const ceiling = roleCeiling.value; if (!ceiling) return MENU_GROUPS; return MENU_GROUPS.map((g) => ({ ...g, items: g.items.filter((m) => ceiling.includes(m.id)) })).filter((g) => g.items.length > 0); }); const channels = ref([]); const accountChannelOptions = computed( () => form.brandid ? channels.value.filter((ch) => ch.brandid === form.brandid) : [] ); const sel = reactive({ access: [], apps: [], regions: [], products: [] }); const brands = ref([]); const productGroups = ref([]); const prodLoading = ref(false); function fromCsv(s) { return (s || "").split(",").map((x) => x.trim()).filter((x) => x); } function scopeParts(a) { const parts = []; if (a.apps) parts.push("应用:" + fromCsv(a.apps).length); if (a.regions) parts.push("区域:" + fromCsv(a.regions).length); if (a.products) parts.push("产品:" + fromCsv(a.products).length); if (a.access) parts.push("页面:" + fromCsv(a.access).length); return parts; } watch(() => form.identity, (idt) => { if (idt === 2 && sel.access.length === 0) sel.access = DEFAULT_ADMIN_ACCESS.slice(); const ceiling = ROLE_ACCESS_CEILING[idt]; if (ceiling) sel.access = sel.access.filter((id) => ceiling.includes(id)); }); ref(null); ref(0); const topup = reactive({ name: "", cur: "", vipday: 0, trademin: 0, meetmin: 0 }); return (_ctx, _push, _parent, _attrs) => { _push(`
超管 / 管理员 / 代理 / 运营。代理·运营可绑定应用·区域·产品,登录后仪表盘按绑定限制。
| ID | 用户名 | 角色 | 状态 | 绑定作用域 | 备注 | 操作 |
|---|---|---|---|---|---|---|
| 加载中... | ||||||
| 暂无账号(引导超管不在此列) | ||||||
| ${ssrInterpolate(a.id)} | ${ssrInterpolate(a.username || "")} | ${ssrInterpolate(ROLE[a.identity] || a.identity)} | `); if (a.enabled) { _push(`启用`); } else { _push(`停用`); } _push(` | `);
if (a.identity === 3 || a.identity === 4) {
_push(``);
if (scopeParts(a).length) {
_push(`${ssrInterpolate(scopeParts(a).join(" · "))}`);
} else {
_push(`未绑定(不限)`);
}
_push(``);
} else if (a.identity === 2) {
_push(``);
if (a.access) {
_push(`菜单:${ssrInterpolate(fromCsv(a.access).length)}`);
} else {
_push(`默认(除SaaS/系统管理)`);
}
_push(``);
} else {
_push(`全部权限`);
}
if (a.identity === 3) {
_push(` 余额 VIP${ssrInterpolate(a.balance_vipday || 0)}天 · 翻译${ssrInterpolate(a.balance_trademin || 0)}分 · 会议${ssrInterpolate(a.balance_meetmin || 0)}分 `);
} else {
_push(``);
}
_push(` | ${ssrInterpolate(a.remark || "")} | `);
if (a.identity === 3) {
_push(``);
} else {
_push(``);
}
_push(` |
该角色为外部账号,可见页面固定在下列范围内(留空即全部开放这些页面)。
`); } else { _push(`管理员默认开放除「SaaS 管理 / 系统管理」以外的全部菜单(权限留空时按默认生效);代理/运营需显式勾选。
`); } _push(``); ssrRenderList(menuGroupsForRole.value, (g) => { _push(`数据隔离由后端强制:品牌商账号只能看到本品牌商及其名下渠道商的数据,渠道商账号只能看到自己渠道的数据。