hn_cloud_web/smz-screen/js/workerPost/workerPostPeople.js

388 lines
9.7 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.

var type = localStorage.getItem('type');
var postName = localStorage.getItem('postName');
$(function() {
findCompany(); //公司
findWorkType();//获取工种类型
findAddress();//获取省份
$("#selSex").select2();//性别
$("#selContract").select2();//合同
$("#selAge").select2();//年龄
switch(type){
case "公司":
$("#selCompany option:contains('"+postName+"')").attr("selected", true).trigger("change");
break;
case "省份":
$("#selAddress option:contains('"+postName+"')").attr("selected", true).trigger("change");
break;
case "工种":
$("#selPost option:contains('"+postName+"')").attr("selected", true).trigger("change");
break;
case "年龄结构":
$("#selAge option:contains('"+postName+"')").attr("selected", true).trigger("change");
break;
case "持证情况":
$("#certificate").val(postName);
break;
case "性别":
$("#selSex option:contains('"+postName+"')").attr("selected", true).trigger("change");
break;
// case "考勤天数":
// $("#countNum option:contains('"+postName+"')").attr("selected", true).trigger("change");
// break;
case "劳动合同":
$("#selContract option:contains('"+postName+"')").attr("selected", true).trigger("change");
break;
}
initTable();
})
function responseHandler(res) {
console.log(res);
var datas=[];
console.log(res.total);
datas.push({total:res.total,rows:res.list});
return datas[0];
}
function initTable() {
var health;
if(postName == '健康' && type == '健康状况'){
health = '1';
}
if(postName == '不健康' && type == '健康状况'){
health = '0';
}
if(postName == '无' && type == '健康状况'){
health = '-1';
}
//初始化Table
$("#table").bootstrapTable({
classes: 'table table-hover',
url: dataUrl + 'workerPost/getWorkerPostPeople',
method: 'post',
responseHandler: responseHandler, //处理服务器返回的数据格式
height: $(window).height() - ($(window).height() * 0.2),
undefinedText: '', //当数据为 undefined 时显示的字符
queryParams: function(param) {
param = {
companyId:$("#selCompany").val(),
address:$("#selAddress").val(),
sex:$("#selSex").val(),
ageNum:$("#selAge").val(),
postName:$("#selPost").val(),
certificateName:$("#certificate").val(),
counts:$("#countNum").val(),
contract:$("#selContract").val(),
keyWord:$("#keyWord").val(),
peStatus: health,
frequencyRange: postName,
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: 280
},{
title: '公司',
field: 'companyName',
rowspan: 1,
align: 'center',
valign: 'middle',
sortable: true,
width: 200
},
{
title: '省份',
field: 'address',
rowspan: 1,
align: 'center',
valign: 'middle',
sortable: true,
width: 120
},
{
title: '工程名称',
field: 'proName',
rowspan: 1,
align: 'center',
valign: 'middle',
sortable: true,
width: 300
},{
title: '分包商',
field: 'subName',
rowspan: 1,
align: 'center',
valign: 'middle',
sortable: true,
width: 200
},{
title: '班组长',
field: 'foreman',
rowspan: 1,
align: 'center',
valign: 'middle',
sortable: true,
width: 100
},{
title: '工种',
field: 'postName',
rowspan: 1,
align: 'center',
valign: 'middle',
sortable: true,
width: 120
},{
title: '年龄',
field: 'age',
rowspan: 1,
align: 'center',
valign: 'middle',
sortable: true,
width: 100
},
{
title: '持证情况',
field: 'certificateName',
rowspan: 1,
align: 'center',
valign: 'middle',
sortable: true,
width: 120
},
{
title: '考勤天数',
field: 'counts',
rowspan: 1,
align: 'center',
valign: 'middle',
sortable: true,
width: 100
},{
title: '合同签署',
field: 'contract',
rowspan: 1,
align: 'center',
valign: 'middle',
sortable: true,
width: 100
},{
title: '性别',
field: 'sex',
rowspan: 1,
align: 'center',
valign: 'middle',
sortable: true,
width: 100
},
{
title: '安规考试成绩',
field: 'safetyScore',
rowspan: 1,
align: 'center',
valign: 'middle',
sortable: true,
width: 160
},{
title: '体检状况',
field: 'peStatus',
rowspan: 1,
align: 'center',
valign: 'middle',
sortable: true,
width: 100
},{
title: '联系方式',
field: 'phone',
rowspan: 1,
align: 'center',
valign: 'middle',
sortable: true,
width: 180
}
],
onLoadSuccess: function(data) {
top.layer.close(index);
$("#dataCount").html("数量:" + data.total);
},
onLoadError: function() {
$("#dataCount").html("数量:0");
$("#table").bootstrapTable('removeAll');
},
});
}
var index;
// 模糊查询数据、重置查询
function query(type) {
index = top.layer.load(0, {
shade: false
}); // 0代表加载的风格支持0-2
$("#query").css("background-image", "url(../../img/info/queryClick.png)");
$("#reset").css("background-image", "url(../../img/info/resetQuery.png)");
var opt = {
url: dataUrl + 'workerPost/getWorkerPostPeople',
silent: true,
query: {
id:companyId,
companyId:$("#selCompany").val(),
address:$("#selAddress").val(),
sex:$("#selSex").val(),
ageNum:$("#selAge").val(),
postName:$("#selPost").val(),
certificateName:$("#certificate").val(),
counts:$("#countNum").val(),
contract:$("#selContract").val(),
keyWord:$("#keyWord").val()
}
};
if (type == 2) {
$("#query").css("background-image", "url(../../img/info/query.png)");
$("#reset").css("background-image", "url(../../img/info/resetQueryClick.png)");
findCompany(); //公司
findWorkType();//获取工种类型
findAddress();//获取省份
$("#selSex").val("").select2();//性别
$("#selContract").val("").select2();//合同
$("#selAge").val("").select2();//年龄
$("#selCompany option:first").attr("selected", true).trigger("change");
$("#selAddress option:first").attr("selected", true).trigger("change");
$("#selPost option:first").attr("selected", true).trigger("change");
// $("#selSex option:first").attr("selected", true).trigger("change");
// $("#selAge option:first").attr("selected", true).trigger("change");
// $("#selContract option:first").attr("selected", true).trigger("change");
$("#certificate").val("");
$("#countNum").val("");
$("#keyWord").val("");
opt = {
url: dataUrl + 'workerPost/getWorkerPostPeople',
silent: true,
};
}
$("#table").bootstrapTable('refresh', opt);
initTable();
}
//获取分公司
function findCompany(){
$("#selCompany").empty();
$.ajax({
type: 'POST',
url: dataUrl + 'map/findCompany',
data: {key:companyId},
async: false,
dataType: "json",
success: function(data) {
var html="";
html += '<option value="">请选择</option>';
for(var i=0;i<data.length;i++){
html += '<option value="' + data[i].id + '">' + data[i].name + '</option>';
}
$("#selCompany").append(html);
$("#selCompany").select2();
}
});
};
//获取工种类型
function findWorkType(){
$("#selPost").empty();
$.ajax({
type: 'POST',
url: dataUrl + 'map/findWorkType',
data: {},
async: false,
dataType: "json",
success: function(data) {
var html="";
html += '<option value="">请选择</option>';
for(var i=0;i<data.length;i++){
html += '<option value="' + data[i].name + '">' + data[i].name + '</option>';
}
$("#selPost").append(html);
$("#selPost").select2();
},
error:function(data){
var html='<option value="">请选择</option>';
$("#selPost").append(html);
}
});
};
//获取省份
function findAddress(){
$("#selAddress").empty();
$.ajax({
type: 'POST',
url: dataUrl + 'workerPost/getAddressList',
data: {},
async: false,
dataType: "json",
success: function(data) {
var obj=data.obj;
var list=obj.bean;
var html="";
html += '<option value="">请选择</option>';
for(var i=0;i<list.length;i++){
html += '<option value="' + list[i].registerAddressCodeName + '">' + list[i].registerAddressCodeName + '</option>';
}
$("#selAddress").append(html);
$("#selAddress").select2();
},
error:function(data){
var html='<option value="">请选择</option>';
$("#selAddress").append(html);
}
});
};