index.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <template>
  2. <div style="padding-bottom: 60px">
  3. <van-nav-bar
  4. title="完工入库"
  5. left-text=""
  6. left-arrow
  7. @click-left="onClickLeft"
  8. @click-right="onClickRight"
  9. >
  10. <template #right> 添加 </template>
  11. </van-nav-bar>
  12. <van-search
  13. v-model="req.keyword"
  14. placeholder="请输入搜索关键词"
  15. @search="onRefresh"
  16. />
  17. <van-pull-refresh v-model="loading" @refresh="onRefresh">
  18. <div class="list">
  19. <van-list
  20. v-model:loading="loading"
  21. :finished="finished"
  22. finished-text="没有更多了"
  23. @load="onLoad"
  24. style="margin-bottom: 60px"
  25. >
  26. <commonList
  27. :data="listData"
  28. @onClick="toDtl"
  29. :config="listConfig"
  30. ></commonList>
  31. </van-list>
  32. </div>
  33. </van-pull-refresh>
  34. </div>
  35. </template>
  36. <script setup>
  37. import { ref, getCurrentInstance, onMounted } from "vue";
  38. import commonList from "@/components/common-list.vue";
  39. import { useRoute } from "vue-router";
  40. const loading = ref(false);
  41. const router = useRoute();
  42. const req = ref({
  43. pageNum: 1,
  44. keyword: null,
  45. });
  46. const finished = ref(false);
  47. const proxy = getCurrentInstance().proxy;
  48. const listData = ref([]);
  49. const listConfig = ref([
  50. {
  51. label: "生产任务",
  52. prop: "productionTaskCode",
  53. },
  54. {
  55. label: "产品名称",
  56. prop: "productName",
  57. },
  58. {
  59. label: "完工数量",
  60. prop: "quantity",
  61. },
  62. ]);
  63. const onRefresh = () => {
  64. req.value.pageNum = 1;
  65. finished.value = false;
  66. getList("refresh");
  67. };
  68. const onLoad = () => {
  69. getList();
  70. };
  71. const onClickLeft = () => proxy.$router.push("/main/working");
  72. const onClickRight = () => {
  73. proxy.$router.push("/main/completeProjectAdd");
  74. };
  75. proxy.uploadDdRightBtn(onClickRight,'添加')
  76. const toDtl = (row) => {
  77. proxy.$router.push({
  78. path: "completeProjectAdd",
  79. query: {
  80. id: row.id,
  81. },
  82. });
  83. };
  84. const getList = (type) => {
  85. loading.value = true;
  86. proxy
  87. .post("/completionInfo/page", req.value)
  88. .then((res) => {
  89. // const data = res.data.rows.map((x) => ({
  90. // ...x,
  91. // time: x.startDate + " ~ " + x.stopDate,
  92. // statusName:
  93. // x.status == 0
  94. // ? "未开始"
  95. // : x.status == 1
  96. // ? "进行中"
  97. // : x.status == 2
  98. // ? "完成"
  99. // : "",
  100. // }));
  101. // if (type === "refresh") {
  102. // listData.value = data;
  103. // } else {
  104. // listData.value = listData.value.concat(data);
  105. // }
  106. listData.value =
  107. type === "refresh"
  108. ? res.data.rows
  109. : listData.value.concat(res.data.rows);
  110. if (req.value.pageNum * 10 >= res.data.total) {
  111. finished.value = true;
  112. }
  113. req.value.pageNum++;
  114. loading.value = false;
  115. })
  116. .catch((err) => {
  117. loading.value = false;
  118. });
  119. };
  120. getList();
  121. </script>
  122. <style lang="scss" scoped>
  123. .list {
  124. min-height: 70vh;
  125. }
  126. </style>