Commit 3678e212 by 李洋

update code

parent 90eb7c01
...@@ -267,18 +267,63 @@ class MessageController extends Controller ...@@ -267,18 +267,63 @@ class MessageController extends Controller
private function addTemplate(Request $request, $id, $viewid) private function addTemplate(Request $request, $id, $viewid)
{ {
Csrf($request); Csrf($request);
$map = $request->input(); $rq_tpl_id = $request->input('tpl_id');
$db = DB::connection('message')->table('lie_msg_tpl'); $db = DB::connection('message');
$info = $db->get(); $isContainInner = '';
if(!empty($map['tpl_id'])) $isContainSMS = '';
$isContainEmail = '';
$isContainWechatNotify = '';
if(!empty($rq_tpl_id))
{ {
//通过tpl_id找到模板的渠道们 和 描述等
$info = $db->table('lie_msg_tpl')->select('tpl_id','description','channels','msg_type')->where('tpl_id',$rq_tpl_id)->first();
//通过找到的 channels 去渠道模板表里 把每个channel找出来
$tpl_channels_arr = explode(',',$info->channels);
$channel_tpls = [];
foreach ($tpl_channels_arr as $channel_type)
{
$channel_tpl_obj = $db->table('lie_msg_channel_tpl')->where('tpl_id',$info->tpl_id)->where('channel_type',$channel_type)->first();
$channel_tpls[$channel_type] = $channel_tpl_obj;
}
$info->channel_tpls = $channel_tpls;
//判断包含的消息渠道(用于展示消息渠道)(利用之前分割字符串得到的数组)
$isContainInner = in_array('1',$tpl_channels_arr);
$isContainSMS = in_array('2',$tpl_channels_arr);
$isContainEmail = in_array('3',$tpl_channels_arr);
$isContainWechatNotify = in_array('4',$tpl_channels_arr);
} }
$info = [];
if(empty($info))
{
$info = (object)null;
$info->tpl_id = '';
$info->description = '';
$info->channels ='';
$info->channel_tpls = [];
$info->msg_type = '';
}
//消息类型枚举
$msg_type = [
'请选择',
'公告',
'活动',
'新闻',
'其他'
];
$data=[ $data=[
'title'=>'asd', 'title'=>'asd',
'id'=>$id, 'id'=>$id,
'info'=>$info 'info'=>$info,
'msg_type'=>$msg_type,
'isContainInner'=>$isContainInner,
'isContainSMS'=>$isContainSMS,
'isContainEmail'=>$isContainEmail,
'isContainWechatNotify'=>$isContainWechatNotify,
]; ];
return view($viewid, $data); return view($viewid, $data);
......
...@@ -38,6 +38,11 @@ $('#msg_tpl_submit').click(function() ...@@ -38,6 +38,11 @@ $('#msg_tpl_submit').click(function()
Prompt('请填写消息内容', 5); Prompt('请填写消息内容', 5);
return false; return false;
} }
if(!$("input[id='inner-tpl-op-url']").is(':checked') && !$("input[id='inner-tpl-op-open']").is(':checked'))
{
Prompt('请选择点击消息操作', 5);
return false;
}
if($("input[id='inner-tpl-op-url']").is(':checked') && !$("#inner-tpl-op-url-text").val()) if($("input[id='inner-tpl-op-url']").is(':checked') && !$("#inner-tpl-op-url-text").val())
{ {
Prompt('请填写要打开的url', 5); Prompt('请填写要打开的url', 5);
......
...@@ -107,17 +107,17 @@ ...@@ -107,17 +107,17 @@
<div class="col-sm-10 form-inline" style="margin-top: 20px"> <div class="col-sm-10 form-inline" style="margin-top: 20px">
<label class="col-sm-2 control-label" id="msg-tpl-channels"><span style="color: red">*</span> 消息渠道:</label> <label class="col-sm-2 control-label" id="msg-tpl-channels"><span style="color: red">*</span> 消息渠道:</label>
<div class="col-sm-4"> <div class="col-sm-4">
<input type="checkbox" name="chk-channels" id="chk-channels-inner" value="1"/><label>站内信</label> <input type="checkbox" name="chk-channels" id="chk-channels-inner" value="1" @if(!empty($isContainInner)) checked @endif/><label>站内信</label>
<input type="checkbox" name="chk-channels" id="chk-channels-sms" value="2"/><label>短息</label> <input type="checkbox" name="chk-channels" id="chk-channels-sms" value="2" @if(!empty($isContainSMS)) checked @endif/><label>短息</label>
<input type="checkbox" name="chk-channels" id="chk-channels-email" value="3"/><label>邮箱</label> <input type="checkbox" name="chk-channels" id="chk-channels-email" value="3" @if(!empty($isContainEmail)) checked @endif/><label>邮箱</label>
<input type="checkbox" name="chk-channels" id="chk-channels-wechat-notify" value="4"/><label>微信通知</label> <input type="checkbox" name="chk-channels" id="chk-channels-wechat-notify" value="4" @if(!empty($isContainWechatNotify)) checked @endif/><label>微信通知</label>
</div> </div>
</div> </div>
<div class="col-sm-10 form-inline" style="margin-top: 20px"> <div class="col-sm-10 form-inline" style="margin-top: 20px">
<label class="col-sm-2 control-label"><span style="color: red">*</span> 模板描述:</label> <label class="col-sm-2 control-label"><span style="color: red">*</span> 模板描述:</label>
<div class="col-sm-3"> <div class="col-sm-3">
<input type="text" id="msg-tpl-desc" class="form-control" placeholder="请输入描述" value=""/> <input type="text" id="msg-tpl-desc" class="form-control" placeholder="请输入描述" value="{{ $info->description }}"/>
</div> </div>
</div> </div>
</div> </div>
...@@ -163,37 +163,35 @@ ...@@ -163,37 +163,35 @@
<div role="tabpanel" class="tab-pane fade in active" id="innner"> <div role="tabpanel" class="tab-pane fade in active" id="innner">
<div class="col-sm-10 form-inline" style="margin-top: 40px"> <div class="col-sm-10 form-inline" style="margin-top: 40px">
<label class="col-sm-2 control-label"><span style="color: red">*</span> 消息类型:</label> <label class="col-sm-2 control-label"><span style="color: red">*</span> 站内信类型:</label>
<div class="col-sm-3"> <div class="col-sm-3">
<select class="form-control" name="inner-tpl-type" id="inner-tpl-type"> <select class="form-control" name="inner-tpl-type" id="inner-tpl-type">
<option value="0">请选择</option> @for($i=0;$i<5;$i++)
<option value="1">公告</option> <option value="{{ $i }}" @if($i==$info->msg_type) selected @endif>{{ $msg_type[$i] }}</option>
<option value="2">活动</option> @endfor
<option value="3">新闻</option>
<option value="4">其他</option>
</select> </select>
</div> </div>
</div> </div>
<div class="col-sm-10 form-inline" style="margin-top: 20px"> <div class="col-sm-10 form-inline" style="margin-top: 20px">
<label class="col-sm-2 control-label"><span style="color: red">*</span> 消息标题:</label> <label class="col-sm-2 control-label"><span style="color: red">*</span> 站内信标题:</label>
<div class="col-sm-3"> <div class="col-sm-3">
<input type="text" id="inner-tpl-title" class="form-control" placeholder="请输入标题" value=""/> <input type="text" id="inner-tpl-title" class="form-control" placeholder="请输入标题" value=@if(!empty($info->channel_tpls['1'])) "{{ $info->channel_tpls['1']->title }}" @endif>
</div> </div>
</div> </div>
<div class="col-sm-10" style="margin-top: 20px"> <div class="col-sm-10" style="margin-top: 20px">
<label><span style="color: red">*</span>消息内容:</label> <label><span style="color: red">*</span>站内信内容:</label>
<script type="text/plain" id="inner-tpl-content" name="inner-tpl-content"></script> <script type="text/plain" id="inner-tpl-content" name="inner-tpl-content">@if(!empty($info->channel_tpls['1']->content)) {{ $info->channel_tpls['1']->content }} @endif</script>
<script type="text/javascript">UE.getEditor('inner-tpl-content');</script> <script type="text/javascript">UE.getEditor('inner-tpl-content');</script>
</div> </div>
<div class="col-sm-10 form-inline" style="margin-top: 20px"> <div class="col-sm-10 form-inline" style="margin-top: 20px">
<label class="col-sm-2 control-label"><span style="color: red">*</span> 点击消息操作:</label> <label class="col-sm-2 control-label"><span style="color: red">*</span> 点击消息操作:</label>
<div class="col-sm-5"> <div class="col-sm-5">
<input type="radio" id="inner-tpl-op-open" name="inner-tpl-op" checked/><label for="inner-tpl-op-open">打开消息</label> <input type="radio" id="inner-tpl-op-open" name="inner-tpl-op" value="1" @if(!empty($info->channel_tpls['1']) && 1==$info->channel_tpls['1']->op_type) checked @endif/><label for="inner-tpl-op-open">打开消息</label>
<input type="radio" id="inner-tpl-op-url" name="inner-tpl-op"/><label for="inner-tpl-op-url">打开URL</label> <input type="radio" id="inner-tpl-op-url" name="inner-tpl-op" value="2" @if(!empty($info->channel_tpls['1']) && 2==$info->channel_tpls['1']->op_type) checked @endif/><label for="inner-tpl-op-url">打开URL</label>
<input type="text" id="inner-tpl-op-url-text" name="inner-tpl-url-text" placeholder="请输入URL"> <input type="text" id="inner-tpl-op-url-text" name="inner-tpl-url-text" placeholder="请输入URL" value=@if(!empty($info->channel_tpls['1']) && 2==$info->channel_tpls['1']->op_type) "{{ $info->channel_tpls['1']->url }}" @endif>
</div> </div>
</div> </div>
...@@ -204,7 +202,7 @@ ...@@ -204,7 +202,7 @@
<div class="col-sm-10" style="margin-top: 40px"> <div class="col-sm-10" style="margin-top: 40px">
<label class="col-sm-2 control-label"><span style="color: red">*</span> 短信内容:</label> <label class="col-sm-2 control-label"><span style="color: red">*</span> 短信内容:</label>
<div class="col-sm-10"> <div class="col-sm-10">
<textarea rows="2" cols="10" id="sms-tpl-content" class="form-control" placeholder="请输入短信内容"></textarea> <textarea rows="2" cols="10" id="sms-tpl-content" class="form-control" placeholder="请输入短信内容">@if(!empty($info->channel_tpls['2'])) {{ $info->channel_tpls['2']->content }} @endif</textarea>
<label id="sms-content-length">预计1条短信</label> <label id="sms-content-length">预计1条短信</label>
</div> </div>
</div> </div>
...@@ -215,13 +213,13 @@ ...@@ -215,13 +213,13 @@
<div class="col-sm-10 form-inline" style="margin-top: 40px"> <div class="col-sm-10 form-inline" style="margin-top: 40px">
<label class="col-sm-2 control-label"><span style="color: red">*</span> 邮件标题:</label> <label class="col-sm-2 control-label"><span style="color: red">*</span> 邮件标题:</label>
<div class="col-sm-3"> <div class="col-sm-3">
<input type="text" id="email-tpl-title" class="form-control" placeholder="请输入邮件标题" value=""/> <input type="text" id="email-tpl-title" class="form-control" placeholder="请输入邮件标题" value=@if(!empty($info->channel_tpls['3'])) "{{ $info->channel_tpls['3']->title }}" @endif>
</div> </div>
</div> </div>
<div class="col-sm-10" style="margin-top: 20px"> <div class="col-sm-10" style="margin-top: 20px">
<label><span style="color: red">*</span>邮件内容:</label> <label><span style="color: red">*</span>邮件内容:</label>
<script type="text/plain" id="email-tpl-content" name="email-tpl-content"></script> <script type="text/plain" id="email-tpl-content" name="email-tpl-content">@if(!empty($info->channel_tpls['3']->content)) {{ $info->channel_tpls['3']->content }} @endif</script>
<script type="text/javascript">UE.getEditor('email-tpl-content');</script> <script type="text/javascript">UE.getEditor('email-tpl-content');</script>
</div> </div>
</div> </div>
...@@ -231,7 +229,7 @@ ...@@ -231,7 +229,7 @@
<div class="col-sm-10 form-inline" style="margin-top: 40px"> <div class="col-sm-10 form-inline" style="margin-top: 40px">
<label class="col-sm-2 control-label"><span style="color: red">*</span> 微信模板:</label> <label class="col-sm-2 control-label"><span style="color: red">*</span> 微信模板:</label>
<div class="col-sm-3"> <div class="col-sm-3">
<input type="text" id="wechat-notify_tpl_title" class="form-control" placeholder="请输入微信模板编号" value=""/> <input type="text" id="wechat-notify_tpl_title" class="form-control" placeholder="请输入微信模板编号" value=@if(!empty($info->channel_tpls['4'])) "{{ $info->channel_tpls['4']->title }}" @endif>
</div> </div>
</div> </div>
</div> </div>
......
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
<td>{{ $info[$i]->title }}</td> <td>{{ $info[$i]->title }}</td>
<td>{{ $info[$i]->description }}</td> <td>{{ $info[$i]->description }}</td>
<td>{{ $info[$i]->show_channels_str }}</td> <td>{{ $info[$i]->show_channels_str }}</td>
<td><a href="" class="btn btn-xs btn-outline btn-warning">编辑</a></td> <td><a href="{{url('message/addTemplate')}}?tpl_id={{$info[$i]->tpl_id}}" class="btn btn-xs btn-outline btn-primary">编辑</a></td>
</tr> </tr>
@endfor @endfor
</tbody> </tbody>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment