vue2-client 1.10.33 → 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.
- package/package.json +107 -107
- package/src/App.vue +196 -196
- package/src/base-client/components/common/XAddNativeForm/demo.vue +43 -43
- package/src/base-client/components/common/XAddReport/XAddReport.vue +1 -1
- package/src/base-client/components/common/XConversation/XConversation.vue +12 -0
- package/src/base-client/components/common/XForm/XForm.vue +393 -393
- package/src/base-client/components/common/XForm/XFormItem.vue +1248 -1248
- package/src/base-client/components/common/XFormCol/XFormCol.vue +157 -157
- package/src/base-client/components/common/XFormTable/XFormTable.vue +12 -0
- package/src/base-client/components/common/XIntervalPicker/XIntervalPicker.vue +121 -121
- package/src/base-client/components/common/XReportDrawer/XReportDrawer.vue +1 -1
- package/src/base-client/components/common/XReportGrid/XReport.vue +1079 -1070
- package/src/base-client/components/common/XReportGrid/XReportDemo.vue +46 -47
- package/src/base-client/components/common/XReportGrid/XReportDesign.vue +628 -628
- package/src/base-client/components/common/XReportGrid/XReportJsonRender.vue +380 -380
- package/src/base-client/components/common/XReportGrid/XReportTrGroup.vue +1104 -1104
- package/src/base-client/components/common/XReportGrid/print.js +184 -184
- package/src/base-client/components/common/XTab/XTab.vue +57 -25
- package/src/components/cache/AKeepAlive.js +179 -179
- package/src/layouts/BlankView.vue +78 -78
- package/src/pages/ReportGrid/index.vue +76 -76
- package/src/router/async/router.map.js +2 -2
- package/src/utils/microAppUtils.js +49 -49
|
@@ -1,179 +1,179 @@
|
|
|
1
|
-
import { isDef, isRegExp, remove } from '@vue2-client/utils/util'
|
|
2
|
-
|
|
3
|
-
const patternTypes = [String, RegExp, Array]
|
|
4
|
-
|
|
5
|
-
function matches (pattern, name) {
|
|
6
|
-
if (Array.isArray(pattern)) {
|
|
7
|
-
if (pattern.indexOf(name) > -1) {
|
|
8
|
-
return true
|
|
9
|
-
} else {
|
|
10
|
-
for (const item of pattern) {
|
|
11
|
-
if (isRegExp(item) && item.test(name)) {
|
|
12
|
-
return true
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
return false
|
|
16
|
-
}
|
|
17
|
-
} else if (typeof pattern === 'string') {
|
|
18
|
-
return pattern.split(',').indexOf(name) > -1
|
|
19
|
-
} else if (isRegExp(pattern)) {
|
|
20
|
-
return pattern.test(name)
|
|
21
|
-
}
|
|
22
|
-
/* istanbul ignore next */
|
|
23
|
-
return false
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
function getComponentName (opts) {
|
|
27
|
-
return opts && (opts.Ctor.options.name || opts.tag)
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function getComponentKey (vnode) {
|
|
31
|
-
const { componentOptions, key } = vnode
|
|
32
|
-
return key == null
|
|
33
|
-
? componentOptions.Ctor.cid + (componentOptions.tag ? `::${componentOptions.tag}` : '')
|
|
34
|
-
: key + `::${componentOptions.Ctor.cid}`
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
function getFirstComponentChild (children) {
|
|
38
|
-
if (Array.isArray(children)) {
|
|
39
|
-
for (let i = 0; i < children.length; i++) {
|
|
40
|
-
const c = children[i]
|
|
41
|
-
if (isDef(c) && (isDef(c.componentOptions) || c.isAsyncPlaceholder)) {
|
|
42
|
-
return c
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function pruneCache (keepAliveInstance, filter) {
|
|
49
|
-
const { cache, keys, _vnode } = keepAliveInstance
|
|
50
|
-
for (const key in cache) {
|
|
51
|
-
const cachedNode = cache[key]
|
|
52
|
-
if (cachedNode) {
|
|
53
|
-
const name = getComponentName(cachedNode.componentOptions)
|
|
54
|
-
const componentKey = getComponentKey(cachedNode)
|
|
55
|
-
if (name && !filter(name, componentKey)) {
|
|
56
|
-
pruneCacheEntry(cache, key, keys, _vnode)
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
function pruneCacheEntry2 (cache, key, keys) {
|
|
63
|
-
const cached = cache[key]
|
|
64
|
-
if (cached) {
|
|
65
|
-
cached.componentInstance.$destroy()
|
|
66
|
-
}
|
|
67
|
-
cache[key] = null
|
|
68
|
-
remove(keys, key)
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
function pruneCacheEntry (cache, key, keys, current) {
|
|
72
|
-
const cached = cache[key]
|
|
73
|
-
if (cached && (!current || cached.tag !== current.tag)) {
|
|
74
|
-
cached.componentInstance.$destroy()
|
|
75
|
-
}
|
|
76
|
-
cache[key] = null
|
|
77
|
-
remove(keys, key)
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
export default {
|
|
81
|
-
name: 'AKeepAlive',
|
|
82
|
-
abstract: true,
|
|
83
|
-
model: {
|
|
84
|
-
prop: 'clearCaches',
|
|
85
|
-
event: 'clear'
|
|
86
|
-
},
|
|
87
|
-
props: {
|
|
88
|
-
include: patternTypes,
|
|
89
|
-
exclude: patternTypes,
|
|
90
|
-
excludeKeys: patternTypes,
|
|
91
|
-
max: [String, Number],
|
|
92
|
-
clearCaches: Array
|
|
93
|
-
},
|
|
94
|
-
watch: {
|
|
95
|
-
clearCaches: function (val) {
|
|
96
|
-
if (val && val.length > 0) {
|
|
97
|
-
const { cache, keys } = this
|
|
98
|
-
// 遍历所有缓存的 keys,找到以传入的 key 开头的项进行清除
|
|
99
|
-
keys.forEach(cacheKey => {
|
|
100
|
-
val.forEach(targetKey => {
|
|
101
|
-
// 检查缓存的 key 是否以目标 key 开头
|
|
102
|
-
console.warn('clearCaches:', cacheKey, targetKey, cacheKey.includes(`${targetKey}::`) || cacheKey.startsWith(targetKey))
|
|
103
|
-
if (cacheKey.includes(`${targetKey}::`) || cacheKey.startsWith(targetKey)) {
|
|
104
|
-
pruneCacheEntry2(cache, cacheKey, keys)
|
|
105
|
-
}
|
|
106
|
-
})
|
|
107
|
-
})
|
|
108
|
-
this.$emit('clear', [])
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
},
|
|
112
|
-
|
|
113
|
-
created () {
|
|
114
|
-
this.cache = Object.create(null)
|
|
115
|
-
this.keys = []
|
|
116
|
-
},
|
|
117
|
-
|
|
118
|
-
destroyed () {
|
|
119
|
-
for (const key in this.cache) {
|
|
120
|
-
pruneCacheEntry(this.cache, key, this.keys)
|
|
121
|
-
}
|
|
122
|
-
},
|
|
123
|
-
|
|
124
|
-
mounted () {
|
|
125
|
-
this.$watch('include', val => {
|
|
126
|
-
pruneCache(this, (name) => matches(val, name))
|
|
127
|
-
})
|
|
128
|
-
this.$watch('exclude', val => {
|
|
129
|
-
pruneCache(this, (name) => !matches(val, name))
|
|
130
|
-
})
|
|
131
|
-
this.$watch('excludeKeys', val => {
|
|
132
|
-
pruneCache(this, (name, key) => !matches(val, key))
|
|
133
|
-
})
|
|
134
|
-
},
|
|
135
|
-
|
|
136
|
-
render () {
|
|
137
|
-
const slot = this.$slots.default
|
|
138
|
-
const vnode = getFirstComponentChild(slot)
|
|
139
|
-
const componentOptions = vnode && vnode.componentOptions
|
|
140
|
-
if (componentOptions) {
|
|
141
|
-
// check pattern
|
|
142
|
-
const name = getComponentName(componentOptions)
|
|
143
|
-
const componentKey = getComponentKey(vnode)
|
|
144
|
-
const { include, exclude, excludeKeys } = this
|
|
145
|
-
if (
|
|
146
|
-
// not included
|
|
147
|
-
(include && (!name || !matches(include, name))) ||
|
|
148
|
-
// excluded
|
|
149
|
-
(exclude && name && matches(exclude, name)) ||
|
|
150
|
-
(excludeKeys && componentKey && matches(excludeKeys, componentKey))
|
|
151
|
-
) {
|
|
152
|
-
return vnode
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
const { cache, keys } = this
|
|
156
|
-
const key = vnode.key == null
|
|
157
|
-
// same constructor may get registered as different local components
|
|
158
|
-
// so cid alone is not enough (#3269)
|
|
159
|
-
? componentOptions.Ctor.cid + (componentOptions.tag ? `::${componentOptions.tag}` : '')
|
|
160
|
-
: vnode.key + `::${componentOptions.Ctor.cid}`
|
|
161
|
-
if (cache[key]) {
|
|
162
|
-
vnode.componentInstance = cache[key].componentInstance
|
|
163
|
-
// make current key freshest
|
|
164
|
-
remove(keys, key)
|
|
165
|
-
keys.push(key)
|
|
166
|
-
} else {
|
|
167
|
-
cache[key] = vnode
|
|
168
|
-
keys.push(key)
|
|
169
|
-
// prune oldest entry
|
|
170
|
-
if (this.max && keys.length > parseInt(this.max)) {
|
|
171
|
-
pruneCacheEntry(cache, keys[0], keys, this._vnode)
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
vnode.data.keepAlive = true
|
|
176
|
-
}
|
|
177
|
-
return vnode || (slot && slot[0])
|
|
178
|
-
}
|
|
179
|
-
}
|
|
1
|
+
import { isDef, isRegExp, remove } from '@vue2-client/utils/util'
|
|
2
|
+
|
|
3
|
+
const patternTypes = [String, RegExp, Array]
|
|
4
|
+
|
|
5
|
+
function matches (pattern, name) {
|
|
6
|
+
if (Array.isArray(pattern)) {
|
|
7
|
+
if (pattern.indexOf(name) > -1) {
|
|
8
|
+
return true
|
|
9
|
+
} else {
|
|
10
|
+
for (const item of pattern) {
|
|
11
|
+
if (isRegExp(item) && item.test(name)) {
|
|
12
|
+
return true
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return false
|
|
16
|
+
}
|
|
17
|
+
} else if (typeof pattern === 'string') {
|
|
18
|
+
return pattern.split(',').indexOf(name) > -1
|
|
19
|
+
} else if (isRegExp(pattern)) {
|
|
20
|
+
return pattern.test(name)
|
|
21
|
+
}
|
|
22
|
+
/* istanbul ignore next */
|
|
23
|
+
return false
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function getComponentName (opts) {
|
|
27
|
+
return opts && (opts.Ctor.options.name || opts.tag)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function getComponentKey (vnode) {
|
|
31
|
+
const { componentOptions, key } = vnode
|
|
32
|
+
return key == null
|
|
33
|
+
? componentOptions.Ctor.cid + (componentOptions.tag ? `::${componentOptions.tag}` : '')
|
|
34
|
+
: key + `::${componentOptions.Ctor.cid}`
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function getFirstComponentChild (children) {
|
|
38
|
+
if (Array.isArray(children)) {
|
|
39
|
+
for (let i = 0; i < children.length; i++) {
|
|
40
|
+
const c = children[i]
|
|
41
|
+
if (isDef(c) && (isDef(c.componentOptions) || c.isAsyncPlaceholder)) {
|
|
42
|
+
return c
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function pruneCache (keepAliveInstance, filter) {
|
|
49
|
+
const { cache, keys, _vnode } = keepAliveInstance
|
|
50
|
+
for (const key in cache) {
|
|
51
|
+
const cachedNode = cache[key]
|
|
52
|
+
if (cachedNode) {
|
|
53
|
+
const name = getComponentName(cachedNode.componentOptions)
|
|
54
|
+
const componentKey = getComponentKey(cachedNode)
|
|
55
|
+
if (name && !filter(name, componentKey)) {
|
|
56
|
+
pruneCacheEntry(cache, key, keys, _vnode)
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function pruneCacheEntry2 (cache, key, keys) {
|
|
63
|
+
const cached = cache[key]
|
|
64
|
+
if (cached) {
|
|
65
|
+
cached.componentInstance.$destroy()
|
|
66
|
+
}
|
|
67
|
+
cache[key] = null
|
|
68
|
+
remove(keys, key)
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function pruneCacheEntry (cache, key, keys, current) {
|
|
72
|
+
const cached = cache[key]
|
|
73
|
+
if (cached && (!current || cached.tag !== current.tag)) {
|
|
74
|
+
cached.componentInstance.$destroy()
|
|
75
|
+
}
|
|
76
|
+
cache[key] = null
|
|
77
|
+
remove(keys, key)
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export default {
|
|
81
|
+
name: 'AKeepAlive',
|
|
82
|
+
abstract: true,
|
|
83
|
+
model: {
|
|
84
|
+
prop: 'clearCaches',
|
|
85
|
+
event: 'clear'
|
|
86
|
+
},
|
|
87
|
+
props: {
|
|
88
|
+
include: patternTypes,
|
|
89
|
+
exclude: patternTypes,
|
|
90
|
+
excludeKeys: patternTypes,
|
|
91
|
+
max: [String, Number],
|
|
92
|
+
clearCaches: Array
|
|
93
|
+
},
|
|
94
|
+
watch: {
|
|
95
|
+
clearCaches: function (val) {
|
|
96
|
+
if (val && val.length > 0) {
|
|
97
|
+
const { cache, keys } = this
|
|
98
|
+
// 遍历所有缓存的 keys,找到以传入的 key 开头的项进行清除
|
|
99
|
+
keys.forEach(cacheKey => {
|
|
100
|
+
val.forEach(targetKey => {
|
|
101
|
+
// 检查缓存的 key 是否以目标 key 开头
|
|
102
|
+
console.warn('clearCaches:', cacheKey, targetKey, cacheKey.includes(`${targetKey}::`) || cacheKey.startsWith(targetKey))
|
|
103
|
+
if (cacheKey.includes(`${targetKey}::`) || cacheKey.startsWith(targetKey)) {
|
|
104
|
+
pruneCacheEntry2(cache, cacheKey, keys)
|
|
105
|
+
}
|
|
106
|
+
})
|
|
107
|
+
})
|
|
108
|
+
this.$emit('clear', [])
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
|
|
113
|
+
created () {
|
|
114
|
+
this.cache = Object.create(null)
|
|
115
|
+
this.keys = []
|
|
116
|
+
},
|
|
117
|
+
|
|
118
|
+
destroyed () {
|
|
119
|
+
for (const key in this.cache) {
|
|
120
|
+
pruneCacheEntry(this.cache, key, this.keys)
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
|
|
124
|
+
mounted () {
|
|
125
|
+
this.$watch('include', val => {
|
|
126
|
+
pruneCache(this, (name) => matches(val, name))
|
|
127
|
+
})
|
|
128
|
+
this.$watch('exclude', val => {
|
|
129
|
+
pruneCache(this, (name) => !matches(val, name))
|
|
130
|
+
})
|
|
131
|
+
this.$watch('excludeKeys', val => {
|
|
132
|
+
pruneCache(this, (name, key) => !matches(val, key))
|
|
133
|
+
})
|
|
134
|
+
},
|
|
135
|
+
|
|
136
|
+
render () {
|
|
137
|
+
const slot = this.$slots.default
|
|
138
|
+
const vnode = getFirstComponentChild(slot)
|
|
139
|
+
const componentOptions = vnode && vnode.componentOptions
|
|
140
|
+
if (componentOptions) {
|
|
141
|
+
// check pattern
|
|
142
|
+
const name = getComponentName(componentOptions)
|
|
143
|
+
const componentKey = getComponentKey(vnode)
|
|
144
|
+
const { include, exclude, excludeKeys } = this
|
|
145
|
+
if (
|
|
146
|
+
// not included
|
|
147
|
+
(include && (!name || !matches(include, name))) ||
|
|
148
|
+
// excluded
|
|
149
|
+
(exclude && name && matches(exclude, name)) ||
|
|
150
|
+
(excludeKeys && componentKey && matches(excludeKeys, componentKey))
|
|
151
|
+
) {
|
|
152
|
+
return vnode
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
const { cache, keys } = this
|
|
156
|
+
const key = vnode.key == null
|
|
157
|
+
// same constructor may get registered as different local components
|
|
158
|
+
// so cid alone is not enough (#3269)
|
|
159
|
+
? componentOptions.Ctor.cid + (componentOptions.tag ? `::${componentOptions.tag}` : '')
|
|
160
|
+
: vnode.key + `::${componentOptions.Ctor.cid}`
|
|
161
|
+
if (cache[key]) {
|
|
162
|
+
vnode.componentInstance = cache[key].componentInstance
|
|
163
|
+
// make current key freshest
|
|
164
|
+
remove(keys, key)
|
|
165
|
+
keys.push(key)
|
|
166
|
+
} else {
|
|
167
|
+
cache[key] = vnode
|
|
168
|
+
keys.push(key)
|
|
169
|
+
// prune oldest entry
|
|
170
|
+
if (this.max && keys.length > parseInt(this.max)) {
|
|
171
|
+
pruneCacheEntry(cache, keys[0], keys, this._vnode)
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
vnode.data.keepAlive = true
|
|
176
|
+
}
|
|
177
|
+
return vnode || (slot && slot[0])
|
|
178
|
+
}
|
|
179
|
+
}
|
|
@@ -1,78 +1,78 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<page-toggle-transition :disabled="animate.disabled" :animate="animate.name" :direction="animate.direction">
|
|
3
|
-
<a-keep-alive :exclude-keys="excludeKeys" v-if="cachePage" v-model="clearCaches">
|
|
4
|
-
<router-view v-if="!refreshing" :key="$route.path" />
|
|
5
|
-
</a-keep-alive>
|
|
6
|
-
<router-view v-else-if="!refreshing" />
|
|
7
|
-
</page-toggle-transition>
|
|
8
|
-
</template>
|
|
9
|
-
|
|
10
|
-
<script>
|
|
11
|
-
import PageToggleTransition from '../components/transition/PageToggleTransition'
|
|
12
|
-
import { mapState } from 'vuex'
|
|
13
|
-
import AKeepAlive from '@vue2-client/components/cache/AKeepAlive'
|
|
14
|
-
|
|
15
|
-
export default {
|
|
16
|
-
name: 'BlankView',
|
|
17
|
-
components: { PageToggleTransition, AKeepAlive },
|
|
18
|
-
data () {
|
|
19
|
-
return {
|
|
20
|
-
clearCaches: [],
|
|
21
|
-
excludeKeys: [],
|
|
22
|
-
refreshing: false
|
|
23
|
-
}
|
|
24
|
-
},
|
|
25
|
-
computed: {
|
|
26
|
-
...mapState('setting', ['cachePage', 'animate'])
|
|
27
|
-
},
|
|
28
|
-
created () {
|
|
29
|
-
this.loadCacheConfig(this.$router?.options?.routes)
|
|
30
|
-
},
|
|
31
|
-
mounted () {
|
|
32
|
-
if (window.__MICRO_APP_ENVIRONMENT__) {
|
|
33
|
-
window.microApp.addDataListener((data) => {
|
|
34
|
-
if (data.type === 'refresh') {
|
|
35
|
-
this.refresh()
|
|
36
|
-
} else if (data.type === 'clearCache' && data.key) {
|
|
37
|
-
this.clearCache(data.key)
|
|
38
|
-
}
|
|
39
|
-
})
|
|
40
|
-
}
|
|
41
|
-
},
|
|
42
|
-
methods: {
|
|
43
|
-
// 加载需要排除缓存的路由配置
|
|
44
|
-
loadCacheConfig (routes, pCache = true) {
|
|
45
|
-
routes.forEach(item => {
|
|
46
|
-
const cacheAble = item.meta?.page?.cacheAble ?? pCache ?? true
|
|
47
|
-
if (!cacheAble) {
|
|
48
|
-
this.excludeKeys.push(new RegExp(`${item.path.replace(/:[^/]*/g, '[^/]*')}(\\?.*)?\\d*$`))
|
|
49
|
-
}
|
|
50
|
-
if (item.children) {
|
|
51
|
-
this.loadCacheConfig(item.children, cacheAble)
|
|
52
|
-
}
|
|
53
|
-
})
|
|
54
|
-
},
|
|
55
|
-
// 刷新页面方法
|
|
56
|
-
refresh () {
|
|
57
|
-
this.refreshing = true
|
|
58
|
-
setTimeout(() => {
|
|
59
|
-
this.refreshing = false
|
|
60
|
-
}, 200)
|
|
61
|
-
},
|
|
62
|
-
// 清除特定页面的缓存
|
|
63
|
-
clearCache (resultKeys) {
|
|
64
|
-
this.clearCaches = resultKeys
|
|
65
|
-
}
|
|
66
|
-
},
|
|
67
|
-
watch: {
|
|
68
|
-
'$router.options.routes': function (val) {
|
|
69
|
-
this.excludeKeys = []
|
|
70
|
-
this.loadCacheConfig(val)
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
</script>
|
|
75
|
-
|
|
76
|
-
<style scoped>
|
|
77
|
-
|
|
78
|
-
</style>
|
|
1
|
+
<template>
|
|
2
|
+
<page-toggle-transition :disabled="animate.disabled" :animate="animate.name" :direction="animate.direction">
|
|
3
|
+
<a-keep-alive :exclude-keys="excludeKeys" v-if="cachePage" v-model="clearCaches">
|
|
4
|
+
<router-view v-if="!refreshing" :key="$route.path" />
|
|
5
|
+
</a-keep-alive>
|
|
6
|
+
<router-view v-else-if="!refreshing" />
|
|
7
|
+
</page-toggle-transition>
|
|
8
|
+
</template>
|
|
9
|
+
|
|
10
|
+
<script>
|
|
11
|
+
import PageToggleTransition from '../components/transition/PageToggleTransition'
|
|
12
|
+
import { mapState } from 'vuex'
|
|
13
|
+
import AKeepAlive from '@vue2-client/components/cache/AKeepAlive'
|
|
14
|
+
|
|
15
|
+
export default {
|
|
16
|
+
name: 'BlankView',
|
|
17
|
+
components: { PageToggleTransition, AKeepAlive },
|
|
18
|
+
data () {
|
|
19
|
+
return {
|
|
20
|
+
clearCaches: [],
|
|
21
|
+
excludeKeys: [],
|
|
22
|
+
refreshing: false
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
computed: {
|
|
26
|
+
...mapState('setting', ['cachePage', 'animate'])
|
|
27
|
+
},
|
|
28
|
+
created () {
|
|
29
|
+
this.loadCacheConfig(this.$router?.options?.routes)
|
|
30
|
+
},
|
|
31
|
+
mounted () {
|
|
32
|
+
if (window.__MICRO_APP_ENVIRONMENT__) {
|
|
33
|
+
window.microApp.addDataListener((data) => {
|
|
34
|
+
if (data.type === 'refresh') {
|
|
35
|
+
this.refresh()
|
|
36
|
+
} else if (data.type === 'clearCache' && data.key) {
|
|
37
|
+
this.clearCache(data.key)
|
|
38
|
+
}
|
|
39
|
+
})
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
methods: {
|
|
43
|
+
// 加载需要排除缓存的路由配置
|
|
44
|
+
loadCacheConfig (routes, pCache = true) {
|
|
45
|
+
routes.forEach(item => {
|
|
46
|
+
const cacheAble = item.meta?.page?.cacheAble ?? pCache ?? true
|
|
47
|
+
if (!cacheAble) {
|
|
48
|
+
this.excludeKeys.push(new RegExp(`${item.path.replace(/:[^/]*/g, '[^/]*')}(\\?.*)?\\d*$`))
|
|
49
|
+
}
|
|
50
|
+
if (item.children) {
|
|
51
|
+
this.loadCacheConfig(item.children, cacheAble)
|
|
52
|
+
}
|
|
53
|
+
})
|
|
54
|
+
},
|
|
55
|
+
// 刷新页面方法
|
|
56
|
+
refresh () {
|
|
57
|
+
this.refreshing = true
|
|
58
|
+
setTimeout(() => {
|
|
59
|
+
this.refreshing = false
|
|
60
|
+
}, 200)
|
|
61
|
+
},
|
|
62
|
+
// 清除特定页面的缓存
|
|
63
|
+
clearCache (resultKeys) {
|
|
64
|
+
this.clearCaches = resultKeys
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
watch: {
|
|
68
|
+
'$router.options.routes': function (val) {
|
|
69
|
+
this.excludeKeys = []
|
|
70
|
+
this.loadCacheConfig(val)
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
</script>
|
|
75
|
+
|
|
76
|
+
<style scoped>
|
|
77
|
+
|
|
78
|
+
</style>
|
|
@@ -1,76 +1,76 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div id="test" v-if="showReport">
|
|
3
|
-
<XReport
|
|
4
|
-
@updateImg="updateImg"
|
|
5
|
-
ref="main"
|
|
6
|
-
:use-oss-for-img="false"
|
|
7
|
-
config-name="medicineMouldCover"
|
|
8
|
-
server-name="af-his"
|
|
9
|
-
:show-img-in-cell="true"
|
|
10
|
-
:display-only="displayOnly"
|
|
11
|
-
:edit-mode="false"
|
|
12
|
-
:show-save-button="false"
|
|
13
|
-
:dont-format="true"/>
|
|
14
|
-
</div>
|
|
15
|
-
</template>
|
|
16
|
-
|
|
17
|
-
<script>
|
|
18
|
-
import XReport from '@vue2-client/base-client/components/common/XReportGrid/XReport'
|
|
19
|
-
// eslint-disable-next-line no-unused-vars
|
|
20
|
-
import { exportHTMLNodeToPDF } from '@vue2-client/utils/htmlToPDFApi'
|
|
21
|
-
|
|
22
|
-
export default {
|
|
23
|
-
name: 'Example',
|
|
24
|
-
components: {
|
|
25
|
-
XReport
|
|
26
|
-
},
|
|
27
|
-
mounted () {
|
|
28
|
-
console.log(this.$route)
|
|
29
|
-
},
|
|
30
|
-
data () {
|
|
31
|
-
return {
|
|
32
|
-
test: {
|
|
33
|
-
title: {
|
|
34
|
-
type: 'titleKey',
|
|
35
|
-
value: 'f_type'
|
|
36
|
-
},
|
|
37
|
-
designMode: 'json',
|
|
38
|
-
},
|
|
39
|
-
total: 1,
|
|
40
|
-
registerMap: [],
|
|
41
|
-
displayOnly: true,
|
|
42
|
-
showReport: true
|
|
43
|
-
}
|
|
44
|
-
},
|
|
45
|
-
methods: {
|
|
46
|
-
updateImg (data) {
|
|
47
|
-
console.warn('demo', data)
|
|
48
|
-
},
|
|
49
|
-
testExport () {
|
|
50
|
-
this.showReport = false
|
|
51
|
-
this.displayOnly = true
|
|
52
|
-
this.$nextTick(() => {
|
|
53
|
-
this.showReport = true
|
|
54
|
-
setTimeout(() => {
|
|
55
|
-
exportHTMLNodeToPDF('123', '#test')
|
|
56
|
-
this.showReport = false
|
|
57
|
-
this.displayOnly = false
|
|
58
|
-
this.$nextTick(() => {
|
|
59
|
-
this.showReport = true
|
|
60
|
-
})
|
|
61
|
-
}, 500)
|
|
62
|
-
})
|
|
63
|
-
},
|
|
64
|
-
testSave () {
|
|
65
|
-
const result = []
|
|
66
|
-
this.registerMap.forEach(item => {
|
|
67
|
-
result.push(item.exportData())
|
|
68
|
-
})
|
|
69
|
-
console.warn('save', result)
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
</script>
|
|
74
|
-
<style scoped>
|
|
75
|
-
|
|
76
|
-
</style>
|
|
1
|
+
<template>
|
|
2
|
+
<div id="test" v-if="showReport">
|
|
3
|
+
<XReport
|
|
4
|
+
@updateImg="updateImg"
|
|
5
|
+
ref="main"
|
|
6
|
+
:use-oss-for-img="false"
|
|
7
|
+
config-name="medicineMouldCover"
|
|
8
|
+
server-name="af-his"
|
|
9
|
+
:show-img-in-cell="true"
|
|
10
|
+
:display-only="displayOnly"
|
|
11
|
+
:edit-mode="false"
|
|
12
|
+
:show-save-button="false"
|
|
13
|
+
:dont-format="true"/>
|
|
14
|
+
</div>
|
|
15
|
+
</template>
|
|
16
|
+
|
|
17
|
+
<script>
|
|
18
|
+
import XReport from '@vue2-client/base-client/components/common/XReportGrid/XReport'
|
|
19
|
+
// eslint-disable-next-line no-unused-vars
|
|
20
|
+
import { exportHTMLNodeToPDF } from '@vue2-client/utils/htmlToPDFApi'
|
|
21
|
+
|
|
22
|
+
export default {
|
|
23
|
+
name: 'Example',
|
|
24
|
+
components: {
|
|
25
|
+
XReport
|
|
26
|
+
},
|
|
27
|
+
mounted () {
|
|
28
|
+
console.log(this.$route)
|
|
29
|
+
},
|
|
30
|
+
data () {
|
|
31
|
+
return {
|
|
32
|
+
test: {
|
|
33
|
+
title: {
|
|
34
|
+
type: 'titleKey',
|
|
35
|
+
value: 'f_type'
|
|
36
|
+
},
|
|
37
|
+
designMode: 'json',
|
|
38
|
+
},
|
|
39
|
+
total: 1,
|
|
40
|
+
registerMap: [],
|
|
41
|
+
displayOnly: true,
|
|
42
|
+
showReport: true
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
methods: {
|
|
46
|
+
updateImg (data) {
|
|
47
|
+
console.warn('demo', data)
|
|
48
|
+
},
|
|
49
|
+
testExport () {
|
|
50
|
+
this.showReport = false
|
|
51
|
+
this.displayOnly = true
|
|
52
|
+
this.$nextTick(() => {
|
|
53
|
+
this.showReport = true
|
|
54
|
+
setTimeout(() => {
|
|
55
|
+
exportHTMLNodeToPDF('123', '#test')
|
|
56
|
+
this.showReport = false
|
|
57
|
+
this.displayOnly = false
|
|
58
|
+
this.$nextTick(() => {
|
|
59
|
+
this.showReport = true
|
|
60
|
+
})
|
|
61
|
+
}, 500)
|
|
62
|
+
})
|
|
63
|
+
},
|
|
64
|
+
testSave () {
|
|
65
|
+
const result = []
|
|
66
|
+
this.registerMap.forEach(item => {
|
|
67
|
+
result.push(item.exportData())
|
|
68
|
+
})
|
|
69
|
+
console.warn('save', result)
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
</script>
|
|
74
|
+
<style scoped>
|
|
75
|
+
|
|
76
|
+
</style>
|