index.vue 7.3 KB

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