2021-04-07 09:58:34 +08:00
|
|
|
// import '@/assets/stylus/index.scss'
|
2021-11-01 17:23:01 +08:00
|
|
|
// import 'element-ui/lib/theme-chalk/index.css'
|
2019-12-26 17:28:04 +08:00
|
|
|
import 'xterm/dist/xterm.css'
|
2021-04-07 09:58:34 +08:00
|
|
|
import '@/assets/css/main.scss'
|
2021-10-22 15:16:06 +08:00
|
|
|
import '@/assets/css/font/iconfont.js'
|
2021-04-07 09:58:34 +08:00
|
|
|
import ElementUI from 'element-ui'
|
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'
|
2021-03-19 18:52:19 +08:00
|
|
|
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'
|
2021-03-19 18:52:19 +08:00
|
|
|
import axios from 'axios'
|
|
|
|
|
import { hasPermission, hasButton } from './permission'
|
2020-04-15 22:01:56 +08:00
|
|
|
|
|
|
|
|
import plTable from 'pl-table'
|
|
|
|
|
import 'pl-table/themes/index.css'
|
|
|
|
|
|
2021-03-19 18:52:19 +08:00
|
|
|
import { post, get, put, del } from './http.js'
|
2022-02-24 13:43:20 +08:00
|
|
|
import { clickoutside, bottomBoxWindow, stringTimeParseToUnix, unixTimeParseToString, chartResizeTool, tableSet, cancelWithChange, myLoading } from './components/common/js/tools.js'
|
2021-03-19 18:52:19 +08:00
|
|
|
import * as tools from './components/common/js/tools.js'
|
2020-07-15 20:43:19 +08:00
|
|
|
import * as constants from './components/common/js/constants.js'
|
2019-12-02 16:16:26 +08:00
|
|
|
|
2021-03-19 18:52:19 +08:00
|
|
|
import Pagination from './components/common/pagination' // 引入全局分页组件
|
|
|
|
|
import searchInput from './components/common/searchInput' // 搜索框组件
|
|
|
|
|
import elementSet from './components/common/elementSet' // 自定义表头组件
|
2021-09-27 14:46:08 +08:00
|
|
|
import MyElSelect from './components/common/elSelect/MyElSelect'
|
2021-12-13 17:07:41 +08:00
|
|
|
import chartList from '@/components/chart/chartList.vue' // 全局引入 chartList 组件 防止 chart-group爆粗
|
2020-04-15 22:01:56 +08:00
|
|
|
|
2021-04-08 20:28:54 +08:00
|
|
|
import loading from '@/components/common/loading'
|
|
|
|
|
import pickTime from '@/components/common/pickTime'
|
|
|
|
|
import bus from '@/libs/bus'
|
2021-04-28 15:18:21 +08:00
|
|
|
import myDatePicker from '@/components/common/myDatePicker'
|
2021-08-31 10:14:41 +08:00
|
|
|
import vSelectPage from '@/components/common/v-selectpagenew'
|
2021-05-12 10:59:21 +08:00
|
|
|
import nzDataList from '@/components/common/table/nzDataList'
|
2021-05-07 11:16:17 +08:00
|
|
|
Vue.use(vSelectPage, {
|
|
|
|
|
dataLoad: function (vue, url, params) {
|
|
|
|
|
if (params.pageNumber) {
|
|
|
|
|
params.pageNo = params.pageNumber
|
|
|
|
|
}
|
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
|
get(url, params).then(res => {
|
|
|
|
|
resolve(res)
|
|
|
|
|
}, e => reject(e))
|
|
|
|
|
})
|
|
|
|
|
}
|
2021-08-31 10:14:41 +08:00
|
|
|
})
|
2021-04-28 15:18:21 +08:00
|
|
|
Vue.use(myDatePicker)
|
2021-03-19 18:52:19 +08:00
|
|
|
Vue.component('Pagination', Pagination)
|
|
|
|
|
Vue.component('searchInput', searchInput)
|
|
|
|
|
Vue.component('element-set', elementSet)
|
|
|
|
|
Vue.component('loading', loading)
|
|
|
|
|
Vue.component('pick-time', pickTime)
|
2021-04-28 15:18:21 +08:00
|
|
|
Vue.component('myDatePicker', myDatePicker)
|
2021-05-12 10:59:21 +08:00
|
|
|
Vue.component('nzDataList', nzDataList)
|
2021-12-13 17:07:41 +08:00
|
|
|
Vue.component('chartList', chartList)
|
2019-12-16 17:14:58 +08:00
|
|
|
|
2021-03-19 18:52:19 +08:00
|
|
|
Vue.prototype.$axios = axios
|
|
|
|
|
Vue.prototype.$post = post
|
|
|
|
|
Vue.prototype.$get = get
|
|
|
|
|
Vue.prototype.$put = put
|
|
|
|
|
Vue.prototype.$delete = del
|
|
|
|
|
Vue.prototype.$CONSTANTS = constants
|
|
|
|
|
Vue.prototype.$TOOLS = tools
|
|
|
|
|
Vue.prototype.$bottomBoxWindow = bottomBoxWindow // 底部上滑框控制
|
|
|
|
|
Vue.prototype.$stringTimeParseToUnix = stringTimeParseToUnix
|
|
|
|
|
Vue.prototype.$unixTimeParseToString = unixTimeParseToString
|
|
|
|
|
Vue.prototype.$chartResizeTool = chartResizeTool
|
|
|
|
|
Vue.prototype.$tableSet = tableSet
|
|
|
|
|
Vue.prototype.$tableHeight = { // 列表页表格的高度
|
2021-04-07 09:58:34 +08:00
|
|
|
normal: 'calc(100% - 48px)', // 常规高度,特例在下方定义
|
2021-08-29 21:35:04 +08:00
|
|
|
assetList: 'calc(100% - 57px)',
|
|
|
|
|
profile: 'calc(100% - 78px)',
|
2021-03-19 18:52:19 +08:00
|
|
|
openSubList: { // 打开二级列表后的高度
|
2020-03-18 16:00:06 +08:00
|
|
|
mainList: 'calc(100% - 60px)',
|
2021-08-29 21:35:04 +08:00
|
|
|
subList: 'calc(100% - 25px)',
|
|
|
|
|
subListFromAsset: 'calc(100% - 45px)',
|
2020-04-21 18:00:21 +08:00
|
|
|
toTopBtnTop: 'calc(50% - 11px)'
|
2020-03-18 16:00:06 +08:00
|
|
|
},
|
2020-04-21 18:00:21 +08:00
|
|
|
toTopBtnTop: 'calc(100% - 73px)',
|
2021-03-19 18:52:19 +08:00
|
|
|
noPagination: 'calc(100% - 60px)' // 特例:没有翻页组件
|
|
|
|
|
}
|
2019-11-28 18:23:49 +08:00
|
|
|
|
2020-10-16 19:26:50 +08:00
|
|
|
Vue.mixin({
|
2021-03-19 18:52:19 +08:00
|
|
|
data: function () {
|
2020-12-21 11:51:58 +08:00
|
|
|
return {
|
2021-03-19 18:52:19 +08:00
|
|
|
prevent_opt: {
|
|
|
|
|
save: false,
|
|
|
|
|
import: false,
|
2021-04-12 13:00:59 +08:00
|
|
|
duplicate: false,
|
2021-03-19 18:52:19 +08:00
|
|
|
delete: false,
|
|
|
|
|
refresh: false,
|
|
|
|
|
query: false
|
2021-11-01 17:23:01 +08:00
|
|
|
}
|
2020-12-21 11:51:58 +08:00
|
|
|
}
|
|
|
|
|
},
|
2020-12-17 11:07:57 +08:00
|
|
|
methods: {
|
2021-03-19 18:52:19 +08:00
|
|
|
utcTimeToTimezone: function (time) {
|
|
|
|
|
if (time) {
|
2020-12-17 11:07:57 +08:00
|
|
|
return bus.UTCTimeToConfigTimezone(time)
|
2020-12-04 20:53:58 +08:00
|
|
|
}
|
|
|
|
|
},
|
2021-12-30 19:17:22 +08:00
|
|
|
utcTimeToTimezoneStr: function (time) {
|
2021-03-19 18:52:19 +08:00
|
|
|
if (time) {
|
2021-12-31 16:41:30 +08:00
|
|
|
return bus.timeFormate(bus.UTCTimeToConfigTimezone(time), localStorage.getItem('nz-default-dateFormat') ? localStorage.getItem('nz-default-dateFormat') : localStorage.getItem('nz-default-dateFormat') ? localStorage.getItem('nz-default-dateFormat') : 'YYYY-MM-DD HH:mm:ss')
|
2021-03-19 18:52:19 +08:00
|
|
|
} else {
|
2020-12-17 11:07:57 +08:00
|
|
|
return '-'
|
2020-12-04 20:53:58 +08:00
|
|
|
}
|
2020-12-17 11:07:57 +08:00
|
|
|
},
|
2021-03-19 18:52:19 +08:00
|
|
|
timezoneToUtcTime: function (time) {
|
|
|
|
|
if (time) {
|
2020-12-17 11:07:57 +08:00
|
|
|
return bus.configTimezoneToUTCTime(time)
|
|
|
|
|
}
|
|
|
|
|
},
|
2022-01-06 13:50:56 +08:00
|
|
|
timezoneToUtcTimeStr: function (time, fmt) {
|
|
|
|
|
if (!fmt) {
|
|
|
|
|
fmt = localStorage.getItem('nz-default-dateFormat') || 'YYYY-MM-DD HH:mm:ss'
|
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
if (time) {
|
2022-01-06 13:50:56 +08:00
|
|
|
return bus.timeFormate(this.timezoneToUtcTime(time), fmt)
|
2020-12-17 11:07:57 +08:00
|
|
|
}
|
|
|
|
|
},
|
2022-02-24 13:43:20 +08:00
|
|
|
timestampStr: function (time, fmt) {
|
2021-11-02 18:34:00 +08:00
|
|
|
const date = new Date(time)
|
|
|
|
|
const localOffset = date.getTimezoneOffset() * 60 * 1000 // 默认 一分钟显示时区偏移的结果
|
2021-12-30 19:17:22 +08:00
|
|
|
const dateStr = new Date(time).getTime() + localOffset
|
2022-02-24 13:43:20 +08:00
|
|
|
if (!fmt) {
|
|
|
|
|
fmt = localStorage.getItem('nz-default-dateFormat') || 'YYYY-MM-DD HH:mm:ss'
|
|
|
|
|
}
|
2021-11-02 18:34:00 +08:00
|
|
|
if (time) {
|
2022-02-24 13:43:20 +08:00
|
|
|
return bus.timeFormate(bus.UTCTimeToConfigTimezone(dateStr), fmt)
|
2021-11-02 18:34:00 +08:00
|
|
|
} else {
|
|
|
|
|
return '-'
|
|
|
|
|
}
|
|
|
|
|
},
|
2021-03-19 18:52:19 +08:00
|
|
|
hasButton (code) {
|
|
|
|
|
return hasButton(this.$store.getters.buttonList, code)
|
2020-12-17 11:07:57 +08:00
|
|
|
},
|
2021-03-19 18:52:19 +08:00
|
|
|
numberWithEConvent (num) {
|
2020-12-24 18:45:12 +08:00
|
|
|
if (num) {
|
2021-03-19 18:52:19 +08:00
|
|
|
if ((('' + num).indexOf('E') !== -1) || (('' + num).indexOf('e') !== -1)) {
|
|
|
|
|
const regExp = /'^((\\d+.?\\d+)[Ee]{1}(\\d+))$', 'ig'/
|
|
|
|
|
let result = regExp.exec(num)
|
|
|
|
|
let resultValue = ''
|
|
|
|
|
let power
|
2020-12-24 18:45:12 +08:00
|
|
|
if (result != null) {
|
2021-03-19 18:52:19 +08:00
|
|
|
resultValue = result[2]
|
|
|
|
|
power = result[3]
|
|
|
|
|
result = regExp.exec(num)
|
2020-12-24 18:45:12 +08:00
|
|
|
}
|
|
|
|
|
|
2021-03-19 18:52:19 +08:00
|
|
|
if (resultValue) {
|
|
|
|
|
if (power) {
|
|
|
|
|
const powVer = Math.pow(10, power)
|
|
|
|
|
resultValue = resultValue * powVer
|
|
|
|
|
return resultValue
|
2020-12-24 18:45:12 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
2021-03-19 18:52:19 +08:00
|
|
|
return num
|
2020-12-24 18:45:12 +08:00
|
|
|
}
|
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
return 0
|
2020-12-24 18:45:12 +08:00
|
|
|
},
|
2021-03-19 18:52:19 +08:00
|
|
|
translation (key) {
|
|
|
|
|
return i18n.t(key)
|
2021-03-05 20:34:58 +08:00
|
|
|
},
|
2022-01-05 18:01:30 +08:00
|
|
|
timeFormatStrToDatePickFormat (str, flag) {
|
|
|
|
|
if (flag) {
|
2022-01-04 15:36:55 +08:00
|
|
|
const reg = /Y/g
|
|
|
|
|
str = str.replace(reg, 'y')
|
|
|
|
|
const reg1 = /D/g
|
|
|
|
|
str = str.replace(reg1, 'd')
|
|
|
|
|
const reg2 = /[H,m,s,:]/g
|
|
|
|
|
str = str.replace(reg2, '')
|
|
|
|
|
return str
|
|
|
|
|
} else {
|
|
|
|
|
const reg = /Y/g
|
|
|
|
|
str = str.replace(reg, 'y')
|
|
|
|
|
const reg1 = /D/g
|
|
|
|
|
str = str.replace(reg1, 'd')
|
|
|
|
|
return str
|
|
|
|
|
}
|
2022-01-04 10:55:36 +08:00
|
|
|
},
|
2021-03-19 18:52:19 +08:00
|
|
|
copyRow (row, rightBoxValKey, idKey = 'id', show = false, format, callback) {
|
2021-03-12 18:04:17 +08:00
|
|
|
/*
|
|
|
|
|
row 表格当前行
|
|
|
|
|
rightBoxValKey 右侧弹窗绑定的 data
|
|
|
|
|
idKey 当前数据的唯一标识
|
|
|
|
|
show 打开对应的弹窗 函数
|
|
|
|
|
format 是否需要对当前行进行处理
|
|
|
|
|
callBack 回调
|
|
|
|
|
*/
|
2021-03-19 18:52:19 +08:00
|
|
|
let rowCopy = { ...row }
|
|
|
|
|
if (rowCopy.name) {
|
|
|
|
|
rowCopy.name = 'Copy from ' + rowCopy.name
|
2021-03-18 13:58:55 +08:00
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
if (format) {
|
|
|
|
|
rowCopy = format(rowCopy)
|
2021-03-12 18:04:17 +08:00
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
delete rowCopy[idKey]
|
|
|
|
|
this[rightBoxValKey] = rowCopy
|
|
|
|
|
if (typeof show === 'function') {
|
2021-03-12 18:04:17 +08:00
|
|
|
show()
|
2021-03-19 18:52:19 +08:00
|
|
|
} else if (typeof show === 'string') {
|
|
|
|
|
this[show] = true
|
|
|
|
|
} else {
|
|
|
|
|
this.rightBox.show = true
|
2021-03-12 18:04:17 +08:00
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
if (callback) {
|
2021-03-12 18:04:17 +08:00
|
|
|
callback()
|
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
}
|
2020-12-17 11:07:57 +08:00
|
|
|
},
|
|
|
|
|
computed: {
|
2022-01-04 14:57:59 +08:00
|
|
|
timeFormatMain () {
|
|
|
|
|
return this.$store.getters.getTimeFormatMain
|
|
|
|
|
},
|
2021-03-19 18:52:19 +08:00
|
|
|
getMenuList () {
|
|
|
|
|
return this.$store.state.user.menuList
|
2020-12-17 11:07:57 +08:00
|
|
|
},
|
2021-03-19 18:52:19 +08:00
|
|
|
getButtonList () {
|
|
|
|
|
return this.$store.state.buttonList
|
2021-04-15 12:55:11 +08:00
|
|
|
},
|
2021-11-01 17:23:01 +08:00
|
|
|
$routePath () {
|
2021-04-15 12:55:11 +08:00
|
|
|
return this.$route.path
|
2020-12-17 11:07:57 +08:00
|
|
|
}
|
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
})
|
2020-10-16 19:26:50 +08:00
|
|
|
|
2021-03-19 18:52:19 +08:00
|
|
|
Vue.config.productionTip = false
|
|
|
|
|
Vue.use(ElementUI)
|
|
|
|
|
Vue.use(Vuex)
|
|
|
|
|
Vue.use(VueResource)
|
|
|
|
|
Vue.use(plTable)
|
2021-09-27 14:46:08 +08:00
|
|
|
Vue.component('el-select', MyElSelect)
|
2021-03-19 18:52:19 +08:00
|
|
|
Vue.use(hasPermission)
|
2019-12-04 13:45:37 +08:00
|
|
|
|
2021-03-19 18:52:19 +08:00
|
|
|
/* 指令 */
|
|
|
|
|
Vue.directive('cancel', cancelWithChange)
|
|
|
|
|
Vue.directive('clickoutside', clickoutside)
|
2022-02-24 13:43:20 +08:00
|
|
|
Vue.directive('myLoading', myLoading)
|
2021-03-19 18:52:19 +08:00
|
|
|
window.resizing = false
|
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,
|
2021-03-19 18:52:19 +08:00
|
|
|
components: { App },
|
2020-12-04 20:53:58 +08:00
|
|
|
template: '<App/>',
|
2021-03-19 18:52:19 +08:00
|
|
|
mounted () {
|
|
|
|
|
// store.commit()
|
2020-12-04 20:53:58 +08:00
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
})
|
2019-12-12 17:07:33 +08:00
|
|
|
|
2021-03-19 18:52:19 +08:00
|
|
|
export default window.vm
|
2020-03-19 20:44:14 +08:00
|
|
|
|
2021-04-22 18:03:56 +08:00
|
|
|
const orignalSetItem = localStorage.setItem
|
|
|
|
|
localStorage.setItem = function (key, value) {
|
|
|
|
|
const setItemEvent = new Event('setItemEvent')
|
|
|
|
|
setItemEvent.key = key
|
|
|
|
|
setItemEvent.value = value
|
|
|
|
|
window.dispatchEvent(setItemEvent)
|
|
|
|
|
orignalSetItem.apply(this, arguments)
|
2021-04-21 13:05:27 +08:00
|
|
|
}
|
|
|
|
|
|
2020-03-19 20:44:14 +08:00
|
|
|
/* 重写组件内容 */
|
2021-03-19 18:52:19 +08:00
|
|
|
/* const elUi = require("element-ui");
|
2020-04-15 22:01:56 +08:00
|
|
|
const pl = require("pl-table");
|
2020-03-20 21:05:31 +08:00
|
|
|
//去掉el-table表头右侧的滚动条预留空间
|
2020-03-19 20:44:14 +08:00
|
|
|
elUi.Table.components.TableHeader.computed.hasGutter = () => {return false;};
|
2021-03-19 18:52:19 +08:00
|
|
|
pl.PlTable.components.ElTable.components.TableHeader.computed.hasGutter = () => {return false;}; */
|