modal.js 1.8 KB

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