index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346
  1. <template>
  2. <view class="list-page-container">
  3. <view class="search-header">
  4. <view class="search-row">
  5. <uv-input placeholder="请输入项目名称" v-model="queryParams.projectName" prefixIcon="search"
  6. prefixIconStyle="color: #999; font-size: 32rpx;" clearable shape="circle"
  7. customStyle="background-color: #f5f7fa; border: none;" @confirm="onSearch"></uv-input>
  8. </view>
  9. </view>
  10. <view class="type-tabs">
  11. <uv-tabs :list="tabList" :current="currentTab" @change="onTabChange"
  12. :activeStyle="{ color: '#1c9bfd', fontWeight: 'bold', transform: 'scale(1.05)' }"
  13. :inactiveStyle="{ color: '#666' }" lineColor="#1c9bfd" lineWidth="40" :itemStyle="{ height: '88rpx', flex: 1 }"
  14. :scrollable="false"></uv-tabs>
  15. </view>
  16. <view class="list-container">
  17. <scroll-view scroll-y class="scroll-list" :scroll-top="scrollTopValue" scroll-with-animation refresher-enabled
  18. :refresher-triggered="isTriggered" @refresherrefresh="onRefresh" @scroll="onScroll" @scrolltolower="loadMore"
  19. :show-scrollbar="false">
  20. <uv-empty v-if="!list.length && loadStatus !== 'loading'" mode="list"></uv-empty>
  21. <view class="common-list-card" v-for="item in list" :key="item.id" @click="handleCardClick(item)">
  22. <view class="card-header">
  23. <text class="title">打款单位:{{ item.unit || '-' }}</text>
  24. <text class="status-tag"
  25. :class="item.status == '10' ? 'status-undo' : (item.status == '30' ? 'status-undo' : 'status-done')">
  26. {{ item.status == '10' ? '待认领' : (item.status == '30' ? '认领中' : '已认领') }}
  27. </text>
  28. </view>
  29. <view class="card-body">
  30. <!-- <view class="info-item">
  31. <text class="label">到账日期:</text>
  32. <text class="value">{{ item.date ? formatDate(new Date(item.date), 'YYYY-MM-DD') : '-' }}</text>
  33. </view>
  34. <view class="info-item">
  35. <text class="label">经费类型:</text>
  36. <text class="value">{{ getDictLabel(paymentReceivedTypeOptions, item.type) }}</text>
  37. </view> -->
  38. <view class="info-item">
  39. <text class="label">到款金额(元):</text>
  40. <text class="value number-font">{{ amountUnitFormatter(item.amount) }}{{ item.includeTax ? '(含税)' :
  41. '(不含税)' }}</text>
  42. </view>
  43. <!-- <view class="info-item">
  44. <text class="label">管理费(元):</text>
  45. <text class="value number-font">{{ amountUnitFormatter(item.manageAmount) }}</text>
  46. </view>
  47. <view class="info-item">
  48. <text class="label">税费(元):</text>
  49. <text class="value number-font">{{ amountUnitFormatter(item.taxAmount) }}</text>
  50. </view> -->
  51. <view class="info-item" v-if="item.projectName">
  52. <text class="label">项目名称:</text>
  53. <text class="value text-ellipsis">{{ item.projectName }}</text>
  54. </view>
  55. <view class="info-item" v-if="item.projectLeaderName">
  56. <text class="label">项目负责人:</text>
  57. <text class="value">{{ item.projectLeaderName }}</text>
  58. </view>
  59. <!-- <view class="info-item" v-if="item.projectDeptName">
  60. <text class="label">科室:</text>
  61. <text class="value">{{ item.projectDeptName }}</text>
  62. </view>
  63. <view class="info-item" v-if="item.createdName">
  64. <text class="label">创建人:</text>
  65. <text class="value">{{ item.createdName }}</text>
  66. </view>
  67. <view class="info-item" v-if="item.createdTime">
  68. <text class="label">创建时间:</text>
  69. <text class="value">{{ item.createdTime ? formatDate(new Date(item.createdTime), 'YYYY-MM-DD') : '-'
  70. }}</text>
  71. </view> -->
  72. </view>
  73. <view class="card-actions" @click.stop v-if="item.status == '10' || item.status == '30'">
  74. <view class="btn-box" v-if="item.status == '10'">
  75. <uv-button text="认领" type="primary" shape="circle" size="small" @click="toClaim(item.id)"></uv-button>
  76. </view>
  77. <view class="btn-box" v-if="item.status == '30'">
  78. <uv-button text="继续认领" type="primary" shape="circle" size="small" @click="toClaim(item.id)"></uv-button>
  79. </view>
  80. </view>
  81. </view>
  82. <uv-load-more v-if="list.length > 0 || loadStatus === 'loading'" :status="loadStatus"
  83. @loadmore="loadMore"></uv-load-more>
  84. </scroll-view>
  85. <uv-back-top :scrollTop="currentScrollTop" :bottom="100" :right="30" @click="backToTop"></uv-back-top>
  86. </view>
  87. </view>
  88. </template>
  89. <script setup lang="ts">
  90. import { ref, nextTick, watch } from 'vue';
  91. import { onLoad } from '@dcloudio/uni-app';
  92. import { debounce } from 'lodash-es';
  93. import { useFundApi } from '@/api/fund/index';
  94. import { useSystemApi } from '@/api/system/index';
  95. import { onRouterPush } from '@/utils/router';
  96. import { DEFAULT_PAGE_SIZE } from '@/constants/index';
  97. import { formatDate } from '@/utils/date';
  98. const fundApi = useFundApi();
  99. const systemApi = useSystemApi();
  100. const tabList = ref([{ name: '待认领', type: '10' }, { name: '已认领', type: '20' }, { name: '认领中', type: '30' }]);
  101. const currentTab = ref(0);
  102. const queryParams = ref({
  103. status: '10',
  104. projectName: '',
  105. pageNum: 1,
  106. pageSize: DEFAULT_PAGE_SIZE
  107. });
  108. const list = ref<any[]>([]);
  109. const loadStatus = ref<'loadmore' | 'loading' | 'nomore'>('loadmore');
  110. const isTriggered = ref(false);
  111. const scrollTopValue = ref(0);
  112. const currentScrollTop = ref(0);
  113. const paymentReceivedTypeOptions = ref<any[]>([]);
  114. const amountUnitFormatter = (val: any) => {
  115. if (val === null || val === undefined) return '0.00';
  116. const num = Number(val);
  117. return isNaN(num) ? '0.00' : num.toFixed(2).replace(/\B(?=(\d{3})+(?!\d))/g, ',');
  118. };
  119. const getDictLabel = (options: any[], value: string) => {
  120. const find = options.find((item) => item.dictValue === value);
  121. return find ? find.dictLabel : value || '-';
  122. };
  123. const getDict = async () => {
  124. try {
  125. const res: any = await systemApi.getDictDataByType('PaymentReceivedType');
  126. if (res.code == 200 && res.data) {
  127. paymentReceivedTypeOptions.value = res.data.values || [];
  128. }
  129. } catch (err) {
  130. console.error(err);
  131. }
  132. };
  133. const fetchListData = async (reset = false) => {
  134. if (reset) {
  135. queryParams.value.pageNum = 1;
  136. }
  137. loadStatus.value = 'loading';
  138. try {
  139. const res: any = await fundApi.getList(queryParams.value);
  140. if (res.code == 200) {
  141. const records = res.data?.list || res.list || [];
  142. if (reset) {
  143. list.value = records;
  144. } else {
  145. list.value = [...list.value, ...records];
  146. }
  147. if (records.length < queryParams.value.pageSize) {
  148. loadStatus.value = 'nomore';
  149. } else {
  150. loadStatus.value = 'loadmore';
  151. queryParams.value.pageNum += 1;
  152. }
  153. } else {
  154. loadStatus.value = 'nomore';
  155. }
  156. } catch (error) {
  157. console.error('Fetch error:', error);
  158. loadStatus.value = 'nomore';
  159. } finally {
  160. if (reset) {
  161. isTriggered.value = false;
  162. }
  163. }
  164. };
  165. const onSearch = () => {
  166. fetchListData(true);
  167. };
  168. const debouncedSearch = debounce(() => {
  169. fetchListData(true);
  170. }, 500);
  171. watch(() => queryParams.value.projectName, () => {
  172. debouncedSearch();
  173. });
  174. const onTabChange = (e: any) => {
  175. currentTab.value = e.index;
  176. queryParams.value.status = tabList.value[e.index].type;
  177. fetchListData(true);
  178. };
  179. const onRefresh = async () => {
  180. isTriggered.value = true;
  181. await fetchListData(true);
  182. };
  183. const loadMore = () => {
  184. if (loadStatus.value !== 'loadmore') return;
  185. fetchListData(false);
  186. };
  187. const onScroll = (e: any) => {
  188. currentScrollTop.value = e.detail.scrollTop;
  189. };
  190. const backToTop = () => {
  191. scrollTopValue.value = currentScrollTop.value;
  192. nextTick(() => {
  193. scrollTopValue.value = 0;
  194. });
  195. };
  196. const toViewDetail = (id: number) => {
  197. onRouterPush(`/pages/fund/claim/detail?id=${id}`);
  198. };
  199. const toClaim = (id: number) => {
  200. onRouterPush(`/pages/fund/claim/edit?id=${id}`);
  201. };
  202. const handleCardClick = (item: any) => {
  203. if (item.status == '10') {
  204. toClaim(item.id);
  205. } else {
  206. toViewDetail(item.id);
  207. }
  208. };
  209. onLoad(() => {
  210. getDict();
  211. fetchListData(true);
  212. });
  213. </script>
  214. <style lang="scss" scoped>
  215. .list-page-container {
  216. height: calc(100vh - var(--window-top));
  217. display: flex;
  218. flex-direction: column;
  219. background-color: #f5f7fa;
  220. box-sizing: border-box;
  221. }
  222. .search-header {
  223. background-color: #fff;
  224. padding: 20rpx 30rpx;
  225. box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.03);
  226. position: sticky;
  227. top: 0;
  228. z-index: 99;
  229. }
  230. .type-tabs {
  231. background-color: #fff;
  232. padding-bottom: 10rpx;
  233. box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.03);
  234. }
  235. .list-container {
  236. padding: 30rpx;
  237. flex: 1;
  238. overflow: hidden;
  239. box-sizing: border-box;
  240. }
  241. .scroll-list {
  242. flex: 1;
  243. height: 100%;
  244. }
  245. .common-list-card {
  246. .card-header {
  247. .status-tag {
  248. &.status-done {
  249. color: #52c41a;
  250. background-color: rgba(82, 196, 26, 0.1);
  251. }
  252. &.status-undo {
  253. color: #fa8c16;
  254. background-color: rgba(250, 173, 20, 0.1);
  255. }
  256. }
  257. }
  258. .card-body {
  259. .info-item {
  260. display: flex;
  261. font-size: 28rpx;
  262. margin-bottom: 12rpx;
  263. line-height: 1.5;
  264. &:last-child {
  265. margin-bottom: 0;
  266. }
  267. .label {
  268. color: #666;
  269. width: 200rpx;
  270. flex-shrink: 0;
  271. }
  272. .value {
  273. color: #333;
  274. flex: 1;
  275. word-break: break-all;
  276. }
  277. }
  278. }
  279. .card-actions {
  280. display: flex;
  281. justify-content: flex-end;
  282. align-items: center;
  283. padding-top: 24rpx;
  284. margin-top: 16rpx;
  285. border-top: 1rpx solid #f0f0f0;
  286. .btn-box {
  287. width: 150rpx;
  288. margin-left: 20rpx;
  289. }
  290. }
  291. }
  292. .number-font {
  293. font-family: 'Helvetica Neue', Arial, sans-serif;
  294. color: #1c9bfd !important;
  295. font-weight: 500;
  296. }
  297. .text-ellipsis {
  298. overflow: hidden;
  299. white-space: nowrap;
  300. text-overflow: ellipsis;
  301. }
  302. </style>