bri-components 1.3.97 → 1.3.98

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.97",
3
+ "version": "1.3.98",
4
4
  "author": "dengshanghui",
5
5
  "description": "a component lib for vue project",
6
6
  "main": "src/index.js",
@@ -349,7 +349,11 @@
349
349
  let ruleConfig = this.$getFieldRuleConfig(formItem);
350
350
 
351
351
  // 数据格式校验 -关联表格类型的会被过滤掉
352
- if (ruleConfig.type && (!ruleConfig.fields || Object.entries(ruleConfig.fields).every(arr => !arr[1].transform))) {
352
+ if (
353
+ ruleConfig.type &&
354
+ (!ruleConfig.fields || Object.entries(ruleConfig.fields).every(arr => !arr[1].transform)) &&
355
+ (!["date"].includes(formItem._type) || !["daterange", "datetimerange"].includes(formItem._dateType))
356
+ ) {
353
357
  rules.push({
354
358
  message: `${formItem._name}数据格式有错!`,
355
359
  trigger: "blur, change",
@@ -22,10 +22,10 @@
22
22
  }"
23
23
  >
24
24
  <!-- 表头 -->
25
- <dsh-render :render="getTableHeadRender()"></dsh-render>
25
+ <dsh-render :render="tableHeadRender"></dsh-render>
26
26
 
27
27
  <!-- 数据行 -->
28
- <dsh-render :render="getTableBodyRender()"></dsh-render>
28
+ <dsh-render :render="tableBodyRender"></dsh-render>
29
29
  </div>
30
30
  </div>
31
31
 
@@ -61,10 +61,10 @@
61
61
  }"
62
62
  >
63
63
  <!-- 表头 -->
64
- <dsh-render :render="getTableHeadRender()"></dsh-render>
64
+ <dsh-render :render="tableHeadRender"></dsh-render>
65
65
 
66
66
  <!-- 数据行 -->
67
- <dsh-render :render="getTableBodyRender()"></dsh-render>
67
+ <dsh-render :render="tableBodyRender"></dsh-render>
68
68
  </div>
69
69
  </div>
70
70
  </div>
@@ -39,34 +39,21 @@ export default {
39
39
  }
40
40
  },
41
41
  otherOperationMap: {
42
- clickNode: {
42
+ canChangeNode: {
43
+ name: "改变节点值",
44
+ type: "canChangeNode",
45
+ event: "changeNode"
46
+ },
47
+ canClickNode: {
43
48
  name: "点击节点",
44
- type: "clickNode",
49
+ type: "canClickNode",
45
50
  event: "clickNode"
46
51
  },
47
- blurNode: {
52
+ canBlurNode: {
48
53
  name: "节点失去焦点",
49
- type: "blurNode",
54
+ type: "canBlurNode",
50
55
  event: "blurNode"
51
- },
52
- changeNode: {
53
- name: "改变节点值",
54
- type: "changeNode",
55
- event: "changeNode"
56
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
57
  }
71
58
  };
72
59
  },
@@ -152,7 +139,7 @@ export default {
152
139
  },
153
140
 
154
141
  // 树形、汇总节点操作 -点击
155
- clickNode (operationItem, col, row, rowIndex) {
142
+ clickNode (operationItem, row, rowIndex, col) {
156
143
  if (col.colType === "tree") {
157
144
  if (
158
145
  (this.getIsDftRow(row) ? !this.dftReadonlyTreeColKeys.includes(col._key) : true) && // 默认行的某列是否可编辑
@@ -160,10 +147,11 @@ export default {
160
147
  ) {
161
148
  row.isEdit = true;
162
149
  this.$nextTick(() => {
163
- this.$refs[`${col._id}${row._id}`][0] && this.$refs[`${col._id}${row._id}`][0].focus();
150
+ this.$refs[`${col._id}${row._id}`] && this.$refs[`${col._id}${row._id}`].focus();
164
151
  });
165
152
  }
166
- } else if (col.colType === "summary") {
153
+ }
154
+ else if (col.colType === "summary") {
167
155
  this.$Modal.warning({
168
156
  title: "该汇总单元格自动计算,不准手动输入!",
169
157
  closable: true,
@@ -173,245 +161,215 @@ export default {
173
161
  }
174
162
  },
175
163
  // 树形节点操作 -失去焦点
176
- blurNode (operationItem, col, row, rowIndex) {
164
+ blurNode (operationItem, row, rowIndex, col) {
177
165
  row.isEdit = false;
178
166
  },
179
167
  // 树形节点操作 -值改变
180
- changeNode (operationItem, col, row, rowIndex) {
181
- this.change("changeNode", col, row, rowIndex);
168
+ changeNode (operationItem, row, rowIndex, col) {
169
+ this.change("changeNode", row, rowIndex, col);
182
170
  },
183
- // // 节点操作 -清除该节点内容
184
- // clickClearNode (operationItem, row, rowIndex, col) {
185
- // row.name = "";
186
-
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) {
171
+ change (eventType, row, rowIndex, col, ...params) {
196
172
  this.$emit("change", this.tableDataObj, eventType, col, row, rowIndex, ...params);
197
173
  },
198
174
 
199
- /* ----------- 渲染函数 ---------- */
175
+ /* ----------- 渲染函数(声明:为了代码更加规范清晰,return的是h相关的函数,则函数名get开头;return的是h的直接调用,函数名不要get开头)---------- */
200
176
  // 表格表头渲染函数
201
- getTableHeadRender () {
202
- return (h) => {
203
- return h("div", {
204
- class: "DshCasTable-main-center-top"
177
+ tableHeadRender (h) {
178
+ return h("div", {
179
+ class: "DshCasTable-main-center-top"
180
+ }, [
181
+ h("div", {
182
+ class: "DshCasTable-main-center-top-inner"
205
183
  }, [
206
- h("div", {
207
- class: "DshCasTable-main-center-top-inner"
184
+ h("table", {
185
+ class: "table",
186
+ attrs: {
187
+ border: "1",
188
+ cellspacin: "0",
189
+ bordercolor: "#E7EDF8"
190
+ }
208
191
  }, [
209
- h("table", {
210
- class: "table",
211
- attrs: {
212
- border: "1",
213
- cellspacin: "0",
214
- bordercolor: "#E7EDF8"
215
- }
192
+ h("tbody", {
193
+ class: ""
216
194
  }, [
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
- ])
195
+ h(
196
+ "tr",
197
+ {},
198
+ this.showColumns.map((column, colIndex) => {
199
+ return h("th", {
200
+ key: column._id,
201
+ class: "bri-table-th",
202
+ style: this.getThStyle(column)
203
+ }, [
204
+ // 表头单元格
205
+ this.thRender(h, { column, colIndex })
206
+ // h("dsh-render", {
207
+ // props: {
208
+ // render: this.thRender(h, { column, colIndex })
209
+ // }
210
+ // })
211
+ ]);
212
+ })
213
+ )
240
214
  ])
241
215
  ])
242
- ]);
243
- };
216
+ ])
217
+ ]);
244
218
  },
245
219
  // 表格内容渲染函数
246
- getTableBodyRender () {
247
- return (h) => {
248
- return h("div", {
249
- class: "DshCasTable-main-center-list"
220
+ tableBodyRender (h) {
221
+ return h("div", {
222
+ class: "DshCasTable-main-center-list"
223
+ }, [
224
+ h("div", {
225
+ class: "DshCasTable-main-center-list-inner"
250
226
  }, [
251
- h("div", {
252
- class: "DshCasTable-main-center-list-inner"
227
+ h("table", {
228
+ class: "table",
229
+ attrs: {
230
+ border: "1",
231
+ cellspacin: "0",
232
+ bordercolor: "#E7EDF8"
233
+ }
253
234
  }, [
254
- h("table", {
255
- class: "table",
256
- attrs: {
257
- border: "1",
258
- cellspacin: "0",
259
- bordercolor: "#E7EDF8"
260
- }
235
+ h("tbody", {
236
+ class: ""
261
237
  }, [
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", {
284
- 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
- ])
238
+ this.showListData.length
239
+ ? this.showListData.map((mixedRow, rowIndex) => {
240
+ return h(
241
+ "tr",
242
+ {
243
+ key: mixedRow._id,
244
+ class: ""
245
+ },
246
+ this.rowColumnsArr[rowIndex].map(column => {
247
+ return ["tree", "summary"].includes(column.colType)
248
+ // 树节点单元格、汇总单元格
249
+ ? this.treeTdRender(h, { row: mixedRow[column.nodeKey || column._key], rowIndex, column })
250
+ // 普通单元格
251
+ : this.contentTdRender(h, { row: mixedRow[column.nodeKey || column._key], rowIndex, column });
252
+ })
253
+ );
254
+ })
255
+ // 无数据
256
+ : h("tr", {
257
+ class: "bri-table-nodata"
258
+ }, [
259
+ h("td", {
260
+ style: {
261
+ width: `${this.boxWidth}px`,
262
+ minWidth: `${this.boxWidth}px`,
263
+ maxWidth: `${this.boxWidth}px`
264
+ },
265
+ attrs: {
266
+ rowspan: 1,
267
+ colspan: this.showColumns.length
268
+ }
269
+ }, "暂无数据…")
270
+ ])
299
271
  ])
300
272
  ])
301
- ]);
302
- };
273
+ ])
274
+ ]);
303
275
  },
304
276
  // 表头单元格渲染函数 (无法共用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
- }),
277
+ thRender (h, { column, colIndex }) {
278
+ return h("div", [
279
+ this.contentThCellRender(h, { column, colIndex }),
315
280
 
316
- // 级联最末级表头的下拉
317
- this.getDropdownRender(h, "th", column, colIndex)
318
- ]);
319
- };
281
+ // 级联最末级表头的下拉
282
+ this.treeDropOperationRender(h, { column, colIndex }, "th")
283
+ ]);
320
284
  },
321
285
  // 树节点单元格、汇总单元格渲染函数
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),
331
- attrs: {
332
- rowspan: this.getTdRowSpan(column, row, rowIndex),
333
- colspan: this.getTdColSpan(column, row, rowIndex)
334
- },
335
- on: {
336
- click: () => {
337
- this.$dispatchEvent(this.operationMap.clickNode, column, row, rowIndex);
338
- }
286
+ treeTdRender (h, { row, rowIndex, column }) {
287
+ return h("td", {
288
+ class: {
289
+ "bri-table-td": true, // 可以不要,为了position: relative,下面有
290
+ [`bri-table-td-${column.colType}`]: true,
291
+ "bri-table-td-edit": this.canEdit
292
+ },
293
+ style: this.getTdStyle(row, rowIndex, column),
294
+ attrs: {
295
+ rowspan: this.getTdRowSpan(row, rowIndex, column),
296
+ colspan: this.getTdColSpan(row, rowIndex, column)
297
+ },
298
+ on: {
299
+ click: () => {
300
+ this.$dispatchEvent(this.operationMap.canClickNode, row, rowIndex, column);
339
301
  }
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
- }
302
+ }
303
+ }, [
304
+ column.colType === "tree"
305
+ // 树节点单元格
306
+ ? row.isEdit
307
+ // 编辑状态
308
+ ? h("Input", {
309
+ ref: `${column._id}${row._id}`,
310
+ props: {
311
+ value: row.name,
312
+ type: "textarea",
313
+ autosize: {
314
+ minRows: this.getTdRowSpan(row, rowIndex, column) * 3 - 1,
315
+ maxRows: 100
316
+ }
317
+ },
318
+ on: {
319
+ input: val => {
320
+ row.name = val;
354
321
  },
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
- }
322
+ "on-blur": () => {
323
+ this.$dispatchEvent(this.operationMap.canBlurNode, row, rowIndex, column);
324
+ },
325
+ "on-change": () => {
326
+ this.$dispatchEvent(this.operationMap.canChangeNode, row, rowIndex, column);
327
+ }
328
+ }
329
+ })
330
+ // 查看状态
331
+ : [
332
+ h("bri-tooltip", {
333
+ props: {
334
+ content: this.$transformEnterToBr(row.name),
335
+ transfer: true
365
336
  }
366
- })
367
- // 查看状态
368
- : [
369
- h("bri-tooltip", {
370
- props: {
371
- content: this.$transformEnterToBr(row.name),
372
- transfer: true
337
+ }, [
338
+ h("span", {
339
+ domProps: {
340
+ innerHTML: this.$transformEnterToBr(row.name)
373
341
  }
374
- }, [
375
- h("span", {
376
- domProps: {
377
- innerHTML: this.$transformEnterToBr(row.name)
378
- }
379
- })
380
- ]),
342
+ })
343
+ ]),
381
344
 
382
- // 操作下拉
383
- this.getDropdownRender(h, "td", column, undefined, row, rowIndex)
384
- ]
385
- // 汇总单元格
386
- : h("span", this.getSummaryTdVal(column, row, rowIndex))
387
- ]);
388
- };
345
+ // 操作下拉
346
+ this.treeDropOperationRender(h, { row, rowIndex, column }, "td")
347
+ ]
348
+ // 汇总单元格
349
+ : h("span", this.getSummaryTdVal(row, rowIndex, column))
350
+ ]);
389
351
  },
390
352
  // 普通单元格渲染函数
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
- }
353
+ contentTdRender (h, { row, rowIndex, column }) {
354
+ return h(
355
+ "td",
356
+ {
357
+ class: this.tablePropsObj.cellStyleOption.bodyCellClass({ row, rowIndex, column }),
358
+ style: this.getTdStyle(row, rowIndex, column),
359
+ on: {
360
+ mouseenter: (event) => {
361
+ this.$set(this.hoverRecordMap, `${row._id}dsh${column._key}`, true);
362
+ },
363
+ mouseleave: (event) => {
364
+ this.$set(this.hoverRecordMap, `${row._id}dsh${column._key}`, false);
405
365
  }
406
- },
407
- column
408
- ? column.renderBodyCell({ row, rowIndex, column }, h)
409
- : undefined
410
- );
411
- };
366
+ }
367
+ },
368
+ this.contentTdCellRender(h, { row, rowIndex, column })
369
+ );
412
370
  },
