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/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "author": "林川",
4
4
  "license": "MIT",
5
5
  "private": false,
6
- "version": "0.1.19",
6
+ "version": "0.1.21",
7
7
  "description": "domain-language for js",
8
8
  "main": "dist/dlsjs.esm.js",
9
9
  "module": "dist/dlsjs.esm.js",
@@ -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.find(item => item.propName === propName);
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 res2 = list.filter(item => resParentIds.includes(item.id))
207
- return list2Tree([res, res2])
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
  /**