优化表单配置

This commit is contained in:
pushuo 2022-08-12 12:00:30 +08:00
parent 78a932ea7a
commit ede0cd9fe2
5 changed files with 10 additions and 28 deletions

View File

@ -10,14 +10,16 @@ class Input extends Component
public string $title;
public string $value;
public string $class;
public string $width;
public bool $required;
public function __construct(string $name, string $title, ?string $value, bool $required = false, ?string $class = '')
public function __construct(string $name, string $title, ?string $value, bool $required = false, ?string $class = '', ?string $width = '400')
{
$this->name = $name;
$this->title = $title;
$this->value = $value;
$this->class = $class;
$this->width = $width;
$this->required = $required;
}

View File

@ -9,13 +9,15 @@ class InputLocale extends Component
{
public string $name;
public string $title;
public string $width;
public $value;
public function __construct(string $name, string $title, $value)
public function __construct(string $name, string $title, $value, ?string $width = '400')
{
$this->name = $name;
$this->title = $title;
$this->value = $value;
$this->width = $width;
}
public function render()

View File

@ -1,6 +1,6 @@
<x-admin::form.row :title="$title">
@foreach (locales() as $index => $locale)
<div class="d-flex wp-400">
<div class="d-flex wp-{{ $width }}">
<span class="input-group-text wp-100 px-1" id="basic-addon1">{{ $locale['name'] }}</span>
<input type="text" name="{{ $formatName($locale['code']) }}" value="{{ $formatValue($locale['code']) }}" class="form-control short" placeholder="{{ $locale['name'] }}">
</div>
@ -11,25 +11,3 @@
@endif
@endforeach
</x-admin::form.row>
@if (0)
<div class="el-form-item el-form-item--small">
<label for="" class="el-form-item__label" style="width: 200px">{{ $title }}</label>
<div class="el-form-item__content" style="margin-left: 200px">
<div style="max-width: 400px;">
@foreach (locales() as $index => $locale)
<div class="mb-1 el-input el-input--small el-input-group el-input-group--append">
<input type="text" class="el-input__inner" name="{{ $formatName($locale['code']) }}" placeholder="{{ $locale['name'] }}" value="{{ $formatValue($locale['code']) }}">
<div class="el-input-group__append">{{ $locale['name'] }}</div>
</div>
@if ($attributes->has('required'))
@error($errorKey($locale['code']))
<x-admin::form.error :message="$message" />
@enderror
@endif
@endforeach
</div>
</div>
</div>
@endif

View File

@ -1,4 +1,4 @@
<x-admin::form.row :title="$title" :required="$required">
<input type="text" name="{{ $name }}" class="form-control wp-400 {{ $class }}" value="{{ $value }}" placeholder="{{ $title }}">
<input type="text" name="{{ $name }}" class="form-control wp-{{ $width }} {{ $class }}" value="{{ $value }}" placeholder="{{ $title }}">
{{ $slot }}
</x-admin::form.row>

View File

@ -33,7 +33,7 @@
<div class="tab-content">
<div class="tab-pane fade show active" id="tab-basic">
<h6 class="border-bottom pb-3 mb-4">数据</h6>
<x-admin-form-input-locale name="descriptions.*.name" title="名称" :value="$descriptions" required />
<x-admin-form-input-locale :width="600" name="descriptions.*.name" title="名称" :value="$descriptions" required />
<x-admin::form.row title="图片">
<draggable
element="div"
@ -66,7 +66,7 @@
<x-admin-form-switch name="active" title="状态" :value="old('active', $product->active ?? 1)" />
<x-admin::form.row title="分类">
<div class="wp-400 form-control" style="max-height: 300px;overflow-y: auto">
<div class="wp-400 form-control" style="max-height: 240px;overflow-y: auto">
@foreach ($source['categories'] as $_category)
<div class="form-check">
<input class="form-check-input" type="checkbox" name="categories[]" value="{{ $_category->id }}"