feat(xzdstoragelog): 添加出入库单据生成功能
This commit is contained in:
parent
dc65ee2583
commit
4625705ce1
@ -171,6 +171,7 @@
|
||||
style="width: 100%"
|
||||
filterable
|
||||
clearable
|
||||
@focus="handleMatSelectFocus(scope.row)"
|
||||
@change="(val) => handleMatIdChange(val, scope.row)"
|
||||
>
|
||||
<el-option
|
||||
@ -370,16 +371,29 @@ const getMatCode = async () => {
|
||||
// 更新 materialDOList
|
||||
row.materialDOList = newRow.materialDOList
|
||||
|
||||
// 检查当前 matId 是否在新选项列表中(用 == 避免类型不匹配)
|
||||
if (row.matId != null && row.matId !== '') {
|
||||
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 不为空:保持当前选中,检查是否仍在新列表中
|
||||
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 {
|
||||
// 编码不存在了,清空
|
||||
row.matId = undefined
|
||||
row.matCode = ''
|
||||
row.matName = ''
|
||||
@ -391,6 +405,7 @@ const getMatCode = async () => {
|
||||
row.matId = undefined
|
||||
row.matCode = ''
|
||||
row.matName = ''
|
||||
row._autoSelectMatId = false
|
||||
}
|
||||
})
|
||||
|
||||
@ -403,6 +418,55 @@ const getMatCode = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
/** 点击物料编码下拉框时,请求当前行的物料编码列表 */
|
||||
const handleMatSelectFocus = async (row) => {
|
||||
// 避免重复请求
|
||||
if (row._loadingMatList) return
|
||||
row._loadingMatList = true
|
||||
try {
|
||||
queryParams.ids = [row.id]
|
||||
const data = await StorageLogApi.getStorageLogPage(queryParams)
|
||||
const newRow = data.list?.find((r) => r.id == row.id)
|
||||
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 不为空:保持当前选中,检查是否仍在新列表中
|
||||
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 {
|
||||
row.matId = undefined
|
||||
row.matCode = ''
|
||||
row.matName = ''
|
||||
}
|
||||
}
|
||||
}
|
||||
queryParams.ids = []
|
||||
} catch (error) {
|
||||
console.error('获取物料编码失败:', error)
|
||||
} finally {
|
||||
row._loadingMatList = false
|
||||
}
|
||||
}
|
||||
|
||||
const generateBill = async () => {
|
||||
// 1. 检查是否选择了数据
|
||||
if (multipleSelection.value.length === 0) {
|
||||
@ -612,6 +676,9 @@ const getDefaultDateRange = () => {
|
||||
|
||||
/** 物料编码变更处理 */
|
||||
const handleMatIdChange = (val, row) => {
|
||||
// 用户手动选择,清除自动选中标记
|
||||
row._autoSelectMatId = false
|
||||
|
||||
if (val && queryParams.isSameMat) {
|
||||
// 当勾选了"相同物料"选项时,更新所有选中行的物料编码
|
||||
const selectedIds = multipleSelection.value.map((item) => item.id)
|
||||
@ -620,6 +687,7 @@ const handleMatIdChange = (val, row) => {
|
||||
if (selectedIds.includes(item.id)) {
|
||||
// 更新物料 ID
|
||||
item.matId = val
|
||||
item._autoSelectMatId = false // 手动选择
|
||||
// 自动设置价格类型为"1|临时暂估价"
|
||||
if (!item.priceType) {
|
||||
item.priceType = '1|临时暂估价'
|
||||
|
||||
Loading…
Reference in New Issue
Block a user