修改半成品和成品新增时候搜索下拉框显示问题,新增负责人和生产人历史记录功能

This commit is contained in:
dxc
2026-02-28 17:08:35 +08:00
parent 29fd397e4f
commit f7cfb5a346
8 changed files with 168 additions and 48 deletions

View File

@ -469,7 +469,8 @@ import {
deleteProductInbound,
searchMaterialBase,
searchBom,
getFilterOptions // [新增]
getFilterOptions, // [新增]
getManagerHistory // [新增]
} from '@/api/inbound/product'
import { uploadFile, deleteFile } from '@/api/inbound/buy'
import WebRtcCamera from '@/components/Camera/WebRtcCamera.vue'
@ -634,7 +635,7 @@ const defaultVisibleCols = ['company_name', 'material_name', 'sku', 'serial_numb
const visibleColumnProps = ref(defaultVisibleCols)
const form = reactive({
id: undefined, base_id: undefined,
id: undefined, base_id: undefined as number | undefined,
company_name: '', // [新增]
material_name: '', spec_model: '', material_type: '', category: '', unit: '',
sku: '', barcode: '', serial_number: '', in_date: '',
@ -739,7 +740,7 @@ const rules = {
// ------------------------------------
// Material Search & Population Logic
// Material Search & Population Logic (已修改)
// ------------------------------------
const handleMaterialDropdownVisible = (visible: boolean) => { if (visible && materialOptions.value.length === 0) handleSearchMaterialDebounced('') }
@ -758,9 +759,9 @@ const handleSearchMaterial = async (query: string) => {
try {
const res: any = await searchMaterialBase(query, 1)
const apiResults = (res.data || []).map((i: any) => ({ ...i, isHistory: false }))
const apiResults = (res.data?.items || []).map((i: any) => ({ ...i, isHistory: false }))
materialOptions.value = apiResults
hasNextPage.value = res.has_next
hasNextPage.value = res.data?.has_next ?? false
} finally { searchLoading.value = false }
}
@ -770,10 +771,10 @@ const loadMoreMaterials = async () => {
searchPage.value += 1
try {
const res: any = await searchMaterialBase(searchKeyword.value, searchPage.value)
if (res.data && res.data.length > 0) {
const newItems = res.data.map((i: any) => ({...i, isHistory: false}))
if (res.data && res.data.items && res.data.items.length > 0) {
const newItems = res.data.items.map((i: any) => ({...i, isHistory: false}))
materialOptions.value.push(...newItems)
hasNextPage.value = res.has_next
hasNextPage.value = res.data.has_next
} else {
hasNextPage.value = false
}
@ -797,12 +798,21 @@ const onMaterialSelected = (val: number) => {
}
// ------------------------------------
// Autocomplete (Manager) - 后端驱动
// Autocomplete (Manager) - 后端历史记录驱动 (已修改)
// ------------------------------------
const querySearchManager = async (query: string, cb: any) => {
cb([])
if (!form.base_id) { cb([]); return }
try {
const res: any = await getManagerHistory({ base_id: form.base_id })
if (res.code === 200) {
const managers = (res.data || []).map((name: string) => ({ value: name }))
const filtered = query ? managers.filter((item: any) => item.value.toLowerCase().includes(query.toLowerCase())) : managers
cb(filtered)
} else { cb([]) }
} catch (e) { cb([]) }
}
const handleManagerSelect = (item: any) => {
form.production_manager = item.value
}
const fetchData = async () => {

View File

@ -539,7 +539,8 @@ import {
deleteSemiInbound,
searchMaterialBase,
searchBom,
getFilterOptions
getFilterOptions,
getManagerHistory // [新增]
} from '@/api/inbound/semi'
import { uploadFile, deleteFile } from '@/api/inbound/buy'
import WebRtcCamera from '@/components/Camera/WebRtcCamera.vue'
@ -754,16 +755,25 @@ const handleBomSelect = (val: string) => {
}
// ------------------------------------
// Autocomplete & Search Logic (后端 API 驱动)
// Autocomplete & Search Logic (后端 API 驱动) (已修改)
// ------------------------------------
const querySearchManager = async (query: string, cb: any) => {
cb([])
if (!form.base_id) { cb([]); return }
try {
const res: any = await getManagerHistory({ base_id: form.base_id })
if (res.code === 200) {
const managers = (res.data || []).map((name: string) => ({ value: name }))
const filtered = query ? managers.filter((item: any) => item.value.toLowerCase().includes(query.toLowerCase())) : managers
cb(filtered)
} else { cb([]) }
} catch (e) { cb([]) }
}
const handleManagerSelect = (item: any) => {
form.production_manager = item.value
}
// ------------------------------------
// Material Search (Matches Buy.vue)
// Material Search (Matches Buy.vue) (已修改)
// ------------------------------------
const handleMaterialDropdownVisible = (visible: boolean) => { if (visible && materialOptions.value.length === 0) handleSearchMaterialDebounced('') }
@ -782,9 +792,9 @@ const handleSearchMaterial = async (query: string) => {
try {
const res: any = await searchMaterialBase(query, 1)
const apiResults = (res.data || []).map((i: any) => ({...i, isHistory: false}))
const apiResults = (res.data?.items || []).map((i: any) => ({...i, isHistory: false}))
materialOptions.value = apiResults
hasNextPage.value = res.has_next
hasNextPage.value = res.data?.has_next ?? false
} finally { searchLoading.value = false }
}
@ -794,10 +804,10 @@ const loadMoreMaterials = async () => {
searchPage.value += 1
try {
const res: any = await searchMaterialBase(searchKeyword.value, searchPage.value)
if (res.data && res.data.length > 0) {
const newItems = res.data.map((i: any) => ({...i, isHistory: false}))
if (res.data && res.data.items && res.data.items.length > 0) {
const newItems = res.data.items.map((i: any) => ({...i, isHistory: false}))
materialOptions.value.push(...newItems)
hasNextPage.value = res.has_next
hasNextPage.value = res.data.has_next
} else {
hasNextPage.value = false
}