bl-common-vue3 3.8.124 → 3.8.126
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
|
@@ -1,212 +1,268 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="progress-page">
|
|
3
|
-
<div class="progress-box">
|
|
4
|
-
<template v-if="!systemToken">
|
|
5
|
-
<a-alert :message="t('ReportLang.index.603107-0')" type="warning" />
|
|
6
|
-
</template>
|
|
7
|
-
<template v-else>
|
|
8
|
-
<a-progress :percent="reportPercent" />
|
|
9
|
-
<div class="tip-box">
|
|
10
|
-
<div class="tip" v-if="successLanguages.length">
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
</
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
import {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
} from "
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
"a-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
1
|
+
<template>
|
|
2
|
+
<div class="progress-page">
|
|
3
|
+
<div class="progress-box">
|
|
4
|
+
<template v-if="!systemToken">
|
|
5
|
+
<a-alert :message="t('ReportLang.index.603107-0')" type="warning" />
|
|
6
|
+
</template>
|
|
7
|
+
<template v-else>
|
|
8
|
+
<a-progress :percent="reportPercent" />
|
|
9
|
+
<div class="tip-box">
|
|
10
|
+
<div class="tip" v-if="successLanguages.length">
|
|
11
|
+
{{ t("ReportLang.index.603107-1") }}
|
|
12
|
+
{{ successLanguages.join(",") }}
|
|
13
|
+
</div>
|
|
14
|
+
<div class="tip" v-if="errorLanguages.length">
|
|
15
|
+
{{ t("ReportLang.index.603107-2") }} {{ errorLanguages.join(",") }}
|
|
16
|
+
</div>
|
|
17
|
+
</div>
|
|
18
|
+
</template>
|
|
19
|
+
</div>
|
|
20
|
+
</div>
|
|
21
|
+
</template>
|
|
22
|
+
<script>
|
|
23
|
+
import { defineComponent, onMounted, reactive, toRefs } from "vue";
|
|
24
|
+
import utils from "../../common/utils/util";
|
|
25
|
+
import { Progress, Alert } from "ant-design-vue";
|
|
26
|
+
import { t, loadLanguageAsync } from "../../locale";
|
|
27
|
+
|
|
28
|
+
export default defineComponent({
|
|
29
|
+
name: "reportLang",
|
|
30
|
+
props: {
|
|
31
|
+
// 上报语言配置 数组
|
|
32
|
+
langConfigArr: {
|
|
33
|
+
type: Array,
|
|
34
|
+
default: () => {
|
|
35
|
+
return [];
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
components: {
|
|
40
|
+
"a-progress": Progress,
|
|
41
|
+
"a-alert": Alert,
|
|
42
|
+
},
|
|
43
|
+
setup(props, { emit }) {
|
|
44
|
+
const batchSize = 500;
|
|
45
|
+
|
|
46
|
+
const state = reactive({
|
|
47
|
+
successLanguages: [], // 上报成功的语言列表
|
|
48
|
+
errorLanguages: [], // 上报失败的语言列表
|
|
49
|
+
totalSteps: 0,
|
|
50
|
+
reportPercent: 0,
|
|
51
|
+
systemToken: "", // 系统后台token
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
const isInIframe = window.parent !== window;
|
|
55
|
+
|
|
56
|
+
// 向父窗口发送消息
|
|
57
|
+
const sendMessageToParent = (type, data = {}) => {
|
|
58
|
+
if (isInIframe) {
|
|
59
|
+
try {
|
|
60
|
+
// 通过 JSON 序列化来清理数据,避免 DataCloneError
|
|
61
|
+
const message = {
|
|
62
|
+
type,
|
|
63
|
+
data: JSON.parse(JSON.stringify(data || {})),
|
|
64
|
+
};
|
|
65
|
+
if (window.parent && window.parent !== window) {
|
|
66
|
+
window.parent.postMessage(message, window.location.origin);
|
|
67
|
+
}
|
|
68
|
+
if (
|
|
69
|
+
window.top &&
|
|
70
|
+
window.top !== window &&
|
|
71
|
+
window.top !== window.parent
|
|
72
|
+
) {
|
|
73
|
+
window.top.postMessage(message, window.location.origin);
|
|
74
|
+
}
|
|
75
|
+
} catch (e) {
|
|
76
|
+
console.error("发送消息到父窗口失败", e);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
const roundUpToTwoDecimalPlaces = (num) => {
|
|
82
|
+
return Math.ceil(num * 100) / 100;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
const reportLang = (lang, locale, app) => {
|
|
86
|
+
return new Promise((resolve) => {
|
|
87
|
+
// 上报
|
|
88
|
+
emit("request", {
|
|
89
|
+
params: {
|
|
90
|
+
method: "post",
|
|
91
|
+
server: "/public",
|
|
92
|
+
url: "/system/lang/report",
|
|
93
|
+
extra: {
|
|
94
|
+
app,
|
|
95
|
+
lang,
|
|
96
|
+
lang_list: locale,
|
|
97
|
+
system_token: state.systemToken,
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
success: () => {
|
|
101
|
+
resolve("success");
|
|
102
|
+
},
|
|
103
|
+
fail: () => {
|
|
104
|
+
resolve("fail");
|
|
105
|
+
},
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
const setOriginData = async (lang) => {
|
|
111
|
+
let isSuccess = true;
|
|
112
|
+
// 每一种语言前进的百分比
|
|
113
|
+
let oneLangPercent = roundUpToTwoDecimalPlaces(100 / state.totalSteps);
|
|
114
|
+
let sendRequestTotal = 0; // 发送请求总次数
|
|
115
|
+
props.langConfigArr.forEach((v) => {
|
|
116
|
+
let allLocale = v?.langJsonMap || {};
|
|
117
|
+
let currentLocale = allLocale?.[lang];
|
|
118
|
+
// 把语言分成 500 一条发送
|
|
119
|
+
const keys = Object.keys(currentLocale);
|
|
120
|
+
const totalBatches = Math.ceil(keys.length / batchSize);
|
|
121
|
+
sendRequestTotal = sendRequestTotal + totalBatches;
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
// 每一步前进的百分比
|
|
125
|
+
let batchPercent = roundUpToTwoDecimalPlaces(
|
|
126
|
+
oneLangPercent / sendRequestTotal
|
|
127
|
+
);
|
|
128
|
+
|
|
129
|
+
for (let i = 0; i < props.langConfigArr.length; i++) {
|
|
130
|
+
let item = props.langConfigArr[i];
|
|
131
|
+
let reportApp = item.app;
|
|
132
|
+
let allLocale = item?.langJsonMap || {};
|
|
133
|
+
let currentLocale = allLocale?.[lang];
|
|
134
|
+
// 把语言分成 500 一条发送
|
|
135
|
+
const keys = Object.keys(currentLocale);
|
|
136
|
+
const totalBatches = Math.ceil(keys.length / batchSize);
|
|
137
|
+
for (let i = 0; i < totalBatches; i++) {
|
|
138
|
+
// 获取当前批次的键
|
|
139
|
+
const batchKeys = keys.slice(i * batchSize, (i + 1) * batchSize);
|
|
140
|
+
// 构建当前批次的对象
|
|
141
|
+
const batchObject = batchKeys.reduce((acc, key) => {
|
|
142
|
+
acc[key] = currentLocale[key];
|
|
143
|
+
return acc;
|
|
144
|
+
}, {});
|
|
145
|
+
// 分批发送到后端
|
|
146
|
+
let resolveRes = await reportLang(lang, batchObject, reportApp);
|
|
147
|
+
state.reportPercent = utils.countSum([
|
|
148
|
+
Number(state.reportPercent),
|
|
149
|
+
Number(batchPercent),
|
|
150
|
+
]);
|
|
151
|
+
// 批量上报模式:发送进度消息
|
|
152
|
+
sendMessageToParent("REPORT_PROGRESS", {
|
|
153
|
+
percent: state.reportPercent,
|
|
154
|
+
successLanguages: state.successLanguages,
|
|
155
|
+
errorLanguages: state.errorLanguages,
|
|
156
|
+
});
|
|
157
|
+
if (resolveRes == "fail") {
|
|
158
|
+
isSuccess = false;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
if (isSuccess) {
|
|
163
|
+
state.successLanguages = state.successLanguages.concat([lang]);
|
|
164
|
+
} else {
|
|
165
|
+
state.errorLanguages = state.errorLanguages.concat([lang]);
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
// 开始上报
|
|
170
|
+
const uploadLangArr = async (langArr) => {
|
|
171
|
+
for (let i = 0; i < langArr.length; i++) {
|
|
172
|
+
await setOriginData(langArr[i]);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// 批量上报模式:发送完成消息
|
|
176
|
+
sendMessageToParent("REPORT_COMPLETE", {
|
|
177
|
+
hasError: state.errorLanguages.length > 0,
|
|
178
|
+
successLanguages: state.successLanguages,
|
|
179
|
+
errorLanguages: state.errorLanguages,
|
|
180
|
+
});
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
const init = () => {
|
|
184
|
+
state.systemToken = localStorage.getItem('MICRO_systemMain_token');
|
|
185
|
+
if (!state.systemToken) {
|
|
186
|
+
// 批量上报模式:没有 token,发送错误消息
|
|
187
|
+
sendMessageToParent("REPORT_ERROR", {
|
|
188
|
+
message: "未登录或无权限",
|
|
189
|
+
});
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
// 开始上报
|
|
193
|
+
emit("request", {
|
|
194
|
+
params: {
|
|
195
|
+
method: "get",
|
|
196
|
+
server: "/public",
|
|
197
|
+
url: "/system/config",
|
|
198
|
+
extra: {
|
|
199
|
+
visitPort: "org",
|
|
200
|
+
},
|
|
201
|
+
},
|
|
202
|
+
success: (res) => {
|
|
203
|
+
let allLangJsonMap = props.langConfigArr.reduce((acc, obj) => {
|
|
204
|
+
return { ...acc, ...(obj?.langJsonMap || {}) };
|
|
205
|
+
}, {});
|
|
206
|
+
let openLanguage = res?.basic?.system_lang_map;
|
|
207
|
+
let langArr = [];
|
|
208
|
+
Object.keys(openLanguage).forEach((keys) => {
|
|
209
|
+
let lang = openLanguage[keys];
|
|
210
|
+
if (allLangJsonMap[lang]) {
|
|
211
|
+
langArr.push(lang);
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
state.totalSteps = langArr.length;
|
|
215
|
+
uploadLangArr(langArr);
|
|
216
|
+
},
|
|
217
|
+
fail: () => {
|
|
218
|
+
// 批量上报模式:配置获取失败
|
|
219
|
+
sendMessageToParent("REPORT_ERROR", {
|
|
220
|
+
message: "获取系统配置失败",
|
|
221
|
+
});
|
|
222
|
+
},
|
|
223
|
+
});
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
onMounted(() => {
|
|
227
|
+
// 批量上报模式:发送就绪消息
|
|
228
|
+
sendMessageToParent("REPORT_READY");
|
|
229
|
+
init();
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
loadLanguageAsync(utils.getLang());
|
|
233
|
+
|
|
234
|
+
window.addEventListener("setBLLang", (event) => {
|
|
235
|
+
const newLang = event.newValue; // 获取新的语言值
|
|
236
|
+
loadLanguageAsync(newLang);
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
return {
|
|
240
|
+
...toRefs(state),
|
|
241
|
+
t,
|
|
242
|
+
};
|
|
243
|
+
},
|
|
244
|
+
});
|
|
245
|
+
</script>
|
|
246
|
+
|
|
247
|
+
<style lang="less" scoped>
|
|
248
|
+
.progress-page {
|
|
249
|
+
width: 100%;
|
|
250
|
+
height: 100%;
|
|
251
|
+
display: flex;
|
|
252
|
+
justify-content: center;
|
|
253
|
+
align-items: center;
|
|
254
|
+
background: #fff;
|
|
255
|
+
}
|
|
256
|
+
.progress-box {
|
|
257
|
+
width: 50%;
|
|
258
|
+
display: flex;
|
|
259
|
+
flex-direction: column;
|
|
260
|
+
align-items: center;
|
|
261
|
+
}
|
|
262
|
+
.tip-box {
|
|
263
|
+
margin-top: 10px;
|
|
264
|
+
.tip {
|
|
265
|
+
padding-top: 8px;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
</style>
|
|
@@ -473,8 +473,18 @@ export default defineComponent({
|
|
|
473
473
|
};
|
|
474
474
|
|
|
475
475
|
/** 获取树数据 */
|
|
476
|
+
// 获取部门树中的项目总数
|
|
477
|
+
const getVillageCount = (list = []) => {
|
|
478
|
+
return list.reduce((count, item) => {
|
|
479
|
+
if (item.type === 3) {
|
|
480
|
+
return count;
|
|
481
|
+
}
|
|
482
|
+
return count + (item.villageList?.length || 0) + getVillageCount(item.subcat || []);
|
|
483
|
+
}, 0);
|
|
484
|
+
};
|
|
485
|
+
|
|
476
486
|
// 获取部门树列表
|
|
477
|
-
const getDeptTreeList = (list, level) => {
|
|
487
|
+
const getDeptTreeList = (list, level, totalVillageCount) => {
|
|
478
488
|
let result = [];
|
|
479
489
|
for (let listItem of list) {
|
|
480
490
|
// 非项目管理部门
|
|
@@ -486,7 +496,11 @@ export default defineComponent({
|
|
|
486
496
|
listItem.slotIcon = `${listItem.childType}Icon`;
|
|
487
497
|
listItem.children = [];
|
|
488
498
|
if (listItem.subcat && listItem.subcat.length) {
|
|
489
|
-
listItem.children = getDeptTreeList(
|
|
499
|
+
listItem.children = getDeptTreeList(
|
|
500
|
+
listItem.subcat,
|
|
501
|
+
level + 1,
|
|
502
|
+
totalVillageCount,
|
|
503
|
+
);
|
|
490
504
|
}
|
|
491
505
|
if (listItem.villageList && listItem.villageList.length) {
|
|
492
506
|
listItem.noVillage = 0
|
|
@@ -494,6 +508,7 @@ export default defineComponent({
|
|
|
494
508
|
listItem.villageList,
|
|
495
509
|
level,
|
|
496
510
|
listItem,
|
|
511
|
+
totalVillageCount,
|
|
497
512
|
);
|
|
498
513
|
listItem.children = [...listItem.children, ...villageList];
|
|
499
514
|
}else{
|
|
@@ -510,7 +525,12 @@ export default defineComponent({
|
|
|
510
525
|
return result;
|
|
511
526
|
};
|
|
512
527
|
// 获取项目树列表
|
|
513
|
-
const getVillageTreeList = (
|
|
528
|
+
const getVillageTreeList = (
|
|
529
|
+
villageList,
|
|
530
|
+
level = 1,
|
|
531
|
+
parentData = {},
|
|
532
|
+
totalVillageCount = villageList.length,
|
|
533
|
+
) => {
|
|
514
534
|
return villageList.map((village) => {
|
|
515
535
|
village.childType = "village";
|
|
516
536
|
village.key = `${parentData.key ? parentData.key + "-" : ""}${
|
|
@@ -607,7 +627,7 @@ export default defineComponent({
|
|
|
607
627
|
village.isLeaf = true;
|
|
608
628
|
village.disabled = props.isdisabledNumber ? ( props.isdisabledNumber == 2 ? false : true ) : false
|
|
609
629
|
}
|
|
610
|
-
if (
|
|
630
|
+
if (totalVillageCount === 1) {
|
|
611
631
|
state.expandedKeys.push(village.key);
|
|
612
632
|
}
|
|
613
633
|
if (!state.selectedKeys.length) {
|
|
@@ -671,9 +691,12 @@ export default defineComponent({
|
|
|
671
691
|
},
|
|
672
692
|
},
|
|
673
693
|
success: (res) => {
|
|
694
|
+
const totalVillageCount = res.list
|
|
695
|
+
? getVillageCount(res.list)
|
|
696
|
+
: res.villageList?.length || 0;
|
|
674
697
|
state.treeList = res.list
|
|
675
|
-
? getDeptTreeList(res.list, 1)
|
|
676
|
-
: getVillageTreeList(res.villageList);
|
|
698
|
+
? getDeptTreeList(res.list, 1, totalVillageCount)
|
|
699
|
+
: getVillageTreeList(res.villageList, 1, {}, totalVillageCount);
|
|
677
700
|
state.loadingTree = false;
|
|
678
701
|
state.treeList[0].disabled = props.isdisabledNumber ? true : false
|
|
679
702
|
if (props.setFirst&&state.treeList.length&&state.treeList[0].children){
|