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

master
黄伟杰 4 weeks ago
parent a7ac7d8ad7
commit f36f51b2f7

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

@ -113,12 +113,18 @@ function confirmInput() {
uni.showToast({ title: '请输入产品物料ID', icon: 'none' }) uni.showToast({ title: '请输入产品物料ID', icon: 'none' })
return 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({ uni.navigateTo({
url: `/pages_function/pages/product/detail?id=${encodeURIComponent(id)}` url: url
}) })
} }
</script> </script>

Loading…
Cancel
Save