Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
backend
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
亲子游项目
backend
Commits
26d04e02
Commit
26d04e02
authored
Dec 14, 2018
by
LiuJunYi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
区域管理BUG修复
parent
ee5c38d7
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
8 deletions
+33
-8
application/admin/controller/Region.php
+22
-4
application/admin/view/public/sidebar.html
+1
-1
application/admin/view/region/index.html
+10
-3
No files found.
application/admin/controller/Region.php
View file @
26d04e02
...
...
@@ -53,7 +53,9 @@ class Region extends AuthBase
public
function
del
()
{
if
(
request
()
->
isAjax
())
{
$res
=
RegionModel
::
destroy
(
input
(
'id'
));
$ids
=
$this
->
getAllIds
([
input
(
'id'
)]);
array_unshift
(
$ids
,
input
(
'id'
));
$res
=
RegionModel
::
destroy
(
$ids
);
if
(
$res
)
{
return
json
([
'code'
=>
0
,
'msg'
=>
'删除成功'
]);
}
...
...
@@ -62,6 +64,22 @@ class Region extends AuthBase
}
/**
* 获取所有的分类
* @param $id
*/
public
function
getAllIds
(
$ids
=
[
18
])
{
static
$list
=
[];
$pids
=
RegionModel
::
where
(
'pid'
,
'in'
,
$ids
)
->
column
(
'id'
);
if
(
$pids
)
{
$list
=
array_merge
(
$list
,
$pids
);
self
::
getAllIds
(
$pids
);
}
return
$list
;
}
/**
* 修改
* @return \think\response\Json
*/
...
...
@@ -87,14 +105,14 @@ class Region extends AuthBase
*/
public
function
select
()
{
if
(
input
(
'id'
)
==
0
)
{
if
(
input
(
'id'
)
==
0
)
{
return
[];
}
$list
=
RegionModel
::
where
(
'pid'
,
input
(
'id'
))
->
select
();
if
(
!
$list
)
{
if
(
!
$list
)
{
return
[];
}
$list
=
collection
(
$list
)
->
visible
([
'id'
,
'title'
]);
$list
=
collection
(
$list
)
->
visible
([
'id'
,
'title'
]);
return
json
(
$list
);
}
...
...
application/admin/view/public/sidebar.html
View file @
26d04e02
...
...
@@ -46,7 +46,7 @@
<a
href=
"<?php echo url("
@
admin
/
Project
/
tags
")?
>
">标签管理
</a>
</li>
<li
<?
php
if
(
CONTROLLER_NAME =
=
'
Region
'&&(
ACTION_NAME=
='citys'||ACTION_NAME=='index')){echo
'
class=
"active"
';}?
>
>
<a
href=
"<?php echo url("
@
admin
/
Region
/
index
")?
>
">
城市
管理
</a>
<a
href=
"<?php echo url("
@
admin
/
Region
/
index
")?
>
">
区域
管理
</a>
</li>
</ul>
</li>
...
...
application/admin/view/region/index.html
View file @
26d04e02
...
...
@@ -84,7 +84,7 @@
});
//只展开树形的第一级节点
$table
.
treegrid
(
'getRootNodes'
).
treegrid
(
'expand'
);
$table
.
treegrid
(
'getRootNodes'
).
treegrid
(
'expand
All
'
);
},
onCheck
:
function
(
row
)
{
...
...
@@ -117,8 +117,7 @@
'<button type="button" class="RoleOfdelete btn-small btn btn-danger" style="margin-right:15px;"><i class="fa fa-trash-o" ></i> 删除</button>'
];
if
(
row
.
level
>=
3
)
{
arr
.
shift
();
arr
.
shift
();
arr
.
splice
(
1
,
1
);
}
return
"<div class=
\"
form-inline
\"
style='float: right;'>"
+
arr
.
join
(
''
)
+
"</div>"
;
...
...
@@ -155,6 +154,10 @@
<script>
function
add
(
id
)
{
var
title
=
$
(
"#title_"
+
id
).
val
();
if
(
title
.
trim
().
length
===
0
)
{
layer
.
msg
(
'名称不能为空'
,{
icon
:
2
});
return
false
;
}
$
.
post
(
"{:url('add')}"
,
{
title
:
title
,
pid
:
id
},
function
(
res
)
{
if
(
res
.
code
===
0
)
{
location
.
reload
();
...
...
@@ -180,6 +183,10 @@
function
update
(
id
)
{
var
title
=
$
(
"#title_"
+
id
).
val
();
$
.
post
(
"{:url('edit')}"
,
{
title
:
title
,
id
:
id
},
function
(
res
)
{
if
(
title
.
trim
().
length
===
0
)
{
layer
.
msg
(
'名称不能为空'
,{
icon
:
2
});
return
false
;
}
if
(
res
.
code
===
0
)
{
location
.
reload
();
}
else
{
...
...
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