feat: 全局crud的ElNotification提示,ElNotification的封装

This commit is contained in:
H0nGzA1
2023-04-21 20:49:48 +08:00
parent 054bcf3eea
commit 25cc2c83c1
2 changed files with 27 additions and 2 deletions

View File

@@ -9,6 +9,7 @@ import { request } from '/@/utils/service';
//扩展包 //扩展包
import { FsExtendsEditor } from '@fast-crud/fast-extends'; import { FsExtendsEditor } from '@fast-crud/fast-extends';
import '@fast-crud/fast-extends/dist/style.css'; import '@fast-crud/fast-extends/dist/style.css';
import { successMessage, successNotification } from '/@/utils/message';
export default { export default {
async install(app: any, options: any) { async install(app: any, options: any) {
// 先安装ui // 先安装ui
@@ -40,6 +41,14 @@ export default {
return { records: res.data, currentPage: res.page, pageSize: res.limit, total: res.total }; return { records: res.data, currentPage: res.page, pageSize: res.limit, total: res.total };
}, },
}, },
form: {
afterSubmit(ctx: any) {
// 增加crud提示
if (ctx.res.code == 2000) {
successNotification(ctx.res.msg);
}
},
},
/* search: { /* search: {
layout: 'multi-line', layout: 'multi-line',
collapse: true, collapse: true,

View File

@@ -1,10 +1,10 @@
import { ElMessage, MessageOptions } from 'element-plus'; import { ElMessage, ElNotification, MessageOptions } from 'element-plus';
export function message(message: string, option?: MessageOptions) { export function message(message: string, option?: MessageOptions) {
ElMessage({ message, ...option }); ElMessage({ message, ...option });
} }
export function successMessage(message: string, option?: MessageOptions) { export function successMessage(message: string, option?: MessageOptions) {
ElMessage({ message, ...option, type: 'success' }); ElMessage({ message, type: 'success' });
} }
export function warningMessage(message: string, option?: MessageOptions) { export function warningMessage(message: string, option?: MessageOptions) {
ElMessage({ message, ...option, type: 'warning' }); ElMessage({ message, ...option, type: 'warning' });
@@ -15,3 +15,19 @@ export function errorMessage(message: string, option?: MessageOptions) {
export function infoMessage(message: string, option?: MessageOptions) { export function infoMessage(message: string, option?: MessageOptions) {
ElMessage({ message, ...option, type: 'info' }); ElMessage({ message, ...option, type: 'info' });
} }
export function notification(message: string) {
ElNotification({ message });
}
export function successNotification(message: string) {
ElNotification({ message, type: 'success' });
}
export function warningNotification(message: string) {
ElNotification({ message, type: 'warning' });
}
export function errorNotification(message: string) {
ElNotification({ message, type: 'error' });
}
export function infoNotification(message: string) {
ElNotification({ message, type: 'info' });
}