413
371
  // 下拉渲染函数
414
- getDropdownRender (h, position = "th", column, colIndex, row, rowIndex) {
372
+ treeDropOperationRender (h, { row, rowIndex, column, colIndex }, position = "th") {
415
373
  const list = this.$getOperationList(
416
374
  position === "th"
417
375
  ? [
@@ -511,22 +469,22 @@ export default {
511
469
  },
512
470
 
513
471
  // 单元格 -获取样式
514
- getTdStyle (col, row, rowIndex) {
472
+ getTdStyle (row, rowIndex, col) {
515
473
  return {
516
474
  ...this.getThStyle(col, "td"),
517
475
  backgroundColor: ["tree"].includes(col.colType) ? "#fbfbfb" : "#ffffff"
518
476
  };
519
477
  },
520
478
  // 单元格 -获取行合并数
521
- getTdRowSpan (col, row, rowIndex) {
479
+ getTdRowSpan (row, rowIndex, col) {
522
480
  return row.total || 1;
523
481
  },
524
482
  // 单元格 -获取列合并数
525
- getTdColSpan (col, row, rowIndex) {
483
+ getTdColSpan (row, rowIndex, col) {
526
484
  return 1;
527
485
  },
528
486
  // 单元格 -汇总节点单元格-获取值
529
- getSummaryTdVal (col, row, rowIndex) {
487
+ getSummaryTdVal (row, rowIndex, col) {
530
488
  if (col._calField && col._operator) {
531
489
  const calFieldFormItem = this.selfColumns.find(item => item._key === col._calField);
532
490
 
@@ -115,7 +115,7 @@ export default {
115
115
  : list.length;
116
116
  list.splice(newRowIndex, 0, newRow);
117
117
 
118
- this.change("createRow", null, newRow, newRowIndex);
118
+ this.change("createRow", newRow, newRowIndex, null);
119
119
  },
120
120
  // 点击 -删除行
121
121
  clickDelete (operationItem, row, rowIndex) {
@@ -125,12 +125,12 @@ export default {
125
125
  onOk: () => {
126
126
  this.data.splice(rowIndex, 1);
127
127
 
128
- this.change("deleteRow", null, row, rowIndex);
128
+ this.change("deleteRow", row, rowIndex, null);
129
129
  }
130
130
  });
131
131
  },
132
132
 
133
- change (eventType, col, row, rowIndex, ...params) {
133
+ change (eventType, row, rowIndex, col, ...params) {
134
134
  this.$emit("change", { list: this.allListData, rowDefault: this.rowDefault }, eventType, col, row, rowIndex, ...params);
135
135
  }
136
136
  }
@@ -117,7 +117,7 @@ export default {
117
117
  },
118
118
  created () { },
119
119
  methods: {
120
- change (eventType, col, row, rowIndex, ...params) {
120
+ change (eventType, row, rowIndex, col, ...params) {
121
121
  this.$emit("change", { tree: this.data, rowDefault: this.rowDefault }, eventType, col, row, rowIndex, ...params);
122
122
  },
123
123
 
@@ -266,6 +266,12 @@ export default {
266
266
  _isImport: false, // 导入
267
267
  _isExport: false, // 导出
268
268
 
269
+ _default: {
270
+ rowDefault: {},
271
+ list: [],
272
+ tree: []
273
+ },
274
+
269
275
  ...this.propsObj,
270
276
  _contentHeight: this.propsObj._contentHeight || 500 // 表格最大高度
271
277
  };
@@ -478,82 +484,10 @@ export default {
478
484
  filter: undefined,
479
485
  sortBy: undefined,
480
486
  renderHeaderCell: ({ column }, h) => {
481
- column = this.$transformDynamicProperty(column, undefined, this.parentObj);
482
-
483
- return this.$getHeadRender(h, column, {
484
- showRequired: this.showRequired,
485
- showDescription: this.showDescription,
486
- headHeightAuto: this.headHeightAuto
487
- });
487
+ return this.contentThCellRender(h, { column });
488
488
  },
489
489
  renderBodyCell: ({ row, rowIndex, column }, h) => {
490
- column = this.$transformDynamicProperty(column, row, this.parentObj);
491
- column = this.getResetCol(column, row, rowIndex);
492
- const unitCanEdit = this.getUnitCanEdit(column, row, rowIndex);
493
- const ruleResultObj = this.getColRuleResult(column, row, rowIndex);
494
-
495
- return [
496
- this.isShowCompare(column, row, rowIndex)
497
- ? h("Tooltip", {
498
- style: {
499
- width: "100%"
500
- },
501
- props: {
502
- content: this.$isEmptyData(this.compareListData[rowIndex][column._key])
503
- ? ""
504
- : this.compareListData[rowIndex][column._key],
505
- transfer: true,
506
- maxWidth: 200,
507
- placement: "top"
508
- },
509
- scopedSlots: {
510
- default: props => h("dsh-list-unit", {
511
- props: {
512
- canEdit: unitCanEdit,
513
- formData: row,
514
- formItem: column,
515
- allFormList: this.selfColumns,
516
- inTableType: this.inTableType,
517
- allListRows: this.allListData,
518
- rowIndex: rowIndex,
519
- parentFormList: this.allFormList,
520
- parentObj: this.parentObj
521
- },
522
- on: {
523
- blur: () => this.controlBlur(null, column, row, rowIndex, arguments),
524
- change: () => this.$dispatchEvent(this.operationMap.changeVal, column, row, rowIndex, arguments)
525
- }
526
- })
527
- }
528
- })
529
- : h("dsh-list-unit", {
530
- props: {
531
- canEdit: unitCanEdit,
532
- formData: row,
533
- formItem: column,
534
- allFormList: this.selfColumns,
535
- inTableType: this.inTableType,
536
- allListRows: this.allListData,
537
- rowIndex: rowIndex,
538
- parentFormList: this.allFormList,
539
- parentObj: this.parentObj
540
- },
541
- on: {
542
- blur: () => this.controlBlur(null, column, row, rowIndex, arguments),
543
- change: () => this.$dispatchEvent(this.operationMap.changeVal, column, row, rowIndex, arguments)
544
- }
545
- }),
546
-
547
- // 校验文字
548
- !ruleResultObj.bool
549
- ? h("span", {
550
- class: "bri-table-td-tip"
551
- }, ruleResultObj.message)
552
- : undefined,
553
-
554
- // 添加符
555
- ...this.createIconRender(h, { row, rowIndex, column }, 12)
556
- ];
490
+ return this.contentTdCellRender(h, { row, rowIndex, column });
557
491
  },
558
492
  ...colItem
559
493
  }));
@@ -875,14 +809,14 @@ export default {
875
809
  changeSelect (list) {
876
810
  this.$emit("changeSelect", list);
877
811
  },
878
- // 表单控件失去焦点
879
- controlBlur (operationItem, col, row, rowIndex, params) {
812
+ // 输入框失去焦点
813
+ controlBlur (operationItem, row, rowIndex, col, params) {
880
814
  this.$set(this.ruleRecordMap, `${row._id}dsh${col._key}`, { showRuleMessage: true });
881
815
  },
882
816
  // 输入框值改变
883
- changeVal (operationItem, col, row, rowIndex, params) {
817
+ changeVal (operationItem, row, rowIndex, col, params) {
884
818
  this.$set(this.ruleRecordMap, `${row._id}dsh${col._key}`, { showRuleMessage: true });
885
- this.change("changeVal", col, row, rowIndex, ...params);
819
+ this.change("changeVal", row, rowIndex, col, ...params);
886
820
  },
887
821
 
888
822
  /* ----------- 隐藏/显示字段 ---------- */
@@ -1073,7 +1007,7 @@ export default {
1073
1007
  this.isEnlarge = true;
1074
1008
  },
1075
1009
 
1076
- /* ----------- 渲染函数 ---------- */
1010
+ /* ----------- 渲染函数(声明:为了代码更加规范清晰,return的是h相关的函数,则函数名get开头;return的是h的直接调用,函数名不要get开头)---------- */
1077
1011
  getTableTopRender (isEnlarge = false) {
1078
1012
  return (h, params) => {
1079
1013
  return h("div", {
@@ -1093,7 +1027,7 @@ export default {
1093
1027
  ]);
1094
1028
  };
1095
1029
  },
1096
- topSearchRender (h, params) {
1030
+ topSearchRender (h) {
1097
1031
  return this.searchFormList.length
1098
1032
  ? h("dsh-default-search", {
1099
1033
  props: {
@@ -1107,7 +1041,7 @@ export default {
1107
1041
  })
1108
1042
  : undefined;
1109
1043
  },
1110
- topSummaryRender (h, params) {
1044
+ topSummaryRender (h) {
1111
1045
  return h("div", {
1112
1046
  style: {
1113
1047
  "display": "flex",
@@ -1149,7 +1083,7 @@ export default {
1149
1083
  : undefined
1150
1084
  ]);
1151
1085
  },
1152
- topOperationRender (h, params) {
1086
+ topOperationRender (h) {
1153
1087
  return h("dsh-buttons", {
1154
1088
  style: {
1155
1089
  "text-align": "right"
@@ -1162,10 +1096,93 @@ export default {
1162
1096
  click: (event) => {
1163
1097
  this.$dispatchEvent(event);
1164
1098
  }
1099
+ },
1100
+ nativeOn: {
1101
+ click: (e) => {
1102
+ e.stopPropagation();
1103
+ }
1165
1104
  }
1166
1105
  });
1167
1106
  },
1168
- createBtnRender (h, params) {
1107
+ contentThCellRender (h, { column }) {
1108
+ column = this.$transformDynamicProperty(column, undefined, this.parentObj);
1109
+
1110
+ return this.$getHeadRender(h, column, {
1111
+ showRequired: this.showRequired,
1112
+ showDescription: this.showDescription,
1113
+ headHeightAuto: this.headHeightAuto
1114
+ });
1115
+ },
1116
+ contentTdCellRender (h, { row, rowIndex, column }) {
1117
+ column = this.$transformDynamicProperty(column, row, this.parentObj);
1118
+ column = this.getResetCol(row, rowIndex, column);
1119
+ const unitCanEdit = this.getUnitCanEdit(row, rowIndex, column);
1120
+ const ruleResultObj = this.getColRuleResult(row, rowIndex, column);
1121
+
1122
+ return [
1123
+ this.isShowCompare(row, rowIndex, column)
1124
+ ? h("Tooltip", {
1125
+ style: {
1126
+ width: "100%"
1127
+ },
1128
+ props: {
1129
+ content: this.$isEmptyData(this.compareListData[rowIndex][column._key])
1130
+ ? ""
1131
+ : this.compareListData[rowIndex][column._key],
1132
+ transfer: true,
1133
+ maxWidth: 200,
1134
+ placement: "top"
1135
+ },
1136
+ scopedSlots: {
1137
+ default: props => h("dsh-list-unit", {
1138
+ props: {
1139
+ canEdit: unitCanEdit,
1140
+ formData: row,
1141
+ formItem: column,
1142
+ allFormList: this.selfColumns,
1143
+ inTableType: this.inTableType,
1144
+ allListRows: this.allListData,
1145
+ rowIndex: rowIndex,
1146
+ parentFormList: this.allFormList,
1147
+ parentObj: this.parentObj
1148
+ },
1149
+ on: {
1150
+ blur: () => this.controlBlur(null, row, rowIndex, column, arguments),
1151
+ change: () => this.$dispatchEvent(this.operationMap.changeVal, row, rowIndex, column, arguments)
1152
+ }
1153
+ })
1154
+ }
1155
+ })
1156
+ : h("dsh-list-unit", {
1157
+ props: {
1158
+ canEdit: unitCanEdit,
1159
+ formData: row,
1160
+ formItem: column,
1161
+ allFormList: this.selfColumns,
1162
+ inTableType: this.inTableType,
1163
+ allListRows: this.allListData,
1164
+ rowIndex: rowIndex,
1165
+ parentFormList: this.allFormList,
1166
+ parentObj: this.parentObj
1167
+ },
1168
+ on: {
1169
+ blur: () => this.controlBlur(null, row, rowIndex, column, arguments),
1170
+ change: () => this.$dispatchEvent(this.operationMap.changeVal, row, rowIndex, column, arguments)
1171
+ }
1172
+ }),
1173
+
1174
+ // 校验文字
1175
+ !ruleResultObj.bool
1176
+ ? h("span", {
1177
+ class: "bri-table-td-tip"
1178
+ }, ruleResultObj.message)
1179
+ : undefined,
1180
+
1181
+ // 添加符
1182
+ ...this.createIconRender(h, { row, rowIndex, column }, 12)
1183
+ ];
1184
+ },
1185
+ createBtnRender (h) {
1169
1186
  return !this.isSearching && this.disabledFootCreateBtn !== true
1170
1187
  ? h("dsh-buttons", {
1171
1188
  style: {
@@ -1323,12 +1340,12 @@ export default {
1323
1340
  },
1324
1341
  // 整行校验结果
1325
1342
  getRowRuleResult (row, rowIndex) {
1326
- return this.filterColumns.every(colItem => this.getColRuleResult(colItem, row, rowIndex).bool);
1343
+ return this.filterColumns.every(colItem => this.getColRuleResult(row, rowIndex, colItem).bool);
1327
1344
  },
1328
1345
  getRowFormList (row, rowIndex) {
1329
1346
  return this.selfColumns.map(colItem => {
1330
1347
  colItem = this.$transformDynamicProperty(colItem, row, this.parentObj);
1331
- const unitCanEdit = this.getColCanEdit(colItem, row, rowIndex);
1348
+ const unitCanEdit = this.getColCanEdit(row, rowIndex, colItem);
1332
1349
 
1333
1350
  return {
1334
1351
  ...colItem,
@@ -1356,7 +1373,7 @@ export default {
1356
1373
  },
1357
1374
 
1358
1375
  // 单元格校验结果
1359
- getColRuleResult (col, row, rowIndex) {
1376
+ getColRuleResult (row, rowIndex, col) {
1360
1377
  col = this.$transformDynamicProperty(col, row, this.parentObj);
1361
1378
 
1362
1379
  // 未触发校验时 不显示错误
@@ -1377,7 +1394,7 @@ export default {
1377
1394
  }
1378
1395
  },
1379
1396
  // 单元格是否显示对比
1380
- isShowCompare (col, row, rowIndex) {
1397
+ isShowCompare (row, rowIndex, col) {
1381
1398
  const oldRow = this.compareListData[rowIndex] || {};
1382
1399
  const curVal = row[col._key];
1383
1400
  const oldVal = oldRow[col._key];
@@ -1388,7 +1405,7 @@ export default {
1388
1405
  curVal !== oldVal;
1389
1406
  },
1390
1407
  // 加工单元格对应的配置
1391
- getResetCol (col, row, rowIndex) {
1408
+ getResetCol (row, rowIndex, col) {
1392
1409
  let resetMap = {
1393
1410
  select: {
1394
1411
  _optionKind: "dropdown"
@@ -1405,7 +1422,7 @@ export default {
1405
1422
  };
1406
1423
  },
1407
1424
  // 列本身是否可编辑
1408
- getColCanEdit (col, row, rowIndex) {
1425
+ getColCanEdit (row, rowIndex, col) {
1409
1426
  return (
1410
1427
  ["treeTable"].includes(this.inTableType) && ["number", "date"].includes(col._type)
1411
1428
  ? col._summaryType
@@ -1429,9 +1446,9 @@ export default {
1429
1446
  col.canEdit !== false; // 字段本身编辑权限 考虑为undefined时候
1430
1447
  },
1431
1448
  // 单元格最终编辑状态
1432
- getUnitCanEdit (col, row, rowIndex) {
1449
+ getUnitCanEdit (row, rowIndex, col) {
1433
1450
  return this.getRowCanEdit(row, rowIndex) &&
1434
- this.getColCanEdit(col, row, rowIndex) &&
1451
+ this.getColCanEdit(row, rowIndex, col) &&
1435
1452
  this.$isAdvRelyShow(col, row, this.parentObj, true);
1436
1453
  },
1437
1454
 
@@ -57,7 +57,7 @@ export default {
57
57
  : list.length;
58
58
  list.splice(newRowIndex, 0, newRow);
59
59
 
60
- this.change("createRow", null, newRow, newRowIndex);
60
+ this.change("createRow", newRow, newRowIndex, null);
61
61
  },
62
62
  // 节点操作 -添加子行
63
63
  clickCreateChild (operationItem, row, rowIndex, col) {
@@ -69,7 +69,7 @@ export default {
69
69
  // 展开子级
70
70
  this.toggleExpand(row, true);
71
71
 
72
- this.change("createChildRow", null, newRow, newRowIndex);
72
+ this.change("createChildRow", newRow, newRowIndex, null);
73
73
  },
74
74
  // 节点操作 -删除行
75
75
  clickDelete (operationItem, row, rowIndex, col) {
@@ -81,7 +81,7 @@ export default {
81
81
  const index = parentRow.children.findIndex(childRowItem => childRowItem._id === row._id);
82
82
  parentRow.children.splice(index, 1);
83
83
 
84
- this.change("deleteRow", null, row, rowIndex);
84
+ this.change("deleteRow", row, rowIndex, null);
85
85
  }
86
86
  });
87
87
  },
@@ -93,7 +93,7 @@ export default {
93
93
  onOk: () => {
94
94
  row.children.splice(0);
95
95
 
96
- this.change("deleteChildRows", null, row, rowIndex);
96
+ this.change("deleteChildRows", row, rowIndex, null);
97
97
  }
98
98
  });
99
99
  },
@@ -123,7 +123,7 @@ const transformToColumns = function (form, {
123
123
  }
124
124
  : undefined
125
125
  : undefined,
126
- renderHeaderCell: ({ row, column }, h) => {
126
+ renderHeaderCell: ({ column }, h) => {
127
127
  return getHeadRender(h, column, {
128
128
  showRequired,
129
129
  showDescription,