2020-01-13 19:04:03 +08:00
|
|
|
|
//import "./assets/css/main.css";
|
2020-01-17 16:50:17 +08:00
|
|
|
|
import './assets/stylus/index.scss'
|
2019-12-27 17:53:17 +08:00
|
|
|
|
import "./assets/css/nzIcon.css";
|
2020-02-12 12:06:37 +08:00
|
|
|
|
import "./assets/css/main.css";
|
2019-11-29 15:00:26 +08:00
|
|
|
|
import 'element-ui/lib/theme-chalk/index.css';
|
|
|
|
|
|
import ElementUI from 'element-ui';
|
2019-12-26 17:28:04 +08:00
|
|
|
|
import 'xterm/dist/xterm.css'
|
2019-12-02 16:16:26 +08:00
|
|
|
|
import i18n from './components/common/i18n'
|
2019-11-29 15:00:26 +08:00
|
|
|
|
|
2019-11-28 18:23:49 +08:00
|
|
|
|
import Vue from 'vue'
|
2019-12-05 16:48:23 +08:00
|
|
|
|
import Vuex from 'vuex'
|
|
|
|
|
|
import store from './store/index';
|
2019-11-28 18:23:49 +08:00
|
|
|
|
import App from './App'
|
|
|
|
|
|
import router from './router'
|
2020-01-08 22:19:46 +08:00
|
|
|
|
import VueResource from 'vue-resource'
|
2019-12-02 16:16:26 +08:00
|
|
|
|
import axios from 'axios';
|
2019-12-09 19:23:20 +08:00
|
|
|
|
import {post, get, put, del} from './http.js'
|
2019-12-02 16:16:26 +08:00
|
|
|
|
|
|
|
|
|
|
import Pagination from "./components/common/pagination"; //引入全局分页组件
|
2019-12-17 17:17:30 +08:00
|
|
|
|
import searchInput from "./components/common/searchInput"; //搜索框组件
|
2020-01-08 22:19:46 +08:00
|
|
|
|
import elementSet from "./components/common/elementSet"; //自定义表头组件
|
|
|
|
|
|
|
2019-12-18 17:00:44 +08:00
|
|
|
|
import projectBox from './components/common/rightBox/projectBox'; //project弹框组件
|
|
|
|
|
|
import moduleBox from './components/common/rightBox/moduleBox'; //module弹框组件
|
2019-12-20 17:18:30 +08:00
|
|
|
|
import editEndpointBox from './components/common/rightBox/editEndpointBox'; //endpoint弹框组件
|
|
|
|
|
|
import addEndpointBox from './components/common/rightBox/addEndpointBox'; //endpoint弹框组件
|
2019-12-23 15:43:05 +08:00
|
|
|
|
import assetAddUnit from "./components/page/asset/assetAddUnit"; //资产添加组件
|
|
|
|
|
|
import assetEditUnit from "./components/page/asset/assetEditUnit"; //资产添加组件
|
2020-02-19 16:33:01 +08:00
|
|
|
|
import assetBox from "./components/common/rightBox/assetBox"; //资产添加组件
|
2019-12-24 17:31:51 +08:00
|
|
|
|
import alertConfigBox from "./components/common/rightBox/alertConfigBox"; //告警规则弹框组件
|
2020-01-10 18:16:25 +08:00
|
|
|
|
import dcConfigBox from "./components/common/popBox/dcConfig"; //idc配置弹框组件
|
2020-01-03 17:17:09 +08:00
|
|
|
|
import panelBox from "./components/common/rightBox/panelBox"; //面板弹框组件
|
2020-01-09 19:30:43 +08:00
|
|
|
|
import moduleListPop from "./components/page/asset/moduleListPop"; //面板弹框组件
|
2020-01-10 18:16:25 +08:00
|
|
|
|
import cabinetConfigBox from "./components/common/popBox/cabinetConfig"; //面板弹框组件
|
2020-02-21 17:57:19 +08:00
|
|
|
|
import dcBox from "./components/common/rightBox/dcBox"; //dc弹框
|
2020-03-11 12:27:00 +08:00
|
|
|
|
import modelBox from "./components/common/rightBox/modelBox"; //model弹框
|
2020-02-24 20:27:14 +08:00
|
|
|
|
import selectArea from "./components/common/popBox/selectArea"; //dc弹框
|
2020-02-27 21:57:54 +08:00
|
|
|
|
import PerfectScrollbar from "perfect-scrollbar";
|
|
|
|
|
|
import "perfect-scrollbar/css/perfect-scrollbar.css";
|
2020-03-18 19:22:45 +08:00
|
|
|
|
import loading from "./components/common/loading";
|
2019-12-16 17:14:58 +08:00
|
|
|
|
|
2019-12-02 16:16:26 +08:00
|
|
|
|
Vue.component("Pagination", Pagination);
|
2019-12-16 17:14:58 +08:00
|
|
|
|
Vue.component("searchInput", searchInput);
|
2020-01-08 22:19:46 +08:00
|
|
|
|
Vue.component("element-set", elementSet);
|
2019-12-18 17:00:44 +08:00
|
|
|
|
Vue.component("project-box", projectBox);
|
|
|
|
|
|
Vue.component("module-box", moduleBox);
|
2019-12-19 17:22:18 +08:00
|
|
|
|
Vue.component("edit-endpoint-box", editEndpointBox);
|
2019-12-20 17:18:30 +08:00
|
|
|
|
Vue.component("add-endpoint-box", addEndpointBox);
|
2020-02-19 16:33:01 +08:00
|
|
|
|
Vue.component("asset-box", assetBox);
|
2019-12-23 15:43:05 +08:00
|
|
|
|
Vue.component("assetAddUnit", assetAddUnit);
|
|
|
|
|
|
Vue.component("assetEditUnit", assetEditUnit);
|
2019-12-24 17:31:51 +08:00
|
|
|
|
Vue.component("alert-config-box", alertConfigBox);
|
2020-01-03 16:04:23 +08:00
|
|
|
|
Vue.component("idc-config-box", dcConfigBox);
|
2020-01-03 17:17:09 +08:00
|
|
|
|
Vue.component("panel-box", panelBox);
|
2020-01-09 19:30:43 +08:00
|
|
|
|
Vue.component("module-list-pop", moduleListPop);
|
2020-01-10 18:16:25 +08:00
|
|
|
|
Vue.component("cabinet-config-box", cabinetConfigBox);
|
2020-02-21 17:57:19 +08:00
|
|
|
|
Vue.component("dc-box", dcBox);
|
2020-03-11 12:27:00 +08:00
|
|
|
|
Vue.component("model-box", modelBox);
|
2020-02-24 20:27:14 +08:00
|
|
|
|
Vue.component("select-area", selectArea);
|
2020-03-18 19:22:45 +08:00
|
|
|
|
Vue.component('loading',loading);
|
2019-12-02 16:16:26 +08:00
|
|
|
|
|
2019-12-17 17:17:30 +08:00
|
|
|
|
Vue.prototype.$axios = axios;
|
2019-12-02 16:16:26 +08:00
|
|
|
|
Vue.prototype.$post = post;
|
|
|
|
|
|
Vue.prototype.$get = get;
|
2019-12-09 19:23:20 +08:00
|
|
|
|
Vue.prototype.$put = put;
|
|
|
|
|
|
Vue.prototype.$delete = del;
|
2020-03-09 18:05:43 +08:00
|
|
|
|
Vue.prototype.$tableHeight = { //列表页表格的高度
|
|
|
|
|
|
normal: 'calc(100% - 100px)', //常规高度,特例在下方定义
|
2020-03-18 16:00:06 +08:00
|
|
|
|
openSubList: { //打开二级列表后的高度
|
|
|
|
|
|
mainList: 'calc(100% - 60px)',
|
|
|
|
|
|
subList: ''
|
|
|
|
|
|
},
|
2020-03-09 18:05:43 +08:00
|
|
|
|
endpointQuery: 'calc(100% - 60px)', //特例:endpoint query页,没有翻页组件
|
|
|
|
|
|
};
|
2020-03-05 21:30:45 +08:00
|
|
|
|
Vue.prototype.toTop = (type, wrap) => { //top按钮公共方法
|
|
|
|
|
|
if (type == 'el') {
|
2020-03-06 17:53:36 +08:00
|
|
|
|
let currentTop = wrap.scrollTop;
|
|
|
|
|
|
let interval = currentTop/10;
|
|
|
|
|
|
let intervalFunc = setInterval(function(){ //花200ms分10次回到顶部,模拟动画效果
|
|
|
|
|
|
if (currentTop == 0) {
|
|
|
|
|
|
clearInterval(intervalFunc);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
currentTop = (currentTop - interval) < interval*0.5 ? 0 : currentTop - interval;
|
|
|
|
|
|
wrap.scrollTop = currentTop;
|
|
|
|
|
|
}
|
|
|
|
|
|
}, 20);
|
2020-03-05 21:30:45 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
let els = document.querySelectorAll(".el-table__body-wrapper");
|
2020-03-17 19:13:02 +08:00
|
|
|
|
if (wrap || wrap == 0) {
|
|
|
|
|
|
let currentTop = els[wrap].scrollTop;
|
2020-03-06 17:53:36 +08:00
|
|
|
|
let interval = currentTop/10;
|
|
|
|
|
|
let intervalFunc = setInterval(function(){ //花200ms分10次回到顶部,模拟动画效果
|
|
|
|
|
|
if (currentTop == 0) {
|
|
|
|
|
|
clearInterval(intervalFunc);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
currentTop = (currentTop - interval) < interval*0.5 ? 0 : currentTop - interval;
|
2020-03-17 19:13:02 +08:00
|
|
|
|
els[wrap].scrollTop = currentTop;
|
2020-03-06 17:53:36 +08:00
|
|
|
|
}
|
|
|
|
|
|
}, 20);
|
2020-03-17 19:13:02 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
for (let i = 0; i < els.length; i++) {
|
|
|
|
|
|
let currentTop = els[i].scrollTop;
|
|
|
|
|
|
let interval = currentTop/10;
|
|
|
|
|
|
let intervalFunc = setInterval(function(){ //花200ms分10次回到顶部,模拟动画效果
|
|
|
|
|
|
if (currentTop == 0) {
|
|
|
|
|
|
clearInterval(intervalFunc);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
currentTop = (currentTop - interval) < interval*0.5 ? 0 : currentTop - interval;
|
|
|
|
|
|
els[i].scrollTop = currentTop;
|
|
|
|
|
|
}
|
|
|
|
|
|
}, 20);
|
|
|
|
|
|
}
|
2020-03-05 21:30:45 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
Vue.prototype.gutterHandler = (tableClass) => {
|
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
|
let gutterCol = document.querySelector(tableClass + " col[name='gutter']");
|
|
|
|
|
|
//console.info(gutterCol.attributes['width'].value)
|
|
|
|
|
|
if (gutterCol.attributes['width'].value != '0') {
|
|
|
|
|
|
//console.info(gutterCol)
|
2020-03-13 17:55:56 +08:00
|
|
|
|
gutterCol.attributes['width'].value = '1';
|
2020-03-05 21:30:45 +08:00
|
|
|
|
document.querySelector(tableClass + ' .el-table__body').attributes['style'].value = "width: calc(100% - 10px)";
|
|
|
|
|
|
}
|
|
|
|
|
|
}, 1000)
|
|
|
|
|
|
}
|
2019-11-28 18:23:49 +08:00
|
|
|
|
|
2019-12-17 17:17:30 +08:00
|
|
|
|
Vue.config.productionTip = false;
|
|
|
|
|
|
Vue.use(ElementUI);
|
|
|
|
|
|
Vue.use(Vuex);
|
2020-01-08 22:19:46 +08:00
|
|
|
|
Vue.use(VueResource);
|
2019-12-04 13:45:37 +08:00
|
|
|
|
|
2020-02-27 21:57:54 +08:00
|
|
|
|
const el_scrollBar = el => {
|
|
|
|
|
|
//在元素上加点私货,名字随便取,确保不会和已有属性重复即可,我取名叫做_ps_
|
|
|
|
|
|
if (el._ps_ instanceof PerfectScrollbar) {
|
|
|
|
|
|
el._ps_.update();
|
|
|
|
|
|
} else {
|
|
|
|
|
|
//el上挂一份属性
|
2020-03-02 17:34:44 +08:00
|
|
|
|
el._ps_ = new PerfectScrollbar(el, {minScrollbarLength: 20});
|
2020-02-27 21:57:54 +08:00
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
Vue.directive("scrollBar", {
|
|
|
|
|
|
inserted(el, binding, vnode) {
|
|
|
|
|
|
const { arg } = binding;
|
|
|
|
|
|
if (arg === "el-table") {
|
|
|
|
|
|
el = el.querySelector(".el-table__body-wrapper");
|
|
|
|
|
|
!el && console.warn("未发现className为el-table__body-wrapper的dom");
|
2020-03-13 13:44:05 +08:00
|
|
|
|
} else if (arg === "el-dropdown") {
|
|
|
|
|
|
el = el.querySelector(".el-dropdown-menu");
|
|
|
|
|
|
!el && console.warn("未发现className为el-dropdown-menu的dom");
|
2020-02-27 21:57:54 +08:00
|
|
|
|
}
|
2020-03-13 13:44:05 +08:00
|
|
|
|
|
|
|
|
|
|
// 启用x轴后不让原生滚动条出来作乱
|
|
|
|
|
|
vnode.context.$nextTick(() => {
|
2020-03-13 19:17:19 +08:00
|
|
|
|
if (arg === "xterm") {
|
|
|
|
|
|
el = el.querySelector(".xterm-viewport");
|
|
|
|
|
|
!el && console.warn("未发现className为xterm-viewport的dom");
|
|
|
|
|
|
}
|
2020-03-13 13:44:05 +08:00
|
|
|
|
el.classList.add("ps");
|
|
|
|
|
|
el.addEventListener("ps-scroll-y", () =>
|
|
|
|
|
|
el.classList.add("ps")
|
|
|
|
|
|
);
|
|
|
|
|
|
el.addEventListener("ps-scroll-x", () =>
|
|
|
|
|
|
el.classList.add("ps")
|
|
|
|
|
|
);
|
2020-03-13 19:17:19 +08:00
|
|
|
|
//el上挂一份属性
|
|
|
|
|
|
el_scrollBar(el);
|
2020-03-13 13:44:05 +08:00
|
|
|
|
});
|
|
|
|
|
|
|
2020-02-27 21:57:54 +08:00
|
|
|
|
const rules = ["fixed", "absolute", "relative"];
|
|
|
|
|
|
if (!rules.includes(window.getComputedStyle(el, null).position)) {
|
|
|
|
|
|
console.error(
|
|
|
|
|
|
`perfect-scrollbar所在的容器的position属性必须是以下之一:${rules.join(
|
|
|
|
|
|
"、"
|
|
|
|
|
|
)}`
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
componentUpdated(el, binding, vnode, oldVnode) {
|
|
|
|
|
|
const { arg } = binding;
|
|
|
|
|
|
if (arg === "el-table") {
|
|
|
|
|
|
el = el.querySelector(".el-table__body-wrapper");
|
|
|
|
|
|
!el && console.warn("未发现className为el-table__body-wrapper的dom");
|
2020-03-13 13:44:05 +08:00
|
|
|
|
} else if (arg === "el-dropdown") {
|
|
|
|
|
|
el = el.querySelector(".el-dropdown-menu");
|
|
|
|
|
|
!el && console.warn("未发现className为el-dropdown-menu的dom");
|
2020-03-13 19:17:19 +08:00
|
|
|
|
}else if (arg === "xterm") {
|
|
|
|
|
|
el = el.querySelector(".xterm-viewport");
|
|
|
|
|
|
!el && console.warn("未发现className为xterm-viewport的dom");
|
2020-02-27 21:57:54 +08:00
|
|
|
|
}
|
2020-03-13 13:44:05 +08:00
|
|
|
|
setTimeout(() => {
|
|
|
|
|
|
el.classList.add("ps");
|
|
|
|
|
|
el.classList.add("ps--active-y");
|
|
|
|
|
|
el._ps_.update();
|
|
|
|
|
|
}, 1500)
|
|
|
|
|
|
|
2020-02-27 21:57:54 +08:00
|
|
|
|
try {
|
|
|
|
|
|
vnode.context.$nextTick(() => {
|
|
|
|
|
|
el_scrollBar(el);
|
|
|
|
|
|
});
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
|
console.error(error);
|
|
|
|
|
|
el_scrollBar(el);
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
|
2020-03-12 12:13:45 +08:00
|
|
|
|
const exceptClassName = ["config-dropdown", "nz-pop", "el-picker", "chart-box-dropdown", 'metric-dropdown', 'el-cascader__dropdown', "asset-dropdown", "no-style-class", 'el-message-box']; //clickoutside排除的class(白名单) no-style-class:没有任何样式的class
|
2019-12-04 13:45:37 +08:00
|
|
|
|
const clickoutside = {
|
|
|
|
|
|
// 初始化指令
|
|
|
|
|
|
bind(el, binding, vnode) {
|
|
|
|
|
|
function documentHandler(e) {
|
|
|
|
|
|
if (el.contains(e.target)) {
|
|
|
|
|
|
return false;
|
2020-02-25 18:59:23 +08:00
|
|
|
|
} else {
|
2020-02-27 15:47:44 +08:00
|
|
|
|
//console.info(e)
|
2020-02-25 18:59:23 +08:00
|
|
|
|
let flag = true;
|
2020-02-26 18:26:55 +08:00
|
|
|
|
top: for (let i = 0; i < e.path.length; i++) {
|
|
|
|
|
|
for (let j = 0; j < exceptClassName.length; j++) {
|
|
|
|
|
|
if (e.path[i].className && e.path[i].className.indexOf(exceptClassName[j]) != -1) {
|
2020-02-25 18:59:23 +08:00
|
|
|
|
flag = false;
|
2020-02-26 18:26:55 +08:00
|
|
|
|
break top;
|
2020-02-25 18:59:23 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if (!flag) {
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
2019-12-04 13:45:37 +08:00
|
|
|
|
}
|
|
|
|
|
|
// 判断指令中是否绑定了函数
|
|
|
|
|
|
if (binding.expression) {
|
|
|
|
|
|
// 如果绑定了函数 则调用那个函数,此处binding.value就是handleClose方法
|
|
|
|
|
|
if (binding.arg) {
|
|
|
|
|
|
binding.value(e, binding.arg);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
binding.value(e);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2019-12-05 16:48:23 +08:00
|
|
|
|
|
2019-12-04 13:45:37 +08:00
|
|
|
|
// 给当前元素绑定个私有变量,方便在unbind中可以解除事件监听
|
|
|
|
|
|
el.__vueClickOutside__ = documentHandler;
|
2020-02-25 18:59:23 +08:00
|
|
|
|
document.addEventListener('mousedown', documentHandler);
|
2019-12-04 13:45:37 +08:00
|
|
|
|
},
|
|
|
|
|
|
unbind(el, binding) {
|
|
|
|
|
|
// 解除事件监听
|
2020-02-25 18:59:23 +08:00
|
|
|
|
document.removeEventListener('mousedown', el.__vueClickOutside__);
|
2019-12-04 13:45:37 +08:00
|
|
|
|
delete el.__vueClickOutside__;
|
|
|
|
|
|
},
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
Vue.directive('clickoutside',
|
|
|
|
|
|
clickoutside
|
|
|
|
|
|
)
|
|
|
|
|
|
|
2019-11-28 18:23:49 +08:00
|
|
|
|
/* eslint-disable no-new */
|
2019-12-26 17:28:04 +08:00
|
|
|
|
window.vm = new Vue({
|
2019-11-28 18:23:49 +08:00
|
|
|
|
el: '#app',
|
|
|
|
|
|
router,
|
2019-12-02 16:16:26 +08:00
|
|
|
|
i18n,
|
2019-12-05 16:48:23 +08:00
|
|
|
|
store,
|
|
|
|
|
|
components: {App},
|
2019-11-28 18:23:49 +08:00
|
|
|
|
template: '<App/>'
|
|
|
|
|
|
})
|
2019-12-12 17:07:33 +08:00
|
|
|
|
|
2020-03-05 21:30:45 +08:00
|
|
|
|
export default vm;
|
2020-02-27 15:47:44 +08:00
|
|
|
|
/*router.beforeEach((to, from, next) => {
|
2019-12-12 17:07:33 +08:00
|
|
|
|
if (to.path === '/login') {
|
|
|
|
|
|
next()
|
|
|
|
|
|
} else {
|
2019-12-26 18:06:51 +08:00
|
|
|
|
let token = sessionStorage.getItem('nz-token');
|
2019-12-12 17:07:33 +08:00
|
|
|
|
if (token) {
|
|
|
|
|
|
next()
|
|
|
|
|
|
} else {
|
|
|
|
|
|
next({ path: '/dashboard' })
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2020-02-27 15:47:44 +08:00
|
|
|
|
})*/
|