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
60d3c7b6
Commit
60d3c7b6
authored
Dec 18, 2018
by
LiuJunYi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
标签删除
parent
6450d7e1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
54 additions
and
30 deletions
+54
-30
application/admin/controller/Project.php
+24
-1
application/admin/view/project/tags.html
+30
-29
No files found.
application/admin/controller/Project.php
View file @
60d3c7b6
...
@@ -13,6 +13,8 @@ use app\common\model\Citys;
...
@@ -13,6 +13,8 @@ use app\common\model\Citys;
use
app\common\model\Project
as
ProjectModel
;
use
app\common\model\Project
as
ProjectModel
;
use
app\common\model\Tags
;
use
app\common\model\Tags
;
use
app\common\model\Region
as
RegionModel
;
use
app\common\model\Region
as
RegionModel
;
use
think\Db
;
use
think\Exception
;
class
Project
extends
AuthBase
class
Project
extends
AuthBase
{
{
...
@@ -296,7 +298,28 @@ class Project extends AuthBase
...
@@ -296,7 +298,28 @@ class Project extends AuthBase
//删除标签
//删除标签
public
function
deleteTag
()
public
function
deleteTag
()
{
{
//查询
try
{
Db
::
startTrans
();
//查询project里面的标签
$projects
=
ProjectModel
::
where
(
'tags'
,
'like'
,
'%|'
.
input
(
'id'
)
.
'|%'
)
->
column
(
'id'
);
foreach
(
$projects
as
$v
){
//查询当前项目
$project
=
ProjectModel
::
get
(
$v
);
$tags
=
trim
(
$project
->
getData
(
'tags'
),
'|'
);
$tempArr
=
explode
(
'|'
,
$tags
);
unset
(
$tempArr
[
array_search
(
input
(
'id'
),
$tempArr
)]);
$project
->
tags
=
$tempArr
;
$project
->
isUpdate
(
true
)
->
save
();
}
//删除标签
Tags
::
destroy
(
input
(
'id'
));
Db
::
commit
();
return
[
'code'
=>
0
,
'msg'
=>
'删除成功'
];
}
catch
(
Exception
$e
){
Db
::
rollback
();
return
[
'code'
=>
0
,
'msg'
=>
'删除失败'
];
}
}
}
// 预约管理
// 预约管理
...
...
application/admin/view/project/tags.html
View file @
60d3c7b6
...
@@ -7,9 +7,10 @@
...
@@ -7,9 +7,10 @@
<div
class=
"row margin-bottom"
>
<div
class=
"row margin-bottom"
>
<div
class=
"col-md-12"
>
<div
class=
"col-md-12"
>
<form
class=
"form-inline pull-left"
method=
"GET"
action=
"{:url('admin/project/tags')}"
>
<form
class=
"form-inline pull-left"
method=
"GET"
action=
"{:url('admin/project/tags')}"
>
<div
class=
"form-group margin-right"
>
<div
class=
"form-group margin-right"
>
<input
class=
"form-control"
type=
"text"
name=
"name"
id=
"name"
value=
"<?php echo input('title');?>"
placeholder=
"标签名"
/>
<input
class=
"form-control"
type=
"text"
name=
"name"
id=
"name"
value=
"<?php echo input('title');?>"
placeholder=
"标签名"
/>
</div>
</div>
<button
type=
"submit"
class=
"btn btn-primary"
>
搜索
</button>
<button
type=
"submit"
class=
"btn btn-primary"
>
搜索
</button>
...
@@ -24,7 +25,7 @@
...
@@ -24,7 +25,7 @@
<label
for=
""
>
排序
</label>
<label
for=
""
>
排序
</label>
<input
type=
"number"
class=
"form-control"
style=
"width: 70px"
name=
"sort"
>
<input
type=
"number"
class=
"form-control"
style=
"width: 70px"
name=
"sort"
>
</div>
</div>
<button
type=
"submit"
class=
"btn btn-success"
>
添加
</button>
<button
type=
"submit"
class=
"btn btn-success"
>
添加
</button>
</form>
</form>
</div>
</div>
</div>
</div>
...
@@ -34,11 +35,11 @@
...
@@ -34,11 +35,11 @@
<div
class=
"table-responsive"
>
<div
class=
"table-responsive"
>
<table
class=
"table table-bordered table-striped"
>
<table
class=
"table table-bordered table-striped"
>
<!--<colgroup>-->
<!--<colgroup>-->
<!--<col style="width: 2%;">-->
<!--<col style="width: 2%;">-->
<!--<col style="width: 80%;">-->
<!--<col style="width: 80%;">-->
<!--<col style="width: 5%;">-->
<!--<col style="width: 5%;">-->
<!--<col style="width: 5%;">-->
<!--<col style="width: 5%;">-->
<!--<col style="width: 10%;">-->
<!--<col style="width: 10%;">-->
<!--</colgroup>-->
<!--</colgroup>-->
<thead>
<thead>
<tr>
<tr>
...
@@ -59,8 +60,10 @@
...
@@ -59,8 +60,10 @@
<td>
{$vo.sort}
</td>
<td>
{$vo.sort}
</td>
<td>
{$vo.created_at}
</td>
<td>
{$vo.created_at}
</td>
<td>
<td>
<a
href=
"{:url('admin/project/editTag',['id'=>$vo.id])}"
class=
"btn btn-xs btn-primary"
><i
class=
"fa fa-pencil"
></i></a>
<a
href=
"{:url('admin/project/editTag',['id'=>$vo.id])}"
class=
"btn btn-xs btn-primary"
><i
<a
href=
"javascript:"
oid=
"{$vo.id}"
class=
"btn btn-xs btn-danger btn-delete"
><i
class=
"fa fa-trash"
></i></a>
class=
"fa fa-pencil"
></i></a>
<a
href=
"javascript:"
oid=
"{$vo.id}"
class=
"btn btn-xs btn-danger btn-delete"
><i
class=
"fa fa-trash"
></i></a>
</td>
</td>
</tr>
</tr>
{/volist}
{/volist}
...
@@ -78,24 +81,22 @@
...
@@ -78,24 +81,22 @@
<script
type=
"text/javascript"
>
<script
type=
"text/javascript"
>
// 文档加载完毕之后,会进入该方法
// 文档加载完毕之后,会进入该方法
$
(
function
(){
$
(
function
()
{
$
(
".btn-delete"
).
click
(
function
(){
$
(
".btn-delete"
).
click
(
function
()
{
var
_this
=
$
(
this
);
var
_this
=
$
(
this
);
var
url
=
"{:url('admin/project/deleteTag')}"
;
var
url
=
"{:url('admin/project/deleteTag')}"
;
var
oid
=
_this
.
attr
(
'oid'
);
var
oid
=
_this
.
attr
(
'oid'
);
showDialog
(
"提示"
,
"确定删除该标签吗?"
,
function
(){
showDialog
(
"提示"
,
"确定删除该标签吗?"
,
function
()
{
// ajax post 方法
// ajax post 方法
$
.
post
(
url
,
{
id
:
oid
},
function
(
res
)
{
$
.
post
(
url
,
{
id
:
oid
},
function
(
res
)
{
// var res = JSON.parse(res);
// var res = JSON.parse(res);
if
(
res
.
code
==
1
){
if
(
res
.
code
==
0
)
{
// javascript 的默认弹出提示方法
_this
.
remove
();
_this
.
remove
();
$
(
"#tr_"
+
oid
).
fadeOut
();
$
(
"#tr_"
+
oid
).
fadeOut
();
}
}
else
{
layer
.
msg
(
res
.
msg
);
alert
(
res
.
msg
);
});
}
});
});
});
});
});
});
});
</script>
</script>
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