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
cb995417
Commit
cb995417
authored
Jan 17, 2024
by
汪伟伟
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add
parent
a6d377b3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
83 additions
and
56 deletions
+83
-56
app/Admin/Controllers/HomeController.php
+5
-1
app/Admin/Controllers/TaskController.php
+15
-8
app/Admin/Extensions/Tools/BatchReceiveAction.php
+63
-47
No files found.
app/Admin/Controllers/HomeController.php
View file @
cb995417
...
@@ -4,6 +4,7 @@ namespace App\Admin\Controllers;
...
@@ -4,6 +4,7 @@ namespace App\Admin\Controllers;
use
App\Admin\Metrics\Examples
;
use
App\Admin\Metrics\Examples
;
use
App\Http\Controllers\Controller
;
use
App\Http\Controllers\Controller
;
use
Dcat\Admin\Admin
;
use
Dcat\Admin\Http\Controllers\Dashboard
;
use
Dcat\Admin\Http\Controllers\Dashboard
;
use
Dcat\Admin\Layout\Column
;
use
Dcat\Admin\Layout\Column
;
use
Dcat\Admin\Layout\Content
;
use
Dcat\Admin\Layout\Content
;
...
@@ -13,12 +14,15 @@ class HomeController extends Controller
...
@@ -13,12 +14,15 @@ class HomeController extends Controller
{
{
public
function
index
(
Content
$content
)
public
function
index
(
Content
$content
)
{
{
// if ((Admin::user())->is_admin == 0){
// return response()->redirectTo('/receive');
// }
return
$content
return
$content
->
header
(
'Dashboard'
)
->
header
(
'Dashboard'
)
->
description
(
'Description...'
)
->
description
(
'Description...'
)
->
body
(
function
(
Row
$row
)
{
->
body
(
function
(
Row
$row
)
{
$row
->
column
(
6
,
function
(
Column
$column
)
{
$row
->
column
(
6
,
function
(
Column
$column
)
{
$column
->
row
(
Dashboard
::
title
());
//
$column->row(Dashboard::title());
$column
->
row
(
new
Examples\Tickets
());
$column
->
row
(
new
Examples\Tickets
());
});
});
...
...
app/Admin/Controllers/TaskController.php
View file @
cb995417
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
namespace
App\Admin\Controllers
;
namespace
App\Admin\Controllers
;
use
App\Admin\Extensions\Tools\BatchReceiveAction
;
use
App\Admin\Extensions\Tools\BatchReceiveAction
;
use
App\Admin\Extensions\Tools\CreateSettlementOrder
;
use
App\Admin\Extensions\Tools\ReceiveAction
;
use
App\Admin\Extensions\Tools\ReceiveAction
;
use
App\Admin\Repositories\Task
;
use
App\Admin\Repositories\Task
;
use
App\Models\TasksReceive
;
use
App\Models\TasksReceive
;
...
@@ -35,9 +36,14 @@ class TaskController extends AdminController
...
@@ -35,9 +36,14 @@ class TaskController extends AdminController
protected
function
getData
()
protected
function
getData
()
{
{
return
Grid
::
make
(
new
Task
(),
function
(
Grid
$grid
)
{
$user
=
Admin
::
user
();
$user
=
Admin
::
user
();
$exists
=
TasksReceive
::
query
()
->
where
(
'user_id'
,
$user
->
id
)
->
pluck
(
'task_id'
)
->
toArray
();
// $model = \App\Models\Task::query()->whereNotIn('id',$exists)
return
Grid
::
make
(
new
Task
(),
function
(
Grid
$grid
)
use
(
$user
,
$exists
)
{
$grid
->
model
()
->
whereNotIn
(
'id'
,
$exists
);
// dd(Admin::user()->is_admin);
// dd(Admin::user()->is_admin);
// dd(trans('admin.view'));//查看
// dd(trans('admin.view'));//查看
...
@@ -74,12 +80,11 @@ class TaskController extends AdminController
...
@@ -74,12 +80,11 @@ class TaskController extends AdminController
$grid
->
disableEditButton
()
->
disableDeleteButton
()
->
disableCreateButton
();
$grid
->
disableEditButton
()
->
disableDeleteButton
()
->
disableCreateButton
();
$grid
->
disableBatchDelete
();
$grid
->
disableBatchDelete
();
$grid
->
tools
(
function
(
Grid\Tools
$tools
)
use
(
$user
)
{
if
(
$user
->
is_admin
==
0
)
{
$tools
->
append
(
new
BatchReceiveAction
());
//新增批量领取按钮
}
});
if
(
$user
->
is_admin
==
0
)
{
$grid
->
tools
(
new
BatchReceiveAction
(
'<button data-action="refresh" class="btn btn-primary grid-refresh btn-mini btn-outline" style="margin-right:3px">
<i class="feather icon-check-circle"></i><span class="d-none d-sm-inline"> 批量领取</span></button>'
));
}
});
});
}
}
...
@@ -214,7 +219,9 @@ class TaskController extends AdminController
...
@@ -214,7 +219,9 @@ class TaskController extends AdminController
$form
->
select
(
'level'
)
->
options
([
1
=>
1
,
2
=>
2
,
3
=>
3
,
4
=>
4
,
5
=>
5
])
->
required
();
$form
->
select
(
'level'
)
->
options
([
1
=>
1
,
2
=>
2
,
3
=>
3
,
4
=>
4
,
5
=>
5
])
->
required
();
// $form->select('province_id', '省')->options($arr)->loads('city_id', '/getCity');
// $form->select('province_id', '省')->options($arr)->loads('city_id', '/getCity');
$form
->
multipleSelect
(
'city_id'
,
'选择地区'
)
->
options
(
'/getCity'
)
->
required
();
$form
->
multipleSelect
(
'city_id'
,
'选择地区'
)
->
options
(
'/getCity'
)
->
required
()
->
saving
(
function
(
$v
){
return
$v
[
0
];
});
// $form->distpicker([
// $form->distpicker([
// 'province_id' => '省',
// 'province_id' => '省',
...
...
app/Admin/Extensions/Tools/BatchReceiveAction.php
View file @
cb995417
<?php
<?php
namespace
App\Admin\Extensions\Tools
;
namespace
App\Admin\Extensions\Tools
;
use
Dcat\Admin\Grid\RowAction
;
use
App\Admin\Services\CityAreaService
;
use
App\Models\Task
;
use
App\Models\TasksApprove
;
use
App\Models\TasksCollect
;
use
App\Models\TasksOrder
;
use
App\Models\TasksReceive
;
use
Dcat\Admin\Admin
;
use
Dcat\Admin\Grid\BatchAction
;
use
Illuminate\Http\Request
;
use
Illuminate\Http\Request
;
class
BatchReceiveAction
extends
RowAction
class
BatchReceiveAction
extends
BatchAction
{
{
protected
$action
;
/**
// 注意action的构造方法参数一定要给默认值
* 返回字段标题
public
function
__construct
(
$title
=
null
,
$action
=
1
)
*
*
* * @return string
*/
public
function
title
()
{
{
$this
->
title
=
$title
;
return
'<button data-action="refresh" class="btn btn-primary grid-refresh btn-mini btn-outline" style="margin-right:3px">
$this
->
action
=
$action
;
<i class="feather icon-check-circle"></i><span class="d-none d-sm-inline"> 批量领取</span></button>'
;
}
}
/**
// 确认弹窗信息
* 添加JS
public
function
confirm
()
*
{
*
return
'您确定要领取吗?'
;
* * @return string
}
*/
/**
// 处理请求
* 处理请求,如果不需要接口处理,请直接删除这个方法
*
* @param Request $request
*
* @return \Dcat\Admin\Actions\Response
*/
public
function
handle
(
Request
$request
)
public
function
handle
(
Request
$request
)
{
{
// 获取主键
// 获取选中的ID数组
$key
=
$this
->
getKey
();
$keys
=
$this
->
getKey
();
$user
=
\Admin
::
user
();
// dd($key);
$counts
=
TasksReceive
::
query
()
->
where
(
'user_id'
,
$user
->
id
)
->
where
(
'status'
,
0
)
->
count
();
if
(
count
(
$keys
)
+
$counts
>
10
){
return
$this
->
response
()
return
$this
->
response
()
->
error
(
'最多只能领取十个任务'
);
->
success
(
'Processed successfully.'
)
}
->
redirect
(
'/'
);
// 获取请求参数
foreach
(
$keys
as
$id
){
$exists
=
TasksReceive
::
query
()
->
where
(
'task_id'
,
$id
)
->
where
(
'user_id'
,
$user
->
id
)
->
exists
();
// dd()
$task
=
Task
::
query
()
->
find
(
$id
);
if
(
!
$exists
&&
$task
->
num
>
0
){
$receive
=
TasksReceive
::
query
()
->
create
([
'task_id'
=>
$id
,
'user_id'
=>
$user
->
id
,
'area'
=>
CityAreaService
::
getAreaName
(
$task
->
city_id
),
]);
$task
->
num
-=
1
;
$task
->
save
();
TasksCollect
::
query
()
->
updateOrCreate
([
//默认新增一条收集数据的记录
'task_id'
=>
$id
,
'user_id'
=>
$user
->
id
,
'receive_id'
=>
$receive
->
id
,
],[
'task_id'
=>
$id
,
'user_id'
=>
$user
->
id
,
'receive_id'
=>
$receive
->
id
,
]);
}
}
return
$this
->
response
()
->
success
(
'领取成功'
)
->
refresh
();
}
}
public
function
html
()
// 设置请求参数
public
function
parameters
()
{
{
return
[
// $this->setHtmlAttribute(['data-excel' => $this->row->excel_url, 'class' => 'download-btn fa fa-download']);
'action'
=>
$this
->
action
,
];
return
parent
::
html
();
}
}
}
}
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