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

master
黄伟杰 2 weeks ago
parent 220489ef43
commit a7ac7d8ad7

@ -47,6 +47,8 @@ import request from '@/utils/request'
import AppTitleHeader from '@/components/common/AppTitleHeader.vue'
const spareId = ref(undefined)
const spareCode = ref(undefined)
const spareType = ref(undefined)
const loading = ref(false)
const detailData = ref(null)
const unitList = ref([])
@ -98,17 +100,20 @@ const unitLabel = computed(() => {
})
async function fetchAll() {
if (!spareId.value) {
if (!spareId.value && !spareCode.value) {
uni.showToast({ title: '缺少备件ID', icon: 'none' })
return
}
loading.value = true
try {
const isScan = spareType.value === 'scan'
const params = isScan ? { id: spareId.value } : { code: spareCode.value }
const [detailRes, unitRes] = await Promise.all([
request({
url: '/admin-api/erp/product/get',
method: 'get',
params: { id: spareId.value },
params: params,
showLoading: false
}),
request({
@ -127,9 +132,11 @@ async function fetchAll() {
}
onLoad((query) => {
const rawId = query && (query.id !== undefined ? query.id : query.code)
const rawId = query && query.id
const decoded = rawId ? decodeURIComponent(String(rawId)) : ''
spareId.value = decoded ? decoded : undefined
spareType.value = query && query.type
spareCode.value = query && query.code
fetchAll()
})
</script>

@ -120,12 +120,18 @@ function confirmInput() {
return;
}
navigateToDetail(spareCode.value.trim());
navigateToDetail(spareCode.value.trim(), 'input');
}
function navigateToDetail(id) {
function navigateToDetail(id, type = 'scan') {
let url
if (type === 'scan') {
url = `/pages_function/pages/spare/detail?id=${encodeURIComponent(id)}&type=${type}`
} else {
url = `/pages_function/pages/spare/detail?code=${id}&type=${type}`
}
uni.navigateTo({
url: `/pages_function/pages/spare/detail?id=${encodeURIComponent(id)}`
url: url
});
}
</script>

Loading…
Cancel
Save