index.vue 8.1 KB

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