feat: ✨ 全局crud的ElNotification提示,ElNotification的封装
This commit is contained in:
@@ -9,6 +9,7 @@ import { request } from '/@/utils/service';
|
||||
//扩展包
|
||||
import { FsExtendsEditor } from '@fast-crud/fast-extends';
|
||||
import '@fast-crud/fast-extends/dist/style.css';
|
||||
import { successMessage, successNotification } from '/@/utils/message';
|
||||
export default {
|
||||
async install(app: any, options: any) {
|
||||
// 先安装ui
|
||||
@@ -40,6 +41,14 @@ export default {
|
||||
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: {
|
||||
layout: 'multi-line',
|
||||
collapse: true,
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { ElMessage, MessageOptions } from 'element-plus';
|
||||
import { ElMessage, ElNotification, MessageOptions } from 'element-plus';
|
||||
|
||||
export function message(message: string, option?: MessageOptions) {
|
||||
ElMessage({ message, ...option });
|
||||
}
|
||||
export function successMessage(message: string, option?: MessageOptions) {
|
||||
ElMessage({ message, ...option, type: 'success' });
|
||||
ElMessage({ message, type: 'success' });
|
||||
}
|
||||
export function warningMessage(message: string, option?: MessageOptions) {
|
||||
ElMessage({ message, ...option, type: 'warning' });
|
||||
@@ -15,3 +15,19 @@ export function errorMessage(message: string, option?: MessageOptions) {
|
||||
export function infoMessage(message: string, option?: MessageOptions) {
|
||||
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' });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user