dataease/frontend/src/components/msgCfm/index.js

46 lines
1.5 KiB
JavaScript
Raw Normal View History

2022-08-17 13:52:10 +08:00
export default {
methods: {
openMessageSuccess(text, type) {
2022-10-11 15:09:32 +08:00
const h = this.$createElement
const iconClass = `el-icon-${type || 'success'}`
const customClass = `de-message-${type || 'success'} de-message`
2022-08-17 13:52:10 +08:00
this.$message({
2022-10-11 15:09:32 +08:00
message: h('p', null, [h('span', null, this.$t(text))]),
2022-08-17 13:52:10 +08:00
iconClass,
2022-10-11 15:09:32 +08:00
customClass
})
2022-08-17 13:52:10 +08:00
},
2022-10-11 15:09:32 +08:00
handlerConfirm(options, confirmButtonTextInfo) {
const { title, content, type = 'danger', cb, confirmButtonText = confirmButtonTextInfo || this.$t('commons.delete'), showCancelButton = true, cancelButtonText = this.$t('commons.cancel'), cancelCb = () => {}, finallyCb = () => {} } = options
const text = content ? `<span>${this.$t(title)}</span><br><span class="use-html">${this.$t(content)}</span>` : this.$t(title)
const dangerouslyUseHTMLString = Boolean(content)
const customClass = `de-confirm de-confirm-fail ${dangerouslyUseHTMLString && 'de-use-html'}`
const confirmButtonClass = `de-confirm-${type}-btn de-confirm-btn`
2022-08-17 13:52:10 +08:00
this.$confirm(
text,
2022-10-11 15:09:32 +08:00
'',
2022-08-17 13:52:10 +08:00
{
confirmButtonText,
cancelButtonText,
showCancelButton,
2022-10-11 15:09:32 +08:00
cancelButtonClass: 'de-confirm-btn de-confirm-plain-cancel',
2022-08-17 13:52:10 +08:00
dangerouslyUseHTMLString,
confirmButtonClass,
customClass,
2022-10-11 15:09:32 +08:00
iconClass: 'el-icon-warning'
2022-08-17 13:52:10 +08:00
}
)
.then(() => {
2022-10-11 15:09:32 +08:00
cb()
2022-08-17 13:52:10 +08:00
})
2022-09-28 16:41:20 +08:00
.catch((action) => {
cancelCb(action)
})
.finally(() => {
finallyCb()
2022-10-11 15:09:32 +08:00
})
}
}
}