bri-components 1.5.21 → 1.6.0
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/README.md +83 -83
- package/lib/styles/bundle.css +12 -12
- package/lib/styles/font/fontello.svg +31 -31
- package/package.json +125 -125
- package/src/components/Error/Error403.vue +42 -42
- package/src/components/Error/Error404.vue +40 -40
- package/src/components/Error/Error500.vue +51 -51
- package/src/components/Error/error.less +162 -162
- package/src/components/Error/errorBack.vue +40 -40
- package/src/components/controls/DshControlInput.vue +195 -195
- package/src/components/controls/base/BriUpload/BriUpload.vue +434 -434
- package/src/components/controls/base/BriUpload/BriUploadImage.vue +377 -377
- package/src/components/controls/base/BriUpload/uploadList.vue +727 -727
- package/src/components/controls/base/BriUpload/uploadMixin.js +446 -446
- package/src/components/controls/base/DshCascader/DshCascader.vue +215 -215
- package/src/components/controls/base/DshCascader/components/cascaderModal.vue +366 -366
- package/src/components/controls/base/DshCascader/components/cascaderPicker.vue +416 -416
- package/src/components/controls/base/DshCascader/components/cascaderSimple.vue +141 -141
- package/src/components/controls/base/DshCascader/components/cascaderTree.vue +151 -151
- package/src/components/controls/base/DshCoordinates.vue +585 -577
- package/src/components/controls/base/DshDate/DshDate.vue +191 -191
- package/src/components/controls/base/DshDate/DshDaterange.vue +186 -186
- package/src/components/controls/base/DshDivider.vue +201 -201
- package/src/components/controls/base/DshEditor.vue +274 -274
- package/src/components/controls/base/DshInput/BriInputs.vue +166 -166
- package/src/components/controls/base/DshInput/DshInput.vue +260 -260
- package/src/components/controls/base/DshNumber/BriInputNumber/BriInputNumber.vue +435 -435
- package/src/components/controls/base/DshNumber/BriInputNumber/mixins/emitter.js +34 -34
- package/src/components/controls/base/DshNumber/BriInputNumber/mixins/form.js +14 -14
- package/src/components/controls/base/DshNumber/BriInputNumber/utils/assist.js +322 -322
- package/src/components/controls/base/DshNumber/DshNumber.vue +143 -143
- package/src/components/controls/base/DshNumber/DshNumberange.vue +109 -109
- package/src/components/controls/base/DshSelect/DshCheckbox.vue +168 -168
- package/src/components/controls/base/DshSelect/DshSelect.vue +180 -180
- package/src/components/controls/base/DshSelect/DshSelectAll.vue +269 -269
- package/src/components/controls/base/DshSwitch/DshSwitch.vue +115 -115
- package/src/components/controls/control.less +324 -324
- package/src/components/controls/controlMap.js +117 -117
- package/src/components/controls/extra/DshColor.vue +81 -81
- package/src/components/controls/extra/DshThemeColor.vue +100 -100
- package/src/components/controls/extra/DshThemeIcon.vue +122 -122
- package/src/components/controls/mixins/cascaderMixin.js +325 -325
- package/src/components/controls/mixins/cascaderPickerMixin.js +227 -227
- package/src/components/controls/mixins/cascaderTableMixin.js +130 -130
- package/src/components/controls/mixins/controlMixin.js +393 -393
- package/src/components/controls/mixins/dateMixin.js +149 -149
- package/src/components/controls/mixins/flatTableMixin.js +111 -111
- package/src/components/controls/mixins/numberMixin.js +112 -112
- package/src/components/controls/mixins/selectMixin.js +233 -233
- package/src/components/controls/mixins/switchMixin.js +87 -87
- package/src/components/controls/mixins/userAndDepartMixin.js +260 -260
- package/src/components/controls/senior/DshLabels.vue +333 -333
- package/src/components/controls/senior/DshPackage.vue +57 -57
- package/src/components/controls/senior/cascaderTable.vue +213 -213
- package/src/components/controls/senior/correlation.vue +135 -135
- package/src/components/controls/senior/flatTable.vue +138 -138
- package/src/components/controls/senior/selectDepartments.vue +399 -399
- package/src/components/controls/senior/selectUsers/departMenu.vue +293 -293
- package/src/components/controls/senior/selectUsers/selectUsers.vue +712 -712
- package/src/components/controls/special/DshBack.vue +42 -42
- package/src/components/controls/special/DshUndeveloped.vue +41 -41
- package/src/components/form/DshAdvSearch.vue +510 -510
- package/src/components/form/DshDefaultSearch.vue +260 -260
- package/src/components/form/DshForm.vue +494 -494
- package/src/components/form/searchMixin.js +376 -376
- package/src/components/list/BriCard.vue +95 -95
- package/src/components/list/BriTable.vue +205 -205
- package/src/components/list/BriTree.vue +529 -529
- package/src/components/list/BriTreeItem.vue +163 -163
- package/src/components/list/DshBox/DshBox.vue +219 -219
- package/src/components/list/DshBox/DshCard.vue +446 -446
- package/src/components/list/DshBox/DshCrossTable.vue +827 -827
- package/src/components/list/DshBox/DshList.vue +404 -404
- package/src/components/list/DshBox/DshPanel.vue +669 -669
- package/src/components/list/DshBox/DshSingleData.vue +119 -119
- package/src/components/list/DshBox/DshTable.vue +239 -239
- package/src/components/list/DshCascaderTable.vue +115 -115
- package/src/components/list/DshFlatTable.vue +337 -337
- package/src/components/list/DshPage.vue +194 -194
- package/src/components/list/DshTreeTable.vue +113 -113
- package/src/components/list/common/importModal.vue +243 -243
- package/src/components/list/common/quoteListModal.vue +206 -206
- package/src/components/list/mixins/DshCascaderTableMixin.js +278 -278
- package/src/components/list/mixins/DshFlatTableMixin.js +509 -509
- package/src/components/list/mixins/DshTreeTableMixin.js +286 -286
- package/src/components/list/mixins/tableBaseMixin.js +1653 -1653
- package/src/components/list/mixins/treeTableBaseMixin.js +145 -145
- package/src/components/other/BriAvatar.vue +166 -166
- package/src/components/other/BriCode.vue +125 -125
- package/src/components/other/BriCollapseTree.vue +207 -207
- package/src/components/other/BriGantt.vue +1087 -1087
- package/src/components/other/BriIframe.vue +116 -116
- package/src/components/other/BriLoading.vue +171 -171
- package/src/components/other/BriSvg.vue +27 -27
- package/src/components/other/DshColorPanel.vue +128 -128
- package/src/components/other/DshMenuNav.vue +188 -188
- package/src/components/small/BriButton.vue +71 -71
- package/src/components/small/BriDrawer.vue +169 -169
- package/src/components/small/BriTooltip.vue +87 -87
- package/src/components/small/DshBtnModal.vue +68 -68
- package/src/components/small/DshButtons.vue +324 -324
- package/src/components/small/DshDropdown.vue +225 -225
- package/src/components/small/DshIcons.vue +59 -59
- package/src/components/small/DshListRender.js +21 -21
- package/src/components/small/DshModal.vue +160 -160
- package/src/components/small/DshSteps.vue +141 -141
- package/src/components/small/DshTabs.vue +598 -598
- package/src/components/small/DshTabsSet.vue +309 -309
- package/src/components/small/DshTags.vue +251 -251
- package/src/components/small/DshTitle.vue +50 -50
- package/src/components/small/render.js +20 -20
- package/src/components/unit/DshFormUnit.vue +398 -398
- package/src/components/unit/DshListUnit.vue +115 -115
- package/src/components/unit/unitMixin.js +86 -86
- package/src/data/index.js +4 -4
- package/src/index.js +285 -285
- package/src/styles/bundle.css +12 -12
- package/src/styles/components/BriButton.less +307 -307
- package/src/styles/components/BriTable.less +344 -344
- package/src/styles/components/DshModal.less +257 -257
- package/src/styles/components/index.less +3 -3
- package/src/styles/global/animate.less +11 -11
- package/src/styles/global/base.less +45 -45
- package/src/styles/global/box.less +186 -186
- package/src/styles/global/control.less +122 -122
- package/src/styles/global/flex.less +282 -282
- package/src/styles/global/global.less +8 -8
- package/src/styles/global/text.less +59 -59
- package/src/styles/global/variables.less +85 -85
- package/src/styles/iconfont/iconfont.css +254 -254
- package/src/styles/iconfont/iconfont.json +422 -422
- package/src/styles/iconfont/iconfont.svg +137 -137
- package/src/styles/index.less +26 -26
- package/src/styles/reset-easytable.less +21 -21
- package/src/styles/reset-iview-controls.less +145 -145
- package/src/styles/reset-iview-other.less +49 -49
- package/src/styles/reset-iview-variables.less +43 -43
- package/src/styles/reset.less +45 -45
- package/src/utils/index.js +3 -5
- package/lib/0.bri-components.min.js +0 -1
- package/lib/1.bri-components.min.js +0 -1
- package/lib/10.bri-components.min.js +0 -1
- package/lib/11.bri-components.min.js +0 -1
- package/lib/2.bri-components.min.js +0 -1
- package/lib/3.bri-components.min.js +0 -1
- package/lib/4.bri-components.min.js +0 -1
- package/lib/5.bri-components.min.js +0 -1
- package/lib/6.bri-components.min.js +0 -1
- package/lib/7.bri-components.min.js +0 -1
- package/lib/8.bri-components.min.js +0 -1
- package/lib/9.bri-components.min.js +0 -1
- package/lib/bri-components.min.js +0 -18
- package/src/utils/table.js +0 -175
|
@@ -1,278 +1,278 @@
|
|
|
1
|
-
export default {
|
|
2
|
-
mixins: [],
|
|
3
|
-
components: {},
|
|
4
|
-
props: {},
|
|
5
|
-
data () {
|
|
6
|
-
return {};
|
|
7
|
-
},
|
|
8
|
-
computed: {
|
|
9
|
-
selfBasePropsObj () {
|
|
10
|
-
return {
|
|
11
|
-
...this.treeTableBasePropsObj,
|
|
12
|
-
_dftReadonlyTreeColKeys: [], // 默认的数据只读的表头列
|
|
13
|
-
_oldReadonlyTreeColKeys: [] // 保存的数据只读的表头列
|
|
14
|
-
};
|
|
15
|
-
},
|
|
16
|
-
dftReadonlyTreeColKeys () {
|
|
17
|
-
return this.isDftSet ? [] : this.selfPropsObj._dftReadonlyTreeColKeys || []; // 配置端有问题,高级依赖时值成undefined了
|
|
18
|
-
},
|
|
19
|
-
oldReadonlyTreeColKeys () {
|
|
20
|
-
return this.isDftSet ? [] : this.selfPropsObj._oldReadonlyTreeColKeys || []; // 配置端有问题,高级依赖时值成undefined了
|
|
21
|
-
},
|
|
22
|
-
// 替换tableBaseMixin里的
|
|
23
|
-
noborderColKeys () {
|
|
24
|
-
return [
|
|
25
|
-
...this.treeColKeys,
|
|
26
|
-
...this.selfPropsObj._noborderColKeys
|
|
27
|
-
];
|
|
28
|
-
},
|
|
29
|
-
// 替换tableBaseMixin里的
|
|
30
|
-
showCreateBtnColKeys () {
|
|
31
|
-
return [
|
|
32
|
-
...this.treeColKeys,
|
|
33
|
-
...(this.selfPropsObj._showCreateBtnColKeys || [])
|
|
34
|
-
];
|
|
35
|
-
},
|
|
36
|
-
// 替换tableBaseMixin里的
|
|
37
|
-
searchTitle () {
|
|
38
|
-
return `${this.isSearching ? "筛选" : "全部"}数据,共 ${this.totalNum} 条;`;
|
|
39
|
-
},
|
|
40
|
-
|
|
41
|
-
/* --- 列字段 --- */
|
|
42
|
-
showColumns () {
|
|
43
|
-
return [
|
|
44
|
-
...this.$transformToColumns(this.showContentColumns),
|
|
45
|
-
...(!this.isSearching && this.rowOperationList.length ? [this.selfOperationColumn] : [])
|
|
46
|
-
];
|
|
47
|
-
},
|
|
48
|
-
// 替换tableBaseMixin里的
|
|
49
|
-
contentColumns () {
|
|
50
|
-
return [
|
|
51
|
-
...this.treeColumns.reduce((arr, colItem) => ([
|
|
52
|
-
...arr,
|
|
53
|
-
{
|
|
54
|
-
...colItem,
|
|
55
|
-
colType: "tree"
|
|
56
|
-
},
|
|
57
|
-
...colItem._treeSubForm.map(subColItem => ({
|
|
58
|
-
...subColItem,
|
|
59
|
-
colType: "summary",
|
|
60
|
-
nodeKey: colItem._key
|
|
61
|
-
}))
|
|
62
|
-
]), []),
|
|
63
|
-
...this.usedColumns.map(colItem => ({
|
|
64
|
-
...colItem,
|
|
65
|
-
colType: "data",
|
|
66
|
-
nodeKey: this.treeColKeys[this.treeColKeys.length - 1]
|
|
67
|
-
}))
|
|
68
|
-
].map(colItem => ({
|
|
69
|
-
renderHeaderCell: ({ column }, h) => {
|
|
70
|
-
return this.contentThCellRender(h, { column });
|
|
71
|
-
},
|
|
72
|
-
renderBodyCell: ({ row, rowIndex, column }, h) => {
|
|
73
|
-
row = row[column.nodeKey || column._key];
|
|
74
|
-
|
|
75
|
-
return column.colType === "summary"
|
|
76
|
-
? this.getSummaryTdVal({ row, rowIndex, column })
|
|
77
|
-
: this.contentTdCellRender(h, { row, rowIndex, column });
|
|
78
|
-
},
|
|
79
|
-
...colItem
|
|
80
|
-
}));
|
|
81
|
-
},
|
|
82
|
-
selfOperationColumn () {
|
|
83
|
-
return {
|
|
84
|
-
...this.operationColumn,
|
|
85
|
-
nodeKey: this.treeColKeys[this.treeColKeys.length - 1],
|
|
86
|
-
renderBodyCell: ({ row, rowIndex, column }, h) => {
|
|
87
|
-
row = row[column.nodeKey || column._key];
|
|
88
|
-
|
|
89
|
-
return this.operationTdCellRender(h, { row, rowIndex, column });
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
|
-
},
|
|
93
|
-
|
|
94
|
-
/* --- 数据 --- */
|
|
95
|
-
allTreeData () {
|
|
96
|
-
// console.log("allTreeData");
|
|
97
|
-
return this.getCalcuedTree(this.data, this.selfColumns, this.treeColumns);
|
|
98
|
-
},
|
|
99
|
-
allListData () {
|
|
100
|
-
// console.log("allListData");
|
|
101
|
-
return this.$getTreeFlatArr(this.allTreeData, node => !(node.children && node.children.length));
|
|
102
|
-
},
|
|
103
|
-
showListData () {
|
|
104
|
-
// console.log("showListData");
|
|
105
|
-
const loop = (nodes = [], finalRows = []) => {
|
|
106
|
-
// 先层层过滤
|
|
107
|
-
const subLoop = (nodes = []) =>
|
|
108
|
-
nodes.filter(row =>
|
|
109
|
-
row.children && row.children.length
|
|
110
|
-
? !!subLoop(row.children).length
|
|
111
|
-
: this.isSearching
|
|
112
|
-
? this.$isAdvRelyAccord(this.finalTableAdvSearch, row)
|
|
113
|
-
: true
|
|
114
|
-
);
|
|
115
|
-
nodes = subLoop(nodes);
|
|
116
|
-
|
|
117
|
-
return nodes.reduce((rows, node, nodeIndex) => {
|
|
118
|
-
// 创建行,并把节点数据(对象类型)注入到行对象内
|
|
119
|
-
if (nodeIndex !== 0 || rows.length === 0) {
|
|
120
|
-
rows.push({
|
|
121
|
-
_id: this.$ObjectID().str
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
const curCol = this.treeColumns[node.level - 1];
|
|
125
|
-
const curRow = rows[rows.length - 1];
|
|
126
|
-
Object.assign(curRow, { [curCol._key]: node });
|
|
127
|
-
|
|
128
|
-
// 判断是否叶子节点,做对应操作
|
|
129
|
-
if (node.children && node.children.length) {
|
|
130
|
-
const oldLength = rows.length - 1;
|
|
131
|
-
const newRows = loop(node.children, rows);
|
|
132
|
-
node.total = newRows.length - oldLength;
|
|
133
|
-
return newRows;
|
|
134
|
-
} else {
|
|
135
|
-
return rows;
|
|
136
|
-
}
|
|
137
|
-
}, finalRows);
|
|
138
|
-
};
|
|
139
|
-
|
|
140
|
-
return loop(this.allTreeData);
|
|
141
|
-
}
|
|
142
|
-
},
|
|
143
|
-
created () { },
|
|
144
|
-
mounted () { },
|
|
145
|
-
methods: {
|
|
146
|
-
// 转化树数据
|
|
147
|
-
getCalcuedTree (nodes = [], subCols = [], treeCols = []) {
|
|
148
|
-
const loop = (nodes = [], parentNodes = []) => {
|
|
149
|
-
nodes.forEach(row => {
|
|
150
|
-
this.fixRowData(row);
|
|
151
|
-
|
|
152
|
-
// 初始化树节点的数据,给节点加上一些属性并监测,注入到节点对象中
|
|
153
|
-
let curCol = treeCols[row.level - 1];
|
|
154
|
-
this.$setObj(row, {
|
|
155
|
-
_key: curCol._key,
|
|
156
|
-
isLeaf: false,
|
|
157
|
-
total: 1
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
// 根节点
|
|
161
|
-
if (row.level === treeCols.length) {
|
|
162
|
-
row.children = [];
|
|
163
|
-
row.isLeaf = true;
|
|
164
|
-
|
|
165
|
-
// // TODO:特殊处理-叶子节点上注入对应表头列们的name值
|
|
166
|
-
// const treeNodes = [...parentNodes, row];
|
|
167
|
-
// treeCols.forEach((colItem, colIndex) => {
|
|
168
|
-
// row[colItem._key] = treeNodes[colIndex].name;
|
|
169
|
-
// });
|
|
170
|
-
}
|
|
171
|
-
// 非根节点,需继续向下循环
|
|
172
|
-
else {
|
|
173
|
-
// 正常的非根节点
|
|
174
|
-
if (row.children && row.children.length) {
|
|
175
|
-
loop(row.children, [...parentNodes, row]);
|
|
176
|
-
}
|
|
177
|
-
// 特殊的非根节点(此时是新增一列 或 新增了非根节点行) -添加一个子节点,并把该节点上的subForm属性值全部给下级节点(新增的是根节点行,不会走此处代码)
|
|
178
|
-
else {
|
|
179
|
-
const newNode = this.getNewRowData(row.level + 1, row.children);
|
|
180
|
-
subCols.forEach(subCol => {
|
|
181
|
-
newNode[subCol._key] = row[subCol._key]; // 用$set也可以
|
|
182
|
-
delete row[subCol._key];
|
|
183
|
-
});
|
|
184
|
-
row.children.push(newNode);
|
|
185
|
-
|
|
186
|
-
loop(row.children, [...parentNodes, row]);
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
});
|
|
190
|
-
};
|
|
191
|
-
|
|
192
|
-
loop(nodes);
|
|
193
|
-
this.initFlag = false;
|
|
194
|
-
return nodes;
|
|
195
|
-
},
|
|
196
|
-
fixSelfRowData (row) {
|
|
197
|
-
if (this.initFlag) {
|
|
198
|
-
// 根节点
|
|
199
|
-
if (!(row.children && row.children.length)) {
|
|
200
|
-
// 每条数据都补充全所有字段值(赋一个默认的空值)
|
|
201
|
-
this.selfColumns.forEach((colItem) => {
|
|
202
|
-
// 不用row[colItem._key] === undefined判断,是因为后端给的空值不可靠,多选的有时候都能给null
|
|
203
|
-
if (!Object.prototype.hasOwnProperty.call(row, colItem._key) && this.$isEmptyData(row[colItem._key])) {
|
|
204
|
-
this.$set(row, colItem._key, this.$deepCopy(this.dftInitValMap[colItem._type]));
|
|
205
|
-
}
|
|
206
|
-
});
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
},
|
|
210
|
-
|
|
211
|
-
// 单元格 -汇总节点单元格-获取值
|
|
212
|
-
getSummaryTdVal ({ row, rowIndex, column }) {
|
|
213
|
-
const calFieldFormItem = this.selfColumns.find(item => item._key === column._calField);
|
|
214
|
-
|
|
215
|
-
if (column._calField && calFieldFormItem && column._operator) {
|
|
216
|
-
const loop = (nodes, arr = []) =>
|
|
217
|
-
nodes.reduce((arr, node) => {
|
|
218
|
-
return node.children.length
|
|
219
|
-
? loop(node.children, arr)
|
|
220
|
-
: [
|
|
221
|
-
...arr,
|
|
222
|
-
node[column._calField] || 0
|
|
223
|
-
];
|
|
224
|
-
}, arr);
|
|
225
|
-
const list = loop(row.children);
|
|
226
|
-
|
|
227
|
-
return this.$calNumList(list, column._operator, calFieldFormItem);
|
|
228
|
-
} else {
|
|
229
|
-
return !column._calField && !column._operator
|
|
230
|
-
? "未选择来源列和算法"
|
|
231
|
-
: !column._calField
|
|
232
|
-
? "未选择来源列"
|
|
233
|
-
: !calFieldFormItem
|
|
234
|
-
? `来源列${column._calField}被删除`
|
|
235
|
-
: "未选择算法";
|
|
236
|
-
}
|
|
237
|
-
},
|
|
238
|
-
bodyCellSpan ({ row, rowIndex, column }) {
|
|
239
|
-
row = row[column.nodeKey || column._key];
|
|
240
|
-
|
|
241
|
-
return {
|
|
242
|
-
rowspan: row
|
|
243
|
-
? row.total || 1
|
|
244
|
-
: 0,
|
|
245
|
-
colspan: 1
|
|
246
|
-
};
|
|
247
|
-
},
|
|
248
|
-
|
|
249
|
-
// 加工单元格对应的配置
|
|
250
|
-
getSelfResetCol ({ row, rowIndex, column }) {
|
|
251
|
-
return column.colType === "tree"
|
|
252
|
-
? {
|
|
253
|
-
_heightAuto: true,
|
|
254
|
-
_placeholder: " "
|
|
255
|
-
}
|
|
256
|
-
: {};
|
|
257
|
-
},
|
|
258
|
-
// 单元格本身是否可编辑性 -针对表头列
|
|
259
|
-
getSelfColCanEdit ({ row, rowIndex, column }) {
|
|
260
|
-
return (this.getIsDftRow(row) ? !this.dftReadonlyTreeColKeys.includes(column._key) : true) && // 默认行的某列是否可编辑
|
|
261
|
-
(row.__old__ === true ? !this.oldReadonlyTreeColKeys.includes(column._key) : true); // 老数据行里某些列不可编辑
|
|
262
|
-
},
|
|
263
|
-
// getNewRowData时,额外补充的行相关的数据(针对层级列)
|
|
264
|
-
getSelfNewRowData (level) {
|
|
265
|
-
const column = this.treeColumns[level - 1];
|
|
266
|
-
const dftVal = column._default;
|
|
267
|
-
const dftInitVal = this.dftInitValMap[column._type];
|
|
268
|
-
|
|
269
|
-
return {
|
|
270
|
-
name: this.$deepCopy(
|
|
271
|
-
this.$isEmptyData(dftVal)
|
|
272
|
-
? dftInitVal
|
|
273
|
-
: dftVal
|
|
274
|
-
)
|
|
275
|
-
};
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
};
|
|
1
|
+
export default {
|
|
2
|
+
mixins: [],
|
|
3
|
+
components: {},
|
|
4
|
+
props: {},
|
|
5
|
+
data () {
|
|
6
|
+
return {};
|
|
7
|
+
},
|
|
8
|
+
computed: {
|
|
9
|
+
selfBasePropsObj () {
|
|
10
|
+
return {
|
|
11
|
+
...this.treeTableBasePropsObj,
|
|
12
|
+
_dftReadonlyTreeColKeys: [], // 默认的数据只读的表头列
|
|
13
|
+
_oldReadonlyTreeColKeys: [] // 保存的数据只读的表头列
|
|
14
|
+
};
|
|
15
|
+
},
|
|
16
|
+
dftReadonlyTreeColKeys () {
|
|
17
|
+
return this.isDftSet ? [] : this.selfPropsObj._dftReadonlyTreeColKeys || []; // 配置端有问题,高级依赖时值成undefined了
|
|
18
|
+
},
|
|
19
|
+
oldReadonlyTreeColKeys () {
|
|
20
|
+
return this.isDftSet ? [] : this.selfPropsObj._oldReadonlyTreeColKeys || []; // 配置端有问题,高级依赖时值成undefined了
|
|
21
|
+
},
|
|
22
|
+
// 替换tableBaseMixin里的
|
|
23
|
+
noborderColKeys () {
|
|
24
|
+
return [
|
|
25
|
+
...this.treeColKeys,
|
|
26
|
+
...this.selfPropsObj._noborderColKeys
|
|
27
|
+
];
|
|
28
|
+
},
|
|
29
|
+
// 替换tableBaseMixin里的
|
|
30
|
+
showCreateBtnColKeys () {
|
|
31
|
+
return [
|
|
32
|
+
...this.treeColKeys,
|
|
33
|
+
...(this.selfPropsObj._showCreateBtnColKeys || [])
|
|
34
|
+
];
|
|
35
|
+
},
|
|
36
|
+
// 替换tableBaseMixin里的
|
|
37
|
+
searchTitle () {
|
|
38
|
+
return `${this.isSearching ? "筛选" : "全部"}数据,共 ${this.totalNum} 条;`;
|
|
39
|
+
},
|
|
40
|
+
|
|
41
|
+
/* --- 列字段 --- */
|
|
42
|
+
showColumns () {
|
|
43
|
+
return [
|
|
44
|
+
...this.$transformToColumns(this.showContentColumns),
|
|
45
|
+
...(!this.isSearching && this.rowOperationList.length ? [this.selfOperationColumn] : [])
|
|
46
|
+
];
|
|
47
|
+
},
|
|
48
|
+
// 替换tableBaseMixin里的
|
|
49
|
+
contentColumns () {
|
|
50
|
+
return [
|
|
51
|
+
...this.treeColumns.reduce((arr, colItem) => ([
|
|
52
|
+
...arr,
|
|
53
|
+
{
|
|
54
|
+
...colItem,
|
|
55
|
+
colType: "tree"
|
|
56
|
+
},
|
|
57
|
+
...colItem._treeSubForm.map(subColItem => ({
|
|
58
|
+
...subColItem,
|
|
59
|
+
colType: "summary",
|
|
60
|
+
nodeKey: colItem._key
|
|
61
|
+
}))
|
|
62
|
+
]), []),
|
|
63
|
+
...this.usedColumns.map(colItem => ({
|
|
64
|
+
...colItem,
|
|
65
|
+
colType: "data",
|
|
66
|
+
nodeKey: this.treeColKeys[this.treeColKeys.length - 1]
|
|
67
|
+
}))
|
|
68
|
+
].map(colItem => ({
|
|
69
|
+
renderHeaderCell: ({ column }, h) => {
|
|
70
|
+
return this.contentThCellRender(h, { column });
|
|
71
|
+
},
|
|
72
|
+
renderBodyCell: ({ row, rowIndex, column }, h) => {
|
|
73
|
+
row = row[column.nodeKey || column._key];
|
|
74
|
+
|
|
75
|
+
return column.colType === "summary"
|
|
76
|
+
? this.getSummaryTdVal({ row, rowIndex, column })
|
|
77
|
+
: this.contentTdCellRender(h, { row, rowIndex, column });
|
|
78
|
+
},
|
|
79
|
+
...colItem
|
|
80
|
+
}));
|
|
81
|
+
},
|
|
82
|
+
selfOperationColumn () {
|
|
83
|
+
return {
|
|
84
|
+
...this.operationColumn,
|
|
85
|
+
nodeKey: this.treeColKeys[this.treeColKeys.length - 1],
|
|
86
|
+
renderBodyCell: ({ row, rowIndex, column }, h) => {
|
|
87
|
+
row = row[column.nodeKey || column._key];
|
|
88
|
+
|
|
89
|
+
return this.operationTdCellRender(h, { row, rowIndex, column });
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
},
|
|
93
|
+
|
|
94
|
+
/* --- 数据 --- */
|
|
95
|
+
allTreeData () {
|
|
96
|
+
// console.log("allTreeData");
|
|
97
|
+
return this.getCalcuedTree(this.data, this.selfColumns, this.treeColumns);
|
|
98
|
+
},
|
|
99
|
+
allListData () {
|
|
100
|
+
// console.log("allListData");
|
|
101
|
+
return this.$getTreeFlatArr(this.allTreeData, node => !(node.children && node.children.length));
|
|
102
|
+
},
|
|
103
|
+
showListData () {
|
|
104
|
+
// console.log("showListData");
|
|
105
|
+
const loop = (nodes = [], finalRows = []) => {
|
|
106
|
+
// 先层层过滤
|
|
107
|
+
const subLoop = (nodes = []) =>
|
|
108
|
+
nodes.filter(row =>
|
|
109
|
+
row.children && row.children.length
|
|
110
|
+
? !!subLoop(row.children).length
|
|
111
|
+
: this.isSearching
|
|
112
|
+
? this.$isAdvRelyAccord(this.finalTableAdvSearch, row)
|
|
113
|
+
: true
|
|
114
|
+
);
|
|
115
|
+
nodes = subLoop(nodes);
|
|
116
|
+
|
|
117
|
+
return nodes.reduce((rows, node, nodeIndex) => {
|
|
118
|
+
// 创建行,并把节点数据(对象类型)注入到行对象内
|
|
119
|
+
if (nodeIndex !== 0 || rows.length === 0) {
|
|
120
|
+
rows.push({
|
|
121
|
+
_id: this.$ObjectID().str
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
const curCol = this.treeColumns[node.level - 1];
|
|
125
|
+
const curRow = rows[rows.length - 1];
|
|
126
|
+
Object.assign(curRow, { [curCol._key]: node });
|
|
127
|
+
|
|
128
|
+
// 判断是否叶子节点,做对应操作
|
|
129
|
+
if (node.children && node.children.length) {
|
|
130
|
+
const oldLength = rows.length - 1;
|
|
131
|
+
const newRows = loop(node.children, rows);
|
|
132
|
+
node.total = newRows.length - oldLength;
|
|
133
|
+
return newRows;
|
|
134
|
+
} else {
|
|
135
|
+
return rows;
|
|
136
|
+
}
|
|
137
|
+
}, finalRows);
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
return loop(this.allTreeData);
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
created () { },
|
|
144
|
+
mounted () { },
|
|
145
|
+
methods: {
|
|
146
|
+
// 转化树数据
|
|
147
|
+
getCalcuedTree (nodes = [], subCols = [], treeCols = []) {
|
|
148
|
+
const loop = (nodes = [], parentNodes = []) => {
|
|
149
|
+
nodes.forEach(row => {
|
|
150
|
+
this.fixRowData(row);
|
|
151
|
+
|
|
152
|
+
// 初始化树节点的数据,给节点加上一些属性并监测,注入到节点对象中
|
|
153
|
+
let curCol = treeCols[row.level - 1];
|
|
154
|
+
this.$setObj(row, {
|
|
155
|
+
_key: curCol._key,
|
|
156
|
+
isLeaf: false,
|
|
157
|
+
total: 1
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
// 根节点
|
|
161
|
+
if (row.level === treeCols.length) {
|
|
162
|
+
row.children = [];
|
|
163
|
+
row.isLeaf = true;
|
|
164
|
+
|
|
165
|
+
// // TODO:特殊处理-叶子节点上注入对应表头列们的name值
|
|
166
|
+
// const treeNodes = [...parentNodes, row];
|
|
167
|
+
// treeCols.forEach((colItem, colIndex) => {
|
|
168
|
+
// row[colItem._key] = treeNodes[colIndex].name;
|
|
169
|
+
// });
|
|
170
|
+
}
|
|
171
|
+
// 非根节点,需继续向下循环
|
|
172
|
+
else {
|
|
173
|
+
// 正常的非根节点
|
|
174
|
+
if (row.children && row.children.length) {
|
|
175
|
+
loop(row.children, [...parentNodes, row]);
|
|
176
|
+
}
|
|
177
|
+
// 特殊的非根节点(此时是新增一列 或 新增了非根节点行) -添加一个子节点,并把该节点上的subForm属性值全部给下级节点(新增的是根节点行,不会走此处代码)
|
|
178
|
+
else {
|
|
179
|
+
const newNode = this.getNewRowData(row.level + 1, row.children);
|
|
180
|
+
subCols.forEach(subCol => {
|
|
181
|
+
newNode[subCol._key] = row[subCol._key]; // 用$set也可以
|
|
182
|
+
delete row[subCol._key];
|
|
183
|
+
});
|
|
184
|
+
row.children.push(newNode);
|
|
185
|
+
|
|
186
|
+
loop(row.children, [...parentNodes, row]);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
loop(nodes);
|
|
193
|
+
this.initFlag = false;
|
|
194
|
+
return nodes;
|
|
195
|
+
},
|
|
196
|
+
fixSelfRowData (row) {
|
|
197
|
+
if (this.initFlag) {
|
|
198
|
+
// 根节点
|
|
199
|
+
if (!(row.children && row.children.length)) {
|
|
200
|
+
// 每条数据都补充全所有字段值(赋一个默认的空值)
|
|
201
|
+
this.selfColumns.forEach((colItem) => {
|
|
202
|
+
// 不用row[colItem._key] === undefined判断,是因为后端给的空值不可靠,多选的有时候都能给null
|
|
203
|
+
if (!Object.prototype.hasOwnProperty.call(row, colItem._key) && this.$isEmptyData(row[colItem._key])) {
|
|
204
|
+
this.$set(row, colItem._key, this.$deepCopy(this.dftInitValMap[colItem._type]));
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
},
|
|
210
|
+
|
|
211
|
+
// 单元格 -汇总节点单元格-获取值
|
|
212
|
+
getSummaryTdVal ({ row, rowIndex, column }) {
|
|
213
|
+
const calFieldFormItem = this.selfColumns.find(item => item._key === column._calField);
|
|
214
|
+
|
|
215
|
+
if (column._calField && calFieldFormItem && column._operator) {
|
|
216
|
+
const loop = (nodes, arr = []) =>
|
|
217
|
+
nodes.reduce((arr, node) => {
|
|
218
|
+
return node.children.length
|
|
219
|
+
? loop(node.children, arr)
|
|
220
|
+
: [
|
|
221
|
+
...arr,
|
|
222
|
+
node[column._calField] || 0
|
|
223
|
+
];
|
|
224
|
+
}, arr);
|
|
225
|
+
const list = loop(row.children);
|
|
226
|
+
|
|
227
|
+
return this.$calNumList(list, column._operator, calFieldFormItem);
|
|
228
|
+
} else {
|
|
229
|
+
return !column._calField && !column._operator
|
|
230
|
+
? "未选择来源列和算法"
|
|
231
|
+
: !column._calField
|
|
232
|
+
? "未选择来源列"
|
|
233
|
+
: !calFieldFormItem
|
|
234
|
+
? `来源列${column._calField}被删除`
|
|
235
|
+
: "未选择算法";
|
|
236
|
+
}
|
|
237
|
+
},
|
|
238
|
+
bodyCellSpan ({ row, rowIndex, column }) {
|
|
239
|
+
row = row[column.nodeKey || column._key];
|
|
240
|
+
|
|
241
|
+
return {
|
|
242
|
+
rowspan: row
|
|
243
|
+
? row.total || 1
|
|
244
|
+
: 0,
|
|
245
|
+
colspan: 1
|
|
246
|
+
};
|
|
247
|
+
},
|
|
248
|
+
|
|
249
|
+
// 加工单元格对应的配置
|
|
250
|
+
getSelfResetCol ({ row, rowIndex, column }) {
|
|
251
|
+
return column.colType === "tree"
|
|
252
|
+
? {
|
|
253
|
+
_heightAuto: true,
|
|
254
|
+
_placeholder: " "
|
|
255
|
+
}
|
|
256
|
+
: {};
|
|
257
|
+
},
|
|
258
|
+
// 单元格本身是否可编辑性 -针对表头列
|
|
259
|
+
getSelfColCanEdit ({ row, rowIndex, column }) {
|
|
260
|
+
return (this.getIsDftRow(row) ? !this.dftReadonlyTreeColKeys.includes(column._key) : true) && // 默认行的某列是否可编辑
|
|
261
|
+
(row.__old__ === true ? !this.oldReadonlyTreeColKeys.includes(column._key) : true); // 老数据行里某些列不可编辑
|
|
262
|
+
},
|
|
263
|
+
// getNewRowData时,额外补充的行相关的数据(针对层级列)
|
|
264
|
+
getSelfNewRowData (level) {
|
|
265
|
+
const column = this.treeColumns[level - 1];
|
|
266
|
+
const dftVal = column._default;
|
|
267
|
+
const dftInitVal = this.dftInitValMap[column._type];
|
|
268
|
+
|
|
269
|
+
return {
|
|
270
|
+
name: this.$deepCopy(
|
|
271
|
+
this.$isEmptyData(dftVal)
|
|
272
|
+
? dftInitVal
|
|
273
|
+
: dftVal
|
|
274
|
+
)
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
};
|