招标
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

105 lines
3.1 KiB

<?php
/**
* Api.php
* Date: 2020-12-11 11:09:23
* User: chenlong <vip_chenlong@163.com>
*/
namespace app\admin\page\system;
use app\common\BasePage;
use sdModule\layui\Layui;
use sdModule\layui\TablePage;
use sdModule\layui\tablePage\TableAux;
use sdModule\layuiSearch\Form;
use sdModule\layui\defaultForm\FormData;
use sdModule\layuiSearch\SearchForm;
use sdModule\layuiSearch\generate\TimeRange;
/**
* Class Api
* @package app\admin\page
*/
class Api extends BasePage
{
/**
* 获取创建列表table的数据
* @return TablePage
*/
public function getTablePageData(): TablePage
{
$table = TablePage::create([
TableAux::column(['type' => 'checkbox']),
// TablePage::column('id', ''),
TableAux::column('api_name', '接口名'),
TableAux::column('method', '请求方式'),
TableAux::column('path', '路径'),
TableAux::column('update_time', '修改时间'),
]);
$table->setHandleWidth(200);
$table->addEvent('see');
$table->setConfig([
'where' => ['search' => ['api_module_id' => request()->get('id')]],
'page' => false,
]);
$table->setBarEventJs('create', TableAux::openPage(url(sprintf('system.api/create?api_module_id=%s', request()->get('id'))), '创建', ['area' => ['90%', '90%']]));
$table->setEventhtml('see', Layui::button('查看', 'read')->setEvent('see')->normal('xs'));
$table->setEventjs('see', TableAux::openPage([url('update?see=1')], '查看', ['area' => ['90%', "90%"]]));
$table->setEventjs('update', TableAux::openPage([url('update')], '编辑', ['area' => ['90%', "90%"]]));
return $table;
}
/**
* 生成表单的数据
* @return array
*/
public function formData(): array
{
return [
FormData::hidden('id'),
FormData::hidden('api_module_id')->preset(request()->get('api_module_id')),
FormData::text('api_name', '接口名'),
FormData::text('path', '路径'),
FormData::text('describe', '描述'),
FormData::u_editor('response', '响应示例'),
];
}
/**
* 列表页面的名字
* @return string
*/
public function listPageName(): string
{
return "api接口表";
}
/**
* 创建搜索表单的数据
* @return string
*/
public function searchFormData():string
{
$form_data = [
SearchForm::Text('i.id', "")->label(true)->html(),
SearchForm::Text('i.api_name%%', "接口名")->label(true)->html(),
SearchForm::Text('i.path%%', "路径")->label(true)->html(),
SearchForm::Text('i.describe%%', "描述")->label(true)->html(),
SearchForm::TimeRange("i.update_time_~", "修改时间")->label(true)->html(TimeRange::TYPE_DATETIME),
];
return Form::CreateHTML($form_data);
}
/**
* @return array 设置快捷搜索
*/
public function setQuickSearchField():array
{
return [
'api_name%%' => '接口名',
];
}
}