feat: GhostButton component
This commit is contained in:
parent
1aa338ba34
commit
81d868aa61
21
apps/web-antd/src/components/global/button.ts
Normal file
21
apps/web-antd/src/components/global/button.ts
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
import { defineComponent, h } from 'vue';
|
||||||
|
|
||||||
|
import { Button } from 'ant-design-vue';
|
||||||
|
import buttonProps from 'ant-design-vue/es/button/buttonTypes';
|
||||||
|
import { omit } from 'lodash-es';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 表格操作列按钮专用
|
||||||
|
*/
|
||||||
|
export const GhostButton = defineComponent({
|
||||||
|
name: 'GhostButton',
|
||||||
|
props: omit(buttonProps(), ['type', 'ghost', 'size']),
|
||||||
|
setup(props, { attrs, slots }) {
|
||||||
|
return () =>
|
||||||
|
h(
|
||||||
|
Button,
|
||||||
|
{ ...props, ...attrs, type: 'primary', ghost: true, size: 'small' },
|
||||||
|
slots,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
});
|
@ -2,9 +2,13 @@ import type { App } from 'vue';
|
|||||||
|
|
||||||
import { Button as AButton } from 'ant-design-vue';
|
import { Button as AButton } from 'ant-design-vue';
|
||||||
|
|
||||||
|
import { GhostButton } from './button';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 全局组件注册
|
* 全局组件注册
|
||||||
*/
|
*/
|
||||||
export function setupGlobalComponent(app: App) {
|
export function setupGlobalComponent(app: App) {
|
||||||
app.use(AButton);
|
app.use(AButton);
|
||||||
|
// 表格操作列专用按钮
|
||||||
|
app.component('GhostButton', GhostButton);
|
||||||
}
|
}
|
||||||
|
@ -248,29 +248,28 @@ function handleResetPwd(record: Recordable<any>) {
|
|||||||
</template>
|
</template>
|
||||||
<template #action="{ row }">
|
<template #action="{ row }">
|
||||||
<template v-if="row.userId !== 1">
|
<template v-if="row.userId !== 1">
|
||||||
<a-button
|
<Space>
|
||||||
size="small"
|
<ghost-button
|
||||||
type="link"
|
|
||||||
v-access:code="['system:user:edit']"
|
v-access:code="['system:user:edit']"
|
||||||
@click.stop="handleEdit(row)"
|
@click.stop="handleEdit(row)"
|
||||||
>
|
>
|
||||||
{{ $t('pages.common.edit') }}
|
{{ $t('pages.common.edit') }}
|
||||||
</a-button>
|
</ghost-button>
|
||||||
<Popconfirm
|
<Popconfirm
|
||||||
|
:get-popup-container="getPopupContainer"
|
||||||
placement="left"
|
placement="left"
|
||||||
title="确认删除?"
|
title="确认删除?"
|
||||||
@confirm="handleDelete(row)"
|
@confirm="handleDelete(row)"
|
||||||
>
|
>
|
||||||
<a-button
|
<ghost-button
|
||||||
danger
|
danger
|
||||||
size="small"
|
|
||||||
type="link"
|
|
||||||
v-access:code="['system:user:remove']"
|
v-access:code="['system:user:remove']"
|
||||||
@click.stop=""
|
@click.stop=""
|
||||||
>
|
>
|
||||||
{{ $t('pages.common.delete') }}
|
{{ $t('pages.common.delete') }}
|
||||||
</a-button>
|
</ghost-button>
|
||||||
</Popconfirm>
|
</Popconfirm>
|
||||||
|
</Space>
|
||||||
<Dropdown
|
<Dropdown
|
||||||
:get-popup-container="getPopupContainer"
|
:get-popup-container="getPopupContainer"
|
||||||
placement="bottomRight"
|
placement="bottomRight"
|
||||||
|
1
apps/web-antd/types/global-components.d.ts
vendored
1
apps/web-antd/types/global-components.d.ts
vendored
@ -4,5 +4,6 @@ export {};
|
|||||||
declare module 'vue' {
|
declare module 'vue' {
|
||||||
export interface GlobalComponents {
|
export interface GlobalComponents {
|
||||||
AButton: typeof import('ant-design-vue/es/button')['default'];
|
AButton: typeof import('ant-design-vue/es/button')['default'];
|
||||||
|
GhostButton: typeof import('#/components/global/button')['GhostButton']
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user