mirror of
https://github.com/cjango/dcat-vue.git
synced 2025-12-06 22:40:03 +08:00
new! number component
This commit is contained in:
@@ -99,6 +99,15 @@
|
||||
->options(['123', '456', 'A' => 'aaa']) // 选项
|
||||
->concatKey('separator') // 显示键
|
||||
->optionsFromKeyValue('kvs'); // 用于结合vKeyValue进行选项选择
|
||||
|
||||
$form->vNumber('number', '数字')
|
||||
->prepend('$') // 前缀
|
||||
->prepend('p') // 后缀
|
||||
->bothButton() // 按钮位置分离到两端
|
||||
->step(2) // 步进
|
||||
->min(2) // 最小值
|
||||
->max(88) // 最大值
|
||||
->precision(2); // 开启小数,精度
|
||||
```
|
||||
|
||||
##### 登录验证码
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -15,6 +15,7 @@ use Weiwait\DcatVue\Field\ListField;
|
||||
use Weiwait\DcatVue\Field\MultipleFile;
|
||||
use Weiwait\DcatVue\Field\MultipleImage;
|
||||
use Weiwait\DcatVue\Field\MultipleSelect;
|
||||
use Weiwait\DcatVue\Field\Number;
|
||||
use Weiwait\DcatVue\Field\Select;
|
||||
use Weiwait\DcatVue\Field\Tag;
|
||||
|
||||
@@ -57,6 +58,7 @@ class DcatVueServiceProvider extends ServiceProvider
|
||||
Form::extend('vDateRange', DateRange::class);
|
||||
Form::extend('vSelect', Select::class);
|
||||
Form::extend('vMultipleSelect', MultipleSelect::class);
|
||||
Form::extend('vNumber', Number::class);
|
||||
|
||||
Admin::requireAssets('@weiwait.dcat-vue');
|
||||
}
|
||||
|
||||
113
src/Field/Number.php
Normal file
113
src/Field/Number.php
Normal file
@@ -0,0 +1,113 @@
|
||||
<?php
|
||||
|
||||
namespace Weiwait\DcatVue\Field;
|
||||
|
||||
use Dcat\Admin\Form\Field;
|
||||
use Dcat\Admin\Support\Helper;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class Number extends Field\Number
|
||||
{
|
||||
protected $view = 'weiwait.dcat-vue::common';
|
||||
|
||||
public function render()
|
||||
{
|
||||
/****************************** parent ************************************/
|
||||
$this->addVariables([
|
||||
'prepend' => $this->prepend,
|
||||
'append' => $this->append,
|
||||
]);
|
||||
|
||||
/****************************** field ************************************/
|
||||
|
||||
$this->addVariables([
|
||||
'options' => $this->options,
|
||||
]);
|
||||
|
||||
/****************************** custom ************************************/
|
||||
|
||||
$this->withProvides();
|
||||
|
||||
$this->addVariables([
|
||||
'provides' => $this->variables(),
|
||||
]);
|
||||
|
||||
return view($this->view(), $this->variables());
|
||||
}
|
||||
|
||||
protected function formatAttributes()
|
||||
{
|
||||
return $this->attributes;
|
||||
}
|
||||
|
||||
protected function withProvides()
|
||||
{
|
||||
$this->addVariables([
|
||||
'component' => 'Number',
|
||||
'mountId' => 'id' . md5(Str::uuid()),
|
||||
]);
|
||||
}
|
||||
|
||||
public function step(int $step = 1): static
|
||||
{
|
||||
$this->addVariables([
|
||||
'step' => $step,
|
||||
]);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function precision(int|float $precision): static
|
||||
{
|
||||
$this->addVariables([
|
||||
'precision' => $precision,
|
||||
]);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function clearable(bool $clearable = true): static
|
||||
{
|
||||
$this->addVariables([
|
||||
'clearable' => $clearable,
|
||||
]);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function showButton(bool $showButton = true): static
|
||||
{
|
||||
$this->addVariables([
|
||||
'showButton' => $showButton,
|
||||
]);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function bothButton(bool $both = true): static
|
||||
{
|
||||
$this->addVariables([
|
||||
'bothButton' => $both,
|
||||
]);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function min($value): static
|
||||
{
|
||||
$this->addVariables([
|
||||
'min' => $value,
|
||||
]);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function max($value): static
|
||||
{
|
||||
$this->addVariables([
|
||||
'max' => $value,
|
||||
]);
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -95,4 +95,7 @@ return [
|
||||
'2.7.2' => [
|
||||
'bug fixed',
|
||||
],
|
||||
'2.8.0' => [
|
||||
'new! number component',
|
||||
],
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user