bri-components 1.3.30 → 1.3.32

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 (28) hide show
  1. package/lib/0.bri-components.min.js +1 -1
  2. package/lib/1.bri-components.min.js +1 -1
  3. package/lib/10.bri-components.min.js +1 -0
  4. package/lib/11.bri-components.min.js +1 -0
  5. package/lib/2.bri-components.min.js +1 -1
  6. package/lib/3.bri-components.min.js +1 -1
  7. package/lib/4.bri-components.min.js +1 -1
  8. package/lib/5.bri-components.min.js +1 -1
  9. package/lib/6.bri-components.min.js +1 -1
  10. package/lib/7.bri-components.min.js +1 -0
  11. package/lib/8.bri-components.min.js +1 -0
  12. package/lib/9.bri-components.min.js +1 -0
  13. package/lib/bri-components.min.js +16 -16
  14. package/package.json +1 -1
  15. package/src/components/controls/base/BriUpload/BriUpload.vue +2 -12
  16. package/src/components/controls/base/BriUpload/uploadList.vue +35 -31
  17. package/src/components/controls/senior/cascaderTable.vue +29 -173
  18. package/src/components/controls/senior/flatTable/flatTable.vue +55 -242
  19. package/src/components/controls/senior/selectUsers/selectUsers.vue +16 -13
  20. package/src/components/form/DshDefaultSearch.vue +1 -2
  21. package/src/components/list/DshCascaderTable.vue +231 -34
  22. package/src/components/list/DshFlatTable.vue +59 -1
  23. package/src/components/list/DshTreeTable.vue +263 -87
  24. package/src/components/{controls/senior/flatTable → list/common}/flatTableImportModal.vue +1 -9
  25. package/src/components/list/mixins/flatTableMixin.js +16 -48
  26. package/src/components/list/mixins/quoteListModal.vue +215 -0
  27. package/src/components/list/mixins/tableBaseMixin.js +349 -12
  28. package/src/styles/components/list/BriTable.less +26 -7
@@ -1,14 +1,24 @@
1
1
  <template>
2
2
  <div class="DshTreeTable">
3
+ <div class="DshTreeTable-top">
4
+ <div class="DshTreeTable-top-total">{{ rowsNumStr }}</div>
5
+
6
+ <dsh-buttons
7
+ class="DshTreeTable-top-btns"
8
+ itemClass="DshTreeTable-top-btns-item"
9
+ :list="$getOperationList(topOperationBtns)"
10
+ @click="$dispatchEvent($event)"
11
+ ></dsh-buttons>
12
+ </div>
13
+
3
14
  <!-- 搜索条件 -->
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>
15
+ <dsh-default-search
16
+ v-if="searchFormList.length && !isEnlarge"
17
+ :formList="searchFormList"
18
+ :initValue="advSearchObj.conditions"
19
+ :labelWidth="searchLabelWidth"
20
+ @change="searchCb"
21
+ ></dsh-default-search>
12
22
 
13
23
  <!-- 表格 -->
14
24
  <bri-table
@@ -20,6 +30,54 @@
20
30
  @changeSelect="changeSelect"
21
31
  @selectAll="changeSelect"
22
32
  ></bri-table>
33
+
34
+ <!-- 添加行 -->
35
+ <dsh-buttons
36
+ v-if="!isSearching"
37
+ class="DshFlatTable-create"
38
+ :list="$getOperationList(['canCreate'])"
39
+ @click="$dispatchEvent($event)"
40
+ ></dsh-buttons>
41
+
42
+ <!-- 全屏模式 -->
43
+ <dsh-modal
44
+ v-model="isEnlarge"
45
+ mode="custom"
46
+ :propsObj="modalPropsObj"
47
+ >
48
+ <template v-if="isEnlargeFlag">
49
+ <!-- 搜索条件 -->
50
+ <template v-if="searchFormList.length">
51
+ <dsh-default-search
52
+ :formList="searchFormList"
53
+ :initValue="advSearchObj.conditions"
54
+ :labelWidth="searchLabelWidth"
55
+ @change="searchCb"
56
+ ></dsh-default-search>
57
+ </template>
58
+
59
+ <!-- 表格 -->
60
+ <bri-table
61
+ class="DshTreeTable-main"
62
+ :columns="showColumns"
63
+ :data="listData"
64
+ :footer-data="footerData"
65
+ :propsObj="tablePropsObj"
66
+ @changeSelect="changeSelect"
67
+ @selectAll="changeSelect"
68
+ ></bri-table>
69
+
70
+ <!-- 添加行 -->
71
+ <dsh-buttons
72
+ class="DshFlatTable-create"
73
+ :list="$getOperationList(['canCreate'])"
74
+ @click="$dispatchEvent($event)"
75
+ ></dsh-buttons>
76
+ </template>
77
+ </dsh-modal>
78
+
79
+ <!-- 各种模态框共用 -->
80
+ <dsh-render :render="dshRender"></dsh-render>
23
81
  </div>
