vue2-client 1.2.110 → 1.2.113

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.
Files changed (28) hide show
  1. package/CHANGELOG.md +287 -275
  2. package/package.json +76 -95
  3. package/src/base-client/all.js +62 -66
  4. package/src/base-client/components/common/XCard/XCard.vue +64 -64
  5. package/src/base-client/components/common/XFormTable/XFormTable.vue +514 -514
  6. package/src/base-client/components/common/XFormTable/index.md +96 -96
  7. package/src/base-client/components/iot/DeviceDetailsView/DeviceDetailsView.vue +232 -232
  8. package/src/base-client/components/iot/DeviceDetailsView/part/DeviceDetailsCount.vue +678 -678
  9. package/src/base-client/components/iot/DeviceDetailsView/part/DeviceDetailsException.vue +57 -57
  10. package/src/base-client/components/iot/DeviceDetailsView/part/DeviceDetailsRead.vue +131 -131
  11. package/src/base-client/components/iot/DeviceTypeDetailsView/DeviceTypeDetailsView.vue +300 -300
  12. package/src/base-client/components/ticket/TicketSubmitSuccessView/TicketSubmitSuccessView.vue +532 -532
  13. package/src/base-client/plugins/AppData.js +71 -79
  14. package/src/base-client/plugins/compatible/LoginServiceOA.js +20 -20
  15. package/src/pages/login/Login.vue +279 -274
  16. package/src/pages/resourceManage/orgListManage.vue +98 -98
  17. package/src/router/async/config.async.js +26 -26
  18. package/src/router/index.js +27 -27
  19. package/src/services/api/index.js +39 -39
  20. package/src/services/api/iot/DeviceDetailsView/DeviceDetailsCountApi.js +18 -18
  21. package/src/theme/default/style.less +47 -47
  22. package/src/utils/request.js +270 -270
  23. package/src/utils/util.js +230 -230
  24. package/src/base-client/components/common/ScrollList/SrcollList.vue +0 -113
  25. package/src/base-client/components/common/ScrollList/index.js +0 -3
  26. package/src/base-client/components/iot/DataAnalysisView/DataAnalysisView.vue +0 -244
  27. package/src/base-client/components/iot/DataAnalysisView/index.js +0 -3
  28. package/src/components/dataAnalysisView/UserData.vue +0 -61
