index.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. <template>
  2. <view class="list-page-container">
  3. <view class="sticky-header">
  4. <view class="search-header">
  5. <view class="search-row">
  6. <uv-input placeholder="请输入单据编号" v-model="queryParams.expenseNo" prefixIcon="search"
  7. prefixIconStyle="color: #999; font-size: 32rpx;" clearable shape="circle"
  8. customStyle="background-color: #f5f7fa; border: none;" @confirm="onSearch"></uv-input>
  9. </view>
  10. </view>
  11. <view class="type-tabs">
  12. <uv-tabs :list="tabList" :current="currentTab" @change="onTabChange"
  13. :activeStyle="{ color: '#1c9bfd', fontWeight: 'bold', transform: 'scale(1.05)' }"
  14. :inactiveStyle="{ color: '#666' }" lineColor="#1c9bfd" lineWidth="40" :itemStyle="{ height: '88rpx', flex: 1 }"
  15. :scrollable="false"></uv-tabs>
  16. </view>
  17. </view>
  18. <!-- 列表区域 -->
  19. <view class="list-container">
  20. <scroll-view scroll-y class="scroll-list" :scroll-top="scrollTopValue" scroll-with-animation refresher-enabled
  21. :refresher-triggered="isTriggered" @refresherrefresh="onRefresh" @scroll="onScroll" @scrolltolower="loadMore"
  22. :show-scrollbar="false">
  23. <uv-empty v-if="!list.length && loadStatus !== 'loading'" mode="list"></uv-empty>
  24. <view
  25. class="common-list-card animate-fade-in"
  26. v-for="(item, index) in list"
  27. :key="item.id"
  28. :style="{ animationDelay: `${(index % 10) * 0.05}s` }"
  29. @click="toDetail(item.id, item.status)"
  30. >
  31. <view class="card-header">
  32. <text class="title">编号:{{ item.expenseNo || '-' }}</text>
  33. <text class="status-tag" :class="{
  34. 'status-undo': item.status === '05',
  35. 'status-ongoing': item.status === '10',
  36. 'status-done': item.status === '20',
  37. 'status-reject': item.status === '30'
  38. }">
  39. <template v-if="item.status === '05'">待审核</template>
  40. <template v-if="item.status === '10'">审核中</template>
  41. <template v-else-if="item.status === '20'">已通过</template>
  42. <template v-else-if="item.status === '30'">已拒绝</template>
  43. </text>
  44. </view>
  45. <view class="card-body">
  46. <view class="info-item">
  47. <text class="label">项目名称:</text>
  48. <text class="value text-ellipsis">{{ item.projectName || '-' }}</text>
  49. </view>
  50. <view class="info-item">
  51. <text class="label">支出金额(元):</text>
  52. <text class="value number-font">{{ item.amount !== null ? formatInteger(item.amount) : '-' }}</text>
  53. </view>
  54. <view class="info-item">
  55. <text class="label">经办人:</text>
  56. <text class="value">{{ item.handle || '-' }}</text>
  57. </view>
  58. <view class="info-item" v-if="item.createdTime">
  59. <text class="label">创建时间:</text>
  60. <text class="value">{{ formatDate(new Date(item.createdTime), 'YYYY-MM-DD') }}</text>
  61. </view>
  62. </view>
  63. </view>
  64. <uv-load-more v-if="list.length > 0 || loadStatus === 'loading'" :status="loadStatus"
  65. @loadmore="loadMore"></uv-load-more>
  66. <!-- 底部安全距离,防止被 Tabbar 遮挡 -->
  67. <!-- <view class="safe-bottom-space"></view> -->
  68. </scroll-view>
  69. <!-- <FundTabbar :current="1" /> -->
  70. <uv-back-top :scrollTop="currentScrollTop" :bottom="160" :right="30" @click="backToTop"></uv-back-top>
  71. </view>
  72. </view>
  73. </template>
  74. <script setup lang="ts">
  75. import { ref, nextTick, watch } from 'vue';
  76. import { onLoad } from '@dcloudio/uni-app';
  77. import { debounce } from 'lodash-es';
  78. import { useRebateApi } from '@/api/fund/index';
  79. import { onRouterPush } from '@/utils/router';
  80. import { formatDate } from '@/utils/date';
  81. import { DEFAULT_PAGE_SIZE } from '@/constants';
  82. import FundTabbar from '@/components/FundTabbar.vue';
  83. const rebateApi = useRebateApi();
  84. // const tabList = ref([
  85. // { name: '待审核', type: '05' },
  86. // { name: '审核中', type: '10' },
  87. // { name: '已通过', type: '20' },
  88. // { name: '已拒绝', type: '30' }
  89. // ]);
  90. const currentTab = ref(0);
  91. const queryParams = ref({
  92. status: '',
  93. projectName: '',
  94. expenseNo: '',
  95. pageNum: 1,
  96. pageSize: DEFAULT_PAGE_SIZE
  97. });
  98. const list = ref<any[]>([]);
  99. const loadStatus = ref<'loadmore' | 'loading' | 'nomore'>('loadmore');
  100. const isTriggered = ref(false);
  101. const scrollTopValue = ref(0);
  102. const currentScrollTop = ref(0);
  103. // Helper function to format integer amount
  104. const formatInteger = (val: any) => {
  105. if (val === null || val === undefined) return '0';
  106. const num = Number(val);
  107. return isNaN(num) ? '0' : Math.floor(num).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',');
  108. };
  109. const fetchListData = async (reset = false) => {
  110. if (reset) {
  111. queryParams.value.pageNum = 1;
  112. }
  113. loadStatus.value = 'loading';
  114. try {
  115. const res: any = await rebateApi.getList(queryParams.value);
  116. if (res.code == 200) {
  117. const records = res.data?.list || res.list || [];
  118. if (reset) {
  119. list.value = records;
  120. } else {
  121. list.value = [...list.value, ...records];
  122. }
  123. if (records.length < queryParams.value.pageSize) {
  124. loadStatus.value = 'nomore';
  125. } else {
  126. loadStatus.value = 'loadmore';
  127. queryParams.value.pageNum += 1;
  128. }
  129. } else {
  130. loadStatus.value = 'nomore';
  131. }
  132. } catch (error) {
  133. console.error('Fetch error:', error);
  134. loadStatus.value = 'nomore';
  135. } finally {
  136. if (reset) {
  137. isTriggered.value = false;
  138. }
  139. }
  140. };
  141. const onSearch = () => {
  142. fetchListData(true);
  143. };
  144. const debouncedSearch = debounce(() => {
  145. fetchListData(true);
  146. }, 500);
  147. watch(() => queryParams.value.expenseNo, () => {
  148. debouncedSearch();
  149. });
  150. const onTabChange = (e: any) => {
  151. currentTab.value = e.index;
  152. queryParams.value.status = tabList.value[e.index].type;
  153. fetchListData(true);
  154. };
  155. const onRefresh = async () => {
  156. isTriggered.value = true;
  157. await fetchListData(true);
  158. };
  159. const loadMore = () => {
  160. if (loadStatus.value !== 'loadmore') return;
  161. fetchListData(false);
  162. };
  163. const onScroll = (e: any) => {
  164. currentScrollTop.value = e.detail.scrollTop;
  165. };
  166. const backToTop = () => {
  167. scrollTopValue.value = currentScrollTop.value;
  168. nextTick(() => {
  169. scrollTopValue.value = 0;
  170. });
  171. };
  172. const toDetail = (id: number, status: string | number) => {
  173. onRouterPush(`/pages/fund/reimbursement/detail?id=${id}`);
  174. };
  175. onLoad(() => {
  176. fetchListData(true);
  177. });
  178. </script>
  179. <style lang="scss" scoped>
  180. .list-page-container {
  181. height: calc(100vh - var(--window-top));
  182. display: flex;
  183. flex-direction: column;
  184. background-color: #f5f7fa;
  185. box-sizing: border-box;
  186. }
  187. .sticky-header {
  188. position: sticky;
  189. top: 0;
  190. z-index: 99;
  191. background-color: #fff;
  192. box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.03);
  193. }
  194. .search-header {
  195. padding: 20rpx 30rpx 10rpx;
  196. }
  197. .type-tabs {
  198. background-color: #fff;
  199. padding-bottom: 10rpx;
  200. }
  201. .list-container {
  202. padding: 30rpx;
  203. flex: 1;
  204. overflow: hidden;
  205. box-sizing: border-box;
  206. }
  207. .scroll-list {
  208. flex: 1;
  209. height: 100%;
  210. }
  211. .common-list-card {
  212. .card-header {
  213. // 样式已统一至 business.scss
  214. }
  215. .card-body {
  216. .info-item {
  217. display: flex;
  218. font-size: 28rpx;
  219. margin-bottom: 12rpx;
  220. line-height: 1.5;
  221. &:last-child {
  222. margin-bottom: 0;
  223. }
  224. .label {
  225. color: #666;
  226. width: 200rpx;
  227. flex-shrink: 0;
  228. }
  229. .value {
  230. color: #333;
  231. flex: 1;
  232. word-break: break-all;
  233. }
  234. }
  235. }
  236. }
  237. .number-font {
  238. font-family: 'Helvetica Neue', Arial, sans-serif;
  239. color: #1c9bfd !important;
  240. font-weight: 500;
  241. }
  242. .text-ellipsis {
  243. overflow: hidden;
  244. white-space: nowrap;
  245. text-overflow: ellipsis;
  246. }
  247. .safe-bottom-space {
  248. height: calc(80rpx + env(safe-area-inset-bottom));
  249. width: 100%;
  250. }
  251. </style>