bri-components 1.4.22 → 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.22",
3
+ "version": "1.4.24",
4
4
  "author": "dengshanghui",
5
5
  "description": "a component lib for vue project",
6
6
  "main": "src/index.js",
@@ -309,12 +309,16 @@
309
309
  } else if (type === "down") {
310
310
  val = addNum(val, -step);
311
311
  }
312
+
312
313
  this.setValue(val, "step");
313
314
  },
314
315
  setValue (val, setType) {
315
316
  // 如果 step 是小数,且没有设置 precision,是有问题的
316
- if (val && !isNaN(this.precision)) val = Number(Number(val).toFixed(this.precision));
317
+ if (val && !isNaN(this.precision)) {
318
+ val = Number(Number(val).toFixed(this.precision));
319
+ }
317
320
 
321
+ // 处理最大值最小值
318
322
  const {min, max} = this;
319
323
  if (val !== null) {
320
324
  if (val > max) {
@@ -324,20 +328,13 @@
324
328
  }
325
329
  }
326
330
 
331
+ // emit事件
327
332
  this.$nextTick(() => {
328
333
  this.transferValue = val;
329
334
  if (setType && setType === "step") {
330
335
  this.$emit("input", val);
331
336
  this.$emit("on-change", val);
332
337
  this.dispatch("FormItem", "on-form-change", val);
333
- } else {
334
- clearTimeout(this.timer);
335
- this.timer = setTimeout(() => {
336
- this.currentValue = val;
337
- this.$emit("input", val);
338
- this.$emit("on-change", val);
339
- this.dispatch("FormItem", "on-form-change", val);
340
- }, 600);
341
338
  }
342
339
  });
343
340
  },
