bri-components 1.3.26 → 1.3.28

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.
Files changed (27) hide show
  1. package/package.json +1 -1
  2. package/src/components/controls/base/BriUpload/BriUpload.vue +10 -10
  3. package/src/components/controls/base/BriUpload/uploadList.vue +3 -3
  4. package/src/components/controls/base/DshCascader/DshCascader.vue +2 -2
  5. package/src/components/controls/base/DshCascader/components/cascaderModal.vue +3 -3
  6. package/src/components/controls/base/DshCascader/components/cascaderPicker.vue +4 -4
  7. package/src/components/controls/base/DshCoordinates.vue +10 -9
  8. package/src/components/controls/base/DshNumber/DshNumber.vue +2 -2
  9. package/src/components/controls/base/DshSelect/DshCheckbox.vue +1 -1
  10. package/src/components/controls/base/DshSelect/DshSelect.vue +2 -2
  11. package/src/components/controls/mixins/cascaderMixin.js +1 -1
  12. package/src/components/controls/mixins/cascaderPickerMixin.js +2 -2
  13. package/src/components/controls/mixins/controlMixin.js +1 -1
  14. package/src/components/controls/mixins/selectMixin.js +1 -1
  15. package/src/components/controls/senior/cascaderTable.vue +14 -12
  16. package/src/components/controls/senior/selectDepartments.vue +18 -1
  17. package/src/components/controls/senior/selectUsers/selectUsers.vue +19 -4
  18. package/src/components/list/DshBox/DshCrossTable.vue +11 -2
  19. package/src/components/list/DshCascaderTable.vue +42 -96
  20. package/src/components/list/DshFlatTable.vue +5 -8
  21. package/src/components/list/DshTreeTable.vue +203 -40
  22. package/src/components/list/mixins/{tableMixin.js → flatTableMixin.js} +81 -27
  23. package/src/components/list/mixins/{DshFlatTableMixin.js → tableBaseMixin.js} +28 -82
  24. package/src/styles/components/list/BriTable.less +41 -31
  25. package/src/styles/global/text.less +0 -3
  26. package/src/styles/reset-iview-other.less +0 -4
  27. package/src/utils/table.js +6 -5
@@ -197,23 +197,15 @@
197
197
  </template>
198
198
 
199
199
  <script>
200
- import DshListUnit from "../unit/DshListUnit.vue";
200
+ import tableBaseMixin from "./mixins/tableBaseMixin.js";
201
201
 
