hb_zhgd_screen/js/pages/dataAnalysisOctober/resourceRateAnalysis.js

336 lines
10 KiB
JavaScript
Raw Normal View History

2025-10-16 15:26:20 +08:00
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;
2025-10-18 15:55:58 +08:00
// getTrend();
//
// wearGarList()
2025-10-16 15:26:20 +08:00
2025-10-18 15:55:58 +08:00
getDeviceEcharts();
2025-10-16 15:26:20 +08:00
});
2025-10-18 15:55:58 +08:00
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; //设备利用率
2025-10-18 17:19:35 +08:00
document.getElementById("deviceUtilization").innerHTML = deviceUtilization +'<span>%</span>';
2025-10-18 15:55:58 +08:00
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; //人员利用率
2025-10-18 17:19:35 +08:00
document.getElementById("workerUtilization").innerHTML = workerUtilization +'<span>%</span>';
2025-10-18 15:55:58 +08:00
let yesterdayDutyRate = data.yesterdayDutyRate; //昨日到岗率
document.getElementById("yesterdayDutyRate").innerHTML = yesterdayDutyRate +'<span>%</span>';
}
}
}
2025-10-16 15:26:20 +08:00
2025-10-18 15:55:58 +08:00
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)
2025-10-16 15:26:20 +08:00
}
2025-10-18 15:55:58 +08:00
function initTrend(date,actualCount,shouldCount) {
2025-10-16 15:26:20 +08:00
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,
},
2025-10-18 15:55:58 +08:00
data: date,
2025-10-16 15:26:20 +08:00
},
],
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,
},
}],
2025-10-18 17:19:35 +08:00
"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
}],
2025-10-16 15:26:20 +08:00
series: [{
2025-10-18 15:55:58 +08:00
name: '实到',
2025-10-16 15:26:20 +08:00
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
}
},
2025-10-18 15:55:58 +08:00
data: actualCount
2025-10-16 15:26:20 +08:00
}, {
2025-10-18 15:55:58 +08:00
name: '应到',
2025-10-16 15:26:20 +08:00
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
}
},
2025-10-18 15:55:58 +08:00
data: shouldCount
2025-10-16 15:26:20 +08:00
}]
};
leftChart.setOption(option);
// 响应式调整
window.addEventListener("resize", function () {
leftChart.resize();
});
}
2025-10-18 15:55:58 +08:00
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;
}
2025-10-16 15:26:20 +08:00
table.render({
elem: '#dome1',
2025-10-18 15:55:58 +08:00
data: tableData,
2025-10-16 15:26:20 +08:00
skin: 'line',
page: false,
headers:{
decrypt:"decrypt",
"Authorization":token
},
cols: [[
{field: 'number', width:'10%',title: '序号', align: 'center', type: 'numbers'},
2025-10-18 15:55:58 +08:00
{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%';
}
},
2025-10-16 15:26:20 +08:00
]],
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);
}
})
}