生产报工扫码代码修改
This commit is contained in:
parent
0a2e4647e8
commit
d3403c2813
@ -9,7 +9,6 @@ import {
|
||||
} from "@/services/productionReport";
|
||||
import { useLoginStore } from "@/stores/modules/login";
|
||||
import { formatDate } from "@/utils/index";
|
||||
|
||||
const userStore = useLoginStore();
|
||||
const userId = userStore.userInfo.userId;
|
||||
|
||||
@ -65,8 +64,8 @@ const getListData = async () => {
|
||||
return uni.showToast({ icon: "none", title: "没有更多数据~" });
|
||||
}
|
||||
isLoading.value = true;
|
||||
console.log('触发列表查询')
|
||||
// 发送请求
|
||||
// const data = await getListAPI(queryParams)
|
||||
const data = await getListWxAPI(queryParams);
|
||||
isLoading.value = false;
|
||||
data.list.forEach((e) => {
|
||||
@ -91,19 +90,31 @@ onMounted(async () => {
|
||||
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}`;
|
||||
await getListData();
|
||||
});
|
||||
|
||||
onShow(async () => {
|
||||
isFinish.value = false;
|
||||
isLoading.value = false;
|
||||
queryParams.pageNo = 1;
|
||||
dataList.value = [];
|
||||
todayStr.value = `${year}-${month}-${day}`;
|
||||
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) => {
|
||||
// var isoverBefore = await isOverBeforeProcedure(item.id);
|
||||
// if (isoverBefore == true) {
|
||||
@ -132,29 +143,46 @@ const onRefresherrefresh = async () => {
|
||||
isTriggered.value = false;
|
||||
};
|
||||
const searchVal = ref("");
|
||||
const searchValBefore = 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) => {
|
||||
queryParams.subOrDetailName = e.inputValue;
|
||||
console.log('触发搜索')
|
||||
// 重置状态
|
||||
queryParams.pageNo = 1;
|
||||
isFinish.value = false;
|
||||
dataList.value = [];
|
||||
|
||||
// 设置搜索词
|
||||
queryParams.subOrDetailName = e.inputValue;
|
||||
searchVal.value = e.inputValue; // 同步输入框值
|
||||
|
||||
|
||||
try {
|
||||
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>
|
||||
<template>
|
||||
<view class="cont">
|
||||
|
Loading…
Reference in New Issue
Block a user