发布测试版 2.5.0

This commit is contained in:
2021-11-28 12:06:10 +08:00
parent 672cc966db
commit 8408038188
807 changed files with 94347 additions and 47563 deletions
@@ -0,0 +1,221 @@
<?php namespace Gdoo\System\Controllers;
use DB;
use Request;
use Validator;
use Gdoo\Model\Grid;
use Gdoo\Index\Controllers\DefaultController;
use Gdoo\System\Models\Cron;
class CronController extends DefaultController
{
public $permission = [];
/**
* 部件设置
*/
public function index()
{
$header = [
'master_name' => '定时任务',
'simple_search_form' => 1,
'table' => 'cron',
'master_table' => 'cron',
];
$search = search_form([
'advanced' => '',
], [
['form_type' => 'text', 'name' => '名称', 'field' => 'cron.name', 'value' => '', 'options' => []],
], 'model');
$header['cols'] = [
'checkbox' => [
'width' => 40,
'suppressSizeToFit' => true,
'cellClass' => 'text-center',
'suppressMenu' => true,
'sortable' => false,
'editable' => false,
'resizable' => false,
'filter' => false,
'checkboxSelection' => true,
'headerCheckboxSelection' => true,
],
'seq_sn' => [
'width' => 60,
'headerName' => '序号',
'suppressSizeToFit' => true,
'cellClass' => 'text-center',
'suppressMenu' => true,
'sortable' => false,
'resizable' => false,
'editable' => false,
'type' => 'sn',
'filter' => false,
],
'name' => [
'field' => 'name',
'headerName' => '名称',
'sortable' => true,
'suppressMenu' => true,
'cellClass' => 'text-center',
'form_type' => 'text',
'width' => 100,
],
'command' => [
'field' => 'command',
'headerName' => '命令',
'sortable' => true,
'suppressMenu' => true,
'cellClass' => 'text-center',
'form_type' => 'text',
'width' => 200,
],
'expression' => [
'field' => 'expression',
'headerName' => '表达式',
'sortable' => true,
'suppressMenu' => true,
'cellClass' => 'text-left',
'form_type' => 'text',
'width' => 200,
],
'type' => [
'field' => 'type',
'headerName' => '类型',
'sortable' => true,
'suppressMenu' => true,
'cellClass' => 'text-center',
'form_type' => 'text',
'width' => 100,
],
'status' => [
'field' => 'status',
'headerName' => '状态',
'sortable' => true,
'suppressMenu' => true,
'cellClass' => 'text-center',
'form_type' => 'text',
'width' => 60,
],
'updated_dt' => [
'field' => 'updated_dt',
'headerName' => '操作时间',
'sortable' => true,
'suppressMenu' => true,
'cellClass' => 'text-center',
'form_type' => 'text',
'width' => 80,
],
'id' => [
'field' => 'id',
'headerName' => 'ID',
'sortable' => true,
'suppressMenu' => true,
'cellClass' => 'text-center',
'form_type' => 'text',
'width' => 40,
],
'actions' => [
'headerName' => '',
'cellRenderer' => 'actionCellRenderer',
'options' => [[
'name' => '编辑',
'action' => 'edit',
'display' => $this->access['edit'],
]],
'width' => 100,
'cellClass' => 'text-center',
'suppressSizeToFit' => true,
'suppressMenu' => true,
'sortable' => false,
'editable' => false,
'resizable' => false,
'filter' => false,
],
];
$header['buttons'] = [
['name' => '删除', 'icon' => 'fa-remove', 'action' => 'delete', 'display' => $this->access['delete']],
['name' => '导出', 'icon' => 'fa-share', 'action' => 'export', 'display' => 1],
];
$header['search_form'] = $search;
$query = $search['query'];
if (Request::method() == 'POST') {
$model = Cron::setBy($header);
foreach ($search['where'] as $where) {
if ($where['active']) {
$model->search($where);
}
}
$model->selectRaw('*, id as master_id');
$rows = $model->paginate($query['limit'])->appends($query);
$rows->transform(function($row) {
$row['type'] = $row['type'] == 'system' ? '系统' : '用户';
$row['status'] = $row['status'] == 1 ? '启用' : '禁用';
$row['updated_dt'] = format_datetime($row['updated_at']);
return $row;
});
$ret = $rows->toArray();
$ret['header'] = Grid::getColumns($header);
return $ret;
}
return $this->display([
'header' => $header,
]);
}
public function create()
{
$id = (int)Request::get('id');
if (Request::method() == 'POST') {
$gets = Request::all();
$rules = [
'name' => 'required',
'expression' => 'required',
'command' => 'required',
];
$v = Validator::make($gets, $rules);
if ($v->fails()) {
return $this->json($v->errors()->first());
}
$model = Cron::findOrNew($gets['id']);
$model->fill($gets);
$model->save();
return $this->json('恭喜你,操作成功。', true);
}
$row = Cron::where('id', $id)->first();
return $this->render([
'row' => $row
], 'create');
}
public function edit()
{
return $this->create();
}
public function store()
{
return $this->edit();
}
public function delete()
{
if (Request::method() == 'POST') {
$id = Request::get('id');
Cron::whereIn('id', $id)->delete();
return $this->json('恭喜你,操作成功。', true);
}
}
}
@@ -172,4 +172,4 @@ class MediaController extends DefaultController
return $this->json('删除成功。', true);
}
}
}
@@ -246,11 +246,10 @@ class WidgetController extends DefaultController
if ($v->fails()) {
return $this->json($v->errors()->first());
}
if ($gets['id']) {
DB::table('widget')->where('id', $gets['id'])->update($gets);
} else {
DB::table('widget')->insert($gets);
}
$model = Widget::findOrNew($gets['id']);
$model->fill($gets);
$model->save();
return $this->json('恭喜你,操作成功。', true);
}
$row = DB::table('widget')->where('id', $id)->first();
@@ -287,6 +286,7 @@ class WidgetController extends DefaultController
$widgets = ModuleService::widgets();
foreach($widgets as $code => $widget) {
$model = Widget::firstOrNew(['code' => $code]);
$widget['params'] = json_encode($widget['params'], JSON_UNESCAPED_UNICODE);
$model->fill($widget);
$model->save();
}
+8
View File
@@ -0,0 +1,8 @@
<?php namespace Gdoo\System\Models;
use Gdoo\Index\Models\BaseModel;
class Cron extends BaseModel
{
protected $table = 'cron';
}
+17
View File
@@ -144,6 +144,23 @@ return [
]
]
],
"cron" => [
"name" => "定时任务",
"actions" => [
"index" => [
"name" => "列表"
],
"create" => [
"name" => "新建"
],
"edit" => [
"name" => "编辑"
],
"delete" => [
"name" => "删除"
]
]
],
"option" => [
"name" => "枚举管理",
"actions" => [
@@ -0,0 +1,47 @@
<form method="post" id="cron" name="cron">
<table class="table table-form m-b-none">
<tr>
<td align="right" width="10%">名称</td>
<td align="left">
<input class="form-control input-sm" type="text" name="name" value="{{$row['name']}}">
</td>
</tr>
<tr>
<td align="right">命令</td>
<td align="left">
<input class="form-control input-sm" type="text" name="command" value="{{$row['command']}}">
</td>
</tr>
<tr>
<td align="right">表达式</td>
<td align="left">
<input class="form-control input-sm" type="text" name="expression" value="{{$row['expression']}}">
</td>
</tr>
<tr>
<td align="right">类型</td>
<td align="left">
<select class="form-control input-sm" name="type" id="type">
<option value="system" @if($row['type'] == 'system') selected @endif>系统</option>
<option value="user" @if($row['type'] == 'user') selected @endif>用户</option>
</select>
</td>
</tr>
<tr>
<td align="right">状态</td>
<td align="left">
<select class="form-control input-sm" name="status" id="status">
<option value="1" @if($row['status'] == 1) selected @endif>正常</option>
<option value="0" @if($row['status'] == 0) selected @endif>禁用</option>
</select>
</td>
</tr>
</table>
<input type="hidden" name="id" value="{{$row['id']}}">
</form>
@@ -0,0 +1,43 @@
<div class="gdoo-list-page" id="{{$header['master_table']}}-page">
<div class="gdoo-list panel">
<div class="gdoo-list-header">
<gdoo-grid-header :header="header" :grid="grid" :action="action" />
</div>
<div class='gdoo-list-grid'>
<div id="{{$header['master_table']}}-grid" class="ag-theme-balham"></div>
</div>
</div>
</div>
<script>
Vue.createApp({
components: {
gdooGridHeader,
},
setup(props, ctx) {
var table = '{{$header["master_table"]}}';
var config = new gdoo.grid(table);
var grid = config.grid;
grid.remoteDataUrl = '{{url()}}';
grid.autoColumnsToFit = true;
var action = config.action;
// 双击行执行的方法
action.rowDoubleClick = action.edit;
var setup = config.setup;
Vue.onMounted(function() {
var gridDiv = config.div(93);
// 初始化数据
grid.remoteData({page: 1}, function(res) {
config.init(res);
});
});
return setup;
}
}).mount("#{{$header['master_table']}}-page");
</script>