modal.ts 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. import { MessageBoxData } from 'element-plus';
  2. import { LoadingInstance } from 'element-plus/es/components/loading/src/loading';
  3. let loadingInstance: LoadingInstance;
  4. export default {
  5. // 消息提示
  6. msg(content: any) {
  7. ElMessage.info(content);
  8. },
  9. // 错误消息
  10. msgError(content: any) {
  11. ElMessage.error(content);
  12. },
  13. // 成功消息
  14. msgSuccess(content: any) {
  15. ElMessage.success(content);
  16. },
  17. // 警告消息
  18. msgWarning(content: any) {
  19. ElMessage.warning(content);
  20. },
  21. // 弹出提示
  22. alert(content: any) {
  23. ElMessageBox.alert(content, '系统提示');
  24. },
  25. // 错误提示
  26. alertError(content: any) {
  27. ElMessageBox.alert(content, '系统提示', { type: 'error' });
  28. },
  29. // 成功提示
  30. alertSuccess(content: any) {
  31. ElMessageBox.alert(content, '系统提示', { type: 'success' });
  32. },
  33. // 警告提示
  34. alertWarning(content: any) {
  35. ElMessageBox.alert(content, '系统提示', { type: 'warning' });
  36. },
  37. // 通知提示
  38. notify(content: any) {
  39. ElNotification.info(content);
  40. },
  41. // 错误通知
  42. notifyError(content: any) {
  43. ElNotification.error(content);
  44. },
  45. // 成功通知
  46. notifySuccess(content: any) {
  47. ElNotification.success(content);
  48. },
  49. // 警告通知
  50. notifyWarning(content: any) {
  51. ElNotification.warning(content);
  52. },
  53. // 确认窗体
  54. confirm(content: any): Promise<MessageBoxData> {
  55. return ElMessageBox.confirm(content, '系统提示', {
  56. confirmButtonText: '确定',
  57. cancelButtonText: '取消',
  58. type: 'warning'
  59. });
  60. },
  61. // 提交内容
  62. prompt(content: any) {
  63. return ElMessageBox.prompt(content, '系统提示', {
  64. confirmButtonText: '确定',
  65. cancelButtonText: '取消',
  66. type: 'warning'
  67. });
  68. },
  69. // 打开遮罩层
  70. loading(content: string) {
  71. loadingInstance = ElLoading.service({
  72. lock: true,
  73. text: content,
  74. background: 'rgba(0, 0, 0, 0.7)'
  75. });
  76. },
  77. // 关闭遮罩层
  78. closeLoading() {
  79. loadingInstance.close();
  80. }
  81. };