简单标签使用demo

解决已知bug
This commit is contained in:
2020-04-22 21:32:36 +08:00
parent 5ae9d68948
commit 676c5854cd
12 changed files with 40 additions and 144 deletions

View File

@@ -1,41 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | OneThink [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.onethink.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: 麦当苗儿 <zuojiazi@vip.qq.com> <http://www.zjzit.cn>
// +----------------------------------------------------------------------
namespace app\model;
/**
* 分类模型
*/
class Action {
protected function getStatusTextAttr($value, $data) {
$status = array(-1 => '删除', 0 => '禁用', 1 => '正常', 2 => '待审核');
return $status[$data['status']];
}
public $fieldlist = array(
array('name' => 'id', 'title' => 'ID', 'type' => 'hidden'),
array('name' => 'name', 'title' => '行为标识', 'type' => 'text', 'help' => '输入行为标识 英文字母'),
array('name' => 'title', 'title' => '行为名称', 'type' => 'text', 'help' => '输入行为名称'),
array('name' => 'type', 'title' => '行为类型', 'type' => 'select', 'help' => '选择行为类型', 'option' => ''),
array('name' => 'remark', 'title' => '行为描述', 'type' => 'textarea', 'help' => '输入行为描述'),
array('name' => 'rule', 'title' => '行为规则', 'type' => 'textarea', 'help' => '输入行为规则,不写则只记录日志'),
array('name' => 'log', 'title' => '日志规则', 'type' => 'textarea', 'help' => '记录日志备注时按此规则来生成,支持[变量|函数]。目前变量有user,time,model,record,data'),
);
public function _initialize() {
parent::_initialize();
foreach ($this->fieldlist as $key => $value) {
if ($value['name'] == 'type') {
$value['option'] = get_action_type(null, true);
}
$this->fieldlist[$key] = $value;
}
}
}

View File

@@ -25,8 +25,8 @@ class AuthRule extends Model{
public $keyList = [
['name'=>'module','title'=>'所属模块','type'=>'hidden'],
['name'=>'title','title'=>'节点名称','type'=>'text','help'=>''],
['name'=>'name','title'=>'节点标识','type'=>'text','help'=>''],
['name'=>'title','title'=>'节点名称','type'=>'text', 'is_must'=>true,'help'=>''],
['name'=>'name','title'=>'节点标识','type'=>'text', 'is_must'=>true,'help'=>''],
['name'=>'group','title'=>'功能组','type'=>'text','help'=>'功能分组'],
['name'=>'status','title'=>'状态','type'=>'select','option'=>[['key' => '0', 'label'=>'禁用'],['key' => '1', 'label'=>'启用']],'help'=>''],
['name'=>'condition','title'=>'条件','type'=>'text','help'=>'']

View File

@@ -18,22 +18,35 @@ class Channel extends \think\Model {
'id' => 'integer',
);
protected $auto = array('update_time', 'status' => 1);
protected $insert = array('create_time');
protected function setStatusAttr($value){
return ($value !== '') ? $value : 1;
}
protected function getStatusTextAttr($value, $data){
$status = [0 => '禁用', 1 => '启用'];
return isset($status[$data['status']]) ? $status[$data['status']] : '禁用';
}
public static function getChannelList($pid, $tree){
public static function getChannelList($type, $pid = '', $tree = false){
$map = [];
$map[] = ['status', '=', 1];
if ($pid !== '') {
$map[] = ['pid', '=', $pid];
}
$list = self::where($map)->order('sort asc, id desc')->column("*");
if($type !== ''){
$map[] = ['type', '=', $type];
}
$list = self::where($map)->order('sort asc, id desc')->select()->each(function($item){
if(strpos($item['url'], "?")){
$url = parse_url($item['url']);
$param = [];
parse_str($url['query'], $param);
$item['url'] = url($url['path'], $param);
}else{
$item['url'] = url($item['url']);
}
return $item;
})->toArray();
if ($tree) {
$list = (new \sent\tree\Tree())->listToTree($list);
}

View File

@@ -1,85 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | OneThink [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.onethink.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: 麦当苗儿 <zuojiazi@vip.qq.com> <http://www.zjzit.cn>
// +----------------------------------------------------------------------
namespace app\model;
/**
* 分类模型
*/
class Record extends \think\Model {
protected $type = [
'new_data' => 'json',
'old_data' => 'json',
'order_num' => 'float'
];
public function getDataList($request) {
$map = [];
$order = "id desc";
$param = $request->param();
if (isset($param['name']) && $param['name'] != '') {
$map[] = ['data_name', 'LIKE', '%' . $param['name'] . '%'];
}
if (isset($param['nickname']) && $param['nickname'] != '') {
$searchUser = db('Member')->where('nickname', $param['nickname'])->field('uid,department')->find();
if ($searchUser) {
$map[] = ['uid', '=', $searchUser['uid']];
}
}
if (isset($param['data']) && count($param['data']) == 2 && $param['data'][0] && $param['data'][1]) {
$data = [strtotime($param['data'][0]), strtotime($param['data'][1])];
$map[] = ['create_time', 'between time', $data];
}
//数据权限
if ($request->user['role']['data_auth'] == 1) {
// 部门数据...
$user = Db::name('Member')->field('uid')
->where('department', $request->user['department'])
->buildSql();
$map[] = ["uid", "EXP", "in " . $user];
} elseif ($request->user['role']['data_auth'] == 2) {
// 个人数据...
$map[] = ['uid', '=', $request->user['uid']];
}
$list = self::with(['member'])->where($map)
->order($order)->paginate($request->pageConfig);
return $list;
}
/**
* title : 添加记录
* param : old 旧数据new 新数据 type 类型
*/
public function adds($old = array(), $new = array(), $type = 'customer') {
$edit = array(); //修改过的字段
foreach ($new as $key => $value) {
if (isset($old[$key]) && $value != $old[$key]) {
$edit[] = $key;
}
}
if (!empty($edit)) {
$data['data_id'] = $old['id'];
$data['data_name'] = $old['name'];
$data['type'] = $type;
$data['uid'] = session('user_auth.uid');
$data['old_data'] = json_encode($old);
$data['new_data'] = json_encode($new);
$data['fields'] = json_encode($edit);
$data['create_time'] = time();
return $this->insert($data);
}
}
public function member() {
return $this->hasOne('Member', 'uid', 'uid')->field('uid,username,nickname');
}
}

View File

@@ -18,8 +18,8 @@ class Rewrite extends \think\Model {
public static $keyList = array(
array('name' => 'id', 'title' => '标识', 'type' => 'hidden'),
array('name' => 'rule', 'title' => '规则名称', 'type' => 'text', 'option' => '', 'help' => '规则名称,方便记忆'),
array('name' => 'url', 'title' => '规则地址', 'type' => 'text', 'option' => '', 'help' => '规则地址'),
array('name' => 'rule', 'title' => '规则名称', 'type' => 'text', 'is_must'=> true, 'option' => '', 'help' => '规则名称,方便记忆'),
array('name' => 'url', 'title' => '规则地址', 'type' => 'text', 'is_must'=> true, 'option' => '', 'help' => '规则地址'),
);
/**

View File

@@ -16,13 +16,13 @@ class SeoRule extends \think\Model {
public static $keyList = [
['name' => 'id', 'title' => '标识', 'type' => 'hidden'],
['name' => 'title', 'title' => '规则名称', 'type' => 'text', 'option' => '', 'help' => '规则名称,方便记忆'],
['name' => 'title', 'title' => '规则名称', 'type' => 'text', 'is_must'=>true, 'option' => '', 'help' => '规则名称,方便记忆'],
['name' => 'app', 'title' => '模块名', 'type' => 'select', 'option' => [['key'=>'*', 'label' => '-所有模块-'], ['key'=>'front', 'label' => '前台模块'], ['key'=>'user', 'label' => '用户中心']], 'help' => '不选表示所有模块'],
['name' => 'controller', 'title' => '控制器', 'type' => 'text', 'option' => '', 'help' => '不填表示所有控制器'],
['name' => 'action', 'title' => '方法', 'type' => 'text', 'option' => '', 'help' => '不填表示所有方法'],
['name' => 'seo_title', 'title' => 'SEO标题', 'type' => 'text', 'option' => '', 'help' => '不填表示使用默认'],
['name' => 'seo_keywords', 'title' => 'SEO关键字', 'type' => 'text', 'option' => '', 'help' => '不填表示使用默认'],
['name' => 'seo_description', 'title' => 'SEO描述', 'type' => 'text', 'option' => '', 'help' => '不填表示使用默认'],
['name' => 'seo_title', 'title' => 'SEO标题', 'type' => 'text', 'is_must'=>true, 'option' => '', 'help' => '不填表示使用默认'],
['name' => 'seo_keywords', 'title' => 'SEO关键字', 'type' => 'text', 'is_must'=>true, 'option' => '', 'help' => '不填表示使用默认'],
['name' => 'seo_description', 'title' => 'SEO描述', 'type' => 'text', 'is_must'=>true, 'option' => '', 'help' => '不填表示使用默认'],
['name' => 'status', 'title' => '状态', 'type' => 'select', 'option' => [['key'=>'0', 'label' => '禁用'], ['key'=>'1', 'label' => '启用']], 'help' => ''],
['name' => 'sort', 'title' => '排序', 'type' => 'text', 'option' => '', 'help' => ''],
];