diff --git a/application/admin/controller/ApiManager.php b/application/admin/controller/ApiManager.php index ad374c0..da6b5f5 100644 --- a/application/admin/controller/ApiManager.php +++ b/application/admin/controller/ApiManager.php @@ -18,15 +18,19 @@ class ApiManager extends Base { 'header' => [ [ 'field' => 'name', - 'info' => '应用名称' + 'info' => '接口名称' ], [ - 'field' => 'info', - 'info' => '应用描述' + 'field' => 'version', + 'info' => '接口版本' + ], + [ + 'field' => 'map', + 'info' => '接口映射' ], [ 'field' => 'type', - 'info' => '参与方式' + 'info' => '接口标识' ], [ 'field' => 'status', diff --git a/application/admin/controller/Base.php b/application/admin/controller/Base.php index dfaad66..06de263 100644 --- a/application/admin/controller/Base.php +++ b/application/admin/controller/Base.php @@ -38,6 +38,11 @@ class Base extends Controller { } } + /** + * 自定义初始化函数 + */ + public function _myInitialize(){} + /** * 空方法默认的页面 */ diff --git a/application/admin/controller/KeyManager.php b/application/admin/controller/KeyManager.php index a2a2b98..9216295 100644 --- a/application/admin/controller/KeyManager.php +++ b/application/admin/controller/KeyManager.php @@ -11,6 +11,20 @@ namespace app\admin\controller; use app\admin\model\Keys; 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(){ $data = Keys::all(); $table = [ @@ -101,13 +115,12 @@ class KeyManager extends Base { ] ], 'filterId' => [ - 'module' => 'label', - 'rule' => [ - -1 => [ - 'info' => '无限制', - 'class' => 'label label-warning' - ] - ] + 'module' => 'listValue', + 'rule' => $this->filters + ], + 'appId' => [ + 'module' => 'listValue', + 'rule' => $this->apps ] ], 'data' => $data @@ -126,12 +139,6 @@ class KeyManager extends Base { $this->success('操作成功!', url('KeyManager/index')); } }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); $ak = \StrOrg::keyGen(); $form = [ @@ -172,7 +179,7 @@ class KeyManager extends Base { 'attr' => [ 'name' => 'appId', 'value' => '', - 'options' => $apps + 'options' => $this->apps ] ], [ @@ -182,7 +189,7 @@ class KeyManager extends Base { 'attr' => [ 'name' => 'filterId', 'value' => '', - 'options' => $filters + 'options' => $this->filters ] ], [ @@ -219,12 +226,6 @@ class KeyManager extends Base { $keysModel->allowField(true)->update($data); $this->success('操作成功!', url('KeyManager/index')); }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(); $form = [ 'formTitle' => $this->menuInfo['name'], @@ -274,7 +275,7 @@ class KeyManager extends Base { 'attr' => [ 'name' => 'appId', 'value' => $detail['appId'], - 'options' => $apps + 'options' => $this->apps ] ], [ @@ -284,7 +285,7 @@ class KeyManager extends Base { 'attr' => [ 'name' => 'filterId', 'value' => $detail['filterId'], - 'options' => $filters + 'options' => $this->filters ] ], [ diff --git a/public/admin/static/js/template/table.js b/public/admin/static/js/template/table.js index 1cdd592..aa480ce 100644 --- a/public/admin/static/js/template/table.js +++ b/public/admin/static/js/template/table.js @@ -117,6 +117,15 @@ dataListHtml += ''; } } + break; + case 'listValue': + if( rule.rule[dataValue[fieldName]] ){ + styleList = rule.rule[dataValue[fieldName]]; + dataListHtml += ''+ styleList +''; + }else{ + dataListHtml += '' + dataValue[fieldName] + ''; + } + break; } }else{ dataListHtml += '' + dataValue[fieldName] + '';