try {
$.ajaxSetup({headers: {'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')}});
} catch (e) {
location.href = '/';
}
var $mytab = $('#mytab');
var tag = false;
var atcArray = new Array();
var columnTitle = [{
title: "全选",
field: "select",
checkbox: true,
width: 10,
}];
for (var i in table_config.table_title) {
if (table_config.table_title[i].type == 'text') {
columnTitle.push({
field: table_config.table_title[i].key,
title: table_config.table_title[i].value,
width: 200,
height: 200,
sortable: true,
order: "desc",
filterControl: "input",
})
}
if (table_config.table_title[i].type == 'image') {
columnTitle.push({
field: table_config.table_title[i].key,
title: table_config.table_title[i].value,
align: 'center',
formatter: function (value, row, index) {
if (value != null)
return ' + value + ' \'); " src="/common/displayImg/' + value + '" width=60 class="img-rounded" >';
}
})
}
}
var updateData = [];
columnTitle.push({
formatter: function (value, row, index) {
updateData[row.id] = (row);
var content = '';
if (table_config.method.edit != 'false') {
content += '+ row.id + ')">' +
'' +
'';
}
if (table_config.method.delete != 'false') {
content += '+ row.id + ')">' +
'' +
'';
}
return [
content
].join('');
},
title: '操作'
});
$('#mytab').bootstrapTable({
url: table_config.method.list,
dataField: "data",
search: true,
pagination: true,
pageSize: 10,
pageList: [10, 30, 50, 100],
sidePagination: "server",
contentType: "application/x-www-form-urlencoded",
dataType: "json",
method: "post",
searchAlign: "right",
queryParamsType: "limit",
onLoadSuccess: function queryParams(params) {
var fun = "successHD";
var isFunction = false;
try {
isFunction = typeof (eval('successHD')) == "function";
} catch (e) {
}
if (isFunction) {
successHD(params.data);
} else {
console.log('函数不存在!');
}
},
queryParams: function queryParams(params) {
var params = {
limit: params.limit,
offset: params.offset,
sort: params.sort,
order: params.order,
search: $('.search input').val()
};
return params;
},
searchOnEnterKey: false,
showRefresh: true,
showColumns: false,
buttonsAlign: "right",
exportDataType: "basic",
toolbar: "#toolbar",
toolbarAlign: "left",
sortable: true,
sortOrder: "desc",
showExport: true,
exportTypes: ['excel'],
locale: "zh-CN",
detailView: false,
striped: true,
showToggle: true,
showPaginationSwitch: true,
clickToSelect: false,
uniqueId: "id",
cache: false,
filterControl: true,
filtershowclear: "true",
rowStyle: function (row, index) {
var classes = ['active', 'success', 'info', 'warning', 'danger'];
var strclass = "";
if (row.status_color == 10||row.status_color==0) {
strclass = classes[0];
} else if (row.status_color == 20||row.status_color==1) {
strclass = classes[1];
}else if (row.status_color == 30) {
strclass = classes[2];
}else if (row.status_color == 40) {
strclass = classes[3];
}else if (row.status_color == 50) {
strclass = classes[4];
} else {
return {};
}
return {classes: strclass}
},
columns: columnTitle,
onExpandRow: function (index, row, $detail) {
initSubTable(index, row, $detail);
}
,
onClickRow: function (row, $element) {
}
,
onEditableSave: function (field, row, oldValue, $el) {
$.ajax({
type: "post",
url: table_config.method.edit,
data: row,
dataType: 'JSON',
success: function (data, status) {
if (status == "success") {
alert('提交数据成功');
}
},
error: function () {
alert('编辑失败');
},
complete: function () {
}
});
}
,
})
;
function initSubTable(index, row, $detail) {
var parentid = row.MB001;
var cur_table = $detail.html('').find('table');
$(cur_table).bootstrapTable({
url: './data/coptdserver.php',
method: 'post',
contentType: "application/x-www-form-urlencoded",
dataType: "json",
queryParams: {strParentID: parentid},
ajaxOptions: {strParentID: parentid},
clickToSelect: true,
uniqueId: "MC001",
pageSize: 10,
pageList: [10, 25],
columns: [{
checkbox: true
}, {
field: 'MC001',
title: 'SubId'
}, {
field: 'MC002',
title: 'Grade',
editable: true,
}, {
field: 'MC003',
title: 'Name'
}],
});
}
bootbox.setLocale('zh_CN');
var titleTip = '提示';
function verifyAge(MB001) {
var reg = /^[a-zA-Z]*$/;
if (!reg.test(MB001)) {
return false;
}
return true;
}
function verifyNameAndAddress(name, address) {
if (name != '' && address != '') {
return true;
}
return false;
}
function nullAlert() {
bootbox.alert({
title: titleTip,
message: '所有项均为必填!'
});
}
$('#queryBtn').click(function () {
var MB001 = $('#MB001').val();
if (verifyAge(MB001)) {
$testTable.bootstrapTable('selectPage', 1);
} else {
bootbox.alert({
title: titleTip,
message: '品号输入有误!'
});
}
});
$('#withdraw').click(function () {
$('.search input').val('今日待打款');
$mytab.bootstrapTable('selectPage', 1);
});
$('#withdraw_finish').change(function () {
$('.search input').val($('#withdraw_finish').val());
$mytab.bootstrapTable('selectPage', 1);
});
$('#order_finish').change(function () {
$('.search input').val($('#order_finish').val());
$mytab.bootstrapTable('selectPage', 1);
});
$('#allWithdraw').click(function () {
$('.search input').val('');
$mytab.bootstrapTable('selectPage', 1);
});
$('#resetBtn').click(function () {
$('.search input').val('');
$mytab.bootstrapTable('selectPage', 1);
});
function exchangeData(path, data) {
if (atcArray.length != 0) {
console.log(atcArray.join('|'));
data.attachment = atcArray.join('|');
}
$.ajax({
url: path,
type: 'post',
data: data,
success: function (res) {
bootbox.alert({
title: titleTip,
message: res.message
});
$mytab.bootstrapTable('selectPage', 1);
}, error: function (res) {
if (res.responseJSON.message == 'The given data was invalid.') {
res.responseJSON.message = '参数填写不完整'
for (var i in res.responseJSON.errors) {
res.responseJSON.message += res.responseJSON.errors[i][0] + ''
}
}
bootbox.alert({
title: titleTip,
message: res.responseJSON.message
});
$mytab.bootstrapTable('selectPage', 1);
}
});
}
$('#addBtn').click(function () {
$('#addNameText').val('');
$('#addAgeText').val('');
$('#addAddressText').val('');
$('#addModal').modal('show');
});
$('#saveAdd').click(function () {
$('#addModal').modal('hide');
bootbox.confirm({
title: titleTip,
message: '确认增加?',
callback: function (flag) {
if (flag) {
var data = $('#add_form').serializeArray();
exchangeData(table_config.method.add, data);
}
}
});
});
$('#btn_edit').click(function () {
if (($mytab.bootstrapTable('getSelections')).length == 1) {
for (var i in ($mytab.bootstrapTable('getSelections'))[0]) {
$('#edit_' + i).val(($mytab.bootstrapTable('getSelections'))[0][i]);
}
var fun = "edit";
$('#modifyModal').modal('show');
var isFunction = false;
try {
isFunction = typeof (eval('edit')) == "function";
} catch (e) {
}
if (isFunction) {
edit(updateData[id]);
} else {
console.log('函数不存在!');
}
} else {
alert("请选中一行并且只能选中一行!")
}
;
});
var mid;
function modifyPer(id) {
for (var i in updateData[id]) {
$('#edit_' + i).val(updateData[id][i]);
}
var fun = "edit";
$('#modifyModal').modal('show');
var isFunction = false;
try {
isFunction = typeof (eval('edit')) == "function";
} catch (e) {
}
if (isFunction) {
edit(updateData[id]);
} else {
console.log('函数不存在!');
}
}
$('#saveModify').click(function () {
$('#modifyModal').modal('hide');
bootbox.confirm({
title: titleTip,
message: '确认修改?',
callback: function (flag) {
if (flag) {
var data = $('#edit_form').serializeArray();
exchangeData(table_config.method.edit, data);
}
}
});
});
function delPer(id) {
console.log(id);
bootbox.confirm({
title: titleTip,
message: '确认删除?',
callback: function (flag) {
if (flag) {
exchangeData(table_config.method.delete, {'id': id});
}
}
});
};
function tableHeight() {
return $(window).height() - 80;
};
function infoFormatter(value, row, index) {
return "id:" + row.MB001 + " name:" + row.MB002 + " age:" + row.MB003;
}
function operateOpinionFormatter(value, row, index) {
if (value.length > 5) {
return "" + value.substring(0, 5) + "..." + "";
} else {
return "" + value.substring(0, value.length) + "";
}
}
function formatTableUnit(value, row, index) {
return {
css: {
"overflow": 'hidden',
"text-overflow": 'ellipsis',
"white-space": 'nowrap'
}
};
}
erpdel = function () {
var ids = getIdSelections();
var idsy = ids.toString();
var jsonData = {"id": idsy};
if (ids.length == 0) {
bootbox.alert({
buttons: {
ok: {
label: '我知道了!',
className: 'btn-myStyle'
}
},
message: '请选择数据行',
callback: function () {
},
title: "提示",
});
return;
}
if (confirm("确定要删除 id= " + idsy + "吗?此操作不可恢复!")) {
$mytab.bootstrapTable('remove', {
field: 'id',
values: ids
});
$.ajax({
type: "post",
url: table_config.method.delete,
data: jsonData,
dataType: 'json',
success: function (msg) {
if (msg.status_code == '200') {
alert("删除成功");
oTable.ajax.reload();
} else {
alert("删除失败");
}
},
error: function (error) {
console.log(error);
}
});
}
};
function updateStatus(type) {
var ids = getIdSelections();
var idsy = ids.toString();
var jsonData = {"id": idsy, 'type': type};
if (ids.length == 0) {
bootbox.alert({
buttons: {
ok: {
label: '我知道了!',
className: 'btn-myStyle'
}
},
message: '请选择数据行',
callback: function () {
},
title: "提示",
});
return;
}
if (confirm("确定要修改 id= " + idsy + "吗?此操作不可恢复!")) {
$.ajax({
type: "post",
url: table_config.method.edit,
data: jsonData,
dataType: 'json',
success: function (msg) {
if (msg.status_code == '200') {
alert("修改成功");
$mytab.bootstrapTable('selectPage', 1);
} else {
alert("修改失败");
}
},
error: function (error) {
console.log(error);
}
});
}
}
function getIdSelections() {
return $.map($mytab.bootstrapTable('getSelections'), function (row) {
return row.id;
});
};
var $div = $('.div-table'),
$table = $('#mytab'),
$button = $('#button'),
$button2 = $('#button2');
$(function () {
$button.click(function () {
$div.width($div.width() + 50);
$table.bootstrapTable('resetView');
});
$button2.click(function () {
$div.width($div.width() - 50);
$table.bootstrapTable('resetView');
});
});
<!-- CSS-->
<link rel="stylesheet" href="/AdminLTE/bower_components/bootstrap-table-demo/css/childstyle.css" type="text/css"
media="screen"/>
<link rel="stylesheet" href="/AdminLTE/bower_components/bootstrap-table-demo/css/childmenu.css" type="text/css"
media="screen">
<link rel="stylesheet" href="/AdminLTE/bower_components/bootstrap-table-demo/css/bootstrap.min.css"/>
<link rel="stylesheet" href="/AdminLTE/bower_components/bootstrap-table-demo/css/bootstrap-table.css"/>
<link rel="stylesheet" href="/AdminLTE/bower_components/bootstrap-table-demo/css/bootstrap-table-fixed-columns.css"/>
<!--jquery和box和bootstrap-->
<script type="text/javascript" src="https://cdn.bootcss.com/bootbox.js/4.4.0/bootbox.min.js"></script>
<script type="text/javascript" src="/AdminLTE/bower_components/bootstrap-table-demo/js/bootstrap-table.js"></script>
<script type="text/javascript"
src="/AdminLTE/bower_components/bootstrap-table-demo/js/bootstrap-table-zh-CN.js"></script>
<!-- 导出,试了好久才弄好,我测试了edge,IE,火狐、谷歌和猎豹都是可以的,中文乱码和PDF乱码问题也能过了测试,记得在下面启用导出功能参数-->
<script src="/AdminLTE/bower_components/bootstrap-table-demo/js/bootstrap-table-export.js"></script>
{{--<script type="text/javascript" src="/AdminLTE/bower_components/bootstrap-table-demo/js/pdfmake.min.js"></script>--}}
{{-- <script type="text/javascript" src="/AdminLTE/bower_components/bootstrap-table-demo/js/vfs_fonts.js"></script>--}}
<script type="text/javascript" src="/AdminLTE/bower_components/bootstrap-table-demo/js/FileSaver.min.js"></script>
<script type="text/javascript" src="/AdminLTE/bower_components/bootstrap-table-demo/js/jspdf.min.js"></script>
<script type="text/javascript"
src="/AdminLTE/bower_components/bootstrap-table-demo/js/jspdf.plugin.autotable.js"></script>
<script type="text/javascript" src="/AdminLTE/bower_components/bootstrap-table-demo/js/tableExport.js"></script>
<script type="text/javascript" src="/AdminLTE/bower_components/bootstrap-table-demo/js/jquery.base64.js"></script>
<!-- 冻结列,记得启用下面的两个冻结列的参数,貌似启用父子表后,对冻结列会有一定的影响,这个JS是网上那位大神修改过的,解决了冻结列后空白的BUG-->
<script src="/AdminLTE/bower_components/bootstrap-table-demo/js/bootstrap-table-fixed-columns.js"></script>
<!-- 编辑,行内编辑我用不着,但这些功能是蛮实用的,记住要在列参数中启用编辑功能-->
<!-- <link href="/AdminLTE/bower_components/bootstrap-table-demo/css/bootstrap-editable.css" rel="stylesheet">
<script src="/AdminLTE/bower_components/bootstrap-table-demo/js/bootstrap-editable.js"></script>
<script src="/AdminLTE/bower_components/bootstrap-table-demo/js/bootstrap-table-editable.js"></script>
<link href="/AdminLTE/bower_components/bootstrap-table-demo/css/select2.css" rel="stylesheet">
<link href="/AdminLTE/bower_components/bootstrap-table-demo/css/select2-bootstrap.css" rel="stylesheet">
<script src="/AdminLTE/bower_components/bootstrap-table-demo/js/select2.js"></script>
<script src="/AdminLTE/bower_components/bootstrap-table-demo/js/select2.min.js"></script> -->
<!-- 行重新排序,取消这个备注就可启用-->
<!-- <script src="/AdminLTE/bower_components/bootstrap-table-demo/js/bootstrap-table-reorder-rows.js"></script>
<script src="/AdminLTE/bower_components/bootstrap-table-demo/js/jquery.tablednd.js"></script>-->
<!-- 列重新排序:在有父子表的时候不好用,但我还是搬过来,没有启用父子表时正常的,取消这个备注就可以启用-->
<!--<script src="/AdminLTE/bower_components/bootstrap-table-demo/js/bootstrap-table-reorder-columns.js"></script>-->
<!--<link rel="stylesheet" href="/AdminLTE/bower_components/bootstrap-table-demo/css/examples.css">-->
<!--<link rel="stylesheet" href="/AdminLTE/bower_components/bootstrap-table-demo/css/dragtable.css">
<script src="https://code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<script src="/AdminLTE/bower_components/bootstrap-table-demo/js/dragtable.js"></script>
<script src="https://code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<script src="https://code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<script src="/AdminLTE/bower_components/bootstrap-table-demo/js/ga.js"></script>-->
<!-- 列过滤,对我作用不大,所以此功能未启用,我用SQL模糊查询实现,要用的话,须启用下面表和列的参数,此JS要注意版本,有的版本无法显示数据或input框-->
<!--<script src="/AdminLTE/bower_components/bootstrap-table-demo/js/bootstrap-table-filter-control.js"></script>-->
<!-- 列采用select2过滤,按官方的例子做测试即可,这里只引入js-->
<!--<script src="/AdminLTE/bower_components/bootstrap-table-demo/js/bootstrap-table-select2-filter.js"></script>-->
<div class="panel panel-default">
<div class="panel-body">
<div class="container-fluid">
<div id="moon"></div>
<div>
<div class="col-*-12">
<!--工具栏-->
<div id="toolbar" class="btn-group pull-right" style="margin-right: 20px;">
<div class="form-inline">
@if(isset($tool))
@if(isset($tool['gold1']))
<div class="form-group">
<label for="select_status">人员状态 :</label>
<select class=" form-control input-sm" name="select_status" id="select_status">
<option value="0">正常</option>
<option value="1">封号</option>
<option value="2">永久</option>
</select>
</div>
<div class="form-group">
<label for="select_empno">账号 :</label>
<input id="select_empno" class="form-control input-sm">
</div>
<div class="form-group">
<label for="select_empno">手机 :</label>
<input id="select_empno" class="form-control input-sm">
</div>
<div class="form-group">
<label for="select_empno">推荐人 :</label>
<input id="select_empno" class="form-control input-sm">
</div>
<div class="form-group">
<select class=" form-control input-sm" name="select_status" id="select_status">
<option value=""></option>
<option value="0">注册时间</option>
<option value="1">最后时间</option>
<option value="2">确认时间</option>
</select>
<input id="select_empno" class="form-control input-sm">
<input id="select_empno" class="form-control input-sm">
</div>
{{--
<div class="form-group"><label for="MB001">时间 :</label>
<input id="MB001" class="form-control input-sm"></div>
<div class="form-group"><label for="MB002">到:</label>
<input id="MB002" class="form-control input-sm"></div>--}}
<button id="queryBtn" type="button" class="btn btn-default">
<span class="glyphicon glyphicon-search" aria-hidden="true"></span>查询
</button>
@endif
@if(isset($tool['sure']))
<button id="btn_delete" type="button" class="btn btn-default"
onClick="updateStatus(1);">
<span class="glyphicon glyphicon-ok" aria-hidden="true"></span>确认进场
</button>
@endif
@if(isset($tool['start']))
<button id="btn_delete" type="button" class="btn btn-default"
onClick="updateStatus(2);">
<span class="glyphicon glyphicon-play-circle" aria-hidden="true"></span>开始返还
</button>
@endif
@if(isset($tool['finish']))
<button id="btn_delete" type="button" class="btn btn-default"
onClick="updateStatus(3);">
<span class="glyphicon glyphicon-record" aria-hidden="true"></span>标记完成
</button>
@endif
@if(isset($tool['edit']))
<button id="btn_edit" type="button" class="btn btn-default">
<span class="glyphicon glyphicon-pencil" aria-hidden="true"></span>修改
</button>
@endif
@if(isset($tool['delete']))
<button id="btn_delete" type="button" class="btn btn-default" onClick="erpdel();">
<span class="glyphicon glyphicon-remove" aria-hidden="true"></span>删除
</button>
@endif
<!-- <button id="addBtn" type="button" class="btn btn-default" data-toggle="modal" data-target="#addModal">
<span class="glyphicon glyphicon-plus" aria-hidden="true"></span>新增</button>-->
@if(isset($tool['add']))
<button id="addBtn" type="button" class="btn btn-default">
<span class="glyphicon glyphicon-plus" aria-hidden="true"></span>新增
</button>
@endif
@if(isset($tool['gold']))
<button id="gold" type="button" class="btn btn-default">
<span class="glyphicon glyphicon-usd" aria-hidden="true"></span>金币赠送
</button>
@endif
@if(isset($tool['allWithdraw']))
<button id="allWithdraw" type="button" class="btn btn-default">
<span class="glyphicon glyphicon-zoom-in" aria-hidden="true"></span>查询所有
</button>
@endif
@if(isset($tool['withdraw']))
<button id="withdraw" type="button" class="btn btn-default">
<span class="glyphicon glyphicon-zoom-out" aria-hidden="true"></span>今日待打款
</button>
<select id="withdraw_finish" class="form-control " name="status">
<option value="">选择状态</option>
<option value="0">进行中</option>
<option value="1">已完成</option>
</select>
<button id="all" type="button" class="btn btn-default">
总数
</button>
<button id="current" type="button" class="btn btn-default">
本页
</button>
@endif
@if(isset($tool['orderFinish']))
<select id="order_finish" class="form-control " name="status">
<option value="">选择状态</option>
<option value="0">待付款</option>
<option value="10">已付款</option>
<option value="20">待确认</option>
<option value="30">分红中</option>
<option value="40">已完成</option>
</select>
<button id="all" type="button" class="btn btn-default">
总数
</button>
<button id="current" type="button" class="btn btn-default">
本页
</button>
@endif
@if(isset($tool['login']))
<button id="login" type="button" class="btn btn-default">
<span class="glyphicon glyphicon-new-window" aria-hidden="true"></span>登录
</button>
@endif
@endif
{{-- <button id="button" type="button" class="btn btn-default">
<span class="glyphicon glyphicon-zoom-in" aria-hidden="true"></span>Large</button>
<button id="button2" type="button" class="btn btn-default">
<span class="glyphicon glyphicon-zoom-out" aria-hidden="true"></span>Small</button>--}}
</div>
</div>
<!--定义表格样式style-->
<div class="div-table">
<table id="mytab" style="word-break: keep-all;white-space:nowrap;"
data-mobile-responsive="true"
data-reorderable-columns="true" data-use-row-attr-func="true"
data-reorderable-rows="true"></table>
</div>
@if(isset($modal))
@include('panels.tableModal.'.$modal)
@endif
</div>
</div>
</div><!-- container-fluid -->
</div>
</div>
<script>
var table_config = {!! $table !!};
</script>
<script src="/js/tablePanel.js"></script>
'admin_page_parent' => '系统模块',
'admin_page_index' => '管理员',
'admin_page_title' => [
['type' => 'text', 'key' => 'id', 'value' => 'ID'],
['type' => 'text', 'key' => 'empno', 'value' => '用户名'],
['type' => 'text', 'key' => 'empname', 'value' => '真实姓名'],
['type' => 'text', 'key' => 'department', 'value' => '所在部门'],
['type' => 'text', 'key' => 'mobile', 'value' => '手机号码'],
['type' => 'text', 'key' => 'is_super', 'value' => '用户类别'],
['type' => 'text', 'key' => 'status', 'value' => '用户状态'],
],