bri-components 1.3.60 → 1.3.62

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.
@@ -1,38 +1,13 @@
1
1
  <template>
2
2
  <div class="DshTreeTable">
3
- <div class="DshTreeTable-top">
4
- <div class="DshTreeTable-top-status">
5
- <span class="summary">{{ rowsNumStr }};</span>
6
-
7
- <div
8
- v-if="searchFormList.length"
9
- class="logic"
10
- >
11
- <div class="logic-title">{{ selfLogicPropsObj._name }}:</div>
12
- <dsh-select
13
- class="logic-option"
14
- :value="dftAdvSearch"
15
- :propsObj="selfLogicPropsObj"
16
- ></dsh-select>
17
- </div>
18
- </div>
19
-
20
- <dsh-buttons
21
- class="DshTreeTable-top-btns"
22
- itemClass="DshTreeTable-top-btns-item"
23
- :list="$getOperationList(topOperationBtns)"
24
- @click="$dispatchEvent($event)"
25
- ></dsh-buttons>
26
- </div>
3
+ <!-- 顶部 -->
4
+ <dsh-render :render="getTableTopRender()"></dsh-render>
27
5
 
28
6
  <!-- 搜索条件 -->
29
- <dsh-default-search
30
- v-if="searchFormList.length && !isEnlarge"
31
- :formList="searchFormList"
32
- :initValue="dftAdvSearch.conditions"
33
- :labelWidth="searchLabelWidth"
34
- @change="searchCb"
35
- ></dsh-default-search>
7
+ <dsh-render
8
+ v-if="!this.isEnlarge"
9
+ :render="topSearchRender"
10
+ ></dsh-render>
36
11
 
37
12
  <!-- 表格 -->
38
13
  <bri-table
@@ -46,12 +21,7 @@
46
21
  ></bri-table>
47
22
 
48
23
  <!-- 添加行 -->
49
- <dsh-buttons
50
- v-if="!isSearching"
51
- class="DshTreeTable-create"
52
- :list="$getOperationList(['canCreate'])"
53
- @click="$dispatchEvent($event)"
54
- ></dsh-buttons>
24
+ <dsh-render :render="createOperationRender"></dsh-render>
55
25
 
56
26
  <!-- 全屏模式 -->
57
27
  <dsh-modal
@@ -64,33 +34,11 @@
64
34
  v-if="isEnlargeFlag"
65
35
  class="DshTreeTable-fullscreen-inner"
66
36
  >
67
- <div class="DshTreeTable-top">
68
- <div class="DshTreeTable-top-status">
69
- <span class="summary">{{ rowsNumStr }};</span>
70
-
71
- <div
72
- v-if="searchFormList.length"
73
- class="logic"
74
- >
75
- <div class="logic-title">{{ selfLogicPropsObj._name }}:</div>
76
- <dsh-select
77
- class="logic-option"
78
- :value="dftAdvSearch"
79
- :propsObj="selfLogicPropsObj"
80
- ></dsh-select>
81
- </div>
82
- </div>
83
- </div>
37
+ <!-- 顶部 -->
38
+ <dsh-render :render="getTableTopRender(true)"></dsh-render>
84
39
 
85
40
  <!-- 搜索条件 -->
86
- <template v-if="searchFormList.length">
87
- <dsh-default-search
88
- :formList="searchFormList"
89
- :initValue="dftAdvSearch.conditions"
90
- :labelWidth="searchLabelWidth"
91
- @change="searchCb"
92
- ></dsh-default-search>
93
- </template>
41
+ <dsh-render :render="topSearchRender"></dsh-render>
94
42
 
95
43
  <!-- 表格 -->
96
44
  <bri-table
@@ -104,11 +52,7 @@
104
52
  ></bri-table>
105
53
 
106
54
  <!-- 添加行 -->
107
- <dsh-buttons
108
- class="DshTreeTable-create"
109
- :list="$getOperationList(['canCreate'])"
110
- @click="$dispatchEvent($event)"
111
- ></dsh-buttons>
55
+ <dsh-render :render="createOperationRender"></dsh-render>
112
56
  </div>
113
57
  </dsh-modal>
114
58
 
@@ -119,515 +63,33 @@
119
63
 
120
64
  <script>
121
65
  import tableBaseMixin from "./mixins/tableBaseMixin.js";
