Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
李洋
/
消息系统
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
915e5bdd
authored
Apr 17, 2019
by
李洋
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
消息模板改版 包括列表页 和 新增/编辑页
parent
4260a4a7
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
229 additions
and
179 deletions
app/Http/Controllers/MessageApiController.php
app/Http/Controllers/MessageController.php
config/msgconfig.php
public/js/Message/templatelist.js
resources/views/message.blade.php
resources/views/message/templatelist.blade.php
app/Http/Controllers/MessageApiController.php
View file @
915e5bdd
...
@@ -371,4 +371,13 @@ class MessageApiController extends Controller
...
@@ -371,4 +371,13 @@ class MessageApiController extends Controller
->
where
(
'cls_id'
,
$data
[
'sel_msg_tpl_cls'
])
->
get
();
->
where
(
'cls_id'
,
$data
[
'sel_msg_tpl_cls'
])
->
get
();
$this
->
Export
(
0
,
'success'
,
objectToArray
(
$sub_tpl_info
));
$this
->
Export
(
0
,
'success'
,
objectToArray
(
$sub_tpl_info
));
}
}
private
function
delTpl
(
$request
){
$in_data
=
$request
->
input
();
$res
=
DB
::
connection
(
'message'
)
->
table
(
'lie_msg_tpl'
)
->
where
(
'tpl_id'
,
$in_data
[
'tpl_id'
])
->
update
([
'status'
=>
1
]);
if
(
$res
&&
$res
!==
false
){
$this
->
Export
(
0
,
'success'
);
}
}
}
}
\ No newline at end of file
app/Http/Controllers/MessageController.php
View file @
915e5bdd
...
@@ -176,7 +176,6 @@ class MessageController extends Controller
...
@@ -176,7 +176,6 @@ class MessageController extends Controller
// 消息模板列表
// 消息模板列表
private
function
templatelist
(
Request
$request
,
$id
,
$viewid
)
private
function
templatelist
(
Request
$request
,
$id
,
$viewid
)
{
{
Csrf
(
$request
);
//获取权限
//获取权限
$perms_arr
=
[
'template_check'
,
'template_create'
,
'template_edit'
];
$perms_arr
=
[
'template_check'
,
'template_create'
,
'template_edit'
];
$res_perm
=
$this
->
getUserPerms
(
$request
,
$perms_arr
);
$res_perm
=
$this
->
getUserPerms
(
$request
,
$perms_arr
);
...
@@ -184,70 +183,56 @@ class MessageController extends Controller
...
@@ -184,70 +183,56 @@ class MessageController extends Controller
$template_create
=
$res_perm
[
'template_create'
];
$template_create
=
$res_perm
[
'template_create'
];
$template_edit
=
$res_perm
[
'template_edit'
];
$template_edit
=
$res_perm
[
'template_edit'
];
// $template_check = $template_create = $template_edit =true;
$conditions
=
$request
->
input
();
$info
=
[];
//搜索
$db
=
DB
::
connection
(
'message'
);
$search_desc
=
$request
->
input
(
'search_desc'
);
if
(
!
empty
(
$conditions
[
'page'
])
&&
!
empty
(
$conditions
[
'limit'
])){
$search_channel
=
$request
->
input
(
'search_channel'
);
$info
=
$db
->
table
(
'lie_msg_tpl as mt'
)
->
select
(
'mt.tpl_id'
,
'mt.channels'
,
'mt.description'
,
'mt.ex_str'
,
'mtc.cls_name'
,
'mtsc.sub_cls_name'
,
'mtsc.sub_cls_id'
,
'mtsc.cls_id'
)
$search_keyword
=
$request
->
input
(
'search_keyword'
);
->
leftjoin
(
'lie_msg_tpl_sub_classify as mtsc'
,
'mtsc.sub_cls_id'
,
'='
,
'mt.sub_cls_id'
)
->
leftjoin
(
'lie_msg_tpl_classify as mtc'
,
'mtc.cls_id'
,
'='
,
'mtsc.cls_id'
)
->
where
(
function
(
$query
)
use
(
$conditions
){
if
(
!
empty
(
$conditions
[
'msg_key'
])){
$query
->
where
(
'mt.description'
,
'like'
,
'%'
.
$conditions
[
'msg_key'
]
.
'%'
);
}
if
(
!
empty
(
$conditions
[
'msg_channel'
])){
$query
->
where
(
'mt.channels'
,
'like'
,
'%'
.
$conditions
[
'msg_channel'
]
.
'%'
);
}
if
(
!
empty
(
$conditions
[
'msg_tpl_cls'
])){
$query
->
where
(
'mtsc.cls_id'
,
$conditions
[
'msg_tpl_cls'
]);
}
if
(
!
empty
(
$conditions
[
'msg_tpl_sub_cls'
])){
$query
->
where
(
'mtsc.sub_cls_id'
,
$conditions
[
'msg_tpl_sub_cls'
]);
}
})
->
where
(
'status'
,
0
)
->
where
(
'source_type'
,
1
)
->
orderby
(
'tpl_id'
,
'desc'
)
->
paginate
(
$conditions
[
'limit'
],[
'*'
],
'page'
,
$conditions
[
'page'
])
->
toArray
();
$cnt
=
DB
::
connection
(
'message'
);
foreach
(
$info
[
'data'
]
as
&
$item
){
//自动发送模板数据
$item
=
objectToArray
(
$item
);
//1.首次进页面无搜索条件
$item
[
'cls_name'
]
=
!
empty
(
$item
[
'cls_name'
])
?
$item
[
'cls_name'
]
:
''
;
if
(
$search_desc
==
null
&&
$search_channel
==
null
&&
$search_keyword
==
null
)
$item
[
'sub_cls_name'
]
=
!
empty
(
$item
[
'sub_cls_name'
])
?
$item
[
'sub_cls_name'
]
:
''
;
{
$item
[
'show_channels_str'
]
=
$this
->
changeNumberStrToChineseStr
([
'站内信'
,
'短信'
,
'邮箱'
,
'微信通知'
,
'钉钉消息'
],
$item
[
'channels'
]);
$info
=
$cnt
->
table
(
'lie_msg_tpl'
)
->
where
(
"status"
,
'0'
)
->
where
(
'source_type'
,
'1'
)
->
orderBy
(
'tpl_id'
,
'desc'
)
->
paginate
(
20
);
$search_channel
=
0
;
$search_desc
=
''
;
}
else
//2.有搜索条件
{
//渠道里没有0,所以如果没选,将此条件剔除掉
if
(
0
==
$search_channel
)
{
$info
=
$cnt
->
table
(
'lie_msg_tpl'
)
->
where
(
'source_type'
,
'1'
)
->
where
(
"status"
,
'0'
)
->
where
(
'ex_str'
,
'like'
,
"%
$search_desc
%"
)
->
where
(
'description'
,
'like'
,
"%
$search_keyword
%"
)
->
orderBy
(
'tpl_id'
,
'desc'
)
->
paginate
(
20
);
}
else
{
$info
=
$cnt
->
table
(
'lie_msg_tpl'
)
->
where
(
'source_type'
,
'1'
)
->
where
(
"status"
,
'0'
)
->
where
(
'channels'
,
'like'
,
"%
$search_channel
%"
)
->
where
(
'description'
,
'like'
,
"%
$search_keyword
%"
)
->
where
(
'ex_str'
,
'like'
,
"%
$search_desc
%"
)
->
orderBy
(
'tpl_id'
,
'desc'
)
->
paginate
(
20
);
}
}
unset
(
$item
);
return
json_encode
([
'code'
=>
0
,
'count'
=>
$info
[
'total'
],
'msg'
=>
'success'
,
'data'
=>
$info
[
'data'
]]);
}
}
//构建model
//消息模板分类
foreach
(
$info
as
$tpl
)
$clses
=
[];
{
$cls
=
$db
->
table
(
'lie_msg_tpl_classify'
)
->
select
(
'cls_id'
,
'cls_name'
)
->
get
();
//将消息渠道从 数字字符串转化为汉字字符串 用于用户展示
foreach
(
$cls
as
&
$c
){
$tpl
->
show_channels_str
=
$this
->
changeNumberStrToChineseStr
([
'站内信'
,
'短信'
,
'邮箱'
,
'微信通知'
,
'钉钉消息'
],
$tpl
->
channels
);
$c
=
objectToArray
(
$c
);
$clses
[
$c
[
'cls_id'
]]
=
$c
[
'cls_name'
];
//取出渠道站内信和邮件title 放到info中
$inner_title
=
$cnt
->
table
(
'lie_msg_channel_tpl'
)
->
select
(
'title'
)
->
where
(
'tpl_id'
,
$tpl
->
tpl_id
)
->
where
(
'channel_type'
,
1
)
->
first
();
$email_title
=
$cnt
->
table
(
'lie_msg_channel_tpl'
)
->
select
(
'title'
)
->
where
(
'tpl_id'
,
$tpl
->
tpl_id
)
->
where
(
'channel_type'
,
3
)
->
first
();
$tpl
->
title
=
'-'
;
if
(
!
empty
(
$inner_title
->
title
))
{
$tpl
->
title
=
$inner_title
->
title
;
}
else
if
(
!
empty
(
$email_title
->
title
))
{
$tpl
->
title
=
$email_title
->
title
;
}
}
}
$msg_channels
=
[
unset
(
$c
);
'全部'
,
'站内信'
,
'短信'
,
'邮件'
,
'微信通知'
,
'钉钉通知'
];
$data
=
[
$data
=
[
'title'
=>
'asd'
,
'title'
=>
'asd'
,
'id'
=>
$id
,
'id'
=>
$id
,
'info'
=>
$info
,
'info'
=>
$info
,
'msg_channels'
=>
$msg_channels
,
'clses'
=>
$clses
,
'search_desc'
=>
$search_desc
,
'search_channel'
=>
$search_channel
,
'search_keyword'
=>
$search_keyword
,
'template_check'
=>
$template_check
,
'template_check'
=>
$template_check
,
'template_create'
=>
$template_create
,
'template_create'
=>
$template_create
,
...
...
config/msgconfig.php
View file @
915e5bdd
...
@@ -56,6 +56,6 @@ return [
...
@@ -56,6 +56,6 @@ return [
2
=>
'活动'
,
2
=>
'活动'
,
3
=>
'新闻'
,
3
=>
'新闻'
,
4
=>
'其他'
4
=>
'其他'
]
]
,
];
];
\ No newline at end of file
public/js/Message/templatelist.js
View file @
915e5bdd
//指定条件搜索
layui
.
use
([
'jquery'
,
'element'
,
'layer'
,
'form'
,
'table'
,
'laypage'
,
'laydate'
],
function
(){
$
(
'#search-btn'
).
click
(
function
()
{
var
$
=
layui
.
$
;
var
search_desc
=
$
(
'#search-desc'
).
val
();
var
element
=
layui
.
element
;
var
search_keyword
=
$
(
'#search-keyword'
).
val
();
var
layer
=
layui
.
layer
;
var
search_channel
=
$
(
'#choose-tpl option:selected'
).
val
();
var
form
=
layui
.
form
;
window
.
location
.
href
=
"/message/templatelist?search_desc="
+
search_desc
+
"&search_channel="
+
search_channel
+
"&search_keyword="
+
search_keyword
;
var
table
=
layui
.
table
;
})
\ No newline at end of file
//监听模板分类选择 并刷新二级分类数据
form
.
on
(
'select(msg_tpl_cls)'
,
function
(
data
){
var
sel_msg_tpl_cls
=
data
.
value
;
$
.
ajax
({
url
:
"/msgapi/getSubTplCls"
,
dataType
:
'json'
,
data
:
{
sel_msg_tpl_cls
:
sel_msg_tpl_cls
},
success
:
function
(
result
)
{
var
optionstring
=
""
;
$
.
each
(
result
.
data
,
function
(
i
,
item
){
optionstring
+=
"<option value="
+
item
.
sub_cls_id
+
">"
+
item
.
sub_cls_name
+
"</option>"
;
});
$
(
"#msg_tpl_sub_cls"
).
html
(
'<option value=""></option>'
+
optionstring
);
form
.
render
(
'select'
);
}
});
});
//监听表单提交按钮
form
.
on
(
'submit(search)'
,
function
(
data
){
//根据搜索条件 重载表单
msg_tpl_table
.
reload
({
where
:
data
.
field
,
//设定异步数据接口的额外参数,任意设
page
:
{
curr
:
1
//重新从第 1 页开始
}
});
return
false
;
//阻止表单跳转。如果需要表单跳转,去掉这段即可。
});
//数据表格渲染
var
msg_tpl_table
=
table
.
render
({
elem
:
'#table'
,
url
:
'/message/templatelist'
,
page
:
true
,
limit
:
20
,
id
:
'table'
,
cols
:
[[
//表头
{
field
:
'tpl_id'
,
title
:
'模板编号'
,
align
:
'center'
},
{
field
:
'description'
,
title
:
'关键字'
,
align
:
'center'
},
{
field
:
'cls_name'
,
title
:
'模板分类'
,
align
:
'center'
},
{
field
:
'sub_cls_name'
,
title
:
'模板二级分类'
,
align
:
'center'
},
{
field
:
'show_channels_str'
,
title
:
'消息渠道'
,
align
:
'center'
},
{
field
:
'ex_str'
,
title
:
'消息描述'
,
align
:
'center'
},
{
title
:
'操作'
,
fixed
:
'right'
,
width
:
150
,
align
:
'center'
,
toolbar
:
'#bar'
}
]]
});
//监听工具条
table
.
on
(
'tool(table)'
,
function
(
obj
){
//注:tool是工具条事件名,test是table原始容器的属性 lay-filter="对应的值"
var
data
=
obj
.
data
;
//获得当前行数据
var
layEvent
=
obj
.
event
;
//获得 lay-event 对应的值(也可以是表头的 event 参数对应的值)
var
tr
=
obj
.
tr
;
//获得当前行 tr 的DOM对象
if
(
layEvent
===
'edit'
){
//编辑
window
.
location
.
href
=
'addtemplate?tpl_id='
+
data
.
tpl_id
;
}
else
if
(
layEvent
===
'del'
){
//删除
delTpl
(
data
.
tpl_id
);
}
});
$
(
'#reload_table'
).
on
(
'click'
,
function
()
{
table
.
reload
(
'table'
,{
// where: {activity_id:$('#activity_id').val()},//设定异步数据接口的额外参数,任意设
page
:
{
curr
:
1
//重新从第 1 页开始
}
});
});
form
.
render
();
});
function
delTpl
(
tpl_id
){
$
.
ajax
({
url
:
"/msgapi/delTpl"
,
dataType
:
'json'
,
data
:
{
tpl_id
:
tpl_id
},
success
:
function
(
resp
)
{
if
(
!
resp
){
Prompt
(
'网络异常,请重试'
,
5
);
return
false
;
}
if
(
resp
.
errcode
==
0
){
Prompt
(
resp
.
errmsg
,
1
);
location
.
reload
();
}
else
{
Prompt
(
resp
.
errmsg
,
5
);
return
false
;
}
},
error
:
function
(
jqXHR
,
textStatus
,
errorThrown
){
Prompt
(
"网络异常,请重试"
,
5
);
}
});
}
\ No newline at end of file
resources/views/message.blade.php
View file @
915e5bdd
...
@@ -20,7 +20,7 @@
...
@@ -20,7 +20,7 @@
@endif
@endif
<div
class=
"row"
>
<div
class=
"row"
>
<div
class=
"col-lg-12"
>
<div
class=
"col-lg-12"
>
<iframe
src=
"http://{{ Config::get('website.data') }}/message/{{ $id }}"
style=
"height: 100%;overflow: auto"
id=
"iframe"
></iframe>
<iframe
src=
"http://{{ Config::get('website.data') }}/message/{{ $id }}"
style=
"height: 100%;overflow: auto
;width: 98%;
"
id=
"iframe"
></iframe>
</div>
</div>
</div>
</div>
</div>
</div>
...
...
resources/views/message/templatelist.blade.php
View file @
915e5bdd
<style>
<style>
.p-l
{
.filter-label-left
{
margin
:
20px
;
margin-left
:
40px
;
background-color
:
rgba
(
255
,
249
,
242
,
0.02
);
margin-top
:
20px
;
height
:
auto
;
width
:
150px
;
}
.p-l
label
{
margin-left
:
30px
;
}
}
.
div-b
{
.
filter-select
{
margin-top
:
20px
;
margin-top
:
20px
;
width
:
150px
;
}
}
</style>
</style>
@if($template_check)
@if($template_check)
<div
class=
"gray-bg"
>
<div
class=
"wrapper wrapper-content"
>
<form
class=
"layui-form"
action=
""
>
<div
class=
"row"
>
<div
class=
"col-lg-12"
>
<div
class=
"layui-form-item"
>
<div
class=
"ibox float-e-margins"
>
<div
class=
"layui-inline"
>
<div
class=
"ibox-title"
>
<div
class=
"form-inline p-l"
>
<label
class=
"layui-form-label filter-label-left"
>
消息关键字:
</label>
<form
method=
"get"
action=
"/message/templatelist"
>
<div
class=
"layui-input-inline"
style=
"width: 200px; margin-top: 20px;"
>
<div
style=
"text-align: center"
class=
"div-b"
>
<input
type=
"text"
name=
"msg_key"
autocomplete=
"off"
class=
"layui-input"
style=
"width: 200px;"
/>
</div>
@if($template_create)
<a
class=
"btn btn-primary btn-sm"
href=
"/message/addtemplate"
style=
"float: left; margin-left: 30px"
>
新增消息模板
</a>
<label
class=
"layui-form-label filter-label-left"
>
消息渠道:
</label>
@endif
<div
class=
"layui-input-inline filter-select"
>
<label>
消息关键词(开发使用):
</label>
<select
name=
"msg_channel"
lay-filter=
"msg_channel"
id=
"msg_channel"
>
<input
type=
"text"
class=
"form-control"
id=
"search-keyword"
placeholder=
"请输入消息关键词"
value=
"{{ $search_keyword }}"
>
<option
value=
""
>
请选择
</option>
<label>
消息描述:
</label>
@foreach(Config('msgconfig.msg_channels') as $k=>$v)
<input
type=
"text"
class=
"form-control"
id=
"search-desc"
placeholder=
"请输入消息描述"
value=
"{{ $search_desc }}"
>
<option
value=
"{{$k}}"
>
{{$v}}
</option>
<label>
消息渠道:
</label>
@endforeach
<select
class=
"form-control"
name=
"inner-choose-type"
id=
"choose-tpl"
>
</select>
@for($i=0;$i
<count
($
msg_channels
);$
i
++)
<
option
value=
"{{ $i }}"
@
if
($
i=
=$search_channel)
selected
@
endif
>
{{ $msg_channels[$i] }}
</option>
@endfor
</select>
<input
class=
"btn btn-primary btn-sm"
id=
"search-btn"
style=
"float: right; margin-right: 60px"
value=
"搜索"
/>
</div>
</form>
</div>
</div>
@if(count($info)>0)
<div
class=
"ibox-content"
>
<div
class=
"dataTables_wrapper form-inline dt-bootstrap"
>
<div
class=
"row"
>
<div
class=
"col-sm-12"
>
<table
class=
"table table-striped table-bordered table-hover"
>
<thead>
<tr
role=
"row"
>
<th
style=
"width:100px;"
class=
"text-center"
>
模板编号
</th>
<th
style=
"width:100px;"
class=
"text-center"
>
模板标题
</th>
<th
style=
"width:100px;"
class=
"text-center"
>
关键字
</th>
<th
style=
"width:150px;"
class=
"text-center"
>
消息描述
</th>
<th
style=
"width:100px;"
class=
"text-center"
>
消息渠道
</th>
<th
style=
"width:100px;"
class=
"text-center"
>
操作
</th>
</tr>
</thead>
<tbody>
@for($i=0;$i
<count
($
info
);$
i
++)
<
tr
role=
"row"
style=
"text-align: center"
>
<td>
{{ $info[$i]->tpl_id }}
</td>
<td>
{{ $info[$i]->title }}
</td>
<td>
{{ $info[$i]->description }}
</td>
<td>
{{ $info[$i]->ex_str }}
</td>
<td>
{{ $info[$i]->show_channels_str }}
</td>
@if($template_edit)
<td>
<a
href=
"{{url('message/addtemplate')}}?tpl_id={{$info[$i]->tpl_id}}"
class=
"btn btn-xs btn-outline btn-primary"
>
编辑
</a>
<a
onclick=
"deletemlate({{$info[$i]->tpl_id}})"
href=
"#"
class=
"btn btn-xs btn-outline btn-primary"
>
删除
</a>
</td>
@endif
</tr>
@endfor
</tbody>
</table>
{{--{!! $info->links() !!}--}}
{{$info->appends([
'search_desc'=>$search_desc,
'search_channel'=>$search_channel,
'search_keyword'=>$search_keyword,
])->links() }}
</div>
</div>
<div
class=
"row"
id=
"my_list_paginate"
></div>
</div>
</div>
@else
<div
style=
"text-align: center"
>
<label>
很抱歉,暂无数据
</label>
</div>
@endif
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div
class=
"layui-form-item"
>
<div
class=
"layui-inline"
>
<label
class=
"layui-form-label filter-label-left"
>
消息模板分类:
</label>
<div
class=
"layui-input-inline filter-select"
>
<select
name=
"msg_tpl_cls"
lay-filter=
"msg_tpl_cls"
id=
"msg_tpl_cls"
>
<option
value=
""
>
请选择
</option>
@foreach($clses as $k=>$v)
<option
value=
"{{$k}}"
>
{{$v}}
</option>
@endforeach
</select>
</div>
<label
class=
"layui-form-label filter-label-left"
>
消息模板二级分类:
</label>
<div
class=
"layui-input-inline filter-select"
>
<select
name=
"msg_tpl_sub_cls"
lay-filter=
"msg_tpl_sub_cls"
id=
"msg_tpl_sub_cls"
>
<option
value=
""
>
请选择
</option>
</select>
</div>
<div
class=
"layui-input-inline"
style=
"float:right;margin-top: 20px;"
>
<button
class=
"layui-btn"
lay-submit
lay-filter=
"search"
data-type=
"reload"
>
查询
</button>
</div>
</div>
</div>
</form>
{{--
<button
id=
"reload_table"
hidden
></button>
--}}
<table
class=
"layui-hide"
id=
"table"
lay-filter=
"table"
></table>
<script
type=
"text/html"
id=
"bar"
>
@
if
(
$template_edit
)
<
a
class
=
"layui-btn layui-btn-xs"
lay
-
event
=
"edit"
>
编辑
<
/a
>
<
a
class
=
"layui-btn layui-btn-xs"
lay
-
event
=
"del"
>
删除
<
/a
>
@
endif
</script>
@else
@else
<div
style=
"text-align: center"
>
<div
style=
"text-align: center"
>
<label
style=
"margin-top: 30px"
>
对不起,您没有权限查看此页面
</label>
<label
style=
"margin-top: 30px"
>
对不起,您没有权限查看此页面
</label>
...
@@ -114,26 +87,5 @@
...
@@ -114,26 +87,5 @@
</div>
</div>
</div>
</div>
@endif
@endif
<script
src=
"/js/Message/layer/layer.js"
></script>
<script>
var
deletemplateurl
=
'{{url('
msgapi
/
deletetemplate
')}}'
;
function
deletemlate
(
id
){
layer
.
confirm
(
'确定删除?'
,
{
btn
:
[
'确定'
,
'取消'
]
//按钮
},
function
(){
$
.
post
(
deletemplateurl
,{
'id'
:
id
},
function
(
res
){
if
(
res
.
errcode
==
0
){
layer
.
msg
(
'删除成功'
,
{
icon
:
1
});
window
.
location
.
reload
();
}
else
{
layer
.
msg
(
'删除失败'
,
{
icon
:
1
});
}
},
'json'
);
},
function
(){
});
}
</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