diff --git a/src/components/MFA/fun.js b/src/components/MFA/fun.js index f8192fe6..74ea3d15 100644 --- a/src/components/MFA/fun.js +++ b/src/components/MFA/fun.js @@ -2,12 +2,13 @@ import Vue from "vue"; import MFACOMP from "./index.vue"; const MFAConstructor = Vue.extend(MFACOMP); - +let MFAINSTANCELIST = []; const MFA = options => { const { UserId, username, EMail, callBack, cancelBack, status = 'login' } = options; if (!UserId) throw `UserId is requred.but ${UserId}` const id = `MFA${new Date().getTime()}`; const instance = new MFAConstructor(); + MFAINSTANCELIST.push(instance) instance.id = id; instance.vm = instance.$mount(); if (instance.vm.visible) return; @@ -20,7 +21,17 @@ const MFA = options => { if (cancelBack) cancelBack(); document.body.removeChild(instance.vm.$el); instance.vm.$destroy(); + let index = MFAINSTANCELIST.findIndex(item => item.id === id); + MFAINSTANCELIST.splice(index, 1) }); return instance.vm; } +MFA.close = () => { + if (MFAINSTANCELIST.length <= 0) return; + MFAINSTANCELIST.forEach(item => { + document.body.removeChild(item.vm.$el); + item.vm.$destroy(); + }) + MFAINSTANCELIST = []; +} export default MFA; \ No newline at end of file diff --git a/src/components/feedBack/fun.js b/src/components/feedBack/fun.js index 53ca553a..4991323d 100644 --- a/src/components/feedBack/fun.js +++ b/src/components/feedBack/fun.js @@ -1,17 +1,17 @@ import Vue from "vue"; import FEEDBACKCOMP from "./index.vue"; const FBConstructor = Vue.extend(FEEDBACKCOMP); - +let FBCINSTANCELIST = []; const FB = options => { const { type, callBack, cancelBack, trialId = null, Id = null, visitTaskId = null, SubjectVisitId = null } = options; if (!type) throw `type is requred.but ${type}` const id = `FB${new Date().getTime()}`; const instance = new FBConstructor(); + FBCINSTANCELIST.push(instance); instance.id = id; instance.vm = instance.$mount(); if (instance.vm.visible) return; document.body.appendChild(instance.vm.$el); - console.log(type); instance.vm.open({ type, trialId, Id, visitTaskId, SubjectVisitId }); instance.vm.$on("success", (Id) => { if (callBack) callBack(); @@ -20,8 +20,18 @@ const FB = options => { instance.vm.$on("closed", () => { document.body.removeChild(instance.vm.$el); instance.vm.$destroy(); + let index = FBCINSTANCELIST.findIndex(item => item.id === id); + FBCINSTANCELIST.splice(index, 1) if (cancelBack) cancelBack() }); return instance.vm; } +FB.close = () => { + if (FBCINSTANCELIST.length <= 0) return; + FBCINSTANCELIST.forEach(item => { + document.body.removeChild(item.vm.$el); + item.vm.$destroy(); + }) + FBCINSTANCELIST = []; +} export default FB; \ No newline at end of file diff --git a/src/components/feedBackTable/fun.js b/src/components/feedBackTable/fun.js index 7e970a9f..1e6f0a86 100644 --- a/src/components/feedBackTable/fun.js +++ b/src/components/feedBackTable/fun.js @@ -1,12 +1,13 @@ import Vue from "vue"; import FEEDBACKCOMP from "./index.vue"; const FBConstructor = Vue.extend(FEEDBACKCOMP); - +let FBCTABLEINSTANCELIST = []; const FBT = (options = {}) => { const { data = {}, callBack } = options; // if (!UserId) throw `UserId is requred.but ${UserId}` const id = `FB${new Date().getTime()}`; const instance = new FBConstructor(); + FBCTABLEINSTANCELIST.push(instance); instance.id = id; instance.vm = instance.$mount(); if (instance.vm.visible) return; @@ -18,7 +19,17 @@ const FBT = (options = {}) => { instance.vm.$on("closed", () => { document.body.removeChild(instance.vm.$el); instance.vm.$destroy(); + let index = FBCTABLEINSTANCELIST.findIndex(item => item.id === id); + FBCTABLEINSTANCELIST.splice(index, 1) }); return instance.vm; } +FBT.close = () => { + if (FBCTABLEINSTANCELIST.length <= 0) return; + FBCTABLEINSTANCELIST.forEach(item => { + document.body.removeChild(item.vm.$el); + item.vm.$destroy(); + }) + FBCTABLEINSTANCELIST = []; +} export default FBT; \ No newline at end of file diff --git a/src/main.js b/src/main.js index 1cc019d7..7b1423e2 100644 --- a/src/main.js +++ b/src/main.js @@ -381,6 +381,9 @@ async function VueInit() { if (_vm.$msgbox) { _vm.$msgbox.close(); } + _vm.$FB.close(); + _vm.$FBT.close(); + _vm.$MFA.close(); isOpen = false isLock = null zzSessionStorage.removeItem('isLock')