mirror of
https://github.com/jumpserver/lina.git
synced 2025-08-27 19:09:06 +00:00
perf: button disable add tip
This commit is contained in:
parent
51ffebb04f
commit
50077dd0ac
@ -93,7 +93,7 @@
|
|||||||
|
|
||||||
td .el-button.el-button--mini {
|
td .el-button.el-button--mini {
|
||||||
padding: 3px 6px;
|
padding: 3px 6px;
|
||||||
/*line-height: 1.5;*/
|
line-height: 1.5;
|
||||||
|
|
||||||
.el-icon--right {
|
.el-icon--right {
|
||||||
margin-bottom: 2px;
|
margin-bottom: 2px;
|
||||||
|
@ -29,9 +29,11 @@
|
|||||||
>
|
>
|
||||||
{{ option.group }}
|
{{ option.group }}
|
||||||
</div>
|
</div>
|
||||||
|
<el-tooltip :key="option.name" :content="option.tip" :disabled="!option.tip" open-delay="1000" placement="top">
|
||||||
<el-dropdown-item
|
<el-dropdown-item
|
||||||
:key="option.name"
|
:key="option.name"
|
||||||
:command="[option, action]"
|
:command="[option, action]"
|
||||||
|
:title="option.tip"
|
||||||
class="dropdown-item"
|
class="dropdown-item"
|
||||||
v-bind="{...option, icon: ''}"
|
v-bind="{...option, icon: ''}"
|
||||||
>
|
>
|
||||||
@ -41,6 +43,7 @@
|
|||||||
</span>
|
</span>
|
||||||
{{ option.title }}
|
{{ option.title }}
|
||||||
</el-dropdown-item>
|
</el-dropdown-item>
|
||||||
|
</el-tooltip>
|
||||||
</template>
|
</template>
|
||||||
</el-dropdown-menu>
|
</el-dropdown-menu>
|
||||||
</el-dropdown>
|
</el-dropdown>
|
||||||
@ -53,7 +56,7 @@
|
|||||||
v-bind="{...cleanButtonAction(action), icon: action.icon && action.icon.startsWith('el-') ? action.icon : ''}"
|
v-bind="{...cleanButtonAction(action), icon: action.icon && action.icon.startsWith('el-') ? action.icon : ''}"
|
||||||
@click="handleClick(action)"
|
@click="handleClick(action)"
|
||||||
>
|
>
|
||||||
<el-tooltip :content="action.tip" :disabled="!action.tip" placement="top">
|
<el-tooltip :content="action.tip" :disabled="!action.tip" :open-delay="1000" placement="top">
|
||||||
<span>
|
<span>
|
||||||
<span v-if="action.icon && !action.icon.startsWith('el-')" style="vertical-align: initial">
|
<span v-if="action.icon && !action.icon.startsWith('el-')" style="vertical-align: initial">
|
||||||
<i v-if="action.icon.startsWith('fa')" :class="'fa ' + action.icon" />
|
<i v-if="action.icon.startsWith('fa')" :class="'fa ' + action.icon" />
|
||||||
@ -108,6 +111,9 @@ export default {
|
|||||||
},
|
},
|
||||||
handleDropdownCallback(command) {
|
handleDropdownCallback(command) {
|
||||||
const [option, dropdown] = command
|
const [option, dropdown] = command
|
||||||
|
if (option.disabled) {
|
||||||
|
return
|
||||||
|
}
|
||||||
const defaultCallback = () => this.$log.debug('No callback found: ', option, dropdown)
|
const defaultCallback = () => this.$log.debug('No callback found: ', option, dropdown)
|
||||||
let callback = option.callback
|
let callback = option.callback
|
||||||
if (!callback) {
|
if (!callback) {
|
||||||
@ -122,6 +128,9 @@ export default {
|
|||||||
return toSentenceCase(s)
|
return toSentenceCase(s)
|
||||||
},
|
},
|
||||||
handleClick(action) {
|
handleClick(action) {
|
||||||
|
if (action.disabled) {
|
||||||
|
return
|
||||||
|
}
|
||||||
if (action && action.callback) {
|
if (action && action.callback) {
|
||||||
action.callback(action)
|
action.callback(action)
|
||||||
} else {
|
} else {
|
||||||
@ -168,7 +177,13 @@ export default {
|
|||||||
|
|
||||||
// 是否是disabled
|
// 是否是disabled
|
||||||
const can = this.checkItem(action, 'can')
|
const can = this.checkItem(action, 'can')
|
||||||
|
if (typeof can === 'string') {
|
||||||
|
action.disabled = true
|
||||||
|
action.tip = can
|
||||||
|
} else {
|
||||||
action.disabled = !can
|
action.disabled = !can
|
||||||
|
}
|
||||||
|
delete action['can']
|
||||||
|
|
||||||
if (action.dropdown) {
|
if (action.dropdown) {
|
||||||
action.dropdown = this.cleanActions(action.dropdown)
|
action.dropdown = this.cleanActions(action.dropdown)
|
||||||
@ -295,7 +310,9 @@ export default {
|
|||||||
|
|
||||||
.el-dropdown-menu__item {
|
.el-dropdown-menu__item {
|
||||||
&.is-disabled {
|
&.is-disabled {
|
||||||
color: var(--color-disabled)
|
color: var(--color-disabled);
|
||||||
|
cursor: not-allowed;
|
||||||
|
pointer-events: auto;
|
||||||
}
|
}
|
||||||
&:not(.is-disabled):hover {
|
&:not(.is-disabled):hover {
|
||||||
background-color: var(--color-disabled-background);
|
background-color: var(--color-disabled-background);
|
||||||
|
@ -87,11 +87,11 @@ export default {
|
|||||||
default: () => ''
|
default: () => ''
|
||||||
},
|
},
|
||||||
canImportCreate: {
|
canImportCreate: {
|
||||||
type: [Boolean, Function],
|
type: [Boolean, Function, String],
|
||||||
default: false
|
default: false
|
||||||
},
|
},
|
||||||
canImportUpdate: {
|
canImportUpdate: {
|
||||||
type: [Boolean, Function],
|
type: [Boolean, Function, String],
|
||||||
default: false
|
default: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -13,8 +13,8 @@ import DataActions from '@/components/DataActions/index.vue'
|
|||||||
import { createSourceIdCache } from '@/api/common'
|
import { createSourceIdCache } from '@/api/common'
|
||||||
import { cleanActions } from './utils'
|
import { cleanActions } from './utils'
|
||||||
|
|
||||||
const defaultTrue = { type: [Boolean, Function], default: true }
|
const defaultTrue = { type: [Boolean, Function, String], default: true }
|
||||||
const defaultFalse = { type: [Boolean, Function], default: false }
|
const defaultFalse = { type: [Boolean, Function, String], default: false }
|
||||||
export default {
|
export default {
|
||||||
name: 'LeftSide',
|
name: 'LeftSide',
|
||||||
components: {
|
components: {
|
||||||
|
@ -17,7 +17,7 @@ import ImExportDialog from './ImExportDialog.vue'
|
|||||||
import { cleanActions } from './utils'
|
import { cleanActions } from './utils'
|
||||||
import { assignIfNot } from '@/utils/common'
|
import { assignIfNot } from '@/utils/common'
|
||||||
|
|
||||||
const defaultTrue = { type: Boolean, default: true }
|
const defaultTrue = { type: [Boolean, Function, String], default: true }
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'RightSide',
|
name: 'RightSide',
|
||||||
@ -83,11 +83,11 @@ export default {
|
|||||||
default: () => []
|
default: () => []
|
||||||
},
|
},
|
||||||
canCreate: {
|
canCreate: {
|
||||||
type: [Boolean, Function],
|
type: [Boolean, Function, String],
|
||||||
default: false
|
default: false
|
||||||
},
|
},
|
||||||
canBulkUpdate: {
|
canBulkUpdate: {
|
||||||
type: [Boolean, Function],
|
type: [Boolean, Function, String],
|
||||||
default: false
|
default: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -94,11 +94,16 @@ export default {
|
|||||||
}
|
}
|
||||||
const defaults = {}
|
const defaults = {}
|
||||||
for (const [k, v] of Object.entries(actions)) {
|
for (const [k, v] of Object.entries(actions)) {
|
||||||
let hasPerm = v.action.split('|').some(i => this.hasActionPerm(i.trim()))
|
const hasPerm = v.action.split('|').some(i => this.hasActionPerm(i.trim()))
|
||||||
if (v.checkRoot) {
|
if (!hasPerm) {
|
||||||
hasPerm = hasPerm && !this.currentOrgIsRoot
|
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)
|
return Object.assign(defaults, this.headerActions)
|
||||||
},
|
},
|
||||||
@ -110,13 +115,22 @@ export default {
|
|||||||
extraQuery: this.extraQuery
|
extraQuery: this.extraQuery
|
||||||
})
|
})
|
||||||
const checkRoot = !(this.$route.meta?.disableOrgsChange === true)
|
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 = {
|
const formatterArgs = {
|
||||||
'columnsMeta.actions.formatterArgs.canUpdate': () => {
|
'columnsMeta.actions.formatterArgs.canUpdate': () => {
|
||||||
return this.hasActionPerm('change') && (!checkRoot || !this.currentOrgIsRoot)
|
return checkPermAndRoot('change')
|
||||||
},
|
},
|
||||||
'columnsMeta.actions.formatterArgs.canDelete': 'delete',
|
'columnsMeta.actions.formatterArgs.canDelete': 'delete',
|
||||||
'columnsMeta.actions.formatterArgs.canClone': () => {
|
'columnsMeta.actions.formatterArgs.canClone': () => {
|
||||||
return this.hasActionPerm('add') && (!checkRoot || !this.currentOrgIsRoot)
|
return checkPermAndRoot('add')
|
||||||
},
|
},
|
||||||
'columnsMeta.name.formatterArgs.can': 'view'
|
'columnsMeta.name.formatterArgs.can': 'view'
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user