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
a841ad99
Commit
a841ad99
authored
Jan 16, 2024
by
汪伟伟
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
地区多选
parent
8bc1dbc5
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
60 additions
and
34 deletions
+60
-34
.env.example
+1
-1
app/Admin/Controllers/TaskController.php
+46
-24
app/Admin/Controllers/TasksApproveController.php
+1
-5
app/Admin/routes.php
+3
-0
app/Models/Task.php
+6
-1
app/china_all_area.json
+3
-3
No files found.
.env.example
View file @
a841ad99
APP_NAME=Laravel
APP_NAME=Laravel
APP_ENV=local
APP_ENV=local
APP_KEY=base64:wHGDcJa6sO4Z52I01OWMrNUaWDcDd4iqjs5LrlssMmM=
APP_KEY=base64:wHGDcJa6sO4Z52I01OWMrNUaWDcDd4iqjs5LrlssMmM=
APP_DEBUG=
tru
e
APP_DEBUG=
fals
e
APP_URL=http://localhost
APP_URL=http://localhost
LOG_LEVEL=debug
LOG_LEVEL=debug
...
...
app/Admin/Controllers/TaskController.php
View file @
a841ad99
...
@@ -12,6 +12,7 @@ use Dcat\Admin\Grid;
...
@@ -12,6 +12,7 @@ use Dcat\Admin\Grid;
use
Dcat\Admin\Layout\Content
;
use
Dcat\Admin\Layout\Content
;
use
Dcat\Admin\Show
;
use
Dcat\Admin\Show
;
use
Dcat\Admin\Http\Controllers\AdminController
;
use
Dcat\Admin\Http\Controllers\AdminController
;
use
Illuminate\Http\Request
;
use
Illuminate\Support\Facades\Auth
;
use
Illuminate\Support\Facades\Auth
;
...
@@ -62,10 +63,10 @@ class TaskController extends AdminController
...
@@ -62,10 +63,10 @@ class TaskController extends AdminController
});
});
$grid
->
actions
(
function
(
Grid\Displayers\Actions
$actions
)
use
(
$user
)
{
$grid
->
actions
(
function
(
Grid\Displayers\Actions
$actions
)
use
(
$user
)
{
if
(
$user
->
is_admin
==
0
){
if
(
$user
->
is_admin
==
0
)
{
if
(
$this
->
num
>
0
&&
!
TasksReceive
::
query
()
->
where
(
'task_id'
,
$this
->
id
)
->
where
(
'user_id'
,
$user
->
id
)
->
exists
())
{
if
(
$this
->
num
>
0
&&
!
TasksReceive
::
query
()
->
where
(
'task_id'
,
$this
->
id
)
->
where
(
'user_id'
,
$user
->
id
)
->
exists
())
{
$actions
->
append
(
new
ReceiveAction
());
//领取按钮
$actions
->
append
(
new
ReceiveAction
());
//领取按钮
}
}
}
}
...
@@ -73,7 +74,7 @@ class TaskController extends AdminController
...
@@ -73,7 +74,7 @@ class TaskController extends AdminController
$grid
->
disableEditButton
()
->
disableDeleteButton
()
->
disableCreateButton
();
$grid
->
disableEditButton
()
->
disableDeleteButton
()
->
disableCreateButton
();
$grid
->
disableBatchDelete
();
$grid
->
disableBatchDelete
();
$grid
->
tools
(
function
(
Grid\Tools
$tools
)
use
(
$user
){
$grid
->
tools
(
function
(
Grid\Tools
$tools
)
use
(
$user
)
{
if
(
$user
->
is_admin
==
0
)
{
if
(
$user
->
is_admin
==
0
)
{
$tools
->
append
(
new
BatchReceiveAction
());
//新增批量领取按钮
$tools
->
append
(
new
BatchReceiveAction
());
//新增批量领取按钮
}
}
...
@@ -89,7 +90,7 @@ class TaskController extends AdminController
...
@@ -89,7 +90,7 @@ class TaskController extends AdminController
*/
*/
protected
function
receiveDetail
(
$id
)
protected
function
receiveDetail
(
$id
)
{
{
return
Show
::
make
(
$id
,
new
Task
(),
function
(
Show
$show
)
use
(
$id
)
{
return
Show
::
make
(
$id
,
new
Task
(),
function
(
Show
$show
)
use
(
$id
)
{
$show
->
field
(
'id'
);
$show
->
field
(
'id'
);
$show
->
field
(
'name'
);
$show
->
field
(
'name'
);
$show
->
field
(
'level'
);
$show
->
field
(
'level'
);
...
@@ -159,7 +160,7 @@ class TaskController extends AdminController
...
@@ -159,7 +160,7 @@ class TaskController extends AdminController
*/
*/
protected
function
detail
(
$id
)
protected
function
detail
(
$id
)
{
{
return
Show
::
make
(
$id
,
new
Task
(),
function
(
Show
$show
)
use
(
$id
)
{
return
Show
::
make
(
$id
,
new
Task
(),
function
(
Show
$show
)
use
(
$id
)
{
$show
->
field
(
'id'
);
$show
->
field
(
'id'
);
$show
->
field
(
'name'
);
$show
->
field
(
'name'
);
$show
->
field
(
'level'
);
$show
->
field
(
'level'
);
...
@@ -176,6 +177,27 @@ class TaskController extends AdminController
...
@@ -176,6 +177,27 @@ class TaskController extends AdminController
}
}
public
function
getCity
(
Request
$request
)
{
// $provinceId = $request->get('q');
$data
=
json_decode
(
file_get_contents
(
base_path
(
'app/china_all_area.json'
)),
true
);
$city
=
[];
foreach
(
$data
[
'100000'
]
as
$key
=>
$value
)
{
if
(
isset
(
$data
[
$key
]))
{
foreach
(
$data
[
$key
]
as
$k
=>
$val
)
{
$city
[]
=
[
'id'
=>
$k
,
'text'
=>
$val
];
}
}
}
return
$city
;
}
/**
/**
* Make a form builder.
* Make a form builder.
...
@@ -185,23 +207,19 @@ class TaskController extends AdminController
...
@@ -185,23 +207,19 @@ class TaskController extends AdminController
protected
function
form
()
protected
function
form
()
{
{
// $data = json_decode(file_get_contents(base_path('app/china_all_area.json')), true);
// $data = json_decode(file_get_contents(base_path('app/china_all_area.json')), true);
// foreach ($data as $key=>$datum) {
// $arr = $data['100000'];
// if (array_key_exists($key, $data['100000'])) {
// foreach ($datum as $k => $d) {
// $arr[$k] = $d;
// }
// }
// }
return
Form
::
make
(
new
Task
(),
function
(
Form
$form
)
{
return
Form
::
make
(
new
Task
(),
function
(
Form
$form
)
{
$form
->
display
(
'id'
);
$form
->
display
(
'id'
);
$form
->
text
(
'name'
)
->
required
();
$form
->
text
(
'name'
)
->
required
();
$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->multipleSelect('area', '选择地区')->options($arr)->value('110000')->required();
// $form->select('province_id', '省')->options($arr)->loads('city_id', '/getCity');
$form
->
distpicker
([
'province_id'
=>
'省'
,
$form
->
multipleSelect
(
'city_id'
,
'选择地区'
)
->
options
(
'/getCity'
)
->
required
();
'city_id'
=>
'市'
,
],
'选择地区'
)
->
required
();
// $form->distpicker([
// $form->timeRange('year','year','选择时间');
// 'province_id' => '省',
// 'city_id' => '市',
// ], '选择地区')->required();
$form
->
multipleSelect
(
'year'
,
'选择时间'
)
->
options
(
function
()
{
$form
->
multipleSelect
(
'year'
,
'选择时间'
)
->
options
(
function
()
{
$year
=
(
int
)
date
(
'Y'
);
$year
=
(
int
)
date
(
'Y'
);
...
@@ -210,7 +228,7 @@ class TaskController extends AdminController
...
@@ -210,7 +228,7 @@ class TaskController extends AdminController
}
}
return
$years
;
return
$years
;
})
->
value
(
2024
)
->
required
();
})
->
value
(
2024
)
->
required
();
$form
->
url
(
'refer'
,
'参考信源'
)
->
required
();
$form
->
text
(
'refer'
,
'参考信源'
)
->
required
();
$form
->
editor
(
'guide'
,
'收集指南'
)
->
required
();
$form
->
editor
(
'guide'
,
'收集指南'
)
->
required
();
// $form->text('status');
// $form->text('status');
...
@@ -257,14 +275,17 @@ class TaskController extends AdminController
...
@@ -257,14 +275,17 @@ class TaskController extends AdminController
// dd($request->input());
// dd($request->input());
$param
=
$request
->
input
();
$param
=
$request
->
input
();
$query
=
\App\Models\Task
::
query
();
$query
=
\App\Models\Task
::
query
();
foreach
(
$param
[
'city_id'
]
as
$city
)
{
if
(
$city
)
{
foreach
(
$param
[
'year'
]
as
$y
)
{
foreach
(
$param
[
'year'
]
as
$y
)
{
if
(
$y
)
{
if
(
$y
)
{
$insertData
=
[
$insertData
=
[
'name'
=>
$param
[
'name'
],
'name'
=>
$param
[
'name'
],
'level'
=>
$param
[
'level'
],
'level'
=>
$param
[
'level'
],
'province_id'
=>
$param
[
'province_id'
]
,
'province_id'
=>
''
,
'city_id'
=>
$param
[
'city_id'
]
,
'city_id'
=>
$city
,
'year'
=>
[
$y
],
'year'
=>
[
$y
],
'refer'
=>
$param
[
'refer'
],
'refer'
=>
$param
[
'refer'
],
'guide'
=>
$param
[
'guide'
],
'guide'
=>
$param
[
'guide'
],
...
@@ -272,7 +293,8 @@ class TaskController extends AdminController
...
@@ -272,7 +293,8 @@ class TaskController extends AdminController
$query
->
create
(
$insertData
);
$query
->
create
(
$insertData
);
}
}
}
}
}
}
$form
=
Form
::
make
();
$form
=
Form
::
make
();
return
$form
->
response
()
->
success
(
'操作成功'
)
->
redirect
(
'tasks'
);
return
$form
->
response
()
->
success
(
'操作成功'
)
->
redirect
(
'tasks'
);
...
...
app/Admin/Controllers/TasksApproveController.php
View file @
a841ad99
...
@@ -159,9 +159,5 @@ class TasksApproveController extends AdminController
...
@@ -159,9 +159,5 @@ class TasksApproveController extends AdminController
// ->body($this->form());
// ->body($this->form());
// }
// }
public
function
update
(
$id
)
{
dd
(
$id
);
return
$this
->
res
;
}
}
}
app/Admin/routes.php
View file @
a841ad99
...
@@ -14,9 +14,12 @@ Route::group([
...
@@ -14,9 +14,12 @@ Route::group([
$router
->
get
(
'/dashboard'
,
'HomeController@index'
);
$router
->
get
(
'/dashboard'
,
'HomeController@index'
);
$router
->
resource
(
'tasks'
,
'TaskController'
);
$router
->
resource
(
'tasks'
,
'TaskController'
);
$router
->
get
(
'receive'
,
'TaskController@receiveIndex'
);
$router
->
get
(
'receive'
,
'TaskController@receiveIndex'
);
$router
->
get
(
'getCity'
,
'TaskController@getCity'
);
$router
->
get
(
'receive/{id}'
,
'TaskController@receiveDetail'
);
$router
->
get
(
'receive/{id}'
,
'TaskController@receiveDetail'
);
...
...
app/Models/Task.php
View file @
a841ad99
...
@@ -24,8 +24,8 @@ class Task extends Model
...
@@ -24,8 +24,8 @@ class Task extends Model
protected
$fillable
=
[
protected
$fillable
=
[
'name'
,
'name'
,
'level'
,
'level'
,
'province_id'
,
'city_id'
,
'city_id'
,
'province_id'
,
'year'
,
'year'
,
'refer'
,
'refer'
,
'guide'
,
'guide'
,
...
@@ -55,6 +55,11 @@ class Task extends Model
...
@@ -55,6 +55,11 @@ class Task extends Model
$this
->
attributes
[
'year'
]
=
implode
(
','
,
$value
);
$this
->
attributes
[
'year'
]
=
implode
(
','
,
$value
);
}
}
public
function
setCityIdAttribute
(
$value
)
{
$this
->
attributes
[
'city_id'
]
=
implode
(
','
,
$value
);
}
public
function
approves
()
public
function
approves
()
{
{
return
$this
->
hasMany
(
TasksApprove
::
class
,
'task_id'
);
return
$this
->
hasMany
(
TasksApprove
::
class
,
'task_id'
);
...
...
app/china_all_area.json
View file @
a841ad99
...
@@ -36,7 +36,7 @@
...
@@ -36,7 +36,7 @@
"820000"
:
"澳门特别行政区"
"820000"
:
"澳门特别行政区"
},
},
"110000"
:
{
"110000"
:
{
"110100"
:
"北京
城区
"
"110100"
:
"北京"
},
},
"110100"
:
{
"110100"
:
{
"110101"
:
"东城区"
,
"110101"
:
"东城区"
,
...
@@ -57,7 +57,7 @@
...
@@ -57,7 +57,7 @@
"110119"
:
"延庆区"
"110119"
:
"延庆区"
},
},
"120000"
:
{
"120000"
:
{
"120100"
:
"天津
城区
"
"120100"
:
"天津"
},
},
"120100"
:
{
"120100"
:
{
"120101"
:
"和平区"
,
"120101"
:
"和平区"
,
...
@@ -970,7 +970,7 @@
...
@@ -970,7 +970,7 @@
"232722"
:
"塔河县"
"232722"
:
"塔河县"
},
},
"310000"
:
{
"310000"
:
{
"310100"
:
"上海
城区
"
"310100"
:
"上海"
},
},
"310100"
:
{
"310100"
:
{
"310101"
:
"黄浦区"
,
"310101"
:
"黄浦区"
,
...
...
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