import { Message, MessageBox } from 'element-ui'
var windowWidth =
document.documentElement.clientWidth || document.body.clientWidth
export default {
message (option) {
const { type, duration, message } = option
windowWidth =
document.documentElement.clientWidth || document.body.clientWidth
Message({
type: type || 'error',
customClass: windowWidth <= 1024 ? 'my-message-width' : '',
duration: duration || 2000,
message: message
})
},
confrimMessage (option, callback,errback) {
const {
type,
message,
confirmButtonText,
cancelButtonText,
tips,
showCancelButton,
showConfirmButton,
closeOnClickModal
} = option
let showCancelButtonStatus =
showCancelButton === undefined ? true : showCancelButton
let showConfirmButtonStatus = showConfirmButton === undefined ? true : showConfirmButton
let msg = !type ? `确定要删除该${message}吗?` : message
let tipsMsg = tips ? tips : '提示'
windowWidth =
document.documentElement.clientWidth || document.body.clientWidth
MessageBox.confirm(msg, tipsMsg, {
confirmButtonText: confirmButtonText || '确定',
cancelButtonText: cancelButtonText || '取消',
type: type || 'error',
customClass: windowWidth <= 1024 ? `my-confirm-width ${showConfirmButton === undefined?'':'my-confirm-box-none'}` : (showConfirmButton=== undefined?'':'my-confirm-box-none'),
cancelButtonClass: 'my-confirm-cancel',
confirmButtonClass: `my-confirm-confirm ${showConfirmButton === undefined?'':'my-confirm-confirm-none'}`,
showCancelButton: showCancelButtonStatus,
showConfirmButton: showConfirmButtonStatus,
closeOnClickModal:closeOnClickModal===undefined?false:closeOnClickModal
})
.then(() => {
callback()
})
.catch(() => {
errback? errback():''
})
},
promptMessage (option, callback) {
const {
type,
message,
confirmButtonText,
cancelButtonText,
tips,
showCancelButton,
inputPattern,
inputType,
inputErrorMessage,
inputValidator,
closeOnClickModal,
showConfirmButton
} = option
let showCancelButtonStatus =
showCancelButton === undefined ? true : showCancelButton
let showConfirmButtonStatus = showConfirmButton === undefined ? true : showConfirmButton
let msg = !type ? `请输入${message}` : message
let tipsMsg = tips ? tips : '提示'
windowWidth =
document.documentElement.clientWidth || document.body.clientWidth
MessageBox.prompt(message, tipsMsg, {
confirmButtonText: confirmButtonText || '确定',
cancelButtonText: cancelButtonText || '取消',
customClass: windowWidth <= 1024 ? 'my-prompt-width' : 'my-prompt-box',
cancelButtonClass: 'my-prompt-cancel',
inputPlaceholder:msg,
confirmButtonClass: 'my-prompt-confirm',
showCancelButton: showCancelButtonStatus,
showConfirmButton: showConfirmButtonStatus,
inputPattern: inputPattern || '',
inputType: inputType || '',
inputErrorMessage: inputErrorMessage || '',
inputValidator: inputValidator || function vali () {},
closeOnClickModal: closeOnClickModal!==undefined?closeOnClickModal:true
})
.then((res) => {
callback(res)
})
.catch((err) => {
console.log(err,'取消')
})
}
}
import commonMessage from '@/utils/message'
Vue.prototype.$commonMessage = commonMessage
原文地址:https://blog.csdn.net/weixin_46328739/article/details/134738416
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如若转载,请注明出处:http://www.7code.cn/show_25054.html
如若内容造成侵权/违法违规/事实不符,请联系代码007邮箱:suwngjj01@126.com进行投诉反馈,一经查实,立即删除!
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。