bri-components 1.4.0 → 1.4.1

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.0",
3
+ "version": "1.4.1",
4
4
  "author": "dengshanghui",
5
5
  "description": "a component lib for vue project",
6
6
  "main": "src/index.js",
@@ -102,7 +102,7 @@
102
102
 
103
103
  const prefixCls = "ivu-upload";
104
104
  const imageType = ["jpg", "png", "gif", "jpeg", "tiff", "swf"];
105
- const documentType = ["txt", "doc", "xls", "ppt", "docx", "xlsx", "pptx", "pdf"];
105
+ const documentType = ["txt", "doc", "xls", "ppt", "docx", "xlsx", "pptx", "pdf", "xmind"];
106
106
  const videoType = ["flv", "rmvb", "mp4", "mvb"];
107
107
  const audioType = ["wma", "mp3", "m4a"];
108
108
  const packageType = ["rar", "zip"];
@@ -163,7 +163,7 @@
163
163
  return this.selfPropsObj._fileType;
164
164
  },
165
165
  showMode () {
166
- return this.isInTable ? "inline" : this.selfPropsObj._showMode;
166
+ return this.isInTable ? this.selfPropsObj._inTableStyle == "list" && !this.finalCanEdit ? "tableList" : "inline" : this.selfPropsObj._showMode;
167
167
  },
168
168
  useType () {
169
169
  return this.selfPropsObj._useType;
@@ -58,6 +58,59 @@
58
58
  </div>
59
59
  </template>
60
60
 
61
+ <!-- 在表格中展开 -->
62
+ <template v-else-if="showMode ==='tableList'">
63
+ <!-- 有值 -->
64
+ <div
65
+ v-if="files.length"
66
+ ref="viewerImage"
67
+ :class="['uploadList-list', `uploadList-list-${propsObj._fileType}`]"
68
+ >
69
+ <div
70
+ v-for="(fileItem, fileIndex) in files"
71
+ :key="fileItem._key || fileItem._id"
72
+ :class="{
73
+ 'item': propsObj._fileType === 'image',
74
+ [`item-${propsObj._fileType}`]: true
75
+ }"
76
+ >
77
+ <!-- 展示图 -->
78
+ <div class="item-show">
79
+ <img
80
+ v-if="fileItem.mimetype.includes('image')"
81
+ :data-original="fileItem.url"
82
+ :src="$imageResize(fileItem.url, imageResizeConfig)"
83
+ :alt="fileItem.name"
84
+ >
85
+ <img
86
+ v-else
87
+ :src="getFileImage(fileItem)"
88
+ :alt="fileItem.name"
89
+ >
90
+ </div>
91
+
92
+ <!-- 展示名称 -->
93
+ <p class="item-name-title">{{ fileItem.name }}</p>
94
+
95
+ <!-- 图标 -->
96
+ <dsh-icons
97
+ class="item-action"
98
+ item-class="item-action-icon"
99
+ :list="$getOperationList(getBtns(fileItem))"
100
+ @click="$dispatchEvent($event, fileItem, fileIndex)"
101
+ ></dsh-icons>
102
+ </div>
103
+ </div>
104
+
105
+ <!-- 无值 -->
106
+ <div
107
+ v-else
108
+ class="uploadList-inline-nodata"
109
+ >
110
+ <span>{{ noDataText }}</span>
111
+ </div>
112
+ </template>
113
+
61
114
  <div
62
115
  v-else-if="propsObj._fileType === 'file'"
63
116
  ref="viewerImage"
@@ -73,7 +126,10 @@
73
126
  'uploadList-fileList-fileName-edit': canEdit
74
127
  }">
75
128
  {{ files.length }}个
76
- <Icon v-if="canEdit" type="ios-arrow-down" />
129
+ <Icon
130
+ v-if="canEdit"
131
+ type="ios-arrow-down"
132
+ />
77
133
  </div>
78
134
 
79
135
  <div
@@ -94,9 +150,7 @@
94
150
  :alt="dropdownItem.name"
95
151
  class="fileItem-img"
96
152
  >
