bri-components 1.3.25 → 1.3.27
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/mixins/controlMixin.js +1 -1
- package/src/components/controls/senior/cascaderTable.vue +14 -12
- package/src/components/list/DshCascaderTable.vue +42 -96
- package/src/components/list/DshFlatTable.vue +5 -8
- package/src/components/list/DshTreeTable.vue +184 -29
- package/src/components/list/mixins/{tableMixin.js → flatTableMixin.js} +81 -27
- package/src/components/list/mixins/{DshFlatTableMixin.js → tableBaseMixin.js} +27 -81
- package/src/styles/reset-iview-other.less +0 -4
package/package.json
CHANGED
|
@@ -72,7 +72,7 @@ export default {
|
|
|
72
72
|
},
|
|
73
73
|
set (val) {
|
|
74
74
|
// 修复文本框clear后值为undefined,后端无法更新保存数据bug
|
|
75
|
-
if (["select"].includes(this.controlType) &&
|
|
75
|
+
if (["select"].includes(this.controlType) && val === undefined) {
|
|
76
76
|
val = "";
|
|
77
77
|
}
|
|
78
78
|
|
|
@@ -32,9 +32,12 @@
|
|
|
32
32
|
v-else
|
|
33
33
|
:canEdit="finalCanEdit"
|
|
34
34
|
:data="curVal"
|
|
35
|
-
:treeColumns="
|
|
35
|
+
:treeColumns="treeForm"
|
|
36
36
|
:subColumns="subForm"
|
|
37
|
-
:propsObj="
|
|
37
|
+
:propsObj="{
|
|
38
|
+
...propsObj,
|
|
39
|
+
_useCol: false
|
|
40
|
+
}"
|
|
38
41
|
:parentFormList="allFormList"
|
|
39
42
|
:parentObj="value"
|
|
40
43
|
@change="change"
|
|
@@ -68,10 +71,9 @@
|
|
|
68
71
|
<dsh-cascader-table
|
|
69
72
|
v-else
|
|
70
73
|
ref="table"
|
|
71
|
-
useCol
|
|
72
74
|
:canEdit="finalCanEdit"
|
|
73
75
|
:data="curVal"
|
|
74
|
-
:treeColumns="
|
|
76
|
+
:treeColumns="treeForm"
|
|
75
77
|
:subColumns="subForm"
|
|
76
78
|
:propsObj="propsObj"
|
|
77
79
|
:parentFormList="allFormList"
|
|
@@ -100,10 +102,9 @@
|
|
|
100
102
|
></dsh-tree-table>
|
|
101
103
|
<dsh-cascader-table
|
|
102
104
|
v-else
|
|
103
|
-
useCol
|
|
104
105
|
:canEdit="finalCanEdit"
|
|
105
106
|
:data="curVal"
|
|
106
|
-
:treeColumns="
|
|
107
|
+
:treeColumns="treeForm"
|
|
107
108
|
:subColumns="subForm"
|
|
108
109
|
:propsObj="propsObj"
|
|
109
110
|
:parentFormList="allFormList"
|
|
@@ -175,17 +176,18 @@
|
|
|
175
176
|
subForm () {
|
|
176
177
|
return this.propsObj._subForm;
|
|
177
178
|
},
|
|
178
|
-
treeForm () {
|
|
179
|
-
return this.propsObj._treeForm;
|
|
180
|
-
},
|
|
181
179
|
// 用户态的每条数据的表头配置,都是存的自己的,不用通用配置_treeForm的
|
|
182
|
-
|
|
180
|
+
treeForm () {
|
|
183
181
|
return this.curVal && this.curVal._treeForm
|
|
184
182
|
? this.curVal._treeForm
|
|
185
|
-
: this.
|
|
183
|
+
: this.propsObj._treeForm;
|
|
184
|
+
},
|
|
185
|
+
isExport () {
|
|
186
|
+
return this.propsObj._isExport;
|
|
186
187
|
},
|
|
188
|
+
|
|
187
189
|
operationBtns () {
|
|
188
|
-
return this.
|
|
190
|
+
return this.isExport
|
|
189
191
|
? ["canExport", "canEnlarge"]
|
|
190
192
|
: ["canEnlarge"];
|
|
191
193
|
},
|
|
@@ -197,23 +197,15 @@
|
|
|
197
197
|
</template>
|
|
198
198
|
|
|
199
199
|
<script>
|
|
200
|
-
import
|
|
200
|
+
import tableBaseMixin from "./mixins/tableBaseMixin.js";
|
|
201
201
|
|
|
202
202
|
export default {
|
|
203
203
|
name: "DshCascaderTable",
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
204
|
+
mixins: [
|
|
205
|
+
tableBaseMixin
|
|
206
|
+
],
|
|
207
|
+
components: {},
|
|
207
208
|
props: {
|
|
208
|
-
canEdit: {
|
|
209
|
-
type: Boolean,
|
|
210
|
-
default: true
|
|
211
|
-
},
|
|
212
|
-
useCol: {
|
|
213
|
-
type: Boolean,
|
|
214
|
-
default: false
|
|
215
|
-
},
|
|
216
|
-
|
|
217
209
|
data: {
|
|
218
210
|
type: Object,
|
|
219
211
|
default () {
|
|
@@ -236,32 +228,10 @@
|
|
|
236
228
|
default () {
|
|
237
229
|
return [];
|
|
238
230
|
}
|
|
239
|
-
},
|
|
240
|
-
propsObj: {
|
|
241
|
-
type: Object,
|
|
242
|
-
default () {
|
|
243
|
-
return {};
|
|
244
|
-
}
|
|
245
|
-
},
|
|
246
|
-
|
|
247
|
-
parentFormList: {
|
|
248
|
-
type: Array,
|
|
249
|
-
default () {
|
|
250
|
-
return [];
|
|
251
|
-
}
|
|
252
|
-
},
|
|
253
|
-
parentObj: {
|
|
254
|
-
type: Object,
|
|
255
|
-
default () {
|
|
256
|
-
return {};
|
|
257
|
-
}
|
|
258
231
|
}
|
|
259
232
|
},
|
|
260
233
|
data () {
|
|
261
234
|
return {
|
|
262
|
-
showRuleMessage: false, // 显示校验文字
|
|
263
|
-
ruleRecordMap: {},
|
|
264
|
-
|
|
265
235
|
widthMap: this.$getModFieldPropertyMap("width"),
|
|
266
236
|
boxWidth: 0,
|
|
267
237
|
getColOperationNames (col) {
|
|
@@ -363,46 +333,28 @@
|
|
|
363
333
|
computed: {
|
|
364
334
|
selfPropsObj () {
|
|
365
335
|
return {
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
_showRequired: true, // 表头显示校验符号*
|
|
369
|
-
_showDescription: true, // 表头显示提示
|
|
370
|
-
_headHeightAuto: false, // 表头高度自适应
|
|
371
|
-
_heightAuto: false, // 单元格高度自适应
|
|
372
|
-
_disabledBtns: false, // 禁用增删按钮
|
|
373
|
-
...this.propsObj,
|
|
336
|
+
_useCol: true,
|
|
337
|
+
...this.commonPropsObj,
|
|
374
338
|
|
|
375
339
|
_contentHeight: this.propsObj._contentHeight || 400 // 表格最大高度
|
|
376
340
|
};
|
|
377
341
|
},
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
// },
|
|
381
|
-
contentHeight () {
|
|
382
|
-
return this.selfPropsObj._contentHeight;
|
|
383
|
-
},
|
|
384
|
-
showRequired () {
|
|
385
|
-
return this.selfPropsObj._showRequired;
|
|
386
|
-
},
|
|
387
|
-
showDescription () {
|
|
388
|
-
return this.selfPropsObj._showDescription;
|
|
389
|
-
},
|
|
390
|
-
headHeightAuto () {
|
|
391
|
-
return this.selfPropsObj._headHeightAuto;
|
|
392
|
-
},
|
|
393
|
-
heightAuto () {
|
|
394
|
-
return this.selfPropsObj._heightAuto;
|
|
395
|
-
},
|
|
396
|
-
disabledBtns () {
|
|
397
|
-
return this.selfPropsObj._disabledBtns;
|
|
342
|
+
useCol () {
|
|
343
|
+
return this.selfPropsObj._useCol;
|
|
398
344
|
},
|
|
399
345
|
|
|
400
346
|
columns () {
|
|
401
347
|
return this.transformColumns(this.treeColumns);
|
|
402
348
|
},
|
|
349
|
+
filterColumns () {
|
|
350
|
+
return this.columns.filter(col => col.colType === "data");
|
|
351
|
+
},
|
|
403
352
|
treeData () {
|
|
404
353
|
return this.transforBriTreeData();
|
|
405
354
|
},
|
|
355
|
+
listData () {
|
|
356
|
+
return this.rows;
|
|
357
|
+
},
|
|
406
358
|
rows () {
|
|
407
359
|
return this.transformRows();
|
|
408
360
|
},
|
|
@@ -456,16 +408,34 @@
|
|
|
456
408
|
};
|
|
457
409
|
loop(this.data.tree);
|
|
458
410
|
},
|
|
459
|
-
//
|
|
460
|
-
|
|
461
|
-
this.
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
411
|
+
// 整行校验结果
|
|
412
|
+
getRowRuleResult (row, rowIndex) {
|
|
413
|
+
this.filterColumns.every(col => this.getColRuleResult(col, row[col.nodeKey], rowIndex, true).bool);
|
|
414
|
+
},
|
|
415
|
+
// 单元格校验结果
|
|
416
|
+
getColRuleResult (col, row, rowIndex) {
|
|
417
|
+
if ((this.ruleRecordMap[`${row._id}dsh${col._key}`] || {}).showRuleMessage || this.showRuleMessage) {
|
|
418
|
+
return this.$getFieldRuleResult({
|
|
419
|
+
...col,
|
|
420
|
+
_regStr: col._regStr && [";", ";"].some(symbol => col._regStr.includes(symbol))
|
|
421
|
+
? col._regStr
|
|
422
|
+
.replace(/\n/g, "")
|
|
423
|
+
.split(";")
|
|
424
|
+
.reduce((arr, item) => arr.concat(item.split(";")), [])[rowIndex]
|
|
425
|
+
: col._regStr,
|
|
426
|
+
_regMessage: col._regMessage && [";", ";"].some(symbol => col._regMessage.includes(symbol))
|
|
427
|
+
? col._regMessage
|
|
428
|
+
.replace(/\n/g, "")
|
|
429
|
+
.split(";")
|
|
430
|
+
.reduce((arr, item) => arr.concat(item.split(";")), [])[rowIndex]
|
|
431
|
+
: col._regMessage
|
|
432
|
+
}, row);
|
|
433
|
+
} else {
|
|
434
|
+
return {
|
|
435
|
+
bool: true
|
|
436
|
+
};
|
|
437
|
+
}
|
|
467
438
|
},
|
|
468
|
-
|
|
469
439
|
// 点击表头
|
|
470
440
|
clickTh (operationItem, col) {
|
|
471
441
|
this.$emit("clickTh", col);
|
|
@@ -586,30 +556,6 @@
|
|
|
586
556
|
controlBlur (operationItem, col, row, params) {
|
|
587
557
|
this.$set(this.ruleRecordMap, `${row._id}dsh${col._key}`, { showRuleMessage: true });
|
|
588
558
|
},
|
|
589
|
-
// 是否显示 单元格校验提示文字
|
|
590
|
-
getColRuleResult (col, row, rowIndex, showRuleMessage = this.showRuleMessage) {
|
|
591
|
-
if ((this.ruleRecordMap[`${row._id}dsh${col._key}`] || {}).showRuleMessage || showRuleMessage) {
|
|
592
|
-
return this.$getFieldRuleResult({
|
|
593
|
-
...col,
|
|
594
|
-
_regStr: col._regStr && [";", ";"].some(symbol => col._regStr.includes(symbol))
|
|
595
|
-
? col._regStr
|
|
596
|
-
.replace(/\n/g, "")
|
|
597
|
-
.split(";")
|
|
598
|
-
.reduce((arr, item) => arr.concat(item.split(";")), [])[rowIndex]
|
|
599
|
-
: col._regStr,
|
|
600
|
-
_regMessage: col._regMessage && [";", ";"].some(symbol => col._regMessage.includes(symbol))
|
|
601
|
-
? col._regMessage
|
|
602
|
-
.replace(/\n/g, "")
|
|
603
|
-
.split(";")
|
|
604
|
-
.reduce((arr, item) => arr.concat(item.split(";")), [])[rowIndex]
|
|
605
|
-
: col._regMessage
|
|
606
|
-
}, row);
|
|
607
|
-
} else {
|
|
608
|
-
return {
|
|
609
|
-
bool: true
|
|
610
|
-
};
|
|
611
|
-
}
|
|
612
|
-
},
|
|
613
559
|
|
|
614
560
|
/* ---- 工具方法 ---- */
|
|
615
561
|
// 合并表头
|
|
@@ -20,19 +20,16 @@
|
|
|
20
20
|
</template>
|
|
21
21
|
|
|
22
22
|
<script>
|
|
23
|
-
import
|
|
24
|
-
import
|
|
25
|
-
import DshListUnit from "../unit/DshListUnit.vue";
|
|
23
|
+
import tableBaseMixin from "./mixins/tableBaseMixin.js";
|
|
24
|
+
import flatTableMixin from "./mixins/flatTableMixin.js";
|
|
26
25
|
|
|
27
26
|
export default {
|
|
28
27
|
name: "DshFlatTable",
|
|
29
28
|
mixins: [
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
tableBaseMixin,
|
|
30
|
+
flatTableMixin
|
|
32
31
|
],
|
|
33
|
-
components: {
|
|
34
|
-
DshListUnit
|
|
35
|
-
},
|
|
32
|
+
components: {},
|
|
36
33
|
props: {},
|
|
37
34
|
data () {
|
|
38
35
|
return {};
|
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="DshTreeTable">
|
|
3
|
+
<!-- 搜索条件 -->
|
|
4
|
+
<template v-if="searchFormList.length">
|
|
5
|
+
<dsh-default-search
|
|
6
|
+
:formList="searchFormList"
|
|
7
|
+
:initValue="[]"
|
|
8
|
+
:labelWidth="searchLabelWidth"
|
|
9
|
+
@change="searchCb"
|
|
10
|
+
></dsh-default-search>
|
|
11
|
+
</template>
|
|
12
|
+
|
|
13
|
+
<!-- 表格 -->
|
|
3
14
|
<bri-table
|
|
4
15
|
class="DshTreeTable-main"
|
|
5
16
|
:columns="showColumns"
|
|
@@ -13,30 +24,68 @@
|
|
|
13
24
|
</template>
|
|
14
25
|
|
|
15
26
|
<script>
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
import DshListUnit from "../unit/DshListUnit.vue";
|
|
27
|
+
import tableBaseMixin from "./mixins/tableBaseMixin.js";
|
|
28
|
+
import flatTableMixin from "./mixins/flatTableMixin.js";
|
|
19
29
|
|
|
20
30
|
export default {
|
|
21
31
|
name: "DshTreeTable",
|
|
22
32
|
mixins: [
|
|
23
|
-
|
|
24
|
-
|
|
33
|
+
tableBaseMixin,
|
|
34
|
+
flatTableMixin
|
|
25
35
|
],
|
|
26
|
-
components: {
|
|
27
|
-
DshListUnit
|
|
28
|
-
},
|
|
36
|
+
components: {},
|
|
29
37
|
props: {},
|
|
30
38
|
data () {
|
|
31
|
-
return {
|
|
39
|
+
return {
|
|
40
|
+
advSearchObj: {
|
|
41
|
+
logic: "and",
|
|
42
|
+
conditions: []
|
|
43
|
+
}
|
|
44
|
+
};
|
|
32
45
|
},
|
|
33
46
|
computed: {
|
|
47
|
+
isSearching () {
|
|
48
|
+
return this.searchFormList.length && this.advSearchObj.conditions.some(conditionItem => conditionItem.fieldValue.length);
|
|
49
|
+
},
|
|
34
50
|
listData () {
|
|
35
|
-
|
|
51
|
+
console.log("listData");
|
|
52
|
+
const treeData = this.getCalcuTree(this.data, this.filterColumns);
|
|
53
|
+
return this.$getTreeFlatArr(treeData, node =>
|
|
54
|
+
(this.searchFormList.length ? this.$isAdvRelyAccord(this.advSearchObj, node) : true) &&
|
|
55
|
+
(node.level === 1 || node.__isShow__)
|
|
56
|
+
);
|
|
57
|
+
},
|
|
58
|
+
footerData () {
|
|
59
|
+
console.log("footerData");
|
|
60
|
+
return this.useSummary && this.listData.length
|
|
61
|
+
? [
|
|
62
|
+
this.filterColumns.reduce((obj, col) => {
|
|
63
|
+
return {
|
|
64
|
+
...obj,
|
|
65
|
+
[col._key]: col._type === "number" && ![undefined, null, "", "no"].includes(col._summaryType)
|
|
66
|
+
? this.$calNumList(
|
|
67
|
+
this.listData
|
|
68
|
+
.filter(item => item.level === 1)
|
|
69
|
+
.map(item => item[col._key]),
|
|
70
|
+
col._summaryType,
|
|
71
|
+
{ ...col, _defaultDigit: 2 }
|
|
72
|
+
)
|
|
73
|
+
: (obj[col._key] || "--")
|
|
74
|
+
};
|
|
75
|
+
}, {
|
|
76
|
+
_id: this.$ObjectID().str,
|
|
77
|
+
__index__: "汇总",
|
|
78
|
+
__isExpand__: "-",
|
|
79
|
+
__operation__: "——"
|
|
80
|
+
})
|
|
81
|
+
]
|
|
82
|
+
: [];
|
|
36
83
|
},
|
|
37
84
|
|
|
38
85
|
selfPropsObj () {
|
|
39
86
|
return {
|
|
87
|
+
_searchFields: [], // 作为搜索的字段
|
|
88
|
+
_searchLabelWidth: 100, // 搜索的label宽度
|
|
40
89
|
...this.commonPropsObj,
|
|
41
90
|
|
|
42
91
|
_maxLevel: this.commonPropsObj._maxLevel || 3
|
|
@@ -45,6 +94,21 @@
|
|
|
45
94
|
maxLevel () {
|
|
46
95
|
return this.selfPropsObj._maxLevel;
|
|
47
96
|
},
|
|
97
|
+
searchLabelWidth () {
|
|
98
|
+
return this.selfPropsObj._searchLabelWidth;
|
|
99
|
+
},
|
|
100
|
+
searchFormList () {
|
|
101
|
+
return this.selfPropsObj._searchFields
|
|
102
|
+
.map(fieldKey => this.columns.find(column => column._key === fieldKey))
|
|
103
|
+
.filter(column => !!column)
|
|
104
|
+
.map(column => {
|
|
105
|
+
return {
|
|
106
|
+
...column,
|
|
107
|
+
_span: 6
|
|
108
|
+
};
|
|
109
|
+
});
|
|
110
|
+
},
|
|
111
|
+
|
|
48
112
|
tablePropsObj () {
|
|
49
113
|
return {
|
|
50
114
|
maxHeight: this.contentHeight,
|
|
@@ -76,6 +140,9 @@
|
|
|
76
140
|
}
|
|
77
141
|
};
|
|
78
142
|
},
|
|
143
|
+
filterColumns () {
|
|
144
|
+
return this.columns;
|
|
145
|
+
},
|
|
79
146
|
showColumns () {
|
|
80
147
|
return [
|
|
81
148
|
...(this.useSelection === true ? [this.selectionColumn] : []),
|
|
@@ -137,7 +204,7 @@
|
|
|
137
204
|
}, row.__treeIndex__),
|
|
138
205
|
|
|
139
206
|
// 添加符
|
|
140
|
-
row.level < this.maxLevel
|
|
207
|
+
row.level < this.maxLevel && !this.isSearching
|
|
141
208
|
? h("div", {
|
|
142
209
|
style: {
|
|
143
210
|
position: "absolute",
|
|
@@ -164,21 +231,7 @@
|
|
|
164
231
|
},
|
|
165
232
|
on: {
|
|
166
233
|
click: () => {
|
|
167
|
-
|
|
168
|
-
const rowDefault = this.$deepCopy(this.rowDefault);
|
|
169
|
-
this.columns.forEach(column => {
|
|
170
|
-
// 用$set也可以
|
|
171
|
-
rowDefault[column._key] = rowDefault[column._key];
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
row.children.push({
|
|
175
|
-
_id: this.$ObjectID().str,
|
|
176
|
-
level: row.level + 1,
|
|
177
|
-
children: [],
|
|
178
|
-
...rowDefault
|
|
179
|
-
});
|
|
180
|
-
|
|
181
|
-
this.toggleExpand(row, true);
|
|
234
|
+
this.clickCreate(this.operationMap.canCreate, row, rowIndex);
|
|
182
235
|
}
|
|
183
236
|
}
|
|
184
237
|
})
|
|
@@ -191,13 +244,115 @@
|
|
|
191
244
|
},
|
|
192
245
|
created () {},
|
|
193
246
|
methods: {
|
|
247
|
+
// 默认筛选回调
|
|
248
|
+
searchCb (conditions) {
|
|
249
|
+
this.advSearchObj = {
|
|
250
|
+
...this.advSearchObj,
|
|
251
|
+
conditions: conditions
|
|
252
|
+
};
|
|
253
|
+
},
|
|
194
254
|
toggleExpand (row, bool = true) {
|
|
255
|
+
this.$set(row, "__isRendered__", true);
|
|
256
|
+
|
|
195
257
|
this.$set(row, "__isExpand__", bool);
|
|
258
|
+
row.children.forEach(subRow => {
|
|
259
|
+
this.$set(subRow, "__isShow__", bool);
|
|
260
|
+
});
|
|
261
|
+
},
|
|
262
|
+
// 点击 -添加一行
|
|
263
|
+
clickCreate (operationItem, row, rowIndex) {
|
|
264
|
+
row.children.push({
|
|
265
|
+
_id: this.$ObjectID().str,
|
|
266
|
+
...this.$deepCopy(this.rowDefault),
|
|
267
|
+
level: row.level + 1,
|
|
268
|
+
isLeaf: true,
|
|
269
|
+
children: []
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
this.toggleExpand(row, true);
|
|
273
|
+
},
|
|
274
|
+
// 点击 -删除行
|
|
275
|
+
clickDelete (operationItem, row, rowIndex) {
|
|
276
|
+
const parentNode = this.getParentNode(this.data, row);
|
|
277
|
+
const index = parentNode.children.findIndex(childNode => childNode._id === row._id);
|
|
278
|
+
parentNode.children.splice(index, 1);
|
|
279
|
+
console.log(index);
|
|
280
|
+
console.log(parentNode);
|
|
281
|
+
// this.$Modal.confirm({
|
|
282
|
+
// title: "警告",
|
|
283
|
+
// content: "确定删除吗?",
|
|
284
|
+
// onOk: () => {
|
|
196
285
|
|
|
197
|
-
//
|
|
198
|
-
// row.children.forEach(subRow => {
|
|
199
|
-
// this.$set(subRow, "__isShow__", bool);
|
|
286
|
+
// }
|
|
200
287
|
// });
|
|
288
|
+
},
|
|
289
|
+
|
|
290
|
+
getCalcuTree (tree = [], columns) {
|
|
291
|
+
const loop = (list = []) =>
|
|
292
|
+
list.reduce((newList, node) => {
|
|
293
|
+
if (node.children && node.children.length) {
|
|
294
|
+
node.isLeaf = false;
|
|
295
|
+
|
|
296
|
+
node.children = loop(node.children);
|
|
297
|
+
columns.reduce((newNode, col) => {
|
|
298
|
+
newNode[col._key] = col._type === "number" && ![undefined, null, "", "no"].includes(col._summaryType)
|
|
299
|
+
? this.$calNumList(
|
|
300
|
+
node.children.map(subNode => subNode[col._key]),
|
|
301
|
+
col._summaryType,
|
|
302
|
+
{ ...col, _defaultDigit: 2 },
|
|
303
|
+
false
|
|
304
|
+
)
|
|
305
|
+
: newNode[col._key];
|
|
306
|
+
// this.$set(
|
|
307
|
+
// newNode,
|
|
308
|
+
// col._key,
|
|
309
|
+
// col._type === "number" && ![undefined, null, "", "no"].includes(col._summaryType)
|
|
310
|
+
// ? this.$calNumList(
|
|
311
|
+
// node.children.map(subNode => subNode[col._key]),
|
|
312
|
+
// col._summaryType,
|
|
313
|
+
// { ...col, _defaultDigit: 2 },
|
|
314
|
+
// false
|
|
315
|
+
// )
|
|
316
|
+
// : newNode[col._key]
|
|
317
|
+
// );
|
|
318
|
+
|
|
319
|
+
return newNode;
|
|
320
|
+
}, node);
|
|
321
|
+
} else {
|
|
322
|
+
node.isLeaf = true;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
return [
|
|
326
|
+
...newList,
|
|
327
|
+
node
|
|
328
|
+
];
|
|
329
|
+
}, []);
|
|
330
|
+
|
|
331
|
+
return loop(tree);
|
|
332
|
+
},
|
|
333
|
+
getParentNode (tree = [], curNode) {
|
|
334
|
+
if (curNode.level === 1) {
|
|
335
|
+
return {
|
|
336
|
+
children: tree
|
|
337
|
+
};
|
|
338
|
+
} else {
|
|
339
|
+
let parentNode;
|
|
340
|
+
|
|
341
|
+
const loop = (list = []) => {
|
|
342
|
+
return list.some(node => {
|
|
343
|
+
if (node.level === curNode.level - 1) {
|
|
344
|
+
const isExist = node.children.some(childNode => childNode._id === curNode._id);
|
|
345
|
+
parentNode = node;
|
|
346
|
+
return isExist;
|
|
347
|
+
} else {
|
|
348
|
+
return loop(node.children);
|
|
349
|
+
}
|
|
350
|
+
});
|
|
351
|
+
};
|
|
352
|
+
|
|
353
|
+
loop(tree);
|
|
354
|
+
return parentNode;
|
|
355
|
+
}
|
|
201
356
|
}
|
|
202
357
|
}
|
|
203
358
|
};
|
|
@@ -1,31 +1,70 @@
|
|
|
1
1
|
export default {
|
|
2
2
|
mixins: [],
|
|
3
3
|
components: {},
|
|
4
|
-
props: {
|
|
4
|
+
props: {
|
|
5
|
+
columns: {
|
|
6
|
+
type: Array,
|
|
7
|
+
default () {
|
|
8
|
+
return [];
|
|
9
|
+
}
|
|
10
|
+
},
|
|
11
|
+
data: {
|
|
12
|
+
type: Array,
|
|
13
|
+
default () {
|
|
14
|
+
return [];
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
oldData: {
|
|
18
|
+
type: Array,
|
|
19
|
+
default () {
|
|
20
|
+
return [];
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
model: {
|
|
25
|
+
prop: "data",
|
|
26
|
+
event: "change"
|
|
27
|
+
},
|
|
5
28
|
data () {
|
|
6
29
|
return {};
|
|
7
30
|
},
|
|
8
31
|
computed: {
|
|
32
|
+
listData () {
|
|
33
|
+
this.data.forEach(item => {
|
|
34
|
+
!item._id && this.$set(item, "_id", this.$ObjectID().str);
|
|
35
|
+
});
|
|
36
|
+
return this.data;
|
|
37
|
+
},
|
|
38
|
+
oldListData () {
|
|
39
|
+
this.oldData.forEach(item => {
|
|
40
|
+
!item._id && this.$set(item, "_id", this.$ObjectID().str);
|
|
41
|
+
});
|
|
42
|
+
return this.oldData;
|
|
43
|
+
},
|
|
44
|
+
useCampare () {
|
|
45
|
+
return !!this.oldListData.length;
|
|
46
|
+
},
|
|
9
47
|
footerData () {
|
|
10
|
-
|
|
11
|
-
|
|
48
|
+
return this.useSummary && this.listData.length
|
|
49
|
+
? [
|
|
12
50
|
this.filterColumns.reduce((obj, col) => {
|
|
13
51
|
return {
|
|
14
52
|
...obj,
|
|
15
|
-
[col._key]: col._type === "number"
|
|
16
|
-
? this.$calNumList(
|
|
53
|
+
[col._key]: col._type === "number" && ![undefined, null, "", "no"].includes(col._summaryType)
|
|
54
|
+
? this.$calNumList(
|
|
55
|
+
this.listData.map(item => item[col._key]),
|
|
56
|
+
col._summaryType,
|
|
57
|
+
{ ...col, _defaultDigit: 2 }
|
|
58
|
+
)
|
|
17
59
|
: (obj[col._key] || "--")
|
|
18
60
|
};
|
|
19
61
|
}, {
|
|
20
62
|
_id: this.$ObjectID().str,
|
|
21
63
|
__index__: "汇总",
|
|
22
|
-
__isExpand__: "-",
|
|
23
64
|
__operation__: "——"
|
|
24
65
|
})
|
|
25
|
-
]
|
|
26
|
-
|
|
27
|
-
return [];
|
|
28
|
-
}
|
|
66
|
+
]
|
|
67
|
+
: [];
|
|
29
68
|
},
|
|
30
69
|
|
|
31
70
|
tablePropsObj () {
|
|
@@ -47,19 +86,10 @@ export default {
|
|
|
47
86
|
...this.commonPropsObj
|
|
48
87
|
};
|
|
49
88
|
},
|
|
50
|
-
showRequired () {
|
|
51
|
-
return this.selfPropsObj._showRequired;
|
|
52
|
-
},
|
|
53
|
-
showDescription () {
|
|
54
|
-
return this.selfPropsObj._showDescription;
|
|
55
|
-
},
|
|
56
|
-
headHeightAuto () {
|
|
57
|
-
return this.selfPropsObj._headHeightAuto;
|
|
58
|
-
},
|
|
59
|
-
heightAuto () {
|
|
60
|
-
return this.selfPropsObj._heightAuto;
|
|
61
|
-
},
|
|
62
89
|
|
|
90
|
+
filterColumns () {
|
|
91
|
+
return this.columns.filter(col => this.$isAdvRelyShow(col, this.listData, this.parentObj, true));
|
|
92
|
+
},
|
|
63
93
|
showColumns () {
|
|
64
94
|
return [
|
|
65
95
|
...(this.useSelection === true ? [this.selectionColumn] : []),
|
|
@@ -218,17 +248,21 @@ export default {
|
|
|
218
248
|
disabled: false,
|
|
219
249
|
event: "clickDelete"
|
|
220
250
|
},
|
|
221
|
-
// expand: {
|
|
222
|
-
// name: "展开",
|
|
223
|
-
// type: "expand",
|
|
224
|
-
// event: "clickExpand"
|
|
225
|
-
// },
|
|
226
251
|
changeVal: {
|
|
227
252
|
name: "改变输入框值",
|
|
228
253
|
type: "changeVal",
|
|
229
254
|
event: "changeVal"
|
|
230
255
|
}
|
|
231
256
|
};
|
|
257
|
+
},
|
|
258
|
+
operationMap () {
|
|
259
|
+
return this.canEdit
|
|
260
|
+
? this.$categoryMapToMap(
|
|
261
|
+
this.allOperationMap,
|
|
262
|
+
null,
|
|
263
|
+
this.disabledBtns ? ["canCreate", "canDelete"] : []
|
|
264
|
+
)
|
|
265
|
+
: {};
|
|
232
266
|
}
|
|
233
267
|
},
|
|
234
268
|
created () { },
|
|
@@ -246,6 +280,18 @@ export default {
|
|
|
246
280
|
|
|
247
281
|
this.change("createRow", null, newRow, newRowIndex);
|
|
248
282
|
},
|
|
283
|
+
// 点击 -删除行
|
|
284
|
+
clickDelete (operationItem, row, rowIndex, list) {
|
|
285
|
+
this.$Modal.confirm({
|
|
286
|
+
title: "警告",
|
|
287
|
+
content: "确定删除吗?",
|
|
288
|
+
onOk: () => {
|
|
289
|
+
list.splice(rowIndex, 1);
|
|
290
|
+
|
|
291
|
+
this.change("deleteRow", null, row, rowIndex);
|
|
292
|
+
}
|
|
293
|
+
});
|
|
294
|
+
},
|
|
249
295
|
changeSelect (list) {
|
|
250
296
|
this.$emit("changeSelect", list);
|
|
251
297
|
},
|
|
@@ -258,6 +304,9 @@ export default {
|
|
|
258
304
|
controlBlur (operationItem, col, row, params) {
|
|
259
305
|
this.$set(this.ruleRecordMap, `${row._id}dsh${col._key}`, { showRuleMessage: true });
|
|
260
306
|
},
|
|
307
|
+
change (...params) {
|
|
308
|
+
this.$emit("change", { list: this.listData, rowDefault: this.rowDefault }, ...params);
|
|
309
|
+
},
|
|
261
310
|
|
|
262
311
|
resetCol (col, row) {
|
|
263
312
|
let resetMap = {
|
|
@@ -274,6 +323,11 @@ export default {
|
|
|
274
323
|
// isShare: this.isShare,
|
|
275
324
|
_heightAuto: this.heightAuto
|
|
276
325
|
};
|
|
326
|
+
},
|
|
327
|
+
isShowCompare (col, row, oldRow = {}) {
|
|
328
|
+
return this.useCampare && ["number"].includes(col._type) &&
|
|
329
|
+
!(this.$isEmptyData(row[col._key]) && this.$isEmptyData(oldRow[col._key])) &&
|
|
330
|
+
row[col._key] !== oldRow[col._key];
|
|
277
331
|
}
|
|
278
332
|
}
|
|
279
333
|
};
|
|
@@ -1,29 +1,15 @@
|
|
|
1
|
+
import DshListUnit from "../../unit/DshListUnit.vue";
|
|
2
|
+
|
|
1
3
|
export default {
|
|
2
4
|
mixins: [],
|
|
3
|
-
components: {
|
|
5
|
+
components: {
|
|
6
|
+
DshListUnit
|
|
7
|
+
},
|
|
4
8
|
props: {
|
|
5
9
|
canEdit: {
|
|
6
10
|
type: Boolean,
|
|
7
11
|
default: true
|
|
8
12
|
},
|
|
9
|
-
columns: {
|
|
10
|
-
type: Array,
|
|
11
|
-
default () {
|
|
12
|
-
return [];
|
|
13
|
-
}
|
|
14
|
-
},
|
|
15
|
-
data: {
|
|
16
|
-
type: Array,
|
|
17
|
-
default () {
|
|
18
|
-
return [];
|
|
19
|
-
}
|
|
20
|
-
},
|
|
21
|
-
oldData: {
|
|
22
|
-
type: Array,
|
|
23
|
-
default () {
|
|
24
|
-
return [];
|
|
25
|
-
}
|
|
26
|
-
},
|
|
27
13
|
rowDefault: {
|
|
28
14
|
type: Object,
|
|
29
15
|
default () {
|
|
@@ -50,10 +36,6 @@ export default {
|
|
|
50
36
|
}
|
|
51
37
|
}
|
|
52
38
|
},
|
|
53
|
-
model: {
|
|
54
|
-
prop: "data",
|
|
55
|
-
event: "change"
|
|
56
|
-
},
|
|
57
39
|
data () {
|
|
58
40
|
return {
|
|
59
41
|
showRuleMessage: false, // 显示校验文字
|
|
@@ -61,22 +43,6 @@ export default {
|
|
|
61
43
|
};
|
|
62
44
|
},
|
|
63
45
|
computed: {
|
|
64
|
-
listData () {
|
|
65
|
-
this.data.forEach(item => {
|
|
66
|
-
!item._id && this.$set(item, "_id", this.$ObjectID().str);
|
|
67
|
-
});
|
|
68
|
-
return this.data;
|
|
69
|
-
},
|
|
70
|
-
oldListData () {
|
|
71
|
-
this.oldData.forEach(item => {
|
|
72
|
-
!item._id && this.$set(item, "_id", this.$ObjectID().str);
|
|
73
|
-
});
|
|
74
|
-
return this.oldData;
|
|
75
|
-
},
|
|
76
|
-
useCampare () {
|
|
77
|
-
return !!this.oldListData.length;
|
|
78
|
-
},
|
|
79
|
-
|
|
80
46
|
commonPropsObj () {
|
|
81
47
|
return {
|
|
82
48
|
// isShare: false, // 是否是分享页在用
|
|
@@ -102,6 +68,18 @@ export default {
|
|
|
102
68
|
contentHeight () {
|
|
103
69
|
return this.selfPropsObj._contentHeight;
|
|
104
70
|
},
|
|
71
|
+
showRequired () {
|
|
72
|
+
return this.selfPropsObj._showRequired;
|
|
73
|
+
},
|
|
74
|
+
showDescription () {
|
|
75
|
+
return this.selfPropsObj._showDescription;
|
|
76
|
+
},
|
|
77
|
+
headHeightAuto () {
|
|
78
|
+
return this.selfPropsObj._headHeightAuto;
|
|
79
|
+
},
|
|
80
|
+
heightAuto () {
|
|
81
|
+
return this.selfPropsObj._heightAuto;
|
|
82
|
+
},
|
|
105
83
|
useSelection () {
|
|
106
84
|
return this.selfPropsObj._useSelection;
|
|
107
85
|
},
|
|
@@ -121,22 +99,8 @@ export default {
|
|
|
121
99
|
return this.selfPropsObj._disabledOldDataRow;
|
|
122
100
|
},
|
|
123
101
|
|
|
124
|
-
filterColumns () {
|
|
125
|
-
console.log(this.listData);
|
|
126
|
-
return this.columns.filter(col => this.$isAdvRelyShow(col, this.listData, this.parentObj, true));
|
|
127
|
-
},
|
|
128
102
|
selfRowDefault () {
|
|
129
103
|
return this.$filterObj(this.filterColumns, this.rowDefault);
|
|
130
|
-
},
|
|
131
|
-
|
|
132
|
-
operationMap () {
|
|
133
|
-
return this.canEdit
|
|
134
|
-
? this.$categoryMapToMap(
|
|
135
|
-
this.allOperationMap,
|
|
136
|
-
null,
|
|
137
|
-
this.disabledBtns ? ["canCreate", "canDelete"] : []
|
|
138
|
-
)
|
|
139
|
-
: {};
|
|
140
104
|
}
|
|
141
105
|
},
|
|
142
106
|
created () { },
|
|
@@ -145,14 +109,14 @@ export default {
|
|
|
145
109
|
validate () {
|
|
146
110
|
this.showRuleMessage = true;
|
|
147
111
|
|
|
148
|
-
return this.listData.every(row => this.getRowRuleResult(row));
|
|
112
|
+
return this.listData.every((row, rowIndex) => this.getRowRuleResult(row, rowIndex));
|
|
149
113
|
},
|
|
150
114
|
// 整行校验结果
|
|
151
|
-
getRowRuleResult (row) {
|
|
152
|
-
return this.filterColumns.every(column => this.getColRuleResult(column, row).bool);
|
|
115
|
+
getRowRuleResult (row, rowIndex) {
|
|
116
|
+
return this.filterColumns.every(column => this.getColRuleResult(column, row, rowIndex).bool);
|
|
153
117
|
},
|
|
154
118
|
// 单元格校验结果
|
|
155
|
-
getColRuleResult (col, row) {
|
|
119
|
+
getColRuleResult (col, row, rowIndex) {
|
|
156
120
|
col = this.$transformFieldProperty(col, row, this.parentObj);
|
|
157
121
|
if ((this.ruleRecordMap[`${row._id}dsh${col._key}`] || {}).showRuleMessage || this.showRuleMessage) {
|
|
158
122
|
return this.$getFieldRuleResult(col, row);
|
|
@@ -163,39 +127,21 @@ export default {
|
|
|
163
127
|
}
|
|
164
128
|
},
|
|
165
129
|
|
|
166
|
-
// 点击 -删除行
|
|
167
|
-
clickDelete (operationItem, row, rowIndex, list) {
|
|
168
|
-
this.$Modal.confirm({
|
|
169
|
-
title: "警告",
|
|
170
|
-
content: "确定删除吗?",
|
|
171
|
-
onOk: () => {
|
|
172
|
-
list.splice(rowIndex, 1);
|
|
173
|
-
|
|
174
|
-
this.change("deleteRow", null, row, rowIndex);
|
|
175
|
-
}
|
|
176
|
-
});
|
|
177
|
-
},
|
|
178
|
-
change (...params) {
|
|
179
|
-
this.$emit("change", { list: this.listData, rowDefault: this.rowDefault }, ...params);
|
|
180
|
-
},
|
|
181
|
-
|
|
182
130
|
/* --------------- 工具方法 ------------- */
|
|
183
131
|
getRowCanEdit (row) {
|
|
184
|
-
return this.canEdit && // 是否是编辑状态
|
|
185
|
-
|
|
132
|
+
return this.canEdit && ( // 是否是编辑状态
|
|
133
|
+
this.disabledOldDataRow ? !!row.__isCreate__ : true); // 是否让老数据行置灰
|
|
186
134
|
},
|
|
187
135
|
getColCanEdit (col, row) {
|
|
188
|
-
return col.dependRowCanEdit ? row.canEdit !== false : true
|
|
136
|
+
return (col.dependRowCanEdit ? row.canEdit !== false : true) && // 在老数据行里某些列不可编辑
|
|
137
|
+
col._enterType !== "calculate" && // 计算的不可编辑
|
|
138
|
+
col._readonly !== true && // 不能为只读
|
|
139
|
+
(["number"].includes(col._type) && ![undefined, null, "", "no"].includes(col._summaryType) ? row.isLeaf !== false : true); // 级联表格 -“需要计的数字列 且 不是叶子行的”不可编辑(必须用isLeaf !== false判断,因为牵扯内部表格也在用)
|
|
189
140
|
},
|
|
190
141
|
getUnitCanEdit (col, row) {
|
|
191
142
|
return this.getRowCanEdit(row) &&
|
|
192
143
|
this.getColCanEdit(col, row) &&
|
|
193
144
|
this.$isAdvRelyShow(col, row, this.parentObj, true);
|
|
194
|
-
},
|
|
195
|
-
isShowCompare (col, row, oldRow = {}) {
|
|
196
|
-
return this.useCampare && ["number"].includes(col._type) &&
|
|
197
|
-
!(this.$isEmptyData(row[col._key]) && this.$isEmptyData(oldRow[col._key])) &&
|
|
198
|
-
row[col._key] !== oldRow[col._key];
|
|
199
145
|
}
|
|
200
146
|
}
|
|
201
147
|
};
|