modal.js 2.3 KB

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