24
82
  </template>
25
83
 
@@ -37,6 +95,10 @@
37
95
  props: {},
38
96
  data () {
39
97
  return {
98
+ deleteProperties: ["__treeIndex__", "__old__", "__isExpand__", "__isRendered__", "__isShow__", "__isTmpShow__", "__isSearchingShow__"], // 除了__old__
99
+ isExpandAction: false,
100
+
101
+ searchMode: "flat", // "flat", "tree"
40
102
  advSearchObj: {
41
103
  logic: "and",
42
104
  conditions: []
@@ -45,41 +107,75 @@
45
107
  },
46
108
  computed: {
47
109
  isSearching () {
48
- return this.searchFormList.length && this.advSearchObj.conditions.some(conditionItem => conditionItem.fieldValue.length);
110
+ return this.searchFormList.length && this.advSearchObj.conditions.some(conditionItem =>
111
+ conditionItem.fieldValue.length && conditionItem.fieldValue.some(valItem => !this.$isEmptyData(valItem))
112
+ );
113
+ },
114
+ allTreeData () {
115
+ console.log("allTreeData");
116
+ return this.getCalcuedTree(this.data, this.filterColumns);
117
+ },
118
+ allListData () {
119
+ return this.$getTreeFlatArr(this.allTreeData);
49
120
  },
50
121
  listData () {
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__)
122
+ return this.allListData.filter(row => {
123
+ if (this.isSearching) {
124
+ // 重置__isSearchingShow__为false
125
+ row.__isSearchingShow__ = false;
126
+
127
+ const bool = this.$isAdvRelyAccord(this.advSearchObj, row);
128
+ if (bool) {
129
+ row.__isRendered__ = true;
130
+ row.__isSearchingShow__ = true;
131
+ }
132
+
133
+ return bool || row.__isRendered__;
134
+ } else {
135
+ return row.__isRendered__;
136
+ }
137
+ });
138
+ },
139
+ showListData () {
140
+ return this.listData.filter(row =>
141
+ this.isSearching ? !!row.__isSearchingShow__ : !!row.__isShow__
56
142
  );
57
143
  },
144
+ rowsNum () {
145
+ return this.isSearching
146
+ ? this.showListData.length
147
+ : this.allListData.length;
148
+ },
149
+ rowsNumStr () {
150
+ return `当前范围“${this.isSearching ? "筛选" : "全部"}”, 共 ${this.rowsNum} 行`;
151
+ },
58
152
  footerData () {
59
153
  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
- : [];
154
+ return this.isSearching
155
+ ? []
156
+ : this.useSummary && this.listData.length
157
+ ? [
158
+ this.filterColumns.reduce((obj, col) => {
159
+ return {
160
+ ...obj,
161
+ [col._key]: col._type === "number" && ![undefined, null, "", "no"].includes(col._summaryType)
162
+ ? this.$calNumList(
163
+ this.listData
164
+ .filter(item => item.level === 1)
165
+ .map(item => item[col._key]),
166
+ col._summaryType,
167
+ { ...col, _defaultDigit: 2 }
168
+ )
169
+ : (obj[col._key] || "--")
170
+ };
171
+ }, {
172
+ _id: this.$ObjectID().str,
173
+ __index__: "汇总",
174
+ __isExpand__: "-",
175
+ __operation__: "——"
176
+ })
177
+ ]
178
+ : [];
83
179
  },
84
180
 
85
181
  selfPropsObj () {
@@ -120,8 +216,22 @@
120
216
  cellStyleOption: {
121
217
  bodyCellClass: ({ row, column, rowIndex }) => {
122
218
  return "bri-table-td" +
123
- `${this.canEdit ? " bri-table-td-edit" : " bri-table-td-show"}` +
124
- `${row.__isShow__ === false ? " bri-table-td-hide" : ""}` +
219
+ `${
220
+ this.getRowCanEdit(row)
221
+ ? " bri-table-td-edit"
222
+ : " bri-table-td-show"
223
+ }` +
224
+ `${
225
+ this.isSearching
226
+ ? !row.__isSearchingShow__
227
+ ? " bri-table-td-hide"
228
+ : ""
229
+ : !row.__isShow__
230
+ ? " bri-table-td-hide"
231
+ : this.isExpandAction
232
+ ? " bri-table-td-visible"
233
+ : ""
234
+ }` +
125
235
  `${
126
236
  ["__isExpand__"].includes(column._key)
127
237
  ? " bri-table-td-expand"
@@ -146,7 +256,11 @@
146
256
  this.expandColumn,
147
257
  ...(this.useIndex === true ? [this.indexColumn] : []),
148
258
  ...this.$transformToColumns(this.contentColumns),
149
- ...(this.$getOperationList(["canDelete"]).length ? [this.operationColumn] : [])
259
+ ...(this.isSearching
260
+ ? []
261
+ : this.$getOperationList(["canDelete"]).length
262
+ ? [this.operationColumn]
263
+ : [])
150
264
  ];
151
265
  },
152
266
  expandColumn () {
@@ -159,26 +273,28 @@
159
273
  align: "center",
160
274
  fixed: "left",
161
275
  renderBodyCell: ({ row, column, rowIndex }, h) => {
162
- return row.children && row.children.length
163
- ? h("Icon", {
164
- style: {
165
- width: "16px",
166
- height: "16px",
167
- cursor: "pointer",
168
- transform: row.__isExpand__ ? "rotate(90deg)" : "rotate(0deg)",
169
- transition: "transform 0.4s"
170
- },
171
- props: {
172
- type: "ios-arrow-forward",
173
- size: "18"
174
- },
175
- on: {
176
- click: () => {
177
- this.toggleExpand(row, !row.__isExpand__);
276
+ return this.isSearching && this.searchMode === "flat"
277
+ ? h("span", "")
278
+ : row.children && row.children.length
279
+ ? h("Icon", {
280
+ style: {
281
+ width: "16px",
282
+ height: "16px",
283
+ cursor: "pointer",
284
+ transform: row.__isExpand__ ? "rotate(90deg)" : "rotate(0deg)",
285
+ transition: "transform 0.3s"
286
+ },
287
+ props: {
288
+ type: "ios-arrow-forward",
289
+ size: "18"
290
+ },
291
+ on: {
292
+ click: () => {
293
+ this.toggleExpand(row, !row.__isExpand__);
294
+ }
178
295
  }
179
- }
180
- })
181
- : h("span", "");
296
+ })
297
+ : h("span", "");
182
298
  }
183
299
  };
184
300
  },
@@ -188,20 +304,20 @@
188
304
  _key: "__index__",
189
305
  key: "__index__",
190
306
  field: "__index__",
191
- width: 28 + 16 + (this.maxLevel - 1) * 36,
307
+ width: 28 + 16 + (this.maxLevel - 1) * 38,
192
308
  align: "left",
193
309
  fixed: "left",
194
310
  renderBodyCell: ({ row, column, rowIndex }, h) => {
195
311
  return [
196
312
  h("div", {
197
313
  style: {
198
- paddingLeft: `${(row.level - 1) * 16}px`,
314
+ paddingLeft: `${(row.level - 1) * 18}px`,
199
315
  fontWeight: "500"
200
316
  }
201
317
  }, row.__treeIndex__),
202
318
 
203
319
  // 添加符
204
- row.level < this.maxLevel && !this.isSearching
320
+ this.operationMap.canCreate && row.level < this.maxLevel && !this.isSearching
205
321
  ? h("div", {
206
322
  style: {
207
323
  position: "absolute",
@@ -241,30 +357,56 @@
241
357
  },
242
358
  created () {},
243
359
  methods: {
244
- // 默认筛选回调
360
+ // 本身的初始化
361
+ selfReset () {
362
+ this.isExpandAction = false;
363
+ this.searchMode = "flat";
364
+ this.advSearchObj = {
365
+ logic: "and",
366
+ conditions: []
367
+ };
368
+ },
369
+
370
+ // 筛选回调
245
371
  searchCb (conditions) {
372
+ this.isExpandAction = false;
246
373
  this.advSearchObj = {
247
374
  ...this.advSearchObj,
248
375
  conditions: conditions
249
376
  };
250
377
  },
378
+ // 展开/隐藏节点
251
379
  toggleExpand (row, bool = true) {
252
- this.$set(row, "__isRendered__", true);// 作用不大 可有可无
380
+ this.isExpandAction = true;
253
381
  this.$set(row, "__isExpand__", bool);
254
382
 
255
383
  this.toggleDescendantsShow(row, bool);
256
384
  },
385
+
257
386
  // 点击 -添加一行
258
387
  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
- });
388
+ // !row代表最上级节点
389
+ if (!row) {
390
+ this.data.push({
391
+ _id: this.$ObjectID().str,
392
+ ...this.$deepCopy(this.rowDefault),
393
+ level: 1,
394
+ isLeaf: true,
395
+ children: [],
396
+ __isRendered__: true,
397
+ __isShow__: true
398
+ });
399
+ } else {
400
+ row.children.push({
401
+ _id: this.$ObjectID().str,
402
+ ...this.$deepCopy(this.rowDefault),
403
+ level: row.level + 1,
404
+ isLeaf: true,
405
+ children: []
406
+ });
266
407
 
267
- this.toggleExpand(row, true);
408
+ this.toggleExpand(row, true);
409
+ }
268
410
  },
269
411
  // 点击 -删除行
270
412
  clickDelete (operationItem, row, rowIndex) {
@@ -272,22 +414,21 @@
272
414
  title: "警告",
273
415
  content: "确定删除吗?",
274
416
  onOk: () => {
275
- const parentNode = this.getParentNode(this.data, row);
417
+ const parentNode = this.getParentNode(row, this.data);
276
418
  const index = parentNode.children.findIndex(childNode => childNode._id === row._id);
277
419
  parentNode.children.splice(index, 1);
278
- console.log(index);
279
- console.log(parentNode);
280
420
  }
281
421
  });
282
422
  },
283
423
 
284
424
  /* ------ 工具方法 ------- */
285
- getCalcuTree (tree = [], columns) {
425
+ // 加工树形数据
426
+ getCalcuedTree (treeData = [], columns) {
286
427
  const loop = (list = []) =>
287
- list.reduce((newList, node) => {
428
+ list.forEach((node) => {
288
429
  if (node.children && node.children.length) {
289
430
  node.isLeaf = false;
290
- node.children = loop(node.children);
431
+ loop(node.children);
291
432
 
292
433
  columns.reduce((newNode, col) => {
293
434
  if (col._type === "number" && ![undefined, null, "", "no"].includes(col._summaryType)) {
@@ -307,15 +448,29 @@
307
448
  node.isLeaf = true;
308
449
  }
309
450
 
310
- return [
311
- ...newList,
312
- node
313
- ];
314
- }, []);
451
+ // 初次进来把前端存的状态值全部清除(除了__readonly__)
452
+ if (this.initFlag) {
453
+ this.deleteProperties.forEach(property => {
454
+ delete node[property];
455
+ });
315
456
 
316
- return loop(tree);
457
+ node.__old__ = true; // 老的数据都打上标记 尽管不一定会用
458
+ // 第一级的需要显示出来
459
+ if (node.level == 1) {
460
+ node.__isRendered__ = true;
461
+ node.__isShow__ = true;
462
+ node.__isTmpShow__ = true;
463
+ }
464
+ }
465
+ });
466
+
467
+ loop(treeData);
468
+ console.log("treeee");
469
+ this.initFlag = false;
470
+ return treeData;
317
471
  },
318
- getParentNode (tree = [], curNode) {
472
+ // 获取父节点
473
+ getParentNode (curNode, tree = []) {
319
474
  if (curNode.level === 1) {
320
475
  return {
321
476
  children: tree
@@ -334,11 +489,12 @@
334
489
  }
335
490
  });
336
491
  };
337
-
338
492
  loop(tree);
493
+
339
494
  return parentNode;
340
495
  }
341
496
  },
497
+ // 切换子孙后代的显示/隐藏
342
498
  toggleDescendantsShow (node, bool) {
343
499
  const loop = (node, isFirstSon) => {
344
500
  if (node.children && node.children.length) {
@@ -346,11 +502,11 @@
346
502
  if (isFirstSon) {
347
503
  this.$set(subNode, "__isRendered__", true);
348
504
  this.$set(subNode, "__isShow__", bool);
505
+ this.$set(subNode, "__isTmpShow__", bool);
349
506
  } else {
350
507
  if (bool) {
351
508
  this.$set(subNode, "__isShow__", subNode.__isTmpShow__);
352
509
  } else {
353
- this.$set(subNode, "__isTmpShow__", subNode.__isShow__);
354
510
  this.$set(subNode, "__isShow__", false);
355
511
  }
356
512
  }
@@ -368,6 +524,26 @@
368
524
 
369
525
  <style lang="less" scoped>
370
526
  .DshTreeTable {
527
+ &-top {
528
+ display: flex;
529
+ flex-direction: row;
530
+ justify-content: space-between;
531
+ align-items: center;
532
+
533
+ &-total {
534
+ font-weight: 500;
535
+ }
536
+
537
+ &-btns {
538
+ text-align: right;
539
+ color: @textColor;
540
+
541
+ &-item {
542
+
543
+ }
544
+ }
545
+ }
546
+
371
547
  &-main {
372
548
  width: 100%;
373
549
  height: auto;
@@ -237,15 +237,7 @@
237
237
  </script>
238
238
 
239
239
  <style lang="less">
240
- .sheetBatchImportModal {
241
- &-file {
242
- position: relative;
240
+ .flatTableImportModal {
243
241
 
244
- &-cancel {
245
- cursor: pointer;
246
- float: right;
247
- font-size: @titleSize;
248
- }
249
- }
250
242
  }
251
243
  </style>
@@ -32,7 +32,13 @@ export default {
32
32
  listData () {
33
33
  this.data.forEach(item => {
34
34
  !item._id && this.$set(item, "_id", this.$ObjectID().str);
35
+
36
+ if (!this.initFlag) {
37
+ item.__old__ = true; // 标记老数据(initFlag不用在data中声明)
38
+ }
35
39
  });
40
+
41
+ this.initFlag = true;
36
42
  return this.data;
37
43
  },
38
44
  oldListData () {
@@ -67,13 +73,18 @@ export default {
67
73
  : [];
68
74
  },
69
75
 
76
+ selfPropsObj () {
77
+ return {
78
+ ...this.commonPropsObj
79
+ };
80
+ },
70
81
  tablePropsObj () {
71
82
  return {
72
83
  maxHeight: this.contentHeight,
73
84
  cellStyleOption: {
74
85
  bodyCellClass: ({ row, column, rowIndex }) => {
75
86
  return "bri-table-td" +
76
- `${this.canEdit
87
+ `${this.getRowCanEdit(row)
77
88
  ? " bri-table-td-edit"
78
89
  : " bri-table-td-show"
79
90
  }`;
@@ -81,11 +92,6 @@ export default {
81
92
  }
82
93
  };
83
94
  },
84
- selfPropsObj () {
85
- return {
86
- ...this.commonPropsObj
87
- };
88
- },
89
95
 
90
96
  filterColumns () {
91
97
  return this.columns.filter(col => this.$isAdvRelyShow(col, this.listData, this.parentObj, true));
@@ -137,7 +143,7 @@ export default {
137
143
  props: {
138
144
  list: operationList.map(btnItem => ({
139
145
  ...btnItem,
140
- disabled: this.disabledOldDataRow && !row.__isCreate__
146
+ disabled: !this.getRowCanEdit(row)
141
147
  }))
142
148
  },
143
149
  on: {
@@ -226,55 +232,17 @@ export default {
226
232
  },
227
233
  ...colItem
228
234
  }));
229
- },
230
-
231
- allOperationMap () {
232
- return {
233
- canCreate: {
234
- name: "添加一行",
235
- type: "canCreate",
236
- size: "default",
237
- long: true,
238
- disabled: !!this.disabledCreateBtn,
239
- event: "clickCreate",
240
- btnType: "default"
241
- },
242
- canDelete: {
243
- name: "删除",
244
- type: "canDelete",
245
- btnType: "errorText",
246
- icon: "ios-trash-outline",
247
- size: "small",
248
- disabled: false,
249
- event: "clickDelete"
250
- },
251
- changeVal: {
252
- name: "改变输入框值",
253
- type: "changeVal",
254
- event: "changeVal"
255
- }
256
- };
257
- },
258
- operationMap () {
259
- return this.canEdit
260
- ? this.$categoryMapToMap(
261
- this.allOperationMap,
262
- null,
263
- this.disabledBtns ? ["canCreate", "canDelete"] : []
264
- )
265
- : {};
266
235
  }
267
236
  },
268
237
  created () { },
269
238
  methods: {
270
239
  // 点击 -添加行
271
- clickCreate (operationItem, row, index, list) {
240
+ clickCreate (operationItem, row, rowIndex, list) {
272
241
  const newRow = {
273
242
  ...this.$deepCopy(this.selfRowDefault),
274
- __isCreate__: true,
275
243
  _id: this.$ObjectID().str
276
244
  };
277
- const newRowIndex = index == null ? list.length : index + 1;
245
+ const newRowIndex = rowIndex == null ? list.length : rowIndex + 1;
278
246
  list.splice(newRowIndex, 0, newRow);
279
247
  this.$forceUpdate(); // 自定义页中点击添加一行没有更新页面
280
248
 
@@ -283,7 +251,7 @@ export default {
283
251
  // 点击 -删除行
284
252
  clickDelete (operationItem, row, rowIndex, list) {
285
253
  this.$Modal.confirm({
286
- title: "警告",
254
+ title: "提示",
287
255
  content: "确定删除吗?",
288
256
  onOk: () => {
289
257
  list.splice(rowIndex, 1);