bri-components 1.3.88 → 1.3.90

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.3.88",
3
+ "version": "1.3.90",
4
4
  "author": "dengshanghui",
5
5
  "description": "a component lib for vue project",
6
6
  "main": "src/index.js",
@@ -201,8 +201,7 @@
201
201
  "users", "departments", "labels", "flatTable", "cascaderTable", "reference", "referenceBy"
202
202
  ],
203
203
  ignoreProperties: [
204
- "_name", "_key", "_default", "_required", "_regStr", "_regMessage", "_span", "_br", "_line", "_noLabel", "_clearable",
205
- "_disabledBtns", "_disabledOldDataRow"
204
+ "_name", "_key", "_span", "_br", "_line", "_noLabel", "_required", "_regStr", "_regMessage", "_clearable", "_default"
206
205
  ]
207
206
  // subIgnoreProperties: []
208
207
  };
@@ -19,7 +19,13 @@
19
19
  :key="row._id"
20
20
  class="item"
21
21
  >
22
+ <div class="item-index">
23
+ <p>第{{ rowIndex + 1 }}条</p>
24
+ <span></span>
25
+ </div>
26
+
22
27
  <dsh-form
28
+ class="item-form"
23
29
  :canEdit="getRowCanEdit(row)"
24
30
  :formData="row"
25
31
  :formList="getRowFormList(row)"
@@ -121,6 +127,7 @@
121
127
  <script>
122
128
  import tableBaseMixin from "./mixins/tableBaseMixin.js";
123
129
  import DshFlatTableMixin from "./mixins/DshFlatTableMixin.js";
130
+ import DshDivider from "../controls/base/DshDivider.vue";
124
131
 
125
132
  export default {
126
133
  name: "DshFlatTable",
@@ -128,7 +135,9 @@
128
135
  tableBaseMixin,
129
136
  DshFlatTableMixin
130
137
  ],
131
- components: {},
138
+ components: {
139
+ DshDivider
140
+ },
132
141
  props: {},
133
142
  data () {
134
143
  return {};
@@ -143,9 +152,61 @@
143
152
  .DshFlatTable {
144
153
  &-form {
145
154
  .item {
146
- border: 1px solid #E5E5E6;
147
155
  margin-bottom: 5px;
156
+ // border: 1px solid #E5E5E6;
148
157
  position: relative;
158
+
159
+ &-index {
160
+ min-width: 130px;
161
+ max-width: 100%;
162
+ height: 32px;
163
+ padding: 0px 16px;
164
+ color: @themeColor;
165
+
166
+ p {
167
+ height: 32px;
168
+ line-height: 32px;
169
+ font-size:14px;
170
+ }
171
+
172
+ span {
173
+ display: block;
174
+ width: 100%;
175
+ height: 1px;
176
+ background: linear-gradient(270deg,rgba(166,215,250,0) 0%,rgba(109,174,242,1) 100%) bottom left no-repeat;
177
+ position: relative;
178
+
179
+ &::before {
180
+ position: absolute;
181
+ left: 0px;
182
+ top: -2px;
183
+ content: "";
184
+ width: 5px;
185
+ height: 5px;
186
+ border-radius: 5px;
187
+ background: #6DAEF2;
188
+ }
189
+ }
190
+ }
191
+
192
+ &-form {
193
+
194
+ }
195
+
196
+ &-icons {
197
+ position: absolute;
198
+ top: 10px;
199
+ right: 10px;
200
+ line-height: 18px;
201
+ z-index: 2;
202
+ display: none;
203
+ }
204
+
205
+ &:hover {
206
+ .item-icons {
207
+ display: block !important;
208
+ }
209
+ }
149
210
  }
150
211
  }
151
212
 
@@ -165,20 +226,7 @@
165
226
  .DshFlatTable {
166
227
  &-form {
167
228
  .item {
168
- &-icons {
169
- position: absolute;
170
- top: -10px;
171
- right: -10px;
172
- line-height: 18px;
173
- z-index: 2;
174
- display: none;
175
- }
176
229
 
177
- &:hover {
178
- .item-icons {
179
- display: block !important;
180
- }
181
- }
182
230
  }
183
231
  }
184
232
  }
@@ -13,6 +13,7 @@ export default {
13
13
 
14
14
  if (this.initFlag) {
15
15
  item.__old__ = true; // 标记老数据(initFlag不用在data中声明)
16
+ item.__isDefault__ = item.__isDefault__ === undefined ? this.controlKey === "_default" : item.__isDefault__; // 配置端-默认数据打上标记
16
17
  }
17
18
  item.__isRendered__ = true;
18
19
  item.__isShow__ = true;
@@ -75,10 +76,10 @@ export default {
75
76
  return [
76
77
  h("div", rowIndex + 1),
77
78
 
78
- // 添加符
79
+ // 插入一行添加符
79
80
  (this.operationMap.canCreate && this.operationMap.canCreate.disabled !== true) &&
80
- !this.isSearching
81
- // rowIndex !== this.allListData.length - 1
81
+ !this.isSearching &&
82
+ !this.showCreateBtnColKeys.length
82
83
  ? h("div", {
83
84
  style: {
84
85
  position: "absolute",
@@ -106,7 +107,7 @@ export default {
106
107
  },
107
108
  on: {
108
109
  click: () => {
109
- this.$dispatchEvent(this.operationMap.canCreate, row, rowIndex);
110
+ this.$dispatchEvent(this.operationMap.canCreate, row, rowIndex, column);
110
111
  }
111
112
  }
112
113
  })
@@ -120,14 +121,23 @@ export default {
120
121
  created () { },
121
122
  methods: {
122
123
  // 点击 -添加行
123
- clickCreate (operationItem, row, rowIndex) {
124
+ clickCreate (operationItem, row, rowIndex, column) {
125
+ const mergeRowData = row
126
+ ? this.mergeRowColumns.reduce((obj, column) => {
127
+ return column._canEditOnMergeRow === true
128
+ ? obj
129
+ : Object.assign(obj, { [column._key]: row[column._key] });
130
+ }, {})
131
+ : {};
124
132
  const newRow = {
125
133
  ...this.$deepCopy(this.selfRowDefault),
134
+ ...this.$deepCopy(mergeRowData),
126
135
  _id: this.$ObjectID().str,
127
136
  __isRendered__: true,
128
137
  __isShow__: true,
129
138
  __isTmpShow__: true,
130
- __isSearchShow__: false
139
+ __isSearchShow__: false,
140
+ __isDefault__: this.controlKey === "_default"
131
141
  };
132
142
  const list = this.data;
133
143
  const newRowIndex = row
@@ -179,10 +179,10 @@ export default {
179
179
  }
180
180
  }, row.__treeIndex__),
181
181
 
182
- // 添加符
182
+ // 插入一行添加符
183
183
  (this.operationMap.canCreate && this.operationMap.canCreate.disabled !== true) &&
184
- !this.isSearching
185
- // rowIndex !== this.allListData.length - 1
184
+ !this.isSearching &&
185
+ !this.showCreateBtnColKeys.length
186
186
  ? h("div", {
187
187
  style: {
188
188
  position: "absolute",
@@ -210,14 +210,14 @@ export default {
210
210
  },
211
211
  on: {
212
212
  click: () => {
213
- this.$dispatchEvent(this.operationMap.canCreate, row, rowIndex);
213
+ this.$dispatchEvent(this.operationMap.canCreate, row, rowIndex, column);
214
214
  }
215
215
  }
216
216
  })
217
217
  ])
218
218
  : h("span", ""),
219
219
 
220
- // 下级添加符
220
+ // 插入一行下级添加符
221
221
  (this.operationMap.canCreateChild && this.operationMap.canCreateChild.disabled !== true) &&
222
222
  !this.isSearching &&
223
223
  row.level < this.maxLevel
@@ -342,7 +342,7 @@ export default {
342
342
  /* ------ 工具方法 ------- */
343
343
  // 加工树形数据
344
344
  getCalcuedTree (treeData = [], cols = []) {
345
- const loop = (list = [], parentRow) =>
345
+ const loop = (list = [], parentRow, levelNum = 1) =>
346
346
  list.forEach((row) => {
347
347
  // 递归到叶子节点前 从上往下执行 要处理的
348
348
  cols.reduce((newRow, column) => {
@@ -365,7 +365,7 @@ export default {
365
365
 
366
366
  if (row.children && row.children.length) {
367
367
  row.isLeaf = false;
368
- loop(row.children, row);
368
+ loop(row.children, row, levelNum + 1);
369
369
 
370
370
  // 递归到叶子节点后到 从下往上执行 要处理的(非叶子节点)
371
371
  cols.reduce((newRow, column) => {
@@ -416,14 +416,15 @@ export default {
416
416
  }, row);
417
417
  }
418
418
 
419
- // 初次进来把前端存的状态值全部清除(除了__readonly__和__isQuote__不处理)
420
419
  if (this.initFlag) {
420
+ // TODO:修正数据level属性,后期可以删除
421
+ row.level = row.level || levelNum;
422
+
423
+ // 初次进来把前端存的状态值全部清除(除了__readonly__和__isQuote__不处理)
421
424
  this.deleteProperties.forEach(property => {
422
425
  delete row[property];
423
426
  });
424
-
425
427
  row.__old__ = true; // 老的数据都打上标记 尽管不一定会用
426
-
427
428
  // row.__isExpand__ = false;
428
429
  // row.__isSearchShow__ = false;
429
430
  // 第一级的需要显示出来
@@ -66,6 +66,7 @@ export default {
66
66
  initFlag: true,
67
67
  showRuleMessage: false, // 进行全体校验
68
68
  ruleRecordMap: {}, // 单元格是否发生校验的记录映射
69
+ hoverRecordMap: {},
69
70
 
70
71
  hideStatus: true,
71
72
  dftAdvSearch: {
@@ -139,16 +140,17 @@ export default {
139
140
  btnType: "default",
140
141
  icon: "md-add-circle",
141
142
  size: "default",
143
+ color: "#3DB8C5",
142
144
  long: true,
143
145
  disabled: false,
144
146
  event: "clickCreate"
145
147
  },
146
148
  canCreateChild: {
147
- name: "添加子行",
149
+ name: "添加一行下级",
148
150
  type: "canCreateChild",
149
151
  btnType: "default",
150
152
  size: "default",
151
- long: true,
153
+ color: "#3DB8C5",
152
154
  disabled: false,
153
155
  event: "clickCreateChild"
154
156
  },
@@ -158,6 +160,7 @@ export default {
158
160
  btnType: "errorText",
159
161
  icon: "ios-trash-outline",
160
162
  size: "small",
163
+ color: "#E83636",
161
164
  disabled: false,
162
165
  event: "clickDelete"
163
166
  },
@@ -194,6 +197,9 @@ export default {
194
197
  selfColumns () {
195
198
  return this.columns;
196
199
  },
200
+ mergeRowColumns () {
201
+ return this.columns.filter(column => column._mergeRow === true);
202
+ },
197
203
  filterColumns () {
198
204
  // console.log("filterColumns");
199
205
  return this.selfColumns.filter(col => this.$isAdvRelyShow(col, this.allListData, this.parentObj, true));
@@ -214,9 +220,12 @@ export default {
214
220
  _useSummary: false, // 使用汇总行
215
221
  _disabledBtns: false, // 禁用增删按钮
216
222
  // _disabledCreateBtn: false, // 置灰新增按钮,目前只内部使用,comp_web数据表配置页那块
223
+ _disabledFootCreateBtn: false, // 禁用底部新增按钮
224
+ _disabledDeleteDftRow: false, // 默认数据行禁止删除
217
225
  _disabledOldDataRow: false, // 置灰老数据行包含删除
218
-
226
+ _showCreateBtnColKeys: [], // 显示插入一行按钮的列
219
227
  _hideColKeys: [], // 隐藏/查看列字段的keys
228
+
220
229
  _searchList: [], // 作为搜索的字段
221
230
  _searchLabelWidth: 100, // 搜索的label宽度
222
231
  _tableAdvSearch: {
@@ -283,13 +292,22 @@ export default {
283
292
  return this.selfPropsObj._useSummary;
284
293
  },
285
294
  disabledBtns () {
286
- return this.selfPropsObj._disabledBtns;
295
+ return this.controlKey === "_default" ? false : this.selfPropsObj._disabledBtns;
287
296
  },
288
297
  // disabledCreateBtn () {
289
298
  // return this.selfPropsObj._disabledCreateBtn;
290
299
  // },
300
+ disabledFootCreateBtn () {
301
+ return this.selfPropsObj._disabledFootCreateBtn;
302
+ },
303
+ disabledDeleteDftRow () {
304
+ return this.selfPropsObj._disabledDeleteDftRow;
305
+ },
291
306
  disabledOldDataRow () {
292
- return this.selfPropsObj._disabledOldDataRow;
307
+ return this.controlKey === "_default" ? false : this.selfPropsObj._disabledOldDataRow;
308
+ },
309
+ showCreateBtnColKeys () {
310
+ return this.selfPropsObj._showCreateBtnColKeys;
293
311
  },
294
312
  hideColKeys () {
295
313
  return this.selfPropsObj._hideColKeys || [];
@@ -345,7 +363,7 @@ export default {
345
363
  : this.allListData.length;
346
364
  },
347
365
  rowsNumStr () {
348
- return `当前“${this.isSearching ? "筛选" : "全部"}”范围, 共 ${this.rowsNum} 行`;
366
+ return `当前${this.isSearching ? "筛选" : "全部"}数据, 共 ${this.rowsNum} ${this.showMode === "form" ? "条" : "行"}`;
349
367
  },
350
368
 
351
369
  renderedListData () {
@@ -378,13 +396,16 @@ export default {
378
396
  },
379
397
  selfRowDefault () {
380
398
  return this.selfColumns.reduce((obj, column) => {
381
- const defaultVal = this.rowDefault[column._key];
399
+ const dftInRowVal = this.rowDefault[column._key];
400
+ const dftVal = column._default;
382
401
  const initDftVal = this.initDftValMap[column._type];
383
402
 
384
403
  return Object.assign(obj, {
385
- [column._key]: this.$isEmptyData(defaultVal)
386
- ? initDftVal
387
- : defaultVal
404
+ [column._key]: this.$isEmptyData(dftInRowVal)
405
+ ? this.$isEmptyData(dftVal)
406
+ ? initDftVal
407
+ : dftVal
408
+ : dftInRowVal
388
409
  });
389
410
  }, {});
390
411
  },
@@ -424,6 +445,49 @@ export default {
424
445
  : ""
425
446
  }`;
426
447
  }
448
+ },
449
+ cellSpanOption: {
450
+ bodyCellSpan: ({ row, column, rowIndex }) => {
451
+ if (column._mergeRow === true) {
452
+ if (
453
+ rowIndex !== 0 &&
454
+ row[column._key] === this.showListData[rowIndex - 1][column._key]
455
+ ) {
456
+ return {
457
+ rowspan: 0,
458
+ colspan: 0
459
+ };
460
+ } else {
461
+ const newList = this.showListData.slice(rowIndex);
462
+ const newIndex = newList.findIndex(rowItem => row[column._key] !== rowItem[column._key]);
463
+ return {
464
+ rowspan: newIndex === -1 ? newList.length : newIndex,
465
+ colspan: 1
466
+ };
467
+ }
468
+ }
469
+ }
470
+ },
471
+ eventCustomOption: {
472
+ bodyCellEvents: ({ row, column, rowIndex }) => {
473
+ return {
474
+ click: (event) => {
475
+ // console.log("click::", row, column, rowIndex, event);
476
+ },
477
+ dblclick: (event) => {
478
+ // console.log("dblclick::", row, column, rowIndex, event);
479
+ },
480
+ contextmenu: (event) => {
481
+ // console.log("contextmenu::", row, column, rowIndex, event);
482
+ },
483
+ mouseenter: (event) => {
484
+ this.$set(this.hoverRecordMap, `${row._id}dsh${column._key}`, true);
485
+ },
486
+ mouseleave: (event) => {
487
+ this.$set(this.hoverRecordMap, `${row._id}dsh${column._key}`, false);
488
+ }
489
+ };
490
+ }
427
491
  }
428
492
  };
429
493
  },
@@ -432,6 +496,15 @@ export default {
432
496
  return this.filterColumns.map(colItem => ({
433
497
  filter: undefined,
434
498
  sortBy: undefined,
499
+ renderHeaderCell: ({ column }, h) => {
500
+ column = this.$transformDynamicProperty(column, undefined, this.parentObj);
501
+
502
+ return this.$getHeadRender(h, column, {
503
+ showRequired: this.showRequired,
504
+ showDescription: this.showDescription,
505
+ headHeightAuto: this.headHeightAuto
506
+ });
507
+ },
435
508
  renderBodyCell: ({ column, row, rowIndex }, h) => {
436
509
  column = this.$transformDynamicProperty(column, row, this.parentObj);
437
510
  column = this.resetCol(column, row);
@@ -495,17 +568,48 @@ export default {
495
568
  ? h("span", {
496
569
  class: "bri-table-td-tip"
497
570
  }, ruleResultObj.message)
498
- : undefined
499
- ];
500
- },
501
- renderHeaderCell: ({ column }, h) => {
502
- column = this.$transformDynamicProperty(column, undefined, this.parentObj);
571
+ : undefined,
503
572
 
504
- return this.$getHeadRender(h, column, {
505
- showRequired: this.showRequired,
506
- showDescription: this.showDescription,
507
- headHeightAuto: this.headHeightAuto
508
- });
573
+ // 插入一行添加符
574
+ (this.operationMap.canCreate && this.operationMap.canCreate.disabled !== true) &&
575
+ !this.isSearching &&
576
+ this.showCreateBtnColKeys.includes(column._key) &&
577
+ this.hoverRecordMap[`${row._id}dsh${column._key}`]
578
+ ? h("div", {
579
+ style: {
580
+ position: "absolute",
581
+ bottom: "0px",
582
+ right: "0px",
583
+ display: "inline-block",
584
+ width: "16px",
585
+ height: " 16px",
586
+ // border: "1px solid #3DB8C5",
587
+ // backgroundColor: "#ffffff",
588
+ lineHeight: "12px",
589
+ cursor: "pointer",
590
+ verticalAlign: "middle",
591
+ transition: "color .2s ease-in-out,border-color .2s ease-in-out"
592
+ }
593
+ }, [
594
+ h("Icon", {
595
+ style: {
596
+ fontWeight: "500",
597
+ color: "#3DB8C5"
598
+ },
599
+ props: {
600
+ type: "md-add-circle", // "ios-add"
601
+ size: "16"
602
+ // size: "14"
603
+ },
604
+ on: {
605
+ click: () => {
606
+ this.$dispatchEvent(this.operationMap.canCreate, row, rowIndex, column);
607
+ }
608
+ }
609
+ })
610
+ ])
611
+ : h("span", "")
612
+ ];
509
613
  },
510
614
  ...colItem
511
615
  }));
@@ -537,7 +641,8 @@ export default {
537
641
  props: {
538
642
  list: operationList.map(btnItem => ({
539
643
  ...btnItem,
540
- disabled: !this.getRowBtnCanEdit(row)
644
+ disabled: !this.getRowBtnCanEdit(row) ||
645
+ (this.disabledDeleteDftRow ? row.__isDefault__ === true : false)
541
646
  }))
542
647
  },
543
648
  on: {
@@ -625,15 +730,21 @@ export default {
625
730
  canHideOrShow: {
626
731
  ...this.topOperationMap.canHideOrShow,
627
732
  name: this.hideStatus ? "显示字段" : "隐藏字段"
733
+ },
734
+ canCreate: {
735
+ ...this.baseOperationMap.canCreate,
736
+ name: this.showMode === "form"
737
+ ? this.baseOperationMap.canCreate.name.replace("行", "条")
738
+ : this.baseOperationMap.canCreate.name
739
+ // disabled: !!this.disabledCreateBtn
740
+ },
741
+ canCreateChild: {
742
+ ...this.baseOperationMap.canCreateChild,
743
+ name: this.showMode === "form"
744
+ ? this.baseOperationMap.canCreateChild.name.replace("行", "条")
745
+ : this.baseOperationMap.canCreateChild.name
746
+ // disabled: !!this.disabledCreateBtn
628
747
  }
629
- // canCreate: {
630
- // ...this.baseOperationMap.canCreate,
631
- // disabled: !!this.disabledCreateBtn
632
- // },
633
- // canCreateChild: {
634
- // ...this.baseOperationMap.canCreateChild,
635
- // disabled: !!this.disabledCreateBtn
636
- // }
637
748
  };
638
749
  },
639
750
  operationMap () {
@@ -986,7 +1097,7 @@ export default {
986
1097
  });
987
1098
  },
988
1099
  createOperationRender (h, params) {
989
- return !this.isSearching
1100
+ return !this.isSearching && this.disabledFootCreateBtn !== true
990
1101
  ? h("dsh-buttons", {
991
1102
  style: {
992
1103
  "margin-top": "3px"
@@ -1079,8 +1190,13 @@ export default {
1079
1190
  !(["cascaderTable"].includes(this.controlType) && ["level", "children"].includes(col._key)) && // 级联表格类型,固定字段不编辑
1080
1191
  (col._oldReadonly ? row.__old__ !== true : true) && // 老数据行里某些列不可编辑
1081
1192
  (row.__isQuote__ ? !this.quoteDisabledColKeys.includes(col._key) : true) && // 引用过来的数据是否可编辑
1082
- col._enterType !== "calculate" && // 计算的不可编辑
1193
+ !["calculate"].includes(col._enterType) && // 计算的不可编辑
1083
1194
  col._readonly !== true && // 不能为只读
1195
+ (
1196
+ col._mergeRow === true
1197
+ ? this.controlKey === "_default" || (col._canEditOnMergeRow === true && row.__isDefault__ !== true)
1198
+ : true
1199
+ ) && // 合并单元格的且不配置"新增数据的可编辑"的不可编辑
1084
1200
  col.canEdit !== false; // 字段本身编辑权限 考虑为undefined时候
1085
1201
  },
1086
1202
  // 单元格最终编辑状态