优化商品详情页验证
This commit is contained in:
parent
ed6eea3382
commit
b88afed286
|
|
@ -11,15 +11,17 @@ class Input extends Component
|
|||
public string $value;
|
||||
public string $error;
|
||||
public string $width;
|
||||
public string $type;
|
||||
public bool $required;
|
||||
|
||||
public function __construct(string $name, string $title, ?string $value, bool $required = false, ?string $error = '', ?string $width = '400')
|
||||
public function __construct(string $name, string $title, ?string $value, bool $required = false, ?string $error = '', ?string $width = '400', ?string $type = 'text')
|
||||
{
|
||||
$this->name = $name;
|
||||
$this->title = $title;
|
||||
$this->value = $value;
|
||||
$this->error = $error;
|
||||
$this->width = $width;
|
||||
$this->type = $type;
|
||||
$this->required = $required;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
<x-admin::form.row :title="$title" :required="$required">
|
||||
<input type="text" name="{{ $name }}"
|
||||
<input type="{{ $type }}" name="{{ $name }}"
|
||||
class="form-control wp-{{ $width }} {{ $error ? 'is-invalid' : '' }}" value="{{ $value }}"
|
||||
placeholder="{{ $title }}" @if ($required) required @endif>
|
||||
<span class="invalid-feedback" role="alert">
|
||||
|
|
|
|||
|
|
@ -11,14 +11,17 @@
|
|||
@endpush
|
||||
|
||||
@section('content')
|
||||
|
||||
@if ($errors->has('error'))
|
||||
<x-admin-alert type="danger" msg="{{ $errors->first('error') }}" class="mt-4" />
|
||||
<x-admin-alert type="danger" msg="{{ $errors->first('error') }}" class="mt-4" />
|
||||
@endif
|
||||
|
||||
|
||||
@if ($errors->any())
|
||||
@dump($errors)
|
||||
<div class="alert alert-danger">
|
||||
@foreach ($errors->all() as $error)
|
||||
<div>{{ $error }}</div>
|
||||
@endforeach
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<ul class="nav nav-tabs nav-bordered mb-3" role="tablist">
|
||||
|
|
@ -200,16 +203,16 @@
|
|||
<span v-if="sku.is_default" class="text-success">{{ __('admin/product.default_main_product') }}</span>
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" class="form-control" v-model="sku.price" :name="'skus[' + skuIndex + '][price]'"
|
||||
<input type="number" class="form-control" v-model="sku.price" :name="'skus[' + skuIndex + '][price]'"
|
||||
placeholder="{{ __('admin/product.price') }}" required>
|
||||
<span role="alert" class="invalid-feedback">{{ __('common.error_required', ['name' => __('admin/product.price')]) }}</span>
|
||||
</td>
|
||||
<td><input type="text" class="form-control" v-model="sku.origin_price" :name="'skus[' + skuIndex + '][origin_price]'"
|
||||
<td><input type="number" class="form-control" v-model="sku.origin_price" :name="'skus[' + skuIndex + '][origin_price]'"
|
||||
placeholder="{{ __('admin/product.origin_price') }}"></td>
|
||||
<td><input type="text" class="form-control" v-model="sku.cost_price" :name="'skus[' + skuIndex + '][cost_price]'"
|
||||
<td><input type="number" class="form-control" v-model="sku.cost_price" :name="'skus[' + skuIndex + '][cost_price]'"
|
||||
placeholder="{{ __('admin/product.cost_price') }}">
|
||||
</td>
|
||||
<td><input type="text" class="form-control" v-model="sku.quantity" :name="'skus[' + skuIndex + '][quantity]'"
|
||||
<td><input type="number" class="form-control" v-model="sku.quantity" :name="'skus[' + skuIndex + '][quantity]'"
|
||||
placeholder="{{ __('admin/product.quantity') }}"></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
|
@ -225,10 +228,10 @@
|
|||
<input type="hidden" value="{{ old('skus.0.image', $product->skus[0]->image ?? '') }}" name="skus[0][image]">
|
||||
<x-admin-form-input name="skus[0][model]" :title="__('admin/product.model')" :value="old('skus.0.model', $product->skus[0]->model ?? '')" />
|
||||
<x-admin-form-input name="skus[0][sku]" title="sku" :value="old('skus.0.sku', $product->skus[0]->sku ?? '')" required />
|
||||
<x-admin-form-input name="skus[0][price]" :title="__('admin/product.price')" :value="old('skus.0.price', $product->skus[0]->price ?? '')" required />
|
||||
<x-admin-form-input name="skus[0][origin_price]" :title="__('admin/product.origin_price')" :value="old('skus.0.origin_price', $product->skus[0]->origin_price ?? '')" />
|
||||
<x-admin-form-input name="skus[0][cost_price]" :title="__('admin/product.cost_price')" :value="old('skus.0.cost_price', $product->skus[0]->cost_price ?? '')" />
|
||||
<x-admin-form-input name="skus[0][quantity]" :title="__('admin/product.quantity')" :value="old('skus.0.quantity', $product->skus[0]->quantity ?? '')" />
|
||||
<x-admin-form-input name="skus[0][price]" type="number" :title="__('admin/product.price')" :value="old('skus.0.price', $product->skus[0]->price ?? '')" required />
|
||||
<x-admin-form-input name="skus[0][origin_price]" type="number" :title="__('admin/product.origin_price')" :value="old('skus.0.origin_price', $product->skus[0]->origin_price ?? '')" />
|
||||
<x-admin-form-input name="skus[0][cost_price]" type="number" :title="__('admin/product.cost_price')" :value="old('skus.0.cost_price', $product->skus[0]->cost_price ?? '')" />
|
||||
<x-admin-form-input name="skus[0][quantity]" type="number" :title="__('admin/product.quantity')" :value="old('skus.0.quantity', $product->skus[0]->quantity ?? '')" />
|
||||
<input type="hidden" name="skus[0][variants]" placeholder="variants" value="">
|
||||
<input type="hidden" name="skus[0][position]" placeholder="position" value="0">
|
||||
<input type="hidden" name="skus[0][is_default]" placeholder="is_default" value="1">
|
||||
|
|
|
|||
Loading…
Reference in New Issue