af-mobile-client-vue3 1.3.61 → 1.3.62

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "af-mobile-client-vue3",
3
3
  "type": "module",
4
- "version": "1.3.61",
4
+ "version": "1.3.62",
5
5
  "packageManager": "pnpm@10.13.1",
6
6
  "description": "Vue + Vite component lib",
7
7
  "engines": {
@@ -17,6 +17,7 @@ const props = defineProps({
17
17
  mode: { default: '新增' }, // 预览
18
18
  // 整体只读:只允许预览,禁止拍照/上传/删除
19
19
  readonly: { type: Boolean, default: false },
20
+ isAsyncUpload: { type: Boolean, default: false },
20
21
  })
21
22
  const emit = defineEmits(['updateFileList', 'updateAllFileList'])
22
23
 
@@ -157,6 +158,8 @@ function handlePhotoUpload(photoData: any) {
157
158
  status: 'uploading',
158
159
  message: '上传中...',
159
160
  url: `data:${mimeType};base64,${photoData.content}`,
161
+ isImage: true,
162
+ type: mimeType,
160
163
  }
161
164
 
162
165
  if (!imageList.value) {
@@ -178,40 +181,80 @@ function handlePhotoUpload(photoData: any) {
178
181
  imgPath: photoData.filePath,
179
182
  urlPath: `/api/${import.meta.env.VITE_APP_SYSTEM_NAME}/resource/upload`,
180
183
  }
181
- // 上传到服务器
182
- mobileUtil.execute({
183
- funcName: 'uploadResource',
184
- param,
185
- callbackFunc: (result: any) => {
186
- const index = imageList.value.findIndex(item => item.uid === tempFile.uid)
187
- if (result.status === 'success') {
188
- if (index !== -1) {
189
- imageList.value[index].uid = result.data.id
190
- imageList.value[index].id = result.data.id
191
- delete imageList.value[index].message
192
- imageList.value[index].status = 'done'
193
- imageList.value[index].url = result.data.f_downloadpath
184
+ if (props.isAsyncUpload) {
185
+ // 添加上传队列
186
+ mobileUtil.execute({
187
+ funcName: 'queueUpload',
188
+ param,
189
+ callbackFunc: (res: any) => {
190
+ console.warn('上传结果', res)
191
+ // 成功
192
+ if (res.data && res.data.enqueued) {
193
+ const index = imageList.value.findIndex(item => item.uid === tempFile.uid)
194
+ console.log('index--------', index)
195
+ if (index !== -1) {
196
+ delete imageList.value[index].message
197
+ imageList.value[index].status = 'done'
198
+ imageList.value[index].pthotoName = photoData.name
199
+ imageList.value[index].type = mimeType
200
+ }
201
+ else {
202
+ if (index !== -1) {
203
+ imageList.value[index].status = 'failed'
204
+ imageList.value[index].message = '上传失败'
205
+ }
206
+ }
194
207
  }
195
- }
196
- else {
197
- if (index !== -1) {
198
- imageList.value[index].status = 'failed'
199
- imageList.value[index].message = '上传失败'
208
+
209
+ emit('updateAllFileList', imageList.value.filter(item => item.status === 'done').map(item => item)) // 新增
210
+
211
+ const doneIds = Object.values(imageList.value)
212
+ .filter(item => item.status === 'done')
213
+ .map(item => item.pthotoName)
214
+
215
+ if (props.outerIndex !== undefined)
216
+ emit('updateFileList', doneIds, props.outerIndex)
217
+ else
218
+ emit('updateFileList', doneIds)
219
+ },
220
+ })
221
+ }
222
+ else {
223
+ // 上传到服务器
224
+ mobileUtil.execute({
225
+ funcName: 'uploadResource',
226
+ param,
227
+ callbackFunc: (result: any) => {
228
+ const index = imageList.value.findIndex(item => item.uid === tempFile.uid)
229
+ if (result.status === 'success') {
230
+ if (index !== -1) {
231
+ imageList.value[index].uid = result.data.id
232
+ imageList.value[index].id = result.data.id
233
+ delete imageList.value[index].message
234
+ imageList.value[index].status = 'done'
235
+ imageList.value[index].url = result.data.f_downloadpath
236
+ }
237
+ }
238
+ else {
239
+ if (index !== -1) {
240
+ imageList.value[index].status = 'failed'
241
+ imageList.value[index].message = '上传失败'
242
+ }
200
243
  }
201
- }
202
244
 
203
- emit('updateAllFileList', imageList.value.filter(item => item.status === 'done').map(item => item)) // 新增
245
+ emit('updateAllFileList', imageList.value.filter(item => item.status === 'done').map(item => item)) // 新增
204
246
 
205
- const doneIds = Object.values(imageList.value)
206
- .filter(item => item.status === 'done')
207
- .map(item => item.id)
247
+ const doneIds = Object.values(imageList.value)
248
+ .filter(item => item.status === 'done')
249
+ .map(item => item.id)
208
250
 
209
- if (props.outerIndex !== undefined)
210
- emit('updateFileList', doneIds, props.outerIndex)
211
- else
212
- emit('updateFileList', doneIds)
213
- },
214
- })
251
+ if (props.outerIndex !== undefined)
252
+ emit('updateFileList', doneIds, props.outerIndex)
253
+ else
254
+ emit('updateFileList', doneIds)
255
+ },
256
+ })
257
+ }
215
258
  }
216
259
 
217
260
  // 删除图片
@@ -226,13 +269,21 @@ function deleteFileFunction(file: any) {
226
269
 
227
270
  emit('updateAllFileList', imageList.value.filter(item => item.status === 'done').map(item => item))
228
271
 
229
- const doneIds = Object.values(imageList.value)
230
- .filter(item => item.status === 'done')
231
- .map(item => item.id)
272
+ const doneIds = ref(null)
273
+ if (props.isAsyncUpload) {
274
+ doneIds.value = Object.values(imageList.value)
275
+ .filter(item => item.status === 'done')
276
+ .map(item => item.pthotoName)
277
+ }
278
+ else {
279
+ doneIds.value = Object.values(imageList.value)
280
+ .filter(item => item.status === 'done')
281
+ .map(item => item.id)
282
+ }
232
283
  if (props.outerIndex !== undefined)
233
- emit('updateFileList', doneIds, props.outerIndex)
284
+ emit('updateFileList', doneIds.value, props.outerIndex)
234
285
  else
235
- emit('updateFileList', doneIds)
286
+ emit('updateFileList', doneIds.value)
236
287
  }
237
288
  })
238
289
  return false // 已手动移除,阻止van-uploader再次移除
@@ -245,13 +296,21 @@ function deleteFileFunction(file: any) {
245
296
 
246
297
  emit('updateAllFileList', imageList.value.filter(item => item.status === 'done').map(item => item))
247
298
 
248
- const doneIds = Object.values(imageList.value)
249
- .filter(item => item.status === 'done')
250
- .map(item => item.id)
299
+ const doneIds = ref(null)
300
+ if (props.isAsyncUpload) {
301
+ doneIds.value = Object.values(imageList.value)
302
+ .filter(item => item.status === 'done')
303
+ .map(item => item.pthotoName)
304
+ }
305
+ else {
306
+ doneIds.value = Object.values(imageList.value)
307
+ .filter(item => item.status === 'done')
308
+ .map(item => item.id)
309
+ }
251
310
  if (props.outerIndex !== undefined)
252
- emit('updateFileList', doneIds, props.outerIndex)
311
+ emit('updateFileList', doneIds.value, props.outerIndex)
253
312
  else
254
- emit('updateFileList', doneIds)
313
+ emit('updateFileList', doneIds.value)
255
314
 
256
315
  return false // 阻止van-uploader二次处理
257
316
  }
@@ -330,7 +389,7 @@ function handleActionSelect(option: any) {
330
389
  上传附件
331
390
  </div>
332
391
  <div v-if="props.attr?.acceptCount" class="upload-desc">
333
- 已上传 {{ imageList.length }} 个,最多可上传 {{ props.attr?.acceptCount }}
392
+ 上传限制: {{ imageList.length }} / {{ props.attr?.acceptCount }}
334
393
  </div>
335
394
  </div>
336
395
  <van-uploader
@@ -62,6 +62,8 @@ const props = withDefaults(defineProps<{
62
62
  isGroupForm?: boolean
63
63
  // 整体表单只读:为 true 时,所有表单项不可交互
64
64
  formReadonly?: boolean
65
+ // 控制上传——异步/同步
66
+ isAsyncUpload?: boolean
65
67
  }>(), {
66
68
  configName: undefined,
67
69
  groupTitle: undefined,
@@ -75,6 +77,7 @@ const props = withDefaults(defineProps<{
75
77
  paramLogicNameParam: {},
76
78
  isGroupForm: false,
77
79
  formReadonly: false,
80
+ isAsyncUpload: false,
78
81
  })
79
82
 
80
83
  const emits = defineEmits(['onSubmit', 'xFormItemEmitFunc'])
@@ -612,6 +615,7 @@ defineExpose({ init, form, formGroupName, validate, asyncSubmit, setForm, getFor
612
615
  :service-name="myServiceName"
613
616
  :get-data-params="myGetDataParams"
614
617
  :form-readonly="props.formReadonly"
618
+ :is-async-upload="props.isAsyncUpload"
615
619
  @set-form="setForm"
616
620
  @x-form-item-emit-func="emitFunc"
617
621
  />
@@ -119,4 +119,4 @@ onUnmounted(() => {
119
119
  color: #ff976a;
120
120
  }
121
121
  }
122
- </style>
122
+ </style>
@@ -99,4 +99,4 @@ onUnmounted(() => {
99
99
  .user-form {
100
100
  padding: 16px;
101
101
  }
102
- </style>
102
+ </style>
@@ -94,6 +94,10 @@ const props = defineProps({
94
94
  return { text: 'label', value: 'value' }
95
95
  },
96
96
  },
97
+ isAsyncUpload: {
98
+ type: Boolean,
99
+ default: false,
100
+ },
97
101
 
98
102
  })
99
103
 
@@ -988,6 +992,7 @@ function findOptionInTree(options, value) {
988
992
  :attr="attr"
989
993
  :mode="props.mode"
990
994
  :readonly="readonly"
995
+ :is-async-upload="isAsyncUpload"
991
996
  @update-file-list="updateFile"
992
997
  />
993
998
  </template>
@@ -1,33 +1,33 @@
1
- <script setup lang="ts">
2
- import { onMounted, ref } from 'vue'
3
- import XReport from './XReport.vue'
4
-
5
- const mainRef = ref()
6
-
7
- onMounted(() => {
8
- // 初始化逻辑
9
- })
10
- </script>
11
-
12
- <template>
13
- <div id="test">
14
- <van-card :bordered="false">
15
- <XReport
16
- ref="mainRef"
17
- :use-oss-for-img="false"
18
- config-name="nurseWorkstationCover"
19
- server-name="af-his"
20
- :show-img-in-cell="true"
21
- :display-only="true"
22
- :edit-mode="false"
23
- :show-save-button="false"
24
- :no-padding="true"
25
- :dont-format="true"
26
- />
27
- </van-card>
28
- </div>
29
- </template>
30
-
31
- <style scoped>
32
-
33
- </style>
1
+ <script setup lang="ts">
2
+ import { onMounted, ref } from 'vue'
3
+ import XReport from './XReport.vue'
4
+
5
+ const mainRef = ref()
6
+
7
+ onMounted(() => {
8
+ // 初始化逻辑
9
+ })
10
+ </script>
11
+
12
+ <template>
13
+ <div id="test">
14
+ <van-card :bordered="false">
15
+ <XReport
16
+ ref="mainRef"
17
+ :use-oss-for-img="false"
18
+ config-name="nurseWorkstationCover"
19
+ server-name="af-his"
20
+ :show-img-in-cell="true"
21
+ :display-only="true"
22
+ :edit-mode="false"
23
+ :show-save-button="false"
24
+ :no-padding="true"
25
+ :dont-format="true"
26
+ />
27
+ </van-card>
28
+ </div>
29
+ </template>
30
+
31
+ <style scoped>
32
+
33
+ </style>