index.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. <template>
  2. <oa-scroll
  3. customClass="scroll-height"
  4. :pageSize="pageSize"
  5. :total="total"
  6. :refresherLoad="true"
  7. :refresherEnabled="true"
  8. :refresherDefaultStyle="'none'"
  9. :refresherThreshold="44"
  10. :refresherBackground="'#f5f6f7'"
  11. @load="load"
  12. @refresh="refresh"
  13. :data-theme="'theme-' + proxy.$settingStore.themeColor.name"
  14. >
  15. <template #default>
  16. <view class="fireReport">
  17. <view class="reportContent">
  18. <view class="contentDom" v-for="(li, index) in dataList" :key="index">
  19. <view style="margin: auto 10px auto 0" @click="handleSelect()">
  20. <u-image src="@/static/images/fireReport/icon1.png" width="13px" height="13px"></u-image>
  21. </view>
  22. <view style="margin: 0 auto 0 0" @click="handleSelect(li.reportPath)">
  23. <view>{{ li.reportName }}</view>
  24. </view>
  25. <view>
  26. <view style="color: #3c9cff; cursor: pointer" @click="handleDownload(li.reportPath)">下载报告</view>
  27. </view>
  28. </view>
  29. </view>
  30. </view>
  31. </template>
  32. </oa-scroll>
  33. </template>
  34. <script setup>
  35. import { onReady, onLoad, onShow, onReachBottom, onNavigationBarButtonTap } from "@dcloudio/uni-app";
  36. import { ref, onMounted, inject, shallowRef, reactive, watchEffect, getCurrentInstance } from "vue";
  37. import { useStores, commonStores } from "@/store/modules/index";
  38. import { reportInfoList } from "@/api/business/mhxf/fireReport";
  39. const commonStore = commonStores(); //全局公共Store
  40. const { proxy } = getCurrentInstance();
  41. const dataRes = ref(true);
  42. const dataList = ref([]);
  43. const pageSize = ref(20);
  44. const pageNum = ref(1);
  45. const total = ref(0);
  46. /**
  47. * @列表点击事件
  48. */
  49. function handleSelect(reportPath) {
  50. proxy.$tab.navigateTo("/pages/business/mhxf/fireReport/components/detailedPath?reportPath=" + reportPath);
  51. // proxy.$tab.navigateTo("/pages/business/mhxf/fireReport/components/detailed");
  52. }
  53. /**
  54. * @历史报告列表查询接口
  55. * @API接口查询
  56. */
  57. function reportInfoListApi() {
  58. reportInfoList({
  59. pageSize: pageSize.value,
  60. pageNum: pageNum.value,
  61. companyId: "",
  62. sourceType: 2,
  63. }).then((res) => {
  64. dataList.value = res.data.records;
  65. total.value = res.data.total;
  66. });
  67. }
  68. /**
  69. * @下载
  70. * @按钮点击事件
  71. */
  72. function handleDownload(reportPath) {
  73. proxy.$modal.loading("报告下载中,请耐心等待...");
  74. setTimeout(() => {
  75. // #ifdef H5
  76. window.open(reportPath);
  77. // #endif
  78. // 微信下载文件需要在微信公众平台>开发>开发管理>服务器域名>downloadFile合法域名>配置白名单域名
  79. // #ifdef MP-WEIXIN
  80. uni.downloadFile({
  81. url: reportPath,
  82. success: (res) => {
  83. console.log(res);
  84. if (res.statusCode === 200) {
  85. // 预览pdf文件
  86. uni.openDocument({
  87. filePath: res.tempFilePath,
  88. showMenu: true, // 右上角菜单,可以进行分享保存pdf
  89. success: function (file) {
  90. console.log("file-success", file);
  91. },
  92. });
  93. }
  94. },
  95. });
  96. // #endif
  97. // #ifdef APP-PLUS
  98. uni.downloadFile({
  99. url: reportPath,
  100. success: (res) => {
  101. console.log(res);
  102. if (res.statusCode === 200) {
  103. // 保存pdf文件至手机,一般安卓端存储路径为:手机存储/dcim/camera文件夹下
  104. uni.saveImageToPhotosAlbum({
  105. filePath: res.tempFilePath,
  106. success: function () {
  107. uni.showToast({
  108. title: "文件已保存至/DCIM/CAMERA文件夹下",
  109. icon: "none",
  110. });
  111. setTimeout(function () {
  112. // 预览pdf文件
  113. uni.openDocument({
  114. filePath: res.tempFilePath,
  115. showMenu: true,
  116. success: function (file) {
  117. console.log("file-success", file);
  118. },
  119. });
  120. }, 1500);
  121. },
  122. fail: function () {
  123. uni.showToast({
  124. title: "保存失败,请稍后重试!",
  125. icon: "none",
  126. });
  127. },
  128. });
  129. }
  130. },
  131. });
  132. // #endif
  133. proxy.$modal.closeLoading();
  134. }, 2000);
  135. }
  136. /**
  137. * @scrollView加载数据
  138. */
  139. function load() {
  140. pageSize.value += 10;
  141. reportInfoListApi();
  142. }
  143. /**
  144. * @scrollView刷新数据
  145. */
  146. function refresh() {
  147. pageSize.value = 20;
  148. total.value = 0;
  149. reportInfoListApi();
  150. }
  151. // 自定义导航事件
  152. onNavigationBarButtonTap((e) => {
  153. if (e.float == "right") {
  154. uni.navigateTo({
  155. url: "/pages/business/mhxf/xunJian/collect/components/collectRecord",
  156. });
  157. } else {
  158. }
  159. });
  160. onLoad((options) => {
  161. reportInfoListApi();
  162. });
  163. onShow(() => {
  164. //调用系统主题颜色
  165. proxy.$settingStore.systemThemeColor([1]);
  166. });
  167. onReady(() => {});
  168. onMounted(() => {});
  169. </script>
  170. <style lang="scss">
  171. .fireReport {
  172. background-color: #f7f7f7;
  173. .reportContent {
  174. .contentDom {
  175. display: flex;
  176. height: 45px;
  177. line-height: 45px;
  178. background: #fff;
  179. padding: 0 10px;
  180. }
  181. > uni-view {
  182. margin-bottom: 10px;
  183. }
  184. > uni-view:last-child {
  185. margin-bottom: 0px;
  186. }
  187. }
  188. .progress-container {
  189. position: fixed;
  190. top: 0;
  191. left: 0;
  192. z-index: 99;
  193. background: rgba(0, 0, 0, 0.2);
  194. width: 750rpx;
  195. height: 100vh;
  196. display: flex;
  197. align-items: center;
  198. justify-content: center;
  199. .progress-box {
  200. background: #ffffff;
  201. border-radius: 20rpx;
  202. padding: 30rpx;
  203. .text {
  204. margin-bottom: 20rpx;
  205. }
  206. }
  207. }
  208. }
  209. </style>