From 220489ef43f1cd84123315c20091bf24a4b6c0ab Mon Sep 17 00:00:00 2001 From: hwj Date: Fri, 24 Apr 2026 10:33:32 +0800 Subject: [PATCH] =?UTF-8?q?style=EF=BC=9A=E5=85=B3=E9=94=AE=E4=BB=B6?= =?UTF-8?q?=E6=A8=A1=E5=9D=97-=E6=89=8B=E5=8A=A8=E8=BE=93=E5=85=A5?= =?UTF-8?q?=E7=BC=96=E7=A0=81=E6=96=B9=E5=BC=8F=E4=BC=A0=E5=8F=82=E6=94=B9?= =?UTF-8?q?=E7=94=A8code?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages_function/pages/keypart/detail.vue | 13 ++++++++++--- src/pages_function/pages/keypart/index.vue | 12 +++++++++--- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/pages_function/pages/keypart/detail.vue b/src/pages_function/pages/keypart/detail.vue index 63f15a5..9b8476c 100644 --- a/src/pages_function/pages/keypart/detail.vue +++ b/src/pages_function/pages/keypart/detail.vue @@ -39,27 +39,34 @@ import request from '@/utils/request' import AppTitleHeader from '@/components/common/AppTitleHeader.vue' const keypartId = ref(undefined) +const keypartCode = ref(undefined) +const keypartType = ref(undefined) const loading = ref(false) const detailData = ref(null) onLoad((query) => { - const rawId = query && (query.id !== undefined ? query.id : query.code) + const rawId = query && query.id const decoded = rawId ? decodeURIComponent(String(rawId)) : '' keypartId.value = decoded ? decoded : undefined + keypartType.value = query && query.type + keypartCode.value = query && query.code fetchDetail() }) async function fetchDetail() { - if (!keypartId.value) { + if (!keypartId.value && !keypartCode.value) { uni.showToast({ title: '缺少关键件ID', icon: 'none' }) return } loading.value = true try { + const isScan = keypartType.value === 'scan' + const params = isScan ? { id: keypartId.value } : { code: keypartCode.value } + const res = await request({ url: '/admin-api/mes/critical-component/get', method: 'get', - params: { id: keypartId.value } + params: params }) detailData.value = res && res.data !== undefined ? res.data : res } catch (e) { diff --git a/src/pages_function/pages/keypart/index.vue b/src/pages_function/pages/keypart/index.vue index f5a1014..f78e5f6 100644 --- a/src/pages_function/pages/keypart/index.vue +++ b/src/pages_function/pages/keypart/index.vue @@ -120,12 +120,18 @@ function confirmInput() { return; } - navigateToDetail(keypartCode.value.trim()); + navigateToDetail(keypartCode.value.trim(), 'input'); } -function navigateToDetail(id) { +function navigateToDetail(id, type = 'scan') { + let url + if (type === 'scan') { + url = `/pages_function/pages/keypart/detail?id=${encodeURIComponent(id)}&type=${type}` + } else { + url = `/pages_function/pages/keypart/detail?code=${id}&type=${type}` + } uni.navigateTo({ - url: `/pages_function/pages/keypart/detail?id=${encodeURIComponent(id)}` + url: url }); }