import formGlobal from "./global/formGlobal";
import formPlugin from "./global/formPlugin";
import cacheGlobal from "./global/cacheGlobal";
import dataGlobal from "./global/dataGlobal";
import formResourceGlobal from "./global/formResourceGlobal";
import formUserGlobal from "./global/formUserGlobal";
import apiForm from "./api/apiForm";
import apiOutAdmin from "./api/apiOutAdmin";
import jcqkDialog from "../../views/popup/formRender/jcqkDialog";
import {registerAxiosFormData} from "sasp-base";

const install = function (Vue, opts = {}) {
    apiForm.init(opts.SERVICE_URL || window.JAVA_URL);
    if(opts.ADMIN_URL){
        apiOutAdmin.init(opts.ADMIN_URL);
    }
    registerAxiosFormData(opts.SERVICE_URL || window.JAVA_URL);

    Vue.use(formUserGlobal,opts);
    Vue.use(formGlobal,opts);
    Vue.use(dataGlobal,opts);
    Vue.use(formResourceGlobal,opts);
    Vue.use(cacheGlobal,opts);
    Vue.prototype.FORM_GLOBAL = formGlobal;
    Vue.prototype.FORM_RES_GLOBAL = formResourceGlobal;
    Vue.prototype.FORM_PLUGIN = formPlugin;

    formPlugin.installTableViewsRenderComponent(jcqkDialog);

    Vue.prototype.CACHE_GLOBAL = cacheGlobal;
    Vue.prototype.FORM_USER_GLOBAL = formUserGlobal;
    if(!Vue.prototype.api){
        Vue.prototype.api = {};
    }
    Object.assign(Vue.prototype.api, apiForm.apis, apiOutAdmin.apis);
}

export default {
    install
};
