index.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <template>
  2. <van-nav-bar :title="$t('contract.name')" left-text="" left-arrow @click-left="onClickLeft" @click-right="onClickRight">
  3. <template #right>{{ $t("common.add") }}</template>
  4. </van-nav-bar>
  5. <van-search v-model="req.keyword" :placeholder="$t('common.pleaseEnterKeywords')" @search="onRefresh" />
  6. <van-pull-refresh v-model="loading" @refresh="onRefresh">
  7. <div class="list">
  8. <van-list v-model:loading="loading" :finished="finished" :finished-text="$t('common.noMore')" @load="getList" style="margin-bottom: 60px">
  9. <commonList :data="listData" @onClick="toDtl" :config="listConfig"></commonList>
  10. </van-list>
  11. </div>
  12. </van-pull-refresh>
  13. </template>
  14. <script setup>
  15. import { ref, getCurrentInstance } from "vue";
  16. import commonList from "@/components/common-list.vue";
  17. const proxy = getCurrentInstance().proxy;
  18. const onClickLeft = () => proxy.$router.push("/main/working");
  19. const onClickRight = () => {
  20. proxy.$router.push({
  21. path: "/main/processDtl",
  22. query: {
  23. flowKey: "contract_flow",
  24. },
  25. });
  26. };
  27. const req = ref({
  28. pageNum: 1,
  29. keyword: null,
  30. });
  31. const finished = ref(false);
  32. const onRefresh = () => {
  33. req.value.pageNum = 1;
  34. finished.value = false;
  35. getList("refresh");
  36. };
  37. const loading = ref(false);
  38. const listData = ref([]);
  39. const getList = (type) => {
  40. loading.value = true;
  41. proxy
  42. .post("/contract/page", req.value)
  43. .then((res) => {
  44. if (res.data.rows && res.data.rows.length > 0) {
  45. res.data.rows = res.data.rows.map((item) => {
  46. return {
  47. ...item,
  48. currencyAmount: item.currency + " " + item.amount,
  49. };
  50. });
  51. }
  52. listData.value = type === "refresh" ? res.data.rows : listData.value.concat(res.data.rows);
  53. if (req.value.pageNum * 10 >= res.data.total) {
  54. finished.value = true;
  55. }
  56. req.value.pageNum++;
  57. loading.value = false;
  58. })
  59. .catch(() => {
  60. loading.value = false;
  61. });
  62. };
  63. const toDtl = (row) => {
  64. // proxy.$router.push({
  65. // path: "/main/processDtl",
  66. // query: {
  67. // flowKey: "account_request_funds_flow",
  68. // id: row.flowInfoId,
  69. // processType: 20,
  70. // },
  71. // });
  72. };
  73. const listConfig = ref([
  74. {
  75. label: proxy.t("contract.sellCorporation"),
  76. prop: "sellCorporationName",
  77. },
  78. {
  79. label: proxy.t("contract.contractType"),
  80. prop: "contractTypeVal",
  81. },
  82. {
  83. label: proxy.t("contract.code"),
  84. prop: "code",
  85. },
  86. {
  87. label: proxy.t("contract.buyCorporation"),
  88. prop: "buyCorporationName",
  89. },
  90. {
  91. label: proxy.t("contract.amount"),
  92. prop: "currencyAmount",
  93. },
  94. ]);
  95. </script>
  96. <style lang="scss" scoped>
  97. .list {
  98. min-height: 70vh;
  99. }
  100. </style>