vue2-client 1.10.32 → 1.10.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.
Files changed (27) hide show
  1. package/package.json +1 -1
  2. package/src/App.vue +196 -196
  3. package/src/base-client/components/common/XAddNativeForm/demo.vue +43 -43
  4. package/src/base-client/components/common/XAddReport/XAddReport.vue +1 -1
  5. package/src/base-client/components/common/XConversation/XConversation.vue +12 -0
  6. package/src/base-client/components/common/XDataCard/XDataCard.vue +17 -16
  7. package/src/base-client/components/common/XForm/XFormItem.vue +1248 -1286
  8. package/src/base-client/components/common/XFormCol/XFormCol.vue +157 -157
  9. package/src/base-client/components/common/XFormGroup/XFormGroup.vue +301 -301
  10. package/src/base-client/components/common/XFormTable/XFormTable.vue +12 -0
  11. package/src/base-client/components/common/XFormTable/demo.vue +2 -2
  12. package/src/base-client/components/common/XIntervalPicker/XIntervalPicker.vue +121 -0
  13. package/src/base-client/components/common/XReportDrawer/XReportDrawer.vue +1 -1
  14. package/src/base-client/components/common/XReportGrid/XReport.vue +1079 -1070
  15. package/src/base-client/components/common/XReportGrid/XReportDemo.vue +46 -47
  16. package/src/base-client/components/common/XReportGrid/XReportDesign.vue +628 -628
  17. package/src/base-client/components/common/XReportGrid/XReportJsonRender.vue +380 -380
  18. package/src/base-client/components/common/XReportGrid/XReportTrGroup.vue +1104 -1104
  19. package/src/base-client/components/common/XReportGrid/print.js +184 -184
  20. package/src/base-client/components/common/XTab/XTab.vue +57 -25
  21. package/src/components/cache/AKeepAlive.js +11 -4
  22. package/src/layouts/BlankView.vue +59 -3
  23. package/src/pages/ReportGrid/index.vue +76 -76
  24. package/src/router/async/router.map.js +95 -148
  25. package/src/router/guards.js +260 -263
  26. package/src/utils/microAppUtils.js +49 -40
  27. package/src/utils/routerUtil.js +526 -450
@@ -1,263 +1,260 @@
1
- import { hasAuthority } from '@vue2-client/utils/authority-utils'
2
- import { loginIgnore } from '@vue2-client/router/index'
3
- import { checkAuthorization, METHOD, request } from '@vue2-client/utils/request'
4
- import NProgress from 'nprogress'
5
- import { logout } from '@vue2-client/services/user'
6
- import {
7
- startLogin,
8
- checkSingleAuthorization,
9
- } from '@vue2-client/utils/login'
10
- import AES from '@vue2-client/utils/EncryptUtil'
11
- import Vue from 'vue'
12
- import { funcToRouter, loadRoutes } from '@vue2-client/utils/routerUtil'
13
- import { indexedDB } from '@vue2-client/utils/indexedDB'
14
-
15
- NProgress.configure({ showSpinner: false })
16
-
17
- /**
18
- * 进度条开始
19
- * @param to
20
- * @param form
21
- * @param next
22
- */
23
- const progressStart = (to, from, next) => {
24
- // start progress bar
25
- if (!NProgress.isStarted()) {
26
- NProgress.start()
27
- }
28
- next()
29
- }
30
-
31
- /**
32
- * 登录守卫
33
- * @param to
34
- * @param form
35
- * @param next
36
- * @param options
37
- */
38
- const loginGuard = (to, from, next, options) => {
39
- if (window.__MICRO_APP_ENVIRONMENT__) {
40
- window.microApp.dispatch({ type: '子应用发送给主应用的数据', to: to.path })
41
- }
42
- const urlParams = new URLSearchParams(window.location.search)
43
- const LoginTicket = urlParams.get('LoginTicket')
44
- // 如果是需要我们自己登陆的项目
45
- const token = urlParams.get('token')
46
- // 如果是v2 的项目 资源管理和营收分开库的那种项目 传递用户信息进来
47
- const tokenV2 = urlParams.get('tokenV2')
48
- // 如果是 v4 的父项目,通过localStorage传递信息
49
- const V4_LOGIN_DATA_KEY = localStorage.getItem('v4LoginData')
50
- if (LoginTicket) {
51
- const loginTicket = decodeURIComponent(LoginTicket)
52
- const { AESDecrypt } = AES
53
- const info = AESDecrypt(loginTicket, '3KMKqvgwR8ULbR8Z')
54
- const { store, message, router } = options
55
- // 单页面通常是嵌入到v3的项目中,没有单独的清除按钮,所以需要清除indexedDB
56
- indexedDB.clear()
57
- if (
58
- (!loginIgnore.includes(to) || to.name === '404') &&
59
- !checkSingleAuthorization('SinglePage', loginTicket)
60
- ) {
61
- localStorage.setItem('SinglePage_TOKEN', loginTicket)
62
- startLogin({
63
- ...info,
64
- pathname: window.location.pathname.replace(process.env.VUE_APP_PUBLIC_PATH, ''),
65
- store,
66
- router,
67
- })
68
- } else {
69
- const roles = store.getters['account/roles']
70
- let user = {}
71
- try {
72
- user = JSON.parse(localStorage.getItem(process.env.VUE_APP_USER_KEY))
73
- } catch (e) {
74
- user = localStorage.getItem(process.env.VUE_APP_USER_KEY)
75
- }
76
- const setUser = store._mutations['account/setUser'][0]
77
- setUser(user)
78
- if (roles.length === 0 && !loginIgnore.includes(to)) {
79
- message.warning('登录已失效,请重新登录')
80
- logout().finally((res) => {
81
- next({ path: '/login' })
82
- })
83
- } else {
84
- next()
85
- }
86
- }
87
- } else if (token) {
88
- const { AESDecrypt } = AES
89
- const info = AESDecrypt(token, '3KMKqvgwR8ULbR8Z')
90
- const { store, message, router } = options
91
- // 单页面通常是嵌入到v3的项目中,没有单独的清除按钮,所以需要清除indexedDB
92
- indexedDB.clear()
93
- if (
94
- (!loginIgnore.includes(to) || to.name === '404') &&
95
- !checkSingleAuthorization('SinglePage', token)
96
- ) {
97
- localStorage.setItem('SinglePage_TOKEN', token)
98
- startLogin({
99
- ...info,
100
- pathname: window.location.pathname.replace(process.env.VUE_APP_PUBLIC_PATH, ''),
101
- store,
102
- router,
103
- })
104
- } else {
105
- const roles = store.getters['account/roles']
106
- let user = {}
107
- try {
108
- user = JSON.parse(localStorage.getItem(process.env.VUE_APP_USER_KEY))
109
- } catch (e) {
110
- user = localStorage.getItem(process.env.VUE_APP_USER_KEY)
111
- }
112
- const setUser = store._mutations['account/setUser'][0]
113
- setUser(user)
114
- if (roles.length === 0 && !loginIgnore.includes(to)) {
115
- message.warning('登录已失效,请重新登录')
116
- logout().finally((res) => {
117
- next({ path: '/login' })
118
- })
119
- } else {
120
- next()
121
- }
122
- }
123
- } else if (tokenV2) {
124
- const { AESDecrypt } = AES
125
- const info = AESDecrypt(tokenV2, '3KMKqvgwR8ULbR8Z')
126
- request(`/rs/user/${info.name}/${info.password}/智慧燃气`, METHOD.GET).then(
127
- res => {
128
- const curUser = {
129
- name: res.name,
130
- username: res.name,
131
- orgid: res.name,
132
- avatar: '',
133
- ename: res.ename,
134
- id: res.id,
135
- orgName: res.f_fengongsi,
136
- contact: '',
137
- phone: '',
138
- orgs: res.orgs
139
- }
140
- Vue.$store.commit('account/setUser', Object.assign(curUser, res))
141
- const login = {
142
- f: res,
143
- jwt: res.id,
144
- r: res.roles
145
- }
146
- Vue.$store.commit('account/setLogin', login)
147
- loadRoutes(funcToRouter(res.functions))
148
- next()
149
- }
150
- )
151
- } else if (V4_LOGIN_DATA_KEY) {
152
- const v4LoginData = JSON.parse(localStorage.getItem('userInfo'))
153
- const curUser = {
154
- name: v4LoginData.name,
155
- username: v4LoginData.name,
156
- orgid: v4LoginData.name,
157
- avatar: '',
158
- ename: v4LoginData.ename,
159
- id: v4LoginData.id,
160
- orgName: v4LoginData.orgs,
161
- contact: '',
162
- phone: '',
163
- orgs: v4LoginData.orgs
164
- }
165
- Vue.$store.commit('account/setUser', Object.assign(curUser, v4LoginData))
166
- const login = {
167
- f: v4LoginData,
168
- jwt: v4LoginData.id,
169
- r: v4LoginData.r
170
- }
171
- Vue.$store.commit('account/setLogin', login)
172
- if (!Vue.$store.state?.setting?.menuData || Vue.$store.state?.setting?.menuData?.length === 0) {
173
- loadRoutes(funcToRouter(v4LoginData.functions))
174
- }
175
- next()
176
- } else {
177
- const { store, message } = options
178
- if (
179
- (!loginIgnore.includes(to) || to.name === '404') &&
180
- !checkAuthorization()
181
- ) {
182
- message.warning('登录已失效,请重新登录')
183
- next({ path: '/login' })
184
- } else {
185
- const roles = store.getters['account/roles']
186
- if (roles.length === 0 && !loginIgnore.includes(to)) {
187
- message.warning('登录已失效,请重新登录')
188
- logout().finally((res) => {
189
- next({ path: '/login' })
190
- })
191
- } else {
192
- next()
193
- }
194
- }
195
- }
196
- }
197
-
198
- /**
199
- * 权限守卫
200
- * @param to
201
- * @param form
202
- * @param next
203
- * @param options
204
- */
205
- const authorityGuard = (to, from, next, options) => {
206
- const { store, message } = options
207
- const permissions = store.getters['account/permissions']
208
- const roles = store.getters['account/roles']
209
- if (!hasAuthority(to, permissions, roles)) {
210
- message.warning(`对不起,您无权访问页面: ${to.fullPath},请联系管理员`)
211
- next({ path: '/403' })
212
- // NProgress.done()
213
- } else {
214
- next()
215
- }
216
- }
217
-
218
- /**
219
- * 混合导航模式下一级菜单跳转重定向
220
- * @param to
221
- * @param from
222
- * @param next
223
- * @param options
224
- * @returns {*}
225
- */
226
- const redirectGuard = (to, from, next, options) => {
227
- const { store } = options
228
- const getFirstChild = (routes) => {
229
- const route = routes[0]
230
- if (!route.children || route.children.length === 0) {
231
- return route
232
- }
233
- return getFirstChild(route.children)
234
- }
235
- if (store.state.setting.layout === 'mix') {
236
- const firstMenu = store.getters['setting/firstMenu']
237
- if (firstMenu.find((item) => item.fullPath === to.fullPath)) {
238
- store.commit('setting/setActivatedFirst', to.fullPath)
239
- const subMenu = store.getters['setting/subMenu']
240
- if (subMenu.length > 0) {
241
- const redirect = getFirstChild(subMenu)
242
- return next({ path: redirect.fullPath })
243
- }
244
- }
245
- }
246
- next()
247
- }
248
-
249
- /**
250
- * 进度条结束
251
- * @param to
252
- * @param form
253
- * @param options
254
- */
255
- const progressDone = () => {
256
- // finish progress bar
257
- NProgress.done()
258
- }
259
-
260
- export default {
261
- beforeEach: [progressStart, loginGuard, authorityGuard, redirectGuard],
262
- afterEach: [progressDone],
263
- }
1
+ import { hasAuthority } from '@vue2-client/utils/authority-utils'
2
+ import { loginIgnore } from '@vue2-client/router/index'
3
+ import { checkAuthorization, METHOD, request } from '@vue2-client/utils/request'
4
+ import NProgress from 'nprogress'
5
+ import { logout } from '@vue2-client/services/user'
6
+ import {
7
+ startLogin,
8
+ checkSingleAuthorization,
9
+ } from '@vue2-client/utils/login'
10
+ import AES from '@vue2-client/utils/EncryptUtil'
11
+ import Vue from 'vue'
12
+ import { funcToRouter, loadRoutes } from '@vue2-client/utils/routerUtil'
13
+ import { indexedDB } from '@vue2-client/utils/indexedDB'
14
+
15
+ NProgress.configure({ showSpinner: false })
16
+
17
+ /**
18
+ * 进度条开始
19
+ * @param to
20
+ * @param form
21
+ * @param next
22
+ */
23
+ const progressStart = (to, form, next) => {
24
+ // start progress bar
25
+ if (!NProgress.isStarted()) {
26
+ NProgress.start()
27
+ }
28
+ next()
29
+ }
30
+
31
+ /**
32
+ * 登录守卫
33
+ * @param to
34
+ * @param form
35
+ * @param next
36
+ * @param options
37
+ */
38
+ const loginGuard = (to, form, next, options) => {
39
+ if (window.__MICRO_APP_ENVIRONMENT__) {
40
+ window.microApp.dispatch({ type: '子应用发送给主应用的数据', to: to.path })
41
+ }
42
+ const urlParams = new URLSearchParams(window.location.search)
43
+ const LoginTicket = urlParams.get('LoginTicket')
44
+ // 如果是需要我们自己登陆的项目
45
+ const token = urlParams.get('token')
46
+ // 如果是v2 的项目 资源管理和营收分开库的那种项目 传递用户信息进来
47
+ const tokenV2 = urlParams.get('tokenV2')
48
+ // 如果是 v4 的父项目,通过localStorage传递信息
49
+ const V4_LOGIN_DATA_KEY = localStorage.getItem('v4LoginData')
50
+ if (LoginTicket) {
51
+ const loginTicket = decodeURIComponent(LoginTicket)
52
+ const { AESDecrypt } = AES
53
+ const info = AESDecrypt(loginTicket, '3KMKqvgwR8ULbR8Z')
54
+ const { store, message, router } = options
55
+ // 单页面通常是嵌入到v3的项目中,没有单独的清除按钮,所以需要清除indexedDB
56
+ indexedDB.clear()
57
+ if (
58
+ (!loginIgnore.includes(to) || to.name === '404') &&
59
+ !checkSingleAuthorization('SinglePage', loginTicket)
60
+ ) {
61
+ localStorage.setItem('SinglePage_TOKEN', loginTicket)
62
+ startLogin({
63
+ ...info,
64
+ pathname: window.location.pathname.replace(process.env.VUE_APP_PUBLIC_PATH, ''),
65
+ store,
66
+ router,
67
+ })
68
+ } else {
69
+ const roles = store.getters['account/roles']
70
+ let user = {}
71
+ try {
72
+ user = JSON.parse(localStorage.getItem(process.env.VUE_APP_USER_KEY))
73
+ } catch (e) {
74
+ user = localStorage.getItem(process.env.VUE_APP_USER_KEY)
75
+ }
76
+ const setUser = store._mutations['account/setUser'][0]
77
+ setUser(user)
78
+ if (roles.length === 0 && !loginIgnore.includes(to)) {
79
+ message.warning('登录已失效,请重新登录')
80
+ logout().finally((res) => {
81
+ next({ path: '/login' })
82
+ })
83
+ } else {
84
+ next()
85
+ }
86
+ }
87
+ } else if (token) {
88
+ const { AESDecrypt } = AES
89
+ const info = AESDecrypt(token, '3KMKqvgwR8ULbR8Z')
90
+ const { store, message, router } = options
91
+ // 单页面通常是嵌入到v3的项目中,没有单独的清除按钮,所以需要清除indexedDB
92
+ indexedDB.clear()
93
+ if (
94
+ (!loginIgnore.includes(to) || to.name === '404') &&
95
+ !checkSingleAuthorization('SinglePage', token)
96
+ ) {
97
+ localStorage.setItem('SinglePage_TOKEN', token)
98
+ startLogin({
99
+ ...info,
100
+ pathname: window.location.pathname.replace(process.env.VUE_APP_PUBLIC_PATH, ''),
101
+ store,
102
+ router,
103
+ })
104
+ } else {
105
+ const roles = store.getters['account/roles']
106
+ let user = {}
107
+ try {
108
+ user = JSON.parse(localStorage.getItem(process.env.VUE_APP_USER_KEY))
109
+ } catch (e) {
110
+ user = localStorage.getItem(process.env.VUE_APP_USER_KEY)
111
+ }
112
+ const setUser = store._mutations['account/setUser'][0]
113
+ setUser(user)
114
+ if (roles.length === 0 && !loginIgnore.includes(to)) {
115
+ message.warning('登录已失效,请重新登录')
116
+ logout().finally((res) => {
117
+ next({ path: '/login' })
118
+ })
119
+ } else {
120
+ next()
121
+ }
122
+ }
123
+ } else if (tokenV2) {
124
+ const { AESDecrypt } = AES
125
+ const info = AESDecrypt(tokenV2, '3KMKqvgwR8ULbR8Z')
126
+ request(`/rs/user/${info.name}/${info.password}/智慧燃气`, METHOD.GET).then(
127
+ res => {
128
+ const curUser = {
129
+ name: res.name,
130
+ username: res.name,
131
+ orgid: res.name,
132
+ avatar: '',
133
+ ename: res.ename,
134
+ id: res.id,
135
+ orgName: res.f_fengongsi,
136
+ contact: '',
137
+ phone: '',
138
+ orgs: res.orgs
139
+ }
140
+ Vue.$store.commit('account/setUser', Object.assign(curUser, res))
141
+ const login = {
142
+ f: res,
143
+ jwt: res.id,
144
+ r: res.roles
145
+ }
146
+ Vue.$store.commit('account/setLogin', login)
147
+ loadRoutes(funcToRouter(res.functions))
148
+ next()
149
+ }
150
+ )
151
+ } else if (V4_LOGIN_DATA_KEY) {
152
+ const v4LoginData = JSON.parse(localStorage.getItem('userInfo'))
153
+ const curUser = {
154
+ name: v4LoginData.name,
155
+ username: v4LoginData.name,
156
+ orgid: v4LoginData.name,
157
+ avatar: '',
158
+ ename: v4LoginData.ename,
159
+ id: v4LoginData.id,
160
+ orgName: v4LoginData.orgs,
161
+ contact: '',
162
+ phone: '',
163
+ orgs: v4LoginData.orgs
164
+ }
165
+ Vue.$store.commit('account/setUser', Object.assign(curUser, v4LoginData))
166
+ const login = {
167
+ f: v4LoginData,
168
+ jwt: v4LoginData.id,
169
+ r: v4LoginData.r
170
+ }
171
+ Vue.$store.commit('account/setLogin', login)
172
+ if (!Vue.$store.state?.setting?.menuData || Vue.$store.state?.setting?.menuData?.length === 0) {
173
+ loadRoutes(funcToRouter(v4LoginData.functions))
174
+ }
175
+ next()
176
+ } else {
177
+ const { store, message } = options
178
+ if (
179
+ (!loginIgnore.includes(to) || to.name === '404') &&
180
+ !checkAuthorization()
181
+ ) {
182
+ message.warning('登录已失效,请重新登录')
183
+ next({ path: '/login' })
184
+ } else {
185
+ const roles = store.getters['account/roles']
186
+ if (roles.length === 0 && !loginIgnore.includes(to)) {
187
+ message.warning('登录已失效,请重新登录')
188
+ logout().finally((res) => {
189
+ next({ path: '/login' })
190
+ })
191
+ } else {
192
+ next()
193
+ }
194
+ }
195
+ }
196
+ }
197
+
198
+ /**
199
+ * 权限守卫
200
+ * @param to
201
+ * @param form
202
+ * @param next
203
+ * @param options
204
+ */
205
+ const authorityGuard = (to, form, next, options) => {
206
+ const { store, message } = options
207
+ const permissions = store.getters['account/permissions']
208
+ const roles = store.getters['account/roles']
209
+ if (!hasAuthority(to, permissions, roles)) {
210
+ message.warning(`对不起,您无权访问页面: ${to.fullPath},请联系管理员`)
211
+ next({ path: '/403' })
212
+ // NProgress.done()
213
+ } else {
214
+ next()
215
+ }
216
+ }
217
+
218
+ /**
219
+ * 混合导航模式下一级菜单跳转重定向
220
+ * @param to
221
+ * @param from
222
+ * @param next
223
+ * @param options
224
+ * @returns {*}
225
+ */
226
+ const redirectGuard = (to, from, next, options) => {
227
+ const { store } = options
228
+ const getFirstChild = (routes) => {
229
+ const route = routes[0]
230
+ if (!route.children || route.children.length === 0) {
231
+ return route
232
+ }
233
+ return getFirstChild(route.children)
234
+ }
235
+ if (store.state.setting.layout === 'mix') {
236
+ const firstMenu = store.getters['setting/firstMenu']
237
+ if (firstMenu.find((item) => item.fullPath === to.fullPath)) {
238
+ store.commit('setting/setActivatedFirst', to.fullPath)
239
+ const subMenu = store.getters['setting/subMenu']
240
+ if (subMenu.length > 0) {
241
+ const redirect = getFirstChild(subMenu)
242
+ return next({ path: redirect.fullPath })
243
+ }
244
+ }
245
+ }
246
+ next()
247
+ }
248
+
249
+ /**
250
+ * 进度条结束
251
+ */
252
+ const progressDone = () => {
253
+ // finish progress bar
254
+ NProgress.done()
255
+ }
256
+
257
+ export default {
258
+ beforeEach: [progressStart, loginGuard, authorityGuard, redirectGuard],
259
+ afterEach: [progressDone],
260
+ }
@@ -1,40 +1,49 @@
1
- /**
2
- * 获取 window 对象
3
- * @returns {Window} window 对象
4
- */
5
- export function getWindow () {
6
- return window
7
- }
8
-
9
- /**
10
- * 判断是否处于 microApp 环境
11
- * @returns {boolean} 如果在 microApp 环境下返回 true,否则返回 false
12
- */
13
- export function isMicroAppEnv () {
14
- return window.__MICRO_APP_ENVIRONMENT__
15
- }
16
-
17
- /**
18
- * 发送事件给基座应用
19
- * @param {Object} data 要传递的数据
20
- * @param {Function} callBack 如果不是 microApp 环境时的回调函数
21
- * @returns {*} 在 microApp 环境下返回 dispatch 的结果,否则执行 callBack
22
- */
23
- export function microDispatch (data, callBack) {
24
- if (window.__MICRO_APP_ENVIRONMENT__) {
25
- return window.microApp.dispatch(data)
26
- }
27
- if (callBack) {
28
- return callBack()
29
- }
30
- }
31
-
32
- /**
33
- * 获取 microApp 的数据
34
- * @returns {*} microApp 的数据,如果不在 microApp 环境下返回 undefined
35
- */
36
- export function getMicroData () {
37
- if (window.__MICRO_APP_ENVIRONMENT__) {
38
- return window.microApp.getData()
39
- }
40
- }
1
+ /**
2
+ * 获取 window 对象
3
+ * @returns {Window} window 对象
4
+ */
5
+ export function getWindow () {
6
+ return window
7
+ }
8
+
9
+ /**
10
+ * 获取当前子应用的 name
11
+ * @returns {string} 子应用的 name
12
+ */
13
+ export function getMicroAppName () {
14
+ // 如果在微前端环境中运行,返回应用名称,否则返回 undefined
15
+ return window.__MICRO_APP_ENVIRONMENT__ ? window.__MICRO_APP_NAME__ : undefined
16
+ }
17
+
18
+ /**
19
+ * 判断是否处于 microApp 环境
20
+ * @returns {boolean} 如果在 microApp 环境下返回 true,否则返回 false
21
+ */
22
+ export function isMicroAppEnv () {
23
+ return window.__MICRO_APP_ENVIRONMENT__
24
+ }
25
+
26
+ /**
27
+ * 发送事件给基座应用
28
+ * @param {Object} data 要传递的数据
29
+ * @param {Function} callBack 如果不是 microApp 环境时的回调函数
30
+ * @returns {*} 在 microApp 环境下返回 dispatch 的结果,否则执行 callBack
31
+ */
32
+ export function microDispatch (data, callBack) {
33
+ if (window.__MICRO_APP_ENVIRONMENT__) {
34
+ return window.microApp.dispatch(data)
35
+ }
36
+ if (callBack) {
37
+ return callBack()
38
+ }
39
+ }
40
+
41
+ /**
42
+ * 获取 microApp 的数据
43
+ * @returns {*} microApp 的数据,如果不在 microApp 环境下返回 undefined
44
+ */
45
+ export function getMicroData () {
46
+ if (window.__MICRO_APP_ENVIRONMENT__) {
47
+ return window.microApp.getData()
48
+ }
49
+ }