336 lines
10 KiB
JavaScript
336 lines
10 KiB
JavaScript
let table, layer, form;
|
|
let fontSize = '14', fontFamily = 'Alibaba PuHuiTi R', fontColor = '#fff';
|
|
|
|
const bidCode = parent.$('#bidPro').val();
|
|
layui.use(["layer", "table", "form"], function () {
|
|
layer = layui.layer;
|
|
table = layui.table;
|
|
form = layui.form;
|
|
// getTrend();
|
|
//
|
|
// wearGarList()
|
|
|
|
getDeviceEcharts();
|
|
});
|
|
|
|
function getDeviceEcharts(){
|
|
const url =
|
|
commonUrl +
|
|
"screen/resourceUtilization/selectDeviceEcharts"
|
|
ajaxRequestGet(
|
|
url,
|
|
"GET",
|
|
true,
|
|
function () {
|
|
},
|
|
function (result) {
|
|
if (result.code === 200) {
|
|
setData(result.data);
|
|
} else if (result.code === 500) {
|
|
console.error("实时监测" + result.msg);
|
|
setData(null);
|
|
} else if (result.code === 401) {
|
|
loginout(1);
|
|
}
|
|
},
|
|
function (xhr, status, error) {
|
|
errorFn(xhr, status, error);
|
|
setData(null);
|
|
},
|
|
aqEnnable
|
|
);
|
|
|
|
/* 实时检测赋值 */
|
|
function setData(data) {
|
|
if (data) {
|
|
console.log( data['deviceEcharts'])
|
|
let deviceEchartsList = data['deviceEcharts']; //设备情况的echarts
|
|
let deviceUtilization = data.deviceUtilization; //设备利用率
|
|
document.getElementById("deviceUtilization").innerHTML = deviceUtilization +'<span>%</span>';
|
|
let efficiency = data['efficiency']; // 效率分析
|
|
getEfficiencyTable(efficiency)
|
|
let todayDutyRate = data.todayDutyRate; //今日到岗率
|
|
document.getElementById("todayDutyRate").innerHTML = todayDutyRate +'<span>%</span>';
|
|
let workerEcharts = data['workerEcharts']; //一周到岗人数趋势
|
|
getTrend(workerEcharts)
|
|
let workerUtilization = data.workerUtilization; //人员利用率
|
|
document.getElementById("workerUtilization").innerHTML = workerUtilization +'<span>%</span>';
|
|
let yesterdayDutyRate = data.yesterdayDutyRate; //昨日到岗率
|
|
document.getElementById("yesterdayDutyRate").innerHTML = yesterdayDutyRate +'<span>%</span>';
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
function getTrend(workerEcharts) {
|
|
let date =[];
|
|
let actualCount =[]; //实到
|
|
let shouldCount =[]; //应到
|
|
if(workerEcharts){
|
|
for (let i = 0; i < workerEcharts.length; i++) {
|
|
date.push(workerEcharts[i].date)
|
|
actualCount.push(workerEcharts[i].actualCount)
|
|
shouldCount.push(workerEcharts[i].shouldCount)
|
|
}
|
|
}
|
|
initTrend(date,actualCount,actualCount)
|
|
}
|
|
|
|
function initTrend(date,actualCount,shouldCount) {
|
|
const leftChart = echarts.init(document.getElementById("trend"));
|
|
const option = {
|
|
title: {
|
|
text: '一周到岗人数趋势',
|
|
textStyle: {
|
|
color: '#ffffff',
|
|
fontSize: fontSize,
|
|
fontFamily: fontFamily
|
|
},
|
|
left: 5,
|
|
top: 5
|
|
},
|
|
tooltip: {
|
|
show:true,
|
|
trigger: 'axis',
|
|
axisPointer: {
|
|
type: 'shadow',
|
|
},
|
|
borderColor: 'rgba(255,255,255,.3)',
|
|
backgroundColor: 'rgba(19,51,55,.6)',
|
|
textStyle: {
|
|
color: 'white', //设置文字颜色
|
|
},
|
|
borderWidth: 1,
|
|
padding: 10,
|
|
},
|
|
legend: {
|
|
show:true,
|
|
top:10,
|
|
right:20,
|
|
textStyle:{
|
|
color:'#ffffff'
|
|
}
|
|
},
|
|
grid: {
|
|
top: '25%',
|
|
left: '8%',
|
|
right: '4%',
|
|
bottom: '15%'
|
|
},
|
|
xAxis: [
|
|
{
|
|
type: 'category',
|
|
boundaryGap: true,
|
|
axisLine: {
|
|
//坐标轴轴线相关设置。数学上的x轴
|
|
show: true,
|
|
lineStyle: {
|
|
color: '#5A6E71',
|
|
},
|
|
},
|
|
axisLabel: {
|
|
//坐标轴刻度标签的相关设置
|
|
textStyle: {
|
|
color: fontColor,
|
|
fontSize: fontSize,
|
|
fontFamily: fontFamily
|
|
},
|
|
},
|
|
splitLine: {
|
|
show: false,
|
|
lineStyle: {
|
|
color: '#233653',
|
|
},
|
|
},
|
|
axisTick: {
|
|
show: true,
|
|
},
|
|
data: date,
|
|
},
|
|
],
|
|
yAxis: [{
|
|
min: 0,
|
|
splitNumber: 10,
|
|
splitLine: {
|
|
show: true,
|
|
lineStyle: {
|
|
color: 'rgba(255,255,255,0.6)',
|
|
type: 'dashed',
|
|
},
|
|
},
|
|
axisLine: {
|
|
show: false,
|
|
},
|
|
axisLabel: {
|
|
show: true,
|
|
textStyle: {
|
|
color: 'rgba(255,255,255,0.8)',
|
|
padding: 16
|
|
},
|
|
formatter: function(value) {
|
|
if (value === 0) {
|
|
return value
|
|
}
|
|
return value
|
|
}
|
|
},
|
|
axisTick: {
|
|
show: false,
|
|
},
|
|
}],
|
|
"dataZoom": [{
|
|
"show": true,
|
|
"height": 12,
|
|
"xAxisIndex": [
|
|
0
|
|
],
|
|
bottom:'8%',
|
|
"start": 10,
|
|
"end": 90,
|
|
handleIcon: 'path://M306.1,413c0,2.2-1.8,4-4,4h-59.8c-2.2,0-4-1.8-4-4V200.8c0-2.2,1.8-4,4-4h59.8c2.2,0,4,1.8,4,4V413z',
|
|
handleSize: '110%',
|
|
handleStyle:{
|
|
color:"#d3dee5",
|
|
|
|
},
|
|
textStyle:{
|
|
color:"#fff"},
|
|
borderColor:"#90979c"
|
|
}, {
|
|
"type": "inside",
|
|
"show": true,
|
|
"height": 15,
|
|
"start": 1,
|
|
"end": 35
|
|
}],
|
|
series: [{
|
|
name: '实到',
|
|
type: 'line',
|
|
symbol: 'circle',
|
|
showAllSymbol: true,
|
|
symbolSize: 0,
|
|
smooth: true,
|
|
lineStyle: {
|
|
normal: {
|
|
width: 2,
|
|
color: "#00FEFC",
|
|
}
|
|
},
|
|
itemStyle: {
|
|
color: "#00FEFC",
|
|
borderWidth: 2
|
|
},
|
|
tooltip: {
|
|
show: true
|
|
},
|
|
areaStyle: {
|
|
normal: {
|
|
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
|
|
offset: 0,
|
|
color: "rgba(18,86,100,0.6)"
|
|
},
|
|
{
|
|
offset: 1,
|
|
color: "rgba(16,72,81, 0.7)"
|
|
}
|
|
], false),
|
|
shadowColor: 'rgba(15,55,63, 0.8)',
|
|
shadowBlur: 20
|
|
}
|
|
},
|
|
data: actualCount
|
|
}, {
|
|
name: '应到',
|
|
type: 'line',
|
|
symbol: 'circle',
|
|
showAllSymbol: true,
|
|
symbolSize: 0,
|
|
smooth: true,
|
|
lineStyle: {
|
|
normal: {
|
|
width: 2,
|
|
color: "rgba(25,196,134, 1)",
|
|
}
|
|
},
|
|
itemStyle: {
|
|
color: "rgba(25,196,134, 1)",
|
|
borderWidth: 2
|
|
|
|
},
|
|
tooltip: {
|
|
show: true
|
|
},
|
|
areaStyle: {
|
|
normal: {
|
|
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
|
|
offset: 0,
|
|
color: "rgba(17,95,82, 0.6)"
|
|
},
|
|
{
|
|
offset: 1,
|
|
color: "rgba(16,72,67, 0.7)"
|
|
}
|
|
], false),
|
|
shadowColor: 'rgba(15,55,54, 0.8)',
|
|
shadowBlur: 20
|
|
}
|
|
},
|
|
data: shouldCount
|
|
}]
|
|
};
|
|
|
|
leftChart.setOption(option);
|
|
// 响应式调整
|
|
window.addEventListener("resize", function () {
|
|
leftChart.resize();
|
|
});
|
|
}
|
|
|
|
function getEfficiencyTable(efficiency){
|
|
|
|
// 确保 efficiency 是数组且不为空
|
|
const tableData = efficiency && efficiency.length > 0 ? efficiency : [];
|
|
|
|
if (tableData.length === 0) {
|
|
console.log('没有数据可显示');
|
|
// 可以显示空数据提示
|
|
document.getElementById('dome1').innerHTML = '<div class="no-data">暂无数据</div>';
|
|
return;
|
|
}
|
|
|
|
table.render({
|
|
elem: '#dome1',
|
|
data: tableData,
|
|
skin: 'line',
|
|
page: false,
|
|
headers:{
|
|
decrypt:"decrypt",
|
|
"Authorization":token
|
|
},
|
|
cols: [[
|
|
{field: 'number', width:'10%',title: '序号', align: 'center', type: 'numbers'},
|
|
{field: 'workType', width:'20%', align: 'center', title: '专业'},
|
|
{field: 'teamName', width:'20%', align: 'center', title: '班组'},
|
|
{field: 'teamLeader', width:'15%', align: 'center', title: '班组负责人'},
|
|
{field: 'totalPeople', width:'15%', align: 'center', title: '班组人数'},
|
|
{field: 'utilizationRate', width:'20%', align: 'center', title: '利用率',
|
|
templet: function(d){
|
|
return d.utilizationRate ? d.utilizationRate + '%' : '0%';
|
|
}
|
|
},
|
|
]],
|
|
initComplete: function () {
|
|
// 在表格渲染完成后,重新渲染序号列
|
|
var that = this.elem.next();
|
|
var tool = that.children('.layui-table-box').children('.layui-table-fixed').children('.layui-table-body').children('.layui-table');
|
|
tool.find("tr").each(function (index, item) {
|
|
$(this).find('td[data-field="LAY_TABLE_INDEX"]').text(index + 1);
|
|
});
|
|
},
|
|
done:function(res, curr, count, origin){
|
|
console.log(res);
|
|
}
|
|
})
|
|
|
|
}
|