97
- <p
98
- class="fileItem-name-title"
99
- >{{ dropdownItem.name }}</p>
153
+ <p class="fileItem-name-title">{{ dropdownItem.name }}</p>
100
154
  <dsh-icons
101
155
  class="fileItem-action"
102
156
  item-class="fileItem-action-icon"
@@ -298,7 +352,7 @@
298
352
  let lastIndex = fileItem.name.lastIndexOf(".");
299
353
  let formate = fileItem.name.substring(lastIndex);
300
354
 
301
- this.$Modal.info({
355
+ this.$Modal.confirm({
302
356
  title: "修改名称",
303
357
  render: (h) => {
304
358
  return h("Input", {
@@ -14,7 +14,7 @@
14
14
  'DshCheckbox-flat-color': useColor,
15
15
  'DshCheckbox-flat-scroll': isHeightAuto
16
16
  ? isUnitUpdate
17
- ? listData.length > 6
17
+ ? listData.length > 3
18
18
  : false
19
19
  : true
20
20
  }"
@@ -14,7 +14,7 @@
14
14
  'DshSelect-flat-color': useColor,
15
15
  'DshSelect-flat-scroll': isHeightAuto
16
16
  ? isUnitUpdate
17
- ? listData.length > 4
17
+ ? listData.length > 3
18
18
  : false
19
19
  : true
20
20
  }"
@@ -52,7 +52,7 @@ export default {
52
52
  return this.selfPropsObj._reverseFilter;
53
53
  },
54
54
  selectFilterVals () {
55
- return this.selfPropsObj._selectFilterVals;
55
+ return this.selfPropsObj._selectFilterVals || []; // 老版级联表格层级属性那用到单选,缺这些属性,会产生undefined,有问题
56
56
  },
57
57
  selectFilterKey () {
58
58
  return this.selfPropsObj._selectFilterKey;
@@ -336,7 +336,7 @@
336
336
  _displayType: "show",
337
337
  canEdit: !["createdAt", "updatedAt", "_creaters"].includes(formData._key)
338
338
  }).forEach(arr => {
339
- if (!this.ignoreProperties.includes(arr[0])) {
339
+ if (!this.ignoreProperties.includes(arr[0]) && arr[1] !== undefined) {
340
340
  this.$set(formItem, arr[0], arr[1]);
341
341
  }
342
342
  });
@@ -11,38 +11,20 @@ export default {
11
11
  },
12
12
  data () {
13
13
  return {
14
- boxWidth: 0,
15
-
16
- baseOperationMap: {
17
- canCreateCol: {
18
- name: "添加一列",
19
- type: "canCreateCol",
20
- icon: "md-add",
21
- event: "clickCreateCol"
22
- },
23
- canDeleteCol: {
24
- name: "删除该列",
25
- type: "canDeleteCol",
26
- icon: "md-trash",
27
- color: "red",
28
- event: "clickDeleteCol"
29
- }
30
- }
31
- // otherOperationMap: {
32
- // canChangeNode: {
33
- // name: "改变节点值",
34
- // type: "canChangeNode",
35
- // event: "changeNode"
36
- // },
37
- // canClickNode: {
38
- // name: "点击节点",
39
- // type: "canClickNode",
40
- // event: "clickNode"
14
+ boxWidth: 0
15
+ // baseOperationMap: {
16
+ // canCreateCol: {
17
+ // name: "添加一列",
18
+ // type: "canCreateCol",
19
+ // icon: "md-add",
20
+ // event: "clickCreateCol"
41
21
  // },
42
- // canBlurNode: {
43
- // name: "节点失去焦点",
44
- // type: "canBlurNode",
45
- // event: "blurNode"
22
+ // canDeleteCol: {
23
+ // name: "删除该列",
24
+ // type: "canDeleteCol",
25
+ // icon: "md-trash",
26
+ // color: "red",
27
+ // event: "clickDeleteCol"
46
28
  // }
47
29
  // }
48
30
  };
@@ -64,7 +46,7 @@ export default {
64
46
  // 替换tableBaseMixin里的
65
47
  showCreateBtnColKeys () {
66
48
  return [
67
- ...this.treeForm.map(treeFormItem => treeFormItem._key),
49
+ ...this.treeFormKeys,
68
50
  ...(this.selfPropsObj._showCreateBtnColKeys || [])
69
51
  ];
70
52
  },
@@ -103,34 +85,34 @@ export default {
103
85
  init () {
104
86
  this.treeColumns.forEach((treeFormItem, treeFormIndex) => {
105
87
  this.$set(treeFormItem, "level", treeFormIndex + 1);
106
- this.$set(treeFormItem, "canDelete", true);
88
+ // this.$set(treeFormItem, "canDelete", true);
107
89
  });
108
90
  },
109
91
 
110
- /* ----------- 操作 ---------- */
111
- // 表头操作 -树形表头-添加一列
112
- clickCreateCol (operationItem, col, colIndex) {
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;
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;
123
105
 
124
- this.change("createCol", null, null, col);
125
- },
126
- // 表头操作 -树形表头-删除一列
127
- clickDeleteCol (operationItem, col, colIndex) {
128
- this.isDeleteColStatus = true; // isDeleteStatus不用在data中定义
129
- this.treeColumns.pop();
130
- this.tableDataObj._treeForm = this.treeColumns;
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;
131
113
 
132
- this.change("deleteCol", null, null, col);
133
- },
114
+ // this.change("deleteCol", null, null, col);
115
+ // },
134
116
 
135
117
  /* ----------- 渲染函数(声明:为了代码更加规范清晰,return的是h相关的函数,则函数名get开头;return的是h的直接调用,函数名不要get开头)---------- */
136
118
  // 表格表头渲染函数
@@ -198,9 +180,6 @@ export default {
198
180
  },
199
181
  this.rowColumnsArr[rowIndex].map(column => {
200
182
  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
183
  })
205
184
  );
206
185
  })
@@ -229,9 +208,9 @@ export default {
229
208
  style: this.getThStyle(column)
230
209
  },
231
210
  [
232
- this.contentThCellRender(h, { column, colIndex }),
211
+ this.contentThCellRender(h, { column, colIndex })
233
212
 
234
- this.treeThDropOperationRender(h, { column, colIndex })
213
+ // this.treeThDropOperationRender(h, { column, colIndex })
235
214
  ]);
236
215
  },
237
216
  emptyTdRender (h, { row, rowIndex, column }) {
@@ -261,72 +240,72 @@ export default {
261
240
  },
262
241
  on: {
263
242
  mouseenter: (event) => {
264
- this.$set(this.hoverRecordMap, `${row._id}dsh${column._key}`, true);
243
+ this.$set(this.hoverRecordMap, `${row._id}`, true);
244
+ // this.$set(this.hoverRecordMap, `${row._id}dsh${column._key}`, true);
265
245
  },
266
246
  mouseleave: (event) => {
267
- this.$set(this.hoverRecordMap, `${row._id}dsh${column._key}`, false);
247
+ this.$set(this.hoverRecordMap, `${row._id}`, false);
248
+ // this.$set(this.hoverRecordMap, `${row._id}dsh${column._key}`, false);
268
249
  }
269
250
  }
270
251
  },
271
252
  column.colType === "summary"
272
253
  ? 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 })
254
+ : column.colType === "operation"
255
+ ? this.operationTdCellRender(h, { row, rowIndex, column })
256
+ : this.contentTdCellRender(h, { row, rowIndex, column })
278
257
  );
