<table class=”layui-table” lay-data=”{height:’full-100′,url:’sys-set/loadtest.action’, page:true, id:’ssTable’}” lay-filter=”editEvent”>
<thead>
<tr>
<th lay-data=”{field:’role1′, width:180,templet: function(d){if(d.role1==’ ‘) return ‘未审批’; else if(d.role1==’1′) return ‘已同意’; else if(d.role1==’0′) return ‘未同意’;}}”>A</th>
<th lay-data=”{field:’role2′, width:180,templet: function(d){if(d.role2==’ ‘) return ‘未审批’; else if(d.role2==’1′) return ‘已同意’; else if(d.role2==’0′) return ‘未同意’;}}”>B</th>
<th lay-data=”{field:’role3′, width:180, templet: ‘#roleTpl’}”>C</th>
<th lay-data=”{field:’role4′, width:180,templet: function(d){return getrolename(d.role4)}}”>D</th>
<th lay-data=”{field:’role5′, width:180,templet: function(d){return getrolename(d.role4)}}”>E</th>
<th lay-data=”{field:’role6′, width:180,templet: function(d){return getrolename(d.role5)}}”>F</th>
<th lay-data=”{field:’remark’, width:200}”>备注</th>
<th lay-data=”{fixed: ‘right’, width:160, align:’center’, toolbar: ‘#operbar’}”>相关操作</th>
</tr>
</thead>
</table>
<script type=”text/html” id=”roleTpl”>
{ {# if (d.role3=== ‘ ‘) { }}
未审批
{ {# } else if(d.role3=== ‘1’) { }}
同意
{ {# } else { }}
未同意
{ {# } }}
</script>
第一种方式:(直接在列中判断)
<th lay-data=”{field:’role1′, width:180,templet: function(d){if(d.role1==’ ‘) return ‘未审批’; else if(d.role1==’1′) return ‘已同意’; else if(d.role1==’0′) return ‘未同意’;}}”>A</th>
第二种方式:(列中增加, templet: ‘#roleTpl,然后增加js声明id=roleTpl)
<th lay-data=”{field:’role3′, width:180, templet: ‘#roleTpl’}”>C</th>
<script type=”text/html” id=”roleTpl”>
{ {# if (d.role3=== ‘ ‘) { }}
未审批
{ {# } else if(d.role3=== ‘1’) { }}
同意
{ {# } else { }}
未同意
{ {# } }}
</script>
第三种方式:(列中写方法,在js里面调用)
<th lay-data=”{field:’role6′, width:180,templet: function(d){return getrolename(d.role5)}}”>F</th>
然后再js中写方法:
<script type=”text/html” >
function getrolename(roleid){
if(roleid==’ ‘) return ‘未审批’; else if(roleid==’1′) return ‘已同意’; else if(roleid==’0′) return ‘未同意’;
}
</script>
第四种方式:仅限有2个标志位的判断
<th lay-data=”{field:’role1′, width:180,templet: function(d){return d.sex==’0′?’男’:’女’}}”>A</th>