From d7698f2a2e000c74d77bb92073f5a0d5ecd59cdd Mon Sep 17 00:00:00 2001 From: liapples Date: Fri, 24 Sep 2021 19:45:19 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/AdminAgent/Controllers/AgentProductController.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/AdminAgent/Controllers/AgentProductController.php b/app/AdminAgent/Controllers/AgentProductController.php index 7a4dbcc..a369e8f 100644 --- a/app/AdminAgent/Controllers/AgentProductController.php +++ b/app/AdminAgent/Controllers/AgentProductController.php @@ -216,10 +216,10 @@ class AgentProductController extends AdminController $form->date('date', '日期')->readOnly(); $form->text('supplier_stock', '供应商库存')->disable()->customFormat(fn() => $this->product_spec['stock'] ?? 0); $form->text('supplier_price', '供应商价')->disable()->customFormat(fn() => $this->product_spec['price'] ?? 0); - $form->text('stock', '您的库存'); + $form->text('stock', '您的库存')->customFormat(fn() => isset($this->product_spec['stock'], $this->stock) && $this->stock > $this->product_spec['stock'] ? $this->product_spec['stock'] : $this->stock); $form->text('original_price', '您的原价'); $form->text('price', '您的售价'); - Admin::style('.has-many-spec .add.btn{display:;} + Admin::style('.has-many-spec .add.btn{display:none;} .has-many-spec .field_date{width:100px!important;} .has-many-spec .col-md-12{padding:0;} .has-many-spec .form-group{margin-bottom:0;} @@ -398,6 +398,9 @@ class AgentProductController extends AdminController } $form->hidden(['stock', 'price']); + if (!$form->spec) { + return $form->response()->error('请选择产品,并设置产品规格'); + } $spec = array_filter($form->spec, fn($v) => !$v['_remove_']); $form->stock = array_sum(array_column($spec, 'stock')); $form->original_price = min(array_column($spec, 'original_price'));