Browse Source

修改BUG

master
李可松 4 years ago
parent
commit
d7698f2a2e
  1. 7
      app/AdminAgent/Controllers/AgentProductController.php

7
app/AdminAgent/Controllers/AgentProductController.php

@ -216,10 +216,10 @@ class AgentProductController extends AdminController
$form->date('date', '日期')->readOnly(); $form->date('date', '日期')->readOnly();
$form->text('supplier_stock', '供应商库存')->disable()->customFormat(fn() => $this->product_spec['stock'] ?? 0); $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('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('original_price', '您的原价');
$form->text('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 .field_date{width:100px!important;}
.has-many-spec .col-md-12{padding:0;} .has-many-spec .col-md-12{padding:0;}
.has-many-spec .form-group{margin-bottom:0;} .has-many-spec .form-group{margin-bottom:0;}
@ -398,6 +398,9 @@ class AgentProductController extends AdminController
} }
$form->hidden(['stock', 'price']); $form->hidden(['stock', 'price']);
if (!$form->spec) {
return $form->response()->error('请选择产品,并设置产品规格');
}
$spec = array_filter($form->spec, fn($v) => !$v['_remove_']); $spec = array_filter($form->spec, fn($v) => !$v['_remove_']);
$form->stock = array_sum(array_column($spec, 'stock')); $form->stock = array_sum(array_column($spec, 'stock'));
$form->original_price = min(array_column($spec, 'original_price')); $form->original_price = min(array_column($spec, 'original_price'));

Loading…
Cancel
Save