hn_cloud_web/smz-screen/js/redBlack/workerRed.js

177 lines
4.4 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

$(function() {
initTable();
})
function responseHandler(res) {
var datas=[];
datas.push({total:res.total,rows:res.list});
return datas[0];
}
function initTable() {
index = top.layer.load(0, {
shade: false
}); // 0代表加载的风格支持0-2
//初始化Table
$("#table").bootstrapTable({
classes: 'table table-hover',
url: smz_web_url + 'redBlack/getWorkerRedInfo',
method: 'post',
responseHandler: responseHandler, //处理服务器返回的数据格式
height: $(window).height() - ($(window).height() * 0.13),
undefinedText: '', //当数据为 undefined 时显示的字符
queryParams: function(param) {
param = {
companyId: companyId,
keyWord: $("#keyWord").val(),
pageSize: param.limit,
pageNum: param.offset / param.limit + 1,
sort: param.sort, //排序列名
sortOrder: param.order //排位命令descasc
}
return param;
},
sortable: true, //是否启用排序
sortOrder: "asc", //排序方式
cache: false, //是否使用缓存默认为true所以一般情况下需要设置一下这个属性*
pagination: true,
pageNumber: 1,
pageSize: 50,
pageList: [50, 100, 200, 300],
smartDisplay: false,
showColumns: false,
sidePagination: "server", //分页方式client客户端分页server服务端分页*
contentType: "application/x-www-form-urlencoded",
minimumCountColumns: 2, //最少允许的列数
uniqueId: "no", //每一行的唯一标识,一般为主键列
columns: [{
title: '序号',
formatter: function(value, row, index) {
return index + 1;
},
rowspan: 1,
align: 'center',
valign: 'middle',
width: 50
},
{
title: '姓名',
field: 'name',
rowspan: 1,
align: 'center',
valign: 'middle',
sortable: true,
width: 100
},
{
title: '身份证',
field: 'idNumber',
rowspan: 1,
align: 'center',
valign: 'middle',
sortable: true,
width: 230
},
{
title: '年龄',
field: 'age',
rowspan: 1,
align: 'center',
valign: 'middle',
sortable: true,
width: 100
},
{
title: '工种',
field: 'postName',
rowspan: 1,
align: 'center',
valign: 'middle',
sortable: true,
width: 100
},
{
title: '家挺地址',
field: 'address',
rowspan: 1,
align: 'center',
valign: 'middle',
sortable: true,
width: 150
},
{
title: '联系方式',
field: 'phone',
rowspan: 1,
align: 'center',
valign: 'middle',
sortable: true,
width: 200
},
{
title: '备注',
field: 'remark',
rowspan: 1,
align: 'center',
valign: 'middle',
sortable: true,
width: 200
}
],
onLoadSuccess: function(data) {
$("#dataCount").html("数量:" + data.total);
top.layer.close(index);
},
onLoadError: function() {
$("#dataCount").html("数量:0");
$("#table").bootstrapTable('removeAll');
top.layer.close(index);
}
});
}
var index;
// 模糊查询数据、重置查询
function query(type) {
index = top.layer.load(0, {
shade: false
}); // 0代表加载的风格支持0-2
if (type == 1) {
var keyWord = $("#keyWord").val();
$("#query").css("background-image", "url(../../img/info/queryClick.png)");
$("#reset").css("background-image", "url(../../img/info/resetQuery.png)");
$("#export").css("background-image", "url(../../img/info/export.png)");
var opt = {
url: smz_web_url + 'redBlack/getWorkerRedInfo',
silent: true,
query: {
keyWord: keyWord,
}
};
$("#table").bootstrapTable('refresh', opt);
}else if (type == 2) {
$("#query").css("background-image", "url(../../img/info/query.png)");
$("#reset").css("background-image", "url(../../img/info/resetQueryClick.png)");
$("#export").css("background-image", "url(../../img/info/export.png)");
$("#keyWord").val("");
var keyWord = $("#keyWord").val();
var opt = {
url: smz_web_url + 'redBlack/getWorkerRedInfo',
silent: true,
query: {
keyWord: keyWord
}
};
}
$("#table").bootstrapTable('refresh', opt);
initTable();
}
function exportBtn() {
$("#query").css("background-image", "url(../../img/info/query.png)");
$("#reset").css("background-image", "url(../../img/info/resetQuery.png)");
$("#export").css("background-image", "url(../../img/info/exportClick.png)");
var keyWord = $("#keyWord").val();
window.location.href = smz_web_url + "redBlack/exportWorkerRed?keyWord=" + keyWord + "&x-auth-token=" + token;
}