Commit 92f7c49e authored by 14699's avatar 14699

fix:合同签约及发票附件下载调整

parent 0a05f5b3
......@@ -9,12 +9,12 @@
</template>
<script setup>
import { goBack } from "@/utils/globalFun"
import { NavBar, Toast } from "vant";
import {Copy, goBack, isAndroid} from "@/utils/globalFun"
import {Dialog, NavBar, Toast} from "vant";
import VuePdfEmbed from 'vue-pdf-embed'
import { watchEffect } from 'vue'
import { useRoute, useRouter } from "vue-router";
import downfileHips from "@/utils/downfileHips"
import { downfileHips, openFileUrl} from "@/utils/downfileHips"
const route = useRoute();
const router = useRouter();
......@@ -33,30 +33,49 @@ watchEffect(() => {
})
const download = () => {
downfileHips(
pdfSource,
(msg) => {
console.log(msg);
const msgObj = JSON.parse(msg)
switch (msgObj.status) {
case "PROGRESS":
console.log("正在传输")
break
case "FINISH":
Toast({
message: `下载成功!保存地址是:${msgObj.response}`,
position: 'bottom',
});
break
case "FAIL":
Toast.fail('下载失败');
}
},
(err) => {
console.error('下载失败:', err)
Toast.fail('下载失败');
})
Copy(pdfSource, '已将文件地址复制至剪切板,请至浏览器下载')
// if (isAndroid()) {
// downfileHips(
// pdfSource,
// (msg) => {
// console.log(msg);
// const msgObj = JSON.parse(msg)
// switch (msgObj.status) {
// case "PROGRESS":
// console.log("正在传输")
// Toast.loading({
// duration: 0,
// forbidClick: true,
// message: '下载中...',
// });
// break
// case "FINISH":
// Toast.clear();
// Dialog.alert({
// title: "下载成功",
// message: `保存地址是:${msgObj.response}`
// });
// break
// case "FAIL":
// Toast.clear();
// Toast.fail('下载失败');
// }
//
// },
// (err) => {
// console.error('下载失败:', err)
// Toast.fail('下载失败');
// })
// } else {
// openFileUrl(
// pdfSource,
// (msg) => {
// console.log(msg);
// },
// (err) => {
// Copy(pdfSource, '已将文件地址复制至剪切板,请至浏览器下载')
// })
// }
}
const handleDocumentRender = (args) => {
......
......@@ -21,11 +21,11 @@
</template>
<script setup>
import { goBack } from "@/utils/globalFun"
import { NavBar, List, PullRefresh, Toast } from "vant";
import {Copy, goBack, isAndroid} from "@/utils/globalFun"
import {NavBar, List, PullRefresh, Toast, Dialog} from "vant";
import api from "../api";
import { useRoute, useRouter } from "vue-router";
import downfileHips from "@/utils/downfileHips"
import { downfileHips, openFileUrl} from "@/utils/downfileHips"
const route = useRoute();
const router = useRouter();
......@@ -49,30 +49,49 @@ const getDailyLiquidatedDetail = async () => {
getDailyLiquidatedDetail();
const download = (item) => {
downfileHips(
item.fileUrl,
(msg) => {
console.log(msg);
const msgObj = JSON.parse(msg)
switch (msgObj.status) {
case "PROGRESS":
console.log("正在传输")
break
case "FINISH":
Toast({
message: `下载成功!保存地址是:${msgObj.response}`,
position: 'bottom',
});
break
case "FAIL":
Toast.fail('下载失败');
}
},
(err) => {
console.error('下载失败:', err)
Toast.fail('下载失败');
})
Copy(item.fileUrl, '已将文件地址复制至剪切板,请至浏览器下载')
// if (isAndroid()) {
// downfileHips(
// item.fileUrl,
// (msg) => {
// console.log(msg);
// const msgObj = JSON.parse(msg)
// switch (msgObj.status) {
// case "PROGRESS":
// console.log("正在传输")
// Toast.loading({
// duration: 0,
// forbidClick: true,
// message: '下载中...',
// });
// break
// case "FINISH":
// Toast.clear();
// Dialog.alert({
// title: "下载成功",
// message: `保存地址是:${msgObj.response}`
// });
// break
// case "FAIL":
// Toast.clear();
// Toast.fail('下载失败');
// }
//
// },
// (err) => {
// console.error('下载失败:', err)
// Toast.fail('下载失败');
// })
// } else {
// openFileUrl(
// item.fileUrl,
// (msg) => {
// console.log(msg);
// },
// (err) => {
// Copy(item.fileUrl, '已将文件地址复制至剪切板,请至浏览器下载')
// })
// }
}
const jump = (item) => {
......
......@@ -9,7 +9,10 @@
<img src="../../../assets/list.png"/>
<div class="title">{{item.documentName}}</div>
</div>
<div style="display: flex;">
<div class="button-status sign" @click="jump(item)">查看</div>
<div class="button-status sign" @click="download(item)">下载</div>
</div>
</div>
</List>
</PullRefresh>
......@@ -18,12 +21,13 @@
</template>
<script setup>
import { goBack,HIPSDownLoad} from "@/utils/globalFun"
import { NavBar, List, PullRefresh, Empty, Toast} from "vant";
import {Copy, goBack, HIPSDownLoad, isAndroid} from "@/utils/globalFun"
import {NavBar, List, PullRefresh, Empty, Toast, Dialog} from "vant";
import ListItem from '@/components/ListItem.vue'
import api from "../api";
import { useRoute, useRouter } from "vue-router";
import { useIntention } from "../store";
import {downfileHips, openFileUrl} from "@/utils/downfileHips";
const route = useRoute();
const router = useRouter();
......@@ -60,6 +64,52 @@ const jump = (item) => {
}
}
const download = (item) => {
Copy(item.downloadUrl, '已将文件地址复制至剪切板,请至浏览器下载')
// if (isAndroid()) {
// downfileHips(
// item.downloadUrl,
// (msg) => {
// console.log(msg);
// const msgObj = JSON.parse(msg)
// switch (msgObj.status) {
// case "PROGRESS":
// console.log("正在传输")
// Toast.loading({
// duration: 0,
// forbidClick: true,
// message: '下载中...',
// });
// break
// case "FINISH":
// Toast.clear();
// Dialog.alert({
// title: "下载成功",
// message: `保存地址是:${msgObj.response}`
// });
// break
// case "FAIL":
// Toast.clear();
// Toast.fail('下载失败');
// }
//
// },
// (err) => {
// console.error('下载失败:', err)
// Toast.fail('下载失败');
// })
// } else {
// openFileUrl(
// item.downloadUrl,
// (msg) => {
// console.log(msg);
// },
// (err) => {
// Copy(item.downloadUrl, '已将文件地址复制至剪切板,请至浏览器下载')
// })
// }
}
</script>
<style scoped lang="less">
......@@ -90,6 +140,7 @@ const jump = (item) => {
}
.left {
display: flex;
//width: calc(100% - 100px);
}
.item img{
width: 20px;
......@@ -102,16 +153,16 @@ const jump = (item) => {
margin-left: 16px;
font-weight: 600;
line-height: 20px;
word-break:break-all;
}
.button-status{
width: 54px;
width: 50px;
height: 20px;
font-size: 12px;
border-radius: 10px;
display: flex;
justify-content: center;
align-items: center;
margin-right: 15px;
}
.sign{
color: #2499FF;
......
......@@ -23,6 +23,8 @@ function downloadFile(source, target, isTemp = 'N',succesE,errorE) {
HandBridge.postMessage(JSON.stringify(args))
}
// {
// "status":"PROGRESS"/"FINISH"/"FAIL" //正在传输/完成/失败
// "fileSize":1234 //文件总大小,当为-1时则表示文件的大小不可获取
......@@ -30,6 +32,29 @@ function downloadFile(source, target, isTemp = 'N',succesE,errorE) {
// "response":"xxxxx" //传输完成后文件的本地路径
// }
export default function downfileHips(source, succesE, errorE, target, isTemp = 'N') {
export function downfileHips(source, succesE, errorE, target, isTemp = 'N') {
downloadFile(source, target, isTemp,succesE,errorE)
}
export function openFileUrl(source, succesE, errorE) {
window.onSuccess = function(res){
console.log('success:',res);
succesE(res)
};
window.onError = function(res){
console.log('download:',res);
errorE(res)
};
let options = {
scheme: source
}
let args = {
className: "BaseBridge",
function: "gotoScheme",
params: options,
successCallBack: "onSuccess",
failCallBack: "onError"
}
console.log(JSON.stringify(args));
HandBridge.postMessage(JSON.stringify(args))
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment