You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
72 lines
1.5 KiB
72 lines
1.5 KiB
|
|
import {
|
|
listCommonuser
|
|
} from "@/api/common.js"
|
|
let userData1 = []
|
|
|
|
|
|
// 获取 userdata
|
|
|
|
export function getUser(){
|
|
console.log("userData1",userData1)
|
|
if(userData1.length>0){
|
|
console.log("123")
|
|
return
|
|
}else{
|
|
listCommonuser({
|
|
page_size: 999,
|
|
}).
|
|
then((res) => {
|
|
// this.userdata = res.data ? res.data.reverse() : [];
|
|
userData1 = res.data ? res.data.reverse() : [];
|
|
console.log("userData1",userData1)
|
|
return userData1
|
|
}).catch(error => {
|
|
console.log(error)
|
|
})
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
* @param {Object} arr
|
|
* 处理组别返回
|
|
*/
|
|
export function contactGroup(arr) {
|
|
let tempArr = [],
|
|
newArr = []
|
|
for (let i = 0; i < arr.length; i++) {
|
|
if (tempArr.indexOf(arr[i].name) === -1) {
|
|
if (arr[i].type === 1) {
|
|
newArr.push({
|
|
type: arr[i].type,
|
|
name: arr[i]['name'],
|
|
admin_details: arr[i].details,
|
|
dep_details: []
|
|
})
|
|
} else {
|
|
newArr.push({
|
|
type: arr[i].type,
|
|
name: arr[i]['name'],
|
|
admin_details: [],
|
|
dep_details: arr[i].details
|
|
})
|
|
}
|
|
tempArr.push(arr[i].name);
|
|
} else {
|
|
for (let j = 0; j < newArr.length; j++) {
|
|
if (newArr[j].name == arr[i].name) {
|
|
if (arr[i].type === 1) {
|
|
newArr[j].admin_details.push(...arr[i].details)
|
|
} else {
|
|
newArr[j].dep_details.push(
|
|
...arr[i].details
|
|
)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return newArr
|
|
}
|