菜单--微信提醒
ftl代码:
<table id="datatable" class="table table-striped table-bordered dt-responsive nowrap order-column" cellspacing="0" width="100%">
<#list listMenuItem as mix>
<thead>
<tr>
<th><h4>${mix_index+1}、${mix.name}</h4></th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<#list mix.menuitems as m>
<td class='dt-left eachColumn'>
<span class="menuItem col-md-6">
<input id="${m.name}" name="menuItem" type="hidden" value="${m.id}">
<label for="${m.name}">${m.name}</label>
</span>
<span class="remind col-md-2">
<input id="circle${mix_index}_${m_index+1}_${m.id}" name="remind" type="checkbox" value="${m.remind}" ${(m.remind = 0) ? string("", 'checked="checked"')}>
<label for="circle${mix_index}_${m_index+1}_${m.id}">微信提醒</label>
</span>
<span class="remindPeriod col-md-4" ${(m.remind = 1) ? string("", 'style="display: none"')}>
<input type="hidden" value="${m.remindPeriod}">
<label><input type="radio" value="1" name="radio${mix_index}_${m_index+1}_${m.id}" ${(m.remindPeriod = 1) ? string('checked="checked"',"")} />按月 </label>
<label><input type="radio" value="2" name="radio${mix_index}_${m_index+1}_${m.id}" ${(m.remindPeriod = 2) ? string('checked="checked"',"")}/>按周 </label>
<label><input type="radio" value="3" name="radio${mix_index}_${m_index+1}_${m.id}" ${(m.remindPeriod = 3) ? string('checked="checked"',"")}/>按天 </label>
</span>
</td>
<#if (m_index+1) % 3 ==0><tr></#if>
</#list>
</tbody>
</#list>
</table>
js完整代码:
$(function() {})
/**
* 操作页面时---选中微信提醒后 加载 选月周日(默认月)
* index = 0取消提醒;1月提醒;2周提醒;3日提醒
*/
$("input[name='remind']").on('click',function(){
var menuitemId = $(this).parent().prev(".menuItem").children().eq(0).val();
var flag = $(this).attr("checked");
//勾选微信提醒,默认月
if(flag == undefined){
$(this).attr("checked",'checked').parent().next().show();
$(this).parent().next().children().find("input[type='radio'][value='1']").attr("checked",'checked');
listenAjax(menuitemId,1);
}
//取消微信提醒
if(flag == "checked"){
$(this).removeAttr("checked",'checked').parent().next().hide();
listenAjax(menuitemId,0);
}
})
/**
* 改变推送周期
*/
$("input[type='radio']").on('click',function(){
var index = $(this).val();
$(this).attr("checked",'checked').parent().siblings().children().removeAttr("checked",'checked');
var menuitemId = $(this).parent().parent().siblings(".menuItem").children().eq(0).val();
listenAjax(menuitemId,index);
})
function listenAjax(menuitemId,index){
$.ajax({
type: "GET",
dataType : "json",
url: "admin/column/operate?index=" + index,
data: {
"menuitemId" : menuitemId,
},
// success: function(result){
// if(!result.isSuccess){
// layer.open({content: result.message, btn: '我知道了', time : 2000});
// }else{
// layer.open({content: result.message, btn: '我知道了', time : 2000});
// }
// },
error : function(){
layer.msg("异常错误,请联系技术人员!", {icon: 2});
}
});
}
控制器代码:
@Controller
public class ColumnController {
@Autowired
private MenuService menuService;
/**
* 栏目管理初始化
*/
@RequestMapping(value = "admin/column", method = RequestMethod.GET)
public String init(Model model) {
List<Menu> listMix = menuService.listMenuItem();
model.addAttribute("listMenuItem", listMix);
return "system/column_manage";
}
/**
* 栏目管理Ajax处理
*/
@ResponseBody
@RequestMapping(value = "admin/column/operate", method = RequestMethod.GET)
public Result column(@RequestParam String menuitemId, @RequestParam int index) {
Result result = new Result<>();
result = menuService.doAjaxByType(menuitemId, index);
return result;
}
}