mirror of
https://gitee.com/wonderful-code/buildadmin
synced 2024-11-21 22:55:36 +00:00
feat(baTable):独立出表格内部组件自动调用的鉴权方法,便于开发者重写
This commit is contained in:
parent
daae1db4e7
commit
e3a36267f3
@ -114,9 +114,11 @@
|
||||
/>
|
||||
|
||||
<!-- 按钮组 -->
|
||||
<!-- 只对默认的编辑、删除、排序按钮进行鉴权,其他按钮请通过 display 属性控制按钮是否显示 -->
|
||||
<div v-if="field.render == 'buttons' && field.buttons">
|
||||
<template v-for="(btn, idx) in field.buttons" :key="idx">
|
||||
<template v-if="btn.display ? btn.display(row, field) : true">
|
||||
<!-- 常规按钮 -->
|
||||
<el-button
|
||||
v-if="btn.render == 'basicButton'"
|
||||
v-blur
|
||||
@ -130,28 +132,15 @@
|
||||
<Icon :name="btn.icon" />
|
||||
<div v-if="btn.text" class="table-operate-text">{{ btn.text }}</div>
|
||||
</el-button>
|
||||
|
||||
<!-- 带提示信息的按钮 -->
|
||||
<el-tooltip
|
||||
v-if="btn.render == 'tipButton'"
|
||||
v-if="btn.render == 'tipButton' && ((btn.name == 'edit' && baTable.auth('edit')) || btn.name != 'edit')"
|
||||
:disabled="btn.title && !btn.disabledTip ? false : true"
|
||||
:content="btn.title ? t(btn.title) : ''"
|
||||
placement="top"
|
||||
>
|
||||
<el-button
|
||||
v-if="btn.name == 'edit'"
|
||||
v-auth="'edit'"
|
||||
v-blur
|
||||
@click="onButtonClick(btn)"
|
||||
:class="btn.class"
|
||||
class="table-operate"
|
||||
:type="btn.type"
|
||||
:disabled="btn.disabled && btn.disabled(row, field)"
|
||||
v-bind="btn.attr"
|
||||
>
|
||||
<Icon :name="btn.icon" />
|
||||
<div v-if="btn.text" class="table-operate-text">{{ btn.text }}</div>
|
||||
</el-button>
|
||||
<el-button
|
||||
v-else
|
||||
v-blur
|
||||
@click="onButtonClick(btn)"
|
||||
:class="btn.class"
|
||||
@ -164,8 +153,10 @@
|
||||
<div v-if="btn.text" class="table-operate-text">{{ btn.text }}</div>
|
||||
</el-button>
|
||||
</el-tooltip>
|
||||
|
||||
<!-- 带确认框的按钮 -->
|
||||
<el-popconfirm
|
||||
v-if="btn.render == 'confirmButton'"
|
||||
v-if="btn.render == 'confirmButton' && ((btn.name == 'delete' && baTable.auth('del')) || btn.name != 'delete')"
|
||||
:disabled="btn.disabled && btn.disabled(row, field)"
|
||||
v-bind="btn.popconfirm"
|
||||
@confirm="onButtonClick(btn)"
|
||||
@ -174,20 +165,6 @@
|
||||
<div class="ml-6">
|
||||
<el-tooltip :disabled="btn.title ? false : true" :content="btn.title ? t(btn.title) : ''" placement="top">
|
||||
<el-button
|
||||
v-if="btn.name == 'delete'"
|
||||
v-auth="'del'"
|
||||
v-blur
|
||||
:class="btn.class"
|
||||
class="table-operate"
|
||||
:type="btn.type"
|
||||
:disabled="btn.disabled && btn.disabled(row, field)"
|
||||
v-bind="btn.attr"
|
||||
>
|
||||
<Icon :name="btn.icon" />
|
||||
<div v-if="btn.text" class="table-operate-text">{{ btn.text }}</div>
|
||||
</el-button>
|
||||
<el-button
|
||||
v-else
|
||||
v-blur
|
||||
:class="btn.class"
|
||||
class="table-operate"
|
||||
@ -202,27 +179,15 @@
|
||||
</div>
|
||||
</template>
|
||||
</el-popconfirm>
|
||||
|
||||
<!-- 带提示的可拖拽按钮 -->
|
||||
<el-tooltip
|
||||
v-if="btn.render == 'moveButton'"
|
||||
v-if="btn.render == 'moveButton' && ((btn.name == 'weigh-sort' && baTable.auth('sortable')) || btn.name != 'weigh-sort')"
|
||||
:disabled="btn.title && !btn.disabledTip ? false : true"
|
||||
:content="btn.title ? t(btn.title) : ''"
|
||||
placement="top"
|
||||
>
|
||||
<el-button
|
||||
v-if="btn.name == 'weigh-sort'"
|
||||
v-auth="'sortable'"
|
||||
:class="btn.class"
|
||||
class="table-operate move-button"
|
||||
:type="btn.type"
|
||||
:disabled="btn.disabled && btn.disabled(row, field)"
|
||||
v-bind="btn.attr"
|
||||
>
|
||||
<Icon :name="btn.icon" />
|
||||
<div v-if="btn.text" class="table-operate-text">{{ btn.text }}</div>
|
||||
</el-button>
|
||||
<el-button
|
||||
v-else
|
||||
v-blur
|
||||
:class="btn.class"
|
||||
class="table-operate move-button"
|
||||
:type="btn.type"
|
||||
|
@ -17,20 +17,20 @@
|
||||
</el-button>
|
||||
</el-tooltip>
|
||||
<slot name="refreshAppend"></slot>
|
||||
<el-tooltip v-if="props.buttons.includes('add') && auth('add')" :content="t('Add')" placement="top">
|
||||
<el-tooltip v-if="props.buttons.includes('add') && baTable.auth('add')" :content="t('Add')" placement="top">
|
||||
<el-button v-blur @click="onAction('add')" class="table-header-operate" type="primary">
|
||||
<Icon name="fa fa-plus" />
|
||||
<span class="table-header-operate-text">{{ t('Add') }}</span>
|
||||
</el-button>
|
||||
</el-tooltip>
|
||||
<el-tooltip v-if="props.buttons.includes('edit') && auth('edit')" :content="t('Edit selected row')" placement="top">
|
||||
<el-tooltip v-if="props.buttons.includes('edit') && baTable.auth('edit')" :content="t('Edit selected row')" placement="top">
|
||||
<el-button v-blur @click="onAction('edit')" :disabled="!enableBatchOpt" class="table-header-operate" type="primary">
|
||||
<Icon name="fa fa-pencil" />
|
||||
<span class="table-header-operate-text">{{ t('Edit') }}</span>
|
||||
</el-button>
|
||||
</el-tooltip>
|
||||
<el-popconfirm
|
||||
v-if="props.buttons.includes('delete') && auth('del')"
|
||||
v-if="props.buttons.includes('delete') && baTable.auth('del')"
|
||||
@confirm="onAction('delete')"
|
||||
:confirm-button-text="t('Delete')"
|
||||
:cancel-button-text="t('Cancel')"
|
||||
@ -125,7 +125,7 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { reactive, computed, inject } from 'vue'
|
||||
import { debounce, auth } from '/@/utils/common'
|
||||
import { debounce } from '/@/utils/common'
|
||||
import type baTableClass from '/@/utils/baTable'
|
||||
import ComSearch from '/@/components/table/comSearch/index.vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { reactive } from 'vue'
|
||||
import { getArrayKey } from '/@/utils/common'
|
||||
import { auth, getArrayKey } from '/@/utils/common'
|
||||
import type { baTableApi } from '/@/api/common'
|
||||
import Sortable from 'sortablejs'
|
||||
import { findIndexRow } from '/@/components/table'
|
||||
@ -69,6 +69,15 @@ export default class baTable {
|
||||
this.initComSearch(!isUndefined(route) ? route.query : {})
|
||||
}
|
||||
|
||||
/**
|
||||
* 表格内部鉴权方法
|
||||
* 此方法在表头或表行组件内部自动调用,传递权限节点名,如:add、edit
|
||||
* 若需自定义表格内部鉴权,重写此方法即可
|
||||
*/
|
||||
auth(node: string) {
|
||||
return auth(node)
|
||||
}
|
||||
|
||||
/**
|
||||
* 运行前置函数
|
||||
* @param funName 函数名
|
||||
|
Loading…
Reference in New Issue
Block a user