122
- import flatTableMixin from "./mixins/flatTableMixin.js";
66
+ import DshTreeTableMixin from "./mixins/DshTreeTableMixin.js";
123
67
 
124
68
  export default {
125
69
  name: "DshTreeTable",
126
70
  mixins: [
127
71
  tableBaseMixin,
128
- flatTableMixin
72
+ DshTreeTableMixin
129
73
  ],
130
74
  components: {},
131
75
  props: {},
132
76
  data () {
133
- return {
134
- deleteProperties: ["__treeIndex__", "__old__", "__isExpand__", "__isRendered__", "__isShow__", "__isTmpShow__", "__isSearchShow__"], // 除了__readonly__和__isQuote__不处理
135
- isExpandAction: false,
136
-
137
- searchMode: "flat" // "flat", "tree"
138
- };
139
- },
140
- computed: {
141
- selfPropsObj () {
142
- return {
143
- _maxLevel: 3, // 最大级数
144
- ...this.commonPropsObj
145
- };
146
- },
147
- maxLevel () {
148
- return this.selfPropsObj._maxLevel || 3;
149
- },
150
-
151
- allTreeData () {
152
- console.log("allTreeData");
153
- return this.getCalcuedTree(this.data, this.columns);
154
- },
155
- allListData () {
156
- return this.$getTreeFlatArr(this.allTreeData);
157
- },
158
- renderedListData () {
159
- return this.allListData.filter(row => {
160
- if (this.isSearching) {
161
- const bool = this.$isAdvRelyAccord(this.finalTableAdvSearch, row);
162
-
163
- // 重置
164
- row.__isSearchShow__ = false;
165
- if (bool) {
166
- row.__isRendered__ = true;
167
- row.__isSearchShow__ = true;
168
- }
169
-
170
- return bool || row.__isRendered__;
171
- } else {
172
- return row.__isRendered__;
173
- }
174
- });
175
- },
176
- showListData () {
177
- return this.renderedListData.filter(row =>
178
- this.isSearching ? !!row.__isSearchShow__ : !!row.__isShow__
179
- );
180
- },
181
- rowsNum () {
182
- return this.isSearching
183
- ? this.showListData.length
184
- : this.allListData.length;
185
- },
186
- rowsNumStr () {
187
- return `当前范围“${this.isSearching ? "筛选" : "全部"}”, 共 ${this.rowsNum} 行`;
188
- },
189
- footerData () {
190
- console.log("footerData");
191
- return this.isSearching
192
- ? []
193
- : this.useSummary && this.allListData.length
194
- ? [
195
- this.filterColumns.reduce((obj, col) => {
196
- return {
197
- ...obj,
198
- [col._key]: col._type === "number" && ![undefined, null, "", "no"].includes(col._summaryType)
199
- ? this.$calNumList(
200
- this.allListData
201
- .filter(item => item.level === 1)
202
- .map(item => item[col._key]),
203
- col._summaryType,
204
- { ...col, _defaultDigit: 2 }
205
- )
206
- : (obj[col._key] || "--")
207
- };
208
- }, {
209
- _id: this.$ObjectID().str,
210
- __index__: "汇总",
211
- __isExpand__: "-",
212
- __operation__: "——"
213
- })
214
- ]
215
- : [];
216
- },
217
-
218
- tablePropsObj () {
219
- return {
220
- maxHeight: this.contentHeight,
221
- // rowStyleOption: {
222
- // hoverHighlight: true,
223
- // clickHighlight: true,
224
- // stripe: true // 斑马纹
225
- // },
226
- cellStyleOption: {
227
- bodyCellClass: ({ row, column, rowIndex }) => {
228
- return "bri-table-td" +
229
- `${
230
- this.getRowCanEdit(row)
231
- ? " bri-table-td-edit"
232
- : ""
233
- }` +
234
- `${
235
- this.isSearching
236
- ? !row.__isSearchShow__
237
- ? " bri-table-td-hide"
238
- : ""
239
- : !row.__isShow__
240
- ? " bri-table-td-hide"
241
- : this.isExpandAction
242
- ? " bri-table-td-visible"
243
- : ""
244
- }` +
245
- `${
246
- ["__isExpand__"].includes(column._key)
247
- ? " bri-table-td-expand"
248
- : ["__index__"].includes(column._key)
249
- ? " bri-table-td-index"
250
- : ""
251
- }`;
252
- }
253
- },
254
- // 通过实例方法 hideColumnsByKeys(keys)将列隐藏,通过实例方法 showColumnsByKeys(keys)将隐藏的列显示
255
- columnHiddenOption: {
256
- defaultHiddenColumnKeys: []
257
- }
258
- };
259
- },
260
- showColumns () {
261
- return [
262
- ...(this.useSelection === true ? [this.selectionColumn] : []),
263
- this.expandColumn,
264
- ...(this.useIndex === true ? [this.indexColumn] : []),
265
- ...this.$transformToColumns(this.contentColumns),
266
- ...(this.isSearching
267
- ? []
268
- : this.$getOperationList(["canDelete"]).length
269
- ? [this.operationColumn]
270
- : [])
271
- ];
272
- },
273
- expandColumn () {
274
- return {
275
- // title: "开/合",
276
- _key: "__isExpand__",
277
- key: "__isExpand__",
278
- field: "__isExpand__",
279
- width: 48,
280
- align: "center",
281
- fixed: "left",
282
- renderBodyCell: ({ row, column, rowIndex }, h) => {
283
- return this.isSearching && this.searchMode === "flat"
284
- ? h("span", "")
285
- : row.children && row.children.length
286
- ? h("Icon", {
287
- style: {
288
- width: "16px",
289
- height: "16px",
290
- cursor: "pointer",
291
- transform: row.__isExpand__ ? "rotate(90deg)" : "rotate(0deg)",
292
- transition: "transform 0.3s"
293
- },
294
- props: {
295
- type: "ios-arrow-forward",
296
- size: "18"
297
- },
298
- on: {
299
- click: () => {
300
- this.toggleExpand(row, !row.__isExpand__);
301
- }
302
- }
303
- })
304
- : h("span", "");
305
- }
306
- };
307
- },
308
- indexColumn () {
309
- return {
310
- title: "序号",
311
- _key: "__index__",
312
- key: "__index__",
313
- field: "__index__",
314
- width: 28 + 16 + (this.maxLevel - 1) * 38,
315
- align: "left",
316
- fixed: "left",
317
- renderBodyCell: ({ row, column, rowIndex }, h) => {
318
- return [
319
- h("div", {
320
- style: {
321
- paddingLeft: `${(row.level - 1) * 18}px`,
322
- fontWeight: "500"
323
- }
324
- }, row.__treeIndex__),
325
-
326
- // 添加符
327
- this.operationMap.canCreate && row.level < this.maxLevel && !this.isSearching
328
- ? h("div", {
329
- style: {
330
- position: "absolute",
331
- bottom: "0px",
332
- right: "0px",
333
- display: "inline-block",
334
- width: "16px",
335
- height: " 16px",
336
- border: "1px solid #dcdee2",
337
- backgroundColor: "#ffffff",
338
- lineHeight: "12px",
339
- cursor: "pointer",
340
- verticalAlign: "middle",
341
- transition: "color .2s ease-in-out,border-color .2s ease-in-out"
342
- }
343
- }, [
344
- h("Icon", {
345
- style: {
346
- fontWeight: "500"
347
- },
348
- props: {
349
- type: "ios-add", // "md-add-circle"
350
- size: "14"
351
- },
352
- on: {
353
- click: () => {
354
- this.clickCreate(this.operationMap.canCreate, row, rowIndex);
355
- }
356
- }
357
- })
358
- ])
359
- : h("span", "")
360
- ];
361
- }
362
- };
363
- }
77
+ return {};
364
78
  },
79
+ computed: {},
365
80
  created () {},
366
- methods: {
367
- // 本身的初始化
368
- selfReset () {
369
- this.isExpandAction = false;
370
- this.searchMode = "flat";
371
- this.dftAdvSearch = {
372
- logic: "and",
373
- conditions: []
374
- };
375
- },
376
-
377
- // 筛选回调
378
- searchCb (conditions) {
379
- this.isExpandAction = false;
380
- this.dftAdvSearch.conditions = conditions;
381
- },
382
- // 展开/隐藏节点
383
- toggleExpand (row, bool = true) {
384
- this.isExpandAction = true;
385
- // row.__isExpand__ = bool;
386
- this.$set(row, "__isExpand__", bool);
387
-
388
- this.toggleDescendantsShow(row, bool);
389
- },
390
-
391
- // 点击 -添加一行
392
- clickCreate (operationItem, row, rowIndex) {
393
- const newRow = {
394
- ...this.$deepCopy(this.selfRowDefault),
395
- _id: this.$ObjectID().str,
396
- isLeaf: true,
397
- children: [],
398
- // __old__: false,
399
- __isExpand__: false,
400
- __isRendered__: true,
401
- __isShow__: true,
402
- __isTmpShow__: false,
403
- __isSearchShow__: false
404
- };
405
-
406
- // !row代表最上级节点
407
- if (!row) {
408
- this.data.push({
409
- ...newRow,
410
- level: 1
411
- });
412
- } else {
413
- row.children.push({
414
- ...newRow,
415
- level: row.level + 1
416
- });
417
-
418
- this.toggleExpand(row, true);
419
- }
420
- },
421
- // 点击 -删除行
422
- clickDelete (operationItem, row, rowIndex) {
423
- this.$Modal.confirm({
424
- title: "警告",
425
- content: "确定删除吗?",
426
- onOk: () => {
427
- const parentNode = this.getParentNode(row, this.data);
428
- const index = parentNode.children.findIndex(childNode => childNode._id === row._id);
429
- parentNode.children.splice(index, 1);
430
- }
431
- });
432
- },
433
-
434
- /* ------ 工具方法 ------- */
435
- // 加工树形数据
436
- getCalcuedTree (treeData = [], columns = []) {
437
- const loop = (list = [], parentRow) =>
438
- list.forEach((row) => {
439
- // 递归到叶子节点前 从上往下要处理的
440
- columns.reduce((newRow, col) => {
441
- const isNumberSummary = col._type === "number" && ![undefined, null, "", "no"].includes(col._summaryType);
442
- const isDateSummary = col._type === "date" && ![undefined, null, ""].includes(col._writeSort);
443
-
444
- if (isNumberSummary || isDateSummary) {
445
- const val = isNumberSummary
446
- ? newRow[col._key]
447
- : ["downToUp"].includes(col._writeSort)
448
- ? newRow[col._key]
449
- : !parentRow || parentRow[col._key]
450
- ? newRow[col._key]
451
- : undefined;
452
-
453
- this.$set(newRow, col._key, val);
454
- }
455
-
456
- return newRow;
457
- }, row);
458
-
459
- if (row.children && row.children.length) {
460
- row.isLeaf = false;
461
- loop(row.children, row);
462
-
463
- // 递归到叶子节点后 从下往上要处理的
464
- columns.reduce((newRow, col) => {
465
- const isNumberSummary = col._type === "number" && ![undefined, null, "", "no"].includes(col._summaryType);
466
- const isDateSummary = col._type === "date" && ![undefined, null, ""].includes(col._writeSort);
467
-
468
- if (isNumberSummary || isDateSummary) {
469
- const val = isNumberSummary
470
- ? this.$calNumList(
471
- newRow.children.map(subRow => subRow[col._key]),
472
- col._summaryType,
473
- { ...col, _defaultDigit: 2 },
474
- false
475
- )
476
- : ["downToUp"].includes(col._writeSort)
477
- ? this.$calDateList(
478
- newRow.children.map(subRow => subRow[col._key]),
479
- col._compareOperator,
480
- col._dateType
481
- )
482
- : newRow[col._key];
483
-
484
- this.$set(newRow, col._key, val);
485
- }
486
-
487
- return newRow;
488
- }, row);
489
- } else {
490
- row.isLeaf = true;
491
- }
492
-
493
- // 初次进来把前端存的状态值全部清除(除了__readonly__)
494
- if (this.initFlag) {
495
- this.deleteProperties.forEach(property => {
496
- delete row[property];
497
- });
498
-
499
- row.__old__ = true; // 老的数据都打上标记 尽管不一定会用
500
- // row.__isExpand__ = false;
501
- // row.__isSearchShow__ = false;
502
- // 第一级的需要显示出来
503
- if (row.level == 1) {
504
- row.__isRendered__ = true;
505
- row.__isShow__ = true;
506
- row.__isTmpShow__ = true;
507
- } else {
508
- // row.__isRendered__ = false;
509
- // row.__isShow__ = false;
510
- // row.__isTmpShow__ = false;
511
- }
512
- }
513
- });
514
- loop(treeData);
515
-
516
- this.initFlag = false;
517
- return treeData;
518
- },
519
- // 获取父节点
520
- getParentNode (curRow, tree = []) {
521
- if (curRow.level === 1) {
522
- return {
523
- children: tree
524
- };
525
- } else {
526
- let parentNode;
527
-
528
- const loop = (list = []) => {
529
- return list.some(row => {
530
- if (row.level === curRow.level - 1) {
531
- const isExist = row.children.some(childNode => childNode._id === curRow._id);
532
- parentNode = row;
533
- return isExist;
534
- } else {
535
- return loop(row.children);
536
- }
537
- });
538
- };
539
- loop(tree);
540
-
541
- return parentNode;
542
- }
543
- },
544
- // 切换子孙后代的显示/隐藏
545
- toggleDescendantsShow (row, bool) {
546
- const loop = (row, isFirstSon) => {
547
- if (row.children && row.children.length) {
548
- row.children.forEach(subRow => {
549
- if (isFirstSon) {
550
- // subRow.__isRendered__ = true;
551
- // subRow.__isShow__ = bool;
552
- // subRow.__isTmpShow__ = bool;
553
- this.$set(subRow, "__isRendered__", true);
554
- this.$set(subRow, "__isShow__", bool);
555
- this.$set(subRow, "__isTmpShow__", bool);
556
- } else {
557
- if (bool) {
558
- // subRow.__isShow__ = subRow.__isTmpShow__;
559
- this.$set(subRow, "__isShow__", subRow.__isTmpShow__);
560
- } else {
561
- // subRow.__isShow__ = false;
562
- this.$set(subRow, "__isShow__", false);
563
- }
564
- }
565
-
566
- loop(subRow);
567
- });
568
- }
569
- };
570
-
571
- loop(row, true);
572
- }
573
- }
81
+ methods: {}
574
82
  };
