af-mobile-client-vue3 1.0.85 → 1.0.87

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.
@@ -1,148 +1,148 @@
1
- <script setup lang="ts">
2
- import { inject, provide, ref } from 'vue'
3
- import { storeToRefs } from 'pinia'
4
- import { Popup as VanPopup } from 'vant'
5
- import XReport from '@af-mobile-client-vue3/components/data/XReportGrid/XReport.vue'
6
- import { useUserStore } from '@af-mobile-client-vue3/stores/modules/user'
7
-
8
- // Props
9
- const props = defineProps({
10
- env: {
11
- type: String,
12
- default: 'prod',
13
- },
14
- })
15
-
16
- // Emits
17
- const emit = defineEmits<{
18
- (e: 'close'): void
19
- (e: 'selectRow', keys: any[], rows: any[]): void
20
- }>()
21
- // 状态管理
22
- const configName = ref('')
23
- const displayOnly = ref(true)
24
- const serverName = ref(process.env.VUE_APP_SYSTEM_NAME)
25
- const loading = ref(false)
26
- const visible = ref(false)
27
- const selectedId = ref(null)
28
- const mixinData = ref({})
29
- const outEnv = ref({})
30
- const attr = ref({})
31
-
32
- // Store
33
- const userStore = useUserStore()
34
- const { user: currUser } = storeToRefs(userStore)
35
-
36
- // Refs
37
- const mainRef = ref()
38
-
39
- // 注入
40
- const getParentComponentByName = inject<Function>('getParentComponentByName')
41
- const setGlobalData = inject<Function>('setGlobalData')
42
- const getGlobalData = inject<Function>('getGlobalData')
43
-
44
- // 提供依赖
45
- provide('getSelectedId', () => getSelectedId())
46
- provide('getSelectedData', () => selectedId.value)
47
- provide('getMixinData', () => mixinData.value)
48
- provide('getOutEnv', () => outEnv.value)
49
- provide('isInAModal', () => true)
50
- provide('currUser', currUser)
51
-
52
- // Methods
53
- function init(params: {
54
- configName?: string
55
- serverName?: string
56
- displayOnly?: boolean
57
- selectedId?: any
58
- outEnv?: Record<string, any>
59
- mixinData?: Record<string, any>
60
- attr?: Record<string, any>
61
- }) {
62
- const {
63
- configName: initConfigName = '',
64
- serverName: initServerName = process.env.VUE_APP_SYSTEM_NAME,
65
- displayOnly: initDisplayOnly = true,
66
- selectedId: initSelectedId = null,
67
- outEnv: initOutEnv = {},
68
- mixinData: initMixinData = {},
69
- attr: initAttr = {},
70
- } = params
71
-
72
- configName.value = initConfigName
73
- serverName.value = initServerName
74
- displayOnly.value = initDisplayOnly
75
- visible.value = true
76
- attr.value = initAttr
77
-
78
- if (initSelectedId)
79
- selectedId.value = initSelectedId
80
-
81
- mixinData.value = initMixinData
82
- outEnv.value = initOutEnv
83
- }
84
-
85
- function getSelectedId() {
86
- if (typeof selectedId.value === 'object') {
87
- if (selectedId.value?.selectedId)
88
- return selectedId.value.selectedId
89
-
90
- if (Object.keys(selectedId.value).length > 0)
91
- return selectedId.value[Object.keys(selectedId.value)[0]]
92
- }
93
- return selectedId.value
94
- }
95
-
96
- function selectRow(selectedRowKeys: any[], selectedRows: any[]) {
97
- console.log('XReportDrawer')
98
- emit('selectRow', selectedRowKeys, selectedRows)
99
- }
100
-
101
- function close() {
102
- loading.value = false
103
- visible.value = false
104
- emit('close')
105
- }
106
-
107
- function getComponentByName(name: string) {
108
- const innerRef = getParentComponentByName?.(name)
109
- if (innerRef)
110
- return innerRef
111
-
112
- return mainRef.value?.getComponentByName(name)
113
- }
114
-
115
- function updateImg(data: any) {
116
- console.log(data)
117
- }
118
-
119
- // 暴露方法
120
- defineExpose({
121
- init,
122
- getComponentByName,
123
- })
124
- </script>
125
-
126
- <template>
127
- <VanPopup
128
- v-model:show="visible"
129
- position="right"
130
- :style="{ width: '85vw', height: '100%' }"
131
- v-bind="attr"
132
- @close="close"
133
- >
134
- <XReport
135
- ref="mainRef"
136
- :env="env"
137
- :use-oss-for-img="false"
138
- :config-name="configName"
139
- :show-img-in-cell="true"
140
- :display-only="displayOnly"
141
- :edit-mode="false"
142
- :show-save-button="false"
143
- :dont-format="true"
144
- @update-img="updateImg"
145
- @select-row="selectRow"
146
- />
147
- </VanPopup>
148
- </template>
1
+ <script setup lang="ts">
2
+ import { inject, provide, ref } from 'vue'
3
+ import { storeToRefs } from 'pinia'
4
+ import { Popup as VanPopup } from 'vant'
5
+ import XReport from '@af-mobile-client-vue3/components/data/XReportGrid/XReport.vue'
6
+ import { useUserStore } from '@af-mobile-client-vue3/stores/modules/user'
7
+
8
+ // Props
9
+ const props = defineProps({
10
+ env: {
11
+ type: String,
12
+ default: 'prod',
13
+ },
14
+ })
15
+
16
+ // Emits
17
+ const emit = defineEmits<{
18
+ (e: 'close'): void
19
+ (e: 'selectRow', keys: any[], rows: any[]): void
20
+ }>()
21
+ // 状态管理
22
+ const configName = ref('')
23
+ const displayOnly = ref(true)
24
+ const serverName = ref(process.env.VUE_APP_SYSTEM_NAME)
25
+ const loading = ref(false)
26
+ const visible = ref(false)
27
+ const selectedId = ref(null)
28
+ const mixinData = ref({})
29
+ const outEnv = ref({})
30
+ const attr = ref({})
31
+
32
+ // Store
33
+ const userStore = useUserStore()
34
+ const { user: currUser } = storeToRefs(userStore)
35
+
36
+ // Refs
37
+ const mainRef = ref()
38
+
39
+ // 注入
40
+ const getParentComponentByName = inject<Function>('getParentComponentByName')
41
+ const setGlobalData = inject<Function>('setGlobalData')
42
+ const getGlobalData = inject<Function>('getGlobalData')
43
+
44
+ // 提供依赖
45
+ provide('getSelectedId', () => getSelectedId())
46
+ provide('getSelectedData', () => selectedId.value)
47
+ provide('getMixinData', () => mixinData.value)
48
+ provide('getOutEnv', () => outEnv.value)
49
+ provide('isInAModal', () => true)
50
+ provide('currUser', currUser)
51
+
52
+ // Methods
53
+ function init(params: {
54
+ configName?: string
55
+ serverName?: string
56
+ displayOnly?: boolean
57
+ selectedId?: any
58
+ outEnv?: Record<string, any>
59
+ mixinData?: Record<string, any>
60
+ attr?: Record<string, any>
61
+ }) {
62
+ const {
63
+ configName: initConfigName = '',
64
+ serverName: initServerName = process.env.VUE_APP_SYSTEM_NAME,
65
+ displayOnly: initDisplayOnly = true,
66
+ selectedId: initSelectedId = null,
67
+ outEnv: initOutEnv = {},
68
+ mixinData: initMixinData = {},
69
+ attr: initAttr = {},
70
+ } = params
71
+
72
+ configName.value = initConfigName
73
+ serverName.value = initServerName
74
+ displayOnly.value = initDisplayOnly
75
+ visible.value = true
76
+ attr.value = initAttr
77
+
78
+ if (initSelectedId)
79
+ selectedId.value = initSelectedId
80
+
81
+ mixinData.value = initMixinData
82
+ outEnv.value = initOutEnv
83
+ }
84
+
85
+ function getSelectedId() {
86
+ if (typeof selectedId.value === 'object') {
87
+ if (selectedId.value?.selectedId)
88
+ return selectedId.value.selectedId
89
+
90
+ if (Object.keys(selectedId.value).length > 0)
91
+ return selectedId.value[Object.keys(selectedId.value)[0]]
92
+ }
93
+ return selectedId.value
94
+ }
95
+
96
+ function selectRow(selectedRowKeys: any[], selectedRows: any[]) {
97
+ console.log('XReportDrawer')
98
+ emit('selectRow', selectedRowKeys, selectedRows)
99
+ }
100
+
101
+ function close() {
102
+ loading.value = false
103
+ visible.value = false
104
+ emit('close')
105
+ }
106
+
107
+ function getComponentByName(name: string) {
108
+ const innerRef = getParentComponentByName?.(name)
109
+ if (innerRef)
110
+ return innerRef
111
+
112
+ return mainRef.value?.getComponentByName(name)
113
+ }
114
+
115
+ function updateImg(data: any) {
116
+ console.log(data)
117
+ }
118
+
119
+ // 暴露方法
120
+ defineExpose({
121
+ init,
122
+ getComponentByName,
123
+ })
124
+ </script>
125
+
126
+ <template>
127
+ <VanPopup
128
+ v-model:show="visible"
129
+ position="right"
130
+ :style="{ width: '85vw', height: '100%' }"
131
+ v-bind="attr"
132
+ @close="close"
133
+ >
134
+ <XReport
135
+ ref="mainRef"
136
+ :env="env"
137
+ :use-oss-for-img="false"
138
+ :config-name="configName"
139
+ :show-img-in-cell="true"
140
+ :display-only="displayOnly"
141
+ :edit-mode="false"
142
+ :show-save-button="false"
143
+ :dont-format="true"
144
+ @update-img="updateImg"
145
+ @select-row="selectRow"
146
+ />
147
+ </VanPopup>
148
+ </template>