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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xianniu-ui",
3
- "version": "0.3.11",
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",
@@ -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
  >&nbsp;</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
- <template v-for="(item, idx) in columns">
127
- <column :key="idx" v-if="item.checked === true" v-bind="item"></column>
128
- </template>
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
@@ -51,6 +51,7 @@ const install = function (Vue) {
51
51
  Vue.prototype.$dayjs = Utils.$dayjs
52
52
  Vue.prototype.$storage = Utils.$storage
53
53
  Vue.prototype.$lodash = Utils.$lodash
54
+ Vue.prototype.$math = Utils.$math
54
55
 
55
56
  }
56
57
  if (typeof window !== 'undefined' && window.Vue) {
@@ -4,6 +4,7 @@
4
4
  * @param {Number} decimals 保留几位小数
5
5
  * @param {String} dec_point 小数点符号
6
6
  * @param {String} thousands_sep 千分位符号
7
+ * @param {String} symbol 货币符号
7
8
  * @returns
8
9
  */
9
10
  const priceToText = (number, decimals = 2, dec_point = '.', thousands_sep = ',', symbol = '¥') => {
@@ -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
+ }
@@ -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
- // 会创建一个 DOMString,其中包含一个表示参数中给出的对象的URL。这个 URL 的生命周期和创建它的窗口中的 document 绑定。这个新的URL 对象表示指定的 File 对象或 Blob 对象。
74
- var url = window.URL.createObjectURL(x.response)
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 = url
83
+ a.href = _url
84
+ a.target = '_blank'
77
85
  a.download = name
78
86
  a.click()
79
87
  }