修改半成品和成品新增时候搜索下拉框显示问题,新增负责人和生产人历史记录功能
This commit is contained in:
@ -33,11 +33,12 @@ export function deleteProductInbound(id: number) {
|
||||
})
|
||||
}
|
||||
|
||||
export function searchMaterialBase(keyword: string) {
|
||||
// 搜索基础物料 (已增加 page 参数)
|
||||
export function searchMaterialBase(keyword: string, page: number = 1) {
|
||||
return request({
|
||||
url: '/inbound/product/search-base',
|
||||
method: 'get',
|
||||
params: { keyword }
|
||||
params: { keyword, page }
|
||||
})
|
||||
}
|
||||
|
||||
@ -65,4 +66,13 @@ export function getFilterOptions() {
|
||||
url: '/inbound/product/options',
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
// [新增] 负责人历史记录
|
||||
export function getManagerHistory(params: any) {
|
||||
return request({
|
||||
url: '/inbound/product/suggestions/managers',
|
||||
method: 'get',
|
||||
params
|
||||
})
|
||||
}
|
||||
@ -35,12 +35,12 @@ export function deleteSemiInbound(id: number) {
|
||||
})
|
||||
}
|
||||
|
||||
// 5. 搜索基础物料
|
||||
export function searchMaterialBase(keyword: string) {
|
||||
// 5. 搜索基础物料 (已增加 page 参数)
|
||||
export function searchMaterialBase(keyword: string, page: number = 1) {
|
||||
return request({
|
||||
url: '/inbound/semi/search-base',
|
||||
method: 'get',
|
||||
params: { keyword }
|
||||
params: { keyword, page }
|
||||
})
|
||||
}
|
||||
|
||||
@ -68,4 +68,13 @@ export function getFilterOptions() {
|
||||
url: '/inbound/semi/options',
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
// [新增] 生产负责人历史记录
|
||||
export function getManagerHistory(params: any) {
|
||||
return request({
|
||||
url: '/inbound/semi/suggestions/managers',
|
||||
method: 'get',
|
||||
params
|
||||
})
|
||||
}
|
||||
@ -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 () => {
|
||||
|
||||
@ -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