history.vue 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <template>
  2. <div class="history-page">
  3. <h3>填写记录</h3>
  4. <van-list
  5. class="history-list"
  6. v-model:loading="loading"
  7. :finished="finished"
  8. @load="onLoad"
  9. finished-text="我们是有底线的"
  10. >
  11. <van-cell
  12. class="item"
  13. v-for="item in list"
  14. :key="item.detailId"
  15. :title="item.invoiceName"
  16. is-link
  17. :to="{ name: 'invoice.fill', query: { invoiceId, personId: item.personId } }"
  18. >
  19. <template #value>
  20. <span class="pname">{{ item.createDate.substr(0, 10) }}</span>
  21. </template>
  22. </van-cell>
  23. </van-list>
  24. </div>
  25. </template>
  26. <script setup>
  27. import { computed, onMounted, reactive, ref } from "vue"
  28. import { useRouter, useRoute } from 'vue-router'
  29. import { getList } from "@/services/invoice";
  30. import { useModel } from "@zjxpcyc/vue-tiny-store";
  31. const { user } = useModel('user')
  32. const router = useRouter();
  33. const route = useRoute();
  34. const { invoiceId } = route.query;
  35. const list = ref([])
  36. const error = ref(false);
  37. const loading = ref(false);
  38. const pagenavi = reactive({ pageNum: 1, pageSize: 10, total: 0 })
  39. const finished = computed(() => pagenavi.pageNum * pagenavi.pageSize > pagenavi.total)
  40. const queryData = (params = {}) => {
  41. console.log('-------------', user.personId)
  42. getList(invoiceId, { ...params, personId: user.personId }).then(res => {
  43. const { records, ...pageInfo } = res;
  44. if (pageInfo.current === 1) {
  45. list.value = records || []
  46. } else {
  47. list.value = list.value.concat(records || [])
  48. }
  49. pagenavi.pageNum = pageInfo.current
  50. pagenavi.total = pageInfo.total
  51. error.value = false
  52. loading.value = false
  53. }).catch(() => {
  54. error.value = true
  55. loading.value = false
  56. })
  57. }
  58. const onLoad = () => {
  59. const params = { pageNum: pagenavi.pageNum + 1, pageSize: pagenavi.pageSize }
  60. queryData(params)
  61. }
  62. onMounted(() => {
  63. //获取提交记录
  64. const params = { pageNum: pagenavi.pageNum, pageSize: pagenavi.pageSize }
  65. queryData(params)
  66. })
  67. </script>
  68. <style lang="less" scoped>
  69. .history-page {
  70. height: 100%;
  71. display: flex;
  72. flex-direction: column;
  73. h3 {
  74. flex: none;
  75. text-align: center;
  76. letter-spacing: 2px;
  77. }
  78. .history-list {
  79. flex: 1;
  80. }
  81. .pname {
  82. color: #333;
  83. }
  84. // .item + .item {
  85. // margin-top: 16px;
  86. // }
  87. }
  88. </style>