index.vue 9.4 KB

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