修改半成品和成品新增时候搜索下拉框显示问题,新增负责人和生产人历史记录功能
This commit is contained in:
@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user