feat(xzdstoragelog): 添加出入库单据生成功能

This commit is contained in:
zxy 2026-04-07 09:08:37 +08:00
parent dc65ee2583
commit 4625705ce1

View File

@ -171,6 +171,7 @@
style="width: 100%" style="width: 100%"
filterable filterable
clearable clearable
@focus="handleMatSelectFocus(scope.row)"
@change="(val) => handleMatIdChange(val, scope.row)" @change="(val) => handleMatIdChange(val, scope.row)"
> >
<el-option <el-option
@ -370,16 +371,29 @@ const getMatCode = async () => {
// materialDOList // materialDOList
row.materialDOList = newRow.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) const mat = newRow.materialDOList.find((m) => m.id == row.matId)
if (mat) { if (mat) {
//
row.matId = mat.id row.matId = mat.id
row.matCode = mat.code row.matCode = mat.code
row.matName = mat.name row.matName = mat.name
} else { } else {
//
row.matId = undefined row.matId = undefined
row.matCode = '' row.matCode = ''
row.matName = '' row.matName = ''
@ -391,6 +405,7 @@ const getMatCode = async () => {
row.matId = undefined row.matId = undefined
row.matCode = '' row.matCode = ''
row.matName = '' 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 () => { const generateBill = async () => {
// 1. // 1.
if (multipleSelection.value.length === 0) { if (multipleSelection.value.length === 0) {
@ -612,6 +676,9 @@ const getDefaultDateRange = () => {
/** 物料编码变更处理 */ /** 物料编码变更处理 */
const handleMatIdChange = (val, row) => { const handleMatIdChange = (val, row) => {
//
row._autoSelectMatId = false
if (val && queryParams.isSameMat) { if (val && queryParams.isSameMat) {
// "" // ""
const selectedIds = multipleSelection.value.map((item) => item.id) const selectedIds = multipleSelection.value.map((item) => item.id)
@ -620,6 +687,7 @@ const handleMatIdChange = (val, row) => {
if (selectedIds.includes(item.id)) { if (selectedIds.includes(item.id)) {
// ID // ID
item.matId = val item.matId = val
item._autoSelectMatId = false //
// "1|" // "1|"
if (!item.priceType) { if (!item.priceType) {
item.priceType = '1|临时暂估价' item.priceType = '1|临时暂估价'