采购单优化

This commit is contained in:
liu
2026-08-17 18:13:33 +08:00
parent a06c45dc49
commit 3dbb9205a4
16 changed files with 2215 additions and 437 deletions
@@ -0,0 +1,45 @@
<?php
namespace App\Http\Requests\Purchase;
use Modules\Common\Http\Requests\BaseFormRequest;
/**
* 采购单门店单品 新增/修改 验证(amount = 数量×单价 由后端重算)
*/
class PurchaseStoreItemRequest extends BaseFormRequest
{
protected $stopOnFirstFailure = true;
public function rules(): array
{
if ($this->isUpdate()) {
return [
'quantity' => 'required|integer|min:0',
'price' => 'nullable|numeric|min:0',
'weight' => 'nullable|numeric|min:0',
];
}
return [
'product_id' => 'required|integer|exists:product,id',
'quantity' => 'required|integer|min:1',
'weight' => 'nullable|numeric|min:0',
];
}
public function messages(): array
{
return [
'product_id.required' => '请选择商品',
'product_id.exists' => '商品不存在或已删除',
'quantity.required' => '采购数量不能为空',
'quantity.integer' => '采购数量必须为整数',
'quantity.min' => '采购数量不能小于 0',
'price.numeric' => '单价必须为数字',
'price.min' => '单价不能小于 0',
'weight.numeric' => '称重必须为数字',
'weight.min' => '称重不能小于 0',
];
}
}