| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297 |
- <template>
- <view class="list-page-container">
- <view class="sticky-header">
- <view class="search-header">
- <view class="search-row">
- <uv-input placeholder="请输入单据编号" v-model="queryParams.expenseNo" prefixIcon="search"
- prefixIconStyle="color: #999; font-size: 32rpx;" clearable shape="circle"
- customStyle="background-color: #f5f7fa; border: none;" @confirm="onSearch"></uv-input>
- </view>
- </view>
- <view class="type-tabs">
- <uv-tabs :list="tabList" :current="currentTab" @change="onTabChange"
- :activeStyle="{ color: '#1c9bfd', fontWeight: 'bold', transform: 'scale(1.05)' }"
- :inactiveStyle="{ color: '#666' }" lineColor="#1c9bfd" lineWidth="40" :itemStyle="{ height: '88rpx', flex: 1 }"
- :scrollable="false"></uv-tabs>
- </view>
- </view>
- <!-- 列表区域 -->
- <view class="list-container">
- <scroll-view scroll-y class="scroll-list" :scroll-top="scrollTopValue" scroll-with-animation refresher-enabled
- :refresher-triggered="isTriggered" @refresherrefresh="onRefresh" @scroll="onScroll" @scrolltolower="loadMore"
- :show-scrollbar="false">
- <uv-empty v-if="!list.length && loadStatus !== 'loading'" mode="list"></uv-empty>
- <view class="common-list-card" v-for="item in list" :key="item.id" @click="toDetail(item.id, item.status)">
- <view class="card-header">
- <text class="title">编号:{{ item.expenseNo || '-' }}</text>
- <text class="status-tag" :class="{
- 'status-undo': item.status === '10',
- 'status-done': item.status === '20',
- 'status-reject': item.status === '30'
- }">
- <template v-if="item.status === '10'">待审核</template>
- <template v-else-if="item.status === '20'">已审核</template>
- <template v-else-if="item.status === '30'">已拒绝</template>
- </text>
- </view>
- <view class="card-body">
- <view class="info-item">
- <text class="label">项目名称:</text>
- <text class="value text-ellipsis">{{ item.projectName || '-' }}</text>
- </view>
- <view class="info-item">
- <text class="label">支出金额(元):</text>
- <text class="value number-font">{{ item.amount !== null ? formatInteger(item.amount) : '-' }}</text>
- </view>
- <view class="info-item">
- <text class="label">经办人:</text>
- <text class="value">{{ item.handle || '-' }}</text>
- </view>
- <view class="info-item" v-if="item.createdTime">
- <text class="label">创建时间:</text>
- <text class="value">{{ formatDate(new Date(item.createdTime), 'YYYY-MM-DD') }}</text>
- </view>
- </view>
- </view>
- <uv-load-more v-if="list.length > 0 || loadStatus === 'loading'" :status="loadStatus"
- @loadmore="loadMore"></uv-load-more>
-
- <!-- 底部安全距离,防止被 Tabbar 遮挡 -->
- <!-- <view class="safe-bottom-space"></view> -->
- </scroll-view>
- <!-- <FundTabbar :current="1" /> -->
- <uv-back-top :scrollTop="currentScrollTop" :bottom="160" :right="30" @click="backToTop"></uv-back-top>
- </view>
- </view>
- </template>
- <script setup lang="ts">
- import { ref, nextTick, watch } from 'vue';
- import { onLoad } from '@dcloudio/uni-app';
- import { debounce } from 'lodash-es';
- import { useRebateApi } from '@/api/fund/index';
- import { onRouterPush } from '@/utils/router';
- import { formatDate } from '@/utils/date';
- import { DEFAULT_PAGE_SIZE } from '@/constants';
- import FundTabbar from '@/components/FundTabbar.vue';
- const rebateApi = useRebateApi();
- const tabList = ref([
- { name: '待审核', type: '10' },
- { name: '已通过', type: '20' },
- { name: '已拒绝', type: '30' }
- ]);
- const currentTab = ref(0);
- const queryParams = ref({
- status: '10',
- projectName: '',
- expenseNo: '',
- pageNum: 1,
- pageSize: DEFAULT_PAGE_SIZE
- });
- const list = ref<any[]>([]);
- const loadStatus = ref<'loadmore' | 'loading' | 'nomore'>('loadmore');
- const isTriggered = ref(false);
- const scrollTopValue = ref(0);
- const currentScrollTop = ref(0);
- // Helper function to format integer amount
- const formatInteger = (val: any) => {
- if (val === null || val === undefined) return '0';
- const num = Number(val);
- return isNaN(num) ? '0' : Math.floor(num).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',');
- };
- const fetchListData = async (reset = false) => {
- if (reset) {
- queryParams.value.pageNum = 1;
- }
- loadStatus.value = 'loading';
- try {
- const res: any = await rebateApi.getList(queryParams.value);
- if (res.code == 200) {
- const records = res.data?.list || res.list || [];
- if (reset) {
- list.value = records;
- } else {
- list.value = [...list.value, ...records];
- }
- if (records.length < queryParams.value.pageSize) {
- loadStatus.value = 'nomore';
- } else {
- loadStatus.value = 'loadmore';
- queryParams.value.pageNum += 1;
- }
- } else {
- loadStatus.value = 'nomore';
- }
- } catch (error) {
- console.error('Fetch error:', error);
- loadStatus.value = 'nomore';
- } finally {
- if (reset) {
- isTriggered.value = false;
- }
- }
- };
- const onSearch = () => {
- fetchListData(true);
- };
- const debouncedSearch = debounce(() => {
- fetchListData(true);
- }, 500);
- watch(() => queryParams.value.expenseNo, () => {
- debouncedSearch();
- });
- const onTabChange = (e: any) => {
- currentTab.value = e.index;
- queryParams.value.status = tabList.value[e.index].type;
- fetchListData(true);
- };
- const onRefresh = async () => {
- isTriggered.value = true;
- await fetchListData(true);
- };
- const loadMore = () => {
- if (loadStatus.value !== 'loadmore') return;
- fetchListData(false);
- };
- const onScroll = (e: any) => {
- currentScrollTop.value = e.detail.scrollTop;
- };
- const backToTop = () => {
- scrollTopValue.value = currentScrollTop.value;
- nextTick(() => {
- scrollTopValue.value = 0;
- });
- };
- const toDetail = (id: number, status: string | number) => {
- onRouterPush(`/pages/fund/reimbursement/detail?id=${id}`);
- };
- onLoad(() => {
- fetchListData(true);
- });
- </script>
- <style lang="scss" scoped>
- .list-page-container {
- height: calc(100vh - var(--window-top));
- display: flex;
- flex-direction: column;
- background-color: #f5f7fa;
- box-sizing: border-box;
- }
- .sticky-header {
- position: sticky;
- top: 0;
- z-index: 99;
- background-color: #fff;
- box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.03);
- }
- .search-header {
- padding: 20rpx 30rpx 10rpx;
- }
- .type-tabs {
- background-color: #fff;
- padding-bottom: 10rpx;
- }
- .list-container {
- padding: 30rpx;
- flex: 1;
- overflow: hidden;
- box-sizing: border-box;
- }
- .scroll-list {
- flex: 1;
- height: 100%;
- }
- .common-list-card {
- .card-header {
- .status-tag {
- &.status-done {
- color: #52c41a;
- background-color: rgba(82, 196, 26, 0.1);
- }
- &.status-undo {
- color: #fa8c16;
- background-color: rgba(250, 173, 20, 0.1);
- }
- &.status-reject {
- color: #f5222d;
- background-color: rgba(245, 34, 45, 0.1);
- }
- }
- }
- .card-body {
- .info-item {
- display: flex;
- font-size: 28rpx;
- margin-bottom: 12rpx;
- line-height: 1.5;
- &:last-child {
- margin-bottom: 0;
- }
- .label {
- color: #666;
- width: 200rpx;
- flex-shrink: 0;
- }
- .value {
- color: #333;
- flex: 1;
- word-break: break-all;
- }
- }
- }
- }
- .number-font {
- font-family: 'Helvetica Neue', Arial, sans-serif;
- color: #1c9bfd !important;
- font-weight: 500;
- }
- .text-ellipsis {
- overflow: hidden;
- white-space: nowrap;
- text-overflow: ellipsis;
- }
- .safe-bottom-space {
- height: calc(80rpx + env(safe-area-inset-bottom));
- width: 100%;
- }
- </style>
|