引入头部
<% include("/global/header.html",{title:"会员设置"}){} %>
页面中引入文件
<link rel="stylesheet" href="${ctxPath}/member/member.css">
<td>${user.storeCount==''?'暂无数据':user.storeCount}</td>
<td>${user.createTime,'yyyy-MM-dd hh:mm:ss'}</td>
<button class="layui-btn layui-btn-primary clBtnGray" data-id=${user.id} onclick="delUser(this)">删除</button>
安全输出
${user.wife.name!”单身”},如果user为null,或者user.wife为null,或者user.wife.name为null,输出”单身”
for elsefor
<div class="layui-form-item mb0">
<label class="layui-form-label">年销售量:</label>
<div class="layui-input-block">
<%
var s = customer.saleNumber;
var arrS = ["1万件以下","1~2万件","2~3万件","3万件以上"];
for (el in arrS){%>
<input type="radio" name="sales" value="${el}" ${el==s?'checked':''} title="${el}" >
<%}
%>
</div>
</div>
<div class="layui-form-item mb0 pt">
<label class="layui-form-label">采购品类:</label>
<div class="layui-input-block">
<%
var c = customer.category;
var arrC=["连衣裙","丝巾","旗袍","睡衣","短衫","其他"];
for(el in arrC){
if(strutil.contain(c,el)){%>
<input type="checkbox" name="kind[${el}]" title="${el}" checked lay-skin="primary">
<%}else{%>
<input type="checkbox" name="kind[${el}]" title="${el}" lay-skin="primary">
<%}
}
%>
</div>
</div>
<div class="layui-input-block w150">
<select name="companyType" required lay-verify="required">
<option value="">请选择</option>
<%
var t=customer.companyType;
var arrT=['连锁商超','市场代理批发','单店','网店','其他'];
for (el in arrT){%>
<option value="${el}" ${el==t?'selected':''}>${el}</option>
<%}
%>
</select>
</div>
异步刷新
<div class="tbWrap" id="layui-container">
<% #ajax userTableList : {
%>
<table class="layui-table" lay-skin="line">
<colgroup>
<col width="8%">
</colgroup>
<tbody>
<%for(user in customers.list){
%>
<tr>
<td>${user.contactProvince==user.contactCity?user.contactProvince:(user.contactProvince+' '+user.contactCity)}</td>
<td>${user.storeCount==''?'暂无数据':user.storeCount}</td>
<td>${user.createTime,'yyyy-MM-dd hh:mm:ss'}</td>
<td><button class="layui-btn layui-btn-primary clBtnwarm" data-id=${user.id} onclick="followUser(this)">跟踪${user.traceCount==null?'':'('+user.traceCount+')'}</button></td>
</tr>
<%
}elsefor{%>
<tr><td colspan="9" class="tbNodata">未查询到数据,换个查询条件试试吧。</td></tr>
<%}%>
</tbody>
</table>
<div id="page" class="page" data-total="${customers.totalRow}"></div>
<%}%>
</div>
$("#layui-container").load("/winIndex.html?ajaxCmd=userTableList", {
"jsonObj": JSON.stringify(_ajxOpt),
"timeRange":_opt.timeRange,
"pageNum": _opt.pageNum,
"pageSize": _opt.pageSize
});
layPage();
function layPage() {
laypage.render({
elem: 'page'
, count: $("#page").attr('data-total') || 10
, curr:_opt.pageNum
, limit: _opt.pageSize
, layout: ['prev', 'page', 'next', 'skip','count']
,theme:'cLayPage'
, jump: function (obj,first) {
if(!first){
jumpPage(obj);
}
}
});
}
function jumpPage(obj) {
_opt.pageNum = obj.curr;
_opt.refresh();
}
elLP 提供了当前循环的信息
elLP.index :当前的索引,从1开始 elLP.size:集合的长度 elLP.first 是否是第一个 elLP.last 是否是最后一个 elLP.even 索引是否是偶数 elLP.odd 索引是否是奇数
refresh: function () { $("#asyncTb").load("/lecturer/lecturerIndex.html?ajaxCmd=asyncTb", { "pageNum": _opt.pageNum, "pageSize": _opt.pageSize },layPage); }