import http from '../../packages/utils/request'
|
|
function getShowColumns(pageUrl, pageCode, table, showColList, defaultShowConfig) {
|
http.get(`defaultShowConfig/getDefaultShowConfig?pageName=${pageUrl}&pageCode=${pageCode}`)
|
.then(res => {
|
let userShowConfig = res.data
|
console.log(userShowConfig, 'userShowConfig userShowConfig')
|
// 页面名字 pagecode 用户Id 列名 中文名 是否显示
|
table.forEach(obj => {
|
if (obj.label !== undefined && obj.prop !== undefined) {
|
let itemDefaultShow = eval('defaultShowConfig.' + obj.prop)
|
itemDefaultShow = itemDefaultShow === undefined ? true : itemDefaultShow
|
let showField = itemDefaultShow
|
if (showField && userShowConfig !== undefined) {
|
let dbStatus = eval('userShowConfig.' + obj.prop)
|
if (dbStatus === false) {
|
showField = false
|
}
|
}
|
if (itemDefaultShow == 'debugging') {
|
showField = true
|
}
|
showColList.push({label: obj.label, prop: obj.prop, isShow: showField, solidShow: itemDefaultShow})
|
}
|
})
|
console.log(showColList, 'showColList showColList')
|
}
|
)
|
}
|
|
const S4 = function () {
|
return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
|
}
|
|
function guid() {
|
return (S4() + S4() + '-' + S4() + '-' + S4() + '-' + S4() + '-' + S4() + S4() + S4());
|
}
|
|
function getCurrentSkin() {
|
let skin = 'light'
|
let aaa = document.querySelectorAll('.zt')
|
for (let i = 0; i < aaa.length; i++) {
|
if (aaa[i].classList.contains('high')) {
|
skin = 'high'
|
break
|
}
|
}
|
return skin;
|
}
|
|
export function isStringContain(all, searchs) {
|
return isArrContain(all.split(','), searchs.split(','));
|
}
|
|
function isArrContain(all, searchs) {
|
let result = false
|
searchs.forEach((item) => {
|
if (all.indexOf(item) > -1) {
|
result = true;
|
return
|
}
|
})
|
return result;
|
}
|
|
function isJSON(str) {
|
if (typeof str == 'string') {
|
try {
|
var obj = JSON.parse(str);
|
if (typeof obj == 'object' && obj) {
|
return true;
|
} else {
|
return false;
|
}
|
|
} catch (e) {
|
console.log('error:' + str + '!!!' + e);
|
return false;
|
}
|
}
|
console.log('It is not a string!')
|
}
|
|
function removeCurrentTabHandle(that) {
|
removeTabHandle(that)
|
}
|
|
function formatDate(value) {
|
var date = new Date(value);
|
var y = date.getFullYear(),
|
m = date.getMonth() + 1,
|
d = date.getDate(),
|
h = date.getHours(),
|
i = date.getMinutes(),
|
s = date.getSeconds();
|
if (m < 10) {
|
m = '0' + m;
|
}
|
if (d < 10) {
|
d = '0' + d;
|
}
|
if (h < 10) {
|
h = '0' + h;
|
}
|
if (i < 10) {
|
i = '0' + i;
|
}
|
if (s < 10) {
|
s = '0' + s;
|
}
|
var t = y + '-' + m + '-' + d + ' ' + h + ':' + i + ':' + s;
|
return t;
|
}
|
|
// tabs, 删除tab
|
function removeTabHandle(that) {
|
let tabName = that.$route.name
|
if (tabName === 'home') {
|
return false
|
}
|
that.$store.state.contentTabs = that.$store.state.contentTabs.filter(item => item.name !== tabName)
|
if (that.$store.state.contentTabs.length <= 0) {
|
that.$store.state.sidebarMenuActiveName = that.$store.state.contentTabsActiveName = 'home'
|
return false
|
}
|
// 当前选中tab被删除
|
if (tabName === that.$store.state.contentTabsActiveName) {
|
let tab = that.$store.state.contentTabs[that.$store.state.contentTabs.length - 1]
|
that.$router.push({
|
name: tab.name,
|
params: {...tab.params},
|
query: {...tab.query}
|
})
|
}
|
}
|
|
function formatDate2(date, fmt) {
|
if (/(y+)/.test(fmt)) {
|
fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length));
|
}
|
let o = {
|
'M+': date.getMonth() + 1,
|
'd+': date.getDate(),
|
'h+': date.getHours(),
|
'm+': date.getMinutes(),
|
's+': date.getSeconds()
|
};
|
for (let k in o) {
|
if (new RegExp(`(${k})`).test(fmt)) {
|
let str = o[k] + '';
|
fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? str : padLeftZero(str));
|
}
|
}
|
return fmt;
|
}
|
|
function padLeftZero(str) {
|
return ('00' + str).substr(str.length);
|
}
|
|
function setHartBeat(intervalm, timeoutm) {
|
if (intervalm == null) {
|
intervalm = 10
|
}
|
let timer = window.setInterval(getHartBeat, intervalm * 60 * 1000)
|
if (timeoutm != null) {
|
window.setTimeout(function () {
|
window.clearInterval(timer)
|
}, timeoutm * 60 * 1000);
|
}
|
return timer;
|
}
|
|
function getHartBeat() {
|
http.get(`sys/common/heartBeat`)
|
if (res.success) {
|
}
|
}
|
|
export {
|
guid,
|
getCurrentSkin,
|
isJSON,
|
removeCurrentTabHandle,
|
formatDate,
|
formatDate2,
|
getShowColumns,
|
setHartBeat
|
}
|