279
258
  },
280
- // 树形表头最末级列的下拉渲染函数
281
- treeThDropOperationRender (h, { column, colIndex }) {
282
- const list = this.$getOperationList(
283
- column.colType === "tree" && column.level === this.treeColumns.length
284
- ? [
285
- ...(column.level < this.maxLevel ? ["canCreateCol"] : []), // 限制最大添加到几级
286
- ...(column.canDelete === true ? ["canDeleteCol"] : []) // 只有一级和最后两级节点数不一致时,不能删
287
- ]
288
- : []
289
- );
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
+ // );
290
269
 
291
- return !this.isSearching &&
292
- list.length
293
- ? h("dsh-dropdown", {
294
- class: "bri-table-dropdown",
295
- props: {
296
- menuClass: "bri-table-dropdown-list",
297
- trigger: "hover",
298
- list: list
299
- },
300
- on: {
301
- click: (operationItem) => {
302
- this.$dispatchEvent(operationItem, column, colIndex);
303
- }
304
- },
305
- nativeOn: {
306
- click: (e) => {
307
- e.stopPropagation();
308
- }
309
- }
310
- }, [
311
- h("a", {
312
- style: {
313
- fontWeight: "500",
314
- color: this.appColor
315
- },
316
- attrs: {
317
- href: "javascript:void(0)"
318
- }
319
- }, [
320
- h("Icon", {
321
- props: {
322
- type: "md-arrow-dropdown-circle",
323
- size: "16"
324
- }
325
- })
326
- ])
327
- ])
328
- : undefined;
329
- },
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
+ // },
330
309
 
