封装: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
提现审核:src/views/withdraw/index.vue
import {copy, dotData, alert, confirm} from '@/utils'