feat:【antd/ele】【组件】table-action 封装的代码统一(剩余部分)
This commit is contained in:
@@ -137,11 +137,11 @@ function handleButtonClick(action: ActionItem) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 监听props变化,强制重新计算 */
|
/** 监听 props 变化,强制重新计算 */
|
||||||
watch(
|
watch(
|
||||||
() => [props.actions, props.dropDownActions],
|
() => [props.actions, props.dropDownActions],
|
||||||
() => {
|
() => {
|
||||||
// 这里不需要额外处理,computed会自动重新计算
|
// 这里不需要额外处理,computed 会自动重新计算
|
||||||
},
|
},
|
||||||
{ deep: true },
|
{ deep: true },
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -3,13 +3,14 @@ export const ACTION_ICON = {
|
|||||||
UPLOAD: 'lucide:upload',
|
UPLOAD: 'lucide:upload',
|
||||||
ADD: 'lucide:plus',
|
ADD: 'lucide:plus',
|
||||||
EDIT: 'lucide:edit',
|
EDIT: 'lucide:edit',
|
||||||
DELETE: 'lucide:trash',
|
DELETE: 'lucide:trash-2',
|
||||||
REFRESH: 'lucide:refresh-cw',
|
REFRESH: 'lucide:refresh-cw',
|
||||||
SEARCH: 'lucide:search',
|
SEARCH: 'lucide:search',
|
||||||
FILTER: 'lucide:filter',
|
FILTER: 'lucide:filter',
|
||||||
MORE: 'lucide:ellipsis-vertical',
|
MORE: 'lucide:ellipsis-vertical',
|
||||||
VIEW: 'lucide:eye',
|
VIEW: 'lucide:eye',
|
||||||
COPY: 'lucide:copy',
|
COPY: 'lucide:copy',
|
||||||
|
CLOSE: 'lucide:x',
|
||||||
BOOK: 'lucide:book',
|
BOOK: 'lucide:book',
|
||||||
AUDIT: 'lucide:file-check',
|
AUDIT: 'lucide:file-check',
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<!-- add by 星语:参考 vben2 的方式,增加 TableAction 组件 -->
|
<!-- add by 星语:参考 vben2 的方式,增加 TableAction 组件 -->
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
// TODO @xingyu:要不要和 apps/web-antd/src/components/table-action/table-action.vue 代码风格,进一步风格对齐?现在每个方法,会有一些差异
|
||||||
import type { PropType } from 'vue';
|
import type { PropType } from 'vue';
|
||||||
|
|
||||||
import type { ActionItem, PopConfirm } from './typing';
|
import type { ActionItem, PopConfirm } from './typing';
|
||||||
@@ -42,20 +43,24 @@ const props = defineProps({
|
|||||||
|
|
||||||
const { hasAccessByCodes } = useAccess();
|
const { hasAccessByCodes } = useAccess();
|
||||||
|
|
||||||
|
/** 检查是否显示 */
|
||||||
function isIfShow(action: ActionItem): boolean {
|
function isIfShow(action: ActionItem): boolean {
|
||||||
const ifShow = action.ifShow;
|
const ifShow = action.ifShow;
|
||||||
|
|
||||||
let isIfShow = true;
|
let isIfShow = true;
|
||||||
|
|
||||||
if (isBoolean(ifShow)) {
|
if (isBoolean(ifShow)) {
|
||||||
isIfShow = ifShow;
|
isIfShow = ifShow;
|
||||||
}
|
}
|
||||||
if (isFunction(ifShow)) {
|
if (isFunction(ifShow)) {
|
||||||
isIfShow = ifShow(action);
|
isIfShow = ifShow(action);
|
||||||
}
|
}
|
||||||
|
if (isIfShow) {
|
||||||
|
isIfShow =
|
||||||
|
hasAccessByCodes(action.auth || []) || (action.auth || []).length === 0;
|
||||||
|
}
|
||||||
return isIfShow;
|
return isIfShow;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 处理按钮 actions */
|
||||||
const getActions = computed(() => {
|
const getActions = computed(() => {
|
||||||
return (toRaw(props.actions) || [])
|
return (toRaw(props.actions) || [])
|
||||||
.filter((action) => {
|
.filter((action) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user