@@ -1,270 +1,270 @@
1
- import axios from 'axios'
2
- import Cookie from 'js-cookie'
3
- import Vue from 'vue'
4
- import { ACCESS_TOKEN } from '@vue2-client/store/mutation-types'
5
- import notification from 'ant-design-vue/es/notification'
6
-
7
- let compatible
8
-
9
- // 跨域认证信息 header 名
10
- const xsrfHeaderName = 'Authorization'
11
- // V4系统请求头名
12
- const v4TokenName = 'ACCESS_TOKEN'
13
- const v4TokenExpire = 'ACCESS_TOKEN_EXPIRES'
14
-
15
- axios.defaults.timeout = 5000
16
- axios.defaults.withCredentials = true
17
- axios.defaults.xsrfHeaderName = xsrfHeaderName
18
- axios.defaults.xsrfCookieName = xsrfHeaderName
19
-
20
- // 认证类型
21
- const AUTH_TYPE = {
22
- BEARER: 'Bearer',
23
- BASIC: 'basic',
24
- AUTH1: 'auth1',
25
- AUTH2: 'auth2'
26
- }
27
-
28
- // http method
29
- const METHOD = {
30
- GET: 'get',
31
- POST: 'post'
32
- }
33
-
34
- /**
35
- * axios请求
36
- * @param url 请求地址
37
- * @param method {METHOD} http method
38
- * @param params 请求参数
39
- * @param config
40
- * @returns {Promise<AxiosResponse<T>>}
41
- */
42
- async function request (url, method, params, config) {
43
- switch (method) {
44
- case METHOD.GET:
45
- return axios.get(url, { params, ...config })
46
- case METHOD.POST:
47
- return axios.post(url, params, config)
48
- default:
49
- return axios.get(url, { params, ...config })
50
- }
51
- }
52
-
53
- /**
54
- * 设置V4认证信息
55
- * @param auth {Object}
56
- * @param authType {AUTH_TYPE} 认证类型,默认:{AUTH_TYPE.BEARER}
57
- */
58
- function setAuthorizationV4 (auth, authType = AUTH_TYPE.BEARER) {
59
- switch (authType) {
60
- case AUTH_TYPE.BEARER:
61
- if (auth.token) {
62
- Cookie.set(v4TokenName, 'Bearer ' + auth.token)
63
- Cookie.set(v4TokenExpire, 'Bearer ' + auth.expire)
64
- }
65
- break
66
- case AUTH_TYPE.BASIC:
67
- case AUTH_TYPE.AUTH1:
68
- case AUTH_TYPE.AUTH2:
69
- default:
70
- break
71
- }
72
- }
73
-
74
- /**
75
- * 移出V4认证信息
76
- * @param authType {AUTH_TYPE} 认证类型
77
- */
78
- function removeAuthorizationV4 (authType = AUTH_TYPE.BEARER) {
79
- switch (authType) {
80
- case AUTH_TYPE.BEARER:
81
- Cookie.remove(v4TokenName)
82
- Cookie.remove(v4TokenExpire)
83
- break
84
- case AUTH_TYPE.BASIC:
85
- case AUTH_TYPE.AUTH1:
86
- case AUTH_TYPE.AUTH2:
87
- default:
88
- break
89
- }
90
- }
91
-
92
- /**
93
- * 设置认证信息
94
- * @param auth {Object}
95
- * @param authType {AUTH_TYPE} 认证类型,默认:{AUTH_TYPE.BEARER}
96
- */
97
- function setAuthorization (auth, authType = AUTH_TYPE.BEARER) {
98
- switch (authType) {
99
- case AUTH_TYPE.BEARER:
100
- if (auth.token){
101
- Cookie.set(xsrfHeaderName, 'Bearer ' + auth.token, { expires: auth.expireAt })
102
- }
103
- break
104
- case AUTH_TYPE.BASIC:
105
- case AUTH_TYPE.AUTH1:
106
- case AUTH_TYPE.AUTH2:
107
- default:
108
- break
109
- }
110
- }
111
-
112
- /**
113
- * 移出认证信息
114
- * @param authType {AUTH_TYPE} 认证类型
115
- */
116
- function removeAuthorization (authType = AUTH_TYPE.BEARER) {
117
- switch (authType) {
118
- case AUTH_TYPE.BEARER:
119
- Cookie.remove(xsrfHeaderName)
120
- break
121
- case AUTH_TYPE.BASIC:
122
- case AUTH_TYPE.AUTH1:
123
- case AUTH_TYPE.AUTH2:
124
- default:
125
- break
126
- }
127
- }
128
-
129
- /**
130
- * 检查认证信息
131
- * @param authType
132
- * @returns {boolean}
133
- */
134
- function checkAuthorization (authType = AUTH_TYPE.BEARER) {
135
- switch (authType) {
136
- case AUTH_TYPE.BEARER:
137
- if (Cookie.get(xsrfHeaderName)) {
138
- return true
139
- }
140
- break
141
- case AUTH_TYPE.BASIC:
142
- case AUTH_TYPE.AUTH1:
143
- case AUTH_TYPE.AUTH2:
144
- default:
145
- break
146
- }
147
- return false
148
- }
149
-
150
- /**
151
- * 加载 axios 拦截器
152
- * @param interceptors
153
- * @param options
154
- */
155
- function loadInterceptors () {
156
- // 加载请求拦截器
157
- axios.interceptors.request.use(config => {
158
- const token = localStorage.getItem('ACCESS_TOKEN')
159
- // 如果 token 存在
160
- // 让每个请求携带自定义 token 请根据实际情况自行修改
161
- if (token) {
162
- // 如果是首次使用系统LocalStorage需要初始化,在登陆之后重新获取一次compatible
163
- if (compatible === null) {
164
- compatible = localStorage.getItem('compatible')
165
- }
166
- // 判断是否为V4环境
167
- if (compatible === 'V4') {
168
- // V4 环境则添加 V4请求头
169
- config.headers['ACCESS_TOKEN'] = localStorage.getItem('ACCESS_TOKEN')
170
- config.headers['ACCESS_TOKEN_EXPIRES'] = localStorage.getItem('ACCESS_TOKEN_EXPIRES')
171
- } else {
172
- config.headers['Access-Token'] = token
173
- }
174
- }
175
- if (!config.headers['Content-Type']) {
176
- config.headers['Content-Type'] = 'application/json;charset=UTF-8'
177
- }
178
- return config
179
- }, errorHandler)
180
- // 加载响应拦截器
181
- axios.interceptors.response.use((response) => {
182
- // 判断是否为V4环境,不为compatible赋初始值
183
- // 其有可能是undefined未定义,或第一次使用本系统LocalStorage在初始化,获得的值为null
184
- if (compatible === null || compatible === undefined) {
185
- compatible = localStorage.getItem('compatible')
186
- }
187
- if (compatible === 'V4') {
188
- if (response.data.data) {
189
- return response.data.data
190
- } else {
191
- return response.data
192
- }
193
- } else {
194
- return response.data
195
- }
196
- }, errorHandler)
197
- }
198
-
199
- // 异常拦截处理器
200
- const errorHandler = (error) => {
201
- if (error.response) {
202
- const data = error.response.data
203
- // 从 localstorage 获取 token
204
- const token = localStorage.getItem(ACCESS_TOKEN)
205
- if (error.response.status === 403 || data.code === 403) {
206
- notification.error({
207
- message: '禁止访问',
208
- description: data
209
- })
210
- } else if ((error.response.status === 401 || data.code === 401) && !(data.result && data.result.isLogin)) {
211
- notification.error({
212
- message: '鉴权失败',
213
- description: data
214
- })
215
- if (token) {
216
- Vue.$store.dispatch('Logout').then(() => {
217
- setTimeout(() => {
218
- window.location.reload()
219
- }, 1500)
220
- })
221
- }
222
- } else if (error.response.status === 500 || data.code === 500) {
223
- notification.error({
224
- message: '系统异常',
225
- description: data
226
- })
227
- } else {
228
- notification.error({
229
- message: '数据异常',
230
- description: data
231
- })
232
- }
233
- }
234
- return Promise.reject(error)
235
- }
236
-
237
- /**
238
- * 解析 url 中的参数
239
- * @param url
240
- * @returns {Object}
241
- */
242
- function parseUrlParams (url) {
243
- const params = {}
244
- if (!url || url === '' || typeof url !== 'string') {
245
- return params
246
- }
247
- const paramsStr = url.split('?')[1]
248
- if (!paramsStr) {
249
- return params
250
- }
251
- const paramsArr = paramsStr.replace(/&|=/g, ' ').split(' ')
252
- for (let i = 0; i < paramsArr.length / 2; i++) {
253
- const value = paramsArr[i * 2 + 1]
254
- params[paramsArr[i * 2]] = value === 'true' ? true : (value === 'false' ? false : value)
255
- }
256
- return params
257
- }
258
-
259
- export {
260
- METHOD,
261
- AUTH_TYPE,
262
- request,
263
- setAuthorization,
264
- removeAuthorization,
265
- checkAuthorization,
266
- loadInterceptors,
267
- parseUrlParams,
268
- setAuthorizationV4,
269
- removeAuthorizationV4
270
- }
1
+ import axios from 'axios'
2
+ import Cookie from 'js-cookie'
3
+ import Vue from 'vue'
4
+ import { ACCESS_TOKEN } from '@vue2-client/store/mutation-types'
5
+ import notification from 'ant-design-vue/es/notification'
6
+
7
+ let compatible
8
+
9
+ // 跨域认证信息 header 名
10
+ const xsrfHeaderName = 'Authorization'
11
+ // V4系统请求头名
12
+ const ACCESS_TOKEN_KEY = 'ACCESS_TOKEN'
13
+ const ACCESS_TOKEN_EXPIRES_KEY = 'ACCESS_TOKEN_EXPIRES'
14
+
15
+ axios.defaults.timeout = 5000
16
+ axios.defaults.withCredentials = true
17
+ axios.defaults.xsrfHeaderName = xsrfHeaderName
18
+ axios.defaults.xsrfCookieName = xsrfHeaderName
19
+
20
+ // 认证类型
21
+ const AUTH_TYPE = {
22
+ BEARER: 'Bearer',
23
+ BASIC: 'basic',
24
+ AUTH1: 'auth1',
25
+ AUTH2: 'auth2'
26
+ }
27
+
28
+ // http method
29
+ const METHOD = {
30
+ GET: 'get',
31
+ POST: 'post'
32
+ }
33
+
34
+ /**
35
+ * axios请求
36
+ * @param url 请求地址
37
+ * @param method {METHOD} http method
38
+ * @param params 请求参数
39
+ * @param config
40
+ * @returns {Promise<AxiosResponse<T>>}
41
+ */
42
+ async function request (url, method, params, config) {
43
+ switch (method) {
44
+ case METHOD.GET:
45
+ return axios.get(url, { params, ...config })
46
+ case METHOD.POST:
47
+ return axios.post(url, params, config)
48
+ default:
49
+ return axios.get(url, { params, ...config })
50
+ }
51
+ }
52
+
53
+ /**
54
+ * 设置V4认证信息
55
+ * @param auth {Object}
56
+ * @param authType {AUTH_TYPE} 认证类型,默认:{AUTH_TYPE.BEARER}
57
+ */
58
+ function setAuthorizationV4 (auth, authType = AUTH_TYPE.BEARER) {
59
+ switch (authType) {
60
+ case AUTH_TYPE.BEARER:
61
+ if (auth.token) {
62
+ Cookie.set(ACCESS_TOKEN_KEY, 'Bearer ' + auth.token)
63
+ Cookie.set(ACCESS_TOKEN_EXPIRES_KEY, 'Bearer ' + auth.expire)
64
+ }
65
+ break
66
+ case AUTH_TYPE.BASIC:
67
+ case AUTH_TYPE.AUTH1:
68
+ case AUTH_TYPE.AUTH2:
69
+ default:
70
+ break
71
+ }
72
+ }
73
+
74
+ /**
75
+ * 移出V4认证信息
76
+ * @param authType {AUTH_TYPE} 认证类型
77
+ */
78
+ function removeAuthorizationV4 (authType = AUTH_TYPE.BEARER) {
79
+ switch (authType) {
80
+ case AUTH_TYPE.BEARER:
81
+ Cookie.remove(ACCESS_TOKEN_KEY)
82
+ Cookie.remove(ACCESS_TOKEN_EXPIRES_KEY)
83
+ break
84
+ case AUTH_TYPE.BASIC:
85
+ case AUTH_TYPE.AUTH1:
86
+ case AUTH_TYPE.AUTH2:
87
+ default:
88
+ break
89
+ }
90
+ }
91
+
92
+ /**
93
+ * 设置认证信息
94
+ * @param auth {Object}
95
+ * @param authType {AUTH_TYPE} 认证类型,默认:{AUTH_TYPE.BEARER}
96
+ */
97
+ function setAuthorization (auth, authType = AUTH_TYPE.BEARER) {
98
+ switch (authType) {
99
+ case AUTH_TYPE.BEARER:
100
+ if (auth.token) {
101
+ Cookie.set(xsrfHeaderName, 'Bearer ' + auth.token, { expires: auth.expireAt })
102
+ }
103
+ break
104
+ case AUTH_TYPE.BASIC:
105
+ case AUTH_TYPE.AUTH1:
106
+ case AUTH_TYPE.AUTH2:
107
+ default:
108
+ break
109
+ }
110
+ }
111
+
112
+ /**
113
+ * 移出认证信息
114
+ * @param authType {AUTH_TYPE} 认证类型
115
+ */
116
+ function removeAuthorization (authType = AUTH_TYPE.BEARER) {
117
+ switch (authType) {
118
+ case AUTH_TYPE.BEARER:
119
+ Cookie.remove(xsrfHeaderName)
120
+ break
121
+ case AUTH_TYPE.BASIC:
122
+ case AUTH_TYPE.AUTH1:
123
+ case AUTH_TYPE.AUTH2:
124
+ default:
125
+ break
126
+ }
127
+ }
128
+
129
+ /**
130
+ * 检查认证信息
131
+ * @param authType
132
+ * @returns {boolean}
133
+ */
134
+ function checkAuthorization (authType = AUTH_TYPE.BEARER) {
135
+ switch (authType) {
136
+ case AUTH_TYPE.BEARER:
137
+ if (Cookie.get(xsrfHeaderName)) {
138
+ return true
139
+ }
140
+ break
141
+ case AUTH_TYPE.BASIC:
142
+ case AUTH_TYPE.AUTH1:
143
+ case AUTH_TYPE.AUTH2:
144
+ default:
145
+ break
146
+ }
147
+ return false
148
+ }
149
+
150
+ /**
151
+ * 加载 axios 拦截器
152
+ * @param interceptors
153
+ * @param options
154
+ */
155
+ function loadInterceptors () {
156
+ // 加载请求拦截器
157
+ axios.interceptors.request.use(config => {
158
+ const token = localStorage.getItem(ACCESS_TOKEN_KEY)
159
+ // 如果 token 存在
160
+ // 让每个请求携带自定义 token 请根据实际情况自行修改
161
+ if (token) {
162
+ // 如果是首次使用系统LocalStorage需要初始化,在登陆之后重新获取一次compatible
163
+ if (compatible === null) {
164
+ compatible = localStorage.getItem('compatible')
165
+ }
166
+ // 判断是否为V4环境
167
+ if (compatible === 'V4') {
168
+ // V4 环境则添加 V4请求头
169
+ config.headers[ACCESS_TOKEN_KEY] = localStorage.getItem(ACCESS_TOKEN_KEY)
170
+ config.headers[ACCESS_TOKEN_EXPIRES_KEY] = localStorage.getItem(ACCESS_TOKEN_EXPIRES_KEY)
171
+ } else {
172
+ config.headers['Access-Token'] = token
173
+ }
174
+ }
175
+ if (!config.headers['Content-Type']) {
176
+ config.headers['Content-Type'] = 'application/json;charset=UTF-8'
177
+ }
178
+ return config
179
+ }, errorHandler)
180
+ // 加载响应拦截器
181
+ axios.interceptors.response.use((response) => {
182
+ // 判断是否为V4环境,不为compatible赋初始值
183
+ // 其有可能是undefined未定义,或第一次使用本系统LocalStorage在初始化,获得的值为null
184
+ if (compatible === null || compatible === undefined) {
185
+ compatible = localStorage.getItem('compatible')
186
+ }
187
+ if (compatible === 'V4') {
188
+ if (response.data.data) {
189
+ return response.data.data
190
+ } else {
191
+ return response.data
192
+ }
193
+ } else {
194
+ return response.data
195
+ }
196
+ }, errorHandler)
197
+ }
198
+
199
+ // 异常拦截处理器
200
+ const errorHandler = (error) => {
201
+ if (error.response) {
202
+ const data = error.response.data
203
+ // 从 localstorage 获取 token
204
+ const token = localStorage.getItem(ACCESS_TOKEN)
205
+ if (error.response.status === 403 || data.code === 403) {
206
+ notification.error({
207
+ message: '禁止访问',
208
+ description: data
209
+ })
210
+ } else if ((error.response.status === 401 || data.code === 401) && !(data.result && data.result.isLogin)) {
211
+ notification.error({
212
+ message: '鉴权失败',
213
+ description: data
214
+ })
215
+ if (token) {
216
+ Vue.$store.dispatch('Logout').then(() => {
217
+ setTimeout(() => {
218
+ window.location.reload()
219
+ }, 1500)
220
+ })
221
+ }
222
+ } else if (error.response.status === 500 || data.code === 500) {
223
+ notification.error({
224
+ message: '系统异常',
225
+ description: data
226
+ })
227
+ } else {
228
+ notification.error({
229
+ message: '数据异常',
230
+ description: data
231
+ })
232
+ }
233
+ }
234
+ return Promise.reject(error)
235
+ }
236
+
237
+ /**
238
+ * 解析 url 中的参数
239
+ * @param url
240
+ * @returns {Object}
241
+ */
242
+ function parseUrlParams (url) {
243
+ const params = {}
244
+ if (!url || url === '' || typeof url !== 'string') {
245
+ return params
246
+ }
247
+ const paramsStr = url.split('?')[1]
248
+ if (!paramsStr) {
249
+ return params
250
+ }
251
+ const paramsArr = paramsStr.replace(/&|=/g, ' ').split(' ')
252
+ for (let i = 0; i < paramsArr.length / 2; i++) {
253
+ const value = paramsArr[i * 2 + 1]
254
+ params[paramsArr[i * 2]] = value === 'true' ? true : (value === 'false' ? false : value)
255
+ }
256
+ return params
257
+ }
258
+
259
+ export {
260
+ METHOD,
261
+ AUTH_TYPE,
262
+ request,
263
+ setAuthorization,
264
+ removeAuthorization,
265
+ checkAuthorization,
266
+ loadInterceptors,
267
+ parseUrlParams,
268
+ setAuthorizationV4,
269
+ removeAuthorizationV4
270
+ }