bri-components 1.3.97 → 1.4.0

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.
@@ -2,16 +2,6 @@ export default {
2
2
  mixins: [],
3
3
  components: {},
4
4
  props: {
5
- tableDataObj: {
6
- type: Object,
7
- default () {
8
- return {
9
- tree: [],
10
- list: [],
11
- _treeForm: []
12
- };
13
- }
14
- },
15
5
  treeColumns: {
16
6
  type: Array,
17
7
  default () {
@@ -37,51 +27,46 @@ export default {
37
27
  color: "red",
38
28
  event: "clickDeleteCol"
39
29
  }
40
- },
41
- otherOperationMap: {
42
- clickNode: {
43
- name: "点击节点",
44
- type: "clickNode",
45
- event: "clickNode"
46
- },
47
- blurNode: {
48
- name: "节点失去焦点",
49
- type: "blurNode",
50
- event: "blurNode"
51
- },
52
- changeNode: {
53
- name: "改变节点值",
54
- type: "changeNode",
55
- event: "changeNode"
56
- }
57
- // canClearNode: {
58
- // name: "清除内容",
59
- // type: "canClearNode",
60
- // icon: "md-trash",
61
- // divided: true,
62
- // event: "clickClearNode"
63
- // },
64
- // canClearChildNodes: {
65
- // name: "清除所有下级内容",
66
- // type: "canClearChildNodes",
67
- // icon: "md-trash",
68
- // event: "clickClearChildNodes"
69
- // }
70
30
  }
31
+ // otherOperationMap: {
32
+ // canChangeNode: {
33
+ // name: "改变节点值",
34
+ // type: "canChangeNode",
35
+ // event: "changeNode"
36
+ // },
37
+ // canClickNode: {
38
+ // name: "点击节点",
39
+ // type: "canClickNode",
40
+ // event: "clickNode"
41
+ // },
42
+ // canBlurNode: {
43
+ // name: "节点失去焦点",
44
+ // type: "canBlurNode",
45
+ // event: "blurNode"
46
+ // }
47
+ // }
71
48
  };
72
49
  },
73
50
  computed: {
74
- typePropsObj () {
51
+ selfBasePropsObj () {
75
52
  return {
53
+ ...this.treeTableBasePropsObj,
76
54
  _dftReadonlyTreeColKeys: [], // 默认的数据只读的表头列
77
55
  _oldReadonlyTreeColKeys: [] // 保存的数据只读的表头列
78
56
  };
79
57
  },
80
58
  dftReadonlyTreeColKeys () {
81
- return this.isDftSet ? [] : this.selfPropsObj._dftReadonlyTreeColKeys || []; // 配置端有问题,高级以依赖时候值成undefined了
59
+ return this.isDftSet ? [] : this.selfPropsObj._dftReadonlyTreeColKeys || []; // 配置端有问题,高级依赖时值成undefined了
82
60
  },
83
61
  oldReadonlyTreeColKeys () {
84
- return this.isDftSet ? [] : this.selfPropsObj._oldReadonlyTreeColKeys || []; // 配置端有问题,高级以依赖时候值成undefined了
62
+ return this.isDftSet ? [] : this.selfPropsObj._oldReadonlyTreeColKeys || []; // 配置端有问题,高级依赖时值成undefined了
63
+ },
64
+ // 替换tableBaseMixin里的
65
+ showCreateBtnColKeys () {
66
+ return [
67
+ ...this.treeForm.map(treeFormItem => treeFormItem._key),
68
+ ...(this.selfPropsObj._showCreateBtnColKeys || [])
69
+ ];
85
70
  },
86
71
 
87
72
  allTreeData () {
@@ -125,318 +110,186 @@ export default {
125
110
  /* ----------- 操作 ---------- */
126
111
  // 表头操作 -树形表头-添加一列
127
112
  clickCreateCol (operationItem, col, colIndex) {
128
- if (col.colType === "tree" && col.level === this.treeColumns.length) {
129
- this.treeColumns.push({
130
- _id: this.$ObjectID().str,
131
- _key: this.$randomB36("Field"),
132
- _type: "textarea",
133
- _name: `${this.$numToChinese(this.treeColumns.length + 1)}级表头`,
134
- level: this.treeColumns.length + 1,
135
- canDelete: true,
136
- _treeSubForm: []
137
- });
138
- this.tableDataObj._treeForm = this.treeColumns;
113
+ this.treeColumns.push({
114
+ _id: this.$ObjectID().str,
115
+ _key: this.$randomB36("Field"),
116
+ _type: "textarea",
117
+ _name: `${this.$numToChinese(this.treeColumns.length + 1)}级表头`,
118
+ level: this.treeColumns.length + 1,
119
+ canDelete: true,
120
+ _treeSubForm: []
121
+ });
122
+ this.tableDataObj._treeForm = this.treeColumns;
139
123
 
140
- this.change("createCol", col);
141
- }
124
+ this.change("createCol", null, null, col);
142
125
  },
143
126
  // 表头操作 -树形表头-删除一列
144
127
  clickDeleteCol (operationItem, col, colIndex) {
145
- if (col.colType === "tree" && col.canDelete !== false) {
146
- this.isDeleteColStatus = true; // isDeleteStatus不用在data中定义
147
- this.treeColumns.pop();
148
- this.tableDataObj._treeForm = this.treeColumns;
149
-
150
- this.change("deleteCol", col);
151
- }
152
- },
153
-
154
- // 树形、汇总节点操作 -点击
155
- clickNode (operationItem, col, row, rowIndex) {
156
- if (col.colType === "tree") {
157
- if (
158
- (this.getIsDftRow(row) ? !this.dftReadonlyTreeColKeys.includes(col._key) : true) && // 默认行的某列是否可编辑
159
- (row.__old__ === true ? !this.oldReadonlyTreeColKeys.includes(col._key) : true) // 老数据行里某些列不可编辑
160
- ) {
161
- row.isEdit = true;
162
- this.$nextTick(() => {
163
- this.$refs[`${col._id}${row._id}`][0] && this.$refs[`${col._id}${row._id}`][0].focus();
164
- });
165
- }
166
- } else if (col.colType === "summary") {
167
- this.$Modal.warning({
168
- title: "该汇总单元格自动计算,不准手动输入!",
169
- closable: true,
170
- onOk: () => { },
171
- onCancel: () => { }
172
- });
173
- }
174
- },
175
- // 树形节点操作 -失去焦点
176
- blurNode (operationItem, col, row, rowIndex) {
177
- row.isEdit = false;
178
- },
179
- // 树形节点操作 -值改变
180
- changeNode (operationItem, col, row, rowIndex) {
181
- this.change("changeNode", col, row, rowIndex);
182
- },
183
- // // 节点操作 -清除该节点内容
184
- // clickClearNode (operationItem, row, rowIndex, col) {
185
- // row.name = "";
128
+ this.isDeleteColStatus = true; // isDeleteStatus不用在data中定义
129
+ this.treeColumns.pop();
130
+ this.tableDataObj._treeForm = this.treeColumns;
186
131
 
187
- // this.change("clearNode", null, row, rowIndex);
188
- // },
189
- // // 节点操作 -清除所有子节点内容
190
- // clickClearChildNodes (operationItem, row, rowIndex, col) {
191
- // this.$clearPropertyValToLeaf(row.children);
192
-
193
- // this.change("clearChildNodes", null, row, rowIndex);
194
- // },
195
- change (eventType, col, row, rowIndex, ...params) {
196
- this.$emit("change", this.tableDataObj, eventType, col, row, rowIndex, ...params);
132
+ this.change("deleteCol", null, null, col);
197
133
  },
198
134
 
199
- /* ----------- 渲染函数 ---------- */
135
+ /* ----------- 渲染函数(声明:为了代码更加规范清晰,return的是h相关的函数,则函数名get开头;return的是h的直接调用,函数名不要get开头)---------- */
200
136
  // 表格表头渲染函数
201
- getTableHeadRender () {
202
- return (h) => {
203
- return h("div", {
204
- class: "DshCasTable-main-center-top"
137
+ tableHeadRender (h) {
138
+ return h("div", {
139
+ class: "DshCasTable-main-center-top"
140
+ }, [
141
+ h("div", {
142
+ class: "DshCasTable-main-center-top-inner"
205
143
  }, [
206
- h("div", {
207
- class: "DshCasTable-main-center-top-inner"
144
+ h("table", {
145
+ class: "table",
146
+ attrs: {
147
+ border: "1",
148
+ cellspacin: "0",
149
+ bordercolor: "#E7EDF8"
150
+ }
208
151
  }, [
209
- h("table", {
210
- class: "table",
211
- attrs: {
212
- border: "1",
213
- cellspacin: "0",
214
- bordercolor: "#E7EDF8"
215
- }
152
+ h("tbody", {
153
+ class: ""
216
154
  }, [
217
- h("tbody", {
218
- class: ""
219
- }, [
220
- h(
221
- "tr",
222
- {},
223
- this.showColumns.map((column, colIndex) => {
224
- return h("th", {
225
- key: column._id,
226
- class: "bri-table-th",
227
- style: this.getThStyle(column, "th")
228
- }, [
229
- // 表头单元格
230
- this.getThRender(column, colIndex)(h)
231
- // h("dsh-render", {
232
- // props: {
233
- // render: this.getThRender(column, colIndex)
234
- // }
235
- // })
236
- ]);
237
- })
238
- )
239
- ])
155
+ h(
156
+ "tr",
157
+ {},
158
+ this.showColumns.map((column, colIndex) => {
159
+ return this.thRender(h, { column, colIndex });
160
+ // return h("dsh-render", {
161
+ // props: {
162
+ // render: this.thRender(h, { column, colIndex })
163
+ // }
164
+ // })
165
+ })
166
+ )
240
167
  ])
241
168
  ])
242
- ]);
243
- };
169
+ ])
170
+ ]);
244
171
  },
245
172
  // 表格内容渲染函数
246
- getTableBodyRender () {
247
- return (h) => {
248
- return h("div", {
249
- class: "DshCasTable-main-center-list"
173
+ tableBodyRender (h) {
174
+ return h("div", {
175
+ class: "DshCasTable-main-center-list"
176
+ }, [
177
+ h("div", {
178
+ class: "DshCasTable-main-center-list-inner"
250
179
  }, [
251
- h("div", {
252
- class: "DshCasTable-main-center-list-inner"
180
+ h("table", {
181
+ class: "table",
182
+ attrs: {
183
+ border: "1",
184
+ cellspacin: "0",
185
+ bordercolor: "#E7EDF8"
186
+ }
253
187
  }, [
254
- h("table", {
255
- class: "table",
256
- attrs: {
257
- border: "1",
258
- cellspacin: "0",
259
- bordercolor: "#E7EDF8"
260
- }
188
+ h("tbody", {
189
+ class: ""
261
190
  }, [
262
- h("tbody", {
263
- class: ""
264
- }, [
265
- this.showListData.length
266
- ? this.showListData.map((mixedRow, rowIndex) => {
267
- return h(
268
- "tr",
269
- {
270
- key: mixedRow._id,
271
- class: ""
272
- },
273
- this.rowColumnsArr[rowIndex].map(column => {
274
- return ["tree", "summary"].includes(column.colType)
275
- // 树节点单元格、汇总单元格
276
- ? this.getTreeTdRender(column, mixedRow[column.nodeKey || column._key], rowIndex)(h)
277
- // 普通单元格
278
- : this.getTdRender(column, mixedRow[column.nodeKey], rowIndex)(h);
279
- })
280
- );
281
- })
282
- // 无数据
283
- : h("tr", {
191
+ this.showListData.length
192
+ ? this.showListData.map((mixedRow, rowIndex) => {
193
+ return h(
194
+ "tr",
195
+ {
196
+ key: mixedRow._id,
197
+ class: ""
198
+ },
199
+ this.rowColumnsArr[rowIndex].map(column => {
200
+ return this.tdRender(h, { row: mixedRow[column.nodeKey || column._key], rowIndex, column });
201
+ // return ["tree", "summary"].includes(column.colType)
202
+ // ? this.treeTdRender(h, { row: mixedRow[column.nodeKey || column._key], rowIndex, column })
203
+ // : this.contentTdRender(h, { row: mixedRow[column.nodeKey || column._key], rowIndex, column });
204
+ })
205
+ );
206
+ })
207
+ // 无数据
208
+ : h(
209
+ "tr",
210
+ {
284
211
  class: "bri-table-nodata"
285
- }, [
286
- h("td", {
287
- style: {
288
- width: `${this.boxWidth}px`,
289
- minWidth: `${this.boxWidth}px`,
290
- maxWidth: `${this.boxWidth}px`
291
- },
292
- attrs: {
293
- rowspan: 1,
294
- colspan: this.showColumns.length
295
- }
296
- }, "暂无数据…")
297
- ])
298
- ])
212
+ },
213
+ [
214
+ this.emptyTdRender(h, {})
215
+ ]
216
+ )
299
217
  ])
300
218
  ])
301
- ]);
302
- };
219
+ ])
220
+ ]);
303
221
  },
304
222
  // 表头单元格渲染函数 (无法共用contentColumns的renderHeaderCell,因为级联老版表头的无renderHeaderCell)
305
- getThRender (column, colIndex) {
306
- column = this.$transformDynamicProperty(column, undefined, this.parentObj);
307
-
308
- return (h) => {
309
- return h("div", [
310
- this.$getHeadRender(h, column, {
311
- showRequired: this.showRequired,
312
- showDescription: this.showDescription,
313
- headHeightAuto: this.headHeightAuto
314
- }),
223
+ thRender (h, { column, colIndex }) {
224
+ return h(
225
+ "th",
226
+ {
227
+ key: column._id,
228
+ class: "bri-table-th",
229
+ style: this.getThStyle(column)
230
+ },
231
+ [
232
+ this.contentThCellRender(h, { column, colIndex }),
315
233
 
316
- // 级联最末级表头的下拉
317
- this.getDropdownRender(h, "th", column, colIndex)
318
- ]);
319
- };
234
+ this.treeThDropOperationRender(h, { column, colIndex })
235
+ ]);
320
236
  },
321
- // 树节点单元格、汇总单元格渲染函数
322
- getTreeTdRender (column, row, rowIndex) {
323
- return (h) => {
324
- return h("td", {
325
- class: {
326
- "bri-table-td": true, // 可以不要,为了position: relative,下面有
327
- [`bri-table-td-${column.colType}`]: true,
328
- "bri-table-td-edit": this.canEdit
329
- },
330
- style: this.getTdStyle(column, row, rowIndex),
237
+ emptyTdRender (h, { row, rowIndex, column }) {
238
+ return h("td", {
239
+ style: {
240
+ width: `${this.boxWidth}px`,
241
+ minWidth: `${this.boxWidth}px`,
242
+ maxWidth: `${this.boxWidth}px`
243
+ },
244
+ attrs: {
245
+ rowspan: 1,
246
+ colspan: this.showColumns.length
247
+ }
248
+ }, "暂无数据…");
249
+ },
250
+ // 内容单元格渲染函数
251
+ tdRender (h, { row, rowIndex, column }) {
252
+ return h(
253
+ "td",
254
+ {
255
+ class: this.bodyCellClass({ row, rowIndex, column }) +
256
+ `${["tree"].includes(column.colType) ? " bri-table-td-merge" : ""}`,
257
+ style: this.getTdStyle(row, rowIndex, column),
331
258
  attrs: {
332
- rowspan: this.getTdRowSpan(column, row, rowIndex),
333
- colspan: this.getTdColSpan(column, row, rowIndex)
259
+ rowspan: this.getTdRowSpan(row, rowIndex, column),
260
+ colspan: this.getTdColSpan(row, rowIndex, column)
334
261
  },
335
262
  on: {
336
- click: () => {
337
- this.$dispatchEvent(this.operationMap.clickNode, column, row, rowIndex);
263
+ mouseenter: (event) => {
264
+ this.$set(this.hoverRecordMap, `${row._id}dsh${column._key}`, true);
265
+ },
266
+ mouseleave: (event) => {
267
+ this.$set(this.hoverRecordMap, `${row._id}dsh${column._key}`, false);
338
268
  }
339
269
  }
340
- }, [
341
- column.colType === "tree"
342
- // 树节点单元格
343
- ? row.isEdit
344
- // 编辑状态
345
- ? h("Input", {
346
- ref: `${column._id}${row._id}`,
347
- props: {
348
- value: row.name,
349
- type: "textarea",
350
- autosize: {
351
- minRows: this.getTdRowSpan(column, row, rowIndex) * 3 - 1,
352
- maxRows: 100
353
- }
354
- },
355
- on: {
356
- input: val => {
357
- row.name = val;
358
- },
359
- "on-blur": () => {
360
- this.$dispatchEvent(this.operationMap.blurNode, column, row, rowIndex);
361
- },
362
- "on-change": () => {
363
- this.$dispatchEvent(this.operationMap.changeNode, column, row, rowIndex);
364
- }
365
- }
366
- })
367
- // 查看状态
368
- : [
369
- h("bri-tooltip", {
370
- props: {
371
- content: this.$transformEnterToBr(row.name),
372
- transfer: true
373
- }
374
- }, [
375
- h("span", {
376
- domProps: {
377
- innerHTML: this.$transformEnterToBr(row.name)
378
- }
379
- })
380
- ]),
381
-
382
- // 操作下拉
383
- this.getDropdownRender(h, "td", column, undefined, row, rowIndex)
384
- ]
385
- // 汇总单元格
386
- : h("span", this.getSummaryTdVal(column, row, rowIndex))
387
- ]);
388
- };
389
- },
390
- // 普通单元格渲染函数
391
- getTdRender (column, row, rowIndex) {
392
- return (h) => {
393
- return h(
394
- "td",
395
- {
396
- class: this.tablePropsObj.cellStyleOption.bodyCellClass({ row, rowIndex, column }),
397
- style: this.getTdStyle(column, row, rowIndex),
398
- on: {
399
- mouseenter: (event) => {
400
- this.$set(this.hoverRecordMap, `${row._id}dsh${column._key}`, true);
401
- },
402
- mouseleave: (event) => {
403
- this.$set(this.hoverRecordMap, `${row._id}dsh${column._key}`, false);
404
- }
405
- }
406
- },
407
- column
408
- ? column.renderBodyCell({ row, rowIndex, column }, h)
409
- : undefined
410
- );
411
- };
270
+ },
271
+ column.colType === "summary"
272
+ ? h("span", this.getSummaryTdVal(row, rowIndex, column))
273
+ : column.colType === "tree"
274
+ ? this.contentTdCellRender(h, { row, rowIndex, column }, "tree")
275
+ : column.colType === "operation"
276
+ ? this.operationTdCellRender(h, { row, rowIndex, column })
277
+ : this.contentTdCellRender(h, { row, rowIndex, column })
278
+ );
412
279
  },
413
- // 下拉渲染函数
414
- getDropdownRender (h, position = "th", column, colIndex, row, rowIndex) {
280
+ // 树形表头最末级列的下拉渲染函数
281
+ treeThDropOperationRender (h, { column, colIndex }) {
415
282
  const list = this.$getOperationList(
416
- position === "th"
283
+ column.colType === "tree" && column.level === this.treeColumns.length
417
284
  ? [
418
285
  ...(column.level < this.maxLevel ? ["canCreateCol"] : []), // 限制最大添加到几级
419
- ...(column.level > 1 && column.canDelete === true ? ["canDeleteCol"] : []) // 只有一级和最后两级节点数不一致时,不能删
286
+ ...(column.canDelete === true ? ["canDeleteCol"] : []) // 只有一级和最后两级节点数不一致时,不能删
420
287
  ]
421
- : row.isLeaf === true
422
- ? [
423
- "canCreate",
424
- ...(this.getRowBtnCanEdit(row, rowIndex) ? ["canDelete"] : [])
425
- ]
426
- : [
427
- "canCreate",
428
- "canCreateChild",
429
- ...(this.getRowBtnCanEdit(row, rowIndex) ? ["canDelete", "canDeleteChilds"] : [])
430
- ]
288
+ : []
431
289
  );
432
290
 
433
291
  return !this.isSearching &&
434
- list.length &&
435
- (
436
- position === "th"
437
- ? column.colType === "tree" && column.level === this.treeColumns.length
438
- : true
439
- )
292
+ list.length
440
293
  ? h("dsh-dropdown", {
441
294
  class: "bri-table-dropdown",
442
295
  props: {
@@ -446,9 +299,7 @@ export default {
446
299
  },
447
300
  on: {
448
301
  click: (operationItem) => {
449
- position === "th"
450
- ? this.$dispatchEvent(operationItem, column, colIndex)
451
- : this.$dispatchEvent(operationItem, row, rowIndex, column);
302
+ this.$dispatchEvent(operationItem, column, colIndex);
452
303
  }
453
304
  },
454
305
  nativeOn: {
@@ -479,54 +330,44 @@ export default {
479
330
 
480
331
  /* ----------- 方法 ---------- */
481
332
  // 表头 -获取样式
482
- getThStyle (col, position = "th") {
333
+ getThStyle (col) {
334
+ const typeData = this.$modFieldMap[col._type] || {};
483
335
  const boxColWidth = this.boxWidth / this.showColumns.length;
484
336
  const calcWidth = (col._name ? col._name.length * 12 : 48) + (col._type === "reference" ? 200 : 32);
485
337
  const dftWidth = Math.max(boxColWidth, this.widthMap[col._type], calcWidth);
486
338
  const width = col._width || dftWidth;
487
339
 
488
- const selfStyle = col.colType === "tree"
489
- ? {
490
- textAlign: col._align || "left",
491
- fontSize: "14px"
492
- }
493
- : col.colType === "summary"
494
- ? {
495
- textAlign: col._align || "right"
496
- }
497
- : {
498
- textAlign: col._align || "left"
499
- };
500
-
501
340
  return {
502
341
  width: `${width}px`,
503
342
  minWidth: `${width}px`,
504
343
  maxWidth: `${width}px`,
505
- paddingTop: position === "th" && !this.headHeightAuto ? "10px" : undefined,
506
- paddingBottom: position === "th" && !this.headHeightAuto ? "10px" : undefined,
344
+ paddingTop: !this.headHeightAuto ? "10px" : undefined,
345
+ paddingBottom: !this.headHeightAuto ? "10px" : undefined,
346
+ align: col._align || typeData.align,
507
347
  "word-break": "break-all",
508
- cursor: "pointer",
509
- ...selfStyle
348
+ cursor: "pointer"
510
349
  };
511
350
  },
512
351
 
513
352
  // 单元格 -获取样式
514
- getTdStyle (col, row, rowIndex) {
353
+ getTdStyle (row, rowIndex, col) {
515
354
  return {
516
- ...this.getThStyle(col, "td"),
517
- backgroundColor: ["tree"].includes(col.colType) ? "#fbfbfb" : "#ffffff"
355
+ ...this.getThStyle(col),
356
+ paddingTop: undefined,
357
+ paddingBottom: undefined,
358
+ backgroundColor: "#ffffff"
518
359
  };
519
360
  },
520
361
  // 单元格 -获取行合并数
521
- getTdRowSpan (col, row, rowIndex) {
362
+ getTdRowSpan (row, rowIndex, col) {
522
363
  return row.total || 1;
523
364
  },
524
365
  // 单元格 -获取列合并数
525
- getTdColSpan (col, row, rowIndex) {
366
+ getTdColSpan (row, rowIndex, col) {
526
367
  return 1;
527
368
  },
528
369
  // 单元格 -汇总节点单元格-获取值
529
- getSummaryTdVal (col, row, rowIndex) {
370
+ getSummaryTdVal (row, rowIndex, col) {
530
371
  if (col._calField && col._operator) {
531
372
  const calFieldFormItem = this.selfColumns.find(item => item._key === col._calField);
532
373
 
@@ -555,12 +396,17 @@ export default {
555
396
  : "未选择算法";
556
397
  }
557
398
  },
399
+ // 列本身是否可编辑 -针对表头列
400
+ getTypeColCanEdit (row, rowIndex, col) {
401
+ return (this.getIsDftRow(row) ? !this.dftReadonlyTreeColKeys.includes(col._key) : true) && // 默认行的某列是否可编辑
402
+ (row.__old__ === true ? !this.oldReadonlyTreeColKeys.includes(col._key) : true); // 老数据行里某些列不可编辑
403
+ },
558
404
 
559
405
  /* ----------- 工具方法 ---------- */
560
406
  // 合并表头
561
407
  mergeColumns (treeForm = [], subForm = this.showContentColumns) {
562
- return treeForm
563
- .reduce((arr, treeFormItem, treeFormIndex) => {
408
+ return [
409
+ ...treeForm.reduce((arr, treeFormItem) => {
564
410
  return arr.concat(
565
411
  {
566
412
  ...treeFormItem,
@@ -574,16 +420,22 @@ export default {
574
420
  }
575
421
  ))
576
422
  );
577
- }, [])
578
- .concat(
579
- subForm.map(subFormItem => (
580
- {
581
- ...subFormItem,
423
+ }, []),
424
+ ...subForm.map(subFormItem => ({
425
+ ...subFormItem,
426
+ nodeKey: treeForm[treeForm.length - 1]._key,
427
+ colType: "data"
428
+ })),
429
+ ...(
430
+ !this.isSearching && this.$getOperationList(["canDelete"]).length
431
+ ? [{
432
+ ...this.operationColumn,
582
433
  nodeKey: treeForm[treeForm.length - 1]._key,
583
- colType: "data"
584
- }
585
- ))
586
- );
434
+ colType: "operation"
435
+ }]
436
+ : []
437
+ )
438
+ ];
587
439
  },
588
440
  // 转化树数据
589
441
  getCalcuedTree (nodes = [], treeForm = [], subForm = []) {
@@ -719,5 +571,176 @@ export default {
719
571
 
720
572
  return loop(nodes);
721
573
  }
574
+ // // 树形、汇总节点操作 -点击
575
+ // clickNode (operationItem, row, rowIndex, col) {
576
+ // if (col.colType === "tree") {
577
+ // if (
578
+ // (this.getIsDftRow(row) ? !this.dftReadonlyTreeColKeys.includes(col._key) : true) && // 默认行的某列是否可编辑
579
+ // (row.__old__ === true ? !this.oldReadonlyTreeColKeys.includes(col._key) : true) // 老数据行里某些列不可编辑
580
+ // ) {
581
+ // row.isEdit = true;
582
+ // this.$nextTick(() => {
583
+ // this.$refs[`${col._id}${row._id}`] && this.$refs[`${col._id}${row._id}`].focus();
584
+ // });
585
+ // }
586
+ // }
587
+ // else if (col.colType === "summary") {
588
+ // this.$Modal.warning({
589
+ // title: "该汇总单元格自动计算,不准手动输入!",
590
+ // closable: true,
591
+ // onOk: () => { },
592
+ // onCancel: () => { }
593
+ // });
594
+ // }
595
+ // },
596
+ // // 树形节点操作 -失去焦点
597
+ // blurNode (operationItem, row, rowIndex, col) {
598
+ // row.isEdit = false;
599
+ // },
600
+ // // 树形节点操作 -值改变
601
+ // changeNode (operationItem, row, rowIndex, col) {
602
+ // this.change("changeNode", row, rowIndex, col);
603
+ // },
604
+
605
+ // // 树节点单元格、汇总单元格渲染函数
606
+ // treeTdRender (h, { row, rowIndex, column }) {
607
+ // return h("td", {
608
+ // class: {
609
+ // "bri-table-td": true, // 可以不要,为了position: relative,下面有
610
+ // "bri-table-td-edit": this.canEdit,
611
+ // "bri-table-td-merge": column.colType === "tree"
612
+ // },
613
+ // style: this.getTdStyle(row, rowIndex, column),
614
+ // attrs: {
615
+ // rowspan: this.getTdRowSpan(row, rowIndex, column),
616
+ // colspan: this.getTdColSpan(row, rowIndex, column)
617
+ // },
618
+ // on: {
619
+ // click: () => {
620
+ // this.$dispatchEvent(this.operationMap.canClickNode, row, rowIndex, column);
621
+ // }
622
+ // }
623
+ // }, [
624
+ // column.colType === "tree"
625
+ // // 树节点单元格
626
+ // ? row.isEdit
627
+ // // 编辑状态
628
+ // ? h("Input", {
629
+ // ref: `${column._id}${row._id}`,
630
+ // props: {
631
+ // value: row.name,
632
+ // type: "textarea",
633
+ // autosize: {
634
+ // minRows: this.getTdRowSpan(row, rowIndex, column) * 3 - 1,
635
+ // maxRows: 100
636
+ // }
637
+ // },
638
+ // on: {
639
+ // input: val => {
640
+ // row.name = val;
641
+ // },
642
+ // "on-blur": () => {
643
+ // this.$dispatchEvent(this.operationMap.canBlurNode, row, rowIndex, column);
644
+ // },
645
+ // "on-change": () => {
646
+ // this.$dispatchEvent(this.operationMap.canChangeNode, row, rowIndex, column);
647
+ // }
648
+ // }
649
+ // })
650
+ // // 查看状态
651
+ // : [
652
+ // h("bri-tooltip", {
653
+ // props: {
654
+ // content: this.$transformEnterToBr(row.name),
655
+ // transfer: true
656
+ // }
657
+ // }, [
658
+ // h("span", {
659
+ // domProps: {
660
+ // innerHTML: this.$transformEnterToBr(row.name)
661
+ // }
662
+ // })
663
+ // ]),
664
+
665
+ // // 操作下拉
666
+ // this.treeTdDropOperationRender(h, { row, rowIndex, column })
667
+ // ]
668
+ // // 汇总单元格
669
+ // : h("span", this.getSummaryTdVal(row, rowIndex, column))
670
+ // ]);
671
+ // },
672
+ // // 普通单元格渲染函数
673
+ // contentTdRender (h, { row, rowIndex, column }) {
674
+ // return h(
675
+ // "td",
676
+ // {
677
+ // class: this.bodyCellClass({ row, rowIndex, column }),
678
+ // style: this.getTdStyle(row, rowIndex, column),
679
+ // on: {
680
+ // mouseenter: (event) => {
681
+ // this.$set(this.hoverRecordMap, `${row._id}dsh${column._key}`, true);
682
+ // },
683
+ // mouseleave: (event) => {
684
+ // this.$set(this.hoverRecordMap, `${row._id}dsh${column._key}`, false);
685
+ // }
686
+ // }
687
+ // },
688
+ // this.contentTdCellRender(h, { row, rowIndex, column })
689
+ // );
690
+ // },
691
+ // // 树形单元格的下拉渲染函数
692
+ // treeTdDropOperationRender (h, { row, rowIndex, column }) {
693
+ // const list = this.$getOperationList([
694
+ // "canCreate",
695
+ // ...(this.getRowDelBtnCanEdit(row, rowIndex) ? ["canDelete"] : []),
696
+ // ...(
697
+ // row.isLeaf === true
698
+ // ? []
699
+ // : [
700
+ // "canCreateChild",
701
+ // ...(this.getRowDelBtnCanEdit(row, rowIndex) ? ["canDeleteChilds"] : [])
702
+ // ]
703
+ // )
704
+ // ]);
705
+
706
+ // return !this.isSearching &&
707
+ // list.length
708
+ // ? h("dsh-dropdown", {
709
+ // class: "bri-table-dropdown",
710
+ // props: {
711
+ // menuClass: "bri-table-dropdown-list",
712
+ // trigger: "hover",
713
+ // list: list
714
+ // },
715
+ // on: {
716
+ // click: (operationItem) => {
717
+ // this.$dispatchEvent(operationItem, row, rowIndex, column);
718
+ // }
719
+ // },
720
+ // nativeOn: {
721
+ // click: (e) => {
722
+ // e.stopPropagation();
723
+ // }
724
+ // }
725
+ // }, [
726
+ // h("a", {
727
+ // style: {
728
+ // fontWeight: "500",
729
+ // color: this.appColor
730
+ // },
731
+ // attrs: {
732
+ // href: "javascript:void(0)"
733
+ // }
734
+ // }, [
735
+ // h("Icon", {
736
+ // props: {
737
+ // type: "md-arrow-dropdown-circle",
738
+ // size: "16"
739
+ // }
740
+ // })
741
+ // ])
742
+ // ])
743
+ // : undefined;
744
+ // }
722
745
  }
723
746
  };