From f5c5d4140cfd32a6c2bdc4f2561223dc2b1b6066 Mon Sep 17 00:00:00 2001 From: cwchen <1048842385@qq.com> Date: Wed, 23 Jul 2025 23:29:52 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B7=A5=E4=BA=BA=E6=95=88=E7=8E=87=E5=88=86?= =?UTF-8?q?=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- css/dataAnalysis/commonStyle.css | 11 +- .../workerEfficiencyAnalysis.js | 165 +++++++++++------- .../workerEfficiencyAnalysis.html | 13 +- 3 files changed, 125 insertions(+), 64 deletions(-) diff --git a/css/dataAnalysis/commonStyle.css b/css/dataAnalysis/commonStyle.css index 0af73d5..5036f2b 100644 --- a/css/dataAnalysis/commonStyle.css +++ b/css/dataAnalysis/commonStyle.css @@ -61,9 +61,16 @@ body { #oneEcharts{ width: 100%; - height: 49%; + height: 45%; } #twoEcharts{ width: 100%; - height: 49%; + height: 45%; +} + +#suggestion{ + width: 100%; + height: 8%; + color: red; + font-size: 16px; } \ No newline at end of file diff --git a/js/pages/newDataAnalysis/workerEfficiencyAnalysis.js b/js/pages/newDataAnalysis/workerEfficiencyAnalysis.js index 265cb2b..2d05800 100644 --- a/js/pages/newDataAnalysis/workerEfficiencyAnalysis.js +++ b/js/pages/newDataAnalysis/workerEfficiencyAnalysis.js @@ -4,19 +4,30 @@ layui.use(['layer', 'table', 'form'], function () { layer = layui.layer; table = layui.table; form = layui.form; - let bidCode = parent.parent.$('#bidPro').val() - let filterList = dataList.filter(item => { - return item.bidCode === bidCode; - }); - initTable(filterList[0].list || []); - initEcharts(filterList[0].list[0]); + // 响应成功后的拦截器 + $.ajaxSetup({ + beforeSend: function (xhr, options) { + var originalSuccess = options.success + options.success = function (data, textStatus, jqXhr) { + data = modifyResponseData(data); + // success(data,textStatus, jqXhr); + originalSuccess.apply(this, arguments) + } + } + }) + initTable(); }); -function initTable(data) { +function initTable() { + let userName = $('#userName').val(); + let teamName = $('#teamName').val(); + let bidCode = parent.parent.$('#bidPro').val() + const url = commonUrl + "screen/largeScreen/workerEfficiency/getList"; table.render({ elem: '#demo2', id: 'demo2', + url: url, skin: 'line', page: true, height: 'full-140', @@ -24,49 +35,56 @@ function initTable(data) { "decrypt": "decrypt", "Authorization": token }, - data: data, + where: { + bidCode: bidCode, + teamName: teamName, + userName: userName, + }, cols: [[ { type: 'numbers', title: '序号', width: '10%' }, // 添加序号列 - { field: 'userName', title: '工人', align: 'center', width: '10%' }, + { field: 'userName', title: '姓名', align: 'center', width: '10%' }, { field: 'teamName', title: '班组', align: 'center', width: '10%' }, { field: 'postName', title: '工种', align: 'center', width: '10%' }, { field: 'attDay', title: '出勤天数', align: 'center', width: '10%' }, { - field: 'workTime', title: '工作时长', align: 'center', width: '10%', - templet: function (d) { - return d.workTime + '小时'; - } + field: 'sgType', title: '施工类型', align: 'center', width: '10%', }, { field: 'completeWorkload', title: '完成工作量', align: 'center', width: '10%', templet: function (d) { - return d.completeWorkload + d.completeWorkloadUnit; + return d.completeWorkload + d.unitTimeOutputUnit; } }, { field: 'unitTimeOutput', title: '单位时间产量', align: 'center', width: '10%', templet: function (d) { - return d.unitTimeOutput + d.unitTimeOutputUnit; + return d.unitTimeOutput + d.unit; } }, { - field: 'unitTimeOutput', title: '单位时间标准产量', align: 'center', width: '10%', + field: 'standardTimeOutput', title: '单位时间标准产量', align: 'center', width: '10%', templet: function (d) { - return d.standardTimeOutput + d.unitTimeOutputUnit; + return d.standardTimeOutput + d.unit; } }, { - field: 'rateLevel', title: '效率评级', align: 'center', width: '10%', + title: '效率评级', align: 'center', width: '10%', templet: function (d) { - let color = ''; - if (d.rateLevel === '高效') { - color = 'green'; - } else if (d.rateLevel === '达标') { - color = 'yellow'; - } else if (d.rateLevel === '低效') { - color = 'red'; + let color = '', title = ''; + let min = parseFloat(d.standardTimeOutput.split('~')[0]) || 0; + let max = parseFloat(d.standardTimeOutput.split('~')[1]) || 0; + let unitTimeOutput = parseFloat(d.unitTimeOutput) || 0; + if (unitTimeOutput > max) { + color = 'green', + title = '高效'; + } else if (unitTimeOutput >= min && unitTimeOutput <= max) { + color = 'yellow', + title = '达标'; + } else if (unitTimeOutput < min) { + color = 'red', + title = '低效'; } - return '
' + d.rateLevel + '
'; + return '' + title + '
'; } } @@ -81,32 +99,31 @@ function initTable(data) { }, done: function (res, curr, count, origin) { // console.log(res); + if (res.data && res.data.length > 0) { + initEcharts(res.data[0]); + } } }) - table.on('rowDouble(demo2)', function (obj) { + table.on('row(demo2)', function (obj) { initEcharts(obj.data); }); } -function query(type) { +function query() { let userName = $('#userName').val(); + let teamName = $('#teamName').val(); let bidCode = parent.parent.$('#bidPro').val() - let filterList = dataList.filter(item => { - return item.bidCode === bidCode; - }); - let list = filterList[0].list || [] - let data = []; - if (userName) { - data = list.filter(item => { - return item.userName.indexOf(userName) > -1; - }); - } else { - data = list; - } - initTable(data); - if (data && data.length > 0) { - initEcharts(data[0]); - } + table.reload("demo2", { + page: { + curr: 1, + }, + where: { + bidCode: bidCode, + teamName: teamName, + userName: userName, + }, + }, + ); } // 初始化 echarts @@ -117,15 +134,27 @@ function initEcharts(data) { } myChart = echarts.init(document.getElementById("oneEcharts")); myChart2 = echarts.init(document.getElementById("twoEcharts")); + $('#suggestion').empty(); initEchartsOne(data); - if (data.unitTimeOutput < data.standardTimeOutput) { + let min = parseFloat(data.standardTimeOutput.split('~')[0]) || 0; + let max = parseFloat(data.standardTimeOutput.split('~')[1]) || 0; + let unitTimeOutput = parseFloat(data.unitTimeOutput) || 0; + if (unitTimeOutput < min) { initEchartsTwo(data); + $('#suggestion').append('建议:定期加强技能培训和考试,并且针对施工工具安排定期检查
'); } } + +function average(a, b) { + return +((a + b) / 2).toFixed(3); // 限制 10 位小数 + } + function initEchartsOne(obj) { + let min = parseFloat(obj.standardTimeOutput.split('~')[0]) || 0; + let max = parseFloat(obj.standardTimeOutput.split('~')[1]) || 0; const data = [obj.unitTimeOutput]; - const data2 = [obj.standardTimeOutput]; + const data2 = [average(min,max)]; const colorArr1 = ["rgba(11, 83, 128)", "rgba(2, 143, 224)", "#2a7fcc"]; const colorArr2 = ["rgb(12, 109, 122)", "rgba(1, 241, 228)", "#5ce1d6"]; var color1 = { @@ -195,19 +224,24 @@ function initEchartsOne(obj) { var str = params[0].name + ":"; params.filter(function (item) { if (item.componentSubType == "bar") { - str += "