@@ -348,6 +345,10 @@
348
345
  blur () {
349
346
  this.focused = false;
350
347
  if (this.transferValue !== this.currentValue) {
348
+ this.currentValue = this.transferValue;
349
+ this.$emit("input", this.transferValue);
350
+ this.$emit("on-change", this.transferValue);
351
+ this.dispatch("FormItem", "on-form-change", this.transferValue);
351
352
  this.focused = false;
352
353
  this.$emit("on-blur");
353
354
  if (!findComponentUpward(this, ["DatePicker", "TimePicker", "Cascader", "Search"])) {
@@ -365,31 +366,35 @@
365
366
  }
366
367
  },
367
368
  change (event) {
368
- if (event.type == "change" && this.activeChange) return;
369
-
370
- if (event.type == "input" && !this.activeChange) return;
369
+ if (event.type == "change" && this.activeChange) {
371
370
 
372
- let val = event.target.value.trim();
373
- if (this.parser) {
374
- val = this.parser(val);
375
- }
371
+ } else if (event.type == "input" && !this.activeChange) {
376
372
 
377
- const isEmptyString = val.length === 0;
378
- if (isEmptyString) {
379
- this.setValue(null);
380
- return;
381
- }
382
- if (event.type == "input" && val.match(/^-?\.?$|\.$/)) return; // prevent fire early if decimal. If no more input the change event will fire later
373
+ } else {
374
+ let val = event.target.value.trim();
375
+ if (this.parser) {
376
+ val = this.parser(val);
377
+ }
383
378
 
384
- // eslint认为\为无用的转义符(-不需要转义)
385
- // if (event.type == "input" && val.match(/^\-?\.?$|\.$/)) return; // prevent fire early if decimal. If no more input the change event will fire later
386
- val = Number(val);
379
+ const isEmptyString = val.length === 0;
380
+ if (isEmptyString) {
381
+ this.setValue(null);
382
+ } else {
383
+ if (event.type == "input" && val.match(/^-?\.?$|\.$/)) {
384
+ // prevent fire early if decimal. If no more input the change event will fire later
385
+ } else {
386
+ // eslint认为\为无用的转义符(-不需要转义)
387
+ // if (event.type == "input" && val.match(/^\-?\.?$|\.$/)) return; // prevent fire early if decimal. If no more input the change event will fire later
388
+ val = Number(val);
387
389
 
388
- if (!isNaN(val)) {
389
- // this.currentValue = val;
390
- this.setValue(val);
391
- } else {
392
- event.target.value = this.currentValue;
390
+ if (!isNaN(val)) {
391
+ // this.currentValue = val;
392
+ this.setValue(val);
393
+ } else {
394
+ event.target.value = this.currentValue;
395
+ }
396
+ }
397
+ }
393
398
  }
394
399
  },
395
400
  changeVal (val) {
@@ -15,7 +15,6 @@
15
15
  :max="maxNum"
16
16
  :min="minNum"
17
17
  :precision="digit"
18
- @on-change="change"
19
18
  >
20
19
  <div
21
20
  v-if="unitStr"
@@ -170,8 +170,6 @@ export default {
170
170
  clickInput (e) {
171
171
  if (!this.disabled) {
172
172
  this.showModal = true;
173
- } else {
174
- e.stopPropagation();
175
173
  }
176
174
  },
177
175
  clickCancel () {
@@ -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
  // 筛选
@@ -10,7 +10,7 @@
10
10
  maxWidth="200"
11
11
  :transfer="true"
12
12
  >
13
- <div @click.stop="clickInput">
13
+ <div @click="clickInput">
14
14
  <slot>
15
15
  <!-- 编辑 -->
16
16
  <dsh-control-input
@@ -120,51 +120,35 @@
120
120
  >
121
121
  <!-- 有值 -->
122
122
  <template v-if="!$isEmptyData(curShowValList)">
123
- <!-- 单元格查看 -->
123
+ <!-- 表单查看 -->
124
+ <!-- 高度自由时 -->
125
+ <dsh-tags
126
+ v-if="isHeightAuto"
127
+ :class="{
128
+ ...commonClass,
129
+ 'selectDepartments-show-auto': true
130
+ }"
131
+ itemClass="selectDepartments-show-auto-tag"
132
+ :list="curShowValList"
133
+ ></dsh-tags>
134
+
135
+ <!-- 高度不自由(不换行) -->
124
136
  <bri-tooltip
125
- v-if="isUnitShow"
137
+ v-else
126
138
  :content="showVal"
127
139
  placement="top"
128
140
  maxWidth="200"
129
141
  :transfer="true"
130
142
  >
131
143
  <dsh-tags
132
- class="text"
133
- :list="curShowValList"
134
- ></dsh-tags>
135
- </bri-tooltip>
136
-
137
- <!-- 表单查看 -->
138
- <template v-else>
139
- <!-- 高度自由时 -->
140
- <dsh-tags
141
- v-if="isHeightAuto"
142
144
  :class="{
143
145
  ...commonClass,
144
- 'selectDepartments-show-auto': true
146
+ 'selectDepartments-show-ellipsis': true
145
147
  }"
146
- itemClass="selectDepartments-show-auto-tag"
148
+ itemClass="selectDepartments-show-ellipsis-tag"
147
149
  :list="curShowValList"
148
150
  ></dsh-tags>
149
-
150
- <!-- 高度不自由(不换行) -->
151
- <bri-tooltip
152
- v-else
153
- :content="showVal"
154
- placement="top"
155
- maxWidth="200"
156
- :transfer="true"
157
- >
158
- <dsh-tags
159
- :class="{
160
- ...commonClass,
161
- 'selectDepartments-show-ellipsis': true
162
- }"
163
- itemClass="selectDepartments-show-ellipsis-tag"
164
- :list="curShowValList"
165
- ></dsh-tags>
166
- </bri-tooltip>
167
- </template>
151
+ </bri-tooltip>
168
152
  </template>
169
153
 
170
154
  <!-- 无值 -->
@@ -276,7 +260,7 @@
276
260
 
277
261
  const departList = [
278
262
  ...(this.highSearch ? this.highList : []),
279
- ...loop(this.dataList, this.filterVals, this.cascaderVals, this.reverseFilter)
263
+ ...loop(this.departList, this.filterVals, this.cascaderVals, this.reverseFilter)
280
264
  ];
281
265
 
282
266
  return this.transformDepartList(departList, this.tmpValKeys);
@@ -329,7 +313,7 @@
329
313
  callback: data => {
330
314
  this.loadinged = true;
331
315
 
332
- this.dataList = data.list;
316
+ this.departList = data.list;
333
317
  }
334
318
  });
