index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457
  1. <script setup>
  2. import {
  3. ref,
  4. reactive,
  5. getCurrentInstance
  6. } from "vue";
  7. import {
  8. onLoad,
  9. } from "@dcloudio/uni-app";
  10. import {
  11. getHYFLlist,
  12. } from "@/api/work/projectInfo.js";
  13. import {
  14. getYearReportData,
  15. getYearReportTableData
  16. } from "@/api/work/analysis.js";
  17. import config from '@/config.js';
  18. // 年度
  19. let yearShow = ref(false);
  20. let defaultIndex = ref([0]);
  21. let yearColumns = ref([
  22. ["2000", "2001", "2002", "2003", "2004", "2005", "2006", "2007", "2008", "2009", "2010", "2011", "2012",
  23. "2013",
  24. "2014", "2015", "2016", "2017", "2018", "2019", "2020", "2021", "2022", "2023", "2024", "2025", "2026",
  25. "2027", "2028", "2029", "2030", "2031", "2032", "2033"
  26. ]
  27. ])
  28. const yearShowChoose = function() {
  29. yearShow.value = true;
  30. }
  31. const yearClose = function(e) {
  32. if (e) {
  33. searchInfo.year = e.value[0];
  34. // getTableData();
  35. }
  36. yearShow.value = false;
  37. }
  38. // 是否隐藏
  39. let hideFull = [{
  40. key: true,
  41. value: "包含"
  42. }, {
  43. key: false,
  44. value: "不包含"
  45. }, ];
  46. let hideColumns = ref([
  47. ["包含", "不包含"]
  48. ])
  49. let hideShow = ref(false);
  50. const hideShowChoose = function() {
  51. hideShow.value = true;
  52. }
  53. const hideClose = function(e) {
  54. if (e) {
  55. searchInfo.isHide = e.value[0];
  56. // getTableData();
  57. }
  58. hideShow.value = false;
  59. }
  60. // 行业分类
  61. let hyflFull = []
  62. let hyflShow = ref(false);
  63. let hyflList = ref([]);
  64. const getHYFL = () => {
  65. getHYFLlist().then(res => {
  66. hyflList.value = res.data.list;
  67. })
  68. }
  69. let hyflSelectIndex = [];
  70. let hyflChooseList = [];
  71. const hyflSelect = e => {
  72. hyflSelectIndex = e.detail.index;
  73. }
  74. const hyflShowChoose = () => {
  75. hyflSelectIndex = [];
  76. hyflShow.value = true
  77. }
  78. const closeHyflPopup = type => {
  79. if (type === "confirm") {
  80. let tempArr = [];
  81. for (let i in hyflSelectIndex) {
  82. tempArr.push(hyflList.value[hyflSelectIndex[i]])
  83. };
  84. hyflChooseList = tempArr;
  85. searchInfo.hyfl = tempArr.map(item => item.value).join("、");
  86. }
  87. hyflShow.value = false;
  88. }
  89. // 搜索条件
  90. let searchInfo = reactive({
  91. year: null, //年度
  92. isHide: "包含", //是否隐藏,
  93. hyfl: null,
  94. })
  95. const createReport = () => {
  96. uni.$u.route({
  97. url: "/pages/analysis/media/index",
  98. params: {
  99. year: searchInfo.year,
  100. containHide: hideFull.find(item => item.value === searchInfo.isHide)?.key,
  101. hyfl: hyflChooseList.map(item => item.key).join(","),
  102. token: uni.getStorageSync('App-Token'),
  103. }
  104. })
  105. // 老版本下载pdf
  106. // getYearReportData(params).then(res => {
  107. // return console.log(res);
  108. // let url =
  109. // `${baseUrlIp}/projects/outApi/projects/statics/downReportPdf?url=${res.data.url}&year=${res.data.year}`
  110. // downLoadFile(url)
  111. // })
  112. }
  113. // 列表数据
  114. let showList = ref([{
  115. text: "行业分类",
  116. key: "hyflName",
  117. value: null,
  118. width: "200rpx"
  119. }, {
  120. text: "数量",
  121. key: "totalNum",
  122. value: null,
  123. width: "100rpx"
  124. }, {
  125. text: "总投资金额(亿元)",
  126. key: "totalAmt",
  127. value: null,
  128. width: "200rpx"
  129. }, {
  130. text: "年度计划投资金额(亿元)",
  131. key: "yearPlan",
  132. value: null,
  133. width: "200rpx"
  134. }, {
  135. text: "占比",
  136. key: "planRate",
  137. value: null,
  138. width: "100rpx"
  139. }, {
  140. text: "已完成金额(亿元)",
  141. key: "endAmt",
  142. value: null,
  143. width: "200rpx"
  144. }, ])
  145. let tableList = ref([]);
  146. const getTableData = () => {
  147. let params = {
  148. year: searchInfo.year,
  149. containHide: hideFull.find(item => item.value === searchInfo.isHide)?.key,
  150. // hyfl: hyflFull.find(item => item.value === searchInfo.hyfl)?.key ?? "",
  151. }
  152. getYearReportTableData(params).then(res => {
  153. tableList.value = res.data.hyflData;
  154. })
  155. }
  156. let isDownload = ref(false); // 是否正在下载
  157. let downloadPrecent = ref(0); //下载进度
  158. // 文件预览
  159. const downLoadFile = url => {
  160. isDownload.value = true;
  161. let downloadTask = uni.downloadFile({
  162. url,
  163. success: function(res) {
  164. isDownload.value = false;
  165. let filepathss = plus.io.convertLocalFileSystemURL(res.tempFilePath);
  166. setTimeout(
  167. () =>
  168. uni.openDocument({
  169. filePath: filepathss,
  170. showMenu: false,
  171. success: function() {},
  172. fail: function(failRes) {
  173. uni.showToast({
  174. title: '暂不支持此类型',
  175. duration: 2000,
  176. icon: "none",
  177. });
  178. }
  179. }),
  180. 1000
  181. );
  182. },
  183. fail: function(failRes) {
  184. isDownload.value = false;
  185. }
  186. });
  187. downloadTask.onProgressUpdate(res => {
  188. downloadPrecent.value = res.progress;
  189. })
  190. }
  191. onLoad(() => {
  192. let now = new Date();
  193. searchInfo.year = now.getFullYear();
  194. defaultIndex.value = [searchInfo.year - 2000];
  195. })
  196. </script>
  197. <template>
  198. <view class="container">
  199. <page-title>投资分析报告</page-title>
  200. <view class="cards-list">
  201. <view class="card only-card">
  202. <!-- 年度 -->
  203. <view class="card-item first-card-item" @click="yearShowChoose()">
  204. <view class="card-item-name">年度</view>
  205. <view class="card-item-description">
  206. <view v-if="searchInfo.year">{{searchInfo.year}}</view>
  207. <view v-else class="remind-text">请选择年度</view>
  208. <u-icon name="arrow-right" color="#343437" size="16" customStyle="margin-left:10rpx"></u-icon>
  209. </view>
  210. </view>
  211. <!-- 行业分类 -->
  212. <view class="card-item" @click="hyflShowChoose()">
  213. <view class="card-item-name">行业分类</view>
  214. <view class="card-item-description">
  215. <view v-if="searchInfo.hyfl">{{searchInfo.hyfl}}</view>
  216. <view v-else class="remind-text">请选择类型</view>
  217. <u-icon name="arrow-right" color="#343437" size="16" customStyle="margin-left:10rpx"></u-icon>
  218. </view>
  219. </view>
  220. <!-- 是否隐藏 -->
  221. <view class="card-item" @click="hideShowChoose()">
  222. <view class="card-item-name">是否包含隐藏</view>
  223. <view class="card-item-description">
  224. <view v-if="searchInfo.isHide">{{searchInfo.isHide}}</view>
  225. <view v-else class="remind-text">请选择</view>
  226. <u-icon name="arrow-right" color="#343437" size="16" customStyle="margin-left:10rpx"></u-icon>
  227. </view>
  228. </view>
  229. </view>
  230. <view class="search-btn" @click="createReport()">生成报告</view>
  231. <!-- <scroll-view class="swiper-item-content" scroll-y>
  232. <uni-table stripe emptyText="暂无更多数据">
  233. <uni-tr>
  234. <uni-th align="center" v-for="(showItem,showIndex) in showList" :index="showIndex"
  235. :width="showItem.width">{{showItem.text}}</uni-th>
  236. </uni-tr>
  237. <uni-tr v-for="(item,index) in tableList" :key="index">
  238. <uni-td align="center" v-for="(showItem,showIndex) in showList" :index="showIndex">
  239. {{item[showItem.key] ?? "--"}}
  240. </uni-td>
  241. </uni-tr>
  242. </uni-table>
  243. </scroll-view> -->
  244. <view class="gap-bottom"></view>
  245. </view>
  246. <!-- 年度选择 -->
  247. <u-picker :show="yearShow" :defaultIndex="defaultIndex" :columns="yearColumns" @confirm="yearClose"
  248. @cancel="yearClose" @close="yearClose" closeOnClickOverlay></u-picker>
  249. <!-- 是否隐藏 -->
  250. <u-picker :show="hideShow" :columns="hideColumns" @confirm="hideClose" @cancel="hideClose" @close="hideClose"
  251. closeOnClickOverlay></u-picker>
  252. <!-- 行业分类 -->
  253. <u-popup :show="hyflShow" @open="getHYFL()" mode="center">
  254. <view class="user-choose">
  255. <view class="user-choose-title">
  256. <view class="uesr-choose-icon hide"></view>
  257. 行业分类
  258. <view class="uesr-choose-icon" @click="closeHyflPopup('close')"></view>
  259. </view>
  260. <view class="search-item">
  261. <scroll-view class="swiper-item-content" scroll-y>
  262. <uni-table type="selection" emptyText="暂无更多数据" @selection-change="hyflSelect">
  263. <!-- 表头行 -->
  264. <uni-tr :style="{backgroundColor: '#c4daff'}">
  265. <uni-th align="center" :style="{color: '#1869F6',fontWeight: 'bold'}">行业分类</uni-th>
  266. </uni-tr>
  267. <!-- 表格数据行 -->
  268. <uni-tr v-for="(item,index) in hyflList" :key="index">
  269. <uni-td align="center">{{item.value}}</uni-td>
  270. </uni-tr>
  271. </uni-table>
  272. </scroll-view>
  273. </view>
  274. <view class="search-btn" @click="closeHyflPopup('confirm')">确定</view>
  275. </view>
  276. </u-popup>
  277. <u-overlay :show="isDownload">
  278. <view class="download-box">
  279. <view class="loading-box">
  280. <view class="loading-icon">
  281. <u-loading-icon v-if="downloadPrecent !== '100'" size="40"></u-loading-icon>
  282. <u-icon v-else name="checkmark" size="40"></u-icon>
  283. </view>
  284. <view class="loading-text">附件下载中</view>
  285. <view class="loading-progress">
  286. <u-line-progress :percentage="downloadPrecent" activeColor="#1869F6"></u-line-progress>
  287. </view>
  288. </view>
  289. </view>
  290. </u-overlay>
  291. </view>
  292. </template>
  293. <style lang="scss" scoped>
  294. .search-btn {
  295. width: 98%;
  296. height: 84rpx;
  297. margin: 40rpx auto 56rpx;
  298. line-height: 84rpx;
  299. text-align: center;
  300. color: #FFFFFF;
  301. font-size: 36rpx;
  302. background: #1763E7;
  303. border-radius: 16rpx;
  304. }
  305. .download-box {
  306. display: flex;
  307. align-items: center;
  308. justify-content: center;
  309. height: 100%;
  310. .loading-box {
  311. display: flex;
  312. flex-direction: column;
  313. justify-content: space-between;
  314. width: 360rpx;
  315. height: 360rpx;
  316. padding: 20rpx;
  317. background-color: #fff;
  318. border-radius: 40rpx;
  319. }
  320. .loading-icon {
  321. flex: 4;
  322. display: flex;
  323. flex-direction: column;
  324. justify-content: center;
  325. }
  326. .loading-text {
  327. flex: 1;
  328. display: flex;
  329. align-items: flex-end;
  330. text-align: center;
  331. }
  332. .loading-progress {
  333. flex: 1;
  334. display: flex;
  335. align-items: flex-end;
  336. }
  337. }
  338. .swiper-item-content {
  339. height: 1200rpx;
  340. }
  341. ::v-deep .uni-table-scroll {
  342. height: 1000rpx;
  343. }
  344. .user-choose {
  345. width: 666rpx;
  346. height: 1220rpx;
  347. padding: 30rpx 28rpx;
  348. .user-choose-title {
  349. display: flex;
  350. justify-content: space-between;
  351. width: 100%;
  352. margin-bottom: 54rpx;
  353. font-weight: 500;
  354. color: #3D3D3D;
  355. font-size: 32rpx;
  356. .uesr-choose-icon {
  357. width: 44rpx;
  358. height: 44rpx;
  359. background: url("@/static/message-close.svg");
  360. background-size: 100% 100%;
  361. }
  362. .hide {
  363. background: none;
  364. }
  365. }
  366. .search-item {
  367. display: flex;
  368. justify-content: space-between;
  369. align-items: flex-start;
  370. width: 606rpx;
  371. height: 950rpx;
  372. padding: 26rpx 30rpx;
  373. margin-bottom: 32rpx;
  374. font-size: 28rpx;
  375. border-radius: 20rpx;
  376. border: 2rpx solid #D0D9E7;
  377. .search-item-name {
  378. min-width: 128rpx;
  379. color: #939AA5;
  380. }
  381. .search-item-content {
  382. color: #3D3D3D;
  383. text-align: right;
  384. }
  385. .swiper-item-content {
  386. height: 900rpx;
  387. }
  388. }
  389. .search-btn {
  390. width: 606rpx;
  391. height: 64rpx;
  392. margin-top: 50rpx;
  393. line-height: 64rpx;
  394. text-align: center;
  395. color: #FFFFFF;
  396. font-size: 28rpx;
  397. background: #1869F6;
  398. border-radius: 16rpx;
  399. }
  400. }
  401. ::v-deep .u-popup__content {
  402. border-radius: 28rpx !important;
  403. }
  404. ::v-deep .uni-table-th-content {
  405. // color: #1869F6 !important;
  406. // font-weight: bold;
  407. }
  408. </style>