封裝:element-ui之confirm消息提示框、確認提示彈框


封裝:element-ui之confirm消息提示框、確認提示彈框

src/utils/index.js


   
   
   
           
  1. /**
  2. * @author 封裝 element-ui confirm
  3. * @param text
  4. * @param title
  5. * @param config
  6. * @returns {Promise}
  7. */
  8. export function confirm(text, title = '溫磬提示', config = {}) {
  9. return new Promise((resolve, reject) => {
  10. let confirmButtonLoadingClose = () => {
  11. }
  12. let _config = merge({
  13. showCancelButton: true,
  14. closeOnClickModal: false,
  15. center: true
  16. }, config)
  17. let afterCloseResolve = () => {
  18. }
  19. _config.beforeClose = (action, instance, done) => {
  20. if (lodash.isFunction(config.beforeClose)) {
  21. config.beforeClose(action, instance, () => {
  22. })
  23. }
  24. if (lodash.isFunction(config.confirmCallBack)) {
  25. if (action === 'confirm') {
  26. instance.confirmButtonLoading = true
  27. confirmButtonLoadingClose = () => {
  28. instance.confirmButtonLoading = false
  29. }
  30. config.confirmCallBack({
  31. confirmButtonLoadingClose,
  32. close: () => new Promise((resolve, reject) => {
  33. done()
  34. afterCloseResolve = resolve
  35. }),
  36. action
  37. })
  38. } else {
  39. done()
  40. }
  41. }
  42. if (!config.confirmButtonLoading) {
  43. done()
  44. }
  45. }
  46. delete _config.confirmButtonLoading
  47. MessageBox.confirm(text, title, _config).then(_ => {
  48. afterCloseResolve()
  49. resolve()
  50. }).catch(err => {
  51. afterCloseResolve()
  52. reject(err)
  53. })
  54. })
  55. }

訂單池: src/views/fhb/temporary/Index.vue

 

提現審核:src/views/withdraw/index.vue

import {copy, dotData, alert, confirm} from '@/utils'
  
  
  
          

 

 

 

https://blog.csdn.net/qq_37126704/article/details/86701160


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM