add cms banners

This commit is contained in:
JaguarJack
2021-05-26 20:35:19 +08:00
parent 4b30123aa4
commit af8e6c3f5d
4 changed files with 150 additions and 0 deletions

View File

@@ -0,0 +1,49 @@
<?php
namespace catchAdmin\cms\tables;
use catcher\CatchTable;
use catchAdmin\cms\tables\forms\Factory;
use catcher\library\table\Actions;
use catcher\library\table\HeaderItem;
class Banners extends CatchTable
{
public function table()
{
// TODO: Implement table() method.
return $this->getTable('banners')
->header([
HeaderItem::label('编号')->prop('id')->width(50),
HeaderItem::label('分类')->prop('category'),
HeaderItem::label('标题')->prop('title'),
HeaderItem::label('图片')->prop('banner_img')->withPreviewComponent(),
HeaderItem::label('外链')->prop('link_to')->withUrlComponent(),
HeaderItem::label('创建者')->prop('creator'),
HeaderItem::label('创建时间')->prop('created_at'),
HeaderItem::label('操作')->actions([
Actions::update(),
Actions::delete()
])
])
->withActions([
Actions::create()
])
->withBind()
->withApiRoute('cms/banners')
->render();
}
protected function form()
{
// TODO: Implement form() method.
return Factory::create('banners');
}
}

View File

@@ -0,0 +1,38 @@
<?php
namespace catchAdmin\cms\tables\forms;
use catchAdmin\cms\model\Category;
use catcher\library\form\Form;
class Banners extends Form
{
public function fields(): array
{
$categories = Category::field(['id', 'name', 'parent_id'])->select()->toTree();
// TODO: Implement fields() method.
return [
self::cascader('category_id', '选择分类', [])
->options($categories)
->clearable(true)
->filterable(true)
->showAllLevels(false)
->props([
'props' => [
'value' => 'id',
'label' => 'name',
'checkStrictly' => true
],
])->style(['width' => '100%'])
->required(),
self::input('title', '标题')->placeholder('请输入标题')->required(),
self::image('图片', 'banner_img'),
self::input('link_to', '外链')->appendValidate([
self::validateUrl()
])
];
}
}