hn_cloud_web/smz-web/js/work/basic/teamWorkInfo.js

203 lines
8.4 KiB
JavaScript
Raw Permalink 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 example = null;
var pers = null;
$(function () {
layui.use(['layer','form'], function () {
var layer = layui.layer;
var form = layui.form;
pers = checkPermission();
getTeamType(form);
init();
$("#searchBt").click(function () {
example.ajax.reload();
});
form.render();
});
});
function init() {
example =
$('#dt-table').DataTable({
"searching": false,
"processing": true, //加载数据时显示进度状态
"serverSide": true,
"pagingType": "full_numbers", //首页|尾页
"language": {
"url": "../../../js/plugin/datatables/Chinese.lang"
},
"ajax": {
"url": smz_ht_url + "/TeamManager/getTeamWorkInfoList",
"type": "get",
"data": function (d) {
d.keyWord = $('#name').val();
d.teamType = $('#teamType').val();
},
"error": function (xhr, textStatus, errorThrown) {
var msg = xhr.responseText;
console.log(msg);
var response = JSON.parse(msg);
var code = response.code;
var message = response.message;
if (code == 400) {
layer.msg(message);
} else if (code == 401) {
localStorage.removeItem("token");
layer.msg("token过期请先登录", {shift: -1, time: 1000}, function () {
location.href = smz_ht_url + '/login.html';
});
} else if (code == 403) {
console.log("未授权:" + message);
layer.msg('未授权');
} else if (code == 500) {
console.log('系统错误:' + message);
}
}
},
"lengthMenu": [ [10, 20, 50], [10, 20, 50] ], // 设置每页显示数据量选项
"drawCallback": function() {
// alert( '表格重绘了' );
var thisDataTable = $('#dt-table').DataTable();
$(".pagination").append("<li>" +
"<a class='paginate_button' style='padding:4px;' href='#' tabindex='0'>到 <input style='margin:0px;width:40px;' id='changePage'> 页</a>" +
"<a class='paginate_button' style='margin-bottom:1px' href='#' tabindex='0' id='dataTable-btn'>确认</a></li>");
//点击按钮跳转指定页数
$('#dataTable-btn').click(function (e) {
if ($("#changePage").val() && $("#changePage").val() > 0) {
var redirectpage = $("#changePage").val() - 1;
} else {
var redirectpage = 0;
}
thisDataTable.page(redirectpage).draw( 'page' );
});
//敲击回车键跳转指定页数
$("#changePage").keypress(function (e) {
if(event.keyCode==13){
if ($("#changePage").val() && $("#changePage").val() > 0) {
var redirectpage = $("#changePage").val() - 1;
} else {
var redirectpage = 0;
}
thisDataTable.page(redirectpage).draw( 'page' );
}
});
},
"dom": "<'dt-toolbar'r>t<'dt-toolbar-footer'<'col-sm-4 col-xs-4 hidden-xs'i><'col-xs-8 col-sm-8' p v>><'dt-table-length'l>",
"columns": [
{
width: '20px',
"orderable": false,
data: function (row, type, set, meta) {
var c = meta.settings._iDisplayStart + meta.row + 1;
return c;
}
},
{"data": "name", "orderable": false,'width': '60px'},
{"data": "teamType", "orderable": false,'width': '60px'},
{
"orderable": false,
"width": "40px",
"render": function (data, type, row) {
var totalNum = row['teamTotalNumber'];
var teamId = row['id'];
var proId = row['proId'];
var keyStatus = '3';
var html = "<span style='color: #25568b;cursor: pointer;' title='' onclick='photoView(\""+teamId +"\",\"" + keyStatus +"\" ,\"" + proId +"\")'>" + totalNum + " </span>";
return html;
}
},
{
"orderable": false,
'width': '30px',
"render": function (data, type, row) {
var totalNum = row['einPeopleNumber'];
var teamId = row['id'];
var proId = row['proId'];
var keyStatus = '1';
var html = "<span style='color: green;cursor: pointer;' title='' onclick='photoView(\""+teamId +"\",\"" + keyStatus +"\" ,\"" + proId +"\")'> " + totalNum + " </span>";
return html;
}
},
{
"orderable": false,
'width': '30px',
"render": function (data, type, row) {
var totalNum = row['exitPeopleNumber'];
var teamId = row['id'];
var proId = row['proId'];
var keyStatus = '0';
var html = "<span style='color: green;cursor: pointer;' title='' onclick='photoView(\""+teamId +"\",\"" + keyStatus +"\" ,\"" + proId +"\")'> " + totalNum + " </span>";
return html;
}
},
{
"orderable": false,
"width": "40px",
"render": function (data, type, row) {
var redListTotal = row['redListTotal'];
var teamId = row['id'];
var proId = row['proId'];
var keyStatus = '2';
var html = "<span style='color: #25568b;cursor: pointer;' title='' onclick='photoView(\""+teamId +"\",\"" + keyStatus +"\" ,\"" + proId +"\")'>" + redListTotal +" </span>";
return html;
}
},
{"data": "subName", "orderable": false,'width': '60px'},
{"data": "proName", "orderable": false,'width': '90px'},
{
"orderable": false,
'width': '20px',
"render": function (data, type, row) {
var isExcellent = row['isExcellent'];
if (isExcellent>0){
isExcellent = '是';
}else{
isExcellent = '否';
}
return isExcellent;
}
},
],
"order": [] //在栏目列上显示排序功能
});
}
//查看
function photoView(teamId,keyStatus,proId) {
localStorage.setItem("teamId", teamId);
localStorage.setItem("keyStatus", keyStatus);
console.log(keyStatus);
console.log(teamId);
var height = '75%';
var width = '75%';
var index = layer.open({
title: ["查看", 'color:#3B70A1;background-color:#E8ECEB;font-size:20px'],
type: 2,
content: './teamWorkerPerson.html',
area: [width, height],
maxmin: false,
});
}
/**
* 获取班组类别
* */
function getTeamType(form) {
$("#teamType").empty();
$.ajax({
type: 'post',
url: smz_ht_url + '/org/getTeamTypeList',
data: {},
dataType: 'json',
success: function (data) {
var str = '<option value="">请选择班组类别</option>';
for (var i = 0; i < data.obj.length; i++) {
str += '<option value=\'' + data.obj[i].id + '\'>' + data.obj[i].name + '</option>';
}
$("#teamType").html(str);
form.render();
}
})
}