bri-components 1.3.92 → 1.3.94
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 +2 -2
- package/src/components/form/DshForm.vue +22 -2
- package/src/components/list/DshCascaderTable.vue +3 -1
- package/src/components/list/DshFlatTable.vue +3 -1
- package/src/components/list/DshTreeTable.vue +1 -1
- package/src/components/list/mixins/DshCascaderTableMixin.js +106 -240
- package/src/components/list/mixins/DshFlatTableMixin.js +34 -34
- package/src/components/list/mixins/DshTreeTableMixin.js +4 -155
- package/src/components/list/mixins/tableBaseMixin.js +130 -47
- package/src/components/list/mixins/treeTableBaseMixin.js +132 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bri-components",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.94",
|
|
4
4
|
"author": "dengshanghui",
|
|
5
5
|
"description": "a component lib for vue project",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"ali-oss": "^6.13.1",
|
|
34
34
|
"axios": "^0.23.0",
|
|
35
|
-
"bri-datas": "^1.1.
|
|
35
|
+
"bri-datas": "^1.1.94",
|
|
36
36
|
"jshint": "^2.12.0",
|
|
37
37
|
"jsonlint": "^1.6.3",
|
|
38
38
|
"minio": "7.1.0",
|
|
@@ -348,13 +348,33 @@
|
|
|
348
348
|
let rules = [];
|
|
349
349
|
let ruleConfig = this.$getFieldRuleConfig(formItem);
|
|
350
350
|
|
|
351
|
+
// 数据格式校验
|
|
352
|
+
if (ruleConfig.type) {
|
|
353
|
+
rules.push({
|
|
354
|
+
message: `${formItem._name}数据格式有错!`,
|
|
355
|
+
trigger: "blur, change",
|
|
356
|
+
type: "string",
|
|
357
|
+
...ruleConfig,
|
|
358
|
+
fields: ruleConfig.fields && Object.entries(ruleConfig.fields).reduce((obj, arr) => {
|
|
359
|
+
return {
|
|
360
|
+
...obj,
|
|
361
|
+
[arr[0]]: {
|
|
362
|
+
...arr[1],
|
|
363
|
+
required: false,
|
|
364
|
+
message: `${formItem._name}${arr[1].message || ""}`
|
|
365
|
+
}
|
|
366
|
+
};
|
|
367
|
+
}, ruleConfig.fields)
|
|
368
|
+
});
|
|
369
|
+
}
|
|
370
|
+
|
|
351
371
|
// 必填校验
|
|
352
372
|
if (formItem._required) {
|
|
353
373
|
rules.push({
|
|
354
|
-
required: true,
|
|
355
374
|
message: `${formItem._name}为必填项!`,
|
|
356
375
|
trigger: "blur, change",
|
|
357
376
|
type: "string",
|
|
377
|
+
required: true,
|
|
358
378
|
...ruleConfig,
|
|
359
379
|
fields: ruleConfig.fields && Object.entries(ruleConfig.fields).reduce((obj, arr) => {
|
|
360
380
|
return {
|
|
@@ -384,7 +404,7 @@
|
|
|
384
404
|
}
|
|
385
405
|
|
|
386
406
|
// 对比校验(横向同类型字段对比)-暂时只number和date对比校验
|
|
387
|
-
if (formItem._saveRuleConfigs) {
|
|
407
|
+
if (formItem._saveRuleConfigs && formItem._saveRuleConfigs.length) {
|
|
388
408
|
const ruleObj = {
|
|
389
409
|
message: `${formItem._name}对比不通过!`,
|
|
390
410
|
trigger: "blur, change",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
<!-- 搜索条件 -->
|
|
10
10
|
<dsh-render
|
|
11
|
-
v-if="!
|
|
11
|
+
v-if="!isEnlarge && showTopSearch"
|
|
12
12
|
:render="topSearchRender"
|
|
13
13
|
></dsh-render>
|
|
14
14
|
|
|
@@ -71,12 +71,14 @@
|
|
|
71
71
|
|
|
72
72
|
<script>
|
|
73
73
|
import tableBaseMixin from "./mixins/tableBaseMixin.js";
|
|
74
|
+
import treeTableBaseMixin from "./mixins/treeTableBaseMixin.js";
|
|
74
75
|
import DshCascaderTableMixin from "./mixins/DshCascaderTableMixin.js";
|
|
75
76
|
|
|
76
77
|
export default {
|
|
77
78
|
name: "DshCascaderTable",
|
|
78
79
|
mixins: [
|
|
79
80
|
tableBaseMixin,
|
|
81
|
+
treeTableBaseMixin,
|
|
80
82
|
DshCascaderTableMixin
|
|
81
83
|
],
|
|
82
84
|
components: {},
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
<!-- 搜索条件 -->
|
|
7
7
|
<dsh-render
|
|
8
|
-
v-if="!
|
|
8
|
+
v-if="!isEnlarge && showTopSearch"
|
|
9
9
|
:render="topSearchRender"
|
|
10
10
|
></dsh-render>
|
|
11
11
|
|
|
@@ -126,6 +126,7 @@
|
|
|
126
126
|
|
|
127
127
|
<script>
|
|
128
128
|
import tableBaseMixin from "./mixins/tableBaseMixin.js";
|
|
129
|
+
import treeTableBaseMixin from "./mixins/treeTableBaseMixin.js";
|
|
129
130
|
import DshFlatTableMixin from "./mixins/DshFlatTableMixin.js";
|
|
130
131
|
import DshDivider from "../controls/base/DshDivider.vue";
|
|
131
132
|
|
|
@@ -133,6 +134,7 @@
|
|
|
133
134
|
name: "DshFlatTable",
|
|
134
135
|
mixins: [
|
|
135
136
|
tableBaseMixin,
|
|
137
|
+
treeTableBaseMixin,
|
|
136
138
|
DshFlatTableMixin
|
|
137
139
|
],
|
|
138
140
|
components: {
|
|
@@ -24,23 +24,18 @@ export default {
|
|
|
24
24
|
boxWidth: 0,
|
|
25
25
|
|
|
26
26
|
baseOperationMap: {
|
|
27
|
-
|
|
28
|
-
name: "点击列的表头",
|
|
29
|
-
type: "clickTh",
|
|
30
|
-
event: "clickTh"
|
|
31
|
-
},
|
|
32
|
-
createCol: {
|
|
27
|
+
canCreateCol: {
|
|
33
28
|
name: "添加一列",
|
|
34
|
-
type: "
|
|
29
|
+
type: "canCreateCol",
|
|
35
30
|
icon: "md-add",
|
|
36
|
-
event: "
|
|
31
|
+
event: "clickCreateCol"
|
|
37
32
|
},
|
|
38
|
-
|
|
33
|
+
canDeleteCol: {
|
|
39
34
|
name: "删除该列",
|
|
40
|
-
type: "
|
|
35
|
+
type: "canDeleteCol",
|
|
41
36
|
icon: "md-trash",
|
|
42
37
|
color: "red",
|
|
43
|
-
event: "
|
|
38
|
+
event: "clickDeleteCol"
|
|
44
39
|
},
|
|
45
40
|
|
|
46
41
|
clickNode: {
|
|
@@ -59,43 +54,16 @@ export default {
|
|
|
59
54
|
event: "changeNode"
|
|
60
55
|
},
|
|
61
56
|
|
|
62
|
-
|
|
63
|
-
name: "
|
|
64
|
-
type: "
|
|
65
|
-
icon: "md-add",
|
|
66
|
-
event: "clickCreate"
|
|
67
|
-
},
|
|
68
|
-
canCreateChildNode: {
|
|
69
|
-
name: "添加子节点",
|
|
70
|
-
type: "canCreateChildNode",
|
|
71
|
-
icon: "md-add",
|
|
72
|
-
event: "clickCreateChild"
|
|
73
|
-
},
|
|
74
|
-
deleteSelfAndChildNodes: {
|
|
75
|
-
name: "删除该节点",
|
|
76
|
-
type: "deleteSelfAndChildNodes",
|
|
77
|
-
icon: "md-trash",
|
|
78
|
-
color: "red",
|
|
79
|
-
divided: true,
|
|
80
|
-
event: "clickDelete"
|
|
81
|
-
},
|
|
82
|
-
deleteChildNodes: {
|
|
83
|
-
name: "删除所有子节点",
|
|
84
|
-
type: "deleteChildNodes",
|
|
85
|
-
icon: "md-trash",
|
|
86
|
-
color: "red",
|
|
87
|
-
event: "clickDeleteChilds"
|
|
88
|
-
},
|
|
89
|
-
clearNode: {
|
|
90
|
-
name: "清除该节点内容",
|
|
91
|
-
type: "clearNode",
|
|
57
|
+
canClearNode: {
|
|
58
|
+
name: "清除内容",
|
|
59
|
+
type: "canClearNode",
|
|
92
60
|
icon: "md-trash",
|
|
93
61
|
divided: true,
|
|
94
62
|
event: "clickClearNode"
|
|
95
63
|
},
|
|
96
|
-
|
|
97
|
-
name: "
|
|
98
|
-
type: "
|
|
64
|
+
canClearChildNodes: {
|
|
65
|
+
name: "清除所有下级内容",
|
|
66
|
+
type: "canClearChildNodes",
|
|
99
67
|
icon: "md-trash",
|
|
100
68
|
event: "clickClearChildNodes"
|
|
101
69
|
}
|
|
@@ -103,16 +71,6 @@ export default {
|
|
|
103
71
|
};
|
|
104
72
|
},
|
|
105
73
|
computed: {
|
|
106
|
-
selfPropsObj () {
|
|
107
|
-
return {
|
|
108
|
-
_treeForm: [],
|
|
109
|
-
...this.commonPropsObj,
|
|
110
|
-
|
|
111
|
-
_maxLevel: this.commonPropsObj._maxLevel || 3, // 最大级数
|
|
112
|
-
_contentHeight: this.propsObj._contentHeight || 400 // 表格最大高度
|
|
113
|
-
};
|
|
114
|
-
},
|
|
115
|
-
|
|
116
74
|
allTreeData () {
|
|
117
75
|
// console.log("allTreeData");
|
|
118
76
|
return this.getCalcuedTree(this.data, this.treeColumns, this.selfColumns);
|
|
@@ -150,36 +108,11 @@ export default {
|
|
|
150
108
|
this.$set(treeFormItem, "level", treeFormIndex + 1);
|
|
151
109
|
this.$set(treeFormItem, "canDelete", true);
|
|
152
110
|
});
|
|
153
|
-
|
|
154
|
-
// 循环遍树,给根节点赋值
|
|
155
|
-
const loop = (nodes = []) => {
|
|
156
|
-
nodes.forEach(rowItem => {
|
|
157
|
-
if (rowItem.children && rowItem.children.length) {
|
|
158
|
-
loop(rowItem.children);
|
|
159
|
-
} else {
|
|
160
|
-
// 根节点下所有表格字段加上监测,注入到节点对象中,必须$set,牵扯_rely值再出现并没有检测
|
|
161
|
-
this.selfColumns.forEach(subFormItem => {
|
|
162
|
-
this.$set(rowItem, subFormItem._key, rowItem[subFormItem._key]);
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
if (this.initFlag) {
|
|
167
|
-
this.fixRowItem(rowItem);
|
|
168
|
-
}
|
|
169
|
-
});
|
|
170
|
-
};
|
|
171
|
-
loop(this.data);
|
|
172
|
-
|
|
173
|
-
this.initFlag = false;
|
|
174
111
|
},
|
|
175
112
|
|
|
176
113
|
/* ----------- 操作 ---------- */
|
|
177
|
-
// 表头操作 -点击
|
|
178
|
-
clickTh (operationItem, col, colIndex) {
|
|
179
|
-
this.$emit("clickTh", col, colIndex);
|
|
180
|
-
},
|
|
181
114
|
// 表头操作 -树形表头-添加一列
|
|
182
|
-
|
|
115
|
+
clickCreateCol (operationItem, col, colIndex) {
|
|
183
116
|
if (col.colType === "tree" && col.level === this.treeColumns.length) {
|
|
184
117
|
this.treeColumns.push({
|
|
185
118
|
_id: this.$ObjectID().str,
|
|
@@ -196,7 +129,7 @@ export default {
|
|
|
196
129
|
}
|
|
197
130
|
},
|
|
198
131
|
// 表头操作 -树形表头-删除一列
|
|
199
|
-
|
|
132
|
+
clickDeleteCol (operationItem, col, colIndex) {
|
|
200
133
|
if (col.colType === "tree" && col.canDelete !== false) {
|
|
201
134
|
this.isDeleteColStatus = true; // isDeleteStatus不用在data中定义
|
|
202
135
|
this.treeColumns.pop();
|
|
@@ -232,59 +165,17 @@ export default {
|
|
|
232
165
|
changeNode (operationItem, col, row, rowIndex) {
|
|
233
166
|
this.change("changeNode", col, row, rowIndex);
|
|
234
167
|
},
|
|
235
|
-
|
|
236
|
-
/* ----------- ---------- */
|
|
237
|
-
// 节点操作 -插入一行
|
|
238
|
-
clickCreate (operationItem, row, rowIndex, col) {
|
|
239
|
-
const nodeData = this.getNodeData(col, row, rowIndex);
|
|
240
|
-
const newNode = this.getNewNode(nodeData.level, nodeData.brotherList);
|
|
241
|
-
nodeData.brotherList.splice(nodeData.index + 1, 0, newNode);
|
|
242
|
-
|
|
243
|
-
this.change("createRow", col, row, rowIndex);
|
|
244
|
-
},
|
|
245
|
-
// 节点操作 -添加子行
|
|
246
|
-
clickCreateChild (operationItem, row, rowIndex, col) {
|
|
247
|
-
const nodeData = this.getNodeData(col, row, rowIndex);
|
|
248
|
-
const newNode = this.getNewNode(nodeData.level + 1, nodeData.childList);
|
|
249
|
-
nodeData.childList.splice(nodeData.childList.length, 0, newNode);
|
|
250
|
-
|
|
251
|
-
this.change("createChildRow", col, row, rowIndex);
|
|
252
|
-
},
|
|
253
|
-
// 节点操作 -删除该行
|
|
254
|
-
clickDelete (operationItem, row, rowIndex, col) {
|
|
255
|
-
const nodeData = this.getNodeData(col, row, rowIndex);
|
|
256
|
-
nodeData.brotherList.splice(nodeData.index, 1);
|
|
257
|
-
// 此处应该判断子节点是否是最后一个,是的话就要添加一个一直到叶子节点,不过现在只需要添加一个子节点,transforBriTreeData会捎带着处理了
|
|
258
|
-
if (!nodeData.brotherList.length) {
|
|
259
|
-
const newNode = this.getNewNode(nodeData.level, nodeData.brotherList);
|
|
260
|
-
nodeData.brotherList.push(newNode);
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
this.change("deleteRow", col, row, rowIndex);
|
|
264
|
-
},
|
|
265
|
-
// 节点操作 -删除所有子行
|
|
266
|
-
clickDeleteChilds (operationItem, row, rowIndex, col) {
|
|
267
|
-
const nodeData = this.getNodeData(col, row, rowIndex);
|
|
268
|
-
nodeData.childList.splice(0);
|
|
269
|
-
// 删除完应该添加一个子节点一直到叶子节点,不过现在只需要添加一个子节点,transforBriTreeData会捎带着处理了
|
|
270
|
-
const newNode = this.getNewNode(nodeData.level + 1, nodeData.childList);
|
|
271
|
-
nodeData.childList.push(newNode);
|
|
272
|
-
|
|
273
|
-
this.change("deleteChildRows", col, row, rowIndex);
|
|
274
|
-
},
|
|
275
168
|
// 节点操作 -清除该节点内容
|
|
276
169
|
clickClearNode (operationItem, row, rowIndex, col) {
|
|
277
|
-
|
|
278
|
-
nodeData.dataObj.name = "";
|
|
170
|
+
row.name = "";
|
|
279
171
|
|
|
280
|
-
this.change("clearNode",
|
|
172
|
+
this.change("clearNode", null, row, rowIndex);
|
|
281
173
|
},
|
|
282
174
|
// 节点操作 -清除所有子节点内容
|
|
283
175
|
clickClearChildNodes (operationItem, row, rowIndex, col) {
|
|
284
|
-
|
|
285
|
-
this.$clearPropertyValToLeaf(nodeData.childList);
|
|
176
|
+
this.$clearPropertyValToLeaf(row.children);
|
|
286
177
|
|
|
287
|
-
this.change("clearChildNodes",
|
|
178
|
+
this.change("clearChildNodes", null, row, rowIndex);
|
|
288
179
|
},
|
|
289
180
|
change (eventType, col, row, rowIndex, ...params) {
|
|
290
181
|
this.$emit("change", this.tableDataObj, eventType, col, row, rowIndex, ...params);
|
|
@@ -318,12 +209,7 @@ export default {
|
|
|
318
209
|
return h("th", {
|
|
319
210
|
key: column._id,
|
|
320
211
|
class: "bri-table-th",
|
|
321
|
-
style: this.getThStyle(column, "th")
|
|
322
|
-
on: {
|
|
323
|
-
click: () => {
|
|
324
|
-
this.$dispatchEvent(this.operationMap.clickTh, column, colIndex);
|
|
325
|
-
}
|
|
326
|
-
}
|
|
212
|
+
style: this.getThStyle(column, "th")
|
|
327
213
|
}, [
|
|
328
214
|
// 表头单元格
|
|
329
215
|
this.getThRender(column, colIndex)(h)
|
|
@@ -413,14 +299,7 @@ export default {
|
|
|
413
299
|
}),
|
|
414
300
|
|
|
415
301
|
// 级联最末级表头的下拉
|
|
416
|
-
(
|
|
417
|
-
!this.isSearching &&
|
|
418
|
-
column.colType === "tree" &&
|
|
419
|
-
column.level === this.treeColumns.length &&
|
|
420
|
-
this.$getOperationList(this.getTreeThBtns(column, colIndex)).length
|
|
421
|
-
)
|
|
422
|
-
? this.getDropdownRender(h, "th", column, colIndex)
|
|
423
|
-
: undefined
|
|
302
|
+
this.getDropdownRender(h, "th", column, colIndex)
|
|
424
303
|
]);
|
|
425
304
|
};
|
|
426
305
|
},
|
|
@@ -486,12 +365,7 @@ export default {
|
|
|
486
365
|
]),
|
|
487
366
|
|
|
488
367
|
// 操作下拉
|
|
489
|
-
(
|
|
490
|
-
!this.isSearching &&
|
|
491
|
-
this.$getOperationList(this.getTreeTdBtns(column, row, rowIndex)).length
|
|
492
|
-
)
|
|
493
|
-
? this.getDropdownRender(h, "td", column, undefined, row, rowIndex)
|
|
494
|
-
: undefined
|
|
368
|
+
this.getDropdownRender(h, "td", column, undefined, row, rowIndex)
|
|
495
369
|
]
|
|
496
370
|
// 汇总单元格
|
|
497
371
|
: h("span", this.getSummaryTdVal(column, row, rowIndex))
|
|
@@ -515,45 +389,62 @@ export default {
|
|
|
515
389
|
},
|
|
516
390
|
// 下拉渲染函数
|
|
517
391
|
getDropdownRender (h, position = "th", column, colIndex, row, rowIndex) {
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
fontWeight: "500",
|
|
543
|
-
color: this.appColor
|
|
392
|
+
const list = this.$getOperationList(
|
|
393
|
+
position === "th"
|
|
394
|
+
? [
|
|
395
|
+
...(column.level <= this.maxLevel ? ["canCreateCol"] : []), // 限制最大添加到几级
|
|
396
|
+
...(column.level > 1 && column.canDelete === true ? ["canDeleteCol"] : []) // 只有一级和最后两级节点数不一致时,不能删
|
|
397
|
+
]
|
|
398
|
+
: row.isLeaf === true
|
|
399
|
+
? ["canCreate", "canDelete", "canClearNode"]
|
|
400
|
+
: ["canCreate", "canCreateChild", "canDelete", "canDeleteChilds", "canClearNode", "canClearChildNodes"]
|
|
401
|
+
);
|
|
402
|
+
|
|
403
|
+
return !this.isSearching &&
|
|
404
|
+
list.length &&
|
|
405
|
+
(
|
|
406
|
+
position === "th"
|
|
407
|
+
? column.colType === "tree" && column.level === this.treeColumns.length
|
|
408
|
+
: true
|
|
409
|
+
)
|
|
410
|
+
? h("dsh-dropdown", {
|
|
411
|
+
class: "bri-table-dropdown",
|
|
412
|
+
props: {
|
|
413
|
+
menuClass: "bri-table-dropdown-list",
|
|
414
|
+
trigger: "hover",
|
|
415
|
+
list: list
|
|
544
416
|
},
|
|
545
|
-
|
|
546
|
-
|
|
417
|
+
on: {
|
|
418
|
+
click: (operationItem) => {
|
|
419
|
+
position === "th"
|
|
420
|
+
? this.$dispatchEvent(operationItem, column, colIndex)
|
|
421
|
+
: this.$dispatchEvent(operationItem, row, rowIndex, column);
|
|
422
|
+
}
|
|
423
|
+
},
|
|
424
|
+
nativeOn: {
|
|
425
|
+
click: (e) => {
|
|
426
|
+
e.stopPropagation();
|
|
427
|
+
}
|
|
547
428
|
}
|
|
548
429
|
}, [
|
|
549
|
-
h("
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
430
|
+
h("a", {
|
|
431
|
+
style: {
|
|
432
|
+
fontWeight: "500",
|
|
433
|
+
color: this.appColor
|
|
434
|
+
},
|
|
435
|
+
attrs: {
|
|
436
|
+
href: "javascript:void(0)"
|
|
553
437
|
}
|
|
554
|
-
}
|
|
438
|
+
}, [
|
|
439
|
+
h("Icon", {
|
|
440
|
+
props: {
|
|
441
|
+
type: "md-arrow-dropdown-circle",
|
|
442
|
+
size: "16"
|
|
443
|
+
}
|
|
444
|
+
})
|
|
445
|
+
])
|
|
555
446
|
])
|
|
556
|
-
|
|
447
|
+
: undefined;
|
|
557
448
|
},
|
|
558
449
|
|
|
559
450
|
/* ----------- 方法 ---------- */
|
|
@@ -588,13 +479,6 @@ export default {
|
|
|
588
479
|
...selfStyle
|
|
589
480
|
};
|
|
590
481
|
},
|
|
591
|
-
// 表头 -树节点表头-获取下拉操作
|
|
592
|
-
getTreeThBtns (col) {
|
|
593
|
-
return [
|
|
594
|
-
"createCol",
|
|
595
|
-
...(col.level > 1 && col.canDelete === true ? ["deleteCol"] : [])
|
|
596
|
-
];
|
|
597
|
-
},
|
|
598
482
|
|
|
599
483
|
// 单元格 -获取样式
|
|
600
484
|
getTdStyle (col, row, rowIndex) {
|
|
@@ -641,35 +525,6 @@ export default {
|
|
|
641
525
|
: "未选择算法";
|
|
642
526
|
}
|
|
643
527
|
},
|
|
644
|
-
// 单元格 -树节点单元格-获取下拉操作
|
|
645
|
-
getTreeTdBtns (col, row, rowIndex) {
|
|
646
|
-
return row.children.length === 0
|
|
647
|
-
? ["canCreateBrother", "deleteSelfAndChildNodes", "clearNode"]
|
|
648
|
-
: ["canCreateBrother", "canCreateChildNode", "deleteSelfAndChildNodes", "deleteChildNodes", "clearNode", "clearChildNodes"];
|
|
649
|
-
},
|
|
650
|
-
// 单元格 -普通单元格-获取节点系列数据
|
|
651
|
-
getNodeData (col, row, rowIndex) {
|
|
652
|
-
const parentRow = this.getParentRow(row, this.data);
|
|
653
|
-
|
|
654
|
-
return {
|
|
655
|
-
level: col.level,
|
|
656
|
-
dataObj: row,
|
|
657
|
-
childList: row.children,
|
|
658
|
-
brotherList: parentRow.children,
|
|
659
|
-
index: parentRow.children.findIndex(childRowItem => childRowItem._id === row._id)
|
|
660
|
-
};
|
|
661
|
-
},
|
|
662
|
-
// 单元格 -普通单元格-新增节点数据
|
|
663
|
-
getNewNode (level, list) {
|
|
664
|
-
return {
|
|
665
|
-
...this.$deepCopy(this.selfRowDefault),
|
|
666
|
-
_id: this.$ObjectID().str,
|
|
667
|
-
name: `${this.$numToChinese(level)}级节点${list.length + 1}`,
|
|
668
|
-
level: level,
|
|
669
|
-
isLeaf: true,
|
|
670
|
-
children: []
|
|
671
|
-
};
|
|
672
|
-
},
|
|
673
528
|
|
|
674
529
|
/* ----------- 工具方法 ---------- */
|
|
675
530
|
// 合并表头
|
|
@@ -713,10 +568,10 @@ export default {
|
|
|
713
568
|
|
|
714
569
|
// 循环遍树节点
|
|
715
570
|
const loop = (nodes = []) => {
|
|
716
|
-
nodes.forEach(
|
|
571
|
+
nodes.forEach(rowItem => {
|
|
717
572
|
// 初始化树节点的数据,给节点加上一些属性并监测,注入到节点对象中
|
|
718
|
-
let curCol = treeForm[
|
|
719
|
-
this.$setObj(
|
|
573
|
+
let curCol = treeForm[rowItem.level - 1];
|
|
574
|
+
this.$setObj(rowItem, {
|
|
720
575
|
_key: curCol._key,
|
|
721
576
|
level: curCol.level,
|
|
722
577
|
isEdit: false,
|
|
@@ -725,51 +580,54 @@ export default {
|
|
|
725
580
|
});
|
|
726
581
|
|
|
727
582
|
// 最后一列(根节点)
|
|
728
|
-
if (
|
|
583
|
+
if (rowItem.level === treeForm.length) {
|
|
729
584
|
// 处理删除了最后一列后,把根节点上的subForm属性值全部给上级节点
|
|
730
585
|
if (this.isDeleteColStatus) {
|
|
731
|
-
let subNode =
|
|
586
|
+
let subNode = rowItem.children[0];
|
|
732
587
|
subForm.forEach(subFormItem => {
|
|
733
588
|
// 用$set也可以
|
|
734
|
-
|
|
589
|
+
rowItem[subFormItem._key] = subNode[subFormItem._key];
|
|
735
590
|
});
|
|
736
591
|
}
|
|
737
592
|
|
|
738
|
-
|
|
739
|
-
|
|
593
|
+
rowItem.children = [];
|
|
594
|
+
rowItem.isLeaf = true;
|
|
740
595
|
}
|
|
741
596
|
// 非最后一列(最后一列前的列,非根节点),需继续向下循环
|
|
742
597
|
else {
|
|
743
598
|
// 判断是否能删除最后一列(1.判断条件:判断根节点列的前一列的所有节点 都必须只有一个子结点 2.canDelete放在表头treeForm最后一项,默认true)
|
|
744
|
-
if (
|
|
745
|
-
if (
|
|
746
|
-
treeForm[
|
|
599
|
+
if (rowItem.level === treeForm.length - 1) {
|
|
600
|
+
if (rowItem.children.length > 1) {
|
|
601
|
+
treeForm[rowItem.level].canDelete = false;
|
|
747
602
|
}
|
|
748
603
|
}
|
|
749
604
|
|
|
750
605
|
// 非最后一列的 正常的非根节点
|
|
751
|
-
if (
|
|
752
|
-
loop(
|
|
606
|
+
if (rowItem.children && rowItem.children.length) {
|
|
607
|
+
loop(rowItem.children);
|
|
753
608
|
}
|
|
754
609
|
// 非最后一列的 新增的非根节点(此时是新增一列或新增非根节点行) -添加一个子节点,并把该节点上的subForm属性值全部给下级节点
|
|
755
610
|
// 特别提示:新增的是根节点行,不会走此处代码
|
|
756
611
|
else {
|
|
757
|
-
const newNode = this.
|
|
612
|
+
const newNode = this.getNewRowData(rowItem.level + 1, rowItem.children);
|
|
758
613
|
subForm.forEach(subFormItem => {
|
|
759
614
|
// 用$set也可以
|
|
760
|
-
newNode[subFormItem._key] =
|
|
761
|
-
delete
|
|
615
|
+
newNode[subFormItem._key] = rowItem[subFormItem._key];
|
|
616
|
+
delete rowItem[subFormItem._key];
|
|
762
617
|
});
|
|
763
|
-
|
|
618
|
+
rowItem.children.push(newNode);
|
|
764
619
|
|
|
765
|
-
loop(
|
|
620
|
+
loop(rowItem.children);
|
|
766
621
|
}
|
|
767
622
|
}
|
|
623
|
+
|
|
624
|
+
this.fixRowItem(rowItem);
|
|
768
625
|
});
|
|
769
626
|
};
|
|
770
627
|
loop(nodes);
|
|
771
|
-
this.isDeleteColStatus = false;
|
|
772
628
|
|
|
629
|
+
this.isDeleteColStatus = false;
|
|
630
|
+
this.initFlag = false;
|
|
773
631
|
return nodes;
|
|
774
632
|
},
|
|
775
633
|
// 转化渲染使用的columns数组
|
|
@@ -823,12 +681,20 @@ export default {
|
|
|
823
681
|
},
|
|
824
682
|
getFilteredNodes (nodes = []) {
|
|
825
683
|
const loop = (nodes = []) => {
|
|
826
|
-
return nodes.filter(
|
|
827
|
-
if (
|
|
828
|
-
const children = loop(
|
|
684
|
+
return nodes.filter(rowItem => {
|
|
685
|
+
if (rowItem.children && rowItem.children.length) {
|
|
686
|
+
const children = loop(rowItem.children);
|
|
829
687
|
return !!children.length;
|
|
830
688
|
} else {
|
|
831
|
-
|
|
689
|
+
const bool = this.$isAdvRelyAccord(this.finalTableAdvSearch, rowItem);
|
|
690
|
+
// 重置
|
|
691
|
+
rowItem.__isSearchShow__ = false;
|
|
692
|
+
if (bool) {
|
|
693
|
+
rowItem.__isRendered__ = true;
|
|
694
|
+
rowItem.__isSearchShow__ = true;
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
return bool;
|
|
832
698
|
}
|
|
833
699
|
});
|
|
834
700
|
};
|
|
@@ -8,14 +8,7 @@ export default {
|
|
|
8
8
|
computed: {
|
|
9
9
|
allListData () {
|
|
10
10
|
this.data.forEach(rowItem => {
|
|
11
|
-
|
|
12
|
-
this.fixRowItem(rowItem);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
rowItem.__isRendered__ = true;
|
|
16
|
-
rowItem.__isShow__ = true;
|
|
17
|
-
rowItem.__isTmpShow__ = true;
|
|
18
|
-
rowItem.__isSearchShow__ = false;
|
|
11
|
+
this.fixRowItem(rowItem);
|
|
19
12
|
});
|
|
20
13
|
|
|
21
14
|
this.initFlag = false;
|
|
@@ -84,36 +77,39 @@ export default {
|
|
|
84
77
|
methods: {
|
|
85
78
|
// 点击 -添加行
|
|
86
79
|
clickCreate (operationItem, row, rowIndex, col) {
|
|
87
|
-
// 处理单元格合并相关
|
|
88
|
-
let mergeRowData = {};
|
|
89
|
-
if (col && col._mergeRow) {
|
|
90
|
-
const newList = this.showListData.slice(rowIndex);
|
|
91
|
-
const newIndex = newList.findIndex(rowItem => row[col._key] !== rowItem[col._key]);
|
|
92
|
-
row = newList[newIndex - 1];
|
|
93
|
-
|
|
94
|
-
// 当前列是合并列,则该列之前的合并列,要复制这一行对应列的值;当前列是普通列,则所有的合并列不用处理
|
|
95
|
-
const curIndex = this.mergeRowColumns.findIndex(column => col._key === column._key);
|
|
96
|
-
mergeRowData = this.mergeRowColumns.reduce((obj, column, colIndex) => {
|
|
97
|
-
return colIndex < curIndex
|
|
98
|
-
? Object.assign(obj, { [column._key]: row[column._key] })
|
|
99
|
-
: obj;
|
|
100
|
-
}, {});
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
const newRow = {
|
|
104
|
-
...this.$deepCopy(this.selfRowDefault),
|
|
105
|
-
...this.$deepCopy(mergeRowData),
|
|
106
|
-
_id: this.$ObjectID().str,
|
|
107
|
-
__isRendered__: true,
|
|
108
|
-
__isShow__: true,
|
|
109
|
-
__isTmpShow__: true,
|
|
110
|
-
__isSearchShow__: false,
|
|
111
|
-
__isDefault__: this.controlKey === "_default"
|
|
112
|
-
};
|
|
113
80
|
const list = this.data;
|
|
81
|
+
const newRow = this.getNewRowData();
|
|
114
82
|
const newRowIndex = row
|
|
115
83
|
? list.findIndex(rowItem => rowItem._id === row._id) + 1
|
|
116
84
|
: list.length;
|
|
85
|
+
|
|
86
|
+
// 处理单元格合并相关(当前列是合并列,则该列之前的合并列,要复制这一行对应列的值;当前列是普通列,按最后合并列的操作处理)
|
|
87
|
+
if (col) {
|
|
88
|
+
if (col._mergeRow === true) {
|
|
89
|
+
const newList = this.allListData.slice(rowIndex); // 从该行开始截取
|
|
90
|
+
const nextRowIndex = newList.findIndex(rowItem => rowItem[col._key] !== row[col._key]); // 寻找该单元格值开始不一样的行(特殊情况是最后一行,nextRowIndex为-1)
|
|
91
|
+
row = nextRowIndex < 0 ? newList[newList.length - 1] : newList[nextRowIndex - 1]; // 取该单元格值一样的最后一行
|
|
92
|
+
|
|
93
|
+
const colIndex = this.mergeRowColumns.findIndex(column => column._key === col._key);
|
|
94
|
+
this.mergeRowColumns.reduce((obj, column, columnIndex) => {
|
|
95
|
+
return columnIndex < colIndex
|
|
96
|
+
? Object.assign(obj, {
|
|
97
|
+
[column._key]: this.$deepCopy(row[column._key])
|
|
98
|
+
})
|
|
99
|
+
: obj;
|
|
100
|
+
}, newRow);
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
const colIndex = this.selfColumns.findIndex(column => column._key === col._key);
|
|
104
|
+
const mergeRowColumns = this.selfColumns.filter((column, columnIndex) => columnIndex < colIndex && column._mergeRow === true);
|
|
105
|
+
mergeRowColumns.slice(0, mergeRowColumns.length - 1).reduce((obj, column) => {
|
|
106
|
+
return Object.assign(obj, {
|
|
107
|
+
[column._key]: this.$deepCopy(row[column._key])
|
|
108
|
+
});
|
|
109
|
+
}, newRow);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
117
113
|
list.splice(newRowIndex, 0, newRow);
|
|
118
114
|
|
|
119
115
|
this.change("createRow", null, newRow, newRowIndex);
|
|
@@ -129,6 +125,10 @@ export default {
|
|
|
129
125
|
this.change("deleteRow", null, row, rowIndex);
|
|
130
126
|
}
|
|
131
127
|
});
|
|
128
|
+
},
|
|
129
|
+
|
|
130
|
+
change (eventType, col, row, rowIndex, ...params) {
|
|
131
|
+
this.$emit("change", { list: this.allListData, rowDefault: this.rowDefault }, eventType, col, row, rowIndex, ...params);
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
134
|
};
|
|
@@ -1,44 +1,11 @@
|
|
|
1
|
-
import { resourceData } from "bri-datas";
|
|
2
|
-
|
|
3
1
|
export default {
|
|
4
2
|
mixins: [],
|
|
5
3
|
components: {},
|
|
6
4
|
props: {},
|
|
7
5
|
data () {
|
|
8
|
-
return {
|
|
9
|
-
// 除了__readonly__, __isDefault__, __old__, __isQuote__不处理
|
|
10
|
-
deleteProperties: ["__treeIndex__", "__isExpand__", "__isRendered__", "__isShow__", "__isTmpShow__", "__isSearchShow__"],
|
|
11
|
-
searchMode: "flat" // "flat", "tree"
|
|
12
|
-
};
|
|
6
|
+
return {};
|
|
13
7
|
},
|
|
14
8
|
computed: {
|
|
15
|
-
selfColumns () {
|
|
16
|
-
return this.columns.map(column => {
|
|
17
|
-
// 层级表格类型,level字段的进行特殊处理(_treeForm加工成_data)
|
|
18
|
-
return column._key === "level"
|
|
19
|
-
? {
|
|
20
|
-
...column,
|
|
21
|
-
_data: this.selfPropsObj._treeForm.map((treeFormItem, treeFormIndex) => ({
|
|
22
|
-
name: treeFormItem._name,
|
|
23
|
-
_key: (treeFormIndex + 1),
|
|
24
|
-
color: Object.keys(resourceData.colorMap)[treeFormIndex + 1]
|
|
25
|
-
}))
|
|
26
|
-
}
|
|
27
|
-
: column;
|
|
28
|
-
});
|
|
29
|
-
},
|
|
30
|
-
selfPropsObj () {
|
|
31
|
-
return {
|
|
32
|
-
_treeForm: [],
|
|
33
|
-
...this.commonPropsObj,
|
|
34
|
-
|
|
35
|
-
_maxLevel: this.commonPropsObj._maxLevel || 3 // 最大级数
|
|
36
|
-
};
|
|
37
|
-
},
|
|
38
|
-
maxLevel () {
|
|
39
|
-
return this.selfPropsObj._maxLevel;
|
|
40
|
-
},
|
|
41
|
-
|
|
42
9
|
allTreeData () {
|
|
43
10
|
return this.getCalcuedTree(this.data, this.selfColumns);
|
|
44
11
|
},
|
|
@@ -150,76 +117,8 @@ export default {
|
|
|
150
117
|
},
|
|
151
118
|
created () { },
|
|
152
119
|
methods: {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
this.searchMode = "flat";
|
|
156
|
-
this.dftAdvSearch = {
|
|
157
|
-
logic: "and",
|
|
158
|
-
conditions: []
|
|
159
|
-
};
|
|
160
|
-
},
|
|
161
|
-
|
|
162
|
-
// 点击 -添加一行
|
|
163
|
-
clickCreate (operationItem, row, rowIndex, col) {
|
|
164
|
-
const newRow = {
|
|
165
|
-
...this.$deepCopy(this.selfRowDefault),
|
|
166
|
-
_id: this.$ObjectID().str,
|
|
167
|
-
level: row ? row.level : 1,
|
|
168
|
-
isLeaf: true,
|
|
169
|
-
children: [],
|
|
170
|
-
// __old__: false,
|
|
171
|
-
__isExpand__: false,
|
|
172
|
-
__isRendered__: true,
|
|
173
|
-
__isShow__: true,
|
|
174
|
-
__isTmpShow__: false,
|
|
175
|
-
__isSearchShow__: false
|
|
176
|
-
};
|
|
177
|
-
const list = row
|
|
178
|
-
? this.getParentRow(row, this.data).children
|
|
179
|
-
: this.data;
|
|
180
|
-
const newRowIndex = row
|
|
181
|
-
? list.findIndex(rowItem => rowItem._id === row._id) + 1
|
|
182
|
-
: list.length;
|
|
183
|
-
list.splice(newRowIndex, 0, newRow);
|
|
184
|
-
|
|
185
|
-
this.change("createRow", null, newRow, newRowIndex);
|
|
186
|
-
},
|
|
187
|
-
// 点击 -添加子行
|
|
188
|
-
clickCreateChild (operationItem, row, rowIndex, col) {
|
|
189
|
-
const newRow = {
|
|
190
|
-
...this.$deepCopy(this.selfRowDefault),
|
|
191
|
-
_id: this.$ObjectID().str,
|
|
192
|
-
level: row.level + 1,
|
|
193
|
-
isLeaf: true,
|
|
194
|
-
children: [],
|
|
195
|
-
// __old__: false,
|
|
196
|
-
__isExpand__: false,
|
|
197
|
-
__isRendered__: true,
|
|
198
|
-
__isShow__: true,
|
|
199
|
-
__isTmpShow__: false,
|
|
200
|
-
__isSearchShow__: false
|
|
201
|
-
};
|
|
202
|
-
const list = row.children;
|
|
203
|
-
const newRowIndex = list.length;
|
|
204
|
-
list.splice(newRowIndex, 0, newRow);
|
|
205
|
-
// 展开子级
|
|
206
|
-
this.toggleExpand(row, true);
|
|
207
|
-
|
|
208
|
-
this.change("createChildRow", null, newRow, newRowIndex);
|
|
209
|
-
},
|
|
210
|
-
// 点击 -删除行
|
|
211
|
-
clickDelete (operationItem, row, rowIndex) {
|
|
212
|
-
this.$Modal.confirm({
|
|
213
|
-
title: "警告",
|
|
214
|
-
content: "确定删除吗?",
|
|
215
|
-
onOk: () => {
|
|
216
|
-
const parentRow = this.getParentRow(row, this.data);
|
|
217
|
-
const index = parentRow.children.findIndex(childRowItem => childRowItem._id === row._id);
|
|
218
|
-
parentRow.children.splice(index, 1);
|
|
219
|
-
|
|
220
|
-
this.change("deleteRow", null, row, rowIndex);
|
|
221
|
-
}
|
|
222
|
-
});
|
|
120
|
+
change (eventType, col, row, rowIndex, ...params) {
|
|
121
|
+
this.$emit("change", { tree: this.data, rowDefault: this.rowDefault }, eventType, col, row, rowIndex, ...params);
|
|
223
122
|
},
|
|
224
123
|
|
|
225
124
|
/* ------ 工具方法 ------- */
|
|
@@ -299,62 +198,12 @@ export default {
|
|
|
299
198
|
}, rowItem);
|
|
300
199
|
}
|
|
301
200
|
|
|
302
|
-
|
|
303
|
-
this.fixRowItem(rowItem);
|
|
304
|
-
|
|
305
|
-
// 初次进来把前端存的状态值全部清除
|
|
306
|
-
this.deleteProperties.forEach(property => {
|
|
307
|
-
delete rowItem[property];
|
|
308
|
-
});
|
|
309
|
-
// rowItem.__isExpand__ = false;
|
|
310
|
-
// rowItem.__isSearchShow__ = false;
|
|
311
|
-
// 第一级的需要显示出来
|
|
312
|
-
if (rowItem.level == 1) {
|
|
313
|
-
rowItem.__isRendered__ = true;
|
|
314
|
-
rowItem.__isShow__ = true;
|
|
315
|
-
rowItem.__isTmpShow__ = true;
|
|
316
|
-
} else {
|
|
317
|
-
// rowItem.__isRendered__ = false;
|
|
318
|
-
// rowItem.__isShow__ = false;
|
|
319
|
-
// rowItem.__isTmpShow__ = false;
|
|
320
|
-
}
|
|
321
|
-
}
|
|
201
|
+
this.fixRowItem(rowItem);
|
|
322
202
|
});
|
|
323
203
|
loop(treeData);
|
|
324
204
|
|
|
325
205
|
this.initFlag = false;
|
|
326
206
|
return treeData;
|
|
327
|
-
},
|
|
328
|
-
// 展开/隐藏节点
|
|
329
|
-
toggleExpand (row, bool = true) {
|
|
330
|
-
this.isExpandAction = true;
|
|
331
|
-
this.$set(row, "__isExpand__", bool);
|
|
332
|
-
|
|
333
|
-
this.toggleDescendantsShow(row, bool);
|
|
334
|
-
},
|
|
335
|
-
// 切换子孙后代的显示/隐藏
|
|
336
|
-
toggleDescendantsShow (row, bool) {
|
|
337
|
-
const loop = (row, isFirstSon) => {
|
|
338
|
-
if (row.children && row.children.length) {
|
|
339
|
-
row.children.forEach(subRow => {
|
|
340
|
-
if (isFirstSon) {
|
|
341
|
-
this.$set(subRow, "__isRendered__", true);
|
|
342
|
-
this.$set(subRow, "__isShow__", bool);
|
|
343
|
-
this.$set(subRow, "__isTmpShow__", bool);
|
|
344
|
-
} else {
|
|
345
|
-
if (bool) {
|
|
346
|
-
this.$set(subRow, "__isShow__", subRow.__isTmpShow__);
|
|
347
|
-
} else {
|
|
348
|
-
this.$set(subRow, "__isShow__", false);
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
loop(subRow);
|
|
353
|
-
});
|
|
354
|
-
}
|
|
355
|
-
};
|
|
356
|
-
|
|
357
|
-
loop(row, true);
|
|
358
207
|
}
|
|
359
208
|
}
|
|
360
209
|
};
|
|
@@ -63,6 +63,8 @@ export default {
|
|
|
63
63
|
return {
|
|
64
64
|
widthMap: this.$getModFieldPropertyMap("width"),
|
|
65
65
|
initDftValMap: this.$getModFieldPropertyMap("initDefaultVal"),
|
|
66
|
+
saveProperties: ["__readonly__", "__isDefault__", "__old__", "__isQuote__"],
|
|
67
|
+
resetProperties: ["__treeIndex__", "__isExpand__", "__isRendered__", "__isShow__", "__isTmpShow__", "__isSearchShow__"],
|
|
66
68
|
|
|
67
69
|
initFlag: true,
|
|
68
70
|
showRuleMessage: false, // 进行全体校验
|
|
@@ -70,10 +72,7 @@ export default {
|
|
|
70
72
|
hoverRecordMap: {},
|
|
71
73
|
isExpandAction: false,
|
|
72
74
|
|
|
73
|
-
|
|
74
|
-
logic: "and",
|
|
75
|
-
conditions: []
|
|
76
|
-
},
|
|
75
|
+
showTopSearch: true,
|
|
77
76
|
selfLogicPropsObj: {
|
|
78
77
|
_name: "逻辑",
|
|
79
78
|
_key: "logic",
|
|
@@ -84,6 +83,10 @@ export default {
|
|
|
84
83
|
{ _key: "or", name: "或" }
|
|
85
84
|
]
|
|
86
85
|
},
|
|
86
|
+
dftAdvSearch: {
|
|
87
|
+
logic: "and",
|
|
88
|
+
conditions: []
|
|
89
|
+
},
|
|
87
90
|
|
|
88
91
|
dshRenderName: undefined,
|
|
89
92
|
hideStatus: true,
|
|
@@ -167,6 +170,16 @@ export default {
|
|
|
167
170
|
disabled: false,
|
|
168
171
|
event: "clickDelete"
|
|
169
172
|
},
|
|
173
|
+
canDeleteChilds: {
|
|
174
|
+
name: "删除所有子级",
|
|
175
|
+
type: "canDeleteChilds",
|
|
176
|
+
btnType: "errorText",
|
|
177
|
+
icon: "ios-trash-outline",
|
|
178
|
+
size: "small",
|
|
179
|
+
color: "#E83636",
|
|
180
|
+
disabled: false,
|
|
181
|
+
event: "clickDeleteChilds"
|
|
182
|
+
},
|
|
170
183
|
changeVal: {
|
|
171
184
|
name: "改变输入框值",
|
|
172
185
|
type: "changeVal",
|
|
@@ -207,7 +220,7 @@ export default {
|
|
|
207
220
|
return this.columns;
|
|
208
221
|
},
|
|
209
222
|
mergeRowColumns () {
|
|
210
|
-
return this.
|
|
223
|
+
return this.selfColumns.filter(column => column._mergeRow === true);
|
|
211
224
|
},
|
|
212
225
|
filterColumns () {
|
|
213
226
|
return this.selfColumns.filter(col => this.$isAdvRelyShow(col, this.allListData, this.parentObj, true));
|
|
@@ -396,26 +409,26 @@ export default {
|
|
|
396
409
|
.filter(id => !!id);
|
|
397
410
|
},
|
|
398
411
|
renderedListData () {
|
|
399
|
-
return this.allListData.filter(
|
|
412
|
+
return this.allListData.filter(rowItem => {
|
|
400
413
|
if (this.isSearching) {
|
|
401
|
-
const bool = this.$isAdvRelyAccord(this.finalTableAdvSearch,
|
|
414
|
+
const bool = this.$isAdvRelyAccord(this.finalTableAdvSearch, rowItem);
|
|
402
415
|
|
|
403
416
|
// 重置
|
|
404
|
-
|
|
417
|
+
rowItem.__isSearchShow__ = false;
|
|
405
418
|
if (bool) {
|
|
406
|
-
|
|
407
|
-
|
|
419
|
+
rowItem.__isRendered__ = true;
|
|
420
|
+
rowItem.__isSearchShow__ = true;
|
|
408
421
|
}
|
|
409
422
|
}
|
|
410
423
|
|
|
411
|
-
return
|
|
424
|
+
return rowItem.__isRendered__;
|
|
412
425
|
});
|
|
413
426
|
},
|
|
414
427
|
showListData () {
|
|
415
|
-
return this.renderedListData.filter(
|
|
428
|
+
return this.renderedListData.filter(rowItem =>
|
|
416
429
|
this.isSearching
|
|
417
|
-
? !!
|
|
418
|
-
: !!
|
|
430
|
+
? !!rowItem.__isSearchShow__
|
|
431
|
+
: !!rowItem.__isShow__
|
|
419
432
|
);
|
|
420
433
|
},
|
|
421
434
|
parentDataId () {
|
|
@@ -428,7 +441,7 @@ export default {
|
|
|
428
441
|
const initDftVal = this.initDftValMap[column._type];
|
|
429
442
|
|
|
430
443
|
return Object.assign(obj, {
|
|
431
|
-
[column._key]:
|
|
444
|
+
[column._key]: dftInRowVal === undefined
|
|
432
445
|
? this.$isEmptyData(dftVal)
|
|
433
446
|
? initDftVal
|
|
434
447
|
: dftVal
|
|
@@ -807,7 +820,13 @@ export default {
|
|
|
807
820
|
this.initFlag = true;
|
|
808
821
|
this.showRuleMessage = false;
|
|
809
822
|
this.ruleRecordMap = {};
|
|
823
|
+
this.hoverRecordMap = {};
|
|
810
824
|
this.isExpandAction = false;
|
|
825
|
+
this.dftAdvSearch = {
|
|
826
|
+
logic: "and",
|
|
827
|
+
conditions: []
|
|
828
|
+
};
|
|
829
|
+
this.hideStatus = true;
|
|
811
830
|
this.selfReset && this.selfReset();
|
|
812
831
|
},
|
|
813
832
|
// 共外部使用
|
|
@@ -834,9 +853,6 @@ export default {
|
|
|
834
853
|
this.$set(this.ruleRecordMap, `${row._id}dsh${col._key}`, { showRuleMessage: true });
|
|
835
854
|
this.change("changeVal", col, row, rowIndex, ...params);
|
|
836
855
|
},
|
|
837
|
-
change (eventType, col, row, rowIndex, ...params) {
|
|
838
|
-
this.$emit("change", { list: this.allListData, rowDefault: this.rowDefault }, eventType, col, row, rowIndex, ...params);
|
|
839
|
-
},
|
|
840
856
|
|
|
841
857
|
/* ----------- 隐藏/显示字段 ---------- */
|
|
842
858
|
toggleHideOrShow () {
|
|
@@ -880,10 +896,10 @@ export default {
|
|
|
880
896
|
if (dataObj) {
|
|
881
897
|
const fieldVal = dataObj[this.controlKey];
|
|
882
898
|
const isEmpty = this.$isEmptyData(fieldVal) || (
|
|
883
|
-
["
|
|
884
|
-
? !fieldVal.
|
|
885
|
-
: ["
|
|
886
|
-
? !fieldVal.
|
|
899
|
+
["cascaderTable"].includes(this.controlType)
|
|
900
|
+
? !fieldVal.tree || !fieldVal.tree.length
|
|
901
|
+
: ["flatTable"].includes(this.controlType)
|
|
902
|
+
? !fieldVal.list || !fieldVal.list.length
|
|
887
903
|
: false
|
|
888
904
|
);
|
|
889
905
|
|
|
@@ -895,17 +911,7 @@ export default {
|
|
|
895
911
|
});
|
|
896
912
|
}
|
|
897
913
|
else {
|
|
898
|
-
if (["
|
|
899
|
-
this.parentObj[this.controlKey] = {
|
|
900
|
-
...fieldVal,
|
|
901
|
-
list: fieldVal.list.map(item => ({
|
|
902
|
-
...item,
|
|
903
|
-
__isQuote__: true,
|
|
904
|
-
__old__: false
|
|
905
|
-
}))
|
|
906
|
-
};
|
|
907
|
-
}
|
|
908
|
-
else if (["cascaderTable"].includes(this.controlType)) {
|
|
914
|
+
if (["cascaderTable"].includes(this.controlType)) {
|
|
909
915
|
const transformData = (list = []) => {
|
|
910
916
|
const loop = (list = []) =>
|
|
911
917
|
list.map(item => ({
|
|
@@ -923,9 +929,24 @@ export default {
|
|
|
923
929
|
tree: transformData(fieldVal.tree)
|
|
924
930
|
};
|
|
925
931
|
}
|
|
932
|
+
else if (["flatTable"].includes(this.controlType)) {
|
|
933
|
+
this.parentObj[this.controlKey] = {
|
|
934
|
+
...fieldVal,
|
|
935
|
+
list: fieldVal.list.map(item => ({
|
|
936
|
+
...item,
|
|
937
|
+
__isQuote__: true,
|
|
938
|
+
__old__: false
|
|
939
|
+
}))
|
|
940
|
+
};
|
|
941
|
+
}
|
|
926
942
|
|
|
927
943
|
this.$Message.success("引用成功!");
|
|
928
944
|
this.reset();
|
|
945
|
+
this.showTopSearch = false;
|
|
946
|
+
this.$nextTick(() => {
|
|
947
|
+
this.showTopSearch = true;
|
|
948
|
+
});
|
|
949
|
+
|
|
929
950
|
this.change("quote");
|
|
930
951
|
}
|
|
931
952
|
} else {
|
|
@@ -1231,6 +1252,43 @@ export default {
|
|
|
1231
1252
|
},
|
|
1232
1253
|
|
|
1233
1254
|
/* ----------- 方法 ---------- */
|
|
1255
|
+
// 生成新的一行数据
|
|
1256
|
+
getNewRowData (level, list) {
|
|
1257
|
+
if (["cascaderTable"].includes(this.controlType)) {
|
|
1258
|
+
return {
|
|
1259
|
+
...this.$deepCopy(this.selfRowDefault),
|
|
1260
|
+
_id: this.$ObjectID().str,
|
|
1261
|
+
level: level,
|
|
1262
|
+
isLeaf: true,
|
|
1263
|
+
children: [],
|
|
1264
|
+
...(
|
|
1265
|
+
["treeTable"].includes(this.inTableType)
|
|
1266
|
+
? {}
|
|
1267
|
+
: {
|
|
1268
|
+
name: `${this.$numToChinese(level)}级节点${list.length + 1}`
|
|
1269
|
+
}
|
|
1270
|
+
),
|
|
1271
|
+
// __old__: false,
|
|
1272
|
+
__isDefault__: this.controlKey === "_default",
|
|
1273
|
+
__isRendered__: true,
|
|
1274
|
+
__isShow__: true,
|
|
1275
|
+
__isTmpShow__: true,
|
|
1276
|
+
__isSearchShow__: false,
|
|
1277
|
+
__isExpand__: false
|
|
1278
|
+
};
|
|
1279
|
+
} else {
|
|
1280
|
+
return {
|
|
1281
|
+
...this.$deepCopy(this.selfRowDefault),
|
|
1282
|
+
_id: this.$ObjectID().str,
|
|
1283
|
+
// __old__: false,
|
|
1284
|
+
__isDefault__: this.controlKey === "_default",
|
|
1285
|
+
__isRendered__: true,
|
|
1286
|
+
__isShow__: true,
|
|
1287
|
+
__isTmpShow__: true,
|
|
1288
|
+
__isSearchShow__: false
|
|
1289
|
+
};
|
|
1290
|
+
}
|
|
1291
|
+
},
|
|
1234
1292
|
// 整行校验结果
|
|
1235
1293
|
getRowRuleResult (row, rowIndex) {
|
|
1236
1294
|
return this.filterColumns.every(column => this.getColRuleResult(column, row, rowIndex).bool);
|
|
@@ -1368,25 +1426,50 @@ export default {
|
|
|
1368
1426
|
},
|
|
1369
1427
|
// 初始化时 修复数据
|
|
1370
1428
|
fixRowItem (row) {
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1429
|
+
if (this.initFlag) {
|
|
1430
|
+
// TODO:修正数据level属性,后期可以删除
|
|
1431
|
+
if (["cascaderTable"].includes(this.controlType)) {
|
|
1432
|
+
row.level = row.level || levelNum;
|
|
1433
|
+
}
|
|
1375
1434
|
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1435
|
+
if (row._id) {
|
|
1436
|
+
if (this.defaultListDataIds.includes(row._id)) {
|
|
1437
|
+
row.__isDefault__ = true;
|
|
1379
1438
|
|
|
1380
|
-
|
|
1439
|
+
// 默认数据的id置换一遍,不然每条数据里该列表的id都是重复的
|
|
1440
|
+
row._id = this.$ObjectID().str;
|
|
1441
|
+
}
|
|
1442
|
+
} else {
|
|
1381
1443
|
row._id = this.$ObjectID().str;
|
|
1382
1444
|
}
|
|
1383
|
-
} else {
|
|
1384
|
-
row._id = this.$ObjectID().str;
|
|
1385
|
-
}
|
|
1386
1445
|
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1446
|
+
row.__old__ = this.controlKey === "_default" ? false : !this.parentObj.__isCreate__; // 标记老数据
|
|
1447
|
+
row.__isDefault__ = this.controlKey === "_default" ? true : !!row.__isDefault__; // 标记默认数据(配置端默认值)
|
|
1448
|
+
|
|
1449
|
+
// 初次进来 把关于展示的状态值全部清除
|
|
1450
|
+
this.resetProperties.forEach(property => {
|
|
1451
|
+
delete row[property];
|
|
1452
|
+
});
|
|
1453
|
+
if (["treeTable"].includes(this.inTableType)) {
|
|
1454
|
+
// row.__isExpand__ = false;
|
|
1455
|
+
// row.__isSearchShow__ = false;
|
|
1456
|
+
// 第一级的需要显示出来
|
|
1457
|
+
if (row.level == 1) {
|
|
1458
|
+
row.__isRendered__ = true;
|
|
1459
|
+
row.__isShow__ = true;
|
|
1460
|
+
row.__isTmpShow__ = true;
|
|
1461
|
+
} else {
|
|
1462
|
+
// row.__isRendered__ = false;
|
|
1463
|
+
// row.__isShow__ = false;
|
|
1464
|
+
// row.__isTmpShow__ = false;
|
|
1465
|
+
}
|
|
1466
|
+
} else {
|
|
1467
|
+
row.__isRendered__ = true;
|
|
1468
|
+
row.__isShow__ = true;
|
|
1469
|
+
row.__isTmpShow__ = true;
|
|
1470
|
+
row.__isSearchShow__ = false;
|
|
1471
|
+
}
|
|
1472
|
+
}
|
|
1390
1473
|
}
|
|
1391
1474
|
}
|
|
1392
1475
|
};
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { resourceData } from "bri-datas";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
mixins: [],
|
|
5
|
+
components: {},
|
|
6
|
+
props: {},
|
|
7
|
+
data () {
|
|
8
|
+
return {
|
|
9
|
+
searchMode: "flat" // "flat", "tree"
|
|
10
|
+
};
|
|
11
|
+
},
|
|
12
|
+
computed: {
|
|
13
|
+
selfPropsObj () {
|
|
14
|
+
return {
|
|
15
|
+
_treeForm: [],
|
|
16
|
+
...this.commonPropsObj,
|
|
17
|
+
|
|
18
|
+
_maxLevel: this.commonPropsObj._maxLevel || 3 // 最大级数
|
|
19
|
+
};
|
|
20
|
+
},
|
|
21
|
+
maxLevel () {
|
|
22
|
+
return this.selfPropsObj._maxLevel;
|
|
23
|
+
},
|
|
24
|
+
|
|
25
|
+
selfColumns () {
|
|
26
|
+
return this.columns.map(column => {
|
|
27
|
+
// 层级表格类型,level字段的进行特殊处理(_treeForm加工成_data)
|
|
28
|
+
return column._key === "level"
|
|
29
|
+
? {
|
|
30
|
+
...column,
|
|
31
|
+
_data: this.selfPropsObj._treeForm.map((treeFormItem, treeFormIndex) => ({
|
|
32
|
+
name: treeFormItem._name,
|
|
33
|
+
_key: (treeFormIndex + 1),
|
|
34
|
+
color: Object.keys(resourceData.colorMap)[treeFormIndex + 1]
|
|
35
|
+
}))
|
|
36
|
+
}
|
|
37
|
+
: column;
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
created () { },
|
|
42
|
+
methods: {
|
|
43
|
+
// 本身的初始化
|
|
44
|
+
selfReset () {
|
|
45
|
+
this.searchMode = "flat";
|
|
46
|
+
},
|
|
47
|
+
|
|
48
|
+
// 节点操作 -添加一行
|
|
49
|
+
clickCreate (operationItem, row, rowIndex, col) {
|
|
50
|
+
const list = row
|
|
51
|
+
? this.getParentRow(row, this.data).children
|
|
52
|
+
: this.data;
|
|
53
|
+
const newRowIndex = row
|
|
54
|
+
? list.findIndex(rowItem => rowItem._id === row._id) + 1
|
|
55
|
+
: list.length;
|
|
56
|
+
const newRow = this.getNewRowData(row ? row.level : 1, list);
|
|
57
|
+
list.splice(newRowIndex, 0, newRow);
|
|
58
|
+
|
|
59
|
+
this.change("createRow", null, newRow, newRowIndex);
|
|
60
|
+
},
|
|
61
|
+
// 节点操作 -添加子行
|
|
62
|
+
clickCreateChild (operationItem, row, rowIndex, col) {
|
|
63
|
+
const list = row.children;
|
|
64
|
+
const newRowIndex = list.length;
|
|
65
|
+
const newRow = this.getNewRowData(row.level + 1, list);
|
|
66
|
+
list.splice(newRowIndex, 0, newRow);
|
|
67
|
+
|
|
68
|
+
// 展开子级
|
|
69
|
+
this.toggleExpand(row, true);
|
|
70
|
+
|
|
71
|
+
this.change("createChildRow", null, newRow, newRowIndex);
|
|
72
|
+
},
|
|
73
|
+
// 节点操作 -删除行
|
|
74
|
+
clickDelete (operationItem, row, rowIndex, col) {
|
|
75
|
+
// this.$Modal.confirm({
|
|
76
|
+
// title: "警告",
|
|
77
|
+
// content: "确定删除该行及其所有下级吗?",
|
|
78
|
+
// onOk: () => {
|
|
79
|
+
const parentRow = this.getParentRow(row, this.data);
|
|
80
|
+
const index = parentRow.children.findIndex(childRowItem => childRowItem._id === row._id);
|
|
81
|
+
parentRow.children.splice(index, 1);
|
|
82
|
+
|
|
83
|
+
this.change("deleteRow", null, row, rowIndex);
|
|
84
|
+
// }
|
|
85
|
+
// });
|
|
86
|
+
},
|
|
87
|
+
// 节点操作 -删除所有子行
|
|
88
|
+
clickDeleteChilds (operationItem, row, rowIndex, col) {
|
|
89
|
+
// this.$Modal.confirm({
|
|
90
|
+
// title: "警告",
|
|
91
|
+
// content: "确定删除该行及其所有下级吗?",
|
|
92
|
+
// onOk: () => {
|
|
93
|
+
row.children.splice(0);
|
|
94
|
+
|
|
95
|
+
this.change("deleteChildRows", null, row, rowIndex);
|
|
96
|
+
// }
|
|
97
|
+
// });
|
|
98
|
+
},
|
|
99
|
+
|
|
100
|
+
// 展开/隐藏节点
|
|
101
|
+
toggleExpand (row, bool = true) {
|
|
102
|
+
this.isExpandAction = true;
|
|
103
|
+
this.$set(row, "__isExpand__", bool);
|
|
104
|
+
|
|
105
|
+
this.toggleDescendantsShow(row, bool);
|
|
106
|
+
},
|
|
107
|
+
// 切换子孙后代的显示/隐藏
|
|
108
|
+
toggleDescendantsShow (row, bool) {
|
|
109
|
+
const loop = (row, isFirstSon) => {
|
|
110
|
+
if (row.children && row.children.length) {
|
|
111
|
+
row.children.forEach(subRow => {
|
|
112
|
+
if (isFirstSon) {
|
|
113
|
+
this.$set(subRow, "__isRendered__", true);
|
|
114
|
+
this.$set(subRow, "__isShow__", bool);
|
|
115
|
+
this.$set(subRow, "__isTmpShow__", bool);
|
|
116
|
+
} else {
|
|
117
|
+
if (bool) {
|
|
118
|
+
this.$set(subRow, "__isShow__", subRow.__isTmpShow__);
|
|
119
|
+
} else {
|
|
120
|
+
this.$set(subRow, "__isShow__", false);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
loop(subRow);
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
loop(row, true);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
};
|