index.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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. type: "1",
  45. keyword: null,
  46. });
  47. const finished = ref(false);
  48. const proxy = getCurrentInstance().proxy;
  49. const listData = ref([]);
  50. const listConfig = ref([
  51. {
  52. label: "工单编号",
  53. prop: "code",
  54. },
  55. {
  56. label: "工单来源",
  57. prop: "source",
  58. },
  59. {
  60. label: "产品名称",
  61. prop: "productName",
  62. },
  63. {
  64. label: "工单数量",
  65. prop: "quantity",
  66. },
  67. {
  68. label: "工单状态",
  69. prop: "status",
  70. },
  71. ]);
  72. const onRefresh = () => {
  73. req.value.pageNum = 1;
  74. finished.value = false;
  75. getList("refresh");
  76. };
  77. const onLoad = () => {
  78. getList();
  79. };
  80. const onClickLeft = () => proxy.$router.push("/main/working");
  81. const onClickRight = () => {
  82. proxy.$router.push("/main/workOrderAdd");
  83. };
  84. const toDtl = (row) => {
  85. proxy.$router.push({
  86. path: "workOrderDtl",
  87. query: {
  88. id: row.id,
  89. },
  90. });
  91. };
  92. const getList = (type) => {
  93. loading.value = true;
  94. proxy
  95. .post("/workOrder/page", req.value)
  96. .then((res) => {
  97. console.log(req.value);
  98. listData.value =
  99. type === "refresh"
  100. ? res.data.rows
  101. : listData.value.concat(res.data.rows);
  102. if (req.value.pageNum * 10 >= res.data.total) {
  103. finished.value = true;
  104. }
  105. req.value.pageNum++;
  106. loading.value = false;
  107. })
  108. .catch((err) => {
  109. loading.value = false;
  110. });
  111. };
  112. getList();
  113. </script>
  114. <style lang="scss" scoped>
  115. .list {
  116. min-height: 70vh;
  117. }
  118. </style>