bri-components 1.3.61 → 1.3.62
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 +1 -1
- package/src/components/controls/senior/cascaderTable.vue +21 -6
- package/src/components/controls/senior/flatTable.vue +69 -9
- package/src/components/form/searchMixin.js +1 -1
- package/src/components/list/DshFlatTable.vue +4 -4
- package/src/components/list/DshTreeTable.vue +5 -411
- package/src/components/list/mixins/DshFlatTableMixin.js +124 -0
- package/src/components/list/mixins/DshTreeTableMixin.js +410 -0
- package/src/components/list/mixins/tableBaseMixin.js +66 -7
- package/src/components/list/mixins/flatTableMixin.js +0 -151
package/package.json
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
|
|
16
16
|
<template v-else>
|
|
17
17
|
<!-- 配置端 设置默认值用-->
|
|
18
|
-
<dsh-btn-modal v-if="
|
|
18
|
+
<dsh-btn-modal v-if="controlKey === '_default'">
|
|
19
19
|
<template>
|
|
20
20
|
<dsh-tree-table
|
|
21
21
|
v-if="showMode === 'treeTable'"
|
|
@@ -105,6 +105,11 @@
|
|
|
105
105
|
_showMode: "default", // "default", "treeTable"
|
|
106
106
|
_subForm: [],
|
|
107
107
|
_treeForm: [],
|
|
108
|
+
_searchList: [], // 作为搜索的字段
|
|
109
|
+
_tableAdvSearch: {
|
|
110
|
+
logic: "and",
|
|
111
|
+
conditions: []
|
|
112
|
+
},
|
|
108
113
|
...this.propsObj
|
|
109
114
|
};
|
|
110
115
|
},
|
|
@@ -169,14 +174,24 @@
|
|
|
169
174
|
]
|
|
170
175
|
};
|
|
171
176
|
},
|
|
177
|
+
isSearching () {
|
|
178
|
+
return this.$isAdvSearching(this.finalTableAdvSearch);
|
|
179
|
+
},
|
|
180
|
+
|
|
172
181
|
showVal () {
|
|
173
182
|
return `${
|
|
174
183
|
this.curVal
|
|
175
|
-
? this.$getTreeFlatArr(this.curVal.tree, (row) =>
|
|
176
|
-
|
|
177
|
-
this
|
|
178
|
-
|
|
179
|
-
|
|
184
|
+
? this.$getTreeFlatArr(this.curVal.tree, (row) =>
|
|
185
|
+
(
|
|
186
|
+
this.showMode === "treeTable"
|
|
187
|
+
? true
|
|
188
|
+
: row.isLeaf === true
|
|
189
|
+
) && (
|
|
190
|
+
this.isSearching
|
|
191
|
+
? this.$isAdvRelyAccord(this.finalTableAdvSearch, row)
|
|
192
|
+
: true
|
|
193
|
+
)
|
|
194
|
+
).length
|
|
180
195
|
: 0
|
|
181
196
|
} 行`;
|
|
182
197
|
}
|
|
@@ -9,20 +9,20 @@
|
|
|
9
9
|
customIcon: 'bico-internaltable'
|
|
10
10
|
}]"></dsh-icons>
|
|
11
11
|
<span class="flatTable-unit-text">
|
|
12
|
-
{{
|
|
12
|
+
{{ showVal }}
|
|
13
13
|
</span>
|
|
14
14
|
</span>
|
|
15
15
|
|
|
16
16
|
<!-- 编辑、查看(查看页内) -->
|
|
17
17
|
<template v-else>
|
|
18
18
|
<!-- 配置端 设置默认值用-->
|
|
19
|
-
<dsh-btn-modal v-if="
|
|
19
|
+
<dsh-btn-modal v-if="controlKey === '_default'">
|
|
20
20
|
<dsh-flat-table
|
|
21
21
|
:canEdit="finalCanEdit"
|
|
22
22
|
:data="curVal.list"
|
|
23
23
|
:rowDefault="curVal.rowDefault"
|
|
24
24
|
:columns="subForm"
|
|
25
|
-
:propsObj="
|
|
25
|
+
:propsObj="defaultPropsObj"
|
|
26
26
|
:allFormList="allFormList"
|
|
27
27
|
:parentObj="value"
|
|
28
28
|
@change="change"
|
|
@@ -69,20 +69,80 @@
|
|
|
69
69
|
selfPropsObj () {
|
|
70
70
|
return {
|
|
71
71
|
_subForm: [],
|
|
72
|
+
_searchList: [], // 作为搜索的字段
|
|
73
|
+
_tableAdvSearch: {
|
|
74
|
+
logic: "and",
|
|
75
|
+
conditions: []
|
|
76
|
+
},
|
|
72
77
|
...this.propsObj
|
|
73
78
|
};
|
|
74
79
|
},
|
|
80
|
+
defaultPropsObj () {
|
|
81
|
+
return {
|
|
82
|
+
...this.selfPropsObj,
|
|
83
|
+
_tableAdvSearch: {
|
|
84
|
+
logic: "and",
|
|
85
|
+
conditions: []
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
},
|
|
75
89
|
subForm () {
|
|
76
90
|
return this.selfPropsObj._subForm;
|
|
77
91
|
},
|
|
78
92
|
|
|
79
|
-
|
|
80
|
-
//
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
93
|
+
searchList () {
|
|
94
|
+
return this.selfPropsObj._searchList || []; // 级联表切层级表时 值会undefined覆盖selfPropsObj默认的[]
|
|
95
|
+
},
|
|
96
|
+
searchListMap () {
|
|
97
|
+
return this.$arrToMap(this.searchList, "_key");
|
|
98
|
+
},
|
|
99
|
+
searchListFields () {
|
|
100
|
+
return this.searchList.map(searchItem => searchItem._key);
|
|
101
|
+
},
|
|
102
|
+
tableAdvSearch () {
|
|
103
|
+
return this.$transformAdvSearch(this.selfPropsObj._tableAdvSearch, this.allFormList, this.value);
|
|
104
|
+
},
|
|
105
|
+
dftAdvSearch () {
|
|
106
|
+
return {
|
|
107
|
+
logic: ["and", "or"].includes(this.tableAdvSearch.logic) ? this.tableAdvSearch.logic : "and",
|
|
108
|
+
conditions: this.tableAdvSearch.conditions.filter(conditionItem =>
|
|
109
|
+
this.searchListFields.includes(conditionItem.fieldKey)
|
|
110
|
+
)
|
|
85
111
|
};
|
|
112
|
+
},
|
|
113
|
+
// 配置的默认筛选值里 隐藏的看不到的筛选条件
|
|
114
|
+
hideAdvSearch () {
|
|
115
|
+
return {
|
|
116
|
+
logic: ["and", "or"].includes(this.tableAdvSearch.logic) ? this.tableAdvSearch.logic : "and",
|
|
117
|
+
conditions: this.tableAdvSearch.conditions.filter(conditionItem =>
|
|
118
|
+
!this.searchListFields.includes(conditionItem.fieldKey)
|
|
119
|
+
)
|
|
120
|
+
};
|
|
121
|
+
},
|
|
122
|
+
// 过滤行数据的 最终的筛选条件
|
|
123
|
+
finalTableAdvSearch () {
|
|
124
|
+
return {
|
|
125
|
+
logic: "and",
|
|
126
|
+
conditions: [
|
|
127
|
+
this.hideAdvSearch,
|
|
128
|
+
this.dftAdvSearch
|
|
129
|
+
]
|
|
130
|
+
};
|
|
131
|
+
},
|
|
132
|
+
isSearching () {
|
|
133
|
+
return this.$isAdvSearching(this.finalTableAdvSearch);
|
|
134
|
+
},
|
|
135
|
+
|
|
136
|
+
showVal () {
|
|
137
|
+
return `${
|
|
138
|
+
this.curVal
|
|
139
|
+
? this.curVal.list.filter((row) =>
|
|
140
|
+
this.isSearching
|
|
141
|
+
? this.$isAdvRelyAccord(this.finalTableAdvSearch, row)
|
|
142
|
+
: true
|
|
143
|
+
).length
|
|
144
|
+
: 0
|
|
145
|
+
} 行`;
|
|
86
146
|
}
|
|
87
147
|
},
|
|
88
148
|
created () {},
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
<bri-table
|
|
14
14
|
class="DshFlatTable-main"
|
|
15
15
|
:columns="showColumns"
|
|
16
|
-
:data="
|
|
16
|
+
:data="renderedListData"
|
|
17
17
|
:footer-data="footerData"
|
|
18
18
|
:propsObj="tablePropsObj"
|
|
19
19
|
@changeSelect="changeSelect"
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
<bri-table
|
|
45
45
|
class="DshFlatTable-main"
|
|
46
46
|
:columns="showColumns"
|
|
47
|
-
:data="
|
|
47
|
+
:data="renderedListData"
|
|
48
48
|
:footer-data="footerData"
|
|
49
49
|
:propsObj="tablePropsObj"
|
|
50
50
|
@changeSelect="changeSelect"
|
|
@@ -63,13 +63,13 @@
|
|
|
63
63
|
|
|
64
64
|
<script>
|
|
65
65
|
import tableBaseMixin from "./mixins/tableBaseMixin.js";
|
|
66
|
-
import
|
|
66
|
+
import DshFlatTableMixin from "./mixins/DshFlatTableMixin.js";
|
|
67
67
|
|
|
68
68
|
export default {
|
|
69
69
|
name: "DshFlatTable",
|
|
70
70
|
mixins: [
|
|
71
71
|
tableBaseMixin,
|
|
72
|
-
|
|
72
|
+
DshFlatTableMixin
|
|
73
73
|
],
|
|
74
74
|
components: {},
|
|
75
75
|
props: {},
|
|
@@ -63,428 +63,22 @@
|
|
|
63
63
|
|
|
64
64
|
<script>
|
|
65
65
|
import tableBaseMixin from "./mixins/tableBaseMixin.js";
|
|
66
|
-
import
|
|
66
|
+
import DshTreeTableMixin from "./mixins/DshTreeTableMixin.js";
|
|
67
67
|
|
|
68
68
|
export default {
|
|
69
69
|
name: "DshTreeTable",
|
|
70
70
|
mixins: [
|
|
71
71
|
tableBaseMixin,
|
|
72
|
-
|
|
72
|
+
DshTreeTableMixin
|
|
73
73
|
],
|
|
74
74
|
components: {},
|
|
75
75
|
props: {},
|
|
76
76
|
data () {
|
|
77
|
-
return {
|
|
78
|
-
deleteProperties: ["__treeIndex__", "__old__", "__isExpand__", "__isRendered__", "__isShow__", "__isTmpShow__", "__isSearchShow__"], // 除了__readonly__和__isQuote__不处理
|
|
79
|
-
isExpandAction: false,
|
|
80
|
-
|
|
81
|
-
searchMode: "flat" // "flat", "tree"
|
|
82
|
-
};
|
|
83
|
-
},
|
|
84
|
-
computed: {
|
|
85
|
-
selfPropsObj () {
|
|
86
|
-
return {
|
|
87
|
-
_maxLevel: 3, // 最大级数
|
|
88
|
-
...this.commonPropsObj
|
|
89
|
-
};
|
|
90
|
-
},
|
|
91
|
-
maxLevel () {
|
|
92
|
-
return this.selfPropsObj._maxLevel || 3;
|
|
93
|
-
},
|
|
94
|
-
|
|
95
|
-
allTreeData () {
|
|
96
|
-
console.log("allTreeData");
|
|
97
|
-
return this.getCalcuedTree(this.data, this.columns);
|
|
98
|
-
},
|
|
99
|
-
allListData () {
|
|
100
|
-
console.log("allListData");
|
|
101
|
-
return this.$getTreeFlatArr(this.allTreeData);
|
|
102
|
-
},
|
|
103
|
-
footerData () {
|
|
104
|
-
console.log("footerData");
|
|
105
|
-
return this.isSearching
|
|
106
|
-
? []
|
|
107
|
-
: this.useSummary && this.allListData.length
|
|
108
|
-
? [
|
|
109
|
-
this.filterColumns.reduce((obj, col) => {
|
|
110
|
-
return {
|
|
111
|
-
...obj,
|
|
112
|
-
[col._key]: col._type === "number" && ![undefined, null, "", "no"].includes(col._summaryType)
|
|
113
|
-
? this.$calNumList(
|
|
114
|
-
this.allListData
|
|
115
|
-
.filter(item => item.level === 1)
|
|
116
|
-
.map(item => item[col._key]),
|
|
117
|
-
col._summaryType,
|
|
118
|
-
{ ...col, _defaultDigit: 2 }
|
|
119
|
-
)
|
|
120
|
-
: (obj[col._key] || "--")
|
|
121
|
-
};
|
|
122
|
-
}, {
|
|
123
|
-
_id: this.$ObjectID().str,
|
|
124
|
-
__index__: "汇总",
|
|
125
|
-
__isExpand__: "-",
|
|
126
|
-
__operation__: "——"
|
|
127
|
-
})
|
|
128
|
-
]
|
|
129
|
-
: [];
|
|
130
|
-
},
|
|
131
|
-
|
|
132
|
-
tablePropsObj () {
|
|
133
|
-
return {
|
|
134
|
-
maxHeight: this.contentHeight,
|
|
135
|
-
// rowStyleOption: {
|
|
136
|
-
// hoverHighlight: true,
|
|
137
|
-
// clickHighlight: true,
|
|
138
|
-
// stripe: true // 斑马纹
|
|
139
|
-
// },
|
|
140
|
-
cellStyleOption: {
|
|
141
|
-
bodyCellClass: ({ row, column, rowIndex }) => {
|
|
142
|
-
return "bri-table-td" +
|
|
143
|
-
`${
|
|
144
|
-
this.getRowCanEdit(row)
|
|
145
|
-
? " bri-table-td-edit"
|
|
146
|
-
: ""
|
|
147
|
-
}` +
|
|
148
|
-
`${
|
|
149
|
-
this.isSearching
|
|
150
|
-
? !row.__isSearchShow__
|
|
151
|
-
? " bri-table-td-hide"
|
|
152
|
-
: ""
|
|
153
|
-
: !row.__isShow__
|
|
154
|
-
? " bri-table-td-hide"
|
|
155
|
-
: this.isExpandAction
|
|
156
|
-
? " bri-table-td-visible"
|
|
157
|
-
: ""
|
|
158
|
-
}` +
|
|
159
|
-
`${
|
|
160
|
-
["__isExpand__"].includes(column._key)
|
|
161
|
-
? " bri-table-td-expand"
|
|
162
|
-
: ["__index__"].includes(column._key)
|
|
163
|
-
? " bri-table-td-index"
|
|
164
|
-
: ""
|
|
165
|
-
}`;
|
|
166
|
-
}
|
|
167
|
-
},
|
|
168
|
-
// 通过实例方法 hideColumnsByKeys(keys)将列隐藏,通过实例方法 showColumnsByKeys(keys)将隐藏的列显示
|
|
169
|
-
columnHiddenOption: {
|
|
170
|
-
defaultHiddenColumnKeys: []
|
|
171
|
-
}
|
|
172
|
-
};
|
|
173
|
-
},
|
|
174
|
-
showColumns () {
|
|
175
|
-
return [
|
|
176
|
-
...(this.useSelection === true ? [this.selectionColumn] : []),
|
|
177
|
-
this.expandColumn,
|
|
178
|
-
...(this.useIndex === true ? [this.indexColumn] : []),
|
|
179
|
-
...this.$transformToColumns(this.contentColumns),
|
|
180
|
-
...(this.isSearching
|
|
181
|
-
? []
|
|
182
|
-
: this.$getOperationList(["canDelete"]).length
|
|
183
|
-
? [this.operationColumn]
|
|
184
|
-
: [])
|
|
185
|
-
];
|
|
186
|
-
},
|
|
187
|
-
expandColumn () {
|
|
188
|
-
return {
|
|
189
|
-
// title: "开/合",
|
|
190
|
-
_key: "__isExpand__",
|
|
191
|
-
key: "__isExpand__",
|
|
192
|
-
field: "__isExpand__",
|
|
193
|
-
width: 48,
|
|
194
|
-
align: "center",
|
|
195
|
-
fixed: "left",
|
|
196
|
-
renderBodyCell: ({ row, column, rowIndex }, h) => {
|
|
197
|
-
return this.isSearching && this.searchMode === "flat"
|
|
198
|
-
? h("span", "")
|
|
199
|
-
: row.children && row.children.length
|
|
200
|
-
? h("Icon", {
|
|
201
|
-
style: {
|
|
202
|
-
width: "16px",
|
|
203
|
-
height: "16px",
|
|
204
|
-
cursor: "pointer",
|
|
205
|
-
transform: row.__isExpand__ ? "rotate(90deg)" : "rotate(0deg)",
|
|
206
|
-
transition: "transform 0.3s"
|
|
207
|
-
},
|
|
208
|
-
props: {
|
|
209
|
-
type: "ios-arrow-forward",
|
|
210
|
-
size: "18"
|
|
211
|
-
},
|
|
212
|
-
on: {
|
|
213
|
-
click: () => {
|
|
214
|
-
this.toggleExpand(row, !row.__isExpand__);
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
})
|
|
218
|
-
: h("span", "");
|
|
219
|
-
}
|
|
220
|
-
};
|
|
221
|
-
},
|
|
222
|
-
indexColumn () {
|
|
223
|
-
return {
|
|
224
|
-
title: "序号",
|
|
225
|
-
_key: "__index__",
|
|
226
|
-
key: "__index__",
|
|
227
|
-
field: "__index__",
|
|
228
|
-
width: 28 + 16 + (this.maxLevel - 1) * 38,
|
|
229
|
-
align: "left",
|
|
230
|
-
fixed: "left",
|
|
231
|
-
renderBodyCell: ({ row, column, rowIndex }, h) => {
|
|
232
|
-
return [
|
|
233
|
-
h("div", {
|
|
234
|
-
style: {
|
|
235
|
-
paddingLeft: `${(row.level - 1) * 18}px`,
|
|
236
|
-
fontWeight: "500"
|
|
237
|
-
}
|
|
238
|
-
}, row.__treeIndex__),
|
|
239
|
-
|
|
240
|
-
// 添加符
|
|
241
|
-
this.operationMap.canCreate && row.level < this.maxLevel && !this.isSearching
|
|
242
|
-
? h("div", {
|
|
243
|
-
style: {
|
|
244
|
-
position: "absolute",
|
|
245
|
-
bottom: "0px",
|
|
246
|
-
right: "0px",
|
|
247
|
-
display: "inline-block",
|
|
248
|
-
width: "16px",
|
|
249
|
-
height: " 16px",
|
|
250
|
-
border: "1px solid #dcdee2",
|
|
251
|
-
backgroundColor: "#ffffff",
|
|
252
|
-
lineHeight: "12px",
|
|
253
|
-
cursor: "pointer",
|
|
254
|
-
verticalAlign: "middle",
|
|
255
|
-
transition: "color .2s ease-in-out,border-color .2s ease-in-out"
|
|
256
|
-
}
|
|
257
|
-
}, [
|
|
258
|
-
h("Icon", {
|
|
259
|
-
style: {
|
|
260
|
-
fontWeight: "500"
|
|
261
|
-
},
|
|
262
|
-
props: {
|
|
263
|
-
type: "ios-add", // "md-add-circle"
|
|
264
|
-
size: "14"
|
|
265
|
-
},
|
|
266
|
-
on: {
|
|
267
|
-
click: () => {
|
|
268
|
-
this.clickCreate(this.operationMap.canCreate, row, rowIndex);
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
})
|
|
272
|
-
])
|
|
273
|
-
: h("span", "")
|
|
274
|
-
];
|
|
275
|
-
}
|
|
276
|
-
};
|
|
277
|
-
}
|
|
77
|
+
return {};
|
|
278
78
|
},
|
|
79
|
+
computed: {},
|
|
279
80
|
created () {},
|
|
280
|
-
methods: {
|
|
281
|
-
// 本身的初始化
|
|
282
|
-
selfReset () {
|
|
283
|
-
this.isExpandAction = false;
|
|
284
|
-
this.searchMode = "flat";
|
|
285
|
-
this.dftAdvSearch = {
|
|
286
|
-
logic: "and",
|
|
287
|
-
conditions: []
|
|
288
|
-
};
|
|
289
|
-
},
|
|
290
|
-
|
|
291
|
-
// 筛选回调
|
|
292
|
-
searchCb (conditions) {
|
|
293
|
-
this.isExpandAction = false;
|
|
294
|
-
this.dftAdvSearch.conditions = conditions;
|
|
295
|
-
},
|
|
296
|
-
// 展开/隐藏节点
|
|
297
|
-
toggleExpand (row, bool = true) {
|
|
298
|
-
this.isExpandAction = true;
|
|
299
|
-
// row.__isExpand__ = bool;
|
|
300
|
-
this.$set(row, "__isExpand__", bool);
|
|
301
|
-
|
|
302
|
-
this.toggleDescendantsShow(row, bool);
|
|
303
|
-
},
|
|
304
|
-
|
|
305
|
-
// 点击 -添加一行
|
|
306
|
-
clickCreate (operationItem, row, rowIndex) {
|
|
307
|
-
const newRow = {
|
|
308
|
-
...this.$deepCopy(this.selfRowDefault),
|
|
309
|
-
_id: this.$ObjectID().str,
|
|
310
|
-
isLeaf: true,
|
|
311
|
-
children: [],
|
|
312
|
-
// __old__: false,
|
|
313
|
-
__isExpand__: false,
|
|
314
|
-
__isRendered__: true,
|
|
315
|
-
__isShow__: true,
|
|
316
|
-
__isTmpShow__: false,
|
|
317
|
-
__isSearchShow__: false
|
|
318
|
-
};
|
|
319
|
-
|
|
320
|
-
// !row代表最上级节点
|
|
321
|
-
if (!row) {
|
|
322
|
-
this.data.push({
|
|
323
|
-
...newRow,
|
|
324
|
-
level: 1
|
|
325
|
-
});
|
|
326
|
-
} else {
|
|
327
|
-
row.children.push({
|
|
328
|
-
...newRow,
|
|
329
|
-
level: row.level + 1
|
|
330
|
-
});
|
|
331
|
-
|
|
332
|
-
this.toggleExpand(row, true);
|
|
333
|
-
}
|
|
334
|
-
},
|
|
335
|
-
// 点击 -删除行
|
|
336
|
-
clickDelete (operationItem, row, rowIndex) {
|
|
337
|
-
this.$Modal.confirm({
|
|
338
|
-
title: "警告",
|
|
339
|
-
content: "确定删除吗?",
|
|
340
|
-
onOk: () => {
|
|
341
|
-
const parentNode = this.getParentNode(row, this.data);
|
|
342
|
-
const index = parentNode.children.findIndex(childNode => childNode._id === row._id);
|
|
343
|
-
parentNode.children.splice(index, 1);
|
|
344
|
-
}
|
|
345
|
-
});
|
|
346
|
-
},
|
|
347
|
-
|
|
348
|
-
/* ------ 工具方法 ------- */
|
|
349
|
-
// 加工树形数据
|
|
350
|
-
getCalcuedTree (treeData = [], columns = []) {
|
|
351
|
-
const loop = (list = [], parentRow) =>
|
|
352
|
-
list.forEach((row) => {
|
|
353
|
-
// 递归到叶子节点前 从上往下要处理的
|
|
354
|
-
columns.reduce((newRow, col) => {
|
|
355
|
-
const isNumberSummary = col._type === "number" && ![undefined, null, "", "no"].includes(col._summaryType);
|
|
356
|
-
const isDateSummary = col._type === "date" && ![undefined, null, ""].includes(col._writeSort);
|
|
357
|
-
|
|
358
|
-
if (isNumberSummary || isDateSummary) {
|
|
359
|
-
const val = isNumberSummary
|
|
360
|
-
? newRow[col._key]
|
|
361
|
-
: ["downToUp"].includes(col._writeSort)
|
|
362
|
-
? newRow[col._key]
|
|
363
|
-
: !parentRow || parentRow[col._key]
|
|
364
|
-
? newRow[col._key]
|
|
365
|
-
: undefined;
|
|
366
|
-
|
|
367
|
-
this.$set(newRow, col._key, val);
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
return newRow;
|
|
371
|
-
}, row);
|
|
372
|
-
|
|
373
|
-
if (row.children && row.children.length) {
|
|
374
|
-
row.isLeaf = false;
|
|
375
|
-
loop(row.children, row);
|
|
376
|
-
|
|
377
|
-
// 递归到叶子节点后 从下往上要处理的
|
|
378
|
-
columns.reduce((newRow, col) => {
|
|
379
|
-
const isNumberSummary = col._type === "number" && ![undefined, null, "", "no"].includes(col._summaryType);
|
|
380
|
-
const isDateSummary = col._type === "date" && ![undefined, null, ""].includes(col._writeSort);
|
|
381
|
-
|
|
382
|
-
if (isNumberSummary || isDateSummary) {
|
|
383
|
-
const val = isNumberSummary
|
|
384
|
-
? this.$calNumList(
|
|
385
|
-
newRow.children.map(subRow => subRow[col._key]),
|
|
386
|
-
col._summaryType,
|
|
387
|
-
{ ...col, _defaultDigit: 2 },
|
|
388
|
-
false
|
|
389
|
-
)
|
|
390
|
-
: ["downToUp"].includes(col._writeSort)
|
|
391
|
-
? this.$calDateList(
|
|
392
|
-
newRow.children.map(subRow => subRow[col._key]),
|
|
393
|
-
col._compareOperator,
|
|
394
|
-
col._dateType
|
|
395
|
-
)
|
|
396
|
-
: newRow[col._key];
|
|
397
|
-
|
|
398
|
-
this.$set(newRow, col._key, val);
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
return newRow;
|
|
402
|
-
}, row);
|
|
403
|
-
} else {
|
|
404
|
-
row.isLeaf = true;
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
// 初次进来把前端存的状态值全部清除(除了__readonly__)
|
|
408
|
-
if (this.initFlag) {
|
|
409
|
-
this.deleteProperties.forEach(property => {
|
|
410
|
-
delete row[property];
|
|
411
|
-
});
|
|
412
|
-
|
|
413
|
-
row.__old__ = true; // 老的数据都打上标记 尽管不一定会用
|
|
414
|
-
// row.__isExpand__ = false;
|
|
415
|
-
// row.__isSearchShow__ = false;
|
|
416
|
-
// 第一级的需要显示出来
|
|
417
|
-
if (row.level == 1) {
|
|
418
|
-
row.__isRendered__ = true;
|
|
419
|
-
row.__isShow__ = true;
|
|
420
|
-
row.__isTmpShow__ = true;
|
|
421
|
-
} else {
|
|
422
|
-
// row.__isRendered__ = false;
|
|
423
|
-
// row.__isShow__ = false;
|
|
424
|
-
// row.__isTmpShow__ = false;
|
|
425
|
-
}
|
|
426
|
-
}
|
|
427
|
-
});
|
|
428
|
-
loop(treeData);
|
|
429
|
-
|
|
430
|
-
this.initFlag = false;
|
|
431
|
-
return treeData;
|
|
432
|
-
},
|
|
433
|
-
// 获取父节点
|
|
434
|
-
getParentNode (curRow, tree = []) {
|
|
435
|
-
if (curRow.level === 1) {
|
|
436
|
-
return {
|
|
437
|
-
children: tree
|
|
438
|
-
};
|
|
439
|
-
} else {
|
|
440
|
-
let parentNode;
|
|
441
|
-
|
|
442
|
-
const loop = (list = []) => {
|
|
443
|
-
return list.some(row => {
|
|
444
|
-
if (row.level === curRow.level - 1) {
|
|
445
|
-
const isExist = row.children.some(childNode => childNode._id === curRow._id);
|
|
446
|
-
parentNode = row;
|
|
447
|
-
return isExist;
|
|
448
|
-
} else {
|
|
449
|
-
return loop(row.children);
|
|
450
|
-
}
|
|
451
|
-
});
|
|
452
|
-
};
|
|
453
|
-
loop(tree);
|
|
454
|
-
|
|
455
|
-
return parentNode;
|
|
456
|
-
}
|
|
457
|
-
},
|
|
458
|
-
// 切换子孙后代的显示/隐藏
|
|
459
|
-
toggleDescendantsShow (row, bool) {
|
|
460
|
-
const loop = (row, isFirstSon) => {
|
|
461
|
-
if (row.children && row.children.length) {
|
|
462
|
-
row.children.forEach(subRow => {
|
|
463
|
-
if (isFirstSon) {
|
|
464
|
-
// subRow.__isRendered__ = true;
|
|
465
|
-
// subRow.__isShow__ = bool;
|
|
466
|
-
// subRow.__isTmpShow__ = bool;
|
|
467
|
-
this.$set(subRow, "__isRendered__", true);
|
|
468
|
-
this.$set(subRow, "__isShow__", bool);
|
|
469
|
-
this.$set(subRow, "__isTmpShow__", bool);
|
|
470
|
-
} else {
|
|
471
|
-
if (bool) {
|
|
472
|
-
// subRow.__isShow__ = subRow.__isTmpShow__;
|
|
473
|
-
this.$set(subRow, "__isShow__", subRow.__isTmpShow__);
|
|
474
|
-
} else {
|
|
475
|
-
// subRow.__isShow__ = false;
|
|
476
|
-
this.$set(subRow, "__isShow__", false);
|
|
477
|
-
}
|
|
478
|
-
}
|
|
479
|
-
|
|
480
|
-
loop(subRow);
|
|
481
|
-
});
|
|
482
|
-
}
|
|
483
|
-
};
|
|
484
|
-
|
|
485
|
-
loop(row, true);
|
|
486
|
-
}
|
|
487
|
-
}
|
|
81
|
+
methods: {}
|
|
488
82
|
};
|
|
489
83
|
</script>
|
|
490
84
|
|