修改附件

main
ihzero 2024-05-15 23:32:10 +08:00
parent 5f7f73970a
commit 0364e37009
2 changed files with 34 additions and 49 deletions

View File

@ -38,7 +38,7 @@
<view v-for="(item, i) in ob" :key="i"> <view v-for="(item, i) in ob" :key="i">
<view class="flex items-center h-84rpx"> <view class="flex items-center h-84rpx">
<view class="w-110rpx text-primary" <view class="w-110rpx text-primary"
>{{ timeFormat(item.month, 'mm') }}</view >{{ timeFormat(`${item.month}-01`, 'mm') }}</view
> >
<view class="flex-1" <view class="flex-1"
>{{ item.actual_performance }}/{{ >{{ item.actual_performance }}/{{

View File

@ -43,6 +43,15 @@
<uv-parse :content="info.content"></uv-parse> <uv-parse :content="info.content"></uv-parse>
</view> </view>
</template> </template>
<uv-modal
ref="modalRef"
title="下载成功"
content="下载成功!是否打开"
showCancelButton
@confirm="confirm"
>
</uv-modal>
</view> </view>
</template> </template>
<script setup> <script setup>
@ -52,8 +61,10 @@ import { onLoad } from '@dcloudio/uni-app'
import { ref } from 'vue' import { ref } from 'vue'
import { timeFormat } from '@climblee/uv-ui/libs/function' import { timeFormat } from '@climblee/uv-ui/libs/function'
const modalRef = ref(null)
const id = ref('') const id = ref('')
const info = ref({}) const info = ref({})
const tempFile = ref(null)
onLoad((options) => { onLoad((options) => {
id.value = options.id id.value = options.id
http.get(`/train/books/${id.value}`).then((res) => { http.get(`/train/books/${id.value}`).then((res) => {
@ -62,59 +73,33 @@ onLoad((options) => {
}) })
const downloadFile = (url) => { const downloadFile = (url) => {
// #ifdef H5 const filetype = url.substring(url.lastIndexOf('.') + 1)
const whiteFile = ['doc', 'xls', 'ppt', 'pdf', 'docx', 'xlsx', 'pptx']
uni.downloadFile({ uni.downloadFile({
url: url, // URL url: url,
success: function (res) { success: (res) => {
console.log('下载成功', res) if (res.statusCode === 200) {
// tempFile.value = res
},
fail: function (err) { if (whiteFile.includes(filetype)) {
console.log('下载失败', err) modalRef.value.open()
// } else {
uni.showToast({
title: '下载成功',
icon: 'none',
})
}
}
}, },
}) })
// #endif
// #ifdef APP-PLUS
let dtask = plus.downloader.createDownload(
url,
{
filename: 'file://storage/emulated/0/Download/',
},
(d, status) => {
if (status == 200) {
let fileSaveUrl = plus.io.convertLocalFileSystemURL(d.filename)
// saveFile(fileSaveUrl)
uni.showToast({
title: '下载成功',
icon: 'none',
})
} else {
//
uni.showToast({
title: '下载失败',
})
plus.downloader.clear() //
}
console.log(d)
}
)
dtask.start()
// #endif
} }
const saveFile = (filePath) => { const confirm = () => {
uni.saveFile({ var filePath = encodeURI(tempFile.value.tempFilePath)
tempFilePath: filePath, uni.openDocument({
success: (res) => { filePath: encodeURI(filePath),
uni.showToast({ // fileType: filetype,
title: '文件保存成功', showMenu: true,
})
console.log('文件保存成功,路径为:' + res.savedFilePath)
},
fail: (err) => {
console.log('文件保存失败:' + err)
},
}) })
} }
</script> </script>