index.vue 7.1 KB

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