123456789101112131415161718192021222324252627282930 |
- import { iAccountGroup, iAccountGroupItem, iUserInfo } from "@/types/setting"
- import request from "@/utils/common/request"
- /**
- * 获取用户分组列表
- */
- export async function apiGetGroup(name: string = "") {
- const { data } = await request.get("/api/projectAccount/group", { name })
- const { roleDate = {}, accountData = [] } = data
- const newData: iAccountGroup = {}
- for (const key in roleDate) {
- if (Object.prototype.hasOwnProperty.call(roleDate, key)) {
- const element = roleDate[key]
- newData[key] = { value: element, children: [] }
- }
- }
- accountData.forEach((account: iUserInfo) => {
- if (newData[account.accountGroup]) {
- newData[account.accountGroup].children.push(account)
- }
- })
- const toArray: iAccountGroupItem[] = []
- for (const key in newData) {
- if (Object.prototype.hasOwnProperty.call(newData, key)) {
- const item = newData[key]
- item && (toArray.push(item))
- }
- }
- return { code: data.code, data: toArray }
- }
|