resolver-egretimp-plus 0.0.33 → 0.0.35
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/dist/3/index.js +1 -1
- package/dist/h5/index.js +1 -1
- package/dist/web/index.js +1 -1
- package/package.json +1 -1
- package/src/components/helper/button.js +2 -4
- package/src/components/packages-web/ElButton.vue +2 -3
- package/src/hooks/pageConfig.js +3 -4
- package/src/resolver-common.vue +2 -1
- package/src/utils/render.jsx +1 -1
- package/src/utils/request.js +63 -60
- package/src/utils/respone.js +41 -0
package/package.json
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { getRelateConfigKeys } from "../../rules/ruleUtils"
|
|
2
|
+
import { resultToast } from "../../utils/respone"
|
|
2
3
|
import { openChildDialog } from "../childDialog"
|
|
3
4
|
|
|
4
5
|
export async function dispatchClickEvents ({serviceList = [], axiosInstance, dynamicMapComp, rootValue, dynamicHireRelat, messageInstance}) {
|
|
@@ -26,8 +27,7 @@ export async function dispatchClickEvent(service, { dynamicMapComp, rootValue, d
|
|
|
26
27
|
method: "post",
|
|
27
28
|
data: reqData
|
|
28
29
|
}))
|
|
29
|
-
if (!ret?.data
|
|
30
|
-
messageInstance?.value?.error(ret?.data?.resultMessage || '')
|
|
30
|
+
if (!resultToast(ret?.data, messageInstance)) {
|
|
31
31
|
await Promise.reject()
|
|
32
32
|
return
|
|
33
33
|
}
|
|
@@ -104,10 +104,8 @@ export function getTableConfig(outParamMappingList = [], { dynamicMapComp, dynam
|
|
|
104
104
|
export function openDailg({
|
|
105
105
|
pagePopupMap,
|
|
106
106
|
axiosInstance,
|
|
107
|
-
rootValue,
|
|
108
107
|
dynamicMapComp,
|
|
109
108
|
dynamicHireRelat,
|
|
110
|
-
messageInstance,
|
|
111
109
|
lang,
|
|
112
110
|
appContext,
|
|
113
111
|
}) {
|
|
@@ -44,6 +44,7 @@ const calcPorps = computed(() => {
|
|
|
44
44
|
if (props?.config?.displayType) {
|
|
45
45
|
ret.type = props?.config?.displayType
|
|
46
46
|
}
|
|
47
|
+
return ret
|
|
47
48
|
})
|
|
48
49
|
|
|
49
50
|
const attrs = useAttrs()
|
|
@@ -97,7 +98,7 @@ const buttonAction = (...arg) => {
|
|
|
97
98
|
rootValue: rootValue?.value,
|
|
98
99
|
dynamicMapComp,
|
|
99
100
|
dynamicHireRelat,
|
|
100
|
-
messageInstance
|
|
101
|
+
messageInstance: messageInstance?.value
|
|
101
102
|
})
|
|
102
103
|
}
|
|
103
104
|
const lcpPagePopupMapVO = props.config.lcpPagePopupMapVO
|
|
@@ -106,10 +107,8 @@ const buttonAction = (...arg) => {
|
|
|
106
107
|
openDailg({
|
|
107
108
|
pagePopupMap: lcpPagePopupMapVO,
|
|
108
109
|
axiosInstance: _axiosInstance,
|
|
109
|
-
rootValue: rootValue?.value,
|
|
110
110
|
dynamicMapComp,
|
|
111
111
|
dynamicHireRelat,
|
|
112
|
-
messageInstance,
|
|
113
112
|
appContext,
|
|
114
113
|
lang: lang?.value
|
|
115
114
|
})
|
package/src/hooks/pageConfig.js
CHANGED
|
@@ -4,6 +4,7 @@ import { buildInRequest } from "../utils/request"
|
|
|
4
4
|
import { GET_SYS_PARAM_CACHE, QUERY_PAGE_CONFIG_DATA } from "../api/builtIn"
|
|
5
5
|
import { normalPageConfigs } from "../components/helper/resolver"
|
|
6
6
|
import mock from "./mock"
|
|
7
|
+
import { resultToast } from "../utils/respone"
|
|
7
8
|
|
|
8
9
|
export function usePageConfig() {
|
|
9
10
|
const pageConfigRef = ref(null)
|
|
@@ -46,14 +47,13 @@ export function useBuildInData(messageTipInstance, loadingInstance) {
|
|
|
46
47
|
loadingInstance.show()
|
|
47
48
|
}
|
|
48
49
|
buildInRequest(QUERY_PAGE_CONFIG_DATA, reqData).then(ret => {
|
|
49
|
-
if (ret.data
|
|
50
|
+
if (resultToast(ret.data, messageTipInstance)) {
|
|
50
51
|
// pageConfig.value = normalPageConfigs(mock)
|
|
51
52
|
pageConfig.value = normalPageConfigs(ret.data.result)
|
|
52
53
|
cb(pageConfig.value)
|
|
53
54
|
getSelects(ret.data.result?.pmBusinessIdentityVO?.tenantId)
|
|
54
55
|
return
|
|
55
56
|
}
|
|
56
|
-
messageTipInstance?.error(ret.data.resultMessage)
|
|
57
57
|
}).catch(() => {
|
|
58
58
|
if (loadingInstance.finish && typeof loadingInstance.finish === 'function') {
|
|
59
59
|
loadingInstance.finish()
|
|
@@ -67,11 +67,10 @@ export function useBuildInData(messageTipInstance, loadingInstance) {
|
|
|
67
67
|
buildInRequest(GET_SYS_PARAM_CACHE, {
|
|
68
68
|
tenantId
|
|
69
69
|
}).then(ret => {
|
|
70
|
-
if (ret.data
|
|
70
|
+
if (resultToast(ret.data, messageTipInstance)) {
|
|
71
71
|
selects.value = JSON.parse(ret.data.result || '{}')
|
|
72
72
|
return
|
|
73
73
|
}
|
|
74
|
-
messageTipInstance?.error(ret.data.resultMessage)
|
|
75
74
|
}).finally(() => {
|
|
76
75
|
if (loadingInstance.finish && typeof loadingInstance.finish === 'function') {
|
|
77
76
|
loadingInstance.finish()
|
package/src/resolver-common.vue
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { computed, useAttrs } from 'vue';
|
|
3
3
|
import Resolver from './index.jsx'
|
|
4
4
|
import { useBuildInData } from './hooks/pageConfig';
|
|
5
|
+
import { initInterceptors } from './utils/request.js';
|
|
5
6
|
|
|
6
7
|
const props = defineProps({
|
|
7
8
|
busiIdentityId: String,
|
|
@@ -26,7 +27,7 @@ defineOptions({
|
|
|
26
27
|
inheritAttrs: false
|
|
27
28
|
})
|
|
28
29
|
const attrs = useAttrs()
|
|
29
|
-
|
|
30
|
+
initInterceptors(props.messageInstance)
|
|
30
31
|
const { getPageConfig, pageConfig, selects } = useBuildInData(props.messageInstance, props.loadingInstance)
|
|
31
32
|
getPageConfig({
|
|
32
33
|
busiIdentityId: props.busiIdentityId,
|
package/src/utils/render.jsx
CHANGED
|
@@ -204,7 +204,7 @@ export function normalConfig({
|
|
|
204
204
|
pageConfig.type = 'daterange'
|
|
205
205
|
}
|
|
206
206
|
if (config.metaType == 'card') {
|
|
207
|
-
pageConfig.needWrap = '
|
|
207
|
+
pageConfig.needWrap = '1'
|
|
208
208
|
}
|
|
209
209
|
mapComp[hireRelat] = pageConfig
|
|
210
210
|
parsePolyfillConfigs({ polyfillConfigs, instance }, pageConfig)
|
package/src/utils/request.js
CHANGED
|
@@ -4,6 +4,7 @@ import { AUTH_CODE, NOT_AUTH_APIS, PASSWORD, USER_NAME, USER_TYPE } from '../enu
|
|
|
4
4
|
import { LCP_LOGIN, REFRESH_TOKEN } from '../api/builtIn'
|
|
5
5
|
import { HashingFactory } from './cipher'
|
|
6
6
|
import dayjs from 'dayjs'
|
|
7
|
+
import { resultToast } from './respone'
|
|
7
8
|
|
|
8
9
|
export function generateRequester(config) {
|
|
9
10
|
const interceptors = config?.interceptors || {}
|
|
@@ -20,67 +21,69 @@ let EXPIRATION_Time = null
|
|
|
20
21
|
const service = axios.create({
|
|
21
22
|
timeout: 60000 // request timeout
|
|
22
23
|
})
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
if (
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
24
|
+
export function initInterceptors(messageInstance) {
|
|
25
|
+
service.interceptors.request.use(
|
|
26
|
+
config => {
|
|
27
|
+
let data = config.data
|
|
28
|
+
const url = config.url
|
|
29
|
+
if (
|
|
30
|
+
config && config.headers &&
|
|
31
|
+
(
|
|
32
|
+
config.headers['Content-type']?.includes('application/x-www-form-urlencoded')
|
|
33
|
+
)
|
|
34
|
+
) {
|
|
35
|
+
data = qs.stringify(data)
|
|
36
|
+
}
|
|
37
|
+
const reqConfig = {
|
|
38
|
+
...config,
|
|
39
|
+
data
|
|
40
|
+
}
|
|
41
|
+
return new Promise(async (resolve, reject) => {
|
|
42
|
+
try {
|
|
43
|
+
if ((!NOT_AUTH_APIS.includes(url) && !loginToken)) {
|
|
44
|
+
await simulatelogin(messageInstance)
|
|
45
|
+
reqConfig.headers = {
|
|
46
|
+
...(reqConfig.headers || {}),
|
|
47
|
+
Authorization: `Bearer ${loginToken}`
|
|
48
|
+
}
|
|
49
|
+
} else {
|
|
50
|
+
if (!NOT_AUTH_APIS.includes(url)) {
|
|
51
|
+
if ((EXPIRATION_Time.getTime() - new Date().getTime()) < THRESHOLD_TIME && REFRESH_TOKEN !== url) {
|
|
52
|
+
await refreshToken(messageInstance)
|
|
53
|
+
reqConfig.headers = {
|
|
54
|
+
...(reqConfig.headers || {}),
|
|
55
|
+
Authorization: `Bearer ${loginToken}`
|
|
56
|
+
}
|
|
57
|
+
} else {
|
|
58
|
+
reqConfig.headers = {
|
|
59
|
+
...(reqConfig.headers || {}),
|
|
60
|
+
Authorization: `Bearer ${loginToken}`
|
|
61
|
+
}
|
|
59
62
|
}
|
|
60
63
|
}
|
|
61
64
|
}
|
|
65
|
+
resolve(reqConfig)
|
|
66
|
+
} catch (error) {
|
|
67
|
+
reject()
|
|
62
68
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
error => {
|
|
70
|
-
return Promise.reject(error)
|
|
71
|
-
}
|
|
72
|
-
)
|
|
69
|
+
})
|
|
70
|
+
},
|
|
71
|
+
error => {
|
|
72
|
+
return Promise.reject(error)
|
|
73
|
+
}
|
|
74
|
+
)
|
|
73
75
|
|
|
74
|
-
// response interceptor
|
|
75
|
-
service.interceptors.response.use(
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
)
|
|
76
|
+
// response interceptor
|
|
77
|
+
service.interceptors.response.use(
|
|
78
|
+
response => {
|
|
79
|
+
// const { config } = response
|
|
80
|
+
return response
|
|
81
|
+
},
|
|
82
|
+
error => {
|
|
83
|
+
return error
|
|
84
|
+
}
|
|
85
|
+
)
|
|
86
|
+
}
|
|
84
87
|
|
|
85
88
|
export function buildInRequest(url, data, config = {}) {
|
|
86
89
|
const reqConfig = {
|
|
@@ -97,7 +100,7 @@ export function buildInRequest(url, data, config = {}) {
|
|
|
97
100
|
return service(reqConfig)
|
|
98
101
|
}
|
|
99
102
|
|
|
100
|
-
function simulatelogin() {
|
|
103
|
+
function simulatelogin(messageInstance) {
|
|
101
104
|
const MD5HashingInstance = HashingFactory.createMD5Hashing()
|
|
102
105
|
return buildInRequest(LCP_LOGIN, {
|
|
103
106
|
username: USER_NAME,
|
|
@@ -109,7 +112,7 @@ function simulatelogin() {
|
|
|
109
112
|
'Content-Type': 'application/x-www-form-urlencoded'
|
|
110
113
|
},
|
|
111
114
|
}).then(res => {
|
|
112
|
-
if (res.data
|
|
115
|
+
if (resultToast(res.data, messageInstance, {noSuccessIip: true})) {
|
|
113
116
|
loginToken = res.data.result.token
|
|
114
117
|
EXPIRATION_Time = dayjs(new Date()).add(2, 'hours').toDate()
|
|
115
118
|
return Promise.resolve(res)
|
|
@@ -120,9 +123,9 @@ function simulatelogin() {
|
|
|
120
123
|
}
|
|
121
124
|
|
|
122
125
|
|
|
123
|
-
function refreshToken() {
|
|
126
|
+
function refreshToken(messageInstance) {
|
|
124
127
|
return buildInRequest(REFRESH_TOKEN).then(res => {
|
|
125
|
-
if (res.data
|
|
128
|
+
if (resultToast(res.data, messageInstance, {noSuccessIip: true})) {
|
|
126
129
|
loginToken = res.data.result
|
|
127
130
|
EXPIRATION_Time = dayjs(new Date()).add(2, 'hours').toDate()
|
|
128
131
|
return Promise.resolve(res)
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export const RESULT_CODE = {
|
|
2
|
+
SUCCESS: '000000',
|
|
3
|
+
INFO: '000088',
|
|
4
|
+
WARNING: '000099',
|
|
5
|
+
ERROR: '000000',
|
|
6
|
+
OTHER: '020002'
|
|
7
|
+
}
|
|
8
|
+
export function resultToast(result = {}, messageInstance, {noSuccessIip = false} = {}) {
|
|
9
|
+
let ret = false
|
|
10
|
+
const resultMessage = result?.resultMessage || ''
|
|
11
|
+
const resultCode = result.resultCode
|
|
12
|
+
switch (resultCode) {
|
|
13
|
+
case RESULT_CODE.SUCCESS:
|
|
14
|
+
if (!noSuccessIip) {
|
|
15
|
+
messageInstance?.success(resultMessage)
|
|
16
|
+
}
|
|
17
|
+
ret = true
|
|
18
|
+
break;
|
|
19
|
+
case RESULT_CODE.INFO:
|
|
20
|
+
if (messageInstance.info && typeof messageInstance.info === 'function') {
|
|
21
|
+
messageInstance.info(resultMessage)
|
|
22
|
+
} else if (messageInstance.text && typeof messageInstance.text === 'function') {
|
|
23
|
+
// 移动端兼容写法
|
|
24
|
+
messageInstance.text(resultMessage)
|
|
25
|
+
}
|
|
26
|
+
break;
|
|
27
|
+
case RESULT_CODE.WARNING:
|
|
28
|
+
messageInstance?.warning(resultMessage)
|
|
29
|
+
break;
|
|
30
|
+
case RESULT_CODE.ERROR:
|
|
31
|
+
messageInstance?.error(resultMessage)
|
|
32
|
+
break;
|
|
33
|
+
case RESULT_CODE.OTHER:
|
|
34
|
+
messageInstance?.error(resultMessage)
|
|
35
|
+
break;
|
|
36
|
+
default:
|
|
37
|
+
messageInstance?.error(resultMessage)
|
|
38
|
+
break;
|
|
39
|
+
}
|
|
40
|
+
return ret
|
|
41
|
+
}
|