mirror of
https://github.com/cjango/dcat-vue.git
synced 2025-12-06 22:40:03 +08:00
新增选择组件,一些优化
This commit is contained in:
@@ -80,6 +80,11 @@
|
|||||||
->disableRegions([440000]) // 禁用一些区划
|
->disableRegions([440000]) // 禁用一些区划
|
||||||
->mapZoom(11); // 地图默认缩放
|
->mapZoom(11); // 地图默认缩放
|
||||||
->mapZoom(11, 'zoom') // 记录地图缩放级别
|
->mapZoom(11, 'zoom') // 记录地图缩放级别
|
||||||
|
|
||||||
|
$form->vSelect('select')
|
||||||
|
->options(['123', '456', 'A' => 'aaa']) // 选项
|
||||||
|
->concatKey('separator') // 显示键
|
||||||
|
->optionsFromKeyValue('kvs'); // 用于结合vKeyValue进行选项选择
|
||||||
```
|
```
|
||||||
|
|
||||||
[comment]: <> (### Donate)
|
[comment]: <> (### Donate)
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -15,6 +15,7 @@ use Weiwait\DcatVue\Field\KeyValue;
|
|||||||
use Weiwait\DcatVue\Field\ListField;
|
use Weiwait\DcatVue\Field\ListField;
|
||||||
use Weiwait\DcatVue\Field\MultipleFile;
|
use Weiwait\DcatVue\Field\MultipleFile;
|
||||||
use Weiwait\DcatVue\Field\MultipleImage;
|
use Weiwait\DcatVue\Field\MultipleImage;
|
||||||
|
use Weiwait\DcatVue\Field\Select;
|
||||||
use Weiwait\DcatVue\Field\Tag;
|
use Weiwait\DcatVue\Field\Tag;
|
||||||
use Weiwait\DcatVue\Field\Vue;
|
use Weiwait\DcatVue\Field\Vue;
|
||||||
use Weiwait\DcatVue\Models\FilesystemConfig;
|
use Weiwait\DcatVue\Models\FilesystemConfig;
|
||||||
@@ -41,6 +42,11 @@ class DcatVueServiceProvider extends ServiceProvider
|
|||||||
|
|
||||||
$this->hackConfigs();
|
$this->hackConfigs();
|
||||||
|
|
||||||
|
$this->exceptRoutes = [
|
||||||
|
'auth' => 'weiwait*',
|
||||||
|
'permission' => 'weiwait*',
|
||||||
|
];
|
||||||
|
|
||||||
// Form::extend('vue', Vue::class);
|
// Form::extend('vue', Vue::class);
|
||||||
Form::extend('vFile', File::class);
|
Form::extend('vFile', File::class);
|
||||||
Form::extend('vMultipleFile', MultipleFile::class);
|
Form::extend('vMultipleFile', MultipleFile::class);
|
||||||
@@ -51,6 +57,7 @@ class DcatVueServiceProvider extends ServiceProvider
|
|||||||
Form::extend('vKeyValue', KeyValue::class);
|
Form::extend('vKeyValue', KeyValue::class);
|
||||||
Form::extend('vDistpicker', Distpicker::class);
|
Form::extend('vDistpicker', Distpicker::class);
|
||||||
Form::extend('vDateRange', DateRange::class);
|
Form::extend('vDateRange', DateRange::class);
|
||||||
|
Form::extend('vSelect', Select::class);
|
||||||
|
|
||||||
Admin::requireAssets('@weiwait.dcat-vue');
|
Admin::requireAssets('@weiwait.dcat-vue');
|
||||||
}
|
}
|
||||||
|
|||||||
91
src/Field/Select.php
Normal file
91
src/Field/Select.php
Normal file
@@ -0,0 +1,91 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Weiwait\DcatVue\Field;
|
||||||
|
|
||||||
|
use Dcat\Admin\Form\Field;
|
||||||
|
use Dcat\Admin\Support\Helper;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
|
class Select extends Field\Select
|
||||||
|
{
|
||||||
|
protected $view = 'weiwait.dcat-vue::common';
|
||||||
|
private string $optionsFromKeyValueField = '';
|
||||||
|
private string $concatSeparator = '';
|
||||||
|
|
||||||
|
public function render()
|
||||||
|
{
|
||||||
|
/****************************** parent ************************************/
|
||||||
|
|
||||||
|
if (! $this->shouldRender()) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->setDefaultClass();
|
||||||
|
|
||||||
|
$this->callComposing();
|
||||||
|
|
||||||
|
$this->withScript();
|
||||||
|
|
||||||
|
/****************************** field ************************************/
|
||||||
|
|
||||||
|
$this->addDefaultConfig([
|
||||||
|
'allowClear' => true,
|
||||||
|
'placeholder' => [
|
||||||
|
'id' => '',
|
||||||
|
'text' => $this->placeholder(),
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->formatOptions();
|
||||||
|
|
||||||
|
$this->addVariables([
|
||||||
|
'options' => $this->options,
|
||||||
|
'groups' => $this->groups,
|
||||||
|
'configs' => $this->config,
|
||||||
|
'cascadeScript' => $this->getCascadeScript(),
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->initSize();
|
||||||
|
|
||||||
|
$this->attribute('data-value', implode(',', Helper::array($this->value())));
|
||||||
|
|
||||||
|
/****************************** 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' => 'Select',
|
||||||
|
'mountId' => 'id' . md5(Str::uuid()),
|
||||||
|
'optionsFromKeyValueField' => $this->optionsFromKeyValueField,
|
||||||
|
'concatSeparator' => $this->concatSeparator,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function optionsFromKeyValue(string $field): self
|
||||||
|
{
|
||||||
|
$this->optionsFromKeyValueField = $field;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function concatKey(string $separator = ': '): self
|
||||||
|
{
|
||||||
|
$this->concatSeparator = $separator;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,6 +4,7 @@ namespace Weiwait\DcatVue;
|
|||||||
|
|
||||||
use Dcat\Admin\Extend\Setting as Form;
|
use Dcat\Admin\Extend\Setting as Form;
|
||||||
use Dcat\Admin\Models\Menu;
|
use Dcat\Admin\Models\Menu;
|
||||||
|
use Weiwait\DcatVue\Models\FilesystemConfig;
|
||||||
|
|
||||||
class Setting extends Form
|
class Setting extends Form
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -49,4 +49,8 @@ return [
|
|||||||
'create_china_areas_table.php',
|
'create_china_areas_table.php',
|
||||||
'ChinaAreaTableSeeder.php',
|
'ChinaAreaTableSeeder.php',
|
||||||
],
|
],
|
||||||
|
'2.3.0' => [
|
||||||
|
'一些优化',
|
||||||
|
'新增选择组件',
|
||||||
|
],
|
||||||
];
|
];
|
||||||
|
|||||||
Reference in New Issue
Block a user