af-mobile-client-vue3 1.2.53 → 1.2.55
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
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
ActionSheet,
|
|
7
7
|
Uploader as vanUploader,
|
|
8
8
|
} from 'vant'
|
|
9
|
-
import { ref
|
|
9
|
+
import { ref } from 'vue'
|
|
10
10
|
|
|
11
11
|
const props = defineProps({
|
|
12
12
|
imageList: Array<any>,
|
|
@@ -19,11 +19,6 @@ const emit = defineEmits(['updateFileList'])
|
|
|
19
19
|
|
|
20
20
|
const imageList = ref<Array<any>>(props.imageList ?? [])
|
|
21
21
|
|
|
22
|
-
// 同步 props.imageList 到内部 imageList,保证每次变化都响应
|
|
23
|
-
watch(() => props.imageList, (newVal) => {
|
|
24
|
-
imageList.value = Array.isArray(newVal) ? [...newVal] : []
|
|
25
|
-
}, { immediate: true })
|
|
26
|
-
|
|
27
22
|
// 触发拍照
|
|
28
23
|
function triggerCamera() {
|
|
29
24
|
mobileUtil.execute({
|
|
@@ -84,8 +79,8 @@ function handlePhotoUpload(photoData: any) {
|
|
|
84
79
|
funcName: 'uploadResource',
|
|
85
80
|
param,
|
|
86
81
|
callbackFunc: (result: any) => {
|
|
82
|
+
const index = imageList.value.findIndex(item => item.uid === tempFile.uid)
|
|
87
83
|
if (result.status === 'success') {
|
|
88
|
-
const index = imageList.value.findIndex(item => item.uid === tempFile.uid)
|
|
89
84
|
if (index !== -1) {
|
|
90
85
|
imageList.value[index].uid = result.data.id
|
|
91
86
|
imageList.value[index].id = result.data.id
|
|
@@ -95,7 +90,6 @@ function handlePhotoUpload(photoData: any) {
|
|
|
95
90
|
}
|
|
96
91
|
}
|
|
97
92
|
else {
|
|
98
|
-
const index = imageList.value.findIndex(item => item.uid === tempFile.uid)
|
|
99
93
|
if (index !== -1) {
|
|
100
94
|
imageList.value[index].status = 'failed'
|
|
101
95
|
imageList.value[index].message = '上传失败'
|
|
@@ -105,7 +99,6 @@ function handlePhotoUpload(photoData: any) {
|
|
|
105
99
|
const doneIds = Object.values(imageList.value)
|
|
106
100
|
.filter(item => item.status === 'done')
|
|
107
101
|
.map(item => item.id)
|
|
108
|
-
console.log('>>>> doneIds: ', JSON.stringify(doneIds))
|
|
109
102
|
|
|
110
103
|
if (props.outerIndex !== undefined)
|
|
111
104
|
emit('updateFileList', doneIds, props.outerIndex)
|
|
@@ -123,10 +116,13 @@ function deleteFileFunction(file: any) {
|
|
|
123
116
|
const targetIndex = imageList.value.findIndex(item => item.id === file.id)
|
|
124
117
|
if (targetIndex !== -1) {
|
|
125
118
|
imageList.value.splice(targetIndex, 1)
|
|
119
|
+
const doneIds = Object.values(imageList.value)
|
|
120
|
+
.filter(item => item.status === 'done')
|
|
121
|
+
.map(item => item.id)
|
|
126
122
|
if (props.outerIndex !== undefined)
|
|
127
|
-
emit('updateFileList',
|
|
123
|
+
emit('updateFileList', doneIds, props.outerIndex)
|
|
128
124
|
else
|
|
129
|
-
emit('updateFileList',
|
|
125
|
+
emit('updateFileList', doneIds)
|
|
130
126
|
}
|
|
131
127
|
}
|
|
132
128
|
})
|
|
@@ -339,7 +339,6 @@ watch(
|
|
|
339
339
|
watch(
|
|
340
340
|
() => modelData.value,
|
|
341
341
|
(newVal, oldVal) => {
|
|
342
|
-
console.log('变更函数新旧值-----', newVal, oldVal)
|
|
343
342
|
// 避免初始化时的调用
|
|
344
343
|
if (newVal !== oldVal) {
|
|
345
344
|
dataChangeFunc()
|
|
@@ -348,10 +347,20 @@ watch(
|
|
|
348
347
|
{ deep: true },
|
|
349
348
|
)
|
|
350
349
|
|
|
350
|
+
// 监听 option.value 的变化
|
|
351
|
+
watch(
|
|
352
|
+
() => option.value,
|
|
353
|
+
(newOption) => {
|
|
354
|
+
if (attr.type === 'treeSelect' && newOption && newOption.length > 0) {
|
|
355
|
+
// 你可以在这里调用 findOptionInTree 函数来查找默认值对应的 label
|
|
356
|
+
const result = findOptionInTree(option.value, modelData.value)
|
|
357
|
+
if (attr.type === 'treeSelect' && result)
|
|
358
|
+
treeValue.value = result.label
|
|
359
|
+
}
|
|
360
|
+
},
|
|
361
|
+
)
|
|
362
|
+
|
|
351
363
|
function updateFile(files, _index) {
|
|
352
|
-
// 处理文件数据
|
|
353
|
-
// 更新本地值
|
|
354
|
-
console.log('>>>> 更新文件数据-----', JSON.stringify(files))
|
|
355
364
|
modelData.value = files
|
|
356
365
|
}
|
|
357
366
|
|
|
@@ -759,13 +768,36 @@ function cleanEmptyChildren(options, fieldNames = { text: 'label', value: 'value
|
|
|
759
768
|
function onTreeSelectFinish({ selectedOptions }) {
|
|
760
769
|
const index = selectedOptions.length - 1
|
|
761
770
|
treeValue.value = selectedOptions[index].label
|
|
762
|
-
|
|
771
|
+
if (mode === '查询') {
|
|
772
|
+
modelData.value = [selectedOptions[index].value]
|
|
773
|
+
}
|
|
774
|
+
else {
|
|
775
|
+
modelData.value = selectedOptions[index].value
|
|
776
|
+
}
|
|
763
777
|
showTreeSelect.value = false
|
|
764
778
|
}
|
|
765
779
|
|
|
766
780
|
function emitFunc(func, data) {
|
|
767
781
|
emits('xFormItemEmitFunc', func, data, data?.model ? form[data.model] : form)
|
|
768
782
|
}
|
|
783
|
+
|
|
784
|
+
function findOptionInTree(options, value) {
|
|
785
|
+
// 在当前层级查找
|
|
786
|
+
const foundItem = options.find(item => item[columnsField.value] === value)
|
|
787
|
+
if (foundItem) {
|
|
788
|
+
return foundItem
|
|
789
|
+
}
|
|
790
|
+
// 递归查找子级
|
|
791
|
+
for (const item of options) {
|
|
792
|
+
if (item.children?.length) {
|
|
793
|
+
const foundInChildren = findOptionInTree(item.children, value)
|
|
794
|
+
if (foundInChildren)
|
|
795
|
+
return foundInChildren
|
|
796
|
+
}
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
return null
|
|
800
|
+
}
|
|
769
801
|
</script>
|
|
770
802
|
|
|
771
803
|
<template>
|