index.js
1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/**
* 工具类
* import utils from "@/utils";
*/
/**
* table滚动
*/
const tableScroll = (columns, y) => {
let _y = (typeof y == "string" || typeof y == 'number') ? y : document.body.clientHeight - y.getBoundingClientRect().top - 150;
let opt = {
x: (typeof columns == "string" || typeof columns == 'number') ? columns : columns.reduce((c, n) => {
let cn = typeof c == "number" ? c : parseInt(c['width'] || 300);
let nn = parseInt(n['width'] || 300);
return cn + nn;
}),
y: Math.max(_y, 300)
}
// console.log(opt);
return opt
}
// table 表格各项配置
const tableConfig = {
align: 'center', // 表格内容排列方式
ellipsis: true, // 表格内容超出宽度,省略显示
}
// 封装接口返回数据
const handlePromise = (promise) => {
return promise.then(res => {
return Promise.resolve(res)
}).catch(e => {
return Promise.resolve(res)
})
}
export {
tableScroll,
tableConfig,
handlePromise
}