import { objAssign, randomCode, numToFixed } from "@/plugins/utils";
// mixins
import commonMixins from "../mixins/common";
import privilegeMixins from "../mixins/privilege";

// components
import ClassSelect from "../components/ClassSelect.vue";
import CourseSelect from "../components/CourseSelect.vue";
import ExamSelect from "../components/ExamSelect.vue";
import TeachSelect from "../components/TeachSelect.vue";
import SemesterSelect from "../components/SemesterSelect.vue";
import InspectCollegeSelect from "../components/InspectCollegeSelect.vue";
import TeachCollegeSelect from "../components/TeachCollegeSelect.vue";
import SchoolSelect from "../components/SchoolSelect.vue";

const components = {
  ClassSelect,
  CourseSelect,
  ExamSelect,
  TeachSelect,
  SemesterSelect,
  InspectCollegeSelect,
  TeachCollegeSelect,
  SchoolSelect
};

export default {
  install: function(Vue) {
    // 实例方法
    Vue.prototype.$objAssign = objAssign;
    Vue.prototype.$randomCode = randomCode;
    Vue.prototype.$numToFixed = numToFixed;

    // 注册全局组件
    Object.keys(components).forEach(key => {
      Vue.component(key, components[key]);
    });

    //全局 mixins
    Vue.mixin(commonMixins);
    Vue.mixin(privilegeMixins);
  }
};
