85 lines
3.1 KiB
PHP
85 lines
3.1 KiB
PHP
<?php
|
||
|
||
namespace App\Admin;
|
||
|
||
use App\Models\Keyword;
|
||
use Slowlyo\OwlAdmin\Renderers\BaseRenderer;
|
||
|
||
class Components extends BaseRenderer {
|
||
|
||
/**
|
||
* 父级选择器
|
||
*/
|
||
public function parentControl($apiUrl = '', $name ='parent_id', $label ='父级', $labelField = 'name', $valueField = 'id')
|
||
{
|
||
return amisMake()->TreeSelectControl()
|
||
->name($name)->label($label)
|
||
->showIcon(false)
|
||
->labelField($labelField)
|
||
->valueField($valueField)->source($apiUrl);
|
||
}
|
||
|
||
/**
|
||
* 排序字段
|
||
*/
|
||
public function sortControl($name ='sort', $label = '排序'){
|
||
return amisMake()->NumberControl()
|
||
->name($name)->label($label)
|
||
->displayMode('enhance')
|
||
->value(0)
|
||
->min(0);
|
||
}
|
||
|
||
/**
|
||
* 2位小数输入框
|
||
*/
|
||
public function decimalControl($name ='decimal', $label = '数值'){
|
||
return amisMake()->NumberControl()
|
||
->name($name)->label($label)
|
||
->kilobitSeparator(true)
|
||
->percision(2)
|
||
->step(0.01)
|
||
->value(0.00)
|
||
->min(0);
|
||
}
|
||
|
||
/**
|
||
* 富文本编辑器
|
||
*/
|
||
public function fuEditorControl($name ='content', $label = '内容', $uploadUrl = ''){
|
||
return amisMake()->RichTextControl()->vendor('tinymce')
|
||
->options([
|
||
"menubar" => false,
|
||
"min_height" => 500,
|
||
"toolbar" => "undo redo | bold italic underline strikethrough | fontfamily fontsize blocks | alignleft aligncenter alignright alignjustify | image link | outdent indent | numlist bullist | forecolor backcolor removeformat | charmap emoticons",
|
||
"help_tabs" => [],
|
||
"convert_urls" => false,
|
||
"quickbars_selection_toolbar" => "fontsize forecolor backcolor",
|
||
"toolbar_mode" => "wrap",
|
||
"quickbars_insert_toolbar" => false,
|
||
])
|
||
->name($name)->label($label);
|
||
|
||
//froala去除授权提示;(但是保存会有额外内容,需要处理)
|
||
//<style type="text/css">
|
||
// a[href="https://froala.com/wysiwyg-editor"], a[href="https://www.froala.com/wysiwyg-editor?k=u"]{
|
||
// display: none !important;
|
||
// position: absolute;
|
||
// top: -99999999px;
|
||
// }
|
||
// </style>
|
||
}
|
||
|
||
public function enableControl($name = 'is_enable', $label= '状态', $mode = 'horizontal'){
|
||
return amisMake()->SwitchControl()
|
||
->name($name)->label($label)
|
||
->mode($mode)
|
||
->onText(__('admin.extensions.status_map.enabled'))->offText(__('admin.extensions.status_map.disabled'));
|
||
}
|
||
|
||
public function keywordsTagControl($name = 'tags', $label= '标签', $typeKey = ''){
|
||
return amisMake()->TagControl()
|
||
->name($name)->label($label)
|
||
->options(Keyword::getByParentKey($typeKey)->pluck('name', 'id')->toArray());
|
||
}
|
||
} |