agilebuilder-ui 1.0.621 → 1.0.962
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/lib/super-ui.css +1 -1
- package/lib/super-ui.js +115880 -110424
- package/lib/super-ui.umd.cjs +103 -95
- package/package.json +6 -3
- package/packages/department-tree/src/department-tree.vue +27 -10
- package/packages/department-tree-inline/src/department-tree-service.js +20 -41
- package/packages/department-tree-mobile/src/department-tree-app.vue +6 -6
- package/packages/department-tree-mobile/src/department-tree-inline-app.vue +15 -15
- package/packages/department-user-tree/src/department-user-tree.vue +17 -2
- package/packages/department-user-tree-inline/src/department-user-multiple-tree-inline.vue +61 -26
- package/packages/department-user-tree-inline/src/department-user-single-tree-inline.vue +64 -22
- package/packages/department-user-tree-inline/src/department-user-tree-single-service.js +0 -6
- package/packages/department-user-tree-inline/src/group-user/group-input.vue +162 -0
- package/packages/department-user-tree-inline/src/group-user/group-list.vue +99 -0
- package/packages/department-user-tree-inline/src/group-user/group-user.vue +42 -0
- package/packages/department-user-tree-inline/src/group-user-multiple-tree.vue +304 -0
- package/packages/department-user-tree-inline/src/group-user-single-tree.vue +155 -0
- package/packages/department-user-tree-inline/src/group-user-tree-service.js +74 -0
- package/packages/department-user-tree-inline/src/search-result.vue +34 -36
- package/packages/department-user-tree-mobile/src/department-user-tree-app.vue +6 -6
- package/packages/department-user-tree-mobile/src/department-user-tree-inline-app.vue +17 -19
- package/packages/department-user-tree-mobile/src/department-user-tree-service.ts +0 -11
- package/packages/dynamic-source-select/src/dynamic-source-select.vue +795 -799
- package/packages/dynamic-source-select/src/events.js +11 -16
- package/packages/fs-upload-list/src/fs-upload-list.vue +183 -122
- package/packages/fs-upload-new/src/file-upload-mobile/file-upload-app.vue +246 -0
- package/packages/fs-upload-new/src/file-upload-mobile/file-upload-browser.vue +480 -0
- package/packages/fs-upload-new/src/file-upload-mobile/file-upload-component.vue +127 -0
- package/packages/fs-upload-new/src/file-upload-mobile/file-upload-input.vue +246 -0
- package/packages/fs-upload-new/src/file-upload-mobile/file-upload.vue +255 -0
- package/packages/fs-upload-new/src/fs-button-upload.vue +10 -13
- package/packages/fs-upload-new/src/fs-drag-upload.vue +4 -8
- package/packages/fs-upload-new/src/fs-preview-new.vue +103 -36
- package/packages/fs-upload-new/src/fs-upload-new.vue +160 -13
- package/packages/index.js +11 -2
- package/packages/organization-input/src/organization-input.vue +493 -539
- package/packages/plugins/export-data-new.js +34 -1
- package/packages/rich-editor/index.vue +29 -0
- package/packages/row-form/index.js +7 -0
- package/packages/row-form/index.vue +211 -0
- package/packages/scan-code-input/src/scan-code-input.vue +136 -104
- package/packages/scan-code-input-browser/index.js +6 -0
- package/packages/{scan-code-input/src/scan-code-input-colse.vue → scan-code-input-browser/src/scan-code-input.vue} +1 -28
- package/packages/secret-info/index.vue +2 -2
- package/packages/super-grid/src/apis.js +158 -10
- package/packages/super-grid/src/components/grid-icon.vue +7 -14
- package/packages/super-grid/src/components/hyperlinks.vue +24 -8
- package/packages/super-grid/src/custom-formatter.js +312 -380
- package/packages/super-grid/src/dynamic-input.vue +346 -43
- package/packages/super-grid/src/formValidatorUtil.js +79 -15
- package/packages/super-grid/src/group-column.vue +5 -0
- package/packages/super-grid/src/normal-column-content.vue +1056 -0
- package/packages/super-grid/src/normal-column.vue +57 -740
- package/packages/super-grid/src/row-detail.vue +50 -0
- package/packages/super-grid/src/row-operation.vue +19 -10
- package/packages/super-grid/src/scan-util.ts +243 -0
- package/packages/super-grid/src/search-button.vue +18 -14
- package/packages/super-grid/src/search-form-advancedQuery.vue +9 -2
- package/packages/super-grid/src/search-form-item.vue +10 -3
- package/packages/super-grid/src/search-form-mobile.vue +250 -0
- package/packages/super-grid/src/search-form.vue +159 -82
- package/packages/super-grid/src/super-grid-service.js +51 -6
- package/packages/super-grid/src/super-grid.vue +657 -761
- package/packages/super-grid/src/utils.js +126 -170
- package/packages/super-nine-grid/src/super-nine-grid.vue +1032 -1141
- package/packages/workflow-button/src/workflow-button.vue +6 -1
- package/packages/workgroup-tree/src/workgroup-tree.vue +31 -0
- package/packages/workgroup-tree-inline/src/workgroup-tree-inline.vue +28 -0
- package/packages/workgroup-tree-inline/src/workgroup-tree-service.js +26 -0
- package/packages/workgroup-tree-mobile/index.js +6 -0
- package/packages/workgroup-tree-mobile/src/dept-result.vue +51 -0
- package/packages/workgroup-tree-mobile/src/workgroup-tree-app.vue +120 -0
- package/packages/workgroup-tree-mobile/src/workgroup-tree-inline-app.vue +375 -0
- package/packages/workgroup-tree-mobile/src/workgroup-tree-service.ts +62 -0
- package/packages/workgroup-user-tree/src/workgroup-user-tree.vue +15 -0
- package/packages/workgroup-user-tree-inline/src/workgroup-tree-inline-service.js +27 -0
- package/packages/workgroup-user-tree-inline/src/workgroup-user-tree-inline.vue +11 -0
- package/packages/workgroup-user-tree-mobile/index.js +6 -0
- package/packages/workgroup-user-tree-mobile/src/dept-path.vue +36 -0
- package/packages/workgroup-user-tree-mobile/src/dept-result.vue +58 -0
- package/packages/workgroup-user-tree-mobile/src/workgroup-user-tree-app.vue +119 -0
- package/packages/workgroup-user-tree-mobile/src/workgroup-user-tree-inline-app.vue +394 -0
- package/packages/workgroup-user-tree-mobile/src/workgroup-user-tree-service.ts +41 -0
- package/src/api/sso-service.js +44 -15
- package/src/directives/permission/permission.js +4 -3
- package/src/i18n/langs/cn.js +19 -3
- package/src/i18n/langs/en.js +18 -2
- package/src/permission.js +114 -122
- package/src/store/modules/user.js +32 -33
- package/src/styles/index.scss +1 -0
- package/src/styles/table.scss +12 -0
- package/src/styles/theme/dark-blue/button.scss +2 -2
- package/src/styles/theme/dark-blue/index.scss +1 -1
- package/src/styles/theme/dark-blue/sidebar.scss +10 -0
- package/src/styles/theme/dark-blue/table.scss +8 -52
- package/src/styles/theme/green/button.scss +2 -2
- package/src/styles/theme/green/green.scss +1 -1
- package/src/styles/theme/green/index.scss +1 -1
- package/src/styles/theme/green/sidebar.scss +20 -0
- package/src/styles/theme/green/table.scss +7 -51
- package/src/styles/theme/ocean-blue/button.scss +2 -2
- package/src/styles/theme/ocean-blue/index.scss +1 -1
- package/src/styles/theme/ocean-blue/ocean-blue.scss +1 -1
- package/src/styles/theme/ocean-blue/sidebar.scss +10 -0
- package/src/styles/theme/ocean-blue/table.scss +7 -52
- package/src/utils/auth.js +23 -3
- package/src/utils/calculator/calculator-factory.js +4 -4
- package/src/utils/calculator/calculator-util.js +14 -0
- package/src/utils/common-util.js +270 -124
- package/src/utils/i18n-util.js +145 -0
- package/src/utils/jump-page-utils.js +245 -314
- package/src/utils/permission.js +7 -1
- package/src/utils/permissionAuth.js +155 -37
- package/src/utils/request.js +10 -11
- package/src/utils/util.js +154 -205
- package/src/views/layout/EmptyLayout.vue +1 -1
- package/src/views/layout/components/Menubar/Item.vue +27 -4
- package/src/views/layout/components/Menubar/SidebarItem.vue +7 -3
- package/src/views/layout/components/Menubar/index.vue +14 -2
- package/src/views/layout/tab-content-index.vue +1 -1
package/src/utils/common-util.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import * as Vue from 'vue'
|
|
2
2
|
import authApi from './auth-api'
|
|
3
3
|
import { getToken, getLanguage, getAllLanguages, setAllLanguages } from './auth'
|
|
4
|
+
import { v4 as uuidv4 } from 'uuid'
|
|
5
|
+
import { getCookieCache } from './auth'
|
|
6
|
+
import i18nUtil from './i18n-util'
|
|
4
7
|
/**
|
|
5
8
|
* 获得相对地址
|
|
6
9
|
*/
|
|
@@ -21,9 +24,7 @@ export function getRelativeBaseUrl(originalBaseUrl) {
|
|
|
21
24
|
if (baseUrls.length >= 3) {
|
|
22
25
|
const baseUrlPrefix = baseUrls[0] + '//' + baseUrls[2]
|
|
23
26
|
// console.log('getRelativeBaseUrl---baseUrlPrefix=',baseUrlPrefix)
|
|
24
|
-
baseUrlSuffix = originalBaseUrl.substring(
|
|
25
|
-
originalBaseUrl.indexOf(baseUrlPrefix) + baseUrlPrefix.length
|
|
26
|
-
)
|
|
27
|
+
baseUrlSuffix = originalBaseUrl.substring(originalBaseUrl.indexOf(baseUrlPrefix) + baseUrlPrefix.length)
|
|
27
28
|
// console.log('getRelativeBaseUrl---baseUrlSuffix=',baseUrlSuffix)
|
|
28
29
|
}
|
|
29
30
|
if (relativeUrl.lastIndexOf('/') === relativeUrl.length - 1) {
|
|
@@ -82,19 +83,14 @@ export function replacePrefix(originalUrl) {
|
|
|
82
83
|
// console.log('replacePrefix---locationPrefixUrl=',locationPrefixUrl)
|
|
83
84
|
if (orginalPrefixUrl !== locationPrefixUrl) {
|
|
84
85
|
// 获得/demo/#/notice/task需要替换为http://127.0.0.1/demo/#/notice/task
|
|
85
|
-
let suffixUrl = originalUrl.substring(
|
|
86
|
-
originalUrl.indexOf(orginalPrefixUrl) + orginalPrefixUrl.length
|
|
87
|
-
)
|
|
86
|
+
let suffixUrl = originalUrl.substring(originalUrl.indexOf(orginalPrefixUrl) + orginalPrefixUrl.length)
|
|
88
87
|
if (suffixUrl.indexOf('/') !== 0) {
|
|
89
88
|
suffixUrl = '/' + suffixUrl
|
|
90
89
|
}
|
|
91
90
|
// console.log('replacePrefix---suffixUrl=',suffixUrl)
|
|
92
91
|
if (locationPrefixUrl.lastIndexOf('/') === locationPrefixUrl.length - 1) {
|
|
93
92
|
// 表示以“/”结尾,去掉最后一个“/”
|
|
94
|
-
locationPrefixUrl = locationPrefixUrl.substring(
|
|
95
|
-
0,
|
|
96
|
-
locationPrefixUrl.lastIndexOf('/')
|
|
97
|
-
)
|
|
93
|
+
locationPrefixUrl = locationPrefixUrl.substring(0, locationPrefixUrl.lastIndexOf('/'))
|
|
98
94
|
}
|
|
99
95
|
// console.log('replacePrefix---locationPrefixUrl2=',locationPrefixUrl)
|
|
100
96
|
newUrl = locationPrefixUrl + suffixUrl
|
|
@@ -128,17 +124,28 @@ export function getLoginUrl() {
|
|
|
128
124
|
routerPath = suffix.substring(0, suffix.indexOf('?'))
|
|
129
125
|
param = suffix.substring(suffix.indexOf('?') + 1)
|
|
130
126
|
}
|
|
127
|
+
} else {
|
|
128
|
+
systemPath = null
|
|
131
129
|
}
|
|
132
130
|
getPortalFrontendUrl()
|
|
133
131
|
.then((portalUrl) => {
|
|
134
|
-
let loginUrl =
|
|
135
|
-
|
|
136
|
-
'
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
132
|
+
let loginUrl = portalUrl + '#/login'
|
|
133
|
+
if (systemPath) {
|
|
134
|
+
loginUrl = loginUrl + '?systemPath=' + systemPath
|
|
135
|
+
}
|
|
136
|
+
if (routerPath) {
|
|
137
|
+
if (loginUrl.indexOf('?') > 0) {
|
|
138
|
+
loginUrl = loginUrl + '&routerPath=' + routerPath
|
|
139
|
+
} else {
|
|
140
|
+
loginUrl = loginUrl + '?routerPath=' + routerPath
|
|
141
|
+
}
|
|
142
|
+
}
|
|
140
143
|
if (param) {
|
|
141
|
-
loginUrl
|
|
144
|
+
if (loginUrl.indexOf('?') > 0) {
|
|
145
|
+
loginUrl = loginUrl + '&' + param
|
|
146
|
+
} else {
|
|
147
|
+
loginUrl = loginUrl + '?' + param
|
|
148
|
+
}
|
|
142
149
|
}
|
|
143
150
|
loginUrl = replacePrefix(loginUrl)
|
|
144
151
|
resolve(loginUrl)
|
|
@@ -170,8 +177,7 @@ export function isShowSystemMenu() {
|
|
|
170
177
|
export function getSystemFrontendUrl(frontendUrl) {
|
|
171
178
|
if (
|
|
172
179
|
window.$vueApp.config.globalProperties.projectModel &&
|
|
173
|
-
window.$vueApp.config.globalProperties.projectModel ===
|
|
174
|
-
'developing.model' &&
|
|
180
|
+
window.$vueApp.config.globalProperties.projectModel === 'developing.model' &&
|
|
175
181
|
window.$vueApp.config.globalProperties.frontUrl
|
|
176
182
|
) {
|
|
177
183
|
return window.$vueApp.config.globalProperties.frontUrl
|
|
@@ -183,8 +189,7 @@ export function getSystemFrontendUrl(frontendUrl) {
|
|
|
183
189
|
export function getSystemBackendUrl(backendUrl) {
|
|
184
190
|
if (
|
|
185
191
|
window.$vueApp.config.globalProperties.projectModel &&
|
|
186
|
-
window.$vueApp.config.globalProperties.projectModel ===
|
|
187
|
-
'developing.model' &&
|
|
192
|
+
window.$vueApp.config.globalProperties.projectModel === 'developing.model' &&
|
|
188
193
|
window.$vueApp.config.globalProperties.baseURL
|
|
189
194
|
) {
|
|
190
195
|
return window.$vueApp.config.globalProperties.baseURL
|
|
@@ -262,16 +267,12 @@ export function getTimeZone() {
|
|
|
262
267
|
const dateStr = new Date() + ''
|
|
263
268
|
let timeZone = ''
|
|
264
269
|
if (dateStr.indexOf('GMT') > 0) {
|
|
265
|
-
const timeZoneSuffix = dateStr
|
|
266
|
-
.substring(dateStr.indexOf('GMT') + 3, dateStr.indexOf('('))
|
|
267
|
-
.trim()
|
|
270
|
+
const timeZoneSuffix = dateStr.substring(dateStr.indexOf('GMT') + 3, dateStr.indexOf('(')).trim()
|
|
268
271
|
const partPrefix = timeZoneSuffix.substring(0, timeZoneSuffix.length - 2)
|
|
269
272
|
const partSuffix = timeZoneSuffix.substring(timeZoneSuffix.length - 2)
|
|
270
273
|
timeZone = 'UTC' + partPrefix + ':' + partSuffix
|
|
271
274
|
} else if (dateStr.indexOf('UTC') > 0) {
|
|
272
|
-
timeZone =
|
|
273
|
-
'UTC' +
|
|
274
|
-
dateStr.substring(dateStr.indexOf('UTC') + 3, dateStr.indexOf('(')).trim()
|
|
275
|
+
timeZone = 'UTC' + dateStr.substring(dateStr.indexOf('UTC') + 3, dateStr.indexOf('(')).trim()
|
|
275
276
|
}
|
|
276
277
|
return timeZone
|
|
277
278
|
}
|
|
@@ -285,8 +286,7 @@ export function setCustomSystemBackendUrl(customSystem) {
|
|
|
285
286
|
// 表示是生产环境时,需要根据数据库配置获得对应的后端地址
|
|
286
287
|
const backendUrl = window.$authApi.getSystemCacheUrlByCode(customSystem)
|
|
287
288
|
if (backendUrl) {
|
|
288
|
-
window.$vueApp.config.globalProperties.baseURL =
|
|
289
|
-
getRelativeBaseUrl(backendUrl)
|
|
289
|
+
window.$vueApp.config.globalProperties.baseURL = getRelativeBaseUrl(backendUrl)
|
|
290
290
|
}
|
|
291
291
|
}
|
|
292
292
|
}
|
|
@@ -304,13 +304,13 @@ export function pushCustomControlValidatorRef(pageCode, refName, ref) {
|
|
|
304
304
|
pageCustomControlRef.set(refName, ref)
|
|
305
305
|
}
|
|
306
306
|
|
|
307
|
-
export function removeCustomControlValidatorRef
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
307
|
+
export function removeCustomControlValidatorRef(pageCode, refName) {
|
|
308
|
+
if (window.customValidatorRef) {
|
|
309
|
+
const pageCustomControlRef = window.customValidatorRef.get(pageCode)
|
|
310
|
+
if (pageCustomControlRef) {
|
|
311
|
+
pageCustomControlRef.delete(refName)
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
314
|
}
|
|
315
315
|
|
|
316
316
|
export function isMobileBrowser() {
|
|
@@ -328,15 +328,7 @@ export function isMobileBrowser() {
|
|
|
328
328
|
}
|
|
329
329
|
|
|
330
330
|
export function getLocaleByLang(lang) {
|
|
331
|
-
|
|
332
|
-
if (lang && lang.indexOf('_') > 0) {
|
|
333
|
-
const language = lang.substring(0, lang.indexOf('_'))
|
|
334
|
-
locale = language
|
|
335
|
-
}
|
|
336
|
-
if (locale === 'zh') {
|
|
337
|
-
locale = 'cn'
|
|
338
|
-
}
|
|
339
|
-
return locale
|
|
331
|
+
return i18nUtil.getLocaleByLang(lang)
|
|
340
332
|
}
|
|
341
333
|
|
|
342
334
|
export function cacheLangs(langs) {
|
|
@@ -378,33 +370,28 @@ export function cacheAllLanguagesUtil(http) {
|
|
|
378
370
|
setAllLanguages(cookieCacheLangs)
|
|
379
371
|
resolve()
|
|
380
372
|
} else {
|
|
381
|
-
http
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
})
|
|
404
|
-
}
|
|
405
|
-
cacheLangs(langResult)
|
|
406
|
-
resolve()
|
|
407
|
-
})
|
|
373
|
+
http.get(window.$vueApp.config.globalProperties.baseAPI + '/component/all-languages').then((langList) => {
|
|
374
|
+
const langResult = {}
|
|
375
|
+
if (langList) {
|
|
376
|
+
langList.forEach((item) => {
|
|
377
|
+
// 例如:zh_CN、en_US
|
|
378
|
+
const lang = item.value
|
|
379
|
+
let langShort
|
|
380
|
+
if (lang.indexOf('_') > 0) {
|
|
381
|
+
langShort = lang.substring(0, lang.indexOf('_'))
|
|
382
|
+
}
|
|
383
|
+
if (langShort && langShort === 'zh') {
|
|
384
|
+
// 中文处理,为了兼容历史逻辑
|
|
385
|
+
langShort = 'cn'
|
|
386
|
+
}
|
|
387
|
+
if (langShort) {
|
|
388
|
+
langResult[langShort] = lang
|
|
389
|
+
}
|
|
390
|
+
})
|
|
391
|
+
}
|
|
392
|
+
cacheLangs(langResult)
|
|
393
|
+
resolve()
|
|
394
|
+
})
|
|
408
395
|
}
|
|
409
396
|
} else {
|
|
410
397
|
resolve()
|
|
@@ -436,8 +423,8 @@ export function windowOpenUrl(url, projectModel) {
|
|
|
436
423
|
// _systemName_参数用于设置浏览器页签名的,国际化使用,在imatrix ui的beforeEach中有使用这个参数
|
|
437
424
|
if (param) {
|
|
438
425
|
jumpUrl += '&' + param
|
|
439
|
-
|
|
440
|
-
|
|
426
|
+
}
|
|
427
|
+
if (jumpUrl.indexOf('_systemName_=') === -1) {
|
|
441
428
|
jumpUrl += '&_systemName_=' + systemName
|
|
442
429
|
}
|
|
443
430
|
window.open(jumpUrl)
|
|
@@ -454,75 +441,234 @@ export function windowOpenUrl(url, projectModel) {
|
|
|
454
441
|
}
|
|
455
442
|
}
|
|
456
443
|
|
|
457
|
-
|
|
458
444
|
// 首次加载业务系统时,缓存当前用户语言
|
|
459
445
|
export function cacheCurrentLanguageUtil(http) {
|
|
460
446
|
return new Promise((resolve, reject) => {
|
|
461
447
|
const token = getToken()
|
|
462
|
-
if (token) {
|
|
463
|
-
|
|
464
|
-
|
|
448
|
+
if (!token) {
|
|
449
|
+
// 默认是中文
|
|
450
|
+
resolve('zh_CN')
|
|
451
|
+
}
|
|
452
|
+
const currentLanguage = getLanguage()
|
|
453
|
+
const systemCode = getCurrentSystemCode()
|
|
454
|
+
if (isPlateSys(systemCode)) {
|
|
455
|
+
// 平台系统不需要加载国际化文件
|
|
456
|
+
if (currentLanguage && currentLanguage !== 'undefined') {
|
|
465
457
|
resolve(currentLanguage)
|
|
466
458
|
} else {
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
459
|
+
// 如果没有缓存当前用户的语言,则需要获取
|
|
460
|
+
const params = { systemCode: systemCode }
|
|
461
|
+
http
|
|
462
|
+
.post(window.$vueApp.config.globalProperties.baseAPI + '/acs/user/i18n-languages', params)
|
|
463
|
+
.then((langInfo) => {
|
|
464
|
+
resolve(langInfo.language ? langInfo.language : 'zh_CN')
|
|
465
|
+
})
|
|
466
|
+
.catch(() => {
|
|
467
|
+
resolve('zh_CN')
|
|
468
|
+
})
|
|
470
469
|
}
|
|
471
470
|
} else {
|
|
472
|
-
//
|
|
473
|
-
|
|
471
|
+
// 业务系统是否启用了国际化
|
|
472
|
+
const enableI18n = i18nUtil.getEnableI18nState(systemCode)
|
|
473
|
+
if (enableI18n === false && currentLanguage && currentLanguage !== 'undefined') {
|
|
474
|
+
// 如果没有开启国际化, 并且已经缓存了当前用户的语言,则直接返回
|
|
475
|
+
resolve(currentLanguage)
|
|
476
|
+
} else {
|
|
477
|
+
// 启用了国际化并且当前已经加载过了国际化json文件,则需要检查是否是最新的国际化文件
|
|
478
|
+
// 没有加载过国际化文件,则不用传递checkLastestI18nFile参数,后台会返回最新的国际化文件路径和用户当前语言
|
|
479
|
+
let url = i18nUtil.getLangFileUrl(systemCode, currentLanguage)
|
|
480
|
+
const params = { systemCode: systemCode }
|
|
481
|
+
if (url && currentLanguage && currentLanguage !== 'undefined' && enableI18n) {
|
|
482
|
+
params.checkLastestI18nFile = true
|
|
483
|
+
params.i18nFileVersion = i18nUtil.getI18nFileVersion()
|
|
484
|
+
}
|
|
485
|
+
http
|
|
486
|
+
.post(window.$vueApp.config.globalProperties.baseAPI + '/acs/user/i18n-languages', params)
|
|
487
|
+
.then((langInfo) => {
|
|
488
|
+
const i18nCurrentVersion = i18nUtil.getI18nFileVersion()
|
|
489
|
+
i18nUtil.setI18nFileVersion(langInfo.i18nFileVersion)
|
|
490
|
+
if (!url && langInfo.i18nFileUrls[langInfo.language]) {
|
|
491
|
+
url = langInfo.i18nFileUrls[langInfo.language] + '?_t_=' + new Date().getTime()
|
|
492
|
+
i18nUtil.setLangFileUrl(systemCode, langInfo.language, url)
|
|
493
|
+
}
|
|
494
|
+
if (i18nCurrentVersion && Number(i18nCurrentVersion) === langInfo.i18nFileVersion) {
|
|
495
|
+
// 表示是最新的国际化文件,可以直接加载使用
|
|
496
|
+
i18nUtil
|
|
497
|
+
.loadLangFile(systemCode, url, currentLanguage)
|
|
498
|
+
.then(() => {
|
|
499
|
+
resolve(currentLanguage)
|
|
500
|
+
})
|
|
501
|
+
.catch(() => {
|
|
502
|
+
resolve(currentLanguage)
|
|
503
|
+
})
|
|
504
|
+
} else {
|
|
505
|
+
// 不是最新的国际化文件或者没有加载过国际化文件,则后端会返回最新的国际化文件路径和用户当前语言
|
|
506
|
+
i18nUtil.setEnableI18nState(systemCode, langInfo.enableI18n ? true : false)
|
|
507
|
+
if (langInfo.enableI18n && langInfo.i18nFileUrls[langInfo.language]) {
|
|
508
|
+
const url = langInfo.i18nFileUrls[langInfo.language] + '?_t_=' + new Date().getTime()
|
|
509
|
+
i18nUtil.setLangFileUrl(systemCode, langInfo.language, url)
|
|
510
|
+
i18nUtil
|
|
511
|
+
.loadLangFile(systemCode, url, langInfo.language)
|
|
512
|
+
.then(() => {
|
|
513
|
+
resolve(langInfo.language)
|
|
514
|
+
})
|
|
515
|
+
.catch(() => {
|
|
516
|
+
resolve(langInfo.language ? langInfo.language : 'zh_CN')
|
|
517
|
+
})
|
|
518
|
+
} else {
|
|
519
|
+
// 如果没有开启国际化
|
|
520
|
+
resolve(langInfo.language)
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
})
|
|
524
|
+
.catch(() => {
|
|
525
|
+
resolve('zh_CN')
|
|
526
|
+
})
|
|
527
|
+
}
|
|
474
528
|
}
|
|
475
529
|
})
|
|
476
530
|
}
|
|
531
|
+
|
|
532
|
+
async function handlePlateSysLang(currentLanguage) {
|
|
533
|
+
if (currentLanguage && currentLanguage !== 'undefined') {
|
|
534
|
+
return currentLanguage
|
|
535
|
+
} else {
|
|
536
|
+
const params = { systemCode: getCurrentSystemCode() }
|
|
537
|
+
try {
|
|
538
|
+
const langInfo = await http.post(
|
|
539
|
+
window.$vueApp.config.globalProperties.baseAPI + '/acs/user/i18n-languages',
|
|
540
|
+
params
|
|
541
|
+
)
|
|
542
|
+
return langInfo.language ? langInfo.language : 'zh_CN'
|
|
543
|
+
} catch {
|
|
544
|
+
return 'zh_CN'
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
|
|
477
549
|
export function setProjectSetting() {
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
550
|
+
const projectSettingCache = Cookies.get('PROJECT_SETTINGS')
|
|
551
|
+
let projectSettings = null
|
|
552
|
+
if (projectSettingCache) {
|
|
553
|
+
projectSettings = JSON.parse(projectSettingCache)
|
|
554
|
+
this.setLogoUrl(projectSettings)
|
|
555
|
+
} else {
|
|
556
|
+
this.$http.get(window.$vueApp.config.globalProperties.baseAPI + '/cfg/project-settings').then((data) => {
|
|
557
|
+
Cookies.set('PROJECT_SETTINGS', JSON.stringify(data))
|
|
558
|
+
projectSettings = data
|
|
559
|
+
})
|
|
560
|
+
}
|
|
561
|
+
if (projectSettings.browserImageUuid) {
|
|
562
|
+
const linkElement = document.getElementById('ambBrowserIcon')
|
|
563
|
+
if (linkElement) {
|
|
564
|
+
linkElement.href = window.$vueApp.config.globalProperties.baseAPI + '/cfg/project/icon/browserIcon'
|
|
565
|
+
}
|
|
566
|
+
}
|
|
495
567
|
}
|
|
496
568
|
|
|
497
569
|
// 动态加载css
|
|
498
570
|
export function loadCSS() {
|
|
499
571
|
var theme
|
|
500
|
-
|
|
501
|
-
|
|
572
|
+
if (!theme) {
|
|
573
|
+
theme = localStorage.getItem('CURRENT_THEME')
|
|
574
|
+
}
|
|
575
|
+
if (!theme) {
|
|
576
|
+
console.error('皮肤主题为空!')
|
|
577
|
+
return
|
|
578
|
+
}
|
|
579
|
+
const baseAPI = localStorage.getItem('_baseAPI_')
|
|
580
|
+
if (baseAPI) {
|
|
581
|
+
const href = replacePrefix(baseAPI) + '/component/theme/load-theme?theme=' + theme + '&_t_=' + new Date().getTime()
|
|
582
|
+
let isHasLink = true
|
|
583
|
+
let cssLink = document.getElementById('_loadTheme_')
|
|
584
|
+
if (!cssLink) {
|
|
585
|
+
cssLink = document.createElement('link')
|
|
586
|
+
isHasLink = false
|
|
502
587
|
}
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
588
|
+
cssLink.rel = 'stylesheet'
|
|
589
|
+
cssLink.type = 'text/css'
|
|
590
|
+
cssLink.id = '_loadTheme_'
|
|
591
|
+
cssLink.href = href
|
|
592
|
+
if (!isHasLink) {
|
|
593
|
+
document.getElementsByTagName('head')[0].appendChild(cssLink)
|
|
506
594
|
}
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
595
|
+
}
|
|
596
|
+
const body = document.querySelector('body')
|
|
597
|
+
if (body) {
|
|
598
|
+
body.setAttribute('class', theme)
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
/**
|
|
603
|
+
* 获取UUID,去掉破折号
|
|
604
|
+
* @returns
|
|
605
|
+
*/
|
|
606
|
+
export function getUuidv4() {
|
|
607
|
+
return uuidv4().replace(/-/g, '')
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
export function replacePlaceholders(template, ...args) {
|
|
611
|
+
return template.replace(/{(\d+)}/g, (match, index) => {
|
|
612
|
+
return typeof args[index] !== 'undefined' ? args[index] : match
|
|
613
|
+
})
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
function isOpenMobileGateway() {
|
|
617
|
+
// 系统参数设置中配置的是否开启移动网关,没有配置默认是开启的
|
|
618
|
+
let isOpenMobileGatewayCache = getCookieCache('IS_OPEN_MOBILE_GATEWAY')
|
|
619
|
+
if (isOpenMobileGatewayCache === undefined || isOpenMobileGatewayCache === null) {
|
|
620
|
+
isOpenMobileGatewayCache = 'true'
|
|
621
|
+
}
|
|
622
|
+
return isOpenMobileGatewayCache
|
|
623
|
+
}
|
|
624
|
+
/**
|
|
625
|
+
* 获得替换域名后的url
|
|
626
|
+
* @param {*} url
|
|
627
|
+
* @returns
|
|
628
|
+
*/
|
|
629
|
+
export function getReplaceUrlDomain(url) {
|
|
630
|
+
const isOpenMobileGatewayCache = isOpenMobileGateway()
|
|
631
|
+
console.log('===getReplaceUrlDomain==isOpenMobileGatewayCache=', isOpenMobileGatewayCache)
|
|
632
|
+
if (isOpenMobileGatewayCache === 'true' && url !== undefined && window.$vueApp.config.globalProperties.replaceUrl) {
|
|
633
|
+
// 表示需要替换url中的"https://域名"
|
|
634
|
+
const baseApi = uswindow.$vueApp.config.globalProperties.baseAPI
|
|
635
|
+
if (
|
|
636
|
+
(url + '').indexOf(uswindow.$vueApp.config.globalProperties.replaceUrl + '/') < 0 &&
|
|
637
|
+
(url + '').indexOf('://') > 0
|
|
638
|
+
) {
|
|
639
|
+
// 表示路径还未替换
|
|
640
|
+
console.log('===getReplaceUrlDomain==url.indexOf(uswindow.$vueApp.config.globalProperties.replaceUrl) !== 0')
|
|
641
|
+
const prefixUrl1 = baseApi.substring(0, baseApi.indexOf('://'))
|
|
642
|
+
const urlSuffix1 = baseApi.substring(baseApi.indexOf('://') + 3)
|
|
643
|
+
const domainUrl1 = urlSuffix1.substring(0, urlSuffix1.indexOf('/'))
|
|
644
|
+
const prefixUrlBase = prefixUrl1 + '://' + domainUrl1
|
|
645
|
+
const prefixUrl2 = baseApi.substring(0, baseApi.indexOf('://'))
|
|
646
|
+
let urlSuffix = url.substring(url.indexOf('://') + 3)
|
|
647
|
+
const domainUrl2 = urlSuffix.substring(0, urlSuffix.indexOf('/'))
|
|
648
|
+
const prefixUrl = prefixUrl2 + '://' + domainUrl2
|
|
649
|
+
if (prefixUrl === prefixUrlBase) {
|
|
650
|
+
urlSuffix = urlSuffix.substring(urlSuffix.indexOf('/'))
|
|
651
|
+
url = uswindow.$vueApp.config.globalProperties.replaceUrl + urlSuffix
|
|
652
|
+
console.log('===getReplaceUrlDomain==url=', url)
|
|
522
653
|
}
|
|
523
|
-
}
|
|
524
|
-
|
|
525
|
-
if(body){
|
|
526
|
-
body.setAttribute('class', theme)
|
|
654
|
+
} else {
|
|
655
|
+
console.log('===getReplaceUrlDomain==has-replace-url=', url)
|
|
527
656
|
}
|
|
528
657
|
}
|
|
658
|
+
return url
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
export function formatFileName(fileName) {
|
|
662
|
+
if (fileName) {
|
|
663
|
+
fileName = fileName.replace('#', '~~').replace('?', '~$').replace('&', '$')
|
|
664
|
+
}
|
|
665
|
+
return fileName
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
export function getCurrentSystemCode() {
|
|
669
|
+
if (window.$vueApp.config.globalProperties.currentSystem) {
|
|
670
|
+
return window.$vueApp.config.globalProperties.currentSystem
|
|
671
|
+
} else {
|
|
672
|
+
return window.$vueApp.config.globalProperties.systemCode
|
|
673
|
+
}
|
|
674
|
+
}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import axios from 'axios'
|
|
2
|
+
export function setLangFileUrl(systemCode, lang, url) {
|
|
3
|
+
let i18nFileUrlsItem = getLocalStorageJson('i18nFileUrls')
|
|
4
|
+
if (!i18nFileUrlsItem) {
|
|
5
|
+
i18nFileUrlsItem = {}
|
|
6
|
+
}
|
|
7
|
+
i18nFileUrlsItem[systemCode + '_' + lang] = url
|
|
8
|
+
window.localStorage.setItem('i18nFileUrls', JSON.stringify(i18nFileUrlsItem))
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function getLangFileUrl(systemCode, lang) {
|
|
12
|
+
const i18nFileUrlsItem = getLocalStorageJson('i18nFileUrls')
|
|
13
|
+
if (i18nFileUrlsItem) {
|
|
14
|
+
return i18nFileUrlsItem[systemCode + '_' + lang]
|
|
15
|
+
}
|
|
16
|
+
return null
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function removeLangFileUrl(systemCode, lang) {
|
|
20
|
+
const i18nFileUrlsItem = getLocalStorageJson('i18nFileUrls')
|
|
21
|
+
if (i18nFileUrlsItem) {
|
|
22
|
+
delete i18nFileUrlsItem[systemCode + '_' + lang]
|
|
23
|
+
window.localStorage.setItem('i18nFileUrls', JSON.stringify(i18nFileUrlsItem))
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function removeAllLangFileUrl(systemCode, lang) {
|
|
28
|
+
window.localStorage.removeItem('i18nFileUrls')
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function setEnableI18nState(systemCode, enableI18n) {
|
|
32
|
+
let allStateObj = {}
|
|
33
|
+
const allState = getLocalStorageJson('enableI18nSystem')
|
|
34
|
+
if (allState) {
|
|
35
|
+
allStateObj = allState
|
|
36
|
+
}
|
|
37
|
+
allStateObj[systemCode] = enableI18n ? true : false
|
|
38
|
+
window.localStorage.setItem('enableI18nSystem', JSON.stringify(allStateObj))
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function getEnableI18nState(systemCode) {
|
|
42
|
+
const allState = getLocalStorageJson('enableI18nSystem')
|
|
43
|
+
if (allState) {
|
|
44
|
+
return allState[systemCode]
|
|
45
|
+
}
|
|
46
|
+
return null
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export function removeEnableI18nState() {
|
|
50
|
+
window.localStorage.removeItem('enableI18nSystem')
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export function removeEnableI18nWidthSystemCode() {
|
|
54
|
+
const allState = getLocalStorageJson('enableI18nSystem')
|
|
55
|
+
if (allState) {
|
|
56
|
+
delete allState[getCurrentSystemCode()]
|
|
57
|
+
window.localStorage.setItem('enableI18nSystem', JSON.stringify(allState))
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function getLocalStorageJson(key) {
|
|
62
|
+
const item = window.localStorage.getItem(key)
|
|
63
|
+
if (item) {
|
|
64
|
+
return JSON.parse(item)
|
|
65
|
+
}
|
|
66
|
+
return null
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function loadLangFile(systemCode, url, language) {
|
|
70
|
+
console.log('loadLangFile', systemCode, url, language)
|
|
71
|
+
if (!url) {
|
|
72
|
+
return Promise.resolve()
|
|
73
|
+
}
|
|
74
|
+
return new Promise((resolve, reject) => {
|
|
75
|
+
if (window.$i18n) {
|
|
76
|
+
axios
|
|
77
|
+
.get(url, {
|
|
78
|
+
withCredential: false
|
|
79
|
+
})
|
|
80
|
+
.then((response) => {
|
|
81
|
+
const lang = getLocaleByLang(language)
|
|
82
|
+
if (response && response.data) {
|
|
83
|
+
// 获取当前的国际化信息
|
|
84
|
+
const currentMessages = window.$i18n.global.getLocaleMessage(lang)
|
|
85
|
+
// 新的国际化信息
|
|
86
|
+
if (currentMessages[systemCode]) {
|
|
87
|
+
Object.assign(currentMessages[systemCode], response.data)
|
|
88
|
+
} else {
|
|
89
|
+
currentMessages[systemCode] = response.data
|
|
90
|
+
}
|
|
91
|
+
// 设置合并后的国际化信息
|
|
92
|
+
window.$i18n.global.setLocaleMessage(lang, currentMessages)
|
|
93
|
+
}
|
|
94
|
+
resolve()
|
|
95
|
+
})
|
|
96
|
+
.catch((error) => {
|
|
97
|
+
reject(error)
|
|
98
|
+
})
|
|
99
|
+
}
|
|
100
|
+
resolve()
|
|
101
|
+
})
|
|
102
|
+
}
|
|
103
|
+
export function getLocaleByLang(lang) {
|
|
104
|
+
let locale = 'cn'
|
|
105
|
+
if (lang && lang.indexOf('_') > 0) {
|
|
106
|
+
const language = lang.substring(0, lang.indexOf('_'))
|
|
107
|
+
locale = language
|
|
108
|
+
}
|
|
109
|
+
if (locale === 'zh') {
|
|
110
|
+
locale = 'cn'
|
|
111
|
+
}
|
|
112
|
+
return locale
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function clearI18nCache(lang) {
|
|
116
|
+
removeEnableI18nState()
|
|
117
|
+
removeAllLangFileUrl()
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function setI18nFileVersion(version) {
|
|
121
|
+
window.localStorage.setItem('i18nFileVersion', version)
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function getI18nFileVersion() {
|
|
125
|
+
const version = window.localStorage.getItem('i18nFileVersion')
|
|
126
|
+
if (version === 'undefined' || version === 'null') {
|
|
127
|
+
return null
|
|
128
|
+
}
|
|
129
|
+
return window.localStorage.getItem('i18nFileVersion')
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export default {
|
|
133
|
+
setLangFileUrl,
|
|
134
|
+
getLangFileUrl,
|
|
135
|
+
removeLangFileUrl,
|
|
136
|
+
setEnableI18nState,
|
|
137
|
+
getEnableI18nState,
|
|
138
|
+
removeEnableI18nState,
|
|
139
|
+
removeEnableI18nWidthSystemCode,
|
|
140
|
+
getLocalStorageJson,
|
|
141
|
+
loadLangFile,
|
|
142
|
+
getLocaleByLang,
|
|
143
|
+
setI18nFileVersion,
|
|
144
|
+
getI18nFileVersion
|
|
145
|
+
}
|