封装:element-ui之confirm消息提示框、确认提示弹框

src/utils/index.js

/**
 * @author 封装 element-ui confirm
 * @param text
 * @param title
 * @param config
 * @returns {Promise}
 */
export function confirm(text, title = '温磬提示', config = {}) {
  return new Promise((resolve, reject) => {
    let confirmButtonLoadingClose = () => {
    }
    let _config = merge({
      showCancelButton: true,
      closeOnClickModal: false,
      center: true
    }, config)
    let afterCloseResolve = () => {
    }
    _config.beforeClose = (action, instance, done) => {
      if (lodash.isFunction(config.beforeClose)) {
        config.beforeClose(action, instance, () => {
        })
      }
      if (lodash.isFunction(config.confirmCallBack)) {
        if (action === 'confirm') {
          instance.confirmButtonLoading = true
          confirmButtonLoadingClose = () => {
            instance.confirmButtonLoading = false
          }
          config.confirmCallBack({
            confirmButtonLoadingClose,
            close: () => new Promise((resolve, reject) => {
              done()
              afterCloseResolve = resolve
            }),
            action
          })
        } else {
          done()
        }
      }
      if (!config.confirmButtonLoading) {
        done()
      }
    }
    delete _config.confirmButtonLoading
    MessageBox.confirm(text, title, _config).then(_ => {
      afterCloseResolve()
      resolve()
    }).catch(err => {
      afterCloseResolve()
      reject(err)
    })
  })
}

订单池: src/views/fhb/temporary/Index.vue

封装:element-ui之confirm消息提示框、确认提示弹框_第1张图片

封装:element-ui之confirm消息提示框、确认提示弹框_第2张图片

 

提现审核:src/views/withdraw/index.vue

封装:element-ui之confirm消息提示框、确认提示弹框_第3张图片

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

封装:element-ui之confirm消息提示框、确认提示弹框_第4张图片

 

封装:element-ui之confirm消息提示框、确认提示弹框_第5张图片

封装:element-ui之confirm消息提示框、确认提示弹框_第6张图片

封装:element-ui之confirm消息提示框、确认提示弹框_第7张图片

 

 

你可能感兴趣的:(提示确认框,封装)