202
202
  export default {
203
203
  name: "DshCascaderTable",
204
- components: {
205
- DshListUnit
206
- },
204
+ mixins: [
205
+ tableBaseMixin
206
+ ],
207
+ components: {},
207
208
  props: {
208
- canEdit: {
209
- type: Boolean,
210
- default: true
211
- },
212
- useCol: {
213
- type: Boolean,
214
- default: false
215
- },
216
-
217
209
  data: {
218
210
  type: Object,
219
211
  default () {
@@ -236,32 +228,10 @@
236
228
  default () {
237
229
  return [];
238
230
  }
239
- },
240
- propsObj: {
241
- type: Object,
242
- default () {
243
- return {};
244
- }
245
- },
246
-
247
- parentFormList: {
248
- type: Array,
249
- default () {
250
- return [];
251
- }
252
- },
253
- parentObj: {
254
- type: Object,
255
- default () {
256
- return {};
257
- }
258
231
  }
259
232
  },
260
233
  data () {
261
234
  return {
262
- showRuleMessage: false, // 显示校验文字
263
- ruleRecordMap: {},
264
-
265
235
  widthMap: this.$getModFieldPropertyMap("width"),
266
236
  boxWidth: 0,
267
237
  getColOperationNames (col) {
@@ -363,46 +333,28 @@
363
333
  computed: {
364
334
  selfPropsObj () {
365
335
  return {
366
- // isShare: false, // 是否是分享页在用
367
-
368
- _showRequired: true, // 表头显示校验符号*
369
- _showDescription: true, // 表头显示提示
370
- _headHeightAuto: false, // 表头高度自适应
371
- _heightAuto: false, // 单元格高度自适应
372
- _disabledBtns: false, // 禁用增删按钮
373
- ...this.propsObj,
336
+ _useCol: true,
337
+ ...this.commonPropsObj,
374
338
 
375
339
  _contentHeight: this.propsObj._contentHeight || 400 // 表格最大高度
376
340
  };
377
341
  },
378
- // isShare () {
379
- // return this.selfPropsObj.isShare;
380
- // },
381
- contentHeight () {
382
- return this.selfPropsObj._contentHeight;
383
- },
384
- showRequired () {
385
- return this.selfPropsObj._showRequired;
386
- },
387
- showDescription () {
388
- return this.selfPropsObj._showDescription;
389
- },
390
- headHeightAuto () {
391
- return this.selfPropsObj._headHeightAuto;
392
- },
393
- heightAuto () {
394
- return this.selfPropsObj._heightAuto;
395
- },
396
- disabledBtns () {
397
- return this.selfPropsObj._disabledBtns;
342
+ useCol () {
343
+ return this.selfPropsObj._useCol;
398
344
  },
399
345
 
400
346
  columns () {
401
347
  return this.transformColumns(this.treeColumns);
402
348
  },
349
+ filterColumns () {
350
+ return this.columns.filter(col => col.colType === "data");
351
+ },
403
352
  treeData () {
404
353
  return this.transforBriTreeData();
405
354
  },
355
+ listData () {
356
+ return this.rows;
357
+ },
406
358
  rows () {
407
359
  return this.transformRows();
408
360
  },
@@ -456,16 +408,34 @@
456
408
  };
457
409
  loop(this.data.tree);
458
410
  },
459
- // 共外部使用
460
- validate () {
461
- this.showRuleMessage = true;
462
-
463
- const subColumns = this.columns.filter(col => col.colType === "data");
464
- return this.rows.every((row, rowIndex) =>
465
- subColumns.every(col => this.getColRuleResult(col, row[col.nodeKey], rowIndex, true).bool)
466
- );
411
+ // 整行校验结果
412
+ getRowRuleResult (row, rowIndex) {
413
+ return this.filterColumns.every(col => this.getColRuleResult(col, row[col.nodeKey], rowIndex).bool);
414
+ },
415
+ // 单元格校验结果
416
+ getColRuleResult (col, row, rowIndex) {
417
+ if ((this.ruleRecordMap[`${row._id}dsh${col._key}`] || {}).showRuleMessage || this.showRuleMessage) {
418
+ return this.$getFieldRuleResult({
419
+ ...col,
420
+ _regStr: col._regStr && [";", ";"].some(symbol => col._regStr.includes(symbol))
421
+ ? col._regStr
422
+ .replace(/\n/g, "")
423
+ .split(";")
424
+ .reduce((arr, item) => arr.concat(item.split(";")), [])[rowIndex]
425
+ : col._regStr,
426
+ _regMessage: col._regMessage && [";", ";"].some(symbol => col._regMessage.includes(symbol))
427
+ ? col._regMessage
428
+ .replace(/\n/g, "")
429
+ .split(";")
430
+ .reduce((arr, item) => arr.concat(item.split(";")), [])[rowIndex]
431
+ : col._regMessage
432
+ }, row);
433
+ } else {
434
+ return {
435
+ bool: true
436
+ };
437
+ }
467
438
  },
468
-
469
439
  // 点击表头
470
440
  clickTh (operationItem, col) {
471
441
  this.$emit("clickTh", col);
@@ -586,30 +556,6 @@
586
556
  controlBlur (operationItem, col, row, params) {
587
557
  this.$set(this.ruleRecordMap, `${row._id}dsh${col._key}`, { showRuleMessage: true });
588
558
  },
589
- // 是否显示 单元格校验提示文字
590
- getColRuleResult (col, row, rowIndex, showRuleMessage = this.showRuleMessage) {
591
- if ((this.ruleRecordMap[`${row._id}dsh${col._key}`] || {}).showRuleMessage || showRuleMessage) {
592
- return this.$getFieldRuleResult({
593
- ...col,
594
- _regStr: col._regStr && [";", ";"].some(symbol => col._regStr.includes(symbol))
595
- ? col._regStr
596
- .replace(/\n/g, "")
597
- .split(";")
598
- .reduce((arr, item) => arr.concat(item.split(";")), [])[rowIndex]
599
- : col._regStr,
600
- _regMessage: col._regMessage && [";", ";"].some(symbol => col._regMessage.includes(symbol))
601
- ? col._regMessage
602
- .replace(/\n/g, "")
603
- .split(";")
604
- .reduce((arr, item) => arr.concat(item.split(";")), [])[rowIndex]
605
- : col._regMessage
606
- }, row);
607
- } else {
608
- return {
609
- bool: true
610
- };
611
- }
612
- },
613
559
 
614
560
  /* ---- 工具方法 ---- */
615
561
  // 合并表头
@@ -20,19 +20,16 @@
20
20
  </template>
21
21
 
22
22
  <script>
23
- import DshFlatTableMixin from "./mixins/DshFlatTableMixin.js";
24
- import tableMixin from "./mixins/tableMixin.js";
25
- import DshListUnit from "../unit/DshListUnit.vue";
23
+ import tableBaseMixin from "./mixins/tableBaseMixin.js";
24
+ import flatTableMixin from "./mixins/flatTableMixin.js";
26
25
 
27
26
  export default {
28
27
  name: "DshFlatTable",
29
28
  mixins: [
30
- DshFlatTableMixin,
31
- tableMixin
29
+ tableBaseMixin,
30
+ flatTableMixin
32
31
  ],
33
- components: {
34
- DshListUnit
35
- },
32
+ components: {},
36
33
  props: {},
37
34
  data () {
38
35
  return {};
@@ -1,5 +1,16 @@
1
1
  <template>
2
2
  <div class="DshTreeTable">
3
+ <!-- 搜索条件 -->
4
+ <template v-if="searchFormList.length">
5
+ <dsh-default-search
6
+ :formList="searchFormList"
7
+ :initValue="[]"
8
+ :labelWidth="searchLabelWidth"
9
+ @change="searchCb"
10
+ ></dsh-default-search>
11
+ </template>
12
+
13
+ <!-- 表格 -->
3
14
  <bri-table
4
15
  class="DshTreeTable-main"
5
16
  :columns="showColumns"
@@ -13,30 +24,68 @@
13
24
  </template>
14
25
 
15
26
  <script>
16
- import DshFlatTableMixin from "./mixins/DshFlatTableMixin.js";
17
- import tableMixin from "./mixins/tableMixin.js";
18
- import DshListUnit from "../unit/DshListUnit.vue";
27
+ import tableBaseMixin from "./mixins/tableBaseMixin.js";
28
+ import flatTableMixin from "./mixins/flatTableMixin.js";
19
29
 
20
30
  export default {
21
31
  name: "DshTreeTable",
22
32
  mixins: [
23
- DshFlatTableMixin,
24
- tableMixin
33
+ tableBaseMixin,
34
+ flatTableMixin
25
35
  ],
26
- components: {
27
- DshListUnit
28
- },
36
+ components: {},
29
37
  props: {},
30
38
  data () {
31
- return {};
39
+ return {
40
+ advSearchObj: {
41
+ logic: "and",
42
+ conditions: []
43
+ }
44
+ };
32
45
  },
33
46
  computed: {
47
+ isSearching () {
48
+ return this.searchFormList.length && this.advSearchObj.conditions.some(conditionItem => conditionItem.fieldValue.length);
49
+ },
34
50
  listData () {
35
- return this.$getTreeFlatArr(this.data, "__isExpand__");
51
+ console.log("listData");
52
+ const treeData = this.getCalcuTree(this.data, this.filterColumns);
53
+ return this.$getTreeFlatArr(treeData, node =>
54
+ (this.searchFormList.length ? this.$isAdvRelyAccord(this.advSearchObj, node) : true) &&
55
+ (node.level === 1 || node.__isRendered__)
56
+ );
57
+ },
58
+ footerData () {
59
+ console.log("footerData");
60
+ return this.useSummary && this.listData.length
61
+ ? [
62
+ this.filterColumns.reduce((obj, col) => {
63
+ return {
64
+ ...obj,
65
+ [col._key]: col._type === "number" && ![undefined, null, "", "no"].includes(col._summaryType)
66
+ ? this.$calNumList(
67
+ this.listData
68
+ .filter(item => item.level === 1)
69
+ .map(item => item[col._key]),
70
+ col._summaryType,
71
+ { ...col, _defaultDigit: 2 }
72
+ )
73
+ : (obj[col._key] || "--")
74
+ };
75
+ }, {
76
+ _id: this.$ObjectID().str,
77
+ __index__: "汇总",
78
+ __isExpand__: "-",
79
+ __operation__: "——"
80
+ })
81
+ ]
82
+ : [];
36
83
  },
37
84
 
38
85
  selfPropsObj () {
39
86
  return {
87
+ _searchFields: [], // 作为搜索的字段
88
+ _searchLabelWidth: 100, // 搜索的label宽度
40
89
  ...this.commonPropsObj,
41
90
 
42
91
  _maxLevel: this.commonPropsObj._maxLevel || 3
@@ -45,6 +94,21 @@
45
94
  maxLevel () {
46
95
  return this.selfPropsObj._maxLevel;
47
96
  },
97
+ searchLabelWidth () {
98
+ return this.selfPropsObj._searchLabelWidth;
99
+ },
100
+ searchFormList () {
101
+ return this.selfPropsObj._searchFields
102
+ .map(fieldKey => this.columns.find(column => column._key === fieldKey))
103
+ .filter(column => !!column)
104
+ .map(column => {
105
+ return {
106
+ ...column,
107
+ _span: 6
108
+ };
109
+ });
110
+ },
111
+
48
112
  tablePropsObj () {
49
113
  return {
50
114
  maxHeight: this.contentHeight,
@@ -56,14 +120,11 @@
56
120
  cellStyleOption: {
57
121
  bodyCellClass: ({ row, column, rowIndex }) => {
58
122
  return "bri-table-td" +
59
- `${
60
- this.canEdit
61
- ? " bri-table-td-edit"
62
- : " bri-table-td-show"
63
- }` +
123
+ `${this.canEdit ? " bri-table-td-edit" : " bri-table-td-show"}` +
124
+ `${row.__isShow__ === false ? " bri-table-td-hide" : ""}` +
64
125
  `${
65
126
  ["__isExpand__"].includes(column._key)
66
- ? " bri-table-td-normal"
127
+ ? " bri-table-td-expand"
67
128
  : ["__index__"].includes(column._key)
68
129
  ? " bri-table-td-index"
69
130
  : ""
@@ -76,6 +137,9 @@
76
137
  }
77
138
  };
78
139
  },
140
+ filterColumns () {
141
+ return this.columns;
142
+ },
79
143
  showColumns () {
80
144
  return [
81
145
  ...(this.useSelection === true ? [this.selectionColumn] : []),
@@ -91,22 +155,22 @@
91
155
  _key: "__isExpand__",
92
156
  key: "__isExpand__",
93
157
  field: "__isExpand__",
94
- width: 46,
158
+ width: 48,
95
159
  align: "center",
96
160
  fixed: "left",
97
161
  renderBodyCell: ({ row, column, rowIndex }, h) => {
98
162
  return row.children && row.children.length
99
163
  ? h("Icon", {
100
164
  style: {
101
- width: "14px",
102
- height: "14px",
165
+ width: "16px",
166
+ height: "16px",
103
167
  cursor: "pointer",
104
168
  transform: row.__isExpand__ ? "rotate(90deg)" : "rotate(0deg)",
105
169
  transition: "transform 0.4s"
106
170
  },
107
171
  props: {
108
172
  type: "ios-arrow-forward",
109
- size: "14"
173
+ size: "18"
110
174
  },
111
175
  on: {
112
176
  click: () => {
@@ -137,7 +201,7 @@
137
201
  }, row.__treeIndex__),
138
202
 
139
203
  // 添加符
140
- row.level < this.maxLevel
204
+ row.level < this.maxLevel && !this.isSearching
141
205
  ? h("div", {
142
206
  style: {
143
207
  position: "absolute",
@@ -164,21 +228,7 @@
164
228
  },
165
229
  on: {
166
230
  click: () => {
167
- // 新增行里的输入框,第一次输入会失去光标的bug,需要$set
168
- const rowDefault = this.$deepCopy(this.rowDefault);
169
- this.columns.forEach(column => {
170
- // 用$set也可以
171
- rowDefault[column._key] = rowDefault[column._key];
172
- });
173
-
174
- row.children.push({
175
- _id: this.$ObjectID().str,
176
- level: row.level + 1,
177
- children: [],
178
- ...rowDefault
179
- });
180
-
181
- this.toggleExpand(row, true);
231
+ this.clickCreate(this.operationMap.canCreate, row, rowIndex);
182
232
  }
183
233
  }
184
234
  })
@@ -191,13 +241,126 @@
191
241
  },
192
242
  created () {},
193
243
  methods: {
244
+ // 默认筛选回调
245
+ searchCb (conditions) {
246
+ this.advSearchObj = {
247
+ ...this.advSearchObj,
248
+ conditions: conditions
249
+ };
250
+ },
194
251
  toggleExpand (row, bool = true) {
252
+ this.$set(row, "__isRendered__", true);// 作用不大 可有可无
195
253
  this.$set(row, "__isExpand__", bool);
196
254
 
197
- // this.$set(row, "__isRendered__", true);
198
- // row.children.forEach(subRow => {
199
- // this.$set(subRow, "__isShow__", bool);
200
- // });
255
+ this.toggleDescendantsShow(row, bool);
256
+ },
257
+ // 点击 -添加一行
258
+ clickCreate (operationItem, row, rowIndex) {
259
+ row.children.push({
260
+ _id: this.$ObjectID().str,
261
+ ...this.$deepCopy(this.rowDefault),
262
+ level: row.level + 1,
263
+ isLeaf: true,
264
+ children: []
265
+ });
266
+
267
+ this.toggleExpand(row, true);
268
+ },
269
+ // 点击 -删除行
270
+ clickDelete (operationItem, row, rowIndex) {
271
+ this.$Modal.confirm({
272
+ title: "警告",
273
+ content: "确定删除吗?",
274
+ onOk: () => {
275
+ const parentNode = this.getParentNode(this.data, row);
276
+ const index = parentNode.children.findIndex(childNode => childNode._id === row._id);
277
+ parentNode.children.splice(index, 1);
278
+ console.log(index);
279
+ console.log(parentNode);
280
+ }
281
+ });
282
+ },
283
+
284
+ /* ------ 工具方法 ------- */
285
+ getCalcuTree (tree = [], columns) {
286
+ const loop = (list = []) =>
287
+ list.reduce((newList, node) => {
288
+ if (node.children && node.children.length) {
289
+ node.isLeaf = false;
290
+ node.children = loop(node.children);
291
+
292
+ columns.reduce((newNode, col) => {
293
+ if (col._type === "number" && ![undefined, null, "", "no"].includes(col._summaryType)) {
294
+ newNode[col._key] = col._type === "number" && ![undefined, null, "", "no"].includes(col._summaryType)
295
+ ? this.$calNumList(
296
+ node.children.map(subNode => subNode[col._key]),
297
+ col._summaryType,
298
+ { ...col, _defaultDigit: 2 },
299
+ false
300
+ )
301
+ : newNode[col._key];
302
+ }
303
+
304
+ return newNode;
305
+ }, node);
306
+ } else {
307
+ node.isLeaf = true;
308
+ }
309
+
310
+ return [
311
+ ...newList,
312
+ node
313
+ ];
314
+ }, []);
315
+
316
+ return loop(tree);
317
+ },
318
+ getParentNode (tree = [], curNode) {
319
+ if (curNode.level === 1) {
320
+ return {
321
+ children: tree
322
+ };
323
+ } else {
324
+ let parentNode;
325
+
326
+ const loop = (list = []) => {
327
+ return list.some(node => {
328
+ if (node.level === curNode.level - 1) {
329
+ const isExist = node.children.some(childNode => childNode._id === curNode._id);
330
+ parentNode = node;
331
+ return isExist;
332
+ } else {
333
+ return loop(node.children);
334
+ }
335
+ });
336
+ };
337
+
338
+ loop(tree);
339
+ return parentNode;
340
+ }
341
+ },
342
+ toggleDescendantsShow (node, bool) {
343
+ const loop = (node, isFirstSon) => {
344
+ if (node.children && node.children.length) {
345
+ node.children.forEach(subNode => {
346
+ if (isFirstSon) {
347
+ this.$set(subNode, "__isRendered__", true);
348
+ this.$set(subNode, "__isShow__", bool);
349
+ } else {
350
+ if (bool) {
351
+ this.$set(subNode, "__isShow__", subNode.__isTmpShow__);
352
+ } else {
353
+ this.$set(subNode, "__isTmpShow__", subNode.__isShow__);
354
+ this.$set(subNode, "__isShow__", false);
355
+ }
356
+ }
357
+
358
+ loop(subNode);
359
+ });
360
+ }
361
+ };
362
+
363
+ loop(node, true);
201
364
  }
202
365
  }
203
366
  };