index.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. <template>
  2. <div style="padding-bottom: 60px">
  3. <van-nav-bar
  4. :title="$t('plan.name')"
  5. left-text=""
  6. left-arrow
  7. @click-left="onClickLeft"
  8. @click-right="onClickRight"
  9. >
  10. <template #right> {{ $t("common.add") }} </template>
  11. </van-nav-bar>
  12. <van-search
  13. v-model="req.keyword"
  14. :placeholder="$t('common.pleaseEnterKeywords')"
  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="$t('common.noMore')"
  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: "code",
  53. },
  54. {
  55. label: proxy.t("plan.planTime"),
  56. prop: "time",
  57. },
  58. {
  59. label: proxy.t("plan.productName"),
  60. prop: "productName",
  61. },
  62. {
  63. label: proxy.t("plan.planQuantity"),
  64. prop: "quantity",
  65. },
  66. {
  67. label: proxy.t("plan.planStatus"),
  68. prop: "statusName",
  69. },
  70. ]);
  71. const onRefresh = () => {
  72. req.value.pageNum = 1;
  73. finished.value = false;
  74. getList("refresh");
  75. };
  76. const onLoad = () => {
  77. getList();
  78. };
  79. const onClickLeft = () => proxy.$router.push("/main/working");
  80. const onClickRight = () => {
  81. proxy.$router.push("/main/planAdd");
  82. };
  83. proxy.uploadDdRightBtn(onClickRight, proxy.t("common.add"));
  84. const toDtl = (row) => {
  85. proxy.$router.push({
  86. path: "planDtl",
  87. query: {
  88. id: row.id,
  89. },
  90. });
  91. };
  92. const getList = (type) => {
  93. loading.value = true;
  94. proxy
  95. .post("/productionPlan/page", req.value)
  96. .then((res) => {
  97. const data = res.data.rows.map((x) => ({
  98. ...x,
  99. time: x.startDate + " ~ " + x.stopDate,
  100. statusName:
  101. x.status == 0
  102. ? proxy.t("plan.notStarted")
  103. : x.status == 1
  104. ? proxy.t("plan.ongoing")
  105. : x.status == 2
  106. ? proxy.t("plan.complete")
  107. : "",
  108. }));
  109. if (type === "refresh") {
  110. listData.value = data;
  111. } else {
  112. listData.value = listData.value.concat(data);
  113. }
  114. // listData.value =
  115. // type === "refresh"
  116. // ? res.data.rows
  117. // : listData.value.concat(res.data.rows);
  118. if (req.value.pageNum * 10 >= res.data.total) {
  119. finished.value = true;
  120. }
  121. req.value.pageNum++;
  122. loading.value = false;
  123. })
  124. .catch((err) => {
  125. loading.value = false;
  126. });
  127. };
  128. getList();
  129. </script>
  130. <style lang="scss" scoped>
  131. .list {
  132. min-height: 70vh;
  133. }
  134. </style>