modal.ts 2.2 KB

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