IntelligentRecognition/ah-jjsp-web/.svn/pristine/66/6620f06253d0df636885af7ce8e...

346 lines
11 KiB
Plaintext
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.

let table, form, layer, rate, util;
$(function () {
layui.use(['rate', 'layer', 'form', 'table', 'util'], function () {
layer = layui.layer;
form = layui.form;
rate = layui.rate;
table = layui.table;
util = layui.util;
util.event('lay-active', {
query: function () {
table.reloadData('teamTable', {
page: {
curr: 1
},
where: getReqParams()
});
},
reset: function () {
$('#keyword').val('');
$('#teamName').val('');
$('#foreman').val('');
$('#projectName').val('');
$('#type').val('');
form.render();
table.reloadData('teamTable', {
page: {
curr: 1
},
where: getReqParams()
});
},
export: function () {
exportData();
}
});
form.render();
getPerNum();
initTable();
//触发单元格工具事件
table.on('tool(teamTable)', function (obj) { // 双击 toolDouble
let data = obj.data;
if (obj.event === 'detail') {
toEvaluatePage(data.classId, data.idNumber, data.teamName);
} else if (obj.event === 'edit') {
layer.prompt({
formType: 2,
title: '拉黑说明 '
}, function (value, index) {
/**
* 拉黑操作
*/
Ajax().post({
url: dataUrl + 'proteam/pot/team/insertTeamBlack',
data: {
idNumber: data.idNumber,
content: value,
userId: '1'
},
success: function (data) {
if (data.code === 200) {
layer.msg(data.msg, {
icon: 1,
time: 2000 //2秒关闭如果不配置默认是3秒
}, function () {
table.reloadData('teamTable', {
page: {
curr: 1
},
where: getReqParams()
});
layer.close(index);
});
} else {
layer.msg(data.msg, {icon: -1});
}
},
async: false
});
});
}
});
});
});
// 获取参数
function getReqParams() {
let obj = {
keyWord: $('#keyword').val(),
teamName: $('#teamName').val(),
fzrName: $('#foreman').val(),
proName: $('#projectName').val(),
status: $('#type').val()
};
return obj;
}
function initTable() {
table.render({
elem: "#deviceTable",
id: "deviceTable",
height: "full-170",
url: dataUrl + "proteam/pot/team/getTeamList" + '?token=' + token,
page: true, //开启分页
method: "POST",
limit: 10, //默认十条数据一页
limits: [10, 20, 30], //数据分页条
cellMinWidth: 100,
loading: true,
totalRow: false,
request: {
pageName: 'pageNum',
limitName: 'pageSize'
},
where: getReqParams(),
cols: [
[//表头
{
field: "number",
type: "numbers",
title: "序号",
minWidth: 200,
unresize: true,
align: "center",
},
{
field: "teamName",
title: "班组名称",
unresize: true,
minWidth: 200,
align: "center",
},
{
field: 'fzrName',
title: "班组长",
unresize: true,
minWidth: 200,
align: "center",
templet: function (d) {
return "<span>" + d.fzrName + "</span><br><span>" + d.phone + "</span>";
},
},
{
field: "zhpj",
title: "班组星级",
minWidth: 200,
unresize: true,
templet: function (d) {
console.log(d)
return '<div id="test' + d.LAY_TABLE_INDEX + '"></div>'
},
align: "center",
},
{
field: "proName",
title: "当前所在工程",
unresize: true,
minWidth: 200,
align: "center",
},
{
field: "status",
title: "状态",
unresize: true,
minWidth: 200,
align: "center",
},
{
field: "dayNum",
title: "今日站班会人数",
unresize: true,
minWidth: 200,
templet: function (d) {
return "<h2 onclick='toTodayPage(" + d.dayNum + ")' style='color: blue;cursor: pointer;'>" + d.dayNum + "</h2>";
},
align: "center",
},
{
field: "yeNum",
title: "昨日站班会人数",
unresize: true,
minWidth: 200,
align: "center",
},
{
field: "yeNum",
title: "累计违章次数",
unresize: true,
minWidth: 200,
templet: function (d) {
return "<h2 onclick='toViolationsPage(" + d.vzNum + ")' style='color: blue;cursor: pointer;'>" + (isEmpty(d.vzNum) ? "0" : d.vzNum) + "</h2>";
},
align: "center",
},
{
fixed: 'right',
title: "操作",
align: 'center',
minWidth: 200,
toolbar: '#barDemo'
}
],
],
done: function (res, curr, count) {
for (let i = 0; i < res.data.length; i++) {
rate.render({
elem: '#test' + i
, value: res.data[i].zhpj / 2
, readonly: true
, half: true,
theme: '#2F82FB'
});
table.render()
}
},
parseData: function (res) {
return {
"code": res.code === 200 ? 0 : res.code,
"msg": res.msg,
"count": res.total,
"data": res.rows
};
}
});
}
/**
* 跳转违章页面
* @param teamId 班组id
*/
function toViolationsPage(teamId) {
console.log(teamId);
}
/**
* 跳转今日人员页面
* @param teamId 班组id
*/
function toTodayPage(classId, idNumber, teamName) {
let width = '90%', height = '80%';
let index = parent.layer.open({
/* color:#253E78;font-size:24px;background-color:rgb(37 62 120 / 22%);*/
title: ['班组人员', 'font-size:24px;'],
type: 2,
skin: 'shadows',
content: '../../html/teamInformation/child/teamPersonnel.html',
area: [width, height],
maxmin: false
});
}
/**
* 跳转班组评价页面
* @param classId 站班会id
* @param idNumber 身份证号
* @param teamName 班组名称
*/
function toEvaluatePage(classId, idNumber, teamName) {
let width = '90%', height = '80%';
layer.open({
id: 'abc',
/* color:#253E78;font-size:24px;background-color:rgb(37 62 120 / 22%);*/
title: ['班组评价', 'font-size:24px;'],
type: 2,
skin: 'shadows',
content: '../../html/teamInformation/child/teamEvaluate.html',
area: [width, height],
maxmin: false,
success: function (layero, index) {
let body = layer.getChildFrame('body', index);
let iframeWin = window[layero.find('iframe')[0]['name']];//获得iframe页的窗口对象执行iframe页的方法
iframeWin.setForm(classId, idNumber, teamName);//调用子页面的方法,页面锁定
}
});
}
//导出
function exportData() {
let loadingMsg = layer.msg("数据导出中,请稍候...", {icon: 16, scrollbar: false, time: 0,});
let url = dataUrl + "proteam/pot/team/exportTeamData?" + setData(getReqParams()) + '&token=' + token;
let xhr = new XMLHttpRequest();
let a = document.createElement("a");
xhr.open("get", url, true);
xhr.responseType = "blob"; // 转换流
xhr.onload = function () {
layer.close(loadingMsg);
if (this.status === 200) {
let url = window.URL.createObjectURL(new Blob([this.response]))
let link = document.createElement('a')
link.style.display = 'none'
link.href = url
link.setAttribute('download', "班组明细.xlsx")
document.body.appendChild(link)
link.click()
// 释放URL对象所占资源
window.URL.revokeObjectURL(url)
// 用完即删
document.body.removeChild(link)
} else {
layer.msg("数据发生异常,请稍后重试", {icon: 16, scrollbar: false, time: 2000});
}
};
xhr.send();
}
function getPerNum() {
$.ajax({
url: dataUrl + 'proteam/pot/team/getPerNum' + '?token=' + token,
type: 'post',
success: function (obj) {
if (obj.code === 200) {
$.each(obj.data, function (index, item) {
$("#dTeam").html(item.dTeam);
$("#dZTeam").html(item.dZTeam);
$("#dPer").html(item.dPer);
$("#dZPer").html(item.dZPer);
$("#dWTeam").html(item.dWTeam);
$("#xZteam").html(item.xZteam);
$("#yTeam").html(item.yTeam);
$("#yPer").html(item.yPer);
})
}
}
});
}
// 展开/收起
function isShow(type) {
if (type === 1) {
$("#basic-info").slideLeftHide();
setTimeout(() => {
$("#show").removeAttr("style");
}, 510);
$(".basic-info-box").animate({backgroundColor: "#fff"}, "500");
} else if (type === 2) {
$("#show").css("display", "none");
$(".basic-info-box").animate({backgroundColor: "#EEF5FF"}, "500");
$("#basic-info").slideLeftShow();
}
}