575
83
  </script>
576
84
 
577
85
  <style lang="less" scoped>
578
86
  .DshTreeTable {
579
- &-top {
580
- margin-bottom: 3px;
581
- display: flex;
582
- flex-direction: row;
583
- justify-content: space-between;
584
- align-items: center;
585
-
586
- &-status {
587
- display: flex;
588
- flex-direction: row;
589
- align-items: center;
590
-
591
- .summary {
592
- font-weight: 500;
593
- }
594
-
595
- .logic {
596
- display: flex;
597
- flex-direction: row;
598
- align-items: center;
599
- margin-left: 16px;
600
-
601
- &-title {
602
-
603
- }
604
-
605
- &-option {
606
- margin-left: 8px;
607
- margin-top: -4px;
608
- }
609
- }
610
- }
611
-
612
- &-btns {
613
- text-align: right;
614
- color: @textColor;
615
-
616
- &-item {
617
-
618
- }
619
- }
620
- }
621
87
 
622
88
  &-main {
623
89
  width: 100%;
624
90
  height: auto;
625
91
  }
626
92
 
627
- &-create {
628
- margin-top: 3px;
629
- }
630
-
631
93
  &-fullscreen {
632
94
  &-inner {
633
95
  padding: 10px 20px;
@@ -1,7 +1,7 @@
1
1
  <template>
2
- <div class="flatTableImportModal">
2
+ <div class="importModal">
3
3
  <dsh-modal
4
- class="flatTableImportModal-modal"
4
+ class="importModal-modal"
5
5
  v-model="showModal"
6
6
  :mode="modalPropsObj.mode"
7
7
  :propsObj="modalPropsObj"
@@ -34,10 +34,10 @@
34
34
  </Upload>
35
35
 
36
36
  <div v-if="file !== null">
37
- <div class="flatTableImportModal-file">
37
+ <div class="importModal-file">
38
38
  <span>文件名称: {{ file.name }}</span>
39
39
  <Icon
40
- class="flatTableImportModal-file-cancel"
40
+ class="importModal-file-cancel"
41
41
  type="ios-close"
42
42
  @click="cacelUpload"
43
43
  />
@@ -75,7 +75,7 @@
75
75
 
76
76
  <script>
77
77
  export default {
78
- name: "flatTableImportModal",
78
+ name: "importModal",
79
79
  props: {
80
80
  value: {
81
81
  type: Boolean,
@@ -237,7 +237,7 @@
237
237
  </script>
238
238
 
239
239
  <style lang="less">
240
- .flatTableImportModal {
240
+ .importModal {
241
241
 
242
242
  }
243
243
  </style>