imatrix-ui 0.0.15 → 0.1.1-up
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/.vscode/extensions.json +3 -0
- package/README.md +7 -0
- package/components/dynamic-source-select/dynamic-source-select-service.js +106 -0
- package/components/dynamic-source-select/dynamic-source-select.vue +673 -0
- package/components/dynamic-source-select/events.js +77 -0
- package/components/fs-preview/fs-preview.vue +287 -0
- package/components/index.js +26 -0
- package/components/plugins/export-data-new.js +623 -0
- package/components/plugins/export-data.js +431 -0
- package/components/plugins/index.js +15 -0
- package/components/plugins/public-method.js +47 -0
- package/components/rich-editor/index-bak.vue +306 -0
- package/components/rich-editor/index.vue +236 -0
- package/components/rich-editor/langs/zh-Hans.js +438 -0
- package/components/rich-editor/viewer.vue +105 -0
- package/components/super-grid/apis.js +1065 -0
- package/components/super-grid/columns-config.vue +430 -0
- package/components/super-grid/custom-formatter.js +330 -0
- package/components/super-grid/dynamic-input.vue +1706 -0
- package/components/super-grid/eventBus.js +2 -0
- package/components/super-grid/events.js +56 -0
- package/components/super-grid/formValidatorUtil.js +300 -0
- package/components/super-grid/formatter.js +190 -0
- package/components/super-grid/group-column.vue +100 -0
- package/components/super-grid/header-context-menu.vue +82 -0
- package/components/super-grid/index-column.vue +69 -0
- package/components/super-grid/normal-column.vue +1148 -0
- package/components/super-grid/public-methods.js +30 -0
- package/components/super-grid/row-operation.vue +193 -0
- package/components/super-grid/search-button.vue +74 -0
- package/components/super-grid/search-condition-input.vue +73 -0
- package/components/super-grid/search-condition-list.vue +68 -0
- package/components/super-grid/search-form-advancedQuery.vue +820 -0
- package/components/super-grid/search-form-dialog.vue +77 -0
- package/components/super-grid/search-form-item.vue +470 -0
- package/components/super-grid/search-form-number.vue +111 -0
- package/components/super-grid/search-form-open.vue +178 -0
- package/components/super-grid/search-form-ordinarySearch.vue +218 -0
- package/components/super-grid/search-form.vue +756 -0
- package/components/super-grid/search-methods.js +484 -0
- package/components/super-grid/selection-column.vue +46 -0
- package/components/super-grid/store.js +3 -0
- package/components/super-grid/super-grid-service.js +682 -0
- package/components/super-grid/super-grid.vue +2893 -0
- package/components/super-grid/utils.js +851 -0
- package/components/super-grid/view-image-dialog.vue +173 -0
- package/components/utils/gogocodeTransfer.js +59 -0
- package/components/utils/utils.js +180 -0
- package/components/utils/value-set.js +98 -0
- package/components/z-test-utton/index.vue +82 -0
- package/package.json +29 -40
- package/public/index.html +13 -0
- package/public/vite.svg +1 -0
- package/src/api/sso-service.js +172 -19
- package/src/api/tab.js +36 -0
- package/src/api/user-service.js +11 -11
- package/src/assets/401/401.gif +0 -0
- package/src/assets/404/404-cloud.png +0 -0
- package/src/assets/404/404.png +0 -0
- package/src/assets/cloud.png +0 -0
- package/src/directives/permission/index.js +13 -13
- package/src/directives/permission/permission.js +20 -15
- package/src/i18n/i18n.js +16 -0
- package/src/i18n/langs/cn.js +254 -0
- package/src/i18n/langs/en.js +264 -0
- package/src/permission.js +157 -71
- package/src/plugins.js +18 -18
- package/src/router/index.js +96 -69
- package/src/store/getters.js +15 -10
- package/src/store/index.js +19 -19
- package/src/store/modules/app.js +54 -42
- package/src/store/modules/permission.js +137 -73
- package/src/store/modules/tab-content.js +36 -0
- package/src/store/modules/user.js +293 -80
- package/src/styles/display-layout.scss +34 -0
- package/src/styles/element-ui.scss +29 -29
- package/src/styles/index.scss +157 -78
- package/src/styles/mixin.scss +27 -27
- package/src/styles/theme/black/font-style.scss +70 -0
- package/src/styles/theme/black/index.scss +306 -0
- package/src/styles/theme/black/sidebar.scss +189 -0
- package/src/styles/theme/blue/font-style.scss +46 -0
- package/src/styles/theme/blue/index.scss +172 -0
- package/src/styles/{sidebar.scss → theme/blue/sidebar.scss} +171 -141
- package/src/styles/theme/blue2/font-style.scss +70 -0
- package/src/styles/theme/blue2/index.scss +188 -0
- package/src/styles/theme/blue2/sidebar.scss +201 -0
- package/src/styles/theme/dark-blue/button.scss +9 -0
- package/src/styles/theme/dark-blue/card.scss +62 -0
- package/src/styles/theme/dark-blue/checkbox.scss +10 -0
- package/src/styles/theme/dark-blue/dark-blue-var.scss +8 -0
- package/src/styles/theme/dark-blue/dialog.scss +21 -0
- package/src/styles/theme/dark-blue/element-variables.scss +7 -0
- package/src/styles/theme/dark-blue/font.scss +71 -0
- package/src/styles/theme/dark-blue/form.scss +51 -0
- package/src/styles/theme/dark-blue/index.scss +269 -0
- package/src/styles/theme/dark-blue/input.scss +15 -0
- package/src/styles/theme/dark-blue/message.scss +8 -0
- package/src/styles/theme/dark-blue/pagination.scss +14 -0
- package/src/styles/theme/dark-blue/scrollbar-style.scss +32 -0
- package/src/styles/theme/dark-blue/sidebar.scss +266 -0
- package/src/styles/theme/dark-blue/tab.scss +83 -0
- package/src/styles/theme/dark-blue/table.scss +60 -0
- package/src/styles/theme/dark-blue/tree.scss +31 -0
- package/src/styles/theme/dark-blue/var.scss +1028 -0
- package/src/styles/theme/gray/card-style.scss +54 -0
- package/src/styles/theme/gray/font-style.scss +70 -0
- package/src/styles/theme/gray/index.scss +172 -0
- package/src/styles/theme/gray/input-style.scss +19 -0
- package/src/styles/theme/gray/scrollbar-style.scss +32 -0
- package/src/styles/theme/gray/sidebar.scss +231 -0
- package/src/styles/theme/gray/tab-style.scss +81 -0
- package/src/styles/transition.scss +47 -46
- package/src/utils/auth-api.js +159 -0
- package/src/utils/auth.js +61 -15
- package/src/utils/calculator/calculator-factory-wf.js +558 -0
- package/src/utils/calculator/calculator-factory.js +145 -0
- package/src/utils/calculator/calculator-util.js +166 -0
- package/src/utils/common-util.js +305 -0
- package/src/utils/eventBus.js +2 -0
- package/src/utils/iconUtils.js +28 -0
- package/src/utils/index.js +102 -86
- package/src/utils/jump-page-utils.js +814 -0
- package/src/utils/local-storage.js +33 -31
- package/src/utils/menu.js +19 -0
- package/src/utils/permission.js +31 -26
- package/src/utils/permissionAuth.js +90 -0
- package/src/utils/range-selector.js +188 -0
- package/src/utils/request.js +270 -116
- package/src/utils/restful-interface-utils.js +57 -0
- package/src/utils/util.js +698 -0
- package/src/utils/validate.js +34 -33
- package/src/utils/watermark.js +108 -0
- package/src/utils/workflow-util.js +93 -0
- package/src/views/404.vue +248 -228
- package/src/views/dsc-component/Sidebar/Item.vue +84 -0
- package/src/views/dsc-component/Sidebar/Link.vue +38 -0
- package/src/views/dsc-component/Sidebar/SidebarItem.vue +196 -0
- package/src/views/dsc-component/Sidebar/index.vue +220 -0
- package/src/views/dsc-component/tabs/tab-content.vue +199 -0
- package/src/views/error-page/401.vue +106 -91
- package/src/views/error-page/404.vue +248 -228
- package/src/views/layout/EmptyLayout.vue +3 -0
- package/src/views/layout/Layout.vue +81 -68
- package/src/views/layout/NewLayout.vue +18 -0
- package/src/views/layout/components/AppMain.vue +39 -29
- package/src/views/layout/components/Breadcrumb/index.vue +156 -0
- package/src/views/layout/components/Menubar/Item.vue +57 -0
- package/src/views/layout/components/Menubar/Link.vue +38 -0
- package/src/views/layout/components/Menubar/SidebarItem.vue +164 -0
- package/src/views/layout/components/Menubar/index.vue +210 -0
- package/src/views/layout/components/Sidebar/Item.vue +53 -29
- package/src/views/layout/components/Sidebar/Link.vue +38 -39
- package/src/views/layout/components/Sidebar/SidebarItem.vue +135 -100
- package/src/views/layout/components/Sidebar/index.vue +141 -48
- package/src/views/layout/components/iframe-page.vue +38 -0
- package/src/views/layout/components/index.js +4 -3
- package/src/views/layout/components/tabs/tab-content.vue +207 -0
- package/src/views/layout/mixin/ResizeHandler.js +41 -41
- package/src/views/layout/tab-content-iframe-index.vue +38 -0
- package/src/views/layout/tab-content-index.vue +93 -0
- package/src/views/login/authredirect.vue +10 -10
- package/src/views/login/index.vue +296 -203
- package/src/views/login/update-password.vue +243 -0
- package/src/views/redirect/index.vue +14 -12
- package/src/views/wf-history/tache-subprocess-history.vue +45 -0
- package/vite.config.js +31 -0
- package/lib/super-ui.css +0 -1
- package/lib/super-ui.umd.min.js +0 -2
- package/src/styles/variables.scss +0 -4
- package/src/views/layout/components/Navbar.vue +0 -92
package/src/utils/request.js
CHANGED
|
@@ -1,116 +1,270 @@
|
|
|
1
|
-
import axios from 'axios'
|
|
2
|
-
import { Message } from 'element-
|
|
3
|
-
import { removeToken } from './auth'
|
|
4
|
-
import store from '../store'
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
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
|
-
|
|
1
|
+
import axios from 'axios'
|
|
2
|
+
import { ElMessage as Message } from 'element-plus'
|
|
3
|
+
import { getToken, removeToken } from './auth'
|
|
4
|
+
import store from '../store'
|
|
5
|
+
import checkPermission from './permission'
|
|
6
|
+
import * as Vue from 'vue'
|
|
7
|
+
import { getI18n } from './util'
|
|
8
|
+
import {
|
|
9
|
+
getRelativeBaseUrl,
|
|
10
|
+
getTimeZone,
|
|
11
|
+
setCustomSystemBackendUrl,
|
|
12
|
+
} from './common-util'
|
|
13
|
+
// 创建axios实例
|
|
14
|
+
const service = axios.create({
|
|
15
|
+
// baseURL: process.env.VUE_APP_BASE_API, // api 的 base_url
|
|
16
|
+
timeout: 300000, // 请求超时时间
|
|
17
|
+
withCredentials: true,
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
// request拦截器
|
|
21
|
+
service.interceptors.request.use(
|
|
22
|
+
(config) => {
|
|
23
|
+
// 防止重复发送ajax请求
|
|
24
|
+
store.commit('togglePreventReclick', true)
|
|
25
|
+
const timeZone = getTimeZone()
|
|
26
|
+
config.headers['timeZone'] = timeZone
|
|
27
|
+
const token = getToken()
|
|
28
|
+
if (token) {
|
|
29
|
+
config.headers['Authorization'] = token // 让每个请求携带自定义token 请根据实际情况自行修改
|
|
30
|
+
}
|
|
31
|
+
// 将自定义系统编码放入header中
|
|
32
|
+
const customSystem = window.$vueApp.config.globalProperties.customSystem
|
|
33
|
+
if (customSystem) {
|
|
34
|
+
config.headers['customSystem'] = customSystem
|
|
35
|
+
// 重新缓存系统后台路径
|
|
36
|
+
setCustomSystemBackendUrl(customSystem)
|
|
37
|
+
}
|
|
38
|
+
if (window.$vueApp.config.globalProperties.baseURL) {
|
|
39
|
+
config.baseURL = getRelativeBaseUrl(
|
|
40
|
+
window.$vueApp.config.globalProperties.baseURL
|
|
41
|
+
)
|
|
42
|
+
}
|
|
43
|
+
return config
|
|
44
|
+
},
|
|
45
|
+
(error) => {
|
|
46
|
+
// 出错了之后允许再次提交
|
|
47
|
+
store.commit('togglePreventReclick', false)
|
|
48
|
+
// console.log(error) // for debug
|
|
49
|
+
Promise.reject(error)
|
|
50
|
+
}
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
// response 拦截器
|
|
54
|
+
service.interceptors.response.use(
|
|
55
|
+
(response) => {
|
|
56
|
+
// 请求得到响应后,允许再次提交
|
|
57
|
+
store.commit('togglePreventReclick', false)
|
|
58
|
+
return response.data
|
|
59
|
+
},
|
|
60
|
+
(error) => {
|
|
61
|
+
// console.log('err' + error) // for debug
|
|
62
|
+
// 出错了之后允许再次提交
|
|
63
|
+
store.commit('togglePreventReclick', false)
|
|
64
|
+
if (error.response) {
|
|
65
|
+
if (error.response.status === 401) {
|
|
66
|
+
// LoginException(401)
|
|
67
|
+
// 清除window.sessionStorage中的jwt,否则无法转到login页面
|
|
68
|
+
removeToken()
|
|
69
|
+
// todo 测试 inframe true
|
|
70
|
+
const isInIframe = window.$vueApp.config.globalProperties.$isInIframe()
|
|
71
|
+
// console.log('isInIframe==========', isInIframe, 'getToken()=', getToken())
|
|
72
|
+
if (isInIframe === true) {
|
|
73
|
+
// 在iframe中时,出现了401错误时,需要进入平台的登录页面,并需要登录后还是进入出错的原页面,而不是永远进入门户页面。
|
|
74
|
+
// 所以使用了跨域发送消息来实现,子页面给父页面发消息,父页面接收该消息,并处理
|
|
75
|
+
// console.log('isInIframe111==========', window.location.href)
|
|
76
|
+
window.parent.postMessage(
|
|
77
|
+
'{"loginTimeout":"' + window.location.href + '"}',
|
|
78
|
+
'*'
|
|
79
|
+
)
|
|
80
|
+
} else {
|
|
81
|
+
// 当前出错的页面不是在子页面iframe内,需要跳转到子系统的登录页面。跳转到业务系统的登录页面,此处不自动跳转了,因为会导致无法跳转到指定页面
|
|
82
|
+
// getLoginUrl().then(loginUrl => {
|
|
83
|
+
// window.location.href = loginUrl
|
|
84
|
+
// })
|
|
85
|
+
}
|
|
86
|
+
} else if (error.response.status === 403) {
|
|
87
|
+
// ForbiddenException(403) 403没权限
|
|
88
|
+
const message = getI18n().t('imatrixUIMessage.forbiddenException')
|
|
89
|
+
Message({
|
|
90
|
+
showClose: true,
|
|
91
|
+
message: message,
|
|
92
|
+
type: 'error',
|
|
93
|
+
duration: 5 * 1000,
|
|
94
|
+
})
|
|
95
|
+
return Promise.reject(error)
|
|
96
|
+
} else if (
|
|
97
|
+
error.response.status === 400 ||
|
|
98
|
+
error.response.status === 406 ||
|
|
99
|
+
error.response.status === 404
|
|
100
|
+
) {
|
|
101
|
+
// BadRequestException(400) || BusinessException(406) || ResourceNotFoundException(404)
|
|
102
|
+
let message = error.message
|
|
103
|
+
if (message) {
|
|
104
|
+
// 说明是原生的错误,不要显示,显示“请联系管理员”
|
|
105
|
+
message = getI18n().t('imatrixUIMessage.internalServerError')
|
|
106
|
+
}
|
|
107
|
+
if (error.response.data && error.response.data.message) {
|
|
108
|
+
message = error.response.data.message
|
|
109
|
+
}
|
|
110
|
+
Message({
|
|
111
|
+
showClose: true,
|
|
112
|
+
message: message,
|
|
113
|
+
type: 'error',
|
|
114
|
+
duration: 5 * 1000,
|
|
115
|
+
})
|
|
116
|
+
return Promise.reject(error)
|
|
117
|
+
} else {
|
|
118
|
+
let message = error.message
|
|
119
|
+
if (error.response.data && error.response.data.message) {
|
|
120
|
+
message = error.response.data.message
|
|
121
|
+
}
|
|
122
|
+
console.log(message)
|
|
123
|
+
let errorMsg = getI18n().t('imatrixUIMessage.internalServerError')
|
|
124
|
+
if (message && message !== 'Internal Server Error') {
|
|
125
|
+
// 表示显示原始异常
|
|
126
|
+
errorMsg = message
|
|
127
|
+
}
|
|
128
|
+
if (
|
|
129
|
+
message &&
|
|
130
|
+
(message === 'gateway.timeout' || message === 'gateway.callFailed')
|
|
131
|
+
) {
|
|
132
|
+
// 网关的fallback返回的异常信息“接口调用超时”、“接口调用失败”
|
|
133
|
+
errorMsg = getI18n().t(message)
|
|
134
|
+
}
|
|
135
|
+
Message({
|
|
136
|
+
showClose: true,
|
|
137
|
+
message: errorMsg,
|
|
138
|
+
type: 'error',
|
|
139
|
+
duration: 5 * 1000,
|
|
140
|
+
})
|
|
141
|
+
return Promise.reject(error)
|
|
142
|
+
}
|
|
143
|
+
} else {
|
|
144
|
+
const errorMsg = getI18n().t('imatrixUIMessage.internalServerError')
|
|
145
|
+
Message({
|
|
146
|
+
showClose: true,
|
|
147
|
+
message: errorMsg,
|
|
148
|
+
type: 'error',
|
|
149
|
+
duration: 5 * 1000,
|
|
150
|
+
})
|
|
151
|
+
return Promise.reject(error)
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
)
|
|
155
|
+
|
|
156
|
+
export const apiUrlMappings = {}
|
|
157
|
+
/**
|
|
158
|
+
*
|
|
159
|
+
* @param {*} code 资源权限的编码
|
|
160
|
+
* @param {*} options 是一个对象,包括data和param两个子对象属性,形如{param:{},data:{}}
|
|
161
|
+
*/
|
|
162
|
+
export function request(code, options) {
|
|
163
|
+
const config = {}
|
|
164
|
+
if (options) {
|
|
165
|
+
if (options.data) {
|
|
166
|
+
config.data = options.data
|
|
167
|
+
}
|
|
168
|
+
if (options.responseType) {
|
|
169
|
+
config.responseType = options.responseType
|
|
170
|
+
}
|
|
171
|
+
if (options.params) {
|
|
172
|
+
config.params = options.params
|
|
173
|
+
}
|
|
174
|
+
if (options.header) {
|
|
175
|
+
config.header = options.header
|
|
176
|
+
}
|
|
177
|
+
if (options.onUploadProgress) {
|
|
178
|
+
config.onUploadProgress = options.onUploadProgress
|
|
179
|
+
}
|
|
180
|
+
if (options.method) {
|
|
181
|
+
config.method = options.method
|
|
182
|
+
}
|
|
183
|
+
if (options.url) {
|
|
184
|
+
config.url = options.url
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
if (code) {
|
|
188
|
+
if (!checkPermission(code)) {
|
|
189
|
+
Message({
|
|
190
|
+
message: '您没有权限访问接口:' + code,
|
|
191
|
+
type: 'error',
|
|
192
|
+
showClose: true,
|
|
193
|
+
})
|
|
194
|
+
}
|
|
195
|
+
const apiInfo = apiUrlMappings[code]
|
|
196
|
+
if (apiInfo) {
|
|
197
|
+
const url = getRealUrl(apiInfo.url, config.params)
|
|
198
|
+
if (url === '') {
|
|
199
|
+
return
|
|
200
|
+
}
|
|
201
|
+
config.url = url
|
|
202
|
+
config.method = apiInfo.method
|
|
203
|
+
} else {
|
|
204
|
+
Message({
|
|
205
|
+
message: '您要访问的接口没有定义:' + code,
|
|
206
|
+
type: 'error',
|
|
207
|
+
showClose: true,
|
|
208
|
+
})
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
if (!config.url) {
|
|
213
|
+
Message({
|
|
214
|
+
message: '接口地址必须配置',
|
|
215
|
+
type: 'error',
|
|
216
|
+
showClose: true,
|
|
217
|
+
})
|
|
218
|
+
}
|
|
219
|
+
if (config.method && config.method.toLowerCase() === 'get') {
|
|
220
|
+
if (config.url.indexOf('?') > 0) {
|
|
221
|
+
// 表示有参数
|
|
222
|
+
config.url = config.url + '&_t=' + new Date().getTime()
|
|
223
|
+
} else {
|
|
224
|
+
config.url = config.url + '?_t=' + new Date().getTime()
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
return service(config)
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* 判断地址中是否有路径参数,有路径参数时就用params中的对应属性替换掉路径中的参数,得到最终的url
|
|
232
|
+
* @param {*} url
|
|
233
|
+
* @param {*} params
|
|
234
|
+
*/
|
|
235
|
+
function getRealUrl(url, params) {
|
|
236
|
+
const regex = /\{(.+?)\}/g
|
|
237
|
+
const matched = url.match(regex)
|
|
238
|
+
// 不包含路径参数直接返回url
|
|
239
|
+
if (!matched) {
|
|
240
|
+
return url
|
|
241
|
+
}
|
|
242
|
+
if (matched.length > 0 && !params) {
|
|
243
|
+
Message({
|
|
244
|
+
message: '请求的url中包含路径参数时,param不能为空。',
|
|
245
|
+
type: 'error',
|
|
246
|
+
showClose: true,
|
|
247
|
+
})
|
|
248
|
+
return ''
|
|
249
|
+
}
|
|
250
|
+
// matched是一个匹配的路径参数的数组,形如[{deparmentId}, {userId}]
|
|
251
|
+
for (const param of matched) {
|
|
252
|
+
// 去掉大括号得到真正的路径参数名
|
|
253
|
+
const paramName = param.substring(1, param.length - 1)
|
|
254
|
+
// 请求的param对象中应该包括这个参数,这样才能把参数名替换成真实的值
|
|
255
|
+
if (params[paramName] === undefined) {
|
|
256
|
+
Message({
|
|
257
|
+
message: '中应该包括属性:' + paramName,
|
|
258
|
+
type: 'error',
|
|
259
|
+
showClose: true,
|
|
260
|
+
})
|
|
261
|
+
return ''
|
|
262
|
+
}
|
|
263
|
+
url = url.replace(param, params[paramName])
|
|
264
|
+
// 从param对象中删掉这个参数,不用重复发送到后台了
|
|
265
|
+
delete params[paramName]
|
|
266
|
+
}
|
|
267
|
+
return url
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
export default service
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import * as Vue from 'vue'
|
|
2
|
+
/**
|
|
3
|
+
* rest接口调用处理
|
|
4
|
+
* @param {*} restfulInterface 接口配置json信息
|
|
5
|
+
* @param {*} backendUrl 后台url路径
|
|
6
|
+
* @param {*} entity 表单数据
|
|
7
|
+
* @returns request Promise函数
|
|
8
|
+
*/
|
|
9
|
+
export function restfulInterfaceTo(
|
|
10
|
+
restfulInterface,
|
|
11
|
+
entity,
|
|
12
|
+
additionalParamMap
|
|
13
|
+
) {
|
|
14
|
+
return new Promise((resolve, reject) => {
|
|
15
|
+
let systemCode = window.$vueApp.config.globalProperties.customSystem
|
|
16
|
+
if (!systemCode) {
|
|
17
|
+
systemCode = window.$vueApp.config.globalProperties.systemCode
|
|
18
|
+
}
|
|
19
|
+
let restConfigMap = restfulInterface
|
|
20
|
+
|
|
21
|
+
if (restfulInterface && typeof restfulInterface === 'string') {
|
|
22
|
+
restConfigMap = JSON.parse(restfulInterface)
|
|
23
|
+
} else if (restfulInterface && typeof restfulInterface === 'object') {
|
|
24
|
+
restConfigMap = restfulInterface
|
|
25
|
+
}
|
|
26
|
+
const paramMap = {}
|
|
27
|
+
if (systemCode) {
|
|
28
|
+
paramMap.systemCode = systemCode
|
|
29
|
+
}
|
|
30
|
+
if (additionalParamMap) {
|
|
31
|
+
paramMap.additionalParamMap = additionalParamMap
|
|
32
|
+
}
|
|
33
|
+
if (restConfigMap) {
|
|
34
|
+
paramMap.restConfig = restConfigMap
|
|
35
|
+
}
|
|
36
|
+
if (entity) {
|
|
37
|
+
paramMap.entity = entity
|
|
38
|
+
}
|
|
39
|
+
window.$vueApp.config.globalProperties.$http
|
|
40
|
+
.post(
|
|
41
|
+
window.$vueApp.config.globalProperties.baseAPI +
|
|
42
|
+
'/component/super-pages/rest-data',
|
|
43
|
+
paramMap
|
|
44
|
+
)
|
|
45
|
+
.then((dataJson) => {
|
|
46
|
+
if (dataJson) {
|
|
47
|
+
// json字符串
|
|
48
|
+
resolve(JSON.parse(dataJson))
|
|
49
|
+
} else {
|
|
50
|
+
resolve()
|
|
51
|
+
}
|
|
52
|
+
})
|
|
53
|
+
.catch((error) => {
|
|
54
|
+
reject(error)
|
|
55
|
+
})
|
|
56
|
+
})
|
|
57
|
+
}
|