Newer
Older
operation_web / src / main.js
@朱忠杰 朱忠杰 on 21 Jan 2021 3 KB 过滤器
// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from "vue";
import App from "./App";
import router from "./router";
// import ElementUI from "element-ui"; //引入js
import "@/element";
import "element-ui/lib/theme-chalk/index.css"; //引入css
import "@/assets/css/index.css";
import "@/assets/css/skincolor.scss";

Vue.config.productionTip = false;

// 引入vue-echarts组件库
let echarts = require("echarts/lib/echarts");
// 引入折线图/柱状图等组件
require("echarts/lib/chart/line");
require("echarts/lib/chart/radar");
// 引入提示框和title组件,图例
require("echarts/lib/component/title");
require("echarts/lib/component/legend");
require("echarts/lib/component/radar");
require("echarts/lib/component/tooltip");
require("echarts/lib/component/toolbox");
Vue.prototype.$echarts = echarts;

import moment from "moment";
Vue.prototype.moment = moment;
//引入公共方法
// import common from '../static/JS/common.js'
// Vue.prototype.$common = common
import "./assets/css/common.css";
import "./util/interface";
import "../static/font/font.css";

import nozzle from "./util/interface";
Vue.prototype.nozzle = nozzle;

import { http } from "./api/APIindex";
Vue.prototype.$http = http;

import components from "@/components/index.js"; // 注册全局组件
Vue.use(components);

import utils from "@/util/utils"; //公共方法
import initRules from "@/util/initRules"; // `初始化验证规则
import validate from "@/util/validate"; // 公共验证方法
Vue.prototype.$initRules = initRules;
Vue.prototype.$fn = utils;
Vue.prototype.$validate = validate;

import store from "@/store";

// Vue.use(ElementUI);
import Viewer from "v-viewer";

Vue.use(Viewer);
Viewer.setDefaults({
  zIndexInline: 9999
});

/** 权限指令,对按钮权限的控制 **/
Vue.directive("has", {
  inserted: function(el, binding) {
    if (!Vue.prototype.$_has(binding.value)) {
      el.parentNode.removeChild(el);
    }
  }
});

// 权限检查方法(且把该方法添加到vue原型中)
Vue.prototype.$_has = function(value) {
  let isExist = false;
  // 从浏览器缓存中获取权限数组(该数组在登入成功后拉取用户的权限信息时保存在浏览器的缓存中)
  var buttonpermsStr = sessionStorage.getItem("powerHandle");
  if (buttonpermsStr === undefined || buttonpermsStr == null) {
    return false;
  }
  if (buttonpermsStr.indexOf(value) >= 0) {
    // 若在按钮中定义的权限字段能在后端返回的权限数组中能找到,则该按钮可显示
    isExist = true;
  }
  return isExist;
};
Vue.filter("timefilter", function(time) {
  var H = parseInt(time / 3600);
  var M = parseInt((time / 60) % 60);
  if (M > 0) {
    return `${H}小时${M}分钟`;
  } else {
    return `${H}小时`;
  }
});

/* eslint-disable no-new */
const vue = new Vue({
  el: "#app",
  router,
  store,
  components: { App },
  template: "<App/>"
});
// window.addEventListener('load', function () {
//   vue.$router.replace('/index') // 列表页面的路由
// })