diff --git a/public/theme/element-extra.css b/public/theme/element-extra.css
index a0f729ef8..eed55f352 100644
--- a/public/theme/element-extra.css
+++ b/public/theme/element-extra.css
@@ -93,7 +93,7 @@
td .el-button.el-button--mini {
padding: 3px 6px;
- /*line-height: 1.5;*/
+ line-height: 1.5;
.el-icon--right {
margin-bottom: 2px;
diff --git a/src/components/DataActions/index.vue b/src/components/DataActions/index.vue
index bd776b604..bef6c23ad 100644
--- a/src/components/DataActions/index.vue
+++ b/src/components/DataActions/index.vue
@@ -29,18 +29,21 @@
>
{{ option.group }}
-
-
-
-
-
- {{ option.title }}
-
+
+
+
+
+
+
+ {{ option.title }}
+
+
@@ -53,7 +56,7 @@
v-bind="{...cleanButtonAction(action), icon: action.icon && action.icon.startsWith('el-') ? action.icon : ''}"
@click="handleClick(action)"
>
-
+
@@ -108,6 +111,9 @@ export default {
},
handleDropdownCallback(command) {
const [option, dropdown] = command
+ if (option.disabled) {
+ return
+ }
const defaultCallback = () => this.$log.debug('No callback found: ', option, dropdown)
let callback = option.callback
if (!callback) {
@@ -122,6 +128,9 @@ export default {
return toSentenceCase(s)
},
handleClick(action) {
+ if (action.disabled) {
+ return
+ }
if (action && action.callback) {
action.callback(action)
} else {
@@ -168,7 +177,13 @@ export default {
// 是否是disabled
const can = this.checkItem(action, 'can')
- action.disabled = !can
+ if (typeof can === 'string') {
+ action.disabled = true
+ action.tip = can
+ } else {
+ action.disabled = !can
+ }
+ delete action['can']
if (action.dropdown) {
action.dropdown = this.cleanActions(action.dropdown)
@@ -295,7 +310,9 @@ export default {
.el-dropdown-menu__item {
&.is-disabled {
- color: var(--color-disabled)
+ color: var(--color-disabled);
+ cursor: not-allowed;
+ pointer-events: auto;
}
&:not(.is-disabled):hover {
background-color: var(--color-disabled-background);
diff --git a/src/components/Table/ListTable/TableAction/ImportDialog.vue b/src/components/Table/ListTable/TableAction/ImportDialog.vue
index 6d056acd4..39f43e505 100644
--- a/src/components/Table/ListTable/TableAction/ImportDialog.vue
+++ b/src/components/Table/ListTable/TableAction/ImportDialog.vue
@@ -87,11 +87,11 @@ export default {
default: () => ''
},
canImportCreate: {
- type: [Boolean, Function],
+ type: [Boolean, Function, String],
default: false
},
canImportUpdate: {
- type: [Boolean, Function],
+ type: [Boolean, Function, String],
default: false
}
},
diff --git a/src/components/Table/ListTable/TableAction/LeftSide.vue b/src/components/Table/ListTable/TableAction/LeftSide.vue
index 8cb110f2f..b0a8c8b88 100644
--- a/src/components/Table/ListTable/TableAction/LeftSide.vue
+++ b/src/components/Table/ListTable/TableAction/LeftSide.vue
@@ -13,8 +13,8 @@ import DataActions from '@/components/DataActions/index.vue'
import { createSourceIdCache } from '@/api/common'
import { cleanActions } from './utils'
-const defaultTrue = { type: [Boolean, Function], default: true }
-const defaultFalse = { type: [Boolean, Function], default: false }
+const defaultTrue = { type: [Boolean, Function, String], default: true }
+const defaultFalse = { type: [Boolean, Function, String], default: false }
export default {
name: 'LeftSide',
components: {
diff --git a/src/components/Table/ListTable/TableAction/RightSide.vue b/src/components/Table/ListTable/TableAction/RightSide.vue
index d31fe92b7..c0c8fc3f9 100644
--- a/src/components/Table/ListTable/TableAction/RightSide.vue
+++ b/src/components/Table/ListTable/TableAction/RightSide.vue
@@ -17,7 +17,7 @@ import ImExportDialog from './ImExportDialog.vue'
import { cleanActions } from './utils'
import { assignIfNot } from '@/utils/common'
-const defaultTrue = { type: Boolean, default: true }
+const defaultTrue = { type: [Boolean, Function, String], default: true }
export default {
name: 'RightSide',
@@ -83,11 +83,11 @@ export default {
default: () => []
},
canCreate: {
- type: [Boolean, Function],
+ type: [Boolean, Function, String],
default: false
},
canBulkUpdate: {
- type: [Boolean, Function],
+ type: [Boolean, Function, String],
default: false
}
},
diff --git a/src/components/Table/ListTable/index.vue b/src/components/Table/ListTable/index.vue
index 9d45f0e80..08210f126 100644
--- a/src/components/Table/ListTable/index.vue
+++ b/src/components/Table/ListTable/index.vue
@@ -94,11 +94,16 @@ export default {
}
const defaults = {}
for (const [k, v] of Object.entries(actions)) {
- let hasPerm = v.action.split('|').some(i => this.hasActionPerm(i.trim()))
- if (v.checkRoot) {
- hasPerm = hasPerm && !this.currentOrgIsRoot
+ const hasPerm = v.action.split('|').some(i => this.hasActionPerm(i.trim()))
+ if (!hasPerm) {
+ defaults[k] = this.$t('NoPermission')
+ continue
}
- defaults[k] = hasPerm
+ if (v.checkRoot && this.currentOrgIsRoot) {
+ defaults[k] = this.$t('NoPermissionInGlobal')
+ continue
+ }
+ defaults[k] = true
}
return Object.assign(defaults, this.headerActions)
},
@@ -110,13 +115,22 @@ export default {
extraQuery: this.extraQuery
})
const checkRoot = !(this.$route.meta?.disableOrgsChange === true)
+ const checkPermAndRoot = (action) => {
+ if (!this.hasActionPerm(action)) {
+ return this.$t('NoPermission')
+ }
+ if (checkRoot && this.currentOrgIsRoot) {
+ return this.$t('NoPermissionInGlobal')
+ }
+ return true
+ }
const formatterArgs = {
'columnsMeta.actions.formatterArgs.canUpdate': () => {
- return this.hasActionPerm('change') && (!checkRoot || !this.currentOrgIsRoot)
+ return checkPermAndRoot('change')
},
'columnsMeta.actions.formatterArgs.canDelete': 'delete',
'columnsMeta.actions.formatterArgs.canClone': () => {
- return this.hasActionPerm('add') && (!checkRoot || !this.currentOrgIsRoot)
+ return checkPermAndRoot('add')
},
'columnsMeta.name.formatterArgs.can': 'view'
}