20260523172803

This commit is contained in:
oneao committed 2026-05-23 17:28:04 +08:00
1 parent c65407b679
commit 843529e57a
5 files changed
+76 -35

No files matched your search

@@ -11,6 +11,7 @@ const current = ref(0)
<sar-toast-agent />
<sar-dialog-agent />
<sar-notify-agent />
<sar-action-sheet-agent />
<!-- <view class="custom-tabbar">
<view class="tabbar-container" @touchmove.stop.prevent>
@@ -209,6 +209,15 @@ async function handleConfirm() {
})),
)
// =========================
// 检查总附件数是否 >= 5
// =========================
const totalFiles = 1 + allFiles.length
if (totalFiles < 5) {
toast.fail(`附件总数不足,上传需至少5张,当前${totalFiles}张`)
return
}
// =========================
// 分类排序
// =========================
@@ -337,6 +346,8 @@ async function handleConfirm() {
if (res.success) {
toast.success('保存成功')
loadMainData()
}
else {
toast.fail('保存失败')
@@ -350,9 +361,7 @@ async function handleConfirm() {
finally {
setTimeout(() => {
toast.hide()
loadMainData()
}, 1000)
}, 1500)
}
}
@@ -483,7 +492,7 @@ const templateCollapse = ref<string[]>(['template1'])
:auto-upload="false"
:before-remove="handleBeforeRemove"
multiple
accept="all"
accept="image"
:max-size="50 * 1024 * 1024"
/>
</view>
@@ -505,7 +514,7 @@ const templateCollapse = ref<string[]>(['template1'])
:auto-upload="false"
:before-remove="handleBeforeRemove"
multiple
accept="all"
accept="image"
:max-size="50 * 1024 * 1024"
/>
</view>
@@ -1,6 +1,5 @@
<script lang="ts" setup>
import type { UploadFile, UploadFileItem } from 'sard-uniapp'
import { dialog, isImageUrl, isVideoUrl, toast } from 'sard-uniapp'
import { actionSheet, dialog, toast } from 'sard-uniapp'
import { getUniqueIdApi, recognizeOcrBoxApi, saveObjectApi, uploadContainerFileApi, uploadTempFileApi } from '@/request/api'
import { downloadFile, getFileExtension, imageCompress, isImage } from '@/utils/file'
@@ -11,6 +10,8 @@ const isError = ref(false)
const showResult = ref(false)
const fileMode = ref('image') // image/video/all
const form = ref({
b_id: 0,
b_container_no: '',
@@ -41,6 +42,30 @@ onLoad(async () => {
toast.hide()
})
function handleBeforeChoose({ fileList, resolve }) {
console.log('before choose', fileList)
actionSheet({
description: '请选择上传方式',
itemList: [{ name: '照片' }, { name: '视频' }, { name: '文件' }],
showCancel: true,
onSelect(item) {
if (item.name === '视频') {
fileMode.value = 'video'
}
else if (item.name === '文件') {
fileMode.value = 'all'
}
else {
fileMode.value = 'image'
}
setTimeout(() => {
resolve(true)
}, 0)
},
})
}
function handleChooseBox() {
uni.chooseImage({
count: 1,
@@ -146,6 +171,25 @@ async function handleConfirm() {
return
}
const subFiles = subFileListRef.value?.getUploadFiles() || []
const subFiles2 = subFileListRef2.value?.getUploadFiles() || []
const allFiles = [
...subFiles.map(item => ({
...item,
cate: '1',
})),
...subFiles2.map(item => ({
...item,
cate: '2',
})),
]
const totalFiles = (boxImage.value ? 1 : 0) + allFiles.length
if (totalFiles < 5) {
toast.fail(`附件总数不足,上传需至少5张,当前${totalFiles}张`)
return
}
toast.loading('正在保存中 . . .', {
overlay: true,
transparent: false,
@@ -203,23 +247,6 @@ async function handleConfirm() {
return indexMap[cate]++
}
// =========================
// 获取附件
// =========================
const subFiles = subFileListRef.value?.getUploadFiles() || []
const subFiles2 = subFileListRef2.value?.getUploadFiles() || []
const allFiles = [
...subFiles.map(item => ({
...item,
cate: '1',
})),
...subFiles2.map(item => ({
...item,
cate: '2',
})),
]
// =========================
// 上传附件
// =========================
@@ -300,7 +327,9 @@ async function handleConfirm() {
toast.fail('保存失败')
}
finally {
toast.hide()
setTimeout(() => {
toast.hide()
}, 1500)
}
}
@@ -478,8 +507,9 @@ const templateCollapse = ref<string[]>(['template1'])
:auto-upload="false"
:before-remove="handleBeforeRemove"
multiple
accept="all"
:accept="fileMode"
:max-size="50 * 1024 * 1024"
:before-choose="handleBeforeChoose"
/>
</view>
</wd-cell-group>
@@ -499,8 +529,9 @@ const templateCollapse = ref<string[]>(['template1'])
:auto-upload="false"
:before-remove="handleBeforeRemove"
multiple
accept="all"
accept="image"
:max-size="50 * 1024 * 1024"
:before-choose="handleBeforeChoose"
/>
</view>
</wd-cell-group>