生产报工扫码代码修改

This commit is contained in:
Ledo 2025-08-22 07:05:03 +08:00
parent 0a2e4647e8
commit d3403c2813

View File

@ -9,7 +9,6 @@ import {
} from "@/services/productionReport"; } from "@/services/productionReport";
import { useLoginStore } from "@/stores/modules/login"; import { useLoginStore } from "@/stores/modules/login";
import { formatDate } from "@/utils/index"; import { formatDate } from "@/utils/index";
const userStore = useLoginStore(); const userStore = useLoginStore();
const userId = userStore.userInfo.userId; const userId = userStore.userInfo.userId;
@ -65,8 +64,8 @@ const getListData = async () => {
return uni.showToast({ icon: "none", title: "没有更多数据~" }); return uni.showToast({ icon: "none", title: "没有更多数据~" });
} }
isLoading.value = true; isLoading.value = true;
console.log('触发列表查询')
// //
// const data = await getListAPI(queryParams)
const data = await getListWxAPI(queryParams); const data = await getListWxAPI(queryParams);
isLoading.value = false; isLoading.value = false;
data.list.forEach((e) => { data.list.forEach((e) => {
@ -91,19 +90,31 @@ onMounted(async () => {
const year = today.getFullYear(); const year = today.getFullYear();
const month = String(today.getMonth() + 1).padStart(2, "0"); const month = String(today.getMonth() + 1).padStart(2, "0");
const day = String(today.getDate()).padStart(2, "0"); const day = String(today.getDate()).padStart(2, "0");
todayStr.value = `${year}-${month}-${day}`;
await getListData();
});
onShow(async () => {
isFinish.value = false; isFinish.value = false;
isLoading.value = false; isLoading.value = false;
queryParams.pageNo = 1; queryParams.pageNo = 1;
dataList.value = []; todayStr.value = `${year}-${month}-${day}`;
await getListData(); await getListData();
}); });
const isScanning = ref(false)
// onShow(async () => {
// isFinish.value = false;
// isLoading.value = false;
// queryParams.pageNo = 1;
// const today = new Date();
// const year = today.getFullYear();
// const month = String(today.getMonth() + 1).padStart(2, "0");
// const day = String(today.getDate()).padStart(2, "0");
// todayStr.value = `${year}-${month}-${day}`;
// dataList.value = [];
// await getListData();
// });
// watch(searchVal, (newVal) => {
// if (newVal) {
// handleSearch({ inputValue: newVal });
// }
// });
const handleDetail = async (item) => { const handleDetail = async (item) => {
// var isoverBefore = await isOverBeforeProcedure(item.id); // var isoverBefore = await isOverBeforeProcedure(item.id);
// if (isoverBefore == true) { // if (isoverBefore == true) {
@ -132,29 +143,46 @@ const onRefresherrefresh = async () => {
isTriggered.value = false; isTriggered.value = false;
}; };
const searchVal = ref(""); const searchVal = ref("");
const searchValBefore = ref('')
// const dataListDefault = ref([]) // const dataListDefault = ref([])
const handleScan = async () => {
if (isScanning.value) return;
isScanning.value = true;
try {
console.log('触发扫码')
const res = await uni.scanCode();
searchVal.value = res.result;
// 使 setTimeout UI
await new Promise(resolve => setTimeout(resolve, 0));
await handleSearch({ inputValue: res.result });
} catch (error) {
uni.showToast({ title: '扫码失败', icon: 'none' });
} finally {
isScanning.value = false;
}
};
const handleSearch = async (e) => { const handleSearch = async (e) => {
queryParams.subOrDetailName = e.inputValue; console.log('触发搜索')
//
queryParams.pageNo = 1; queryParams.pageNo = 1;
isFinish.value = false; isFinish.value = false;
dataList.value = []; dataList.value = [];
//
queryParams.subOrDetailName = e.inputValue;
searchVal.value = e.inputValue; //
try {
await getListData(); await getListData();
} catch (error) {
console.error('搜索请求失败:', error);
}
}; };
const handleScan = () => {
uni.scanCode({
success: (res) => {
searchVal.value = res.result
handleSearch({ inputValue: res.result })
},
fail: () => {
uni.showToast({ title: '扫码失败', icon: 'none' })
}
})
}
</script> </script>
<template> <template>
<view class="cont"> <view class="cont">