@ecip/ecip-web
Version:
A magical vue admin. An out-of-box UI solution for enterprise applications. Newest development stack of vue. Lots of awesome features
76 lines (60 loc) • 1.38 kB
JavaScript
import Vue from 'vue'
import ErrorLogDialog from './ErrorLogDialog.vue'
import i18n from 'ecip-web/lang'
let onOk = function() {}
ErrorLogDialog.newInstance = properties => {
const _props = properties || {}
const Instance = new Vue({
i18n,
data: {},
render(h) {
return h(ErrorLogDialog, {
props: _props,
on: {
'on-close': function(selections) {
if (onOk) {
onOk(selections)
}
}
}
})
}
})
const component = Instance.$mount()
document.body.appendChild(component.$el)
const modal = Instance.$children[0]
return {
show(props) {
if (props && props.onOk) {
onOk = props.onOk
} else {
onOk = function() {}
}
modal.show(props)
},
component: modal
}
}
let modalInstance
function getModalInstance(props) {
modalInstance = modalInstance || ErrorLogDialog.newInstance(props)
return modalInstance
}
function confirm(props) {
const instance = getModalInstance(props)
props.onRemove = function() {
modalInstance = null
}
instance.show(props)
}
ErrorLogDialog.show = function(props) {
return confirm(props)
}
ErrorLogDialog.remove = function() {
if (!modalInstance) {
return false
}
const instance = getModalInstance()
instance.remove()
}
export default ErrorLogDialog