detailedAttachment.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <template>
  2. <view>
  3. <view class="ordertop">
  4. <view>
  5. <view class="iconblue"></view>
  6. <text class="license">附件</text>
  7. </view>
  8. <view class="line">
  9. <u-line color="#ccc" border-style='dashed'/>
  10. </view>
  11. <view class="basic" v-for="(item,index) in list" :key="index">
  12. <view>{{item.fName}}</view>
  13. <view>
  14. <u-button type="primary" :ripple="true" ripple-bg-color="#909399" size="mini"
  15. @click="previewDocx(item.fUrl)">{{progress?'进度:'+progress:'查看'}}</u-button>
  16. </view>
  17. </view>
  18. </view>
  19. </view>
  20. </template>
  21. <script>
  22. export default {
  23. data() {
  24. return {
  25. form: {},
  26. progress:'',
  27. list: []
  28. }
  29. },
  30. onLoad(option) {
  31. this.form = JSON.parse(option.item)
  32. this.$u.get('/warehouseBusiness/enclosure/infoByPid', {
  33. pId: this.form.fId
  34. }).then(res => {
  35. this.list = res.data
  36. })
  37. },
  38. methods: {
  39. //预览
  40. previewDocx(item){
  41. if(item == null){
  42. uni.showToast({
  43. icon: 'none',
  44. title: '无附件',
  45. position: "bottom"
  46. })
  47. }else{
  48. uni.showToast({
  49. icon: 'none',
  50. title: '下载中...',
  51. position: "bottom"
  52. })
  53. uni.downloadFile({
  54. url: item,
  55. success: (res) => {
  56. if (res.statusCode === 200) {
  57. const downloadTask = uni.openDocument({
  58. filePath: res.tempFilePath,
  59. // 如果文件名包含中文,建议使用escape(res.tempFilePath)转码,防止ios和安卓客户端导致的差异
  60. success: function(res) {
  61. uni.showToast({
  62. icon: 'none',
  63. title: '打开附件成功',
  64. position: "bottom"
  65. })
  66. },
  67. fail:function(res){
  68. uni.showToast({
  69. icon: 'none',
  70. title: '打开附件失败',
  71. position: "bottom"
  72. })
  73. }
  74. });
  75. downloadTask.onProgressUpdate((res) => {
  76. this.progress = res.progress
  77. });
  78. }
  79. }
  80. })
  81. }
  82. },
  83. }
  84. }
  85. </script>
  86. <style scoped lang="scss">
  87. .ordertop {
  88. width: 96%;
  89. background-color: #fff;
  90. margin: 20rpx auto;
  91. border-radius: 20rpx;
  92. padding-top: 20rpx;
  93. box-shadow: 0px 0px 8px 0px rgba(165, 189, 251, 0.4);
  94. padding-bottom: 10rpx;
  95. }
  96. .ordertop>view:nth-child(1) {
  97. width: 98%;
  98. margin-bottom: 60rpx;
  99. }
  100. .iconblue {
  101. width: 10rpx;
  102. height: 45rpx;
  103. float: left;
  104. background-color: #3a63cf;
  105. margin-right: 10rpx;
  106. }
  107. .line {
  108. width: 92%;
  109. margin: 0 auto;
  110. }
  111. .various {
  112. float: right;
  113. width: 150rpx;
  114. border: 2rpx solid #3a63cf;
  115. text-align: center;
  116. border-radius: 100rpx;
  117. color: #3a63cf;
  118. }
  119. .basic {
  120. width: 94%;
  121. margin: 10rpx auto;
  122. display: flex;
  123. justify-content: space-between;
  124. }
  125. .basic>view {
  126. margin-bottom: 10rpx;
  127. }
  128. .basic>view:nth-child(1) {
  129. color: #797979;
  130. }
  131. </style>