bri-components 1.4.23 → 1.4.24

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": "bri-components",
3
- "version": "1.4.23",
3
+ "version": "1.4.24",
4
4
  "author": "dengshanghui",
5
5
  "description": "a component lib for vue project",
6
6
  "main": "src/index.js",
@@ -18,7 +18,7 @@ export default {
18
18
 
19
19
  loading: false,
20
20
  loadinged: false,
21
- dataList: [],
21
+ departList: [],
22
22
  tmpValList: [],
23
23
 
24
24
  // 筛选
@@ -260,7 +260,7 @@
260
260
 
261
261
  const departList = [
262
262
  ...(this.highSearch ? this.highList : []),
263
- ...loop(this.dataList, this.filterVals, this.cascaderVals, this.reverseFilter)
263
+ ...loop(this.departList, this.filterVals, this.cascaderVals, this.reverseFilter)
264
264
  ];
265
265
 
266
266
  return this.transformDepartList(departList, this.tmpValKeys);
@@ -313,7 +313,7 @@
313
313
  callback: data => {
314
314
  this.loadinged = true;
315
315
 
316
- this.dataList = data.list;
316
+ this.departList = data.list;
317
317
  }
318
318
  });
319
319
  }
@@ -271,13 +271,21 @@
271
271
  _search: true,
272
272
  _clearable: false
273
273
  },
274
- highList: [
274
+
275
+ curDepart: {
276
+ _key: "",
277
+ name: "全部",
278
+ is_leaf: true,
279
+ level: 1
280
+ },
281
+ highUserList: [
275
282
  {
276
283
  _key: "dyn_myself",
277
284
  realname: "当前用户"
278
285
  }
279
286
  ],
280
- highDepartList: [
287
+ userList: [],
288
+ highList: [
281
289
  {
282
290
  _key: "_highSearch",
283
291
  name: "高级选项",
@@ -285,13 +293,6 @@
285
293
  is_leaf: true
286
294
  }
287
295
  ],
288
- curDepart: {
289
- _key: "",
290
- name: "全部",
291
- is_leaf: true,
292
- level: 1
293
- },
294
- departList: [],
295
296
 
296
297
  imageResizeConfig: {
297
298
  m: "fixed",
@@ -310,37 +311,55 @@
310
311
  return (JSON.parse(sessionStorage.getItem("userData")) || {}).isCompAdmin || this.selfPropsObj._isCompAdmin;
311
312
  },
312
313
 
313
- allFilterDepartKeys () {
314
- const loop = (list = []) => {
315
- return list.reduce((arr, item) => {
314
+ departShowList () {
315
+ const loop = (arr = [], filterVals = [], cascaderVals = [], reverseFilter = false) => {
316
+ arr = cascaderVals.length
317
+ ? arr.filter(item => {
318
+ return reverseFilter
319
+ ? !cascaderVals.some(cascaderItem =>
320
+ item.code && cascaderItem.code
321
+ ? item.code.length < cascaderItem.code.length
322
+ ? false
323
+ : item.code.startsWith(cascaderItem.code)
324
+ : false
325
+ )
326
+ : cascaderVals.some(cascaderItem =>
327
+ item.code && cascaderItem.code
328
+ ? item.code.length < cascaderItem.code.length
329
+ ? cascaderItem.code.startsWith(item.code)
330
+ : item.code.startsWith(cascaderItem.code)
331
+ : false
332
+ );
333
+ })
334
+ : filterVals.length
335
+ ? arr.filter(item =>
336
+ reverseFilter
337
+ ? !filterVals.includes(item._key)
338
+ : filterVals.includes(item._key)
339
+ )
340
+ : arr;
341
+
342
+ return arr.reduce((newArr, item) => {
343
+ if (item.children && item.children.length) {
344
+ item.children = loop(item.children, [], cascaderVals, reverseFilter);
345
+ }
346
+
316
347
  return [
317
- ...arr,
318
- ...loop(item.children)
348
+ ...newArr,
349
+ item
319
350
  ];
320
- }, list);
351
+ }, []);
321
352
  };
322
353
 
323
- const departList = this.departList.filter(item => this.filterVals.includes(item._key));
324
- return loop(departList).map(item => item._key);
325
- },
326
- departShowList () {
327
354
  return [
328
- ...(this.highSearch ? this.highDepartList : []),
355
+ ...(this.highSearch ? this.highList : []),
329
356
  {
330
357
  name: "全部",
331
358
  _key: "",
332
359
  level: 1,
333
360
  is_leaf: true
334
361
  },
335
- ...(
336
- this.allFilterDepartKeys.length
337
- ? this.departList.filter(item =>
338
- this.reverseFilter
339
- ? !this.allFilterDepartKeys.includes(item._key)
340
- : this.allFilterDepartKeys.includes(item._key)
341
- )
342
- : this.departList
343
- ),
362
+ ...loop(this.departList, this.filterVals, this.cascaderVals, this.reverseFilter),
344
363
  ...(
345
364
  this.isCompAdmin
346
365
  ? [
@@ -355,18 +374,30 @@
355
374
  )
356
375
  ];
357
376
  },
377
+ allSelectDepartKeys () {
378
+ const loop = (list = []) => {
379
+ return list.reduce((arr, item) => {
380
+ return [
381
+ ...arr,
382
+ ...loop(item.children)
383
+ ];
384
+ }, list);
385
+ };
386
+
387
+ return loop(this.departShowList).map(item => item._key);
388
+ },
358
389
  userShowList () {
359
- let list = this.allFilterDepartKeys.length
360
- ? this.dataList.filter(item =>
390
+ let list = this.allSelectDepartKeys.length
391
+ ? this.userList.filter(item =>
361
392
  this.reverseFilter
362
- ? !this.allFilterDepartKeys.includes(item.departmentKey)
363
- : this.allFilterDepartKeys.includes(item.departmentKey)
393
+ ? !this.allSelectDepartKeys.includes(item.departmentKey)
394
+ : this.allSelectDepartKeys.includes(item.departmentKey)
364
395
  )
365
- : this.dataList;
396
+ : this.userList;
366
397
  list = this.curDepart._key === "_highSearch"
367
- ? this.highList
398
+ ? this.highUserList
368
399
  : this.curDepart._key === "_resign"
369
- ? this.dataList
400
+ ? this.userList
370
401
  : !this.curDepart._key
371
402
  ? list
372
403
  : list.filter(item => item.departmentKey === this.curDepart._key);
@@ -447,7 +478,7 @@
447
478
  callback: data => {
448
479
  this.loadinged = true;
449
480
 
450
- this.dataList = data.list;
481
+ this.userList = data.list;
451
482
  this.total = data.total;
452
483
  }
453
484
  });