index.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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: "createTime",
  56. },
  57. {
  58. label: "操作人",
  59. prop: "operatorName",
  60. },
  61. ]);
  62. const onRefresh = () => {
  63. req.value.pageNum = 1;
  64. finished.value = false;
  65. getList("refresh");
  66. };
  67. const onLoad = () => {
  68. getList();
  69. };
  70. const onClickLeft = () => proxy.$router.push("/main/working");
  71. const onClickRight = () => {
  72. proxy.$router.push("/main/reportWorkAdd");
  73. };
  74. proxy.uploadDdRightBtn(onClickRight,'报工')
  75. const toDtl = (row) => {
  76. proxy.$router.push({
  77. path: "reportWorkAdd",
  78. query: {
  79. id: row.id,
  80. },
  81. });
  82. };
  83. const getList = (type) => {
  84. loading.value = true;
  85. proxy
  86. .post("/productionReporting/page", req.value)
  87. .then((res) => {
  88. console.log(req.value);
  89. listData.value =
  90. type === "refresh"
  91. ? res.data.rows
  92. : listData.value.concat(res.data.rows);
  93. if (req.value.pageNum * 10 >= res.data.total) {
  94. finished.value = true;
  95. }
  96. req.value.pageNum++;
  97. loading.value = false;
  98. })
  99. .catch((err) => {
  100. loading.value = false;
  101. });
  102. };
  103. getList();
  104. </script>
  105. <style lang="scss" scoped>
  106. .list {
  107. min-height: 70vh;
  108. }
  109. </style>