xianniu-ui 0.3.20 → 0.3.22

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.20",
3
+ "version": "0.3.22",
4
4
  "private": false,
5
5
  "main": "lib/xianniu-ui.umd.min.js",
6
6
  "scripts": {
@@ -21,7 +21,6 @@
21
21
  "public"
22
22
  ],
23
23
  "dependencies": {
24
- "axios": "^0.26.0",
25
24
  "core-js": "^3.6.5",
26
25
  "dayjs": "^1.10.7",
27
26
  "decimal.js": "^10.4.2",
@@ -39,6 +38,7 @@
39
38
  "@vue/cli-plugin-router": "~4.5.0",
40
39
  "@vue/cli-service": "~4.5.0",
41
40
  "@vue/component-compiler-utils": "^2.6.0",
41
+ "axios": "^0.26.1",
42
42
  "babel-eslint": "^10.1.0",
43
43
  "babel-plugin-component": "^1.1.1",
44
44
  "babel-plugin-module-resolver": "^2.7.1",
@@ -121,13 +121,13 @@
121
121
  type="index"
122
122
  ></el-table-column>
123
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>
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
131
  </slot>
132
132
  <template #append v-if="$slots.append">
133
133
  <slot name="append"></slot>
@@ -199,10 +199,13 @@ export default {
199
199
  },
200
200
  computed: {},
201
201
  created() {
202
+
203
+ },
204
+ updated() {
202
205
  !this.$slots.default &&
203
206
  this.columns.length &&
204
207
  this.columns.forEach((item) => {
205
- this.$set(item, "checked", true);
208
+ if(item.checked !== true) this.$set(item, "checked", true);
206
209
  });
207
210
  },
208
211
  methods: {
@@ -70,7 +70,7 @@ const download = (params = { name: '', url: '' }) => {
70
70
  x.open('GET', url, true)
71
71
  // x.responseType = 'blob'
72
72
  // x.responseType = 'blob'
73
- x.onprogress = function(){
73
+ x.onprogress = function () {
74
74
  }
75
75
  x.onload = function () {
76
76
  var _url = ''
@@ -87,10 +87,43 @@ const download = (params = { name: '', url: '' }) => {
87
87
  }
88
88
  x.send()
89
89
  }
90
+ /**
91
+ * 根据某个key 对数组去重合并
92
+ * @param {array} arr 需要合并的数组
93
+ * @param {string} key 传入要合并的key
94
+ * @return {array} result
95
+ */
96
+ const arrMerge = (arr = [], key = '') => {
97
+ if (!key) {
98
+ throw new Error('error arguments: key is required')
99
+ }
100
+ if(!arr.length) return
101
+ var map = {}; var result = []
90
102
 
103
+ for (var i = 0; i < arr.length; i++) {
104
+ var ai = arr[i]
105
+ if (!map[ai[key]]) {
106
+ result.push({
107
+ [key]: ai[key],
108
+ children: [ai]
109
+ })
110
+ map[ai[key]] = ai
111
+ } else {
112
+ for (var j = 0; j < result.length; j++) {
113
+ var dj = result[j]
114
+ if (dj[key] === ai[key]) {
115
+ dj.children.push(ai)
116
+ break
117
+ }
118
+ }
119
+ }
120
+ }
121
+ return result
122
+ }
91
123
  export default {
92
124
  isEmpty,
93
125
  isImg,
94
126
  deepClone,
95
- download
127
+ download,
128
+ arrMerge
96
129
  }