后台内容模块功能完善

This commit is contained in:
2020-03-31 16:17:45 +08:00
parent de73484cca
commit 85d33da0d4
24 changed files with 386 additions and 251 deletions

View File

@@ -12,25 +12,25 @@ namespace app\model;
/**
* 分类模型
*/
class Ad {
class Ad extends \think\Model{
protected $auto = array('update_time');
protected $insert = array('create_time');
protected $type = array(
protected $type = [
'id' => 'integer',
'cover_id' => 'integer',
);
];
public $keyList = array(
array('name' => 'id', 'title' => 'ID', 'type' => 'hidden', 'help' => '', 'option' => ''),
array('name' => 'place_id', 'title' => 'PLACE_ID', 'type' => 'hidden', 'help' => '', 'option' => ''),
array('name' => 'title', 'title' => '广告名称', 'type' => 'text', 'help' => '', 'option' => ''),
array('name' => 'cover_id', 'title' => '广告图片', 'type' => 'image', 'help' => '', 'option' => ''),
array('name' => 'url', 'title' => '广告链接', 'type' => 'text', 'help' => '', 'option' => ''),
array('name' => 'photolist', 'title' => '辅助图片', 'type' => 'images', 'help' => '', 'option' => ''),
array('name' => 'listurl', 'title' => '辅助链接', 'type' => 'textarea', 'help' => '对应辅助图片的排序,一行一个', 'option' => ''),
array('name' => 'background', 'title' => '广告背景颜色', 'type' => 'text', 'help' => '', 'option' => ''),
array('name' => 'content', 'title' => '广告描述', 'type' => 'textarea', 'help' => '', 'option' => ''),
array('name' => 'status', 'title' => '状态', 'type' => 'select', 'help' => '', 'option' => array('1' => '开启', '0' => '用')),
);
public static $keyList = [
['name' => 'id', 'title' => 'ID', 'type' => 'hidden', 'help' => '', 'option' => ''],
['name' => 'place_id', 'title' => 'PLACE_ID', 'type' => 'hidden', 'help' => '', 'option' => ''],
['name' => 'title', 'title' => '广告名称', 'type' => 'text', 'help' => '', 'option' => ''],
['name' => 'cover_id', 'title' => '广告图片', 'type' => 'image', 'help' => '', 'option' => ''],
['name' => 'url', 'title' => '广告链接', 'type' => 'text', 'help' => '', 'option' => ''],
['name' => 'photolist', 'title' => '辅助图片', 'type' => 'images', 'help' => '', 'option' => ''],
['name' => 'listurl', 'title' => '辅助链接', 'type' => 'textarea', 'help' => '对应辅助图片的排序,一行一个', 'option' => ''],
['name' => 'background', 'title' => '广告背景颜色', 'type' => 'text', 'help' => '', 'option' => ''],
['name' => 'content', 'title' => '广告描述', 'type' => 'textarea', 'help' => '', 'option' => ''],
['name' => 'status', 'title' => '状态', 'type' => 'select', 'help' => '', 'option' => [['key' => '0', 'label'=>'禁用'],['key' => '1', 'label'=>'用']]]
];
}

View File

@@ -30,17 +30,17 @@ class AdPlace extends \think\Model{
'6' => '代码广告',
);
public $keyList = array(
array('name' => 'id', 'title' => 'ID', 'type' => 'hidden', 'help' => '', 'option' => ''),
array('name' => 'title', 'title' => '广告位名称', 'type' => 'text', 'help' => '', 'option' => ''),
array('name' => 'name', 'title' => '广告位标识', 'type' => 'text', 'help' => '调用使用{:ad("广告位标识",参数)}', 'option' => ''),
array('name' => 'show_type', 'title' => '类型', 'type' => 'select', 'help' => '', 'option' => ''),
array('name' => 'show_num', 'title' => '显示条数', 'type' => 'num', 'help' => '', 'option' => ''),
array('name' => 'start_time', 'title' => '开始时间', 'type' => 'datetime', 'help' => '', 'option' => ''),
array('name' => 'end_time', 'title' => '结束时间', 'type' => 'datetime', 'help' => '', 'option' => ''),
array('name' => 'template', 'title' => '广告模版', 'type' => 'text', 'help' => '', 'option' => ''),
array('name' => 'status', 'title' => '状态', 'type' => 'select', 'help' => '', 'option' => array('1' => '开启', '0' => '禁用')),
);
public static $keyList = [
['name' => 'id', 'title' => 'ID', 'type' => 'hidden', 'help' => '', 'option' => ''],
['name' => 'title', 'title' => '广告位名称', 'type' => 'text', 'help' => '', 'option' => ''],
['name' => 'name', 'title' => '广告位标识', 'type' => 'text', 'help' => '调用使用{:ad("广告位标识",参数)}', 'option' => ''],
['name' => 'show_type', 'title' => '类型', 'type' => 'select', 'help' => '', 'option' => ''],
['name' => 'show_num', 'title' => '显示条数', 'type' => 'num', 'help' => '', 'option' => ''],
['name' => 'start_time', 'title' => '开始时间', 'type' => 'datetime', 'help' => '', 'option' => ''],
['name' => 'end_time', 'title' => '结束时间', 'type' => 'datetime', 'help' => '', 'option' => ''],
['name' => 'template', 'title' => '广告模版', 'type' => 'text', 'help' => '', 'option' => ''],
['name' => 'status', 'title' => '状态', 'type' => 'select', 'help' => '', 'option' => [['key' => '0', 'label'=>'禁用'],['key' => '1', 'label'=>'启用']]],
];
public function initialize() {
parent::initialize();

View File

@@ -80,4 +80,31 @@ class Attribute extends \think\Model {
}
}
public static function getField($model, $ac = "add"){
$list = [];
$group = $model['attr_group'];
$map = [];
$map[] = ['model_id', '=', $model['id']];
if ($ac == 'add') {
$map[] = ['is_show', 'IN', [1, 2]];
}else if ($ac == 'edit') {
$map[] = ['is_show', 'IN', [1, 3]];
}
$row = self::where('model_id', $model['id'])
->select()
->append(['option'])
->toArray();
foreach ($row as $key => $value) {
if (isset($group[$value['group_id']])) {
$list[$group[$value['group_id']]['label']][] = $value;
}else{
$list[$value['group_id']][] = $value;
}
}
return $list;
}
}

View File

@@ -17,24 +17,24 @@ class Link extends \think\Model {
protected $auto = ['update_time'];
protected $insert = ['create_time'];
public $keyList = array(
array('name' => 'id', 'title' => 'ID', 'type' => 'hidden'),
array('name' => 'title', 'title' => '友链标题', 'type' => 'text', 'help' => ''),
array('name' => 'url', 'title' => 'URL链接', 'type' => 'text', 'help' => ''),
array('name' => 'ftype', 'title' => '友链类别', 'type' => 'select', 'option' => array(
'1' => '常用链接',
'2' => '网站导读',
'3' => '对公服务',
'4' => '校内服务',
), 'help' => ''),
array('name' => 'cover_id', 'title' => '网站LOGO', 'type' => 'image', 'help' => ''),
array('name' => 'status', 'title' => '状态', 'type' => 'select', 'option' => array('1' => '启用', '0' => '用'), 'help' => ''),
array('name' => 'sort', 'title' => '链接排序', 'type' => 'text', 'help' => ''),
array('name' => 'descrip', 'title' => '描述', 'type' => 'textarea', 'help' => ''),
);
public static $keyList = [
['name' => 'id', 'title' => 'ID', 'type' => 'hidden'],
['name' => 'title', 'title' => '友链标题', 'type' => 'text', 'help' => ''],
['name' => 'url', 'title' => 'URL链接', 'type' => 'text', 'help' => ''],
['name' => 'ftype', 'title' => '友链类别', 'type' => 'select', 'option' => [
['key'=>'1', 'label' => '常用链接'],
['key'=>'2', 'label' => '网站导读'],
['key'=>'3', 'label' => '对公服务'],
['key'=>'4', 'label' => '校内服务'],
], 'help' => ''],
['name' => 'cover_id', 'title' => '网站LOGO', 'type' => 'image', 'help' => ''],
['name' => 'status', 'title' => '状态', 'type' => 'select', 'option' => [['key' => '0', 'label'=>'禁用'],['key' => '1', 'label'=>'用']], 'help' => ''],
['name' => 'sort', 'title' => '链接排序', 'type' => 'text', 'help' => ''],
['name' => 'descrip', 'title' => '描述', 'type' => 'textarea', 'help' => ''],
];
protected $type = array(
protected $type = [
'cover_id' => 'integer',
'sort' => 'integer'
);
];
}

View File

@@ -97,6 +97,18 @@ class Model extends \think\Model{
return $list;
}
public function getAttrGroupAttr($value, $data){
$list = [];
if ($data['attribute_group']) {
$row = explode(PHP_EOL, $data['attribute_group']);
foreach ($row as $r) {
list($key, $label) = explode(":", $r);
$list[$key] = ['key' => $key, 'label' => $label];
}
}
return $list;
}
public function getStatusTextAttr($value, $data) {
$status = [0 => '禁用', 1 => '启用'];
return $status[$data['status']];