feat(xzdstoragelog): 添加出入库单据生成功能
This commit is contained in:
parent
aebf8c65a7
commit
37f40e1c16
@ -303,16 +303,11 @@ const getList = async () => {
|
||||
const data = await StorageLogApi.getStorageLogPage(queryParams)
|
||||
list.value = data.list
|
||||
total.value = data.total
|
||||
// 如果没有价格类型,默认选择 1|临时暂估价
|
||||
// 如果只有一个物料类型,默认选中
|
||||
// 价格类型默认'1|临时暂估价'
|
||||
list.value.forEach((item) => {
|
||||
if (!item.priceType) {
|
||||
item.priceType = '1|临时暂估价'
|
||||
}
|
||||
// 如果只有一个物料类型,默认选中
|
||||
if (item.materialDOList && item.materialDOList.length === 1) {
|
||||
item.matId = item.materialDOList[0].id
|
||||
}
|
||||
})
|
||||
} finally {
|
||||
loading.value = false
|
||||
@ -352,8 +347,8 @@ const getMatCode = async () => {
|
||||
try {
|
||||
const selectedList = multipleSelection.value || [] // 安全获取数据
|
||||
// 1. 检查空数据
|
||||
if (!selectedList || selectedList.length == null) {
|
||||
message.error('提交明细不能为空,请确认')
|
||||
if (!selectedList || selectedList.length === 0) {
|
||||
message.error('请先选择数据')
|
||||
return
|
||||
}
|
||||
loading.value = true
|
||||
@ -362,11 +357,18 @@ const getMatCode = async () => {
|
||||
// 只获取选中行的物料编码数据,不刷新整个页面
|
||||
const data = await StorageLogApi.getStorageLogPage(queryParams)
|
||||
|
||||
// 通过 list.value 更新,确保 Vue 响应式生效
|
||||
// 只处理选中行,确保 Vue 响应式生效
|
||||
data.list?.forEach((newRow) => {
|
||||
// 只处理用户勾选的行
|
||||
if (!queryParams.ids.includes(newRow.id)) return
|
||||
const row = list.value.find((r) => r.id == newRow.id)
|
||||
if (!row) return
|
||||
|
||||
// 默认价格类型
|
||||
if (!row.priceType) {
|
||||
row.priceType = '1|临时暂估价'
|
||||
}
|
||||
|
||||
if (newRow.materialDOList && newRow.materialDOList.length > 0) {
|
||||
// 更新 materialDOList
|
||||
row.materialDOList = newRow.materialDOList
|
||||
@ -430,29 +432,10 @@ const handleMatSelectFocus = async (row) => {
|
||||
if (newRow && newRow.materialDOList) {
|
||||
row.materialDOList = newRow.materialDOList
|
||||
|
||||
if (row.matId == null || row.matId === '') {
|
||||
// matId 为空:物料编码 == 1 默认选中,> 1 不选择
|
||||
if (newRow.materialDOList.length === 1) {
|
||||
const mat = newRow.materialDOList[0]
|
||||
row.matId = mat.id
|
||||
row.matCode = mat.code
|
||||
row.matName = mat.name
|
||||
row._autoSelectMatId = true // 标记为自动选中
|
||||
}
|
||||
} else if (row._autoSelectMatId && newRow.materialDOList.length > 1) {
|
||||
// 之前是自动选中的,现在变成多条,清空
|
||||
row.matId = undefined
|
||||
row.matCode = ''
|
||||
row.matName = ''
|
||||
row._autoSelectMatId = false
|
||||
} else {
|
||||
// matId 不为空:保持当前选中,检查是否仍在新列表中
|
||||
// matId 不为空:检查是否仍在新列表中,不在则清空
|
||||
if (row.matId != null && row.matId !== '') {
|
||||
const mat = newRow.materialDOList.find((m) => m.id == row.matId)
|
||||
if (mat) {
|
||||
row.matId = mat.id
|
||||
row.matCode = mat.code
|
||||
row.matName = mat.name
|
||||
} else {
|
||||
if (!mat) {
|
||||
row.matId = undefined
|
||||
row.matCode = ''
|
||||
row.matName = ''
|
||||
@ -557,8 +540,8 @@ const submitForm = async () => {
|
||||
try {
|
||||
const selectedList = multipleSelection.value || [] // 安全获取数据
|
||||
// 1. 检查空数据
|
||||
if (!selectedList || selectedList.length == null) {
|
||||
message.error('提交明细不能为空,请确认')
|
||||
if (!selectedList || selectedList.length === 0) {
|
||||
message.error('请先选择数据')
|
||||
return
|
||||
}
|
||||
// 2.物料编码不能为空 提示 行(具体序列号)没有选择物料编码,请确认! 使用表格中的实际行号
|
||||
@ -688,10 +671,6 @@ const handleMatIdChange = (val, row) => {
|
||||
// 更新物料 ID
|
||||
item.matId = val
|
||||
item._autoSelectMatId = false // 手动选择
|
||||
// 自动设置价格类型为"1|临时暂估价"
|
||||
if (!item.priceType) {
|
||||
item.priceType = '1|临时暂估价'
|
||||
}
|
||||
// 同步更新物料编号和名称
|
||||
const selectedMat = item.materialDOList?.find((m) => m.id === val)
|
||||
if (selectedMat) {
|
||||
@ -707,10 +686,6 @@ const handleMatIdChange = (val, row) => {
|
||||
row.matCode = selectedMat.code
|
||||
row.matName = selectedMat.name
|
||||
}
|
||||
// 自动设置价格类型为"1|临时暂估价"
|
||||
if (!row.priceType) {
|
||||
row.priceType = '1|临时暂估价'
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user