331
310
  /* ----------- 方法 ---------- */
332
311
  // 表头 -获取样式
@@ -343,7 +322,7 @@ export default {
343
322
  maxWidth: `${width}px`,
344
323
  paddingTop: !this.headHeightAuto ? "10px" : undefined,
345
324
  paddingBottom: !this.headHeightAuto ? "10px" : undefined,
346
- align: col._align || typeData.align,
325
+ textAlign: col._align || typeData.align,
347
326
  "word-break": "break-all",
348
327
  cursor: "pointer"
349
328
  };
@@ -401,6 +380,18 @@ export default {
401
380
  return (this.getIsDftRow(row) ? !this.dftReadonlyTreeColKeys.includes(col._key) : true) && // 默认行的某列是否可编辑
402
381
  (row.__old__ === true ? !this.oldReadonlyTreeColKeys.includes(col._key) : true); // 老数据行里某些列不可编辑
403
382
  },
383
+ // getNewRowData时,额外补充的行相关的数据(针对层级属性的列)
384
+ getRowOtherDft (level, list) {
385
+ const column = this.treeForm[level - 1];
386
+ const dftVal = column._default;
387
+ const initDftVal = this.initDftValMap[column._type];
388
+
389
+ return {
390
+ name: this.$isEmptyData(dftVal)
391
+ ? initDftVal
392
+ : dftVal
393
+ };
394
+ },
404
395
 
405
396
  /* ----------- 工具方法 ---------- */
406
397
  // 合并表头
@@ -440,54 +431,60 @@ export default {
440
431
  // 转化树数据
441
432
  getCalcuedTree (nodes = [], treeForm = [], subForm = []) {
442
433
  treeForm.forEach((treeFormItem, treeFormIndex) => {
443
- treeFormItem.canDelete = true; // 每次计算,重置一下
434
+ // treeFormItem.canDelete = true; // 每次计算,重置一下
444
435
  treeFormItem.level = treeFormIndex + 1; // treeColumns更新,缺少level
445
436
  });
446
437
 
447
438
  // 循环遍树节点
448
- const loop = (nodes = []) => {
439
+ const loop = (nodes = [], parentNodes = []) => {
449
440
  nodes.forEach(rowItem => {
450
441
  // 初始化树节点的数据,给节点加上一些属性并监测,注入到节点对象中
451
442
  let curCol = treeForm[rowItem.level - 1];
452
443
  this.$setObj(rowItem, {
453
444
  _key: curCol._key,
454
445
  level: curCol.level,
455
- isEdit: false,
456
446
  isLeaf: false,
457
447
  total: 1
458
448
  });
459
449
 
460
450
  // 最后一列(根节点)
461
451
  if (rowItem.level === treeForm.length) {
462
- // 处理删除了最后一列后,把根节点上的subForm属性值全部给上级节点
463
- if (this.isDeleteColStatus) {
464
- let subNode = rowItem.children[0];
465
- subForm.forEach(subFormItem => {
466
- // 用$set也可以
467
- rowItem[subFormItem._key] = subNode[subFormItem._key];
468
- });
469
- }
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
+ // }
470
460
 
471
461
  rowItem.children = [];
472
462
  rowItem.isLeaf = true;
463
+
464
+ // TODO:特殊处理-叶子节点上注入对应表头列们的name值
465
+ const treeNodes = [...parentNodes, rowItem];
466
+ treeForm.forEach((treeFormItem, treeFormIndex) => {
467
+ rowItem[treeFormItem._key] = treeNodes[treeFormIndex].name;
468
+ });
473
469
  }
474
470
  // 非最后一列(最后一列前的列,非根节点),需继续向下循环
475
471
  else {
476
- // 判断是否能删除最后一列(1.判断条件:判断根节点列的前一列的所有节点 都必须只有一个子结点 2.canDelete放在表头treeForm最后一项,默认true)
477
- if (rowItem.level === treeForm.length - 1) {
478
- if (rowItem.children.length > 1) {
479
- treeForm[rowItem.level].canDelete = false;
480
- }
481
- }
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
+ // }
482
478
 
483
479
  // 非最后一列的 正常的非根节点
484
480
  if (rowItem.children && rowItem.children.length) {
485
- loop(rowItem.children);
481
+ loop(rowItem.children, [...parentNodes, rowItem]);
486
482
  }
487
483
  // 非最后一列的 新增的非根节点(此时是新增一列或新增非根节点行) -添加一个子节点,并把该节点上的subForm属性值全部给下级节点
488
484
  // 特别提示:新增的是根节点行,不会走此处代码
489
485
  else {
490
486
  const newNode = this.getNewRowData(rowItem.level + 1, rowItem.children);
487
+
491
488
  subForm.forEach(subFormItem => {
492
489
  // 用$set也可以
493
490
  newNode[subFormItem._key] = rowItem[subFormItem._key];
@@ -495,7 +492,7 @@ export default {
495
492
  });
496
493
  rowItem.children.push(newNode);
497
494
 
498
- loop(rowItem.children);
495
+ loop(rowItem.children, [...parentNodes, rowItem]);
499
496
  }
500
497
  }
501
498
 
@@ -510,7 +507,7 @@ export default {
510
507
  },
511
508
  // 转化渲染使用的columns数组
512
509
  transformRowColumnsArr (nodes = [], treeForm = []) {
513
- let loop = (nodes, rowColumnsArr) => {
510
+ const loop = (nodes = [], rowColumnsArr = []) => {
514
511
  nodes = this.getFilteredNodes(nodes);
515
512
 
516
513
  return nodes.reduce((rowColumnsArr, node, nodeIndex) => {
@@ -528,11 +525,11 @@ export default {
528
525
  }, rowColumnsArr);
529
526
  };
530
527
 
531
- return loop(nodes, []);
528
+ return loop(nodes);
532
529
  },
533
530
  // 转化表格数据
534
531
  transformRows (nodes = [], treeForm = []) {
535
- const loop = (nodes, rows) => {
532
+ const loop = (nodes = [], rows = []) => {
536
533
  nodes = this.getFilteredNodes(nodes);
537
534
 
538
535
  return nodes.reduce((rows, node, nodeIndex) => {
@@ -555,12 +552,16 @@ export default {
555
552
  }
556
553
  }, rows);
557
554
  };
558
- return loop(nodes, []);
555
+ return loop(nodes);
559
556
  },
560
557
  getFilteredNodes (nodes = []) {
561
558
  const loop = (nodes = []) => {
562
559
  return nodes.filter(rowItem => {
563
560
  if (rowItem.children && rowItem.children.length) {
561
+ if (this.isSearching) {
562
+ rowItem.__isSearchShow__ = true;
563
+ }
564
+
564
565
  const children = loop(rowItem.children);
565
566
  return !!children.length;
566
567
  } else {
@@ -571,176 +572,5 @@ export default {
571
572
 
572
573
  return loop(nodes);
573
574
  }
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
- // }
745
575
  }
746
576
  };
@@ -38,7 +38,7 @@ export default {
38
38
  };
39
39
  }, {
40
40
  _id: this.$ObjectID().str,
41
- __index__: "汇总",
41
+ __treeIndex__: "汇总",
42
42
  __isExpand__: "-",
43
43
  __operation__: "——"
44
44
  })
@@ -97,9 +97,9 @@ export default {
97
97
  indexColumn () {
98
98
  return {
99
99
  title: "序号",
100
- _key: "__index__",
101
- key: "__index__",
102
- field: "__index__",
100
+ _key: "__treeIndex__",
101
+ key: "__treeIndex__",
102
+ field: "__treeIndex__",
103
103
  width: 28 + 16 + (this.maxLevel - 1) * 38,
104
104
  align: "left",
105
105
  fixed: "left",
@@ -126,9 +126,9 @@ export default {
126
126
  }
127
127
  },
128
128
  otherOperationMap: {
129
- changeVal: {
129
+ canChangeVal: {
130
130
  name: "改变输入框值",
131
- type: "changeVal",
131
+ type: "canChangeVal",
132
132
  event: "changeVal"
133
133
  }
134
134
  },
@@ -427,14 +427,14 @@ export default {
427
427
  parentDataId () {
428
428
  return this.parentObj._id;
429
429
  },
430
- selfRowDefault () {
430
+ selfRowDft () {
431
431
  return this.selfColumns.reduce((obj, column) => {
432
432
  const dftInRowVal = this.rowDefault[column._key];
433
433
  const dftVal = column._default;
434
434
  const initDftVal = this.initDftValMap[column._type];
435
435
 
436
436
  return Object.assign(obj, {
437
- [column._key]: dftInRowVal === undefined
437
+ [column._key]: this.$isEmptyData(dftInRowVal)
438
438
  ? this.$isEmptyData(dftVal)
439
439
  ? initDftVal
440
440
  : dftVal
@@ -527,25 +527,7 @@ export default {
527
527
  bodyCellSpan: this.bodyCellSpan
528
528
  },
529
529
  eventCustomOption: {
530
- bodyCellEvents: ({ row, rowIndex, column }) => {
531
- return {
532
- click: (event) => {
533
- // console.log("click::", row, rowIndex, column, event);
534
- },
535
- dblclick: (event) => {
536
- // console.log("dblclick::", row, rowIndex, column, event);
537
- },
538
- contextmenu: (event) => {
539
- // console.log("contextmenu::", row, rowIndex, column, event);
540
- },
541
- mouseenter: (event) => {
542
- this.$set(this.hoverRecordMap, `${row._id}dsh${column._key}`, true);
543
- },
544
- mouseleave: (event) => {
545
- this.$set(this.hoverRecordMap, `${row._id}dsh${column._key}`, false);
546
- }
547
- };
548
- }
530
+ bodyCellEvents: this.eventCustomOption
549
531
  }
550
532
  };
551
533
  },
@@ -1042,7 +1024,7 @@ export default {
1042
1024
  headHeightAuto: this.headHeightAuto
1043
1025
  });
1044
1026
  },
1045
- contentTdCellRender (h, { row, rowIndex, column }, position) {
1027
+ contentTdCellRender (h, { row, rowIndex, column }) {
1046
1028
  column = this.$transformDynamicProperty(column, row, this.parentObj);
1047
1029
  column = this.getResetCol(row, rowIndex, column);
1048
1030
  const unitCanEdit = this.getUnitCanEdit(row, rowIndex, column);
@@ -1069,8 +1051,15 @@ export default {
1069
1051
  formData: row,
1070
1052
  formItem: {
1071
1053
  ...column,
1072
- _key: position === "tree" ? "name" : column._key,
1073
- _heightAuto: column._heightAuto || position === "tree"
1054
+ ...(
1055
+ column.colType === "tree"
1056
+ ? {
1057
+ _key: "name",
1058
+ _heightAuto: true,
1059
+ _placeholder: " "
1060
+ }
1061
+ : column
1062
+ )
1074
1063
  },
1075
1064
  allFormList: this.selfColumns,
1076
1065
  inTableType: this.inTableType,
@@ -1081,7 +1070,7 @@ export default {
1081
1070
  },
1082
1071
  on: {
1083
1072
  blur: () => this.controlBlur(null, row, rowIndex, column, arguments),
1084
- change: () => this.$dispatchEvent(this.operationMap.changeVal, row, rowIndex, column, arguments)
1073
+ change: () => this.$dispatchEvent(this.operationMap.canChangeVal, row, rowIndex, column, arguments)
1085
1074
  }
1086
1075
  })
1087
1076
  }
@@ -1092,8 +1081,15 @@ export default {
1092
1081
  formData: row,
1093
1082
  formItem: {
1094
1083
  ...column,
1095
- _key: position === "tree" ? "name" : column._key,
1096
- _heightAuto: column._heightAuto || position === "tree"
1084
+ ...(
1085
+ column.colType === "tree"
1086
+ ? {
1087
+ _key: "name",
1088
+ _heightAuto: true,
1089
+ _placeholder: " "
1090
+ }
1091
+ : column
1092
+ )
1097
1093
  },
1098
1094
  allFormList: this.selfColumns,
1099
1095
  inTableType: this.inTableType,
@@ -1104,7 +1100,7 @@ export default {
1104
1100
  },
1105
1101
  on: {
1106
1102
  blur: () => this.controlBlur(null, row, rowIndex, column, arguments),
1107
- change: () => this.$dispatchEvent(this.operationMap.changeVal, row, rowIndex, column, arguments)
1103
+ change: () => this.$dispatchEvent(this.operationMap.canChangeVal, row, rowIndex, column, arguments)
1108
1104
  }
1109
1105
  }),
1110
1106
 
@@ -1139,12 +1135,15 @@ export default {
1139
1135
  ];
1140
1136
  },
1141
1137
  operationIconRender (h, { row, rowIndex, column }, iconSize = 14) {
1138
+ 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}`]
1142
+
1142
1143
  return [
1143
1144
  // 插入一行图标
1144
1145
  (this.operationMap.canCreate && this.operationMap.canCreate.disabled !== true) &&
1145
- !this.isSearching &&
1146
- (column._key === "__index__" ? !this.showCreateBtnColKeys.length : this.showCreateBtnColKeys.includes(column._key)) &&
1147
- this.hoverRecordMap[`${row._id}dsh${column._key}`]
1146
+ baseBool
1148
1147
  ? h("div", {
1149
1148
  style: {
1150
1149
  position: "absolute",
@@ -1189,9 +1188,7 @@ export default {
1189
1188
 
1190
1189
  // 添加一行下级图标
1191
1190
  (this.operationMap.canCreateChild && this.operationMap.canCreateChild.disabled !== true) &&
1192
- !this.isSearching &&
1193
- (column._key === "__index__" ? !this.showCreateBtnColKeys.length : this.showCreateBtnColKeys.includes(column._key)) &&
1194
- this.hoverRecordMap[`${row._id}dsh${column._key}`] &&
1191
+ baseBool &&
1195
1192
  row.level < this.maxLevel &&
1196
1193
  !["cascaderTable"].includes(this.inTableType) // 老版级联表格类型不要“添加下级”图标
1197
1194
  ? h("div", {
@@ -1239,9 +1236,7 @@ export default {
1239
1236
 
1240
1237
  // 删除该行图标
1241
1238
  (this.operationMap.canDelete && this.operationMap.canDelete.disabled !== true) &&
1242
- !this.isSearching &&
1243
- (column._key === "__index__" ? !this.showCreateBtnColKeys.length : this.showCreateBtnColKeys.includes(column._key)) &&
1244
- this.hoverRecordMap[`${row._id}dsh${column._key}`] &&
1239
+ baseBool &&
1245
1240
  this.getRowDelBtnCanEdit(row, rowIndex) &&
1246
1241
  ["cascaderTable"].includes(this.inTableType)
1247
1242
  ? h("div", {
@@ -1293,9 +1288,13 @@ export default {
1293
1288
  ? " bri-table-td-merge"
1294
1289
  : ""
1295
1290
  }` +
1296
- `${this.getRowCanEdit(row, rowIndex)
1297
- ? " bri-table-td-edit"
1298
- : ""
1291
+ `${["__isExpand__"].includes(column._key)
1292
+ ? " bri-table-td-expand"
1293
+ : ["__treeIndex__"].includes(column._key)
1294
+ ? " bri-table-td-treeIndex"
1295
+ : this.getRowCanEdit(row, rowIndex)
1296
+ ? " bri-table-td-edit"
1297
+ : ""
1299
1298
  }` +
1300
1299
  `${this.isSearching
1301
1300
  ? row.__isSearchShow__ === false
@@ -1306,32 +1305,41 @@ export default {
1306
1305
  ? " bri-table-td-visible"
1307
1306
  : ""
1308
1307
  : " bri-table-td-hide"
1309
- }` +
1310
- `${["__isExpand__"].includes(column._key)
1311
- ? " bri-table-td-expand"
1312
- : ["__index__"].includes(column._key)
1313
- ? " bri-table-td-index"
1314
- : ""
1315
1308
  }`;
1316
1309
  },
1310
+ eventCustomOption ({ row, rowIndex, column }) {
1311
+ return {
1312
+ click: (event) => {
1313
+ // console.log("click::", row, rowIndex, column, event);
1314
+ },
1315
+ dblclick: (event) => {
1316
+ // console.log("dblclick::", row, rowIndex, column, event);
1317
+ },
1318
+ contextmenu: (event) => {
1319
+ // console.log("contextmenu::", row, rowIndex, column, event);
1320
+ },
1321
+ mouseenter: (event) => {
1322
+ this.$set(this.hoverRecordMap, `${row._id}`, true);
1323
+ // this.$set(this.hoverRecordMap, `${row._id}dsh${column._key}`, true);
1324
+ },
1325
+ mouseleave: (event) => {
1326
+ this.$set(this.hoverRecordMap, `${row._id}`, false);
1327
+ // this.$set(this.hoverRecordMap, `${row._id}dsh${column._key}`, false);
1328
+ }
1329
+ };
1330
+ },
1317
1331
 
1318
1332
  /* ----------- 方法 ---------- */
1319
1333
  // 生成新的一行数据
1320
1334
  getNewRowData (level, list) {
1321
1335
  if (["cascaderTable"].includes(this.controlType)) {
1322
1336
  return {
1323
- ...this.$deepCopy(this.selfRowDefault),
1337
+ ...this.$deepCopy(this.selfRowDft),
1338
+ ...(this.getRowOtherDft ? this.$deepCopy(this.getRowOtherDft(level, list)) : {}),
1324
1339
  _id: this.$ObjectID().str,
1325
1340
  level: level,
1326
1341
  isLeaf: true,
1327
1342
  children: [],
1328
- ...(
1329
- ["treeTable"].includes(this.inTableType)
1330
- ? {}
1331
- : {
1332
- name: `${this.$numToChinese(level)}级节点${list.length + 1}`
1333
- }
1334
- ),
1335
1343
  // __old__: false,
1336
1344
  __isDefault__: this.isDftSet,
1337
1345
  __isRendered__: true,
@@ -1342,7 +1350,7 @@ export default {
1342
1350
  };
1343
1351
  } else {
1344
1352
  return {
1345
- ...this.$deepCopy(this.selfRowDefault),
1353
+ ...this.$deepCopy(this.selfRowDft),
1346
1354
  _id: this.$ObjectID().str,
1347
1355
  // __old__: false,
1348
1356
  __isDefault__: this.isDftSet,
@@ -1425,7 +1433,6 @@ export default {
1425
1433
  return {
1426
1434
  // isShare: this.isShare,
1427
1435
  ...col,
1428
- _optionKind: "dropdown",
1429
1436
  _heightAuto: this.heightAuto
1430
1437
  };
1431
1438
  },
@@ -42,6 +42,9 @@ export default {
42
42
  treeForm () {
43
43
  return this.selfPropsObj._treeForm;
44
44
  },
45
+ treeFormKeys () {
46
+ return this.treeForm.map(treeFormItem => treeFormItem._key);
47
+ },
45
48
  maxLevel () {
46
49
  return this.selfPropsObj._maxLevel || 3;
47
50
  },
@@ -171,7 +171,7 @@
171
171
  &-expand {
172
172
 
173
173
  }
174
- &-index {
174
+ &-treeIndex {
175
175
  padding: 4px 16px 4px 12px!important;
176
176
  }
177
177
  &-operation {