index.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375
  1. <script setup>
  2. import {
  3. ref,
  4. reactive
  5. } from 'vue';
  6. import {
  7. onLoad,
  8. onPullDownRefresh,
  9. onReachBottom,
  10. onPageScroll
  11. } from "@dcloudio/uni-app";
  12. import {
  13. getProjectInfoList
  14. } from "@/api/work/projectInfo.js";
  15. import {
  16. addFocus,
  17. cancelFocus
  18. } from "@/api/work/focus.js";
  19. // 返回头部
  20. let scrollTop = ref(0);
  21. // 获取列表
  22. let loading = ref(true);
  23. let moreListFlag = true;
  24. let projectList = ref([]);
  25. let listTotal = ref(0);
  26. let sendData = ref({});
  27. let searchInfo = reactive({
  28. pageNo: 1,
  29. pageSize: 10,
  30. beginDateStart: null,
  31. beginDateEnd: null,
  32. status: null,
  33. })
  34. const getList = () => {
  35. if (searchInfo.pageNo == 1) loading.value = true;
  36. let params = Object.assign({}, sendData, searchInfo);
  37. getProjectInfoList(params).then(res => {
  38. projectList.value = projectList.value.concat(res.data.list);
  39. listTotal.value = res.data.total;
  40. if (res.data.total == searchInfo.pageNo * searchInfo.pageSize - (10 - res.data.list.length)) {
  41. moreListFlag = false;
  42. }
  43. }).finally(() => {
  44. loading.value = false;
  45. })
  46. }
  47. const reGetList = () => {
  48. searchInfo.pageNo = 1;
  49. projectList.value = [];
  50. moreListFlag = true;
  51. getList();
  52. }
  53. // 折叠/展开
  54. const changeFoldItem = (status, id) => {
  55. let item = projectList.value.find(item => item.id === id);
  56. item.unfold = status;
  57. }
  58. // 详情
  59. const goToDetail = (id, subName) => {
  60. uni.navigateTo({
  61. url: `/pages/projectInfo/detail/index?id=${id}&subName=${subName}`
  62. })
  63. }
  64. // 收藏/取消
  65. const changeFocus = (id, status) => {
  66. let item = projectList.value.find(item => item.id === id);
  67. if (status) {
  68. cancelFocus({
  69. subId: id
  70. }).then(res => {
  71. if (res.code === 200) {
  72. item.isAttention = 0;
  73. }
  74. }).catch(() => {
  75. uni.showToast({
  76. title: "更改收藏状态失败。",
  77. icon: "none",
  78. duration: 2000
  79. })
  80. })
  81. } else {
  82. addFocus({
  83. subId: id
  84. }).then(res => {
  85. if (res.code === 200) {
  86. item.isAttention = 1;
  87. }
  88. }).catch(() => {
  89. uni.showToast({
  90. title: "更改收藏状态失败。",
  91. icon: "none",
  92. duration: 2000
  93. })
  94. })
  95. }
  96. }
  97. // 周报月报/更多
  98. const goToReport = (type, subId, subName) => {
  99. if (type === 'more') {
  100. uni.navigateTo({
  101. url: `/pages/projectBtnList/index?type=${type}&subId=${subId}&subName=${subName}`
  102. })
  103. } else {
  104. uni.navigateTo({
  105. url: `/pages/projectInfo/report/index?type=${type}&subId=${subId}&subName=${subName}`
  106. })
  107. }
  108. }
  109. onLoad(options => {
  110. sendData = options;
  111. searchInfo.beginDateStart = `${options.year}/01/01`;
  112. searchInfo.beginDateEnd = `${options.year}/12/31`;
  113. searchInfo.status = options.status;
  114. getList();
  115. })
  116. onPageScroll(e => {
  117. scrollTop.value = e.scrollTop
  118. })
  119. onPullDownRefresh(() => {
  120. try {
  121. reGetList();
  122. } finally {
  123. uni.stopPullDownRefresh();
  124. }
  125. })
  126. onReachBottom(() => {
  127. if (!moreListFlag) {
  128. return uni.showToast({
  129. title: "已经到底了。",
  130. icon: "none",
  131. duration: 2000
  132. })
  133. }
  134. searchInfo.pageNo++;
  135. getList();
  136. })
  137. </script>
  138. <template>
  139. <view class="container">
  140. <page-title>详情</page-title>
  141. <view class="cards-list">
  142. <view v-for="(item,index) in projectList" :key="index">
  143. <!-- 未折叠卡片 -->
  144. <view class="card" v-if="item.unfold">
  145. <!-- 项目名称 -->
  146. <view class="card-item">
  147. <view class="card-item-name">项目名称</view>
  148. <view class="card-item-content">{{item.subName ?? "--"}}</view>
  149. </view>
  150. <!-- 总投资(万元) -->
  151. <view class="card-item">
  152. <view class="card-item-name">总投资(万元)</view>
  153. <view class="card-item-content">{{item.amtTotal ?? "--"}}</view>
  154. </view>
  155. <!-- 年度计划投资-申报单位(万元) -->
  156. <view class="card-item">
  157. <view class="card-item-name">年度计划投资-申报单位(万元)</view>
  158. <view class="card-item-content">{{item.yearAmt ?? "--"}}</view>
  159. </view>
  160. <!-- 已完成投资(万元)-->
  161. <view class="card-item">
  162. <view class="card-item-name">已完成投资(万元)</view>
  163. <view class="card-item-content">{{item.yearAmtSj ?? "--"}}</view>
  164. </view>
  165. <!-- 当前状态 -->
  166. <view class="card-item">
  167. <view class="card-item-name">当前状态</view>
  168. <view class="card-item-content">{{item.status || "--"}}</view>
  169. </view>
  170. <!-- 功能按钮 -->
  171. <view class="card-item">
  172. <!-- 项目查看按钮(特殊) -->
  173. <view class="card-btn fat-btn special-btn" @click="goToDetail(item.id,item.subName)"
  174. v-if="item.usersub == 1">
  175. 项目查看</view>
  176. <!-- 项目查看按钮 -->
  177. <view class="card-btn fat-btn project-btn" @click="goToDetail(item.id,item.subName)" v-else>项目查看
  178. </view>
  179. <!-- 关注按钮 -->
  180. <view class="card-btn fat-btn focus-btn" @click="changeFocus(item.id,item.isAttention)"
  181. v-if="!item.isAttention">关注</view>
  182. <view class="card-btn fat-btn focus-btn-no" @click="changeFocus(item.id,item.isAttention)" v-else>
  183. 取消关注</view>
  184. </view>
  185. <!-- 周月年报按钮 -->
  186. <view class="card-item bottom-item">
  187. <view class="card-btn thin-btn report-btn" @click="goToReport('weekly',item.id,item.subName)">周报
  188. </view>
  189. <view class="card-btn thin-btn report-btn" @click="goToReport('monthly',item.id,item.subName)">月报
  190. </view>
  191. <view class="card-btn thin-btn more-btn" @click="goToReport('more',item.id,item.subName)">更多操作
  192. </view>
  193. </view>
  194. <!-- 编号 -->
  195. <view class="card-fold-option"
  196. :class="item.status_fgw === '2' ? 'card-fold-red' :item.status_fgw === '1' ?'card-fold-yellow':''">
  197. <view class="card-fold-count">{{index + 1}} / {{listTotal}}</view>
  198. <view class="card-fold-center" @click.stop="changeFoldItem(false,item.id)">
  199. <view class="card-fold-btn card-unfold-btn"></view>
  200. </view>
  201. <view class="card-fold-chaos"></view>
  202. </view>
  203. </view>
  204. <!-- 折叠卡片 -->
  205. <view class="card-fold" v-else>
  206. {{item.subName ?? "--"}}
  207. <view class="card-fold-option"
  208. :class="item.status_fgw === '2' ? 'card-fold-red' :item.status_fgw === '1' ?'card-fold-yellow':''">
  209. <view class="card-fold-count">{{index + 1}} / {{listTotal}}</view>
  210. <view class="card-fold-center" @click.stop="changeFoldItem(true, item.id)">
  211. <view class="card-fold-btn"></view>
  212. </view>
  213. <view class="card-fold-chaos"></view>
  214. </view>
  215. </view>
  216. </view>
  217. <empty-show v-if="projectList.length===0"></empty-show>
  218. <view class="gap-bottom"></view>
  219. </view>
  220. <u-back-top :scroll-top="scrollTop"></u-back-top>
  221. <u-loading-page :loading="loading"></u-loading-page>
  222. </view>
  223. </template>
  224. <style lang="scss">
  225. .card-fold {
  226. position: relative;
  227. width: 100%;
  228. min-height: 152rpx;
  229. margin-bottom: 20rpx;
  230. padding: 24rpx 30rpx 52rpx;
  231. box-sizing: border-box;
  232. background: #FFFFFF;
  233. border-radius: 40rpx;
  234. overflow: hidden;
  235. }
  236. .card-fold-option {
  237. position: absolute;
  238. display: flex;
  239. justify-content: space-between;
  240. align-items: center;
  241. left: 0;
  242. bottom: 0;
  243. width: 100%;
  244. height: 38rpx;
  245. padding: 0 40rpx;
  246. box-sizing: border-box;
  247. background: linear-gradient(270deg, #CADDFF 4%, rgba(219, 232, 255, 0) 100%);
  248. z-index: 999;
  249. .card-fold-count {
  250. flex: 1;
  251. font-size: 28rpx;
  252. color: #1869F6;
  253. }
  254. .card-fold-center {
  255. flex: 1;
  256. .card-fold-btn {
  257. width: 32rpx;
  258. height: 20rpx;
  259. margin: 0 auto;
  260. background-image: url("@/static/icon-fold.png");
  261. background-size: 100% 100%;
  262. }
  263. .card-unfold-btn {
  264. transform: rotate(180deg);
  265. }
  266. }
  267. .card-fold-chaos {
  268. flex: 1;
  269. }
  270. }
  271. .card-fold-red {
  272. background: linear-gradient(270deg, #FF8080 0%, rgba(219, 232, 255, 0) 100%);
  273. .card-fold-count {
  274. color: #FF0000;
  275. }
  276. .card-fold-center {
  277. .card-fold-btn {
  278. background-image: url("@/static/icon-fold-red.png");
  279. }
  280. }
  281. }
  282. .card-fold-yellow {
  283. background: linear-gradient(270deg, #FFAA00 4%, rgba(219, 232, 255, 0) 100%);
  284. .card-fold-count {
  285. color: #E19703;
  286. }
  287. .card-fold-center {
  288. .card-fold-btn {
  289. background-image: url("@/static/icon-fold-yellow.png");
  290. }
  291. }
  292. }
  293. .bottom-item {
  294. margin-bottom: 20rpx;
  295. }
  296. .project-btn {
  297. width: 48% !important;
  298. background: #1869F6;
  299. }
  300. .focus-btn {
  301. width: 48% !important;
  302. background-color: #fff;
  303. border-radius: 16rpx 16rpx 16rpx 16rpx;
  304. border: 3rpx solid #1869F6;
  305. color: #1869F6;
  306. }
  307. .focus-btn-no {
  308. width: 48% !important;
  309. background-color: #fff;
  310. border-radius: 16rpx 16rpx 16rpx 16rpx;
  311. border: 3rpx solid #FF2D2D;
  312. color: #FF2D2D;
  313. }
  314. .more-btn {
  315. background-color: #fff;
  316. color: #1869F6;
  317. font-size: 32rpx;
  318. }
  319. </style>