bl-common-vue3 3.8.107 → 3.8.109
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
package/src/common/utils/xlsx.js
CHANGED
|
@@ -1,6 +1,60 @@
|
|
|
1
1
|
import fs from "file-saver";
|
|
2
2
|
import * as XLSX from "kj-xlsx";
|
|
3
|
-
|
|
3
|
+
|
|
4
|
+
export function getVerticalMergeCells(json, fields, options = {}) {
|
|
5
|
+
const { groupField, mergeFields = [] } = options;
|
|
6
|
+
if (!groupField || !Array.isArray(mergeFields) || !mergeFields.length) {
|
|
7
|
+
return [];
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const fieldKeys = Object.keys(fields);
|
|
11
|
+
const mergeColumnIndexes = mergeFields
|
|
12
|
+
.map((field) => fieldKeys.indexOf(field))
|
|
13
|
+
.filter((columnIndex) => columnIndex >= 0);
|
|
14
|
+
if (!mergeColumnIndexes.length) {
|
|
15
|
+
return [];
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const merges = [];
|
|
19
|
+
let groupStartIndex = 0;
|
|
20
|
+
|
|
21
|
+
const appendGroupMerges = (groupEndIndex) => {
|
|
22
|
+
const groupValue = json[groupStartIndex]?.[groupField];
|
|
23
|
+
if (
|
|
24
|
+
groupEndIndex <= groupStartIndex ||
|
|
25
|
+
groupValue === undefined ||
|
|
26
|
+
groupValue === null ||
|
|
27
|
+
groupValue === ""
|
|
28
|
+
) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
mergeColumnIndexes.forEach((columnIndex) => {
|
|
33
|
+
merges.push({
|
|
34
|
+
// 工作表第 0 行是表头,数据行需要整体向下偏移一行。
|
|
35
|
+
s: { r: groupStartIndex + 1, c: columnIndex },
|
|
36
|
+
e: { r: groupEndIndex + 1, c: columnIndex },
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
for (let rowIndex = 1; rowIndex <= json.length; rowIndex++) {
|
|
42
|
+
const groupChanged =
|
|
43
|
+
rowIndex === json.length ||
|
|
44
|
+
json[rowIndex]?.[groupField] !== json[groupStartIndex]?.[groupField];
|
|
45
|
+
if (!groupChanged) {
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
appendGroupMerges(rowIndex - 1);
|
|
50
|
+
groupStartIndex = rowIndex;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return merges;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export function xlsx(json, fields, filename = ".xlsx", mergeOptions = {}) {
|
|
57
|
+
const merges = getVerticalMergeCells(json, fields, mergeOptions);
|
|
4
58
|
//导出xlsx
|
|
5
59
|
json.forEach((item) => {
|
|
6
60
|
for (let i in item) {
|
|
@@ -14,6 +68,9 @@ export function xlsx(json, fields, filename = ".xlsx") {
|
|
|
14
68
|
let sheetName = filename.replace(/[\\/?*[\]:]/g, "").slice(0, 31) || "Sheet1"; //excel的文件名称
|
|
15
69
|
let wb = XLSX.utils.book_new(); //工作簿对象包含一SheetNames数组,以及一个表对象映射表名称到表对象。XLSX.utils.book_new实用函数创建一个新的工作簿对象。
|
|
16
70
|
let ws = XLSX.utils.json_to_sheet(json, { header: Object.values(fields) }); //将JS对象数组转换为工作表。
|
|
71
|
+
if (merges.length) {
|
|
72
|
+
ws["!merges"] = merges;
|
|
73
|
+
}
|
|
17
74
|
wb.SheetNames.push(sheetName);
|
|
18
75
|
wb.Sheets[sheetName] = ws;
|
|
19
76
|
const defaultCellStyle = {
|
|
@@ -816,7 +816,7 @@
|
|
|
816
816
|
<template #title>
|
|
817
817
|
{{ i18nMapShow(item, ["name"], ["name"]) }}
|
|
818
818
|
</template>
|
|
819
|
-
<template v-for="(child
|
|
819
|
+
<template v-for="(child) in item.children" :key="child.key">
|
|
820
820
|
<a-menu-item v-if="child?.show ?? true" :key="child.key">
|
|
821
821
|
<a-button v-bind="{ ...(child?.props || {}), }" @click.stop="child?.onClick">
|
|
822
822
|
<template #icon v-if="buttonIconSlots.indexOf(`${child.key}`) > -1">
|
|
@@ -4056,7 +4056,7 @@ export default defineComponent({
|
|
|
4056
4056
|
'dateTimeRangePicker': 'date_time',
|
|
4057
4057
|
'timeRangePicker': 'time',
|
|
4058
4058
|
}
|
|
4059
|
-
|
|
4059
|
+
|
|
4060
4060
|
if(singleDateInputTypes.includes(input_type)) {
|
|
4061
4061
|
valueShow = dateFormatMaps[inputTypeFormatMaps[input_type]]?dayjs(value).format(dateFormatMaps[inputTypeFormatMaps[input_type]]):value
|
|
4062
4062
|
}
|
|
@@ -67,6 +67,10 @@ export default defineComponent({
|
|
|
67
67
|
type: Object,
|
|
68
68
|
default: () => ({})
|
|
69
69
|
},
|
|
70
|
+
merge_options: { //导出表格纵向合并配置
|
|
71
|
+
type: Object,
|
|
72
|
+
default: () => ({})
|
|
73
|
+
},
|
|
70
74
|
custom_result: { //导出表格头部
|
|
71
75
|
type: Object,
|
|
72
76
|
// eslint-disable-next-line vue/require-valid-default-prop
|
|
@@ -123,7 +127,7 @@ export default defineComponent({
|
|
|
123
127
|
console.log('导出文档')
|
|
124
128
|
setTimeout(() => {
|
|
125
129
|
let list = utils.deepClone(state.ExportList);
|
|
126
|
-
xlsx(list, removeUndefined(props.columnstitle), props.title);
|
|
130
|
+
xlsx(list, removeUndefined(props.columnstitle), props.title, props.merge_options);
|
|
127
131
|
context.emit("success", t('ExportComponents.index.921182-2'));
|
|
128
132
|
closeModal()
|
|
129
133
|
}, 200);
|
|
@@ -140,7 +144,7 @@ export default defineComponent({
|
|
|
140
144
|
console.log('导出文档')
|
|
141
145
|
setTimeout(() => {
|
|
142
146
|
let list = utils.deepClone(state.ExportList);
|
|
143
|
-
xlsx(list, removeUndefined(props.columnstitle), props.title);
|
|
147
|
+
xlsx(list, removeUndefined(props.columnstitle), props.title, props.merge_options);
|
|
144
148
|
context.emit("success", t('ExportComponents.index.921182-2'));
|
|
145
149
|
closeModal()
|
|
146
150
|
}, 200);
|
|
@@ -160,7 +164,7 @@ export default defineComponent({
|
|
|
160
164
|
(val) => {
|
|
161
165
|
setTimeout(() => {
|
|
162
166
|
let list = utils.deepClone(val);
|
|
163
|
-
xlsx(list, removeUndefined(props.columnstitle), props.title);
|
|
167
|
+
xlsx(list, removeUndefined(props.columnstitle), props.title, props.merge_options);
|
|
164
168
|
context.emit("success", t('ExportComponents.index.921182-2'));
|
|
165
169
|
closeModal()
|
|
166
170
|
}, 200);
|
|
@@ -900,23 +900,8 @@ export default defineComponent({
|
|
|
900
900
|
if (build) {
|
|
901
901
|
/* 处理没有楼层的情况 */
|
|
902
902
|
if (noLayer.value) {
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
);
|
|
906
|
-
if (room) {
|
|
907
|
-
getSubRooms(room, true).then(() => {
|
|
908
|
-
if (refreshParams.selected && refreshParams.selected.roomId) {
|
|
909
|
-
setSelected(room);
|
|
910
|
-
}
|
|
911
|
-
state.loadingTree = false;
|
|
912
|
-
});
|
|
913
|
-
}
|
|
914
|
-
} else {
|
|
915
|
-
const layer = build.children.find(
|
|
916
|
-
(item) => item.id == refreshParams.layerId
|
|
917
|
-
);
|
|
918
|
-
if (layer) {
|
|
919
|
-
const room = build.children.find(
|
|
903
|
+
getRoomList(build, true).then(() => {
|
|
904
|
+
const room = (build.children || []).find(
|
|
920
905
|
(item) => item.id == refreshParams.roomId
|
|
921
906
|
);
|
|
922
907
|
if (room) {
|
|
@@ -926,8 +911,35 @@ export default defineComponent({
|
|
|
926
911
|
}
|
|
927
912
|
state.loadingTree = false;
|
|
928
913
|
});
|
|
914
|
+
} else {
|
|
915
|
+
state.loadingTree = false;
|
|
929
916
|
}
|
|
930
|
-
}
|
|
917
|
+
});
|
|
918
|
+
} else {
|
|
919
|
+
getLayerList(build, true).then(() => {
|
|
920
|
+
const layer = (build.children || []).find(
|
|
921
|
+
(item) => item.id == refreshParams.layerId
|
|
922
|
+
);
|
|
923
|
+
if (layer) {
|
|
924
|
+
getRoomList(layer, true).then(() => {
|
|
925
|
+
const room = (layer.children || []).find(
|
|
926
|
+
(item) => item.id == refreshParams.roomId
|
|
927
|
+
);
|
|
928
|
+
if (room) {
|
|
929
|
+
getSubRooms(room, true).then(() => {
|
|
930
|
+
if (refreshParams.selected && refreshParams.selected.roomId) {
|
|
931
|
+
setSelected(room);
|
|
932
|
+
}
|
|
933
|
+
state.loadingTree = false;
|
|
934
|
+
});
|
|
935
|
+
} else {
|
|
936
|
+
state.loadingTree = false;
|
|
937
|
+
}
|
|
938
|
+
});
|
|
939
|
+
} else {
|
|
940
|
+
state.loadingTree = false;
|
|
941
|
+
}
|
|
942
|
+
});
|
|
931
943
|
}
|
|
932
944
|
|
|
933
945
|
}
|
|
@@ -949,17 +961,21 @@ export default defineComponent({
|
|
|
949
961
|
}
|
|
950
962
|
})
|
|
951
963
|
if (build) {
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
964
|
+
getLayerList(build, true).then(() => {
|
|
965
|
+
const layer = (build.children || []).find(
|
|
966
|
+
(item) => item.id == refreshParams.layerId
|
|
967
|
+
);
|
|
968
|
+
if (layer) {
|
|
969
|
+
getRoomList(layer, true).then(() => {
|
|
970
|
+
if (refreshParams.selected && refreshParams.selected.layerId) {
|
|
971
|
+
setSelected(layer);
|
|
972
|
+
}
|
|
973
|
+
state.loadingTree = false;
|
|
974
|
+
});
|
|
975
|
+
} else {
|
|
960
976
|
state.loadingTree = false;
|
|
961
|
-
}
|
|
962
|
-
}
|
|
977
|
+
}
|
|
978
|
+
});
|
|
963
979
|
}
|
|
964
980
|
}
|
|
965
981
|
} else if (refreshParams.buildId) {
|