335
319
  }
@@ -349,23 +333,6 @@
349
333
  &-ellipsis {
350
334
  margin: 5px 0px;
351
335
  }
352
-
353
- &-unit {
354
- .dsh-ellipsis();
355
- padding-left: 5px;
356
-
357
- &-img {
358
- width: 18px;
359
- height: 18px;
360
- vertical-align: middle;
361
- margin-left: -5px;
362
- border-radius: 50%;
363
- }
364
-
365
- &-text {
366
- vertical-align: middle;
367
- }
368
- }
369
336
  }
370
337
  }
371
338
  </style>
@@ -10,7 +10,7 @@
10
10
  maxWidth="200"
11
11
  :transfer="true"
12
12
  >
13
- <div @click.stop="clickInput">
13
+ <div @click="clickInput">
14
14
  <slot>
15
15
  <dsh-control-input
16
16
  :class="commonClass"
@@ -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,64 +311,96 @@
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
- ...this.getAllListFilterVals(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
- _key: "",
331
357
  name: "全部",
332
- is_leaf: true,
333
- level: 1
358
+ _key: "",
359
+ level: 1,
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
  ? [
347
366
  {
348
- is_leaf: true,
349
- level: 1,
350
367
  name: "离职人员",
351
- _key: "_resign"
368
+ _key: "_resign",
369
+ level: 1,
370
+ is_leaf: true
352
371
  }
353
372
  ]
354
373
  : []
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
368
- : !this.curDepart._key
369
- ? list
370
- : list.filter(item => item.departmentKey === this.curDepart._key);
398
+ ? this.highUserList
399
+ : this.curDepart._key === "_resign"
400
+ ? this.userList
401
+ : !this.curDepart._key
402
+ ? list
403
+ : list.filter(item => item.departmentKey === this.curDepart._key);
371
404
 
372
405
  return this.transformDepartList(list, this.tmpValKeys);
373
406
  },
@@ -438,14 +471,14 @@
438
471
  }
439
472
  : undefined
440
473
  },
441
- department: this.curDepart._key === "_resign" ? "_resign" : undefined,
474
+ // department: this.curDepart._key,
442
475
  pagination: this.pagePropsObj
443
476
  },
444
477
  loadingName: "loading",
445
478
  callback: data => {
446
479
  this.loadinged = true;
447
480
 
448
- this.dataList = data.list;
481
+ this.userList = data.list;
449
482
  this.total = data.total;
450
483
  }
451
484
  });
@@ -537,7 +570,7 @@
537
570
  &-modal {
538
571
  .ivu-modal {
539
572
  width: 40%!important;
540
- min-width: 800px!important;
573
+ min-width: 900px!important;
541
574
  height: 60%;
542
575
  min-height: 600px;
543
576
  }
@@ -570,13 +603,13 @@
570
603
  border-top: 1px solid #E5E5E5;
571
604
 
572
605
  &-menu {
573
- flex: 3;
606
+ flex: 4;
574
607
  height: 100%;
575
608
  overflow: auto;
576
609
  }
577
610
 
578
611
  &-users {
579
- flex: 2;
612
+ flex: 3;
580
613
  border-left: 1px solid #E5E5E5;
581
614
  position: relative;
582
615