index.vue 10.0 KB

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