index.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. <template>
  2. <div style="padding-bottom: 60px">
  3. <van-nav-bar :title="'生产报工'" left-text="" left-arrow @click-left="onClickLeft" @click-right="handleScanCode">
  4. <!-- <template #right> 扫码 </template> -->
  5. </van-nav-bar>
  6. <!-- <van-search v-model="req.keyword" :placeholder="$t('common.pleaseEnterKeywords')" @search="onRefresh" />
  7. <van-pull-refresh v-model="loading" @refresh="onRefresh">
  8. <div class="list">
  9. <van-list v-model:loading="loading" :finished="finished" :finished-text="$t('common.noMore')" @load="onLoad" style="margin-bottom: 60px">
  10. <commonList :data="listData" :config="listConfig" :showMore="false"></commonList>
  11. </van-list>
  12. </div>
  13. </van-pull-refresh> -->
  14. <div style="padding:20px">
  15. <van-button type="success" style="width:100%;height:200px;font-size:36px" @click="handleScanCode">扫码</van-button>
  16. </div>
  17. </div>
  18. </template>
  19. <script setup>
  20. import { ref, getCurrentInstance, onMounted, nextTick } from "vue";
  21. import commonList from "@/components/common-list.vue";
  22. import { useRoute } from "vue-router";
  23. const loading = ref(false);
  24. const router = useRoute();
  25. const req = ref({
  26. pageNum: 1,
  27. keyword: null,
  28. });
  29. const finished = ref(false);
  30. const proxy = getCurrentInstance().proxy;
  31. const listData = ref([]);
  32. const listConfig = ref([
  33. {
  34. label: proxy.t("task.taskCode"),
  35. prop: "code",
  36. },
  37. {
  38. label: proxy.t("task.taskCode"),
  39. prop: "productName",
  40. },
  41. {
  42. label: proxy.t("task.productName"),
  43. prop: "quantity",
  44. },
  45. {
  46. label: proxy.t("task.taskQuantity"),
  47. prop: "dueDate",
  48. },
  49. {
  50. label: proxy.t("task.principal"),
  51. prop: "personLiableName",
  52. },
  53. ]);
  54. const onRefresh = () => {
  55. req.value.pageNum = 1;
  56. finished.value = false;
  57. getList("refresh");
  58. };
  59. const onLoad = () => {
  60. // getList();
  61. };
  62. const onClickLeft = () => proxy.$router.push("/main/working");
  63. const onClickRight = () => {
  64. proxy.$router.push("/main/taskAdd");
  65. };
  66. proxy.uploadDdRightBtn(onClickRight, proxy.t("common.add"));
  67. // const toDtl = (row) => {
  68. // proxy.$router.push({
  69. // path: "taskDtl",
  70. // query: {
  71. // id: row.id,
  72. // },
  73. // });
  74. // };
  75. const getList = (type) => {
  76. loading.value = true;
  77. proxy
  78. .post("/productionTask/page", req.value)
  79. .then((res) => {
  80. // const data = res.data.rows.map((x) => ({
  81. // ...x,
  82. // time: x.startDate + " ~ " + x.stopDate,
  83. // statusName:
  84. // x.status == 0
  85. // ? "未开始"
  86. // : x.status == 1
  87. // ? "进行中"
  88. // : x.status == 2
  89. // ? "完成"
  90. // : "",
  91. // }));
  92. // if (type === "refresh") {
  93. // listData.value = data;
  94. // } else {
  95. // listData.value = listData.value.concat(data);
  96. // }
  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 handleScanCode = () => {
  113. // proxy.$router.push({
  114. // path: "/main/productionReportAdd",
  115. // query: {
  116. // id: "contract_flow",
  117. // },
  118. // });
  119. uni.postMessage({
  120. data: {
  121. type: "scanCode",
  122. },
  123. });
  124. };
  125. // const showScanData = (val) => {
  126. // proxy.post("/productionTaskDetail/snInfo", { productSn: val }).then((res) => {
  127. // if (res.data && res.data.productId) {
  128. // formData.data.productId = res.data.productId;
  129. // formData.data.productSn = res.data.productSn;
  130. // formData.data.code = res.data.contractCode;
  131. // formData.data.productName = res.data.productName;
  132. // formData.data.productSpec = res.data.productSpec;
  133. // formData.data.customerName = res.data.customerName;
  134. // }
  135. // });
  136. // };
  137. // onMounted(() => {
  138. // nextTick(() => {
  139. // window.getVueMessage = (data) => {
  140. // if (data) {
  141. // showScanData(data);
  142. // }
  143. // };
  144. // });
  145. // });
  146. </script>
  147. <style lang="scss" scoped>
  148. .list {
  149. min-height: 70vh;
  150. }
  151. </style>