dlsjs 0.1.19 → 0.1.21
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/dist/dlsjs.cjs.js +1 -1
- package/dist/dlsjs.cjs.js.map +1 -1
- package/dist/dlsjs.esm.js +3 -3
- package/dist/dlsjs.esm.js.map +1 -1
- package/dist/dlsjs.umd.js +1 -1
- package/dist/dlsjs.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/core/ES/Tree.js +7 -6
package/package.json
CHANGED
package/src/core/ES/Tree.js
CHANGED
|
@@ -162,16 +162,16 @@ export function forkProp(obj, leafKey, propName) {
|
|
|
162
162
|
|
|
163
163
|
/**
|
|
164
164
|
* 维表转树
|
|
165
|
-
* @param dimList
|
|
166
|
-
* @param dimLink
|
|
167
|
-
* @param dimMap
|
|
165
|
+
* @param dimList 平铺维表
|
|
166
|
+
* @param dimLink 维表关联关系 e.g.['市','区县','乡镇']
|
|
167
|
+
* @param dimMap 维表关联映射字段 e.g.{'市': {propFieldName: 'code1', textFieldName: 'name1'}, '区': {propFieldName: 'code2', textFieldName: 'name2'}, '乡镇': {propFieldName: 'code3', textFieldName: 'name3'}}
|
|
168
168
|
*/
|
|
169
169
|
export function dim2Tree(dimList, dimLink, dimMap) {
|
|
170
170
|
let filedSort = [];
|
|
171
171
|
if (dimLink.length) {
|
|
172
172
|
for (let propName of dimLink) {
|
|
173
173
|
if (!propName) continue;
|
|
174
|
-
let match = dimMap
|
|
174
|
+
let match = dimMap[propName]
|
|
175
175
|
filedSort.push(match);
|
|
176
176
|
}
|
|
177
177
|
}
|
|
@@ -203,8 +203,9 @@ export function treeFilter(treeLike, func) {
|
|
|
203
203
|
setParentIds4List(list)
|
|
204
204
|
const res = list.filter(func)
|
|
205
205
|
const resParentIds = res.map(item => item._parentIds).flat()
|
|
206
|
-
const
|
|
207
|
-
|
|
206
|
+
const resIds = res.map(item => item.id)
|
|
207
|
+
const res2 = list.filter(item => resParentIds.includes(item.id) || resIds.includes(item.id))
|
|
208
|
+
return list2Tree(res2)
|
|
208
209
|
}
|
|
209
210
|
|
|
210
211
|
/**
|