style:关键件模块-手动输入编码方式传参改用code

master
黄伟杰 3 weeks ago
parent 2faec8ef4c
commit 220489ef43

@ -39,27 +39,34 @@ import request from '@/utils/request'
import AppTitleHeader from '@/components/common/AppTitleHeader.vue' import AppTitleHeader from '@/components/common/AppTitleHeader.vue'
const keypartId = ref(undefined) const keypartId = ref(undefined)
const keypartCode = ref(undefined)
const keypartType = ref(undefined)
const loading = ref(false) const loading = ref(false)
const detailData = ref(null) const detailData = ref(null)
onLoad((query) => { onLoad((query) => {
const rawId = query && (query.id !== undefined ? query.id : query.code) const rawId = query && query.id
const decoded = rawId ? decodeURIComponent(String(rawId)) : '' const decoded = rawId ? decodeURIComponent(String(rawId)) : ''
keypartId.value = decoded ? decoded : undefined keypartId.value = decoded ? decoded : undefined
keypartType.value = query && query.type
keypartCode.value = query && query.code
fetchDetail() fetchDetail()
}) })
async function fetchDetail() { async function fetchDetail() {
if (!keypartId.value) { if (!keypartId.value && !keypartCode.value) {
uni.showToast({ title: '缺少关键件ID', icon: 'none' }) uni.showToast({ title: '缺少关键件ID', icon: 'none' })
return return
} }
loading.value = true loading.value = true
try { try {
const isScan = keypartType.value === 'scan'
const params = isScan ? { id: keypartId.value } : { code: keypartCode.value }
const res = await request({ const res = await request({
url: '/admin-api/mes/critical-component/get', url: '/admin-api/mes/critical-component/get',
method: 'get', method: 'get',
params: { id: keypartId.value } params: params
}) })
detailData.value = res && res.data !== undefined ? res.data : res detailData.value = res && res.data !== undefined ? res.data : res
} catch (e) { } catch (e) {

@ -120,12 +120,18 @@ function confirmInput() {
return; 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({ uni.navigateTo({
url: `/pages_function/pages/keypart/detail?id=${encodeURIComponent(id)}` url: url
}); });
} }
</script> </script>

Loading…
Cancel
Save