关于layui 可以问我呦
<script>
layui.use(['table', 'notice','upload'], function () {
var table = layui.table, form = layui.form, notice = layui.notice;
// 监听行内按钮
table.on('tool(*)', function (obj) {
var data = obj.data;
console.log(data.id);
switch(obj.event) {
case 'review':
layer.confirm('确认重新审核?',function(){
$.ajax({
type:'POST',
url: '/admin/counselor_check/auditing',
data:{ids:data.id},
dataType:'json',
success:function(returnData)
{
if(returnData.code == 1)
{
notice.init({title:returnData.msg});
table.init('*', obj.config);
}
else
{
notice.init({title:returnData.msg,type:'danger'});
table.init('*', obj.config);
}
}
});
layer.closeAll();
});
break;
case 'reject':
var str = '<div class="layui-form" lay-filter="*"><form id="rejectForm">' +
'<input type="hidden" name="id" value="'+data.id+'"/>';
str += '<div class="layui-form-item" style="margin-top: 5%"><div class="layui-inline"><label class="layui-form-label">拒绝原因</label>' +
'<div class="layui-input-block"><textarea style="width: 400px; height: 130px;" class="layui-input" name="remark" type="text" placeholder="填写原因" required>填写内容与实际不相符</textarea></div></div></div>';
str += '</form></div>';
// layer.confirm('确认审核拒绝?', function () {
layer.open({
type: 1,
title: '拒绝审核理由',
skin: 'layui-layer-demo', //样式类名
closeBtn: 0, //不显示关闭按钮
anim: 2,
area: ['30%', '30%'],
btn: ['确定', '取消'],
shadeClose: true, //开启遮罩关闭
content: str,
yes: function (index, layero)
{
layer.setTop(layero);
var data = $('#rejectForm').serialize();
$.ajax({
url: '/admin/counselor_check/reject',
type: "POST",
data: data,
dataType: "json",
success: function (returnData) {
if (returnData.code === 1) {
notice.init({title: returnData.msg,type:'danger'});
table.init('*', obj.config);
layer.closeAll();
} else {
notice.init({title: returnData.msg, type: 'success'});
table.init('*', obj.config);
layer.closeAll();
}
}
});
},
btn2: function (index) {
layer.close(index);
layer.closeAll();
}
, success: function (layero, index) {
console.log('success');
}
});
// });
break;
case 'edit':
layer.open({
type: 1,
title:'审核详情',
skin: 'layui-layer-demo', //样式类名
closeBtn: 0, //不显示关闭按钮
area:['40%','50%'],
shadeClose: true, //开启遮罩关闭
content:'<div class="layui-form-item" style="margin-top: 2%">' +
'<div class="layui-inline"><label class="layui-form-label">真实姓名:</label>' +
'<div class="layui-input-block"><input disabled class="layui-input" value="'+data.truename+'" autocomplete="off" ></div>' +
'</div>'+
'<div class="layui-form-item" style="margin-top: 2%">' +
'<div class="layui-inline"><label class="layui-form-label">手机号:</label>' +
'<div class="layui-input-block"><input disabled class="layui-input" value="'+data.telphone+'" autocomplete="off" ></div>' +
'</div>'+
'<div class="layui-form-item" style="margin-top: 2%">' +
'<div class="layui-inline"><label class="layui-form-label">***号:</label>' +
'<div class="layui-input-block"><input disabled class="layui-input" value="'+data.id_number+'" autocomplete="off" ></div>' +
'</div>'+
'<div class="layui-form-item" style="margin-top: 2%">' +
'<div class="layui-inline"><label class="layui-form-label">***头像面:</label>' +
'<div class="layui-input-block"><img src="'+data.left_pic+'" ></div>' +
'</div>'+
'<div class="layui-form-item" style="margin-top: 2%">' +
'<div class="layui-inline"><label class="layui-form-label">***国徽面:</label>' +
'<div class="layui-input-block"><img src="'+data.right_pic+'" ></div>' +
'</div>'+
'<div class="layui-form-item" style="margin-top: 2%">' +
'<div class="layui-inline"><label class="layui-form-label">审核状态:</label>' +
'<div class="layui-input-block"><input disabled class="layui-input" value="'+data.status+'" autocomplete="off" ></div>' +
'</div>'
});
break;
case 'userSearch' :
var $ = layui.$;
var url = $(this).attr('lay-url');
console.log(url);
layer.open({
title: '用户查询'
, id:'userSearch'
, type : 2
, shade: false
, skin: 'layui-layer-molv'
, area: ['80%', '80%']
, maxmin: true
, btn: ['关闭']
, shadeClose: true
, content: url
, zIndex: layer.zIndex
, yes: function (index, layero) {
layer.close(index);
}
, success: function (layero, index) {
console.log('success');
}
});
break;
default : console.log();
break;
}
});
// 监听数据表格头部按钮
table.on('toolbar(*)', function (obj) {
var checkStatus = table.checkStatus(obj.config.id);
var data = checkStatus.data;
switch (obj.event) {
case 'reload':
table.init('*', obj.config);
break;
case 'toggle':
if(data.length === 0)
{
notice.init({title: '未选择数据', type: 'danger'});
return false;
}
var ids = [];
for(var i in data)
{
ids.push(data[i].id * 1);
}
if(ids.length === 0)
{
notice.init({title: '没有需要审核的数据', type: 'danger'});
return false;
}
layer.confirm('确认重新审核'+ data.length +'条数据?',function(){
$.ajax({
type:'post',
url:'/admin/counselor_check/auditing',
data:{ids:ids},
dataType:'json',
success:function(returnData){
if(returnData.code == 1)
{
notice.init({title:returnData.msg,type:'success'});
table.init('*', obj.config);
}
else
{
notice.init({title:returnData.msg,type:'success'});
table.init('*', obj.config);
}
}
});
layer.closeAll();
});
break;
default:
console.log(obj.event);
break;
}
});
});
</script>