import dialogComponent from '@/components/opsoft-dialog/opsoft-dialog.vue' export default (Vue) => { let dialogDom = null; let dialogCom = null; let dialogShow = true; function showDialog({title, content, cancelText, confirmText, click}) { if (!dialogCom) { dialogCom = Vue.extend(dialogComponent); } if (!dialogDom) { dialogDom = new dialogCom(); // dialogContentTextEllipsis: {type:Boolean, default:true}, //dialogMaskBackground: {type:String, default:''}, dialogDom.dialogTitle = title; dialogDom.dialogContent = content; dialogDom.dialogCancel = cancelText; dialogDom.dialogConfirm = confirmText; dialogDom.dialogShow = dialogShow; dialogDom.$mount(); dialogDom.dialogClickCallback = function(res, event){ dialogShow = false; dialogDom.dialogShow = dialogShow; click(res, event); }; document.body.children[1].children[0].appendChild(dialogDom.$el); } else { if (dialogShow) { dialogShow = false; dialogDom.dialogShow = dialogShow; } dialogShow = true; dialogDom.dialogTitle = title; dialogDom.dialogContent = content; dialogDom.dialogCancel = cancelText; dialogDom.dialogConfirm = confirmText; dialogDom.dialogShow = dialogShow; dialogDom.dialogClickCallback = function(res, event){ dialogShow = false; dialogDom.dialogShow = dialogShow; click(res, event); }; } } Vue.prototype.$dialog = {showDialog}; }