added 新增列表翻译类数据解析方式

This commit is contained in:
zhaoxiang 2016-12-12 23:45:55 +08:00
parent f32ec2b869
commit 4391ca5910
4 changed files with 46 additions and 27 deletions

View File

@ -18,15 +18,19 @@ class ApiManager extends Base {
'header' => [ 'header' => [
[ [
'field' => 'name', 'field' => 'name',
'info' => '应用名称' 'info' => '接口名称'
], ],
[ [
'field' => 'info', 'field' => 'version',
'info' => '应用描述' 'info' => '接口版本'
],
[
'field' => 'map',
'info' => '接口映射'
], ],
[ [
'field' => 'type', 'field' => 'type',
'info' => '参与方式' 'info' => '接口标识'
], ],
[ [
'field' => 'status', 'field' => 'status',

View File

@ -38,6 +38,11 @@ class Base extends Controller {
} }
} }
/**
* 自定义初始化函数
*/
public function _myInitialize(){}
/** /**
* 空方法默认的页面 * 空方法默认的页面
*/ */

View File

@ -11,6 +11,20 @@ namespace app\admin\controller;
use app\admin\model\Keys; use app\admin\model\Keys;
class KeyManager extends Base { class KeyManager extends Base {
private $apps;
private $filters;
public function _myInitialize() {
$this->apps = cache(CacheType::APP_LIST_KEY);
if( !$this->apps ){
$this->error('请先配置应用!', url('AppManager/index'));
}else{
$this->apps = [0 => '不关联'] + $this->apps;
}
$this->filters = [-1 => '不限制'] + cache(CacheType::FILTER_LIST_KEY);
}
public function index(){ public function index(){
$data = Keys::all(); $data = Keys::all();
$table = [ $table = [
@ -101,13 +115,12 @@ class KeyManager extends Base {
] ]
], ],
'filterId' => [ 'filterId' => [
'module' => 'label', 'module' => 'listValue',
'rule' => [ 'rule' => $this->filters
-1 => [ ],
'info' => '无限制', 'appId' => [
'class' => 'label label-warning' 'module' => 'listValue',
] 'rule' => $this->apps
]
] ]
], ],
'data' => $data 'data' => $data
@ -126,12 +139,6 @@ class KeyManager extends Base {
$this->success('操作成功!', url('KeyManager/index')); $this->success('操作成功!', url('KeyManager/index'));
} }
}else{ }else{
$apps = cache(CacheType::APP_LIST_KEY);
if( !$apps ){
$this->error('请先配置应用!', url('AppManager/index'));
}
$filters = cache(CacheType::FILTER_LIST_KEY);
$filters[-1] = '不限制';
$sk = \StrOrg::randString(64); $sk = \StrOrg::randString(64);
$ak = \StrOrg::keyGen(); $ak = \StrOrg::keyGen();
$form = [ $form = [
@ -172,7 +179,7 @@ class KeyManager extends Base {
'attr' => [ 'attr' => [
'name' => 'appId', 'name' => 'appId',
'value' => '', 'value' => '',
'options' => $apps 'options' => $this->apps
] ]
], ],
[ [
@ -182,7 +189,7 @@ class KeyManager extends Base {
'attr' => [ 'attr' => [
'name' => 'filterId', 'name' => 'filterId',
'value' => '', 'value' => '',
'options' => $filters 'options' => $this->filters
] ]
], ],
[ [
@ -219,12 +226,6 @@ class KeyManager extends Base {
$keysModel->allowField(true)->update($data); $keysModel->allowField(true)->update($data);
$this->success('操作成功!', url('KeyManager/index')); $this->success('操作成功!', url('KeyManager/index'));
}else{ }else{
$apps = cache(CacheType::APP_LIST_KEY);
if( !$apps ){
$this->error('请先配置应用!', url('AppManager/index'));
}
$filters = cache(CacheType::FILTER_LIST_KEY);
$filters[-1] = '不限制';
$detail = Keys::get($this->request->get($this->primaryKey))->toArray(); $detail = Keys::get($this->request->get($this->primaryKey))->toArray();
$form = [ $form = [
'formTitle' => $this->menuInfo['name'], 'formTitle' => $this->menuInfo['name'],
@ -274,7 +275,7 @@ class KeyManager extends Base {
'attr' => [ 'attr' => [
'name' => 'appId', 'name' => 'appId',
'value' => $detail['appId'], 'value' => $detail['appId'],
'options' => $apps 'options' => $this->apps
] ]
], ],
[ [
@ -284,7 +285,7 @@ class KeyManager extends Base {
'attr' => [ 'attr' => [
'name' => 'filterId', 'name' => 'filterId',
'value' => $detail['filterId'], 'value' => $detail['filterId'],
'options' => $filters 'options' => $this->filters
] ]
], ],
[ [

View File

@ -117,6 +117,15 @@
dataListHtml += '<td><input class="auth" type="checkbox" url="'+ rule.rule['url'] +'" name="'+fieldName+'" ></td>'; dataListHtml += '<td><input class="auth" type="checkbox" url="'+ rule.rule['url'] +'" name="'+fieldName+'" ></td>';
} }
} }
break;
case 'listValue':
if( rule.rule[dataValue[fieldName]] ){
styleList = rule.rule[dataValue[fieldName]];
dataListHtml += '<td>'+ styleList +'</td>';
}else{
dataListHtml += '<td style="color:red;">' + dataValue[fieldName] + '</td>';
}
break;
} }
}else{ }else{
dataListHtml += '<td>' + dataValue[fieldName] + '</td>'; dataListHtml += '<td>' + dataValue[fieldName] + '</td>';