index.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  1. <script setup>
  2. import {
  3. ref
  4. } from 'vue'
  5. import {
  6. onLoad,
  7. onShow,
  8. onPageScroll,
  9. onPullDownRefresh,
  10. onReachBottom,
  11. } from "@dcloudio/uni-app"
  12. import {
  13. getWeeklyList,
  14. delWeelkyItem
  15. } from "@/api/work/weeklyAndMonthly.js"
  16. let scrollTop = ref(0)
  17. let loading = ref(true)
  18. // 参数
  19. let searchInfo = ref({
  20. pageNo: 1,
  21. pageSize: 10,
  22. })
  23. // 触底加载flag
  24. let moreListFlag = true
  25. // 主要列表
  26. let enterpriseList = ref([])
  27. let listTotal = ref(0)
  28. let optionsBack = null
  29. // 获取列表
  30. function getList() {
  31. if (searchInfo.value.pageNo == 1) {
  32. loading.value = true
  33. }
  34. let params = Object.assign({
  35. orderType: orderByStatus.value
  36. }, searchInfo.value)
  37. getWeeklyList(params).then(res => {
  38. loading.value = false
  39. enterpriseList.value = enterpriseList.value.concat(res.data.list);
  40. listTotal.value = res.data.totalCount;
  41. if (res.data.totalCount == searchInfo.value.pageNo * searchInfo.value.pageSize - (10 - res.data.list
  42. .length)) moreListFlag = false;
  43. }).catch(() => {
  44. loading.value = false
  45. })
  46. }
  47. // 按金额排序
  48. let orderByStatus = ref(null)
  49. const changeOrderByStatus = () => {
  50. if (orderByStatus.value === "desc") {
  51. orderByStatus.value = "asc"
  52. } else if (orderByStatus.value === "asc") {
  53. orderByStatus.value = null
  54. } else {
  55. orderByStatus.value = "desc"
  56. }
  57. searchInfo.value.pageNo = 1;
  58. enterpriseList.value = [];
  59. moreListFlag = true;
  60. getList();
  61. }
  62. // 折叠/展开
  63. const changeFoldItem = (status, id) => {
  64. let item = enterpriseList.value.find(item => item.sub_id === id);
  65. item.unfold = status;
  66. }
  67. // 去录入
  68. function gotoInput(subId, startDate, year, kj_month, num_bl, sub_plan_id) {
  69. uni.navigateTo({
  70. url: `/pages/weekly/input/index?subId=${subId}&startDate=${startDate}&year=${year}&kj_month=${kj_month}&num_bl=${num_bl}&sub_plan_id=${sub_plan_id}`
  71. })
  72. }
  73. // 去删除
  74. function goToDel(year, beginDate, subId) {
  75. uni.showModal({
  76. title: "删除确认",
  77. content: "确定要删除该周报录入吗?",
  78. success: function(res) {
  79. if (res.confirm) {
  80. delWeelkyItem({
  81. year,
  82. beginDate,
  83. subId
  84. }).then(delRes => {
  85. if (delRes.code === 200) {
  86. uni.showToast({
  87. title: "删除成功",
  88. icon: "success",
  89. duration: 2000,
  90. })
  91. getList(optionsBack)
  92. } else {
  93. uni.showToast({
  94. title: delRes.msg || "删除失败",
  95. icon: "error",
  96. duration: 2000,
  97. })
  98. }
  99. })
  100. } else if (res.cancel) {
  101. uni.showToast({
  102. title: "取消删除",
  103. icon: "none",
  104. duration: 2000,
  105. })
  106. }
  107. }
  108. })
  109. }
  110. // 去详情
  111. function gotoDetail(id, subName) {
  112. uni.navigateTo({
  113. url: `/pages/projectInfo/detail/index?id=${id}&subName=${subName}`
  114. })
  115. }
  116. onLoad((options) => {
  117. optionsBack = options
  118. searchInfo.value = Object.assign(searchInfo.value, options);
  119. searchInfo.value.pageNo = 1;
  120. enterpriseList.value = [];
  121. listTotal.value = 0;
  122. moreListFlag = true;
  123. getList();
  124. })
  125. onPageScroll((e) => {
  126. scrollTop.value = e.scrollTop
  127. })
  128. onPullDownRefresh(() => {
  129. searchInfo.value.pageNo = 1;
  130. enterpriseList.value = [];
  131. moreListFlag = true;
  132. try {
  133. getList();
  134. } finally {
  135. uni.stopPullDownRefresh()
  136. }
  137. })
  138. onReachBottom(() => {
  139. if (!moreListFlag) {
  140. return uni.showToast({
  141. title: "已经到底了。",
  142. icon: "none",
  143. duration: 2000
  144. })
  145. }
  146. searchInfo.value.pageNo++;
  147. getList();
  148. })
  149. </script>
  150. <template>
  151. <view class="container">
  152. <page-title>项目信息</page-title>
  153. <view class="cards-list">
  154. <view class="order-by">
  155. <view class=" order-by-item">
  156. 完成比例
  157. <view class="order-by-icon" :class="orderByStatus" @click="changeOrderByStatus()"></view>
  158. </view>
  159. </view>
  160. <view v-for="(item,index) in enterpriseList" :key="index">
  161. <!-- 未折叠卡片 -->
  162. <view class="card" v-if="item.unfold">
  163. <!-- 项目名称 -->
  164. <view class="card-item">
  165. <view class="card-item-name">项目名称</view>
  166. <view class="card-item-content">{{item.sub_name ?? "--"}}</view>
  167. </view>
  168. <view class="card-item">
  169. <view class="card-item-name">周</view>
  170. <view class="card-item-content">{{item.kj_month || "--"}}</view>
  171. </view>
  172. <view class="card-item">
  173. <view class="card-item-name">计划阶段</view>
  174. <view class="card-item-content">{{item.sub_plan_content || "--"}}</view>
  175. </view>
  176. <view class="card-item">
  177. <view class="card-item-name">完成比例</view>
  178. <view class="card-item-content">{{item.num_bl || "--"}}%</view>
  179. </view>
  180. <view class="card-item bottom-item">
  181. <view class="card-btn thin-btn text-btn"
  182. @click="gotoInput(item.sub_id,item.begin_date,item.year,item.kj_month,item.num_bl,item.sub_plan_id)">
  183. <image src="@/static/icon-input.svg" mode=""></image>
  184. 录入
  185. </view>
  186. <view class="card-btn thin-btn empty-btn" @click="goToDel(item.year,item.begin_date,item.sub_id)">删除</view>
  187. <view class="card-btn thin-btn " @click="gotoDetail(item.sub_id,item.sub_name)">项目查看</view>
  188. </view>
  189. <!-- 编号 -->
  190. <view class="card-fold-option">
  191. <view class="card-fold-count">{{index + 1}} / {{listTotal}}</view>
  192. <view class="card-fold-center" @click.stop="changeFoldItem(false,item.sub_id)">
  193. <view class="card-fold-btn card-unfold-btn"></view>
  194. </view>
  195. <view class="card-fold-chaos"></view>
  196. </view>
  197. </view>
  198. <!-- 折叠卡片 -->
  199. <view class="card-fold" v-else>
  200. {{item.sub_name ?? "--"}}
  201. <view class="card-fold-option">
  202. <view class="card-fold-count">{{index + 1}} / {{listTotal}}</view>
  203. <view class="card-fold-center" @click.stop="changeFoldItem(true, item.sub_id)">
  204. <view class="card-fold-btn"></view>
  205. </view>
  206. <view class="card-fold-chaos"></view>
  207. </view>
  208. </view>
  209. </view>
  210. <view class="gap-bottom"></view>
  211. <empty-show v-if="enterpriseList.length===0"></empty-show>
  212. </view>
  213. <u-back-top :scroll-top="scrollTop"></u-back-top>
  214. <u-loading-page :loading="loading"></u-loading-page>
  215. </view>
  216. </template>
  217. <style lang="scss" scoped>
  218. .card-fold {
  219. position: relative;
  220. width: 100%;
  221. min-height: 152rpx;
  222. margin-bottom: 20rpx;
  223. padding: 24rpx 30rpx 52rpx;
  224. box-sizing: border-box;
  225. background: #FFFFFF;
  226. border-radius: 40rpx;
  227. overflow: hidden;
  228. }
  229. .card-fold-option {
  230. position: absolute;
  231. display: flex;
  232. justify-content: space-between;
  233. align-items: center;
  234. left: 0;
  235. bottom: 0;
  236. width: 100%;
  237. height: 38rpx;
  238. padding: 0 40rpx;
  239. box-sizing: border-box;
  240. background: linear-gradient(270deg, #CADDFF 4%, rgba(219, 232, 255, 0) 100%);
  241. z-index: 999;
  242. .card-fold-count {
  243. flex: 1;
  244. font-size: 28rpx;
  245. color: #1869F6;
  246. }
  247. .card-fold-center {
  248. flex: 1;
  249. .card-fold-btn {
  250. width: 32rpx;
  251. height: 20rpx;
  252. margin: 0 auto;
  253. background-image: url("@/static/icon-fold.png");
  254. background-size: 100% 100%;
  255. }
  256. .card-unfold-btn {
  257. transform: rotate(180deg);
  258. }
  259. }
  260. .card-fold-chaos {
  261. flex: 1;
  262. }
  263. }
  264. .bottom-item {
  265. margin-bottom: 20rpx;
  266. }
  267. </style>