1
0
mirror of https://github.com/FatttSnake/Pinnacle-OA.git synced 2026-04-05 23:11:24 +08:00

Optimized table rendering speed

This commit is contained in:
2023-06-08 20:45:23 +08:00
parent 716e6947fc
commit b432149cdc
3 changed files with 50 additions and 63 deletions

View File

@@ -237,13 +237,12 @@ export default {
if (response.code === DATABASE_SELECT_OK) { if (response.code === DATABASE_SELECT_OK) {
const groups = response.data.records const groups = response.data.records
this.totalCount = response.data.total this.totalCount = response.data.total
for (const group of groups) { groups.forEach((group) => {
group.customColumn_1 = [] group.customColumn_1 = []
const roles = group.roles group.roles.forEach((role) => {
for (const role of roles) {
group.customColumn_1.push(role.name) group.customColumn_1.push(role.name)
} })
} })
this.groupTable = groups this.groupTable = groups
this.tableLoading = false this.tableLoading = false
} else { } else {
@@ -290,9 +289,9 @@ export default {
this.groupForm.inputGroupName = row.name this.groupForm.inputGroupName = row.name
this.editGroupId = row.id this.editGroupId = row.id
this.groupForm.selectedRoles = [] this.groupForm.selectedRoles = []
for (const role of row.roles) { row.roles.forEach((role) => {
this.groupForm.selectedRoles.push(role.id) this.groupForm.selectedRoles.push(role.id)
} })
this.groupForm.enable = row.enable this.groupForm.enable = row.enable
this.isAddNew = false this.isAddNew = false
this.dialogVisible = true this.dialogVisible = true
@@ -333,12 +332,11 @@ export default {
roles: [], roles: [],
enable: this.groupForm.enable enable: this.groupForm.enable
} }
for (const roleId of this.groupForm.selectedRoles) { this.groupForm.selectedRoles.forEach((roleId) => {
const role = { groupObject.roles.push({
id: roleId id: roleId
} })
groupObject.roles.push(role) })
}
if (this.isAddNew) { if (this.isAddNew) {
request.post('/group', groupObject).then((res) => { request.post('/group', groupObject).then((res) => {
const response = res.data const response = res.data

View File

@@ -244,20 +244,17 @@ export default {
if (response.code === DATABASE_SELECT_OK) { if (response.code === DATABASE_SELECT_OK) {
const roles = response.data.records const roles = response.data.records
this.totalCount = response.data.total this.totalCount = response.data.total
for (const role of roles) { roles.forEach((role) => {
role.customColumn_1 = [] role.customColumn_1 = []
const menus = role.menus role.operations.forEach((operation) => {
const elements = role.elements const element = _.find(role.elements, { id: operation.elementId })
const operations = role.operations
for (const operation of operations) {
const element = _.find(elements, { id: operation.elementId })
if (element.operations === undefined) { if (element.operations === undefined) {
element.operations = [] element.operations = []
} }
element.operations.push(operation) element.operations.push(operation)
} })
for (const element of elements) { role.elements.forEach((element) => {
const menu = _.find(menus, { id: element.menuId }) const menu = _.find(role.menus, { id: element.menuId })
if (menu.elements === undefined) { if (menu.elements === undefined) {
menu.elements = [] menu.elements = []
} }
@@ -270,8 +267,8 @@ export default {
role.customColumn_1.push( role.customColumn_1.push(
`${menu.name}/${element.name}/${_.join(operas, ';')}` `${menu.name}/${element.name}/${_.join(operas, ';')}`
) )
} })
} })
this.roleTable = roles this.roleTable = roles
this.tableLoading = false this.tableLoading = false
} else { } else {
@@ -301,28 +298,25 @@ export default {
const response = res.data const response = res.data
if (response.code === DATABASE_SELECT_OK) { if (response.code === DATABASE_SELECT_OK) {
const data = response.data const data = response.data
const menuList = data.menuList data.operationList.forEach((operation) => {
const elementList = data.elementList const element = _.find(data.elementList, { id: operation.elementId })
const operationList = data.operationList
for (const operation of operationList) {
const element = _.find(elementList, { id: operation.elementId })
if (element.children === undefined) { if (element.children === undefined) {
element.children = [] element.children = []
} }
element.children.push(operation) element.children.push(operation)
} })
for (const element of elementList) { data.elementList.forEach((element) => {
const menu = _.find(menuList, { id: element.menuId }) const menu = _.find(data.menuList, { id: element.menuId })
if (menu.children === undefined) { if (menu.children === undefined) {
menu.children = [] menu.children = []
} }
menu.children.push(element) menu.children.push(element)
} })
for (const menu of menuList) { data.menuList.forEach((menu) => {
if (menu.children.length === 1) { if (menu.children.length === 1) {
menu.children = menu.children[0].children menu.children = menu.children[0].children
} }
} })
this.powerOptions = data.menuList this.powerOptions = data.menuList
this.powerTree = data.menuList this.powerTree = data.menuList
this.dialogLoading = false this.dialogLoading = false
@@ -353,10 +347,10 @@ export default {
this.roleForm.selectedPower.clear() this.roleForm.selectedPower.clear()
this.roleForm.enable = row.enable this.roleForm.enable = row.enable
this.defaultSelectedPower = [] this.defaultSelectedPower = []
for (const operation of row.operations) { row.operations.forEach((operation) => {
this.defaultSelectedPower.push(operation.powerId) this.defaultSelectedPower.push(operation.powerId)
this.roleForm.selectedPower.add(operation.powerId) this.roleForm.selectedPower.add(operation.powerId)
} })
this.isAddNew = false this.isAddNew = false
this.dialogVisible = true this.dialogVisible = true
}, },
@@ -396,12 +390,11 @@ export default {
powers: [], powers: [],
enable: this.roleForm.enable enable: this.roleForm.enable
} }
for (const powerId of this.roleForm.selectedPower) { this.roleForm.selectedPower.forEach((powerId) => {
const power = { roleObject.powers.push({
id: powerId id: powerId
} })
roleObject.powers.push(power) })
}
if (this.isAddNew) { if (this.isAddNew) {
request.post('/role', roleObject).then((res) => { request.post('/role', roleObject).then((res) => {
const response = res.data const response = res.data

View File

@@ -313,19 +313,17 @@ export default {
if (response.code === DATABASE_SELECT_OK) { if (response.code === DATABASE_SELECT_OK) {
const users = response.data.records const users = response.data.records
this.totalCount = response.data.total this.totalCount = response.data.total
for (const user of users) { users.forEach((user) => {
user.name = user.username user.name = user.username
user.customColumn_1 = [] user.customColumn_1 = []
user.customColumn_2 = [] user.customColumn_2 = []
const roles = user.roles user.roles.forEach((role) => {
for (const role of roles) {
user.customColumn_1.push(role.name) user.customColumn_1.push(role.name)
} })
const groups = user.groups user.groups.forEach((group) => {
for (const group of groups) {
user.customColumn_2.push(group.name) user.customColumn_2.push(group.name)
} })
} })
this.userTable = users this.userTable = users
this.tableLoading = false this.tableLoading = false
} else { } else {
@@ -377,20 +375,20 @@ export default {
this.editUserId = row.id this.editUserId = row.id
this.userForm.selectedRoles = [] this.userForm.selectedRoles = []
this.userForm.selectedGroups = [] this.userForm.selectedGroups = []
for (const role of row.roles) { row.roles.forEach((role) => {
if (role.id === '0') { if (role.id === '0') {
this.userForm.selectedRoles.push(role.name) this.userForm.selectedRoles.push(role.name)
} else { } else {
this.userForm.selectedRoles.push(role.id) this.userForm.selectedRoles.push(role.id)
} }
} })
for (const group of row.groups) { row.groups.forEach((group) => {
if (group.id === '0') { if (group.id === '0') {
this.userForm.selectedGroups.push(group.name) this.userForm.selectedGroups.push(group.name)
} else { } else {
this.userForm.selectedGroups.push(group.id) this.userForm.selectedGroups.push(group.id)
} }
} })
this.userForm.enable = row.enable this.userForm.enable = row.enable
this.isAddNew = false this.isAddNew = false
this.dialogVisible = true this.dialogVisible = true
@@ -455,18 +453,16 @@ export default {
enable: this.userForm.enable enable: this.userForm.enable
} }
if (this.editUserId !== '1') { if (this.editUserId !== '1') {
for (const roleId of this.userForm.selectedRoles) { this.userForm.selectedRoles.forEach((roleId) => {
const role = { userObject.roles.push({
id: roleId id: roleId
} })
userObject.roles.push(role) })
} this.userForm.selectedGroups.forEach((groupId) => {
for (const groupId of this.userForm.selectedGroups) { userObject.groups.push({
const group = {
id: groupId id: groupId
} })
userObject.groups.push(group) })
}
} }
if (this.isAddNew) { if (this.isAddNew) {