index.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <template>
  2. <van-nav-bar
  3. title="已采购"
  4. left-text=""
  5. left-arrow
  6. @click-left="onClickLeft"
  7. @click-right="onClickRight"
  8. >
  9. <template #right> 新增采购 </template>
  10. </van-nav-bar>
  11. <van-search
  12. v-model="req.keyword"
  13. placeholder="请输入关键词"
  14. @search="onRefresh"
  15. />
  16. <van-pull-refresh v-model="loading" @refresh="onRefresh">
  17. <div class="list">
  18. <van-list
  19. v-model:loading="loading"
  20. :finished="finished"
  21. finished-text="没有更多了"
  22. @load="onLoad"
  23. style="margin-bottom: 60px"
  24. >
  25. <commonList
  26. :data="listData"
  27. @onClick="toDtl"
  28. :config="listConfig"
  29. ></commonList>
  30. </van-list>
  31. </div>
  32. </van-pull-refresh>
  33. </template>
  34. <script setup>
  35. import { ref, getCurrentInstance, onMounted } from "vue";
  36. import commonList from "@/components/common-list.vue";
  37. import { useRoute } from "vue-router";
  38. const loading = ref(false);
  39. const router = useRoute();
  40. const req = ref({
  41. pageNum: 1,
  42. type: "1",
  43. keyword: null,
  44. });
  45. const finished = ref(false);
  46. const proxy = getCurrentInstance().proxy;
  47. const listData = ref([]);
  48. const listConfig = ref([
  49. {
  50. label: "申购单号",
  51. prop: "code",
  52. },
  53. {
  54. label: "供应商",
  55. prop: "supplyName",
  56. },
  57. {
  58. label: "采购金额",
  59. prop: "count",
  60. },
  61. {
  62. label: "采购状态",
  63. prop: "purchaseStatus",
  64. },
  65. ]);
  66. const onRefresh = () => {
  67. req.value.pageNum = 1;
  68. finished.value = false;
  69. getList("refresh");
  70. };
  71. const onLoad = () => {
  72. getList();
  73. };
  74. const onClickLeft = () => proxy.$router.push("/main/working");
  75. const onClickRight = () => {
  76. proxy.$router.push("/main/purchasedAdd");
  77. };
  78. proxy.uploadDdRightBtn(onClickRight,'新增采购')
  79. const toDtl = (row) => {
  80. proxy.$router.push({
  81. path: "purchasedAdd",
  82. query: {
  83. id: row.id,
  84. },
  85. });
  86. };
  87. const getList = (type) => {
  88. loading.value = true;
  89. proxy
  90. .post("/purchase/page", req.value)
  91. .then((res) => {
  92. console.log(req.value);
  93. res.data.rows.map((item) => {
  94. item.purchaseStatus =
  95. item.purchaseStatus === 0
  96. ? "草稿"
  97. : item.purchaseStatus === 10
  98. ? "审批中"
  99. : item.purchaseStatus === 20
  100. ? "驳回"
  101. : "通过";
  102. });
  103. listData.value =
  104. type === "refresh"
  105. ? res.data.rows
  106. : listData.value.concat(res.data.rows);
  107. if (req.value.pageNum * 10 >= res.data.total) {
  108. finished.value = true;
  109. }
  110. req.value.pageNum++;
  111. loading.value = false;
  112. })
  113. .catch((err) => {
  114. loading.value = false;
  115. });
  116. };
  117. getList();
  118. </script>
  119. <style lang="scss" scoped>
  120. .list {
  121. min-height: 70vh;
  122. }
  123. </style>