index.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <template>
  2. <van-nav-bar
  3. :title="$t('forward.name')"
  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="$t('common.pleaseEnterKeywords')"
  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="$t('common.noMore')"
  22. @load="onLoad"
  23. style="margin-bottom: 60px"
  24. >
  25. <commonList
  26. :data="listData"
  27. :config="listConfig"
  28. :showMore="true"
  29. @onClick="toDtl"
  30. ></commonList>
  31. </van-list>
  32. </div>
  33. </van-pull-refresh>
  34. </template>
  35. <script setup>
  36. import { ref, getCurrentInstance, onMounted } from "vue";
  37. import commonList from "@/components/common-list.vue";
  38. import { useRoute } from "vue-router";
  39. const loading = ref(false);
  40. const router = useRoute();
  41. const req = ref({
  42. pageNum: 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: proxy.t("forward.productName"),
  51. prop: "productName",
  52. },
  53. {
  54. label: proxy.t("forward.productSN"),
  55. prop: "productSn",
  56. },
  57. {
  58. label: proxy.t("forward.currentProcess"),
  59. prop: "productionProcessesName",
  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("jxskForwardAdd");
  73. // };
  74. const toDtl = (row) => {
  75. let type = "";
  76. if (
  77. row.nextProductionProcessesId == "" ||
  78. row.nextProductionProcessesId == "-1"
  79. ) {
  80. type = "20";
  81. } else {
  82. type = "10";
  83. }
  84. proxy.$router.push({
  85. path: "jxskForwardAdd",
  86. query: {
  87. ...row,
  88. type: type,
  89. },
  90. });
  91. };
  92. const getList = (type) => {
  93. loading.value = true;
  94. proxy
  95. .post("/productionTaskDetail/circulationPage", req.value)
  96. .then((res) => {
  97. listData.value =
  98. type === "refresh"
  99. ? res.data.rows
  100. : listData.value.concat(res.data.rows);
  101. if (req.value.pageNum * 10 >= res.data.total) {
  102. finished.value = true;
  103. }
  104. req.value.pageNum++;
  105. loading.value = false;
  106. })
  107. .catch((err) => {
  108. loading.value = false;
  109. });
  110. };
  111. getList();
  112. const onClickRight = () => {
  113. // 允许从相机和相册扫码
  114. uni.scanCode({
  115. success: function (res) {
  116. console.log("条码类型:" + res.scanType);
  117. console.log("条码内容:" + res.result);
  118. uni.showToast({
  119. title: res.result,
  120. duration: 2000,
  121. });
  122. },
  123. });
  124. };
  125. </script>
  126. <style lang="scss" scoped>
  127. .list {
  128. min-height: 70vh;
  129. }
  130. </style>