bri-components 1.4.1 → 1.4.3

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.1",
3
+ "version": "1.4.3",
4
4
  "author": "dengshanghui",
5
5
  "description": "a component lib for vue project",
6
6
  "main": "src/index.js",
@@ -352,7 +352,8 @@
352
352
  if (
353
353
  ruleConfig.type &&
354
354
  (!ruleConfig.fields || Object.entries(ruleConfig.fields).every(arr => !arr[1].transform)) &&
355
- (!["date"].includes(formItem._type) || !["daterange", "datetimerange"].includes(formItem._dateType))
355
+ (!["date"].includes(formItem._type) || !["daterange", "datetimerange"].includes(formItem._dateType)) &&
356
+ (!["select", "checkbox"].includes(formItem._type)) // 考虑到选项用数字类型时,应该type: "number"
356
357
  ) {
357
358
  rules.push({
358
359
  message: `${formItem._name}数据格式有错!`,
@@ -38,10 +38,10 @@
38
38
  ></dsh-form>
39
39
 
40
40
  <dsh-icons
41
- v-if="$getOperationList(['canCreate', 'canDelete']).length"
41
+ v-if="$getOperationList(['canInsert', 'canDelete']).length"
42
42
  class="item-icons"
43
43
  itemClass="item-icons-item"
44
- :list="$getOperationList(['canCreate', 'canDelete'])"
44
+ :list="$getOperationList(['canInsert', 'canDelete'])"
45
45
  @click="$dispatchEvent($event, row, rowIndex)"
46
46
  ></dsh-icons>
47
47
  </div>
@@ -12,21 +12,6 @@ export default {
12
12
  data () {
13
13
  return {
14
14
  boxWidth: 0
15
- // baseOperationMap: {
16
- // canCreateCol: {
17
- // name: "添加一列",
18
- // type: "canCreateCol",
19
- // icon: "md-add",
20
- // event: "clickCreateCol"
21
- // },
22
- // canDeleteCol: {
23
- // name: "删除该列",
24
- // type: "canDeleteCol",
25
- // icon: "md-trash",
26
- // color: "red",
27
- // event: "clickDeleteCol"
28
- // }
29
- // }
30
15
  };
31
16
  },
32
17
  computed: {
@@ -89,31 +74,6 @@ export default {
89
74
  });
90
75
  },
91
76
 
92
- // /* ----------- 操作 ---------- */
93
- // // 表头操作 -树形表头-添加一列
94
- // clickCreateCol (operationItem, col, colIndex) {
95
- // this.treeColumns.push({
96
- // _id: this.$ObjectID().str,
97
- // _key: this.$randomB36("Field"),
98
- // _type: "textarea",
99
- // _name: `${this.$numToChinese(this.treeColumns.length + 1)}级表头`,
100
- // level: this.treeColumns.length + 1,
101
- // canDelete: true,
102
- // _treeSubForm: []
103
- // });
104
- // this.tableDataObj._treeForm = this.treeColumns;
105
-
106
- // this.change("createCol", null, null, col);
107
- // },
108
- // // 表头操作 -树形表头-删除一列
109
- // clickDeleteCol (operationItem, col, colIndex) {
110
- // this.isDeleteColStatus = true; // isDeleteStatus不用在data中定义
111
- // this.treeColumns.pop();
112
- // this.tableDataObj._treeForm = this.treeColumns;
113
-
114
- // this.change("deleteCol", null, null, col);
115
- // },
116
-
117
77
  /* ----------- 渲染函数(声明:为了代码更加规范清晰,return的是h相关的函数,则函数名get开头;return的是h的直接调用,函数名不要get开头)---------- */
118
78
  // 表格表头渲染函数
119
79
  tableHeadRender (h) {
@@ -209,8 +169,6 @@ export default {
209
169
  },
210
170
  [
211
171
  this.contentThCellRender(h, { column, colIndex })
212
-
213
- // this.treeThDropOperationRender(h, { column, colIndex })
214
172
  ]);
215
173
  },
216
174
  emptyTdRender (h, { row, rowIndex, column }) {
@@ -241,71 +199,19 @@ export default {
241
199
  on: {
242
200
  mouseenter: (event) => {
243
201
  this.$set(this.hoverRecordMap, `${row._id}`, true);
244
- // this.$set(this.hoverRecordMap, `${row._id}dsh${column._key}`, true);
245
202
  },
246
203
  mouseleave: (event) => {
247
204
  this.$set(this.hoverRecordMap, `${row._id}`, false);
248
- // this.$set(this.hoverRecordMap, `${row._id}dsh${column._key}`, false);
249
205
  }
250
206
  }
251
207
  },
252
208
  column.colType === "summary"
253
- ? h("span", this.getSummaryTdVal(row, rowIndex, column))
209
+ ? this.getSummaryTdVal(row, rowIndex, column)
254
210
  : column.colType === "operation"
255
211
  ? this.operationTdCellRender(h, { row, rowIndex, column })
256
212
  : this.contentTdCellRender(h, { row, rowIndex, column })
257
213
  );
258
214
  },
259
- // // 树形表头最末级列的下拉渲染函数
260
- // treeThDropOperationRender (h, { column, colIndex }) {
261
- // const list = this.$getOperationList(
262
- // column.colType === "tree" && column.level === this.treeColumns.length
263
- // ? [
264
- // ...(column.level < this.maxLevel ? ["canCreateCol"] : []), // 限制最大添加到几级
265
- // ...(column.canDelete === true ? ["canDeleteCol"] : []) // 只有一级和最后两级节点数不一致时,不能删
266
- // ]
267
- // : []
268
- // );
269
-
270
- // return !this.isSearching &&
271
- // list.length
272
- // ? h("dsh-dropdown", {
273
- // class: "bri-table-dropdown",
274
- // props: {
275
- // menuClass: "bri-table-dropdown-list",
276
- // trigger: "hover",
277
- // list: list
278
- // },
279
- // on: {
280
- // click: (operationItem) => {
281
- // this.$dispatchEvent(operationItem, column, colIndex);
282
- // }
283
- // },
284
- // nativeOn: {
285
- // click: (e) => {
286
- // e.stopPropagation();
287
- // }
288
- // }
289
- // }, [
290
- // h("a", {
291
- // style: {
292
- // fontWeight: "500",
293
- // color: this.appColor
294
- // },
295
- // attrs: {
296
- // href: "javascript:void(0)"
297
- // }
298
- // }, [
299
- // h("Icon", {
300
- // props: {
301
- // type: "md-arrow-dropdown-circle",
302
- // size: "16"
303
- // }
304
- // })
305
- // ])
306
- // ])
307
- // : undefined;
308
- // },
309
215
 
310
216
  /* ----------- 方法 ---------- */
311
217
  // 表头 -获取样式
@@ -418,7 +324,7 @@ export default {
418
324
  colType: "data"
419
325
  })),
420
326
  ...(
421
- !this.isSearching && this.$getOperationList(["canDelete"]).length
327
+ !this.isSearching && this.rowOperationList.length
422
328
  ? [{
423
329
  ...this.operationColumn,
424
330
  nodeKey: treeForm[treeForm.length - 1]._key,
@@ -449,15 +355,6 @@ export default {
449
355
 
450
356
  // 最后一列(根节点)
451
357
  if (rowItem.level === treeForm.length) {
452
- // // 处理删除了最后一列后,把根节点上的subForm属性值全部给上级节点
453
- // if (this.isDeleteColStatus) {
454
- // let subNode = rowItem.children[0];
455
- // subForm.forEach(subFormItem => {
456
- // // 用$set也可以
457
- // rowItem[subFormItem._key] = subNode[subFormItem._key];
458
- // });
459
- // }
460
-
461
358
  rowItem.children = [];
462
359
  rowItem.isLeaf = true;
463
360
 
@@ -469,13 +366,6 @@ export default {
469
366
  }
470
367
  // 非最后一列(最后一列前的列,非根节点),需继续向下循环
471
368
  else {
472
- // // 判断是否能删除最后一列(1.判断条件:判断根节点列的前一列的所有节点 都必须只有一个子结点 2.canDelete放在表头treeForm最后一项,默认true)
473
- // if (rowItem.level === treeForm.length - 1) {
474
- // if (rowItem.children.length > 1) {
475
- // treeForm[rowItem.level].canDelete = false;
476
- // }
477
- // }
478
-
479
369
  // 非最后一列的 正常的非根节点
480
370
  if (rowItem.children && rowItem.children.length) {
481
371
  loop(rowItem.children, [...parentNodes, rowItem]);
@@ -53,11 +53,7 @@ export default {
53
53
  ...(this.useSelection === true ? [this.selectionColumn] : []),
54
54
  ...(this.useIndex === true ? [this.indexColumn] : []),
55
55
  ...this.$transformToColumns(this.contentColumns),
56
- ...(
57
- !this.isSearching && this.$getOperationList(["canDelete"]).length
58
- ? [this.operationColumn]
59
- : []
60
- )
56
+ ...(!this.isSearching && this.rowOperationList.length ? [this.operationColumn] : [])
61
57
  ];
62
58
  },
63
59
  indexColumn () {
@@ -90,8 +86,9 @@ export default {
90
86
  const list = this.data;
91
87
  const newRow = this.getNewRowData();
92
88
 
93
- // 处理单元格合并相关(当前列是合并列,则该列之前的合并列,要复制这一行对应列的值;当前列是普通列,按该列前的最后合并列的操作处理)
89
+ // 处理单元格合并相关
94
90
  if (col) {
91
+ // 当前列是合并列,则该列之前的合并列,要复制这一行对应列的值;
95
92
  if (this.mergeRowColKeys.includes(col._key)) {
96
93
  const newList = this.allListData.slice(rowIndex); // 从该行开始截取
97
94
  const nextRowIndex = this.$isEmptyData(row[col._key])
@@ -110,9 +107,13 @@ export default {
110
107
  : obj;
111
108
  }, newRow);
112
109
  }
110
+ // 当前列是非合并列,按该列前的最后合并列的操作处理(操作列时,colIndex < 0)
113
111
  else {
114
112
  const colIndex = this.selfColumns.findIndex(column => column._key === col._key);
115
- const mergeRowColumns = this.selfColumns.filter((column, columnIndex) => columnIndex < colIndex && this.mergeRowColKeys.includes(column._key));
113
+ const mergeRowColumns = this.selfColumns.filter((column, columnIndex) =>
114
+ (colIndex < 0 ? true : columnIndex <= colIndex) &&
115
+ this.mergeRowColKeys.includes(column._key)
116
+ );
116
117
  mergeRowColumns.slice(0, mergeRowColumns.length - 1).reduce((obj, column) => {
117
118
  return Object.assign(obj, {
118
119
  [column._key]: this.$deepCopy(row[column._key])
@@ -140,33 +141,33 @@ export default {
140
141
  });
141
142
  },
142
143
 
144
+ /* ----------- 方法 ---------- */
143
145
  bodyCellSpan ({ row, rowIndex, column }) {
146
+ rowIndex = this.showListData.findIndex(dataItem => dataItem._id === row._id);
147
+
144
148
  // 合并单元格(单元格值为空时不合并)
145
- if (this.mergeRowColKeys.includes(column._key)) {
146
- if (this.$isEmptyData(row[column._key])) {
149
+ if (
150
+ this.mergeRowColKeys.includes(column._key) &&
151
+ rowIndex > -1 &&
152
+ !this.$isEmptyData(row[column._key])
153
+ ) {
154
+ if (
155
+ rowIndex !== 0 &&
156
+ row[column._key] === this.showListData[rowIndex - 1][column._key]
157
+ ) {
158
+ return {
159
+ rowspan: 0,
160
+ colspan: 0
161
+ };
162
+ } else {
163
+ const newList = this.showListData.slice(rowIndex);
164
+ const newIndex = newList.findIndex(rowItem => row[column._key] !== rowItem[column._key]);
165
+
147
166
  return {
148
- rowspan: 1,
167
+ rowspan: newIndex === -1 ? newList.length : newIndex,
149
168
  colspan: 1
150
169
  };
151
170
  }
152
- else {
153
- if (
154
- rowIndex !== 0 &&
155
- row[column._key] === this.showListData[rowIndex - 1][column._key]
156
- ) {
157
- return {
158
- rowspan: 0,
159
- colspan: 0
160
- };
161
- } else {
162
- const newList = this.showListData.slice(rowIndex);
163
- const newIndex = newList.findIndex(rowItem => row[column._key] !== rowItem[column._key]);
164
- return {
165
- rowspan: newIndex === -1 ? newList.length : newIndex,
166
- colspan: 1
167
- };
168
- }
169
- }
170
171
  }
171
172
  }
172
173
  }
@@ -52,11 +52,7 @@ export default {
52
52
  this.expandColumn,
53
53
  ...(this.useIndex === true ? [this.indexColumn] : []),
54
54
  ...this.$transformToColumns(this.contentColumns),
55
- ...(
56
- !this.isSearching && this.$getOperationList(["canDelete"]).length
57
- ? [this.operationColumn]
58
- : []
59
- )
55
+ ...(!this.isSearching && this.rowOperationList.length ? [this.operationColumn] : [])
60
56
  ];
61
57
  },
62
58
  expandColumn () {
@@ -100,7 +96,7 @@ export default {
100
96
  _key: "__treeIndex__",
101
97
  key: "__treeIndex__",
102
98
  field: "__treeIndex__",
103
- width: 28 + 16 + (this.maxLevel - 1) * 38,
99
+ width: 28 + 16 + (this.maxLevel - 1) * 36,
104
100
  align: "left",
105
101
  fixed: "left",
106
102
  renderBodyCell: ({ row, rowIndex, column }, h) => {
@@ -105,17 +105,28 @@ export default {
105
105
  baseOperationMap: {
106
106
  canCreate: {
107
107
  name: "添加一行",
108
+ tip: "添加一行",
108
109
  type: "canCreate",
109
110
  btnType: "default",
110
111
  icon: "md-add",
111
112
  size: "default",
112
- color: "#3DB8C5",
113
113
  long: true,
114
114
  disabled: false,
115
115
  event: "clickCreate"
116
116
  },
117
+ canInsert: {
118
+ name: "插入一行",
119
+ tip: "插入一行",
120
+ type: "canInsert",
121
+ btnType: "primaryText",
122
+ icon: "md-add",
123
+ size: "small",
124
+ disabled: false,
125
+ event: "clickCreate"
126
+ },
117
127
  canDelete: {
118
128
  name: "删除",
129
+ tip: "删除该行",
119
130
  type: "canDelete",
120
131
  btnType: "errorText",
121
132
  icon: "md-trash",
@@ -166,7 +177,7 @@ export default {
166
177
  event: "clickExport"
167
178
  },
168
179
  canEnlarge: {
169
- name: "全屏展示",
180
+ name: "全屏",
170
181
  type: "canEnlarge",
171
182
  icon: "md-expand",
172
183
  size: "small",
@@ -251,14 +262,15 @@ export default {
251
262
  }, // 引用列表筛选条件
252
263
  _isImport: false, // 导入
253
264
  _isExport: false, // 导出
265
+ _useEnlarge: true, // 全屏
254
266
 
255
267
  _default: {
256
268
  rowDefault: {},
257
269
  list: [],
258
270
  tree: []
259
271
  },
260
- ...(this.selfBasePropsObj || {}),
261
272
 
273
+ ...(this.selfBasePropsObj || {}),
262
274
  ...this.propsObj
263
275
  };
264
276
  },
@@ -386,7 +398,7 @@ export default {
386
398
  : this.allListData.length;
387
399
  },
388
400
  rowsNumStr () {
389
- return `当前${this.isSearching ? "筛选" : "全部"}数据, 共 ${this.rowsNum} ${this.showMode === "form" ? "条" : "行"}`;
401
+ return `当前${this.isSearching ? "筛选" : "全部"}数据, 共 ${this.rowsNum} ${this.showMode === "form" ? "条" : "行"};`;
390
402
  },
391
403
 
392
404
  /* 数据 */
@@ -500,8 +512,8 @@ export default {
500
512
  align: "center",
501
513
  _fixed: "right",
502
514
  fixed: "right",
503
- _width: 100,
504
- width: 100,
515
+ _width: 210,
516
+ width: 210,
505
517
  renderBodyCell: ({ row, rowIndex, column }, h) => {
506
518
  return this.operationTdCellRender(h, { row, rowIndex, column });
507
519
  }
@@ -589,6 +601,9 @@ export default {
589
601
  advSearch: this.finalTableAdvSearch
590
602
  };
591
603
  },
604
+ useEnlarge () {
605
+ return this.selfPropsObj._useEnlarge;
606
+ },
592
607
  modalPropsObj () {
593
608
  return {
594
609
  mode: "fullscreen",
@@ -615,8 +630,23 @@ export default {
615
630
  ...this.baseOperationMap.canCreate,
616
631
  name: this.showMode === "form"
617
632
  ? this.baseOperationMap.canCreate.name.replace("行", "条")
618
- : this.baseOperationMap.canCreate.name
619
- // disabled: !!this.disabledCreateBtn
633
+ : this.baseOperationMap.canCreate.name,
634
+ tip: this.showMode === "form"
635
+ ? this.baseOperationMap.canCreate.tip.replace("行", "条")
636
+ : this.baseOperationMap.canCreate.tip
637
+ },
638
+ canInsert: {
639
+ ...this.baseOperationMap.canInsert,
640
+ name: this.showMode === "form"
641
+ ? this.baseOperationMap.canInsert.name.replace("行", "条")
642
+ : this.baseOperationMap.canInsert.name,
643
+ tip: this.showMode === "form"
644
+ ? this.baseOperationMap.canInsert.tip.replace("行", "条")
645
+ : this.baseOperationMap.canInsert.tip,
646
+ color: this.appColor
647
+ // style: {
648
+ // color: this.appColor
649
+ // }
620
650
  },
621
651
  canHideOrShow: {
622
652
  ...this.topOperationMap.canHideOrShow,
@@ -631,23 +661,25 @@ export default {
631
661
  this.allOperationMap,
632
662
  undefined,
633
663
  undefined,
634
- this.canEdit
635
- ? [
636
- ...(this.disabledBtns ? [] : this.baseOperationBtns),
637
- ...this.otherOperationBtns,
638
- ...(this.isQuote ? ["canQuote"] : []),
639
- ...(this.isImport ? ["canImport"] : []),
640
-
641
- ...(this.isExport ? ["canExport"] : []),
642
- ...(this.hideColKeys.length ? ["canHideOrShow"] : []),
643
- "canEnlarge"
644
- ]
645
- : [
646
- ...(this.isExport ? ["canExport"] : []),
647
- ...(this.hideColKeys.length ? ["canHideOrShow"] : []),
648
- "canEnlarge"
649
- ]
664
+ [
665
+ ...(
666
+ this.canEdit
667
+ ? [
668
+ ...(this.disabledBtns ? [] : this.baseOperationBtns),
669
+ ...this.otherOperationBtns,
670
+ ...(this.isQuote ? ["canQuote"] : []),
671
+ ...(this.isImport ? ["canImport"] : [])
672
+ ]
673
+ : []
674
+ ),
675
+ ...(this.isExport ? ["canExport"] : []),
676
+ ...(this.useEnlarge ? ["canEnlarge"] : []),
677
+ ...(this.hideColKeys.length ? ["canHideOrShow"] : [])
678
+ ]
650
679
  );
680
+ },
681
+ rowOperationList () {
682
+ return this.$getOperationList(["canInsert", "canDelete"]);
651
683
  }
652
684
  },
653
685
  watch: {
@@ -900,7 +932,7 @@ export default {
900
932
  },
901
933
 
902
934
  /* ----------- 渲染函数(声明:为了代码更加规范清晰,return的是h相关的函数,则函数名get开头;return的是h的直接调用,函数名不要get开头)---------- */
903
- getTableTopRender (isEnlarge = false) {
935
+ getTableTopRender (inEnlarge = false) {
904
936
  return (h, params) => {
905
937
  return h("div", {
906
938
  style: {
@@ -912,43 +944,29 @@ export default {
912
944
  }
913
945
  }, [
914
946
  // 左 -统计,逻辑
915
- this.topSummaryRender(h, params),
947
+ this.topSummaryRender(h),
916
948
 
917
949
  // 右 -功能按钮
918
- isEnlarge ? undefined : this.topOperationRender(h, params)
950
+ this.topOperationRender(h, inEnlarge)
919
951
  ]);
920
952
  };
921
953
  },
922
- topSearchRender (h) {
923
- return this.searchFormList.length
924
- ? h("dsh-default-search", {
925
- props: {
926
- formList: this.searchFormList,
927
- initValue: this.dftAdvSearch.conditions,
928
- labelWidth: this.searchLabelWidth
929
- },
930
- on: {
931
- change: this.searchCb
932
- }
933
- })
934
- : undefined;
935
- },
936
954
  topSummaryRender (h) {
937
- return h("div", {
938
- style: {
939
- "display": "flex",
940
- "flex-direction": "row",
941
- "align-items": "center"
942
- }
943
- }, [
944
- h("span", {
955
+ return this.searchFormList.length
956
+ ? h("div", {
945
957
  style: {
946
- "font-weight": "500"
958
+ "display": "flex",
959
+ "flex-direction": "row",
960
+ "align-items": "center"
947
961
  }
948
- }, this.rowsNumStr + ";"),
962
+ }, [
963
+ h("span", {
964
+ style: {
965
+ "font-weight": "500"
966
+ }
967
+ }, this.rowsNumStr),
949
968
 
950
- this.searchFormList.length
951
- ? h("div", {
969
+ h("div", {
952
970
  style: {
953
971
  "display": "flex",
954
972
  "flex-direction": "row",
@@ -973,30 +991,47 @@ export default {
973
991
  }
974
992
  })
975
993
  ])
976
- : undefined
977
- ]);
978
- },
979
- topOperationRender (h) {
980
- return h("dsh-buttons", {
981
- style: {
982
- "text-align": "right"
983
- },
984
- props: {
985
- itemClass: undefined,
986
- list: this.$getOperationList(this.topOperationBtns)
987
- },
988
- on: {
989
- click: (event) => {
990
- this.$dispatchEvent(event);
991
- }
992
- },
993
- nativeOn: {
994
- click: (e) => {
995
- e.stopPropagation();
994
+ ])
995
+ : h("div", "");
996
+ },
997
+ // 全屏里不显示功能按钮
998
+ topOperationRender (h, inEnlarge) {
999
+ return inEnlarge
1000
+ ? undefined
1001
+ : h("dsh-buttons", {
1002
+ style: {
1003
+ "text-align": "right"
1004
+ },
1005
+ props: {
1006
+ itemClass: undefined,
1007
+ list: this.$getOperationList(this.topOperationBtns)
1008
+ },
1009
+ on: {
1010
+ click: (event) => {
1011
+ this.$dispatchEvent(event);
1012
+ }
1013
+ },
1014
+ nativeOn: {
1015
+ click: (e) => {
1016
+ e.stopPropagation();
1017
+ }
996
1018
  }
997
- }
998
1019
  });
999
1020
  },
1021
+ topSearchRender (h) {
1022
+ return this.searchFormList.length
1023
+ ? h("dsh-default-search", {
1024
+ props: {
1025
+ formList: this.searchFormList,
1026
+ initValue: this.dftAdvSearch.conditions,
1027
+ labelWidth: this.searchLabelWidth
1028
+ },
1029
+ on: {
1030
+ change: this.searchCb
1031
+ }
1032
+ })
1033
+ : undefined;
1034
+ },
1000
1035
  createBtnRender (h) {
1001
1036
  return !this.isSearching && this.disabledFootCreateBtn !== true
1002
1037
  ? h("dsh-buttons", {
@@ -1116,9 +1151,11 @@ export default {
1116
1151
  ];
1117
1152
  },
1118
1153
  operationTdCellRender (h, { row, rowIndex, column }) {
1119
- const operationList = this.$getOperationList(["canDelete"]).map(btnItem => ({
1154
+ const operationList = this.rowOperationList.map(btnItem => ({
1120
1155
  ...btnItem,
1121
- disabled: !this.getRowDelBtnCanEdit(row, rowIndex)
1156
+ disabled: btnItem.type === "canDelete"
1157
+ ? !this.getRowDelBtnCanEdit(row, rowIndex)
1158
+ : btnItem.disabled
1122
1159
  }));
1123
1160
 
1124
1161
  return [
@@ -1128,7 +1165,7 @@ export default {
1128
1165
  },
1129
1166
  on: {
1130
1167
  click: (operationItem) => {
1131
- this.$dispatchEvent(operationItem, row, rowIndex);
1168
+ this.$dispatchEvent(operationItem, row, rowIndex, column);
1132
1169
  }
1133
1170
  }
1134
1171
  })
@@ -1136,151 +1173,75 @@ export default {
1136
1173
  },
1137
1174
  operationIconRender (h, { row, rowIndex, column }, iconSize = 14) {
1138
1175
  const baseBool = !this.isSearching &&
1139
- (this.showCreateBtnColKeys.length ? this.showCreateBtnColKeys.includes(column._key) : ["__index__", "__treeIndex__"].includes(column._key)) &&
1140
- this.hoverRecordMap[`${row._id}`];
1141
- // this.hoverRecordMap[`${row._id}dsh${column._key}`]
1176
+ (this.showCreateBtnColKeys.length ? this.showCreateBtnColKeys.includes(column._key) : ["__index__", "__treeIndex__"].includes(column._key));
1177
+ // this.hoverRecordMap[`${row._id}`];
1142
1178
 
1143
1179
  return [
1144
1180
  // 插入一行图标
1145
- (this.operationMap.canCreate && this.operationMap.canCreate.disabled !== true) &&
1146
- baseBool
1147
- ? h("div", {
1148
- style: {
1149
- position: "absolute",
1150
- bottom: "0px",
1151
- right: "0px",
1152
- width: `${iconSize + 2}px`,
1153
- height: `${iconSize + 2}px`,
1154
- border: `1px solid ${this.appColor}`,
1155
- borderRadius: "2px",
1156
- backgroundColor: "#ffffff",
1157
- lineHeight: `${iconSize - 2}px`,
1158
- cursor: "pointer",
1159
- verticalAlign: "middle",
1160
- transition: "color .2s ease-in-out,border-color .2s ease-in-out"
1161
- }
1162
- }, [
1163
- h("Tooltip", {
1164
- props: {
1165
- content: "插入一行",
1166
- maxWidth: "250",
1167
- transfer: true
1168
- }
1169
- }, [
1170
- h("Icon", {
1171
- style: {
1172
- fontWeight: "500",
1173
- color: this.appColor
1174
- },
1175
- props: {
1176
- type: this.operationMap.canCreate.icon,
1177
- size: iconSize
1178
- },
1179
- on: {
1180
- click: () => {
1181
- this.$dispatchEvent(this.operationMap.canCreate, row, rowIndex, column);
1182
- }
1183
- }
1184
- })
1185
- ])
1186
- ])
1181
+ baseBool
1182
+ ? this.getOperationIconRender(h, { row, rowIndex, column }, "canInsert", iconSize)
1187
1183
  : h("span", ""),
1188
1184
 
1189
1185
  // 添加一行下级图标
1190
- (this.operationMap.canCreateChild && this.operationMap.canCreateChild.disabled !== true) &&
1191
- baseBool &&
1186
+ baseBool &&
1192
1187
  row.level < this.maxLevel &&
1193
1188
  !["cascaderTable"].includes(this.inTableType) // 老版级联表格类型不要“添加下级”图标
1194
- ? h("div", {
1195
- style: {
1196
- position: "absolute",
1197
- bottom: "0px",
1198
- right: `${iconSize + 3}px`,
1199
- display: "inline-block",
1200
- width: `${iconSize + 2}px`,
1201
- height: `${iconSize + 2}px`,
1202
- border: `1px solid ${this.appColor}`,
1203
- borderRadius: "2px",
1204
- backgroundColor: "#ffffff",
1205
- lineHeight: `${iconSize - 2}px`,
1206
- cursor: "pointer",
1207
- verticalAlign: "middle",
1208
- transition: "color .2s ease-in-out,border-color .2s ease-in-out"
1209
- }
1210
- }, [
1211
- h("Tooltip", {
1212
- props: {
1213
- content: "添加下级",
1214
- maxWidth: "250",
1215
- transfer: true
1216
- }
1217
- }, [
1218
- h("Icon", {
1219
- style: {
1220
- fontWeight: "500",
1221
- color: this.appColor
1222
- },
1223
- props: {
1224
- type: this.operationMap.canCreateChild.icon,
1225
- size: iconSize
1226
- },
1227
- on: {
1228
- click: () => {
1229
- this.$dispatchEvent(this.operationMap.canCreateChild, row, rowIndex);
1230
- }
1231
- }
1232
- })
1233
- ])
1234
- ])
1189
+ ? this.getOperationIconRender(h, { row, rowIndex, column }, "canCreateChild", iconSize, true)
1235
1190
  : h("span", ""),
1236
1191
 
1237
1192
  // 删除该行图标
1238
- (this.operationMap.canDelete && this.operationMap.canDelete.disabled !== true) &&
1239
- baseBool &&
1193
+ baseBool &&
1240
1194
  this.getRowDelBtnCanEdit(row, rowIndex) &&
1241
1195
  ["cascaderTable"].includes(this.inTableType)
1242
- ? h("div", {
1243
- style: {
1244
- position: "absolute",
1245
- bottom: "0px",
1246
- right: `${iconSize + 3}px`,
1247
- width: `${iconSize + 2}px`,
1248
- height: `${iconSize + 2}px`,
1249
- border: `1px solid ${this.operationMap.canDelete.color}`,
1250
- borderRadius: "2px",
1251
- backgroundColor: "#ffffff",
1252
- lineHeight: `${iconSize - 2}px`,
1253
- cursor: "pointer",
1254
- verticalAlign: "middle",
1255
- transition: "color .2s ease-in-out,border-color .2s ease-in-out"
1196
+ ? this.getOperationIconRender(h, { row, rowIndex, column }, "canDelete", iconSize, true)
1197
+ : h("span", "")
1198
+ ];
1199
+ },
1200
+ getOperationIconRender (h, { row, rowIndex, column }, operationType, iconSize = 14, isLeft = false) {
1201
+ const operationItem = this.operationMap[operationType];
1202
+
1203
+ return operationItem && operationItem.disabled !== true
1204
+ ? h("div", {
1205
+ style: {
1206
+ position: "absolute",
1207
+ bottom: "0px",
1208
+ right: isLeft ? `${iconSize + 3}px` : "0px",
1209
+ width: `${iconSize + 2}px`,
1210
+ height: `${iconSize + 2}px`,
1211
+ border: `1px solid ${operationItem.color}`,
1212
+ borderRadius: "2px",
1213
+ backgroundColor: "#ffffff",
1214
+ lineHeight: `${iconSize - 2}px`,
1215
+ cursor: "pointer",
1216
+ verticalAlign: "middle",
1217
+ transition: "color .2s ease-in-out,border-color .2s ease-in-out"
1218
+ }
1219
+ }, [
1220
+ h("Tooltip", {
1221
+ props: {
1222
+ content: operationItem.tip,
1223
+ maxWidth: "250",
1224
+ transfer: true
1256
1225
  }
1257
1226
  }, [
1258
- h("Tooltip", {
1227
+ h("Icon", {
1228
+ style: {
1229
+ fontWeight: "500",
1230
+ color: operationItem.color
1231
+ },
1259
1232
  props: {
1260
- content: "删除该行",
1261
- maxWidth: "250",
1262
- transfer: true
1263
- }
1264
- }, [
1265
- h("Icon", {
1266
- style: {
1267
- fontWeight: "500",
1268
- color: this.operationMap.canDelete.color
1269
- },
1270
- props: {
1271
- type: this.operationMap.canDelete.icon,
1272
- size: iconSize
1273
- },
1274
- on: {
1275
- click: () => {
1276
- this.$dispatchEvent(this.operationMap.canDelete, row, rowIndex, column);
1277
- }
1233
+ type: operationItem.icon,
1234
+ size: iconSize
1235
+ },
1236
+ on: {
1237
+ click: () => {
1238
+ this.$dispatchEvent(operationItem, row, rowIndex, column);
1278
1239
  }
1279
- })
1280
- ])
1240
+ }
1241
+ })
1281
1242
  ])
1282
- : h("span", "")
1283
- ];
1243
+ ])
1244
+ : h("span", "");
1284
1245
  },
1285
1246
  bodyCellClass ({ row, rowIndex, column }) {
1286
1247
  return "bri-table-td" +
@@ -1320,11 +1281,9 @@ export default {
1320
1281
  },
1321
1282
  mouseenter: (event) => {
1322
1283
  this.$set(this.hoverRecordMap, `${row._id}`, true);
1323
- // this.$set(this.hoverRecordMap, `${row._id}dsh${column._key}`, true);
1324
1284
  },
1325
1285
  mouseleave: (event) => {
1326
1286
  this.$set(this.hoverRecordMap, `${row._id}`, false);
1327
- // this.$set(this.hoverRecordMap, `${row._id}dsh${column._key}`, false);
1328
1287
  }
1329
1288
  };
1330
1289
  },
@@ -1383,10 +1342,9 @@ export default {
1383
1342
  },
1384
1343
  // 行按钮是否可操作(删除按钮可编辑 不代表行内容是可编辑的)
1385
1344
  getRowDelBtnCanEdit (row, rowIndex) {
1386
- return this.canEdit && // 是编辑状态
1345
+ return row.__readonly__ !== true && // 不能为只读数据
1387
1346
  (this.disabledDeleteDftRow ? row.__isDefault__ !== true : true) && // 默认数据可删除
1388
- (this.disabledDeleteOldRow ? row.__old__ !== true : true) && // 老数据可删除
1389
- row.__readonly__ !== true; // 不能为只读数据
1347
+ (this.disabledDeleteOldRow ? row.__old__ !== true : true); // 老数据可删除
1390
1348
  },
1391
1349
  // 行内容是否可编辑
1392
1350
  getRowCanEdit (row, rowIndex) {
@@ -1438,28 +1396,28 @@ export default {
1438
1396
  },
1439
1397
  // 列本身是否可编辑
1440
1398
  getColCanEdit (row, rowIndex, col) {
1441
- return (
1442
- ["treeTable"].includes(this.inTableType) && ["number", "date"].includes(col._type)
1443
- ? col._summaryType
1444
- ? row.isLeaf === true
1445
- : ["downToUp", "upToDown"].includes(col._writeSort)
1446
- ? col._noLimitWrite === true
1447
- ? true
1448
- : ["downToUp"].includes(col._writeSort)
1449
- ? !(row.children && row.children.length) || row.children.every(sonRow => !this.$isEmptyData(sonRow[col._key]))
1450
- : row.level === 1 || !this.$isEmptyData(this.getParentRow(row, this.data)[col._key])
1451
- : true
1452
- : true
1453
- ) &&
1454
- !(["cascaderTable"].includes(this.controlType) && ["level", "children"].includes(col._key)) && // 层级表格的固定字段不可编辑
1455
- (col._oldReadonly ? row.__old__ !== true : true) && // 某些列在老数据行里不可编辑
1399
+ return (col._oldReadonly ? row.__old__ !== true : true) && // 某些列在老数据行里不可编辑
1456
1400
  (this.getIsDftRow(row) ? !this.dftReadonlyColKeys.includes(col._key) : true) && // 默认行的某列是否可编辑
1457
1401
  (row.__old__ === true ? !this.oldReadonlyColKeys.includes(col._key) : true) && // 老数据行里某些列不可编辑
1458
1402
  (row.__isQuote__ ? !this.quoteReadonlyColKeys.includes(col._key) : true) && // 引用过来的数据是否可编辑
1459
- !["calculate"].includes(col._enterType) && // 计算的不可编辑
1403
+ (!this.getTypeColCanEdit || this.getTypeColCanEdit(row, rowIndex, col)) &&
1404
+ (
1405
+ ["treeTable"].includes(this.inTableType) && ["number", "date"].includes(col._type)
1406
+ ? col._summaryType
1407
+ ? row.isLeaf === true
1408
+ : ["downToUp", "upToDown"].includes(col._writeSort)
1409
+ ? col._noLimitWrite === true
1410
+ ? true
1411
+ : ["downToUp"].includes(col._writeSort)
1412
+ ? !(row.children && row.children.length) || row.children.every(sonRow => !this.$isEmptyData(sonRow[col._key]))
1413
+ : row.level === 1 || !this.$isEmptyData(this.getParentRow(row, this.data)[col._key])
1414
+ : true
1415
+ : true
1416
+ ) &&
1417
+ !(["cascaderTable"].includes(this.controlType) && ["level", "children"].includes(col._key)) && // 层级表格的固定字段不可编辑
1418
+ col._enterType !== "calculate" && // 计算的不可编辑
1460
1419
  col._readonly !== true && // 只读
1461
- col.canEdit !== false && // 字段本身编辑权限 考虑为undefined时候
1462
- (!this.getTypeColCanEdit || this.getTypeColCanEdit(row, rowIndex, col));
1420
+ col.canEdit !== false; // 字段本身编辑权限 考虑为undefined时候
1463
1421
  },
1464
1422
  // 单元格最终编辑状态
1465
1423
  getUnitCanEdit (row, rowIndex, col) {
@@ -10,12 +10,12 @@ export default {
10
10
 
11
11
  baseOperationMap: {
12
12
  canCreateChild: {
13
- name: "添加一行下级",
13
+ name: "添加下级",
14
+ tip: "添加一行下级",
14
15
  type: "canCreateChild",
15
- btnType: "default",
16
+ btnType: "primaryText",
16
17
  icon: "md-add-circle",
17
- size: "default",
18
- color: "#3DB8C5",
18
+ size: "small",
19
19
  disabled: false,
20
20
  event: "clickCreateChild"
21
21
  }
@@ -70,8 +70,14 @@ export default {
70
70
  ...this.baseOperationMap.canCreateChild,
71
71
  name: this.showMode === "form"
72
72
  ? this.baseOperationMap.canCreateChild.name.replace("行", "条")
73
- : this.baseOperationMap.canCreateChild.name
74
- // disabled: !!this.disabledCreateBtn
73
+ : this.baseOperationMap.canCreateChild.name,
74
+ tip: this.showMode === "form"
75
+ ? this.baseOperationMap.canCreateChild.tip.replace("行", "条")
76
+ : this.baseOperationMap.canCreateChild.tip,
77
+ color: this.appColor
78
+ // style: {
79
+ // color: this.appColor
80
+ // }
75
81
  }
76
82
  };
77
83
  }
@@ -12,7 +12,7 @@
12
12
  :accordion="listItem._accordion"
13
13
  :simple="listItem._simple === false ? false : true"
14
14
  :hide-arrow="true"
15
- :value="listItem.expansion && [listItem._key]"
15
+ :value="listItem.expansion ? [listItem._key] : []"
16
16
  >
17
17
  <Panel :name="listItem._key">
18
18
  <div
@@ -70,7 +70,10 @@
70
70
  {{ listItem._simpleDescription }}
71
71
  </span>
72
72
  </Tooltip>
73
- <span v-else class="BriCollapseTree-listItem-rightText">{{ listItem._simpleDescription }}</span>
73
+ <span
74
+ v-else
75
+ class="BriCollapseTree-listItem-rightText"
76
+ >{{ listItem._simpleDescription }}</span>
74
77
  </div>
75
78
  </div>
76
79
  </li>