feat(purchase): 采购单号改为 批次-批内序号 格式,显式体现同批

按用户原始逻辑还原并扩展:
- 单号格式: PUR-日期-时间-批次-批内序号
  例: PUR-20260831-1021-0001-0001(今日第1次采购的第1条)
- generate_request_no 支持 batch_seq 参数生成批次+批内序号
- 新增 GET /purchase/next-batch-seq 返回今日下一个批次号
- 前端提交时获取批次号,同批所有行共享,循环提交生成连续批内序号
- 批次识别: 单号去掉末尾 -批内序号 即为批次前缀
- 保留旧格式兼容(无 batch_seq 时回退 PUR-日期-时间-流水)
This commit is contained in:
yueli
2026-08-31 13:54:03 +08:00
parent f499346f74
commit 1000deda2f
4 changed files with 80 additions and 8 deletions

View File

@ -109,6 +109,14 @@ export function getPurchaseByBatch(batchKey: string) {
})
}
// 获取今日下一个采购批次号(提交一批时调用,同批所有行共享)
export function getNextBatchSeq() {
return request({
url: '/purchase/next-batch-seq',
method: 'get'
})
}
// 获取可选审批人列表
export function getPurchaseApprovers() {
return request({

View File

@ -362,7 +362,7 @@ import { searchMaterialPurchase } from '@/api/purchase'
import {
getPurchaseList, createPurchase, getPurchaseDetail,
approvePurchase, batchApprovePurchase, getPurchaseApprovers, autoFillPurchase,
getPurchaseByBatch
getPurchaseByBatch, getNextBatchSeq
} from '@/api/purchase'
import { uploadFile, deleteFile } from '@/api/common/upload'
import type { FormInstance } from 'element-plus'
@ -951,12 +951,21 @@ const submitForm = async () => {
}
}
// 3. 逐行提交(每行携带公共信息)
// 3. 逐行提交(每行携带公共信息 + 同一批次号
submitLoading.value = true
let successCount = 0
// ★ 获取今日批次号:同一批所有行共享,单号体现 PUR-日期-时间-批次-批内序号
let batchSeq: number | undefined
try {
const seqRes: any = await getNextBatchSeq()
batchSeq = seqRes.data?.batch_seq
} catch (e) {
// 获取批次号失败不阻断,回退旧格式
}
try {
for (const row of validItems) {
const payload: any = {
batch_seq: batchSeq,
name: row.name,
spec_model: row.spec_model,
quantity: row.quantity,