af-mobile-client-vue3 1.0.84 → 1.0.85

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.
@@ -0,0 +1,202 @@
1
+ <script setup lang="ts">
2
+ import { inject, provide, ref } from 'vue'
3
+ import { storeToRefs } from 'pinia'
4
+ import { Dialog as VanDialog, showDialog } from 'vant'
5
+ import { useUserStore } from '@af-mobile-client-vue3/stores/modules/user'
6
+ import { executeStrFunctionByContext } from '@af-mobile-client-vue3/utils/runEvalFunction'
7
+ import XReport from '@af-mobile-client-vue3/components/data/XReportGrid/XReport.vue'
8
+
9
+ // Props
10
+ const props = defineProps({
11
+ env: {
12
+ type: String,
13
+ default: 'prod',
14
+ },
15
+ })
16
+
17
+ // Emits
18
+ const emit = defineEmits<{
19
+ (e: 'close'): void
20
+ (e: 'selectRow', keys: any[], rows: any[]): void
21
+ }>()
22
+ // 状态管理
23
+ const showReport = ref(true)
24
+ const configName = ref('')
25
+ const displayOnly = ref(true)
26
+ const serverName = ref(process.env.VUE_APP_SYSTEM_NAME)
27
+ const loading = ref(false)
28
+ const visible = ref(false)
29
+ const selectedId = ref(null)
30
+ const mixinData = ref({})
31
+ const outEnv = ref({})
32
+ const attr = ref({})
33
+
34
+ // Store
35
+ const userStore = useUserStore()
36
+ const { user: currUser } = storeToRefs(userStore)
37
+
38
+ // Refs
39
+ const mainRef = ref()
40
+
41
+ // 注入
42
+ const getParentComponentByName = inject<Function>('getParentComponentByName')
43
+ const setGlobalData = inject<Function>('setGlobalData')
44
+ const getGlobalData = inject<Function>('getGlobalData')
45
+
46
+ // 提供依赖
47
+ provide('getSelectedId', () => getSelectedId())
48
+ provide('getSelectedData', () => selectedId.value)
49
+ provide('getMixinData', () => mixinData.value)
50
+ provide('getOutEnv', () => outEnv.value)
51
+ provide('isInAModal', () => true)
52
+ provide('currUser', currUser)
53
+
54
+ // Methods
55
+ function init(params: {
56
+ configName?: string
57
+ serverName?: string
58
+ displayOnly?: boolean
59
+ selectedId?: any
60
+ outEnv?: Record<string, any>
61
+ mixinData?: Record<string, any>
62
+ attr?: Record<string, any>
63
+ }) {
64
+ const {
65
+ configName: initConfigName = 'medicalRecordCover',
66
+ serverName: initServerName = process.env.VUE_APP_SYSTEM_NAME,
67
+ displayOnly: initDisplayOnly = true,
68
+ selectedId: initSelectedId = null,
69
+ outEnv: initOutEnv = {},
70
+ mixinData: initMixinData = {},
71
+ attr: initAttr = {},
72
+ } = params
73
+
74
+ configName.value = initConfigName
75
+ serverName.value = initServerName
76
+ displayOnly.value = initDisplayOnly
77
+ visible.value = true
78
+ attr.value = initAttr
79
+
80
+ if (initSelectedId)
81
+ selectedId.value = initSelectedId
82
+
83
+ mixinData.value = initMixinData
84
+ outEnv.value = initOutEnv
85
+ }
86
+
87
+ function getSelectedId() {
88
+ if (typeof selectedId.value === 'object') {
89
+ if (selectedId.value?.selectedId)
90
+ return selectedId.value.selectedId
91
+
92
+ if (Object.keys(selectedId.value).length > 0)
93
+ return selectedId.value[Object.keys(selectedId.value)[0]]
94
+ }
95
+ return selectedId.value
96
+ }
97
+
98
+ function selectRow(selectedRowKeys: any[], selectedRows: any[]) {
99
+ console.log('XAddReport')
100
+ emit('selectRow', selectedRowKeys, selectedRows)
101
+ }
102
+
103
+ function close() {
104
+ loading.value = false
105
+ visible.value = false
106
+ emit('close')
107
+ }
108
+
109
+ function getComponentByName(name: string) {
110
+ const innerRef = getParentComponentByName?.(name)
111
+ if (innerRef)
112
+ return innerRef
113
+
114
+ return mainRef.value?.getComponentByName(name)
115
+ }
116
+
117
+ async function onSubmit() {
118
+ if (mainRef.value?.config?.confirmFunction) {
119
+ console.info('执行自定义确认逻辑')
120
+ let func = mainRef.value.config.confirmFunction
121
+ if (func && func.startsWith('function'))
122
+ func = func.replace('function', 'async function')
123
+
124
+ try {
125
+ const result = await executeStrFunctionByContext(null, func, [])
126
+ if (!result) {
127
+ close()
128
+ return
129
+ }
130
+
131
+ let messageType = 'success'
132
+
133
+ if (result?.name) {
134
+ const waitRefreshRef = getComponentByName(result.name)
135
+ if (waitRefreshRef)
136
+ waitRefreshRef.refresh()
137
+ else
138
+ console.warn(`未找到组件${result.name}无法刷新`)
139
+ }
140
+
141
+ if (result?.messageType)
142
+ messageType = result.messageType
143
+
144
+ if (result?.message) {
145
+ showDialog({
146
+ message: result.message,
147
+ type: messageType,
148
+ })
149
+ }
150
+
151
+ close()
152
+ }
153
+ catch (error) {
154
+ console.error('确认逻辑执行失败:', error)
155
+ close()
156
+ }
157
+ }
158
+ else {
159
+ console.warn('未配置modal确认按钮逻辑')
160
+ close()
161
+ }
162
+ }
163
+
164
+ function updateImg(data: any) {
165
+ console.log(data)
166
+ }
167
+
168
+ // 暴露方法
169
+ defineExpose({
170
+ init,
171
+ getComponentByName,
172
+ })
173
+ </script>
174
+
175
+ <template>
176
+ <VanDialog
177
+ v-model:show="visible"
178
+ :before-close="close"
179
+ :confirm-loading="loading"
180
+ width="80%"
181
+ :show-confirm-button="true"
182
+ confirm-text="提交"
183
+ v-bind="attr"
184
+ @confirm="onSubmit"
185
+ >
186
+ <div v-if="showReport" style="max-height: 70vh; overflow-y: auto; overflow-x: hidden;">
187
+ <XReport
188
+ ref="mainRef"
189
+ :env="env"
190
+ :use-oss-for-img="false"
191
+ :config-name="configName"
192
+ :show-img-in-cell="true"
193
+ :display-only="displayOnly"
194
+ :edit-mode="false"
195
+ :show-save-button="false"
196
+ :dont-format="true"
197
+ @update-img="updateImg"
198
+ @select-row="selectRow"
199
+ />
200
+ </div>
201
+ </VanDialog>
202
+ </template>
@@ -0,0 +1,3 @@
1
+ import XAddReport from './XAddReport'
2
+
3
+ export default XAddReport
@@ -0,0 +1,56 @@
1
+ # XAddForm
2
+
3
+ 动态新增/修改表单控件,根据JSON配置生成一个完整的可供新增/修改数据的动态表单
4
+
5
+
6
+ ## 何时使用
7
+
8
+ 当需要一个可供新增/修改数据的动态生成的表单时
9
+
10
+
11
+ 引用方式:
12
+
13
+ ```javascript
14
+ import XAddReport from '@vue2-client/base-client/components/XAddReport/XAddReport'
15
+
16
+ export default {
17
+ components: {
18
+ XAddReport
19
+ }
20
+ }
21
+ ```
22
+
23
+
24
+
25
+ ## 代码演示
26
+
27
+ ```html
28
+ <x-add-report
29
+
30
+ >
31
+ </x-add-report>
32
+ ```
33
+
34
+ ## API
35
+
36
+ | 参数 | 说明 | 类型 | 默认值 |
37
+ |-----------------|--------------------------|---------|-------|
38
+ | businessTitle | 业务标题 | String | '' |
39
+ | businessType | 业务类型 | String | '' |
40
+ | visible | 是否显示模态框 | Boolean | false |
41
+ | jsonData | JSON配置,根据[工具>查询配置生成]功能生成 | Object | {} |
42
+ | modifyModelData | 修改操作前查询出的业务数据 | Object | {} |
43
+ | loading | 新增或修改业务是否执行中 | Boolean | false |
44
+ | fixedAddForm | 固定新增表单,会和新增表单合并 | Object | {} |
45
+ | getDataParams | 调用logic获取数据源的追加参数 | Object | - |
46
+ | @onSubmit | 表单的提交事件 | event | - |
47
+
48
+ ## 例子1
49
+ ----
50
+ 参考XFormTable组件
51
+ ```
52
+
53
+ 注意事项
54
+ ----
55
+
56
+ > 本组件已经实现了自适应布局,在不同分辨率下的设备均可得到基本理想的展示效果
@@ -0,0 +1,10 @@
1
+ import type { App } from 'vue'
2
+ import XAddReport from './XAddReport.vue'
3
+
4
+ export { XAddReport }
5
+
6
+ export default {
7
+ install(app: App) {
8
+ app.component('XAddReport', XAddReport)
9
+ }
10
+ }