优化
This commit is contained in:
@@ -101,11 +101,12 @@ export function draftBudgetTotal(draft: ProcurementDraft) {
|
||||
}
|
||||
export function buildProcurementCreate(draft: ProcurementDraft, customerName: string, key: string): ProcurementCreate {
|
||||
for (const [field, label, max] of [
|
||||
['purchaseCategory', '采购品类', 128], ['productName', '商品名称', 255], ['receivingAddress', '完整国内收货地址', 1000],
|
||||
['productName', '商品名称', 255], ['receivingAddress', '完整国内收货地址', 1000],
|
||||
['contactName', '最终收件人', 128], ['contactPhone', '联系电话', 64],
|
||||
] as const) {
|
||||
if (!draft[field].trim() || draft[field].trim().length > max) throw new Error(`请填写有效的${label}`)
|
||||
}
|
||||
if (draft.purchaseCategory.trim().length > 128) throw new Error('采购品类超过长度限制')
|
||||
if (!customerName.trim()) throw new Error('当前企业信息尚未加载,请刷新登录信息后重试')
|
||||
if (!/^\d+$/.test(draft.purchaseQuantity) || !Number.isSafeInteger(Number(draft.purchaseQuantity)) || Number(draft.purchaseQuantity) <= 0) throw new Error('采购数量必须为正整数')
|
||||
const price = cents(draft.budgetUnitPrice)
|
||||
|
||||
Reference in New Issue
Block a user