| | |
| | | var pageCurr; |
| | | var tableData; |
| | | layui.use(['table','laydate', 'form'], function(){ |
| | | var table = layui.table; |
| | | var $ = layui.jquery; |
| | |
| | | // ,{field: 'hostName', align: 'center',title: '授权商户'} |
| | | ,{field: 'mobile', align: 'center',title: '账号'} |
| | | ,{field: 'username', align: 'center',title: '名称'} |
| | | ,{field: 'password', align: 'center',title: '密码'} |
| | | // ,{field: 'password', align: 'center',title: '密码'} |
| | | ,{field: 'roleName', align: 'center',title: '角色'} |
| | | // ,{field: 'createTime$', align: 'center',title: '注册时间'} |
| | | ,{field: 'status$', align: 'center',title: '状态'} |
| | | ,{field: 'status$', align: 'center',title: '状态', templet: '#statusTpl', width: 120, unresize: true} |
| | | |
| | | ,{fixed: 'right', title:'操作', align: 'center', toolbar: '#operate', width:100} |
| | | ]], |
| | |
| | | if (res.code === 403) { |
| | | top.location.href = baseUrl+"/"; |
| | | } |
| | | tableData = table.cache.user; |
| | | pageCurr=curr; |
| | | limit(); |
| | | } |
| | | }); |
| | | |
| | | // 修改状态 |
| | | form.on('switch(statusSwitch)', function (obj) { |
| | | var index = obj.othis.parents('tr').attr("data-index"); |
| | | var data = tableData[index]; |
| | | data[this.name] = obj.elem.checked?1:0; |
| | | http.post(baseUrl+"/user/edit/auth", {id: data.id, status: data[this.name]}, function (res) { |
| | | layer.msg(res.msg); |
| | | }) |
| | | }) |
| | | |
| | | // 监听排序事件 |
| | | table.on('sort(user)', function (obj) { |
| | |
| | | if (res.code === 403) { |
| | | top.location.href = baseUrl+"/"; |
| | | } |
| | | tableData = table.cache.user; |
| | | pageCurr=curr; |
| | | limit(); |
| | | } |
| | |
| | | type: 2, |
| | | title: '新增', |
| | | maxmin: true, |
| | | area: [top.detailWidth, top.detailHeight], |
| | | area: ['30%', top.detailHeight], |
| | | shadeClose: true, |
| | | content: 'user_detail.html', |
| | | success: function(layero, index){ |
| | |
| | | layer.iframeAuto(index);layer.style(index, {top: (($(window).height()-layer.getChildFrame('#data-detail', index).height())/3)+"px"}); |
| | | } |
| | | }); |
| | | break; |
| | | case 'refreshData': |
| | | tableIns.reload({ |
| | | page: { |
| | | curr: pageCurr |
| | | } |
| | | }); |
| | | limit(); |
| | | break; |
| | | case 'deleteData': |
| | | var data = checkStatus.data; |
| | |
| | | table.on('tool(user)', function(obj){ |
| | | var data = obj.data; |
| | | switch (obj.event) { |
| | | // 详情 |
| | | case 'detail': |
| | | layer.open({ |
| | | type: 2, |
| | | title: '详情', |
| | | maxmin: true, |
| | | area: [top.detailWidth, top.detailHeight], |
| | | shadeClose: false, |
| | | content: 'user_detail.html', |
| | | success: function(layero, index){ |
| | | setFormVal(layer.getChildFrame('#detail', index), data); |
| | | top.convertDisabled(layer.getChildFrame('#data-detail :input', index), true); |
| | | layer.getChildFrame('#data-detail-submit,#prompt', index).hide(); |
| | | layer.iframeAuto(index);layer.style(index, {top: (($(window).height()-layer.getChildFrame('#data-detail', index).height())/3)+"px"}); |
| | | layero.find('iframe')[0].contentWindow.layui.form.render('select'); |
| | | } |
| | | }); |
| | | break; |
| | | // 编辑 |
| | | case 'edit': |
| | | layer.open({ |
| | | type: 2, |
| | | title: '修改', |
| | | maxmin: true, |
| | | area: [top.detailWidth, top.detailHeight], |
| | | area: ['30%', top.detailHeight], |
| | | shadeClose: true, |
| | | content: 'user_detail.html', |
| | | success: function(layero, index){ |
| | |
| | | layero.find('iframe')[0].contentWindow.layui.form.render('select'); |
| | | } |
| | | }); |
| | | break; |
| | | case 'Role': |
| | | var param = top.reObject(data).roleId; |
| | | if (param === undefined) { |
| | | layer.msg("无数据"); |
| | | } else { |
| | | layer.open({ |
| | | type: 2, |
| | | title: '详情', |
| | | maxmin: true, |
| | | area: [top.detailHeight, top.detailWidth], |
| | | shadeClose: false, |
| | | content: '../role/role_detail.html', |
| | | success: function(layero, index){ |
| | | $.ajax({ |
| | | url: baseUrl+"/role/"+ param +"/auth", |
| | | headers: {'token': localStorage.getItem('token')}, |
| | | method: 'GET', |
| | | success: function (res) { |
| | | if (res.code === 200){ |
| | | setFormVal(layer.getChildFrame('#detail', index), res.data); |
| | | top.convertDisabled(layer.getChildFrame('#data-detail :input', index), true); |
| | | layer.getChildFrame('#data-detail-submit,#prompt', index).hide(); |
| | | layer.iframeAuto(index);layer.style(index, {top: (($(window).height()-layer.getChildFrame('#data-detail', index).height())/3)+"px"}); |
| | | layero.find('iframe')[0].contentWindow.layui.form.render('select'); |
| | | } else if (res.code === 403){ |
| | | parent.location.href = "/"; |
| | | }else { |
| | | layer.msg(res.msg) |
| | | } |
| | | } |
| | | }) |
| | | } |
| | | }); |
| | | } |
| | | break; |
| | | case 'Host': |
| | | var param = top.reObject(data).hostId; |
| | |
| | | if (res.code === 403) { |
| | | top.location.href = baseUrl+"/"; |
| | | } |
| | | tableData = table.cache.user; |
| | | pageCurr=curr; |
| | | if (res.data.length === 0 && count !== 0) { |
| | | tableIns.reload({ |
| | |
| | | for (var val in data) { |
| | | el.find(":input[id='" + val + "']").val(data[val]); |
| | | } |
| | | } |
| | | |
| | | function clearFormVal(el) { |
| | | $(':input', el) |
| | | .val('') |
| | | .removeAttr('checked') |
| | | .removeAttr('selected'); |
| | | } |
| | | |
| | | function detailScreen(index) { |
| | | var detail = layer.getChildFrame('#data-detail', index); |
| | | var height = detail.height()+60; |
| | | if (height > ($(window).height()*0.9)) { |
| | | height = ($(window).height()*0.9); |
| | | } |
| | | layer.style(index, { |
| | | height: height +'px' |
| | | }); |
| | | } |
| | | |
| | | $('body').keydown(function () { |