index.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  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-button @click="handleSend">发送</van-button> -->
  8. <van-pull-refresh v-model="loading" @refresh="onRefresh">
  9. <div class="list">
  10. <van-list v-model:loading="loading" :finished="finished" :finished-text="$t('common.noMore')" @load="onLoad" style="margin-bottom: 60px">
  11. <commonList :data="listData" :config="listConfig" :showMore="false">
  12. <template #btn="{ row }">
  13. <div style="width:100%;text-align:right">
  14. <van-button type="danger" size="small" style="margin-right:10px" @click="toDelete(row)">删除</van-button>
  15. </div>
  16. </template>
  17. </commonList>
  18. </van-list>
  19. </div>
  20. </van-pull-refresh>
  21. <!-- <div style="padding:20px">
  22. <van-button type="success" style="width:100%;height:200px;font-size:36px" @click="handleScanCode">扫码</van-button>
  23. </div> -->
  24. </div>
  25. </template>
  26. <script setup>
  27. import { ref, getCurrentInstance, onMounted, nextTick } from "vue";
  28. import commonList from "@/components/common-list.vue";
  29. import { useRoute } from "vue-router";
  30. import { showSuccessToast, showConfirmDialog } from "vant";
  31. const loading = ref(false);
  32. const route = useRoute();
  33. const req = ref({
  34. pageNum: 1,
  35. keyword: null,
  36. userId: "",
  37. dataDate: "",
  38. });
  39. const finished = ref(false);
  40. const proxy = getCurrentInstance().proxy;
  41. const listData = ref([]);
  42. const listConfig = ref([
  43. {
  44. label: "任务编号",
  45. prop: "orderCode",
  46. },
  47. {
  48. label: "报工数量",
  49. prop: "quantity",
  50. },
  51. {
  52. label: "单价",
  53. prop: "price",
  54. },
  55. {
  56. label: "小计",
  57. prop: "amount",
  58. },
  59. {
  60. label: "报工人",
  61. prop: "userName",
  62. },
  63. {
  64. label: "报工时间",
  65. prop: "createTime",
  66. },
  67. {
  68. label: "工序名称",
  69. prop: "processesName",
  70. },
  71. {
  72. label: "订单号",
  73. prop: "orderCode",
  74. },
  75. {
  76. label: "产品编码",
  77. prop: "productCode",
  78. },
  79. {
  80. label: "产品名称",
  81. prop: "productName",
  82. },
  83. {
  84. type: "slot",
  85. label: "",
  86. slotName: "btn",
  87. },
  88. ]);
  89. const onRefresh = () => {
  90. req.value.pageNum = 1;
  91. finished.value = false;
  92. getList("refresh");
  93. };
  94. if (route.query && route.query.userId) {
  95. req.value.userId = route.query.userId;
  96. req.value.dataDate = route.query.dataDate;
  97. }
  98. const onLoad = () => {
  99. getList();
  100. };
  101. const onClickLeft = () => history.back();
  102. const onClickRight = () => {
  103. proxy.$router.push("/main/taskAdd");
  104. };
  105. proxy.uploadDdRightBtn(onClickRight, proxy.t("common.add"));
  106. // const toDtl = (row) => {
  107. // proxy.$router.push({
  108. // path: "taskDtl",
  109. // query: {
  110. // id: row.id,
  111. // },
  112. // });
  113. // };
  114. const getList = (type) => {
  115. loading.value = true;
  116. proxy
  117. .post("/productionReporting/page", req.value)
  118. .then((res) => {
  119. // const data = res.data.rows.map((x) => ({
  120. // ...x,
  121. // time: x.startDate + " ~ " + x.stopDate,
  122. // statusName:
  123. // x.status == 0
  124. // ? "未开始"
  125. // : x.status == 1
  126. // ? "进行中"
  127. // : x.status == 2
  128. // ? "完成"
  129. // : "",
  130. // }));
  131. // if (type === "refresh") {
  132. // listData.value = data;
  133. // } else {
  134. // listData.value = listData.value.concat(data);
  135. // }
  136. listData.value =
  137. type === "refresh"
  138. ? res.data.rows
  139. : listData.value.concat(res.data.rows);
  140. if (req.value.pageNum * 10 >= res.data.total) {
  141. finished.value = true;
  142. }
  143. req.value.pageNum++;
  144. loading.value = false;
  145. })
  146. .catch((err) => {
  147. loading.value = false;
  148. });
  149. };
  150. getList();
  151. const handleScanCode = () => {
  152. // proxy.$router.push({
  153. // path: "/main/productionReportAdd",
  154. // query: {
  155. // id: "contract_flow",
  156. // },
  157. // });
  158. uni.postMessage({
  159. data: {
  160. type: "scanCode",
  161. },
  162. });
  163. };
  164. // const showScanData = (val) => {
  165. // proxy.post("/productionTaskDetail/snInfo", { productSn: val }).then((res) => {
  166. // if (res.data && res.data.productId) {
  167. // formData.data.productId = res.data.productId;
  168. // formData.data.productSn = res.data.productSn;
  169. // formData.data.code = res.data.contractCode;
  170. // formData.data.productName = res.data.productName;
  171. // formData.data.productSpec = res.data.productSpec;
  172. // formData.data.customerName = res.data.customerName;
  173. // }
  174. // });
  175. // };
  176. // onMounted(() => {
  177. // nextTick(() => {
  178. // window.getVueMessage = (data) => {
  179. // if (data) {
  180. // showScanData(data);
  181. // }
  182. // };
  183. // });
  184. // });
  185. const handleSend = () => {
  186. // uni.postMessage({
  187. // data: {
  188. // type: "push",
  189. // content: "推送测试",
  190. // },
  191. // });
  192. setInterval(() => {
  193. uni.postMessage({
  194. data: {
  195. type: "message",
  196. count: 10,
  197. },
  198. });
  199. }, 1000 * 10);
  200. };
  201. const toDelete = (row) => {
  202. showConfirmDialog({
  203. title: "提示",
  204. message: `您确定删除该数据吗?`,
  205. })
  206. .then(() => {
  207. proxy
  208. .post("/productionReporting/delete", {
  209. id: row.id,
  210. })
  211. .then((res) => {
  212. showSuccessToast("操作成功");
  213. onRefresh();
  214. });
  215. })
  216. .catch(() => {
  217. return;
  218. });
  219. };
  220. </script>
  221. <style lang="scss" scoped>
  222. .list {
  223. min-height: 70vh;
  224. }
  225. </style>