detailedAttachment.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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: 946
  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.downloadFile({
  49. url: item,
  50. success: (res) => {
  51. if (res.statusCode === 200) {
  52. const downloadTask = uni.openDocument({
  53. filePath: res.tempFilePath,
  54. // 如果文件名包含中文,建议使用escape(res.tempFilePath)转码,防止ios和安卓客户端导致的差异
  55. success: function(res) {
  56. uni.showToast({
  57. icon: 'none',
  58. title: '打开附件成功',
  59. position: "bottom"
  60. })
  61. },
  62. fail:function(res){
  63. uni.showToast({
  64. icon: 'none',
  65. title: '打开附件失败',
  66. position: "bottom"
  67. })
  68. }
  69. });
  70. downloadTask.onProgressUpdate((res) => {
  71. this.progress = res.progress
  72. });
  73. }
  74. }
  75. })
  76. }
  77. },
  78. }
  79. }
  80. </script>
  81. <style scoped lang="scss">
  82. .ordertop {
  83. width: 96%;
  84. background-color: #fff;
  85. margin: 20rpx auto;
  86. border-radius: 20rpx;
  87. padding-top: 20rpx;
  88. box-shadow: 0px 0px 8px 0px rgba(165, 189, 251, 0.4);
  89. padding-bottom: 10rpx;
  90. }
  91. .ordertop>view:nth-child(1) {
  92. width: 98%;
  93. margin-bottom: 60rpx;
  94. }
  95. .iconblue {
  96. width: 10rpx;
  97. height: 45rpx;
  98. float: left;
  99. background-color: #3a63cf;
  100. margin-right: 10rpx;
  101. }
  102. .line {
  103. width: 92%;
  104. margin: 0 auto;
  105. }
  106. .various {
  107. float: right;
  108. width: 150rpx;
  109. border: 2rpx solid #3a63cf;
  110. text-align: center;
  111. border-radius: 100rpx;
  112. color: #3a63cf;
  113. }
  114. .basic {
  115. width: 94%;
  116. margin: 10rpx auto;
  117. display: flex;
  118. justify-content: space-between;
  119. }
  120. .basic>view {
  121. margin-bottom: 10rpx;
  122. }
  123. .basic>view:nth-child(1) {
  124. color: #797979;
  125. }
  126. </style>