index.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. <template>
  2. <view class="container">
  3. <page-title>问题查看</page-title>
  4. <view class="cards-list">
  5. <view class="card only-card">
  6. <view class="card-item" :class="index === 0?'first-card-item':''" v-for="(item,index) in companyInfoList"
  7. :key="index">
  8. <view class="card-item-name">{{item.description}}</view>
  9. <view class="card-item-content" @click="showFile(item.description,item.fileAddre)">{{item.value ?? "--"}}
  10. </view>
  11. </view>
  12. </view>
  13. <view class="card only-card">
  14. <view class="card-item" :class="index === 0?'first-card-item':''" v-for="(item,index) in projectInfoList"
  15. :key="index">
  16. <view class="card-item-name">{{item.description}}</view>
  17. <view class="card-item-content">{{item.value ?? "--"}}</view>
  18. </view>
  19. </view>
  20. </view>
  21. <u-overlay :show="isDownload">
  22. <view class="download-box">
  23. <view class="loading-box">
  24. <view class="loading-icon">
  25. <u-loading-icon v-if="downloadPrecent !== '100'" size="40"></u-loading-icon>
  26. <u-icon v-else name="checkmark" size="40"></u-icon>
  27. </view>
  28. <view class="loading-text">附件下载中</view>
  29. <view class="loading-progress">
  30. <u-line-progress :percentage="downloadPrecent" activeColor="#1869F6"></u-line-progress>
  31. </view>
  32. </view>
  33. </view>
  34. </u-overlay>
  35. </view>
  36. </template>
  37. <script setup>
  38. import {
  39. ref
  40. } from 'vue'
  41. import {
  42. onLoad
  43. } from "@dcloudio/uni-app"
  44. import {
  45. getOverseeDetail,
  46. } from "@/api/work/oversee.js"
  47. function backToBefore() {
  48. uni.navigateBack({})
  49. };
  50. let companyInfoList = ref([{
  51. description: '问题类型',
  52. key: "kind_typeid",
  53. value: ''
  54. }, {
  55. description: '问题来源',
  56. key: "kind_sourceid",
  57. value: ''
  58. }, {
  59. description: '要求完成时间',
  60. key: "kind_sourceid",
  61. value: ''
  62. }, {
  63. description: '问题描述',
  64. key: "title",
  65. value: ''
  66. }, {
  67. description: '附件',
  68. key: "fileName",
  69. value: '',
  70. isFile: true,
  71. }])
  72. let projectInfoList = ref([{
  73. description: '督察单位',
  74. key: "unit_id",
  75. value: ''
  76. }, {
  77. description: '责任领导',
  78. key: "nameLead",
  79. value: '',
  80. }, {
  81. description: '联系人',
  82. key: "nameLxr",
  83. value: '',
  84. }, {
  85. description: '联系电话',
  86. key: "tel",
  87. value: '',
  88. type: 'number'
  89. }])
  90. function filterData(obj) {
  91. for (let i in companyInfoList.value) {
  92. companyInfoList.value[i].value = obj[companyInfoList.value[i].key] || "--"
  93. }
  94. for (let i in projectInfoList.value) {
  95. projectInfoList.value[i].value = obj[projectInfoList.value[i].key] || "--"
  96. }
  97. fileAddre = obj.fileAddre;
  98. }
  99. let isDownload = ref(false); // 是否正在下载
  100. let downloadPrecent = ref(0)
  101. let fileAddre = null; // 文件下载地址
  102. // 文件预览
  103. function showFile(description) {
  104. if (description !== "附件" || !fileAddre) return;
  105. // uni.navigateTo({
  106. // url: `/pages/projectInfo/media/index?type=pdf&filePath=${fileAddre}`
  107. // })
  108. isDownload.value = true;
  109. let downloadTask = uni.downloadFile({
  110. url: fileAddre,
  111. success: function(res) {
  112. console.log(res)
  113. isDownload.value = false;
  114. let filepathss = plus.io.convertLocalFileSystemURL(res.tempFilePath);
  115. setTimeout(
  116. () =>
  117. uni.openDocument({
  118. filePath: filepathss,
  119. showMenu: false,
  120. success: function() {
  121. console.log("打开文档成功");
  122. },
  123. fail: function() {
  124. uni.showToast({
  125. title: '暂不支持此类型',
  126. duration: 2000,
  127. icon: "none",
  128. });
  129. }
  130. }),
  131. 1000
  132. );
  133. },
  134. fail: function(res) {
  135. isDownload.value = false;
  136. }
  137. });
  138. downloadTask.onProgressUpdate(res => {
  139. downloadPrecent.value = res.progress;
  140. })
  141. }
  142. onLoad((option) => {
  143. getOverseeDetail({
  144. id: option.id
  145. }).then(res => {
  146. filterData(res.data.problemInfo)
  147. })
  148. })
  149. </script>
  150. <style lang="scss" scoped>
  151. .download-box {
  152. display: flex;
  153. align-items: center;
  154. justify-content: center;
  155. height: 100%;
  156. .loading-box {
  157. display: flex;
  158. flex-direction: column;
  159. justify-content: space-between;
  160. width: 360rpx;
  161. height: 360rpx;
  162. padding: 20rpx;
  163. background-color: #fff;
  164. border-radius: 40rpx;
  165. }
  166. .loading-icon {
  167. flex: 4;
  168. display: flex;
  169. flex-direction: column;
  170. justify-content: center;
  171. }
  172. .loading-text {
  173. flex: 1;
  174. display: flex;
  175. align-items: flex-end;
  176. text-align: center;
  177. }
  178. .loading-progress {
  179. flex: 1;
  180. display: flex;
  181. align-items: flex-end;
  182. }
  183. }
  184. </style>