前端分页
<script type="text/html" id="barDemo">
{{# if(d.end_time==''||d.end_time==null){ }}
{{# if(d.check_status=='1'){ }}
{{# if (d.user_id == sessionStorage.getItem('user_id')){ }}
<a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
{{# } }}
{{# if (Number(sessionStorage.getItem("authority")<=3)){ }}
<a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="check">审核</a>
{{# } }}
{{# } else if(d.check_status=='0'){ }}
{{# if (d.user_id == sessionStorage.getItem('user_id')){ }}
<a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
{{# } }}
{{# } else { }}
{{# if (Number(sessionStorage.getItem("authority")<=3)){ }}
<a class="layui-btn layui-btn-warm layui-btn-xs" lay-event="wancheng">问题已完成</a>
{{# } }}
{{# } }}
{{# } }}
</script>
var tabledata=[]
layui.use('table', function(){
var table = layui.table;
var form=layui.form;
findPropertyProblemList({})
table.render({
elem: '#indextable'
,title: '用户数据表'
,cellMinWidth: 80
,cols: [[
{type:'checkbox'}
,{field:'property_id', title: 'ID', sort: true,width:120}
,{field:'check_status',width:90, title: '状态', templet: function(d){
if(d.check_status==0){
var h='<p style="color:#FF5722">审核不通过</p>'
}else if(d.check_status==1){
var h='<p style="color:#FFB800">待审核</p>'
}else if(d.check_status==2){
var h='<p style="color:#5FB878">审核通过</p>'
}else{
var h='<p style="color:#5FB878">问题已完成</p>'
}
return h
}}
,{ title:'操作', toolbar: '#barDemo', minWidth:240}
]]
,page: true
,id: 'testReload'
,data:tabledata
, done: function (res, curr, count) {
res.data.forEach(function (item, index) {
if (item.user_id !== user_id||item.check_status=='3') {
var tr = $(".layui-table tr[data-index=" + index + "]");
tr.find("input[type='checkbox']").prop('disabled', true).hide();
tr.find("input[type='checkbox']").next().addClass('layui-btn-disabled');
$('.layui-btn-disabled').parents('.layui-table-col-special').css('visibility','hidden')
}
})
}
});
$('.seachBtn').on('click', function(){
var obj={}
findPropertyProblemList(obj)
table.reload('testReload', {data:tabledata});
});
$('.deleteAll').click(function(){
var checkStatus = table.checkStatus('testReload');
var selectCount=checkStatus.data.length
var ids=''
checkStatus.data.forEach(function(it,i){
if(it.user_id==user_id)ids+=it.id+','
})
if(selectCount == 0||ids==''){
layer.msg('批量删除至少选中一项数据',function(){});
return false;
}
layer.confirm('确定要删除上报记录吗?', function(index){
layer.close(index);
deleteByIds({id:ids.substring(0,ids.length-1)})
}, function(){
parent.layer.closeAll()
});
console.log(checkStatus)
console.log(checkStatus.data)
console.log(checkStatus.isAll )
})
$('.exportLayui').click(function(){
var url=''
exportExcel(url)
})
$('.btn-edit').click(function(){
if($('.reason').val()==''){
layer.msg('上报原因必须填写!',{icon:6})
return false
}
var obj={ }
editByIds(obj)
})
$('.checkBtn').click(function(){
var check=$('input[type=radio][name=check]:checked').val()
if(!N.Util.isPoneAvailable($('#check_user_phone').val())){
layer.msg('手机号码格式错误!',{icon:6})
return false
}
var obj={}
CheckProblem(obj)
})
$('.wanchengBtn').click(function(){
if($('#end_user_phone').val()==''){
layer.msg('必须填写审核人电话!',{icon:6})
return false
}
var obj={}
updateProblemEndtime(obj)
})
table.on('tool(test)', function(obj){
var data = obj.data;
console.log(obj)
if(obj.event === 'del'){
layer.confirm('确定要删除上报记录吗?', function(index){
layer.close(index);
deleteByIds({id:data.id})
}, function(){
parent.layer.closeAll()
});
} else if(obj.event === 'edit'){
}else if(obj.event === 'check'){
}else if(obj.event === 'wancheng'){
layer.confirm('请确认问题是否真的已完成!', function(index){
layer.close(index);
}, function(){
parent.layer.closeAll()
});
}
});
form.on('radio(levelM)', function(data){
console.log(data);
if(data.value=='0'){
$('.checkText').show()
}else{
$('.checkText').hide()
}
});
function editByIds(obj){
if(res.code==0){
layer.msg('编辑成功!',{icon:1})
reload()
}else{
layer.msg(res.msg||'编辑失败,请重新编辑!',{icon:2})
}
}
function deleteByIds(obj){
}
function reload(){
var obj={}
findPropertyProblemList(obj)
table.reload('testReload', {data:tabledata});
}
function updateProblemEndtime(obj){
}
function CheckProblem(obj){
}
});
function findPropertyProblemList(obj){
...
f(res.code==0){
tabledata=res.msg
}else{
tabledata=[]
}
...
}```