fix: sort warehouse tree by name, fix tree batch delete cascade, and implement safe history location autofill

This commit is contained in:
DXC
2026-04-08 17:32:00 +08:00
parent c58a0a6d14
commit 4a4baa2f8f
11 changed files with 228 additions and 9 deletions

View File

@ -669,6 +669,7 @@ import {ref, reactive, onMounted, watch, computed} from 'vue'
import {Plus, Setting, Refresh, Search, Lock, Box, House, InfoFilled, Link, Printer, Camera, Delete, Picture} from '@element-plus/icons-vue'
import {ElMessage, ElMessageBox, ElLoading} from 'element-plus'
import dayjs from 'dayjs'
import request from '@/utils/request'
import {
getBuyList,
createBuyInbound,
@ -1132,7 +1133,7 @@ const loadMoreMaterials = async () => {
}
}
const onMaterialSelected = (val: number) => {
const onMaterialSelected = async (val: number) => {
const item = materialOptions.value.find(i => i.id === val)
if (item) {
form.company_name = item.company_name
@ -1146,6 +1147,17 @@ const onMaterialSelected = (val: number) => {
// 更新表单校验规则
updateInspectionRules()
checkHistoryAndSetMode(item.id)
// 获取该物料历史入库库位(新增独立接口)
try {
const res = await request.get('/api/v1/inbound/buy/last-location', { params: { base_id: val } })
if (res.code === 200 && res.data.location) {
form.warehouse_location = res.data.location
ElMessage.info(`已自动带入该物料历史库位:【${res.data.location}】,请核对。`)
}
} catch (e) {
console.error('获取历史库位失败', e)
}
}
}

View File

@ -559,6 +559,7 @@ import { ref, reactive, onMounted, watch, computed } from 'vue'
import { Plus, Setting, Refresh, Search, Box, House, Link, InfoFilled, Printer, Camera, Picture } from '@element-plus/icons-vue'
import { ElMessage, ElLoading } from 'element-plus'
import dayjs from 'dayjs'
import request from '@/utils/request'
import {
getProductList,
createProductInbound,
@ -1029,7 +1030,7 @@ const loadMoreMaterials = async () => {
}
}
const onMaterialSelected = (val: number) => {
const onMaterialSelected = async (val: number) => {
const item = materialOptions.value.find(i => i.id === val)
if (item) {
form.company_name = item.company_name // [新增]
@ -1038,6 +1039,17 @@ const onMaterialSelected = (val: number) => {
form.material_type = item.type
form.category = item.category
form.unit = item.unit
// 获取该物料历史入库库位(新增独立接口)
try {
const res = await request.get('/api/v1/inbound/product/last-location', { params: { base_id: val } })
if (res.code === 200 && res.data.location) {
form.warehouse_location = res.data.location
ElMessage.info(`已自动带入该物料历史库位:【${res.data.location}】,请核对。`)
}
} catch (e) {
console.error('获取历史库位失败', e)
}
}
}

View File

@ -616,6 +616,7 @@ import {ref, reactive, onMounted, watch, computed} from 'vue'
import {Plus, Setting, Refresh, Search, Lock, Box, House, InfoFilled, Link, Printer, Camera, Picture} from '@element-plus/icons-vue'
import {ElMessage, ElLoading} from 'element-plus'
import dayjs from 'dayjs'
import request from '@/utils/request'
import {
getSemiList,
createSemiInbound,
@ -1027,7 +1028,7 @@ const loadMoreMaterials = async () => {
}
}
const onMaterialSelected = (val: number) => {
const onMaterialSelected = async (val: number) => {
const item = materialOptions.value.find(i => i.id === val)
if (item) {
form.company_name = item.company_name // [新增]
@ -1037,6 +1038,17 @@ const onMaterialSelected = (val: number) => {
form.unit = item.unit
form.material_type = item.type
checkHistoryAndSetMode(item.id)
// 获取该物料历史入库库位(新增独立接口)
try {
const res = await request.get('/api/v1/inbound/semi/last-location', { params: { base_id: val } })
if (res.code === 200 && res.data.location) {
form.warehouse_location = res.data.location
ElMessage.info(`已自动带入该物料历史库位:【${res.data.location}】,请核对。`)
}
} catch (e) {
console.error('获取历史库位失败', e)
}
}
}