mirror of
https://github.com/FatttSnake/Pinnacle-OA.git
synced 2026-04-06 07:21:24 +08:00
Optimized table rendering speed
This commit is contained in:
@@ -237,13 +237,12 @@ export default {
|
||||
if (response.code === DATABASE_SELECT_OK) {
|
||||
const groups = response.data.records
|
||||
this.totalCount = response.data.total
|
||||
for (const group of groups) {
|
||||
groups.forEach((group) => {
|
||||
group.customColumn_1 = []
|
||||
const roles = group.roles
|
||||
for (const role of roles) {
|
||||
group.roles.forEach((role) => {
|
||||
group.customColumn_1.push(role.name)
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
this.groupTable = groups
|
||||
this.tableLoading = false
|
||||
} else {
|
||||
@@ -290,9 +289,9 @@ export default {
|
||||
this.groupForm.inputGroupName = row.name
|
||||
this.editGroupId = row.id
|
||||
this.groupForm.selectedRoles = []
|
||||
for (const role of row.roles) {
|
||||
row.roles.forEach((role) => {
|
||||
this.groupForm.selectedRoles.push(role.id)
|
||||
}
|
||||
})
|
||||
this.groupForm.enable = row.enable
|
||||
this.isAddNew = false
|
||||
this.dialogVisible = true
|
||||
@@ -333,12 +332,11 @@ export default {
|
||||
roles: [],
|
||||
enable: this.groupForm.enable
|
||||
}
|
||||
for (const roleId of this.groupForm.selectedRoles) {
|
||||
const role = {
|
||||
this.groupForm.selectedRoles.forEach((roleId) => {
|
||||
groupObject.roles.push({
|
||||
id: roleId
|
||||
}
|
||||
groupObject.roles.push(role)
|
||||
}
|
||||
})
|
||||
})
|
||||
if (this.isAddNew) {
|
||||
request.post('/group', groupObject).then((res) => {
|
||||
const response = res.data
|
||||
|
||||
@@ -244,20 +244,17 @@ export default {
|
||||
if (response.code === DATABASE_SELECT_OK) {
|
||||
const roles = response.data.records
|
||||
this.totalCount = response.data.total
|
||||
for (const role of roles) {
|
||||
roles.forEach((role) => {
|
||||
role.customColumn_1 = []
|
||||
const menus = role.menus
|
||||
const elements = role.elements
|
||||
const operations = role.operations
|
||||
for (const operation of operations) {
|
||||
const element = _.find(elements, { id: operation.elementId })
|
||||
role.operations.forEach((operation) => {
|
||||
const element = _.find(role.elements, { id: operation.elementId })
|
||||
if (element.operations === undefined) {
|
||||
element.operations = []
|
||||
}
|
||||
element.operations.push(operation)
|
||||
}
|
||||
for (const element of elements) {
|
||||
const menu = _.find(menus, { id: element.menuId })
|
||||
})
|
||||
role.elements.forEach((element) => {
|
||||
const menu = _.find(role.menus, { id: element.menuId })
|
||||
if (menu.elements === undefined) {
|
||||
menu.elements = []
|
||||
}
|
||||
@@ -270,8 +267,8 @@ export default {
|
||||
role.customColumn_1.push(
|
||||
`${menu.name}/${element.name}/${_.join(operas, ';')}`
|
||||
)
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
this.roleTable = roles
|
||||
this.tableLoading = false
|
||||
} else {
|
||||
@@ -301,28 +298,25 @@ export default {
|
||||
const response = res.data
|
||||
if (response.code === DATABASE_SELECT_OK) {
|
||||
const data = response.data
|
||||
const menuList = data.menuList
|
||||
const elementList = data.elementList
|
||||
const operationList = data.operationList
|
||||
for (const operation of operationList) {
|
||||
const element = _.find(elementList, { id: operation.elementId })
|
||||
data.operationList.forEach((operation) => {
|
||||
const element = _.find(data.elementList, { id: operation.elementId })
|
||||
if (element.children === undefined) {
|
||||
element.children = []
|
||||
}
|
||||
element.children.push(operation)
|
||||
}
|
||||
for (const element of elementList) {
|
||||
const menu = _.find(menuList, { id: element.menuId })
|
||||
})
|
||||
data.elementList.forEach((element) => {
|
||||
const menu = _.find(data.menuList, { id: element.menuId })
|
||||
if (menu.children === undefined) {
|
||||
menu.children = []
|
||||
}
|
||||
menu.children.push(element)
|
||||
}
|
||||
for (const menu of menuList) {
|
||||
})
|
||||
data.menuList.forEach((menu) => {
|
||||
if (menu.children.length === 1) {
|
||||
menu.children = menu.children[0].children
|
||||
}
|
||||
}
|
||||
})
|
||||
this.powerOptions = data.menuList
|
||||
this.powerTree = data.menuList
|
||||
this.dialogLoading = false
|
||||
@@ -353,10 +347,10 @@ export default {
|
||||
this.roleForm.selectedPower.clear()
|
||||
this.roleForm.enable = row.enable
|
||||
this.defaultSelectedPower = []
|
||||
for (const operation of row.operations) {
|
||||
row.operations.forEach((operation) => {
|
||||
this.defaultSelectedPower.push(operation.powerId)
|
||||
this.roleForm.selectedPower.add(operation.powerId)
|
||||
}
|
||||
})
|
||||
this.isAddNew = false
|
||||
this.dialogVisible = true
|
||||
},
|
||||
@@ -396,12 +390,11 @@ export default {
|
||||
powers: [],
|
||||
enable: this.roleForm.enable
|
||||
}
|
||||
for (const powerId of this.roleForm.selectedPower) {
|
||||
const power = {
|
||||
this.roleForm.selectedPower.forEach((powerId) => {
|
||||
roleObject.powers.push({
|
||||
id: powerId
|
||||
}
|
||||
roleObject.powers.push(power)
|
||||
}
|
||||
})
|
||||
})
|
||||
if (this.isAddNew) {
|
||||
request.post('/role', roleObject).then((res) => {
|
||||
const response = res.data
|
||||
|
||||
@@ -313,19 +313,17 @@ export default {
|
||||
if (response.code === DATABASE_SELECT_OK) {
|
||||
const users = response.data.records
|
||||
this.totalCount = response.data.total
|
||||
for (const user of users) {
|
||||
users.forEach((user) => {
|
||||
user.name = user.username
|
||||
user.customColumn_1 = []
|
||||
user.customColumn_2 = []
|
||||
const roles = user.roles
|
||||
for (const role of roles) {
|
||||
user.roles.forEach((role) => {
|
||||
user.customColumn_1.push(role.name)
|
||||
}
|
||||
const groups = user.groups
|
||||
for (const group of groups) {
|
||||
})
|
||||
user.groups.forEach((group) => {
|
||||
user.customColumn_2.push(group.name)
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
this.userTable = users
|
||||
this.tableLoading = false
|
||||
} else {
|
||||
@@ -377,20 +375,20 @@ export default {
|
||||
this.editUserId = row.id
|
||||
this.userForm.selectedRoles = []
|
||||
this.userForm.selectedGroups = []
|
||||
for (const role of row.roles) {
|
||||
row.roles.forEach((role) => {
|
||||
if (role.id === '0') {
|
||||
this.userForm.selectedRoles.push(role.name)
|
||||
} else {
|
||||
this.userForm.selectedRoles.push(role.id)
|
||||
}
|
||||
}
|
||||
for (const group of row.groups) {
|
||||
})
|
||||
row.groups.forEach((group) => {
|
||||
if (group.id === '0') {
|
||||
this.userForm.selectedGroups.push(group.name)
|
||||
} else {
|
||||
this.userForm.selectedGroups.push(group.id)
|
||||
}
|
||||
}
|
||||
})
|
||||
this.userForm.enable = row.enable
|
||||
this.isAddNew = false
|
||||
this.dialogVisible = true
|
||||
@@ -455,18 +453,16 @@ export default {
|
||||
enable: this.userForm.enable
|
||||
}
|
||||
if (this.editUserId !== '1') {
|
||||
for (const roleId of this.userForm.selectedRoles) {
|
||||
const role = {
|
||||
this.userForm.selectedRoles.forEach((roleId) => {
|
||||
userObject.roles.push({
|
||||
id: roleId
|
||||
}
|
||||
userObject.roles.push(role)
|
||||
}
|
||||
for (const groupId of this.userForm.selectedGroups) {
|
||||
const group = {
|
||||
})
|
||||
})
|
||||
this.userForm.selectedGroups.forEach((groupId) => {
|
||||
userObject.groups.push({
|
||||
id: groupId
|
||||
}
|
||||
userObject.groups.push(group)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
if (this.isAddNew) {
|
||||
|
||||
Reference in New Issue
Block a user