|
@@ -1,11 +1,13 @@
|
|
<script setup lang="ts">
|
|
<script setup lang="ts">
|
|
|
|
+import type { UploaderAfterRead, UploaderFileListItem } from 'vant';
|
|
|
|
+
|
|
|
|
+import { useRequest } from 'alova/client';
|
|
import { getDataMethod } from '@/api/pda.api.ts';
|
|
import { getDataMethod } from '@/api/pda.api.ts';
|
|
import { uploadMethod } from '@/api/file.api.ts';
|
|
import { uploadMethod } from '@/api/file.api.ts';
|
|
-import { type ScanData, useScan } from '@/core/hook/useScan.ts';
|
|
|
|
-import { useStep } from '@/core/hook/useStep.ts';
|
|
|
|
import { useStepStore } from '@/stores';
|
|
import { useStepStore } from '@/stores';
|
|
-import type { UploaderAfterRead, UploaderFileListItem } from 'vant';
|
|
|
|
-import { nextTick } from 'vue';
|
|
|
|
|
|
+
|
|
|
|
+import { useStep } from '@/core/hook/useStep.ts';
|
|
|
|
+import { type ScanData, useScan } from '@/core/hook/useScan.ts';
|
|
|
|
|
|
const stepStore = useStepStore();
|
|
const stepStore = useStepStore();
|
|
const { dataset, id, mode } = storeToRefs(stepStore);
|
|
const { dataset, id, mode } = storeToRefs(stepStore);
|
|
@@ -36,17 +38,19 @@ const { scanValue, scan } = useScan((data) => {
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
|
|
-async function onSearch() {
|
|
|
|
|
|
+const { loading, send: search } = useRequest(getDataMethod, { immediate: false })
|
|
|
|
+ .onSuccess(({ data }) => {
|
|
|
|
+ dataset.value = data;
|
|
|
|
+ next(dataset.value.no);
|
|
|
|
+ })
|
|
|
|
+ .onError(() => {
|
|
|
|
+ keyword.value = '';
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+function onSearch() {
|
|
const value = keyword.value?.trim?.();
|
|
const value = keyword.value?.trim?.();
|
|
if (value) {
|
|
if (value) {
|
|
- showLoadingToast({ forbidClick: true, duration: 0, message: '查询中...' });
|
|
|
|
- try {
|
|
|
|
- dataset.value = await getDataMethod(keyword.value.trim());
|
|
|
|
- await next(dataset.value.no);
|
|
|
|
- } catch (_: unknown) {
|
|
|
|
- keyword.value = '';
|
|
|
|
- }
|
|
|
|
- closeToast();
|
|
|
|
|
|
+ search(value);
|
|
} else {
|
|
} else {
|
|
showNotify({ message: '请使用设备按钮进行扫码', type: 'warning' });
|
|
showNotify({ message: '请使用设备按钮进行扫码', type: 'warning' });
|
|
}
|
|
}
|
|
@@ -77,6 +81,8 @@ const afterRead: UploaderAfterRead = async (listItem) => {
|
|
|
|
|
|
<template>
|
|
<template>
|
|
<div class="page page__home flex flex-col size-full">
|
|
<div class="page page__home flex flex-col size-full">
|
|
|
|
+ <van-toast :show="loading" type="loading" forbid-click message="查询中..." />
|
|
|
|
+
|
|
<header class="flex-none">
|
|
<header class="flex-none">
|
|
<van-nav-bar :title="menu?.title" left-text="返回" left-arrow @click-left="onBack()" />
|
|
<van-nav-bar :title="menu?.title" left-text="返回" left-arrow @click-left="onBack()" />
|
|
<van-search v-model="keyword" input-align="center" placeholder="请使用设备按钮进行扫码" @search="onSearch()" :readonly="loaded" :show-action="loaded" @cancel="onBack()" />
|
|
<van-search v-model="keyword" input-align="center" placeholder="请使用设备按钮进行扫码" @search="onSearch()" :readonly="loaded" :show-action="loaded" @cancel="onBack()" />
|