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
9086adf8
Commit
9086adf8
authored
Jan 24, 2024
by
汪伟伟
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
指标名称重复判断,地区下拉框先加载之前用过的地区
parent
ac3b1101
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
8 deletions
+23
-8
app/Admin/Controllers/TaskController.php
+23
-8
No files found.
app/Admin/Controllers/TaskController.php
View file @
9086adf8
...
@@ -215,22 +215,32 @@ class TaskController extends AdminController
...
@@ -215,22 +215,32 @@ class TaskController extends AdminController
public
function
getCity
(
Request
$request
)
public
function
getCity
(
Request
$request
)
{
{
// $provinceId = $request->get('q');
// $provinceId = $request->get('q');
$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
);
$city
=
[];
$city
=
[];
$already
=
\App\Models\Task
::
query
()
->
orderBy
(
'created_at'
,
'desc'
)
->
pluck
(
'city_id'
)
->
toArray
();
$already
=
array_unique
(
$already
);
foreach
(
$data
[
'100000'
]
as
$key
=>
$value
)
{
foreach
(
$data
[
'100000'
]
as
$key
=>
$value
)
{
if
(
isset
(
$data
[
$key
]))
{
if
(
isset
(
$data
[
$key
]))
{
foreach
(
$data
[
$key
]
as
$k
=>
$val
)
{
foreach
(
$data
[
$key
]
as
$k
=>
$val
)
{
if
(
!
in_array
(
$k
,
$already
)){
$city
[]
=
[
$city
[]
=
[
'id'
=>
$k
,
'id'
=>
$k
,
'text'
=>
$val
'text'
=>
$val
];
];
}
}
}
}
}
}
}
$left
=
[];
return
$city
;
foreach
(
$already
as
$a
){
$left
[]
=
[
'id'
=>
$a
,
'text'
=>
CityAreaService
::
getAreaName
(
$a
)
];
}
// dd($left,array_merge($left,$city));
return
array_merge
(
$left
,
$city
);
}
}
...
@@ -356,12 +366,18 @@ class TaskController extends AdminController
...
@@ -356,12 +366,18 @@ class TaskController extends AdminController
$images
.=
$url
.
','
;
$images
.=
$url
.
','
;
}
}
}
}
$form
=
Form
::
make
();
$query
=
\App\Models\Task
::
query
();
foreach
(
$param
[
'city_id'
]
as
$city
)
{
foreach
(
$param
[
'city_id'
]
as
$city
)
{
if
(
$city
)
{
if
(
$city
)
{
foreach
(
$param
[
'year'
]
as
$y
)
{
foreach
(
$param
[
'year'
]
as
$y
)
{
if
(
$y
)
{
if
(
$y
)
{
if
(
\App\Models\Task
::
query
()
->
where
(
'name'
,
$param
[
'name'
])
->
where
(
'city_id'
,
$city
)
->
where
(
'year'
,
$y
)
->
exists
())
{
return
$form
->
response
()
->
error
(
'指标名称重复:'
.
$param
[
'name'
]
.
' '
.
CityAreaService
::
getAreaName
(
$city
)
.
' '
.
$y
);
}
$insertData
=
[
$insertData
=
[
'name'
=>
$param
[
'name'
],
'name'
=>
$param
[
'name'
],
'level'
=>
$param
[
'level'
],
'level'
=>
$param
[
'level'
],
...
@@ -373,12 +389,11 @@ class TaskController extends AdminController
...
@@ -373,12 +389,11 @@ class TaskController extends AdminController
'price'
=>
$param
[
'price'
]
??
0
,
'price'
=>
$param
[
'price'
]
??
0
,
'images'
=>
$images
,
'images'
=>
$images
,
];
];
$query
->
create
(
$insertData
);
\App\Models\Task
::
query
()
->
create
(
$insertData
);
}
}
}
}
}
}
}
}
$form
=
Form
::
make
();
return
$form
->
response
()
->
success
(
'操作成功'
)
->
redirect
(
'tasks'
);
return
$form
->
response
()
->
success
(
'操作成功'
)
->
redirect
(
'tasks'
);
}
}
...
...
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