let table, layer, form; let myChart = null, myChart2 = null; 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 || []); }); function initTable(data) { table.render({ elem: '#demo2', id: 'demo2', skin: 'line', page: true, height: 'full-120', headers: { "decrypt": "decrypt", "Authorization": token }, data: data, cols: [[ { type: 'numbers', title: '序号', 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%' }, { field: 'completeWorkload', title: '完成工作量', align: 'center', width: '15%', templet: function (d) { return d.completeWorkload + d.completeWorkloadUnit; } }, { field: 'unitTimeOutput', title: '单位时间产量', align: 'center', width: '15%', templet: function (d) { return d.unitTimeOutput + d.unitTimeOutputUnit; } }, { field: 'rateLevel', 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'; } return '
' + d.rateLevel + '
'; } } ]], 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); } }) table.on('rowDouble(demo2)', function (obj) { console.log(obj.data); initEcharts(obj.data); }); } function query(type) { let userName = $('#userName').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); } // 初始化 echarts function initEcharts(data) { if(myChart && myChart2){ myChart.dispose(); myChart2.dispose(); } myChart = echarts.init(document.getElementById("oneEcharts")); myChart2 = echarts.init(document.getElementById("twoEcharts")); initEchartsOne(data); } function initEchartsOne() { let fontSize = '14', fontFamily = 'Alibaba PuHuiTi R', fontColor = '#fff'; const graphicColors = [ ['rgba(7, 209, 250, 1)', 'rgba(7, 209, 250, .2)'], ['rgba(7, 131, 250, 1)', 'rgba(7, 131, 250, .2)'], ['rgba(31, 237, 190, 1)', 'rgba(31, 237, 190, .2)'], ['rgba(255, 209, 92, 1)', 'rgba(255, 209, 92, .2)'], ['rgba(255, 136, 136, 1)', 'rgba(255, 136, 136, .2)'], ['rgba(157, 222, 255, 1)', 'rgba(157, 222, 255, .2)'], ['rgba(94, 255, 108, 1)', 'rgba(94, 255, 108, .2)'], ['rgba(146, 119, 255, 1)', 'rgba(146, 119, 255, .2)'], ['rgba(0, 246, 255, 1)', 'rgba(0, 246, 255, .2)'], ['rgba(255, 162, 77, 1)', 'rgba(255, 162, 77, .2)'], ['rgba(255, 105, 207, 1)', 'rgba(255, 105, 207, .2)'] ] const option = { backgroundColor: "#08244d", tooltip: { trigger: 'axis', axisPointer: { type: 'shadow' }, textStyle: { color: '#fff', fontSize: 12 }, confine: true, // 超出范围 backgroundColor: 'rgba(17,95,182,0.5)', //设置背景颜色 formatter: params => { let str = `