materialAttachments.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. <!-- 材料附件 -->
  2. <template>
  3. <view class="materialAttachments">
  4. <scroll-view scroll-y @scrolltolower="scrollGet" class="info-max-box">
  5. <view class="list">
  6. <view class="list-li" v-for="(item,index) in newData">
  7. <img :src="imagesUrl('safetyCheck/icon_djc_wj.png')">
  8. <view>{{item.fileName}}</view>
  9. <view @click="attachmentPreview(item)">查看</view>
  10. </view>
  11. </view>
  12. </scroll-view>
  13. </view>
  14. </template>
  15. <script>
  16. import {
  17. config
  18. } from '@/api/request/config.js'
  19. import {
  20. chemicalAppletGetStockDetail
  21. } from '@/pages/api/index.js'
  22. export default {
  23. name: "materialAttachments",
  24. components: {
  25. },
  26. data() {
  27. return {
  28. baseUrl: config.base_url,
  29. pageType: 0,
  30. newData: {},
  31. }
  32. },
  33. onLoad(option) {
  34. this.newData = JSON.parse(decodeURIComponent(option.infoData))
  35. },
  36. onShow() {
  37. },
  38. mounted() {
  39. },
  40. methods: {
  41. //滚动事件
  42. scrollGet() {},
  43. attachmentPreview(item) {
  44. uni.showLoading({
  45. title: '下载中'
  46. });
  47. wx.downloadFile({
  48. url: config.base_url + item.fileUrl,
  49. header: {
  50. Authorization: uni.getStorageSync('token')
  51. },
  52. success: function(res) {
  53. uni.hideLoading();
  54. const filePath = res.tempFilePath
  55. wx.openDocument({
  56. filePath: filePath,
  57. success: function(res) {
  58. console.log('打开文档成功')
  59. }
  60. })
  61. },
  62. fail: function(res) {
  63. uni.hideLoading();
  64. uni.showToast({
  65. title: '下载失败',
  66. icon: "none",
  67. mask: true,
  68. duration: 2000
  69. });
  70. }
  71. })
  72. },
  73. }
  74. }
  75. </script>
  76. <style lang="stylus" scoped>
  77. .materialAttachments {
  78. height: 100%;
  79. display flex;
  80. box-sizing: border-box;
  81. padding: 0 30rpx;
  82. box-sizing: border-box;
  83. .list {
  84. width: 690rpx;
  85. background: #FFFFFF;
  86. border-radius: 20rpx 20rpx 20rpx 20rpx;
  87. padding: 0 30rpx;
  88. box-sizing: border-box;
  89. margin-bottom: 20rpx;
  90. margin-top: 20rpx;
  91. .list-li {
  92. height: 100rpx;
  93. border-bottom: 1rpx solid #E0E0E0;
  94. display: flex;
  95. justify-content: space-between;
  96. align-items: center;
  97. >img {
  98. width: 30rpx;
  99. height: 30rpx;
  100. margin-right: 16rpx;
  101. }
  102. >view:nth-of-type(1) {
  103. flex: 1;
  104. font-size: 28rpx;
  105. color: #333333;
  106. line-height: 39rpx;
  107. text-align: left;
  108. overflow: hidden;
  109. text-overflow: ellipsis;
  110. white-space: nowrap;
  111. margin-right: 56rpx;
  112. }
  113. >view:nth-of-type(2) {
  114. font-size: 28rpx;
  115. color: #0183FA;
  116. line-height: 39rpx;
  117. text-align: left;
  118. }
  119. }
  120. .list-li:last-of-type {
  121. border: none;
  122. }
  123. }
  124. }
  125. </style>