preview.vue 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <template>
  2. <web-view :src="pdf"/>
  3. </template>
  4. <script>
  5. export default {
  6. data() {
  7. return {
  8. fileSrc:[],
  9. pdf:'',
  10. }
  11. },
  12. onLoad(e) {
  13. if(e.previews){
  14. this.getPreviews(e.previews);
  15. } else if(e.preview){
  16. this.toPreview(decodeURIComponent(e.preview));
  17. }
  18. },
  19. methods: {
  20. findImage(processId){
  21. var that =this;
  22. that.http.request("/app/previewExcel", {
  23. processId: processId,
  24. }).then(res => {
  25. if(res.datas != null){
  26. that.fileSrc = res.datas;
  27. } else {
  28. that.$prompt.none("暂无数据");
  29. }
  30. })
  31. },
  32. getPreviews(previews){
  33. var that = this;
  34. that.http.request("/app/showOutViewOfSubmit", {
  35. list: previews,
  36. storeName: uni.getStorageSync("storeName")
  37. }).then(res => {
  38. if(res.data){
  39. var encode = encodeURIComponent(res.data);
  40. that.pdf = `/hybrid/html/web/viewer.html?file=${encode}`;
  41. }else{
  42. that.$prompt.none("暂无数据");
  43. }
  44. })
  45. },
  46. toPreview(url){
  47. var encode = encodeURIComponent(url);
  48. this.pdf = `/hybrid/html/web/viewer.html?file=${encode}`;
  49. },
  50. download(){
  51. uni.showLoading({
  52. title: '下载中'
  53. });
  54. uni.saveImageToPhotosAlbum({
  55. filePath: this.fileSrc,
  56. success: function() {
  57. uni.hideLoading();
  58. uni.showToast({
  59. title: '已保存到相册',
  60. icon: 'none',
  61. duration: 2200
  62. });
  63. }
  64. });
  65. }
  66. }
  67. }
  68. </script>