27 lines
892 B
JavaScript
27 lines
892 B
JavaScript
import Vue from "vue";
|
|
import FEEDBACKCOMP from "./index.vue";
|
|
const FBConstructor = Vue.extend(FEEDBACKCOMP);
|
|
|
|
const FB = options => {
|
|
const { type, callBack, cancelBack, trialId = null, Id = null, visitTaskId = null } = options;
|
|
if (!type) throw `type is requred.but ${type}`
|
|
const id = `FB${new Date().getTime()}`;
|
|
const instance = new FBConstructor();
|
|
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 });
|
|
instance.vm.$on("success", (Id) => {
|
|
if (callBack) callBack();
|
|
|
|
});
|
|
instance.vm.$on("closed", () => {
|
|
document.body.removeChild(instance.vm.$el);
|
|
instance.vm.$destroy();
|
|
if (cancelBack) cancelBack()
|
|
});
|
|
return instance.vm;
|
|
}
|
|
export default FB; |