xianniu-ui 0.3.11 → 0.3.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/xianniu-ui.common.js +5023 -27
- package/lib/xianniu-ui.umd.js +5023 -27
- package/lib/xianniu-ui.umd.min.js +9 -2
- package/package.json +2 -1
- package/packages/table/main.vue +10 -7
- package/src/index.js +1 -0
- package/src/utils/format.js +1 -0
- package/src/utils/index.js +4 -1
- package/src/utils/math.js +55 -0
- package/src/utils/utils.js +11 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "xianniu-ui",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.13",
|
|
4
4
|
"private": false,
|
|
5
5
|
"main": "lib/xianniu-ui.umd.min.js",
|
|
6
6
|
"scripts": {
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
"axios": "^0.26.0",
|
|
25
25
|
"core-js": "^3.6.5",
|
|
26
26
|
"dayjs": "^1.10.7",
|
|
27
|
+
"decimal.js": "^10.4.2",
|
|
27
28
|
"good-storage": "^1.1.1",
|
|
28
29
|
"lodash": "^4.17.21",
|
|
29
30
|
"vue": "2.6.11",
|
package/packages/table/main.vue
CHANGED
|
@@ -109,9 +109,7 @@
|
|
|
109
109
|
></el-table-column>
|
|
110
110
|
<el-table-column v-bind="$attrs" v-if="radio" width="40px" align="center">
|
|
111
111
|
<template slot-scope="{ row }">
|
|
112
|
-
<el-radio
|
|
113
|
-
v-model="radioSelected"
|
|
114
|
-
:label="row[idKey]"
|
|
112
|
+
<el-radio v-model="radioSelected" :label="row[idKey]"
|
|
115
113
|
> </el-radio
|
|
116
114
|
>
|
|
117
115
|
</template>
|
|
@@ -122,10 +120,15 @@
|
|
|
122
120
|
v-if="index && data.length"
|
|
123
121
|
type="index"
|
|
124
122
|
></el-table-column>
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
123
|
+
<slot>
|
|
124
|
+
<template v-for="(item, idx) in columns">
|
|
125
|
+
<column
|
|
126
|
+
:key="idx"
|
|
127
|
+
v-if="item.checked === true"
|
|
128
|
+
v-bind="item"
|
|
129
|
+
></column>
|
|
130
|
+
</template>
|
|
131
|
+
</slot>
|
|
129
132
|
</el-table>
|
|
130
133
|
|
|
131
134
|
<template v-if="!$utils.isEmpty(page)">
|
package/src/index.js
CHANGED
package/src/utils/format.js
CHANGED
package/src/utils/index.js
CHANGED
|
@@ -5,6 +5,8 @@ import dayjs from './dayjs'
|
|
|
5
5
|
import storage from './storage'
|
|
6
6
|
import utils from './utils'
|
|
7
7
|
import lodash from 'lodash'
|
|
8
|
+
import math from './math'
|
|
9
|
+
console.log('math: ', math);
|
|
8
10
|
const version = () => {
|
|
9
11
|
return `xianniu-tools@${require('./package.json').version}`
|
|
10
12
|
}
|
|
@@ -16,5 +18,6 @@ export default {
|
|
|
16
18
|
$dayjs: dayjs,
|
|
17
19
|
$lodash: lodash,
|
|
18
20
|
$storage: storage,
|
|
19
|
-
$utils: utils
|
|
21
|
+
$utils: utils,
|
|
22
|
+
$math: math
|
|
20
23
|
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Decimal } from "decimal.js";
|
|
2
|
+
/*
|
|
3
|
+
方式一
|
|
4
|
+
@params 0 array 要计算的数组
|
|
5
|
+
@params 1 string 需要计算的key
|
|
6
|
+
return number 最终结果
|
|
7
|
+
方式二
|
|
8
|
+
@params number/string 需要计算的数值
|
|
9
|
+
return number 最终结果
|
|
10
|
+
*/
|
|
11
|
+
class Math {
|
|
12
|
+
constructor(type) {
|
|
13
|
+
this.type = type
|
|
14
|
+
}
|
|
15
|
+
result(...args) {
|
|
16
|
+
if (!args) {
|
|
17
|
+
throw new Error('error arguments')
|
|
18
|
+
}
|
|
19
|
+
if (Array.isArray(args[0]) && args[1]) {
|
|
20
|
+
if (!args[0].length) return 0
|
|
21
|
+
const list = args[0]
|
|
22
|
+
const fieldKey = args[1]
|
|
23
|
+
return list.map(item => item[fieldKey]).reduce((pre, cur) => {
|
|
24
|
+
let val = new Decimal(pre)
|
|
25
|
+
return val[this.type](new Decimal(cur)).toNumber()
|
|
26
|
+
})
|
|
27
|
+
} else {
|
|
28
|
+
return args.reduce((pre, cur) => new Decimal(pre)[this.type](new Decimal(cur)).toNumber())
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// 加法 (1,2,3) = 6
|
|
34
|
+
const add = function (...args) {
|
|
35
|
+
return new Math('add').result(...args)
|
|
36
|
+
}
|
|
37
|
+
// 减法
|
|
38
|
+
const sub = function (...args) {
|
|
39
|
+
return new Math('sub').result(...args)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const mul = function (...args) {
|
|
43
|
+
return new Math('mul').result(...args)
|
|
44
|
+
}
|
|
45
|
+
const div = function (...args) {
|
|
46
|
+
return new Math('div').result(...args)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export default {
|
|
50
|
+
add,
|
|
51
|
+
sub,
|
|
52
|
+
mul,
|
|
53
|
+
div,
|
|
54
|
+
D: Decimal
|
|
55
|
+
}
|
package/src/utils/utils.js
CHANGED
|
@@ -69,11 +69,19 @@ const download = (params = { name: '', url: '' }) => {
|
|
|
69
69
|
var x = new XMLHttpRequest()
|
|
70
70
|
x.open('GET', url, true)
|
|
71
71
|
// x.responseType = 'blob'
|
|
72
|
+
// x.responseType = 'blob'
|
|
73
|
+
x.onprogress = function(){
|
|
74
|
+
}
|
|
72
75
|
x.onload = function () {
|
|
73
|
-
|
|
74
|
-
|
|
76
|
+
var _url = ''
|
|
77
|
+
try {
|
|
78
|
+
_url = window.URL.createObjectURL(x.response)
|
|
79
|
+
} catch (error) {
|
|
80
|
+
_url = url
|
|
81
|
+
}
|
|
75
82
|
var a = document.createElement('a')
|
|
76
|
-
a.href =
|
|
83
|
+
a.href = _url
|
|
84
|
+
a.target = '_blank'
|
|
77
85
|
a.download = name
|
|
78
86
|
a.click()
|
|
79
87
|
}
|