cms first commit
This commit is contained in:
47
catch/cms/tables/Articles.php
Normal file
47
catch/cms/tables/Articles.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?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 Articles extends CatchTable
|
||||
{
|
||||
public function table()
|
||||
{
|
||||
// TODO: Implement table() method.
|
||||
return $this->getTable('articles')
|
||||
->header([
|
||||
HeaderItem::label('编号')->prop('id'),
|
||||
|
||||
HeaderItem::label('栏目')->prop('category'),
|
||||
|
||||
HeaderItem::label('标题')->prop('title'),
|
||||
|
||||
HeaderItem::label('权重')->prop('weight')->withEditNumberComponent(),
|
||||
|
||||
HeaderItem::label('状态')->prop('status')->withSwitchComponent(),
|
||||
|
||||
HeaderItem::label('创建时间')->prop('created_at'),
|
||||
|
||||
HeaderItem::label('操作')->actions([
|
||||
Actions::update()->to('/cms/articles/detail'),
|
||||
Actions::delete()
|
||||
])
|
||||
])
|
||||
->withBind()
|
||||
->withApiRoute('cms/articles')
|
||||
->withActions([
|
||||
Actions::create()->to('/cms/articles/detail/')
|
||||
])
|
||||
->render();
|
||||
}
|
||||
|
||||
protected function form()
|
||||
{
|
||||
// TODO: Implement form() method.
|
||||
return Factory::create('articles');
|
||||
}
|
||||
|
||||
}
|
59
catch/cms/tables/Category.php
Normal file
59
catch/cms/tables/Category.php
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
namespace catchAdmin\cms\tables;
|
||||
|
||||
use catchAdmin\cms\tables\forms\Factory;
|
||||
use catcher\CatchTable;
|
||||
use catcher\library\table\Actions;
|
||||
use catcher\library\table\Excel;
|
||||
use catcher\library\table\HeaderItem;
|
||||
use catcher\library\table\Search;
|
||||
|
||||
class Category extends CatchTable
|
||||
{
|
||||
public function table()
|
||||
{
|
||||
// TODO: Implement table() method.
|
||||
return $this->getTable('category')
|
||||
->header([
|
||||
HeaderItem::label('分类名称')->prop('name'),
|
||||
HeaderItem::label('自定义链接')->prop('url')->withCopyComponent(),
|
||||
HeaderItem::label('栏目类型')->prop('type')->withSelectComponent([
|
||||
['value' => 1, 'label' => '列表模式'],
|
||||
['value' => 2, 'label' => '单页模式'],
|
||||
['value' => 3, 'label' => '封面模式'],
|
||||
]),
|
||||
HeaderItem::label('投稿')->prop('is_can_contribute')->withSwitchComponent([
|
||||
['value' => 1, 'label' => '是'],
|
||||
['value' => 2, 'label' => '否'],
|
||||
]),
|
||||
HeaderItem::label('评论')->prop('is_can_comment')->withSwitchComponent(),
|
||||
HeaderItem::label('状态')->prop('status')->withSwitchComponent(),
|
||||
HeaderItem::label('权重')->prop('weight')->withEditNumberComponent(),
|
||||
// HeaderItem::label('创建时间')->prop('created_at'),
|
||||
HeaderItem::label('操作')->actions([
|
||||
Actions::update(),
|
||||
Actions::delete()
|
||||
])->width(230)
|
||||
])
|
||||
->withActions([
|
||||
Actions::create()
|
||||
])
|
||||
->withSearch([
|
||||
Search::label('分类名称')->name('请输入分类名称'),
|
||||
Search::label('状态')->status(),
|
||||
])
|
||||
->forceUpdate()
|
||||
->withApiRoute('cms/category')
|
||||
->toTreeTable()
|
||||
->withDialogWidth('40%')
|
||||
->render();
|
||||
}
|
||||
|
||||
public function form()
|
||||
{
|
||||
// TODO: Implement form() method.
|
||||
return Factory::create('category');
|
||||
}
|
||||
|
||||
|
||||
}
|
50
catch/cms/tables/Fields.php
Normal file
50
catch/cms/tables/Fields.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
namespace catchAdmin\cms\tables;
|
||||
|
||||
use catchAdmin\cms\tables\forms\Factory;
|
||||
use catcher\CatchTable;
|
||||
use catcher\library\table\Actions;
|
||||
use catcher\library\table\HeaderItem;
|
||||
use catcher\library\table\Search;
|
||||
|
||||
class Fields extends CatchTable
|
||||
{
|
||||
public function table()
|
||||
{
|
||||
return $this->getTable('fields')
|
||||
->header([
|
||||
HeaderItem::label('编号')->prop('id')->width(80),
|
||||
HeaderItem::label('字段名称')->prop('name'),
|
||||
HeaderItem::label('label名称')->prop('title'),
|
||||
HeaderItem::label('类型')->prop('type'),
|
||||
// HeaderItem::label('列表显示')->prop('use_at_list')->withSwitchComponent( ),
|
||||
// HeaderItem::label('搜索')->prop('use_at_search')->withSwitchComponent(),
|
||||
// HeaderItem::label('详情')->prop('use_at_detail')->withSwitchComponent(),
|
||||
HeaderItem::label('状态')->prop('status')->withSwitchComponent( ),
|
||||
HeaderItem::label('设置索引')->prop('is_index')->withSwitchComponent( ),
|
||||
|
||||
HeaderItem::label('操作')->width(260)->isBubble()->actions([
|
||||
Actions::update(),
|
||||
Actions::delete()
|
||||
]),
|
||||
])
|
||||
->withActions([
|
||||
Actions::create(),
|
||||
])
|
||||
->withSearch([
|
||||
Search::hidden('model_id', '')
|
||||
])
|
||||
->withHiddenPaginate()
|
||||
->withDialogWidth('40%')
|
||||
->withDefaultQueryParams(['model_id'])
|
||||
->withBind()
|
||||
->withApiRoute('cms/modelFields')
|
||||
->render();
|
||||
}
|
||||
|
||||
public function form()
|
||||
{
|
||||
// TODO: Implement form() method.
|
||||
return Factory::create('field');
|
||||
}
|
||||
}
|
48
catch/cms/tables/Model.php
Normal file
48
catch/cms/tables/Model.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
namespace catchAdmin\cms\tables;
|
||||
|
||||
use catchAdmin\cms\tables\forms\Factory;
|
||||
use catcher\CatchTable;
|
||||
use catcher\library\table\Actions;
|
||||
use catcher\library\table\HeaderItem;
|
||||
use catcher\library\table\Search;
|
||||
|
||||
class Model extends CatchTable
|
||||
{
|
||||
public function table()
|
||||
{
|
||||
// TODO: Implement table() method.
|
||||
return $this->getTable('model')
|
||||
->header([
|
||||
HeaderItem::label('编号')->prop('id'),
|
||||
HeaderItem::label('模型名称')->prop('name'),
|
||||
HeaderItem::label('模型别名')->prop('alias'),
|
||||
HeaderItem::label('模型关联表')->prop('table_name'),
|
||||
HeaderItem::label('模型信息')->prop('')->width(200)->component('operate'),
|
||||
HeaderItem::label('创建时间')->prop('created_at'),
|
||||
HeaderItem::label('操作')->actions([
|
||||
Actions::update(),
|
||||
Actions::delete()
|
||||
])->width(230)
|
||||
])
|
||||
->withActions([
|
||||
Actions::create()
|
||||
])
|
||||
->withSearch([
|
||||
Search::label('模型名称')->name('请填写模型名称'),
|
||||
])
|
||||
->forceUpdate()
|
||||
->withApiRoute('cms/model')
|
||||
->toTreeTable()
|
||||
->withDialogWidth('40%')
|
||||
->render();
|
||||
}
|
||||
|
||||
public function form()
|
||||
{
|
||||
// TODO: Implement form() method.
|
||||
return Factory::create('model');
|
||||
}
|
||||
|
||||
|
||||
}
|
21
catch/cms/tables/ModelUsedFields.php
Normal file
21
catch/cms/tables/ModelUsedFields.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
namespace catchAdmin\cms\tables;
|
||||
|
||||
use catcher\CatchTable;
|
||||
use catchAdmin\cms\tables\forms\Factory;
|
||||
|
||||
class ModelUsedFields extends CatchTable
|
||||
{
|
||||
public function table()
|
||||
{
|
||||
// TODO: Implement table() method.
|
||||
return [];
|
||||
}
|
||||
|
||||
protected function form()
|
||||
{
|
||||
// TODO: Implement form() method.
|
||||
return Factory::create('ModelUsedFields');
|
||||
}
|
||||
|
||||
}
|
45
catch/cms/tables/SiteLink.php
Normal file
45
catch/cms/tables/SiteLink.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
namespace catchAdmin\cms\tables;
|
||||
|
||||
use catcher\CatchTable;
|
||||
use catchAdmin\cms\tables\forms\Factory;
|
||||
use catcher\library\table\Actions;
|
||||
use catcher\library\table\HeaderItem;
|
||||
use catcher\library\table\Search;
|
||||
|
||||
class SiteLink extends CatchTable
|
||||
{
|
||||
public function table()
|
||||
{
|
||||
// TODO: Implement table() method.
|
||||
return $this->getTable('SiteLink')
|
||||
->header([
|
||||
HeaderItem::label('标题')->prop('title'),
|
||||
HeaderItem::label('地址')->prop('link_to')->width(400)->withUrlComponent(),
|
||||
HeaderItem::label('图标')->prop('icon')->width(120)->withPreviewComponent(),
|
||||
HeaderItem::label('展示')->prop('is_show')->width(120)->withSwitchComponent(),
|
||||
HeaderItem::label('权重')->prop('weight')->width(120)->withEditNumberComponent(),
|
||||
HeaderItem::label('操作')->actions([
|
||||
Actions::update(),
|
||||
Actions::delete()
|
||||
])
|
||||
])
|
||||
->withActions([
|
||||
Actions::create()
|
||||
])
|
||||
->withSearch([
|
||||
Search::label('网站标题')->input('title', '请输入网站标题')
|
||||
])
|
||||
->withBind()
|
||||
->withDialogWidth('40%')
|
||||
->withApiRoute('cms/site/links')
|
||||
->render();
|
||||
}
|
||||
|
||||
protected function form()
|
||||
{
|
||||
// TODO: Implement form() method.
|
||||
return Factory::create('SiteLink');
|
||||
}
|
||||
|
||||
}
|
45
catch/cms/tables/Tags.php
Normal file
45
catch/cms/tables/Tags.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
namespace catchAdmin\cms\tables;
|
||||
|
||||
use catcher\CatchTable;
|
||||
use catchAdmin\cms\tables\forms\Factory;
|
||||
use catcher\library\table\Actions;
|
||||
use catcher\library\table\HeaderItem;
|
||||
use catcher\library\table\Search;
|
||||
|
||||
class Tags extends CatchTable
|
||||
{
|
||||
public function table()
|
||||
{
|
||||
// TODO: Implement table() method.
|
||||
return $this->getTable('tags')
|
||||
->header([
|
||||
HeaderItem::label('编号')->prop('id'),
|
||||
|
||||
HeaderItem::label('名称')->prop('name'),
|
||||
|
||||
HeaderItem::label('创建时间')->prop('created_at'),
|
||||
|
||||
HeaderItem::label('操作')->actions([
|
||||
Actions::update(),
|
||||
Actions::delete()
|
||||
])
|
||||
])
|
||||
->withBind()
|
||||
->withSearch([
|
||||
Search::label('名称')->name('请输入标签名称')
|
||||
])
|
||||
->withApiRoute('cms/tags')
|
||||
->withActions([
|
||||
Actions::create()
|
||||
])
|
||||
->render();
|
||||
}
|
||||
|
||||
protected function form()
|
||||
{
|
||||
// TODO: Implement form() method.
|
||||
return Factory::create('tags');
|
||||
}
|
||||
|
||||
}
|
21
catch/cms/tables/UsedAt.php
Normal file
21
catch/cms/tables/UsedAt.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
namespace catchAdmin\cms\tables;
|
||||
|
||||
use catcher\CatchTable;
|
||||
use catchAdmin\cms\tables\forms\Factory;
|
||||
|
||||
class UsedAt extends CatchTable
|
||||
{
|
||||
public function table()
|
||||
{
|
||||
// TODO: Implement table() method.
|
||||
return [];
|
||||
}
|
||||
|
||||
protected function form()
|
||||
{
|
||||
// TODO: Implement form() method.
|
||||
return Factory::create('UsedAt');
|
||||
}
|
||||
|
||||
}
|
71
catch/cms/tables/forms/Articles.php
Normal file
71
catch/cms/tables/forms/Articles.php
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
namespace catchAdmin\cms\tables\forms;
|
||||
|
||||
use catchAdmin\cms\model\Tags;
|
||||
use catcher\library\form\Form;
|
||||
use catchAdmin\cms\model\Articles as Article;
|
||||
use catchAdmin\cms\model\Category;
|
||||
|
||||
class Articles extends Form
|
||||
{
|
||||
public function fields(): array
|
||||
{
|
||||
// TODO: Implement fields() method.
|
||||
return [
|
||||
self::input('title', '标题')->required()->maxlength(100)->col(12),
|
||||
|
||||
self::cascader('category_id', '选择分类')
|
||||
->options(
|
||||
Category::field(['id', 'name', 'parent_id'])->select()->toTree()
|
||||
)
|
||||
->col(12)
|
||||
->props(self::props('name', 'id', [
|
||||
'checkStrictly' => true
|
||||
]))
|
||||
->filterable(true)
|
||||
->clearable(true)
|
||||
->style(['width' => '100%'])
|
||||
->required()->col(8),
|
||||
|
||||
self::input('keywords', '关键字')->col(12),
|
||||
|
||||
self::image('封面', 'cover')->col(12),
|
||||
|
||||
self::textarea('description', '摘要')->col(12),
|
||||
|
||||
self::images('组图', 'images')->col(12),
|
||||
|
||||
self::selectMultiple('tags', '标签')
|
||||
->options(Tags::field(['name as value', 'name as label'])->select()->toArray())
|
||||
->clearable(true)
|
||||
->allowCreate(true)
|
||||
->filterable(true)
|
||||
->style(['width' => '100%'])
|
||||
->col(12),
|
||||
|
||||
self::input('url', '自定义URL')->col(8),
|
||||
|
||||
self::editor('content', '内容')->required(),
|
||||
|
||||
self::radio('is_top', '置顶', Article::UN_TOP)->options(
|
||||
self::options()->add('是', Article::TOP)
|
||||
->add('否', Article::UN_TOP)->render()
|
||||
),
|
||||
|
||||
self::radio('is_recommend', '推荐', Article::UN_RECOMMEND)->options(
|
||||
self::options()->add('是', Article::RECOMMEND)
|
||||
->add('否', Article::UN_RECOMMEND)->render()
|
||||
),
|
||||
|
||||
self::radio('status', '展示', Article::ENABLE)->options(
|
||||
self::options()->add('是', Article::ENABLE)
|
||||
->add('否', Article::DISABLE)->render()
|
||||
),
|
||||
|
||||
self::radio('is_can_comment', '允许评论', Article::UN_CAN_COMMENT)->options(
|
||||
self::options()->add('是', Article::CAN_COMMENT)
|
||||
->add('否', Article::UN_CAN_COMMENT)->render()
|
||||
),
|
||||
];
|
||||
}
|
||||
}
|
22
catch/cms/tables/forms/BaseForm.php
Normal file
22
catch/cms/tables/forms/BaseForm.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
namespace catchAdmin\cms\tables\forms;
|
||||
|
||||
use catchAdmin\cms\model\Category as CategoryModel;
|
||||
use catchAdmin\cms\support\DynamicFormFields;
|
||||
use catcher\library\form\Form;
|
||||
|
||||
abstract class BaseForm extends Form
|
||||
{
|
||||
protected $table = null;
|
||||
|
||||
public function create(): array
|
||||
{
|
||||
$fields = parent::create(); // TODO: Change the autogenerated stub
|
||||
|
||||
if ($this->table) {
|
||||
return array_merge($fields, (new DynamicFormFields())->build($this->table));
|
||||
}
|
||||
|
||||
return $fields;
|
||||
}
|
||||
}
|
73
catch/cms/tables/forms/Category.php
Normal file
73
catch/cms/tables/forms/Category.php
Normal file
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | Catch-CMS Design On 2020
|
||||
// +----------------------------------------------------------------------
|
||||
// | CatchAdmin [Just Like ~ ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2017~2020 http://catchadmin.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( https://github.com/yanwenwu/catch-admin/blob/master/LICENSE.txt )
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: JaguarJack [ njphper@gmail.com ]
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace catchAdmin\cms\tables\forms;
|
||||
|
||||
use catchAdmin\cms\model\Category as CategoryModel;
|
||||
use catcher\library\form\Form;
|
||||
|
||||
class Category extends BaseForm
|
||||
{
|
||||
protected $table = 'cms_category';
|
||||
|
||||
/**
|
||||
* create form
|
||||
*
|
||||
* @time 2021年03月02日
|
||||
* @return array
|
||||
*/
|
||||
public function fields(): array
|
||||
{
|
||||
// TODO: Implement create() method.
|
||||
return [
|
||||
Form::input('name', '分类名称')->required(),
|
||||
Form::cascader('parent_id', '父级栏目')
|
||||
->options(CategoryModel::field(['id', 'name', 'parent_id'])->select()->toTree())->props([
|
||||
'props' => [
|
||||
'value' => 'id',
|
||||
'label' => 'name',
|
||||
'checkStrictly' => true
|
||||
]
|
||||
])->showAllLevels(false)->style(['width' => '100%']),
|
||||
|
||||
Form::input('title', 'seo标题'),
|
||||
Form::input('keywords', 'seo关键词'),
|
||||
Form::textarea('description', 'seo描述'),
|
||||
Form::input('url', '自定义URL'),
|
||||
Form::select('type', '页面类型', 1)->options([
|
||||
['value' => 1, 'label' => '列表模式'],
|
||||
['value' => 2, 'label' => '单页模式'],
|
||||
['value' => 3, 'label' => '封面模式'],
|
||||
]),
|
||||
|
||||
Form::radio('status', '状态', 1)->options(
|
||||
self::options()->add('启用', 1)
|
||||
->add('禁用', 2)->render()
|
||||
),
|
||||
|
||||
Form::radio('is_can_comment', '评论', 2)->options(
|
||||
self::options()->add('可以', 1)
|
||||
->add('不可以', 2)->render()
|
||||
),
|
||||
|
||||
Form::radio('is_can_contribute', '投稿', 2)->options(
|
||||
self::options()->add('可以', 1)
|
||||
->add('不可以', 2)->render()
|
||||
),
|
||||
|
||||
Form::number('weight', '权重', 1),
|
||||
|
||||
Form::number('limit', '每页数量', 10),
|
||||
];
|
||||
}
|
||||
}
|
12
catch/cms/tables/forms/Factory.php
Normal file
12
catch/cms/tables/forms/Factory.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
namespace catchAdmin\cms\tables\forms;
|
||||
|
||||
use catcher\library\form\FormFactory;
|
||||
|
||||
class Factory extends FormFactory
|
||||
{
|
||||
public static function from(): string
|
||||
{
|
||||
return __NAMESPACE__;
|
||||
}
|
||||
}
|
128
catch/cms/tables/forms/Field.php
Normal file
128
catch/cms/tables/forms/Field.php
Normal file
@@ -0,0 +1,128 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | Catch-CMS Design On 2020
|
||||
// +----------------------------------------------------------------------
|
||||
// | CatchAdmin [Just Like ~ ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2017~2020 http://catchadmin.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( https://github.com/yanwenwu/catch-admin/blob/master/LICENSE.txt )
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: JaguarJack [ njphper@gmail.com ]
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace catchAdmin\cms\tables\forms;
|
||||
use catcher\library\form\Form;
|
||||
|
||||
class Field extends Form
|
||||
{
|
||||
/**
|
||||
* create form
|
||||
*
|
||||
* @time 2021年03月02日
|
||||
* @return array
|
||||
*/
|
||||
public function fields(): array
|
||||
{
|
||||
// TODO: Implement create() method.
|
||||
return [
|
||||
// 字段名称
|
||||
Form::input('name', '字段名称')->required()
|
||||
->appendValidate(
|
||||
Form::validatePattern('^[a-z]{1,30}_?[a-z]{1,30}?')->message('字段名称只支持小写字母,_组合')
|
||||
)
|
||||
->placeholder('由英文和下划线组成')
|
||||
->clearable(true),
|
||||
// 字段释义
|
||||
Form::input('title', 'label名称')->required()->placeholder('表单Label')->clearable(true),
|
||||
// 字段类型
|
||||
Form::select('type', '类型')
|
||||
->required()
|
||||
->options($this->types())
|
||||
->style(['width' => '100%'])
|
||||
->appendControl('string', [Form::number('length', '长度', 1)->max(1000)->min(1)])
|
||||
->appendControl('int', [Form::number('length', '长度', 1)->max(11)->min(1)])
|
||||
->appendControl('select', [Form::textarea('options', '选项')->placeholder('格式(value|label),一个选项占用一行')])
|
||||
->appendControl('radio', [Form::textarea('options', '选项')->placeholder('格式(value|label),一个选项占用一行')])
|
||||
->appendControl('checkbox', [Form::textarea('options', '选项')->placeholder('格式(value|label),一个选项占用一行')])
|
||||
->clearable(true),
|
||||
// 默认值
|
||||
Form::input('default_value', '默认值'),
|
||||
// 加索引
|
||||
Form::radio('is_index', '加索引', 2)->options(
|
||||
self::options()->add('是', 1)
|
||||
->add('否', 2)->render()
|
||||
),
|
||||
// 值唯一
|
||||
Form::radio('is_unique', '值唯一', 2)->options(
|
||||
self::options()->add('是', 1)
|
||||
->add('否', 2)->render()
|
||||
),
|
||||
// 表单验证规则
|
||||
Form::selectMultiple('rules', '验证规则')
|
||||
->options($this->rules()),
|
||||
// 正则验证
|
||||
Form::input('pattern', '正则验证')->placeholder('格式如下(正则|提示信息)'),
|
||||
// 排序
|
||||
Form::number('sort', '排序', 1)->max(10000)->min(1),
|
||||
// 字段是否在表单中显示
|
||||
Form::radio('status', '状态', 1)->options(
|
||||
self::options()->add('正常', 1)
|
||||
->add('隐藏', 2)->render()
|
||||
)
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 表单类型
|
||||
*
|
||||
* @time 2021年03月06日
|
||||
* @return \string[][]
|
||||
*/
|
||||
protected function types(): array
|
||||
{
|
||||
return [
|
||||
['value' => 'string', 'label' => '字符串'],
|
||||
['value' => 'int', 'label' => '整数'],
|
||||
['value' => 'float', 'label' => '小数'],
|
||||
['value' => 'textarea', 'label' => 'textarea文本'],
|
||||
['value' => 'text', 'label' => '编辑器(建议)'],
|
||||
['value' => 'longtext', 'label' => '编辑器(支持超大文本)'],
|
||||
['value' => 'date', 'label' => '日期型'],
|
||||
['value' => 'datetime', 'label' => '日期时间型'],
|
||||
['value' => 'image', 'label' => '图片上传'],
|
||||
['value' => 'images', 'label' => '多图上传'],
|
||||
['value' => 'file', 'label' => '文件上传'],
|
||||
['value' => 'files', 'label' => '多文件上传'],
|
||||
['value' => 'select', 'label' => '列表'],
|
||||
['value' => 'checkbox', 'label' => '复选框'],
|
||||
['value' => 'password', 'label' => '密码框'],
|
||||
['value' => 'color', 'label' => '颜色选项'],
|
||||
['value' => 'radio', 'label' => '单选'],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
protected function rules(): array
|
||||
{
|
||||
return [
|
||||
['value' => 'require', 'label' => '必填'],
|
||||
['value' => 'number', 'label' => '数字'],
|
||||
['value' => 'integer', 'label' => '整数'],
|
||||
['value' => 'float', 'label' => '浮点数'],
|
||||
['value' => 'email', 'label' => '邮箱'],
|
||||
['value' => 'date', 'label' => '日期'],
|
||||
['value' => 'alpha', 'label' => '纯字母'],
|
||||
['value' => 'alphaNum', 'label' => '纯字母和数字'],
|
||||
['value' => 'url', 'label' => 'url地址'],
|
||||
['value' => 'ip', 'label' => 'ip地址'],
|
||||
['value' => 'mobile', 'label' => '手机号'],
|
||||
['value' => 'idCard', 'label' => '身份证'],
|
||||
['value' => 'zip', 'label' => '邮政编码'],
|
||||
['value' => 'password', 'label' => '密码'],
|
||||
['value' => 'strong_password', 'label' => '强密码'],
|
||||
['value' => 'landLine', 'label' => '座机'],
|
||||
['value' => 'chinese_character', 'label' => '汉字']
|
||||
];
|
||||
}
|
||||
}
|
67
catch/cms/tables/forms/Model.php
Normal file
67
catch/cms/tables/forms/Model.php
Normal file
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | Catch-CMS Design On 2020
|
||||
// +----------------------------------------------------------------------
|
||||
// | CatchAdmin [Just Like ~ ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2017~2020 http://catchadmin.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( https://github.com/yanwenwu/catch-admin/blob/master/LICENSE.txt )
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: JaguarJack [ njphper@gmail.com ]
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace catchAdmin\cms\tables\forms;
|
||||
use catchAdmin\cms\support\Table;
|
||||
use catchAdmin\cms\support\TableColumn;
|
||||
use catcher\library\form\Form;
|
||||
use think\facade\Db;
|
||||
use think\helper\Str;
|
||||
|
||||
class Model extends Form
|
||||
{
|
||||
protected $table = 'cms_articles';
|
||||
|
||||
/**
|
||||
* create form
|
||||
*
|
||||
* @time 2021年03月02日
|
||||
* @return array
|
||||
*/
|
||||
public function fields(): array
|
||||
{
|
||||
// TODO: Implement create() method.
|
||||
return [
|
||||
self::input('name', '模型名称')->required()->maxlength(100),
|
||||
self::input('alias', '模型别名')->required()->appendValidates([
|
||||
self::validateAlphaDash()
|
||||
]),
|
||||
self::select('table_name', '模型关联表')
|
||||
->options($this->getCMSTables())
|
||||
->style(['width' => '100%'])
|
||||
->required(),
|
||||
|
||||
self::textarea('description', '模型描述')->maxlength(255),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取 Cms 表
|
||||
*
|
||||
* @time 2021年04月30日
|
||||
* @return mixed
|
||||
*/
|
||||
protected function getCMSTables()
|
||||
{
|
||||
$options = self::options();
|
||||
|
||||
foreach (Db::getTables() as $table) {
|
||||
if (Str::contains($table, 'cms') && !Str::contains($table, 'relate')) {
|
||||
$options->add($table, $table);
|
||||
}
|
||||
}
|
||||
|
||||
return $options->render();
|
||||
}
|
||||
}
|
66
catch/cms/tables/forms/ModelUsedFields.php
Normal file
66
catch/cms/tables/forms/ModelUsedFields.php
Normal file
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
namespace catchAdmin\cms\tables\forms;
|
||||
|
||||
use catchAdmin\cms\model\Models;
|
||||
use catcher\library\form\Form;
|
||||
use think\facade\Db;
|
||||
|
||||
class ModelUsedFields extends Form
|
||||
{
|
||||
public function fields(): array
|
||||
{
|
||||
$modelId = request()->param('model_id');
|
||||
|
||||
$model = Models::where('id', $modelId)->with('fields')->find();
|
||||
|
||||
$fields = $this->getModelFields($model->table_name);
|
||||
|
||||
$this->primaryKeyValue = $modelId;
|
||||
// TODO: Implement fields() method.
|
||||
return [
|
||||
self::select('used_at_list', '列表使用', $model->used_at_list ? explode(',', $model->used_at_list) : '')
|
||||
->multiple(true)
|
||||
->style(['width' => '100%'])
|
||||
->options($fields),
|
||||
|
||||
self::select('used_at_search', '搜索使用' , $model->used_at_search ? explode(',', $model->used_at_search) : '')
|
||||
->multiple(true)
|
||||
->style(['width' => '100%'])
|
||||
->options($fields),
|
||||
|
||||
self::select('used_at_detail', '详情使用', $model->used_at_detail ? explode(',', $model->used_at_detail) : '')
|
||||
->multiple(true)
|
||||
->style(['width' => '100%'])
|
||||
->options($fields),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取模型字段
|
||||
*
|
||||
* @time 2021年05月11日
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @return int[]|string[]
|
||||
*/
|
||||
protected function getModelFields($tableName)
|
||||
{
|
||||
$fields = array_keys(Db::name($tableName)->getFields());
|
||||
|
||||
foreach ($fields as $k => $field) {
|
||||
if ($field === app(Models::class)->getDeleteAtField()) {
|
||||
unset($fields[$k]);
|
||||
}
|
||||
}
|
||||
|
||||
$options = self::options();
|
||||
|
||||
foreach ($fields as $field) {
|
||||
$options = $options->add($field, $field);
|
||||
}
|
||||
|
||||
|
||||
return $options->render();
|
||||
}
|
||||
}
|
30
catch/cms/tables/forms/SiteLink.php
Normal file
30
catch/cms/tables/forms/SiteLink.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
namespace catchAdmin\cms\tables\forms;
|
||||
|
||||
use catchAdmin\cms\model\BaseModel;
|
||||
|
||||
class SiteLink extends BaseForm
|
||||
{
|
||||
protected $table = 'cms_site_links';
|
||||
|
||||
public function fields(): array
|
||||
{
|
||||
// TODO: Implement fields() method.
|
||||
return [
|
||||
self::input('title', '网站标题')->required(),
|
||||
|
||||
self::input('link_to', '跳转地址')->required()->appendValidates([
|
||||
self::validateUrl()
|
||||
]),
|
||||
|
||||
self::image('网站图标', 'icon'),
|
||||
|
||||
self::radio('is_show', '展示', BaseModel::ENABLE)->options(
|
||||
self::options()->add('是', BaseModel::ENABLE)
|
||||
->add('否', BaseModel::DISABLE)->render()
|
||||
),
|
||||
|
||||
self::number('weight', '权重')->min(1)->max(10000)
|
||||
];
|
||||
}
|
||||
}
|
21
catch/cms/tables/forms/Tags.php
Normal file
21
catch/cms/tables/forms/Tags.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
namespace catchAdmin\cms\tables\forms;
|
||||
|
||||
class Tags extends BaseForm
|
||||
{
|
||||
protected $table = 'cms_tags';
|
||||
|
||||
public function fields(): array
|
||||
{
|
||||
// TODO: Implement fields() method.
|
||||
return [
|
||||
self::input('name', '名称')->required(),
|
||||
|
||||
self::input('title', 'seo 标题'),
|
||||
|
||||
self::input('keywords', 'seo 关键词'),
|
||||
|
||||
self::input('description', 'seo 描述'),
|
||||
];
|
||||
}
|
||||
}
|
15
catch/cms/tables/forms/UsedAt.php
Normal file
15
catch/cms/tables/forms/UsedAt.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
namespace catchAdmin\cms\tables\forms;
|
||||
|
||||
use catcher\library\form\Form;
|
||||
|
||||
class UsedAt extends Form
|
||||
{
|
||||
public function fields(): array
|
||||
{
|
||||
// TODO: Implement fields() method.
|
||||
return [
|
||||
|
||||
];
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user