style:产品物料模块-手动输入编码方式传参改用code

master
黄伟杰 2 weeks ago
parent a7ac7d8ad7
commit f36f51b2f7

@ -55,6 +55,8 @@ import request from '@/utils/request'
import AppTitleHeader from '@/components/common/AppTitleHeader.vue'
const productId = ref(undefined)
const productCode = ref(undefined)
const productType = ref(undefined)
const loading = ref(false)
const detailData = ref(null)
const unitList = ref([])
@ -121,17 +123,20 @@ const statusLabel = computed(() => {
})
async function fetchAll() {
if (!productId.value) {
if (!productId.value && !productCode.value) {
uni.showToast({ title: '缺少产品物料ID', icon: 'none' })
return
}
loading.value = true
try {
const isScan = productType.value === 'scan'
const params = isScan ? { id: productId.value } : { code: productCode.value }
const [detailRes, unitRes] = await Promise.all([
request({
url: '/admin-api/erp/product/get',
method: 'get',
params: { id: productId.value },
params: params,
showLoading: false
}),
request({
@ -150,9 +155,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)) : ''
productId.value = decoded ? decoded : undefined
productType.value = query && query.type
productCode.value = query && query.code
fetchAll()
})
</script>

@ -113,12 +113,18 @@ function confirmInput() {
uni.showToast({ title: '请输入产品物料ID', icon: 'none' })
return
}
navigateToDetail(productId.value.trim())
navigateToDetail(productId.value.trim(), 'input')
}
function navigateToDetail(id) {
function navigateToDetail(id, type = 'scan') {
let url
if (type === 'scan') {
url = `/pages_function/pages/product/detail?id=${encodeURIComponent(id)}&type=${type}`
} else {
url = `/pages_function/pages/product/detail?code=${id}&type=${type}`
}
uni.navigateTo({
url: `/pages_function/pages/product/detail?id=${encodeURIComponent(id)}`
url: url
})
}
</script>

Loading…
Cancel
Save