Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
data-collect
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
汪伟伟
data-collect
Commits
1404b31a
Commit
1404b31a
authored
Jan 09, 2024
by
汪伟伟
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
49374f28
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
150 additions
and
41 deletions
+150
-41
app/Admin/Controllers/TaskController.php
+103
-38
app/Models/Task.php
+45
-1
docker-compose.yml
+1
-1
resources/lang/zh_CN/task.php
+1
-1
No files found.
app/Admin/Controllers/TaskController.php
View file @
1404b31a
...
...
@@ -5,12 +5,11 @@ namespace App\Admin\Controllers;
use
App\Admin\Repositories\Task
;
use
Dcat\Admin\Form
;
use
Dcat\Admin\Grid
;
use
Dcat\Admin\Layout\Column
;
use
Dcat\Admin\Layout\Content
;
use
Dcat\Admin\Http\JsonResponse
;
use
Dcat\Admin\Show
;
use
Dcat\Admin\Http\Controllers\AdminController
;
use
Dcat\Admin\
Layout\Row
;
use
Illuminate\Http\Request
;
use
Dcat\Admin\
Widgets\Tab
;
use
SuperEggs\DcatDistpicker\DcatDistpickerHelper
;
class
TaskController
extends
AdminController
...
...
@@ -20,19 +19,23 @@ class TaskController extends AdminController
*
* @return Grid
*/
protected
function
g
rid
(
)
protected
function
g
etData
(
$tab
=
0
)
{
return
Grid
::
make
(
new
Task
(),
function
(
Grid
$grid
)
{
return
Grid
::
make
(
new
Task
(),
function
(
Grid
$grid
)
use
(
$tab
)
{
if
(
$tab
)
{
$grid
->
model
()
->
where
(
'status'
,
$tab
);
}
$grid
->
column
(
'id'
)
->
sortable
();
$grid
->
column
(
'name'
);
$grid
->
column
(
'level'
);
$grid
->
column
(
'
area'
);
$grid
->
column
(
'
city_id'
)
->
distpicker
(
);
$grid
->
column
(
'year'
);
$grid
->
column
(
'refer'
);
$grid
->
column
(
'guide'
);
//
$grid->column('guide');
// $grid->column('status');
$grid
->
column
(
'created_at'
);
$grid
->
column
(
'updated_at'
)
->
sortable
();
//
$grid->column('created_at');
//
$grid->column('updated_at')->sortable();
$grid
->
filter
(
function
(
Grid\Filter
$filter
)
{
// $filter->equal('id');
...
...
@@ -42,6 +45,18 @@ class TaskController extends AdminController
});
}
protected
function
grid
()
{
$tab
=
Tab
::
make
();
// $tab->add('选项卡1', view('...'));
$tab
->
add
(
'全部任务'
,
$this
->
getData
());
$tab
->
add
(
'已经领取任务'
,
'html2'
);
$tab
->
add
(
'已经完成任务'
,
'html3'
);
return
$tab
;
}
/**
* Make a show builder.
*
...
...
@@ -51,17 +66,19 @@ class TaskController extends AdminController
*/
protected
function
detail
(
$id
)
{
return
Show
::
make
(
$id
,
new
Task
(),
function
(
Show
$show
)
{
return
Show
::
make
(
$id
,
new
Task
(),
function
(
Show
$show
)
use
(
$id
)
{
$show
->
field
(
'id'
);
$show
->
field
(
'name'
);
$show
->
field
(
'level'
);
$show
->
field
(
'area'
);
$show
->
field
(
'city_id'
)
->
value
(
DcatDistpickerHelper
::
getAreaName
(
\App\Models\Task
::
query
()
->
find
(
$id
)
->
city_id
));
$show
->
field
(
'year'
);
$show
->
field
(
'refer'
);
$show
->
field
(
'guide'
);
// $show->field('status');
$show
->
field
(
'created_at'
);
$show
->
field
(
'updated_at'
);
//
$show->field('created_at');
//
$show->field('updated_at');
});
}
...
...
@@ -72,36 +89,54 @@ class TaskController extends AdminController
*/
protected
function
form
()
{
$data
=
json_decode
(
file_get_contents
(
base_path
(
'app/china_all_area.json'
)),
true
);
foreach
(
$data
as
$datum
){
foreach
(
$datum
as
$k
=>
$d
){
$arr
[
$k
]
=
$d
;
}
}
// dd(array_values($data));
return
Form
::
make
(
new
Task
(),
function
(
Form
$form
)
use
(
$arr
)
{
// $data = json_decode(file_get_contents(base_path('app/china_all_area.json')), true);
// foreach ($data as $key=>$datum) {
// if (array_key_exists($key, $data['100000'])) {
// foreach ($datum as $k => $d) {
// $arr[$k] = $d;
// }
// }
// }
return
Form
::
make
(
new
Task
(),
function
(
Form
$form
)
{
$form
->
display
(
'id'
);
$form
->
text
(
'name'
);
$form
->
select
(
'level'
)
->
options
([
1
=>
1
,
2
=>
2
,
3
=>
3
,
4
=>
4
,
5
=>
5
]);
$form
->
multipleSelect
(
'area'
,
'选择地区'
)
->
options
(
$arr
);
// $form->distpicker([
// 'province_id' => '省',
// ],'地区');
$form
->
text
(
'name'
)
->
required
();
$form
->
select
(
'level'
)
->
options
([
1
=>
1
,
2
=>
2
,
3
=>
3
,
4
=>
4
,
5
=>
5
])
->
required
();
// $form->multipleSelect('area', '选择地区')->options($arr)->value('110000')->required();
$form
->
distpicker
([
'province_id'
=>
'省'
,
'city_id'
=>
'市'
,
],
'选择地区'
)
->
required
();
// $form->timeRange('year','year','选择时间');
$form
->
multipleSelect
(
'year'
,
'选择时间'
)
->
options
(
function
()
{
$year
=
(
int
)
date
(
'Y'
);
for
(
$i
=
$year
;
$i
>
1900
;
$i
--
)
{
$years
[
$i
]
=
$i
;
$form
->
multipleSelect
(
'year'
,
'选择时间'
)
->
options
(
function
()
{
$year
=
(
int
)
date
(
'Y'
);
for
(
$i
=
$year
;
$i
>
1900
;
$i
--
)
{
$years
[
$i
]
=
$i
;
}
return
$years
;
});
$form
->
text
(
'refer'
,
'参考信源'
);
$form
->
editor
(
'guide'
,
'收集指南'
);
})
->
value
(
2024
)
->
required
()
;
$form
->
text
(
'refer'
,
'参考信源'
)
->
required
(
);
$form
->
editor
(
'guide'
,
'收集指南'
)
->
required
(
);
// $form->text('status');
$form
->
display
(
'created_at'
);
$form
->
display
(
'updated_at'
);
// $form->display('created_at');
// $form->display('updated_at');
// // 在表单提交前调用
// $form->submitted(function (Form $form) {
// //...
// });
// //保存前回调
// $form->saving(function (Form $form) {
// dump($form->year);
//
// });
//保存后回调
// $form->saved(function (Form $form) {
// dump($form->name);
// });
});
}
...
...
@@ -113,8 +148,38 @@ class TaskController extends AdminController
public
function
store
()
{
$request
=
\request
();
$request
->
validate
([
'name'
=>
'required'
,
'level'
=>
'required'
,
'year'
=>
'required|array'
,
'refer'
=>
'required'
,
'guide'
=>
'required'
,
],
[
'name.required'
=>
'名称不能为空'
]);
// dd($request->input());
$param
=
$request
->
input
();
$query
=
\App\Models\Task
::
query
();
foreach
(
$param
[
'year'
]
as
$y
)
{
if
(
$y
)
{
$insertData
=
[
'name'
=>
$param
[
'name'
],
'level'
=>
$param
[
'level'
],
'province_id'
=>
$param
[
'province_id'
],
'city_id'
=>
$param
[
'city_id'
],
'year'
=>
[
$y
],
'refer'
=>
$param
[
'refer'
],
'guide'
=>
$param
[
'guide'
],
];
$query
->
create
(
$insertData
);
}
}
$form
=
Form
::
make
();
dd
(
$request
->
input
()
);
return
$form
->
response
()
->
success
(
'操作成功'
)
->
redirect
(
'tasks'
);
}
...
...
app/Models/Task.php
View file @
1404b31a
...
...
@@ -4,9 +4,53 @@ namespace App\Models;
use
Dcat\Admin\Traits\HasDateTimeFormatter
;
use
Illuminate\Database\Eloquent\Factories\HasFactory
;
use
Illuminate\Database\Eloquent\Model
;
use
Illuminate\Notifications\Notifiable
;
class
Task
extends
Model
{
use
HasDateTimeFormatter
;
use
HasDateTimeFormatter
,
HasFactory
,
Notifiable
;
protected
$table
=
'tasks'
;
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected
$fillable
=
[
'name'
,
'level'
,
'province_id'
,
'city_id'
,
'year'
,
'refer'
,
'guide'
,
'price'
,
'status'
,
'created_at'
,
'updated_at'
,
];
/**
* The attributes that should be cast to native types.
*
* @var array
*/
protected
$casts
=
[];
// public function getYearAttribute($value)
// {
// return explode(',', $value);
// }
public
function
setYearAttribute
(
$value
)
{
$this
->
attributes
[
'year'
]
=
implode
(
','
,
$value
);
}
}
docker-compose.yml
View file @
1404b31a
...
...
@@ -6,7 +6,7 @@ services:
-
'
8383:80'
environment
:
TZ
:
'
Asia/Shanghai'
WEBROOT
:
'
/var/www/html/
laravel-box
/public'
WEBROOT
:
'
/var/www/html/
data-collect
/public'
# PHP_REDIS_SESSION_HOST: 'redis'
CREATE_LARAVEL_STORAGE
:
'
1'
volumes
:
...
...
resources/lang/zh_CN/task.php
View file @
1404b31a
...
...
@@ -7,7 +7,7 @@ return [
'fields'
=>
[
'name'
=>
'指标名称'
,
'level'
=>
'难度等级'
,
'
area
'
=>
'地区'
,
'
city_id
'
=>
'地区'
,
'year'
=>
'时间'
,
'refer'
=>
'信源'
,
'guide'
=>
'参考指南'
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment