perf: 优化权限判断 (#1413)

* stash: 暂存 api 权限判断

* perf: 优化列表权限判断,通过 url 来

* perf: 优化权限判断

* perf: remove console

* perf: 还原默认值

* perf: 修改 detail

* perf: 修改路由

* perf: 修改路由

* perf: 修复 table perm

* perf: 修改 home

Co-authored-by: ibuler <ibuler@qq.com>
This commit is contained in:
fit2bot
2022-03-09 15:36:38 +08:00
committed by GitHub
parent 833dd305bf
commit 5897c52268
9 changed files with 93 additions and 60 deletions

View File

@@ -84,19 +84,11 @@ export default {
default: function() {
return {
hasUpdate: true, // can set function(row, value)
canUpdate: () => {
const notRootOrg = !this.$store.getters.currentOrgIsRoot
return notRootOrg && this.$hasCurrentResAction('change')
}, // can set function(row, value)
canUpdate: true, // can set function(row, value)
hasDelete: true, // can set function(row, value)
canDelete: () => {
return this.$hasCurrentResAction('delete')
},
canDelete: true,
hasClone: true,
canClone: () => {
const notRootOrg = !this.$store.getters.currentOrgIsRoot
return notRootOrg && this.$hasCurrentResAction('add')
},
canClone: true,
updateRoute: this.$route.name.replace('List', 'Update'),
cloneRoute: this.$route.name.replace('List', 'Create'),
performDelete: defaultPerformDelete,

View File

@@ -16,10 +16,7 @@ export default {
route: this.$route.name.replace('List', 'Detail'),
getRoute: null,
routeQuery: null,
permissions: this.$getCurrentResActionPerms('view'),
can: (col) => {
return this.$hasPerm(this.formatterArgs.permissions)
},
can: true,
getTitle({ col, row, cellValue }) {
return cellValue
}
@@ -42,7 +39,11 @@ export default {
})
},
disabled() {
return !this.formatterArgs.can(this.col)
let can = this.formatterArgs.can
if (typeof can === 'function') {
can = can(this.col)
}
return !can
}
},
methods: {
@@ -60,13 +61,14 @@ export default {
console.error('No route found')
return
}
let detailRoute = {}
let detailRoute = { replace: true }
if (typeof route === 'string') {
detailRoute.name = route
detailRoute.params = { id: this.row.id }
} else {
detailRoute = route
}
console.log('Route: ', detailRoute)
const routeQuery = this.formatterArgs.routeQuery
if (routeQuery && typeof routeQuery === 'object') {