123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673 |
- <template>
- <div class="app-container">
- <el-form :model="queryParams" ref="queryRef" :inline="true" label-width="68px" style="background: #ededed;">
- <el-form-item label="时间" prop="empDate" style="margin-top: 18px;">
- <el-date-picker clearable
- v-model="queryParams.empDate"
- type="month"
- value-format="YYYY-MM"
- placeholder="请选择月份">
- </el-date-picker>
- </el-form-item>
- <el-form-item style="margin-top: 18px;">
- <el-button type="primary" icon="Search" @click="handleQuery">统计</el-button>
- </el-form-item>
- </el-form>
- <div style="display: flex;">
- <div style="width: 33.3%;">
- <div class="caption">金额-月趋势统计曲线</div>
- <div ref="price_echarts_line" class="echarts_area"></div>
- <div class="caption">稼动率-月趋势统计曲线</div>
- <div ref="efficiency_echarts_line" class="echarts_area"></div>
- <div class="caption">产出米数-月趋势统计曲线</div>
- <div ref="lenght_echarts_line" class="echarts_area"></div>
- </div>
- <div style="width: 33%;margin-left: 0.3%;height: 700px;">
- <div class="caption">四分位分析</div>
- <div ref="echarts41" class="echarts_4"></div>
- <div ref="echarts42" class="echarts_4"></div>
- <div ref="echarts43" class="echarts_4"></div>
- </div>
- <div style="width: 33%;margin-left: 0.3%;">
- <div class="caption">员工排名</div>
-
- <el-table :data="empToplist" height="680px">
- <el-table-column prop="empName" align="center" label="姓名"/>
- <el-table-column prop="totalPrice" align="center" label="金额"/>
- <el-table-column prop="length" align="center" label="米数"/>
- <el-table-column prop="efficiency" align="center" label="平均嫁动">
- <template #default="scope">
- {{ scope.row.efficiency*100 }} %
- </template>
- </el-table-column>
- </el-table>
- </div>
- </div>
- </div>
- </template>
- <style>
- .caption{
- width: 100%;
- margin-left: 0px;
- margin-top: 10px;
- margin-bottom: 10px;
- height: 30px;
- line-height: 30px;
- font-weight: bold;
- color: #666;
- border-left: 3px solid #8282bd;
- padding-left: 5px;
- }
- .echarts_area{
- width: 100%;height: 200px;padding: 15px;
- border: 1px solid #ededed;
- border-radius: 4px;
- background-color: #f3f0f078;
- }
- .echarts_4{
- width: 100%;
- height: 33%;
- padding: 15px;
- border: 1px solid #ededed;
- border-radius: 4px;
- background-color: #f3f0f078;
- }
- </style>
- <script setup name="Emp">
- import {ref,reactive} from "vue";
- import { ElMessage } from 'element-plus';
- import {monthCalc} from "@/api/emp/empCalc";
- import * as echarts from 'echarts';
- let queryParams=reactive({empDate:''});
- const price_echarts_line=ref(null);
- const efficiency_echarts_line=ref(null);
- const lenght_echarts_line=ref(null);
- const echarts41 = ref(null);
- const echarts42 = ref(null);
- const echarts43 = ref(null);
- let empToplist =ref([]);
- function init(){
- queryParams.empDate=new Date().Format('yyyy-MM');
- getData();
- }
- /** 搜索按钮操作 */
- function handleQuery() {
- getData();
- }
- function getData(){
- if(queryParams.empDate==null || queryParams.empDate==''){
- let msg = ElMessage({
- message: "请选择月份!",
- type: "error",
- })
- return;
- }
- let msg = ElMessage({
- message: "正在查询数据中...",
- type: "info",
- duration:0,
- })
- console.log('queryParams.value.empDate:',queryParams.empDate)
- monthCalc(queryParams.empDate).then((res)=>{
- msg.close();
- if(res.code!=200){
- ElMessage({
- message: "数据查询失败!",
- type: "error"
- })
- return;
- }
- let tmpLst = [];
-
- for(let i=0;i<res.data.emp.length;i++){
- var x = res.data.emp[i];
- var tmpItem=x;
- for(let k in x){
- if(k=='empName') tmpItem[k] = x[k];
- else tmpItem[k] = (x[k]*1).toFixed(2);
- }
- tmpLst.push(tmpItem);
- }
- empToplist.value = tmpLst;
- loadLine(res.data.trend);
- load4(res.data.trend);
- }).catch(()=>{
- msg.close();
- ElMessage({
- message: "数据查询时发生错误!",
- type: "error"
- })
- })
- }
- function loadLine(data){
- var v_series = [];
- var v_series_efficiency = [];
- var v_series_length = [];
- var times = [];
- //总计曲线
- var price=[];
- var efficiency=[];
- var length=[];
- var priceA=[];
- var efficiencyA=[];
- var lengthA=[];
- var priceB=[];
- var efficiencyB=[];
- var lengthB=[];
- for (var i = 0; i < data.length; i++) {
- var tv = data[i]['empDate'].split("-")
- times.push(tv[1] + "-" + tv[2])
- price.push(data[i]['totalPrice']);
- efficiency.push(data[i]['efficiency']);
- length.push(data[i]['length']);
- priceA.push(data[i]['totalPriceA']);
- efficiencyA.push(data[i]['efficiencyA']);
- lengthA.push(data[i]['lengthA']);
- priceB.push(data[i]['totalPriceB']);
- efficiencyB.push(data[i]['efficiencyB']);
- lengthB.push(data[i]['lengthB']);
- }
- v_series.push({name: "总金额",type: 'line',smooth: true,
- //symbol: 'none',
- data: price,
- itemStyle: {
- normal: {
- color: 'red', // 这里设置折线的颜色
- lineStyle: {
- color: 'red' // 这里同时设置线头的颜色
- }
- }
- }});
- v_series.push({name: "A班金额",type: 'line',smooth: true,
- //symbol: 'none',
- data: priceA,
- itemStyle: {
- normal: {
- color: 'black', // 这里设置折线的颜色
- lineStyle: {
- color: 'black' // 这里同时设置线头的颜色
- }
- }
- }});
- v_series.push({name: "B班金额",type: 'line',smooth: true,
- //symbol: 'none',
- data: priceB,
- itemStyle: {
- normal: {
- color: 'blue', // 这里设置折线的颜色
- lineStyle: {
- color: 'blue' // 这里同时设置线头的颜色
- }
- }
- }
- });
- v_series_efficiency.push(
- {name: "总稼动率",type: 'line',smooth: true,
- //symbol: 'none',
- data: efficiency,
- itemStyle: {
- normal: {
- color: 'red', // 这里设置折线的颜色
- lineStyle: {
- color: 'red' // 这里同时设置线头的颜色
- }
- }
- }}
- );
- v_series_efficiency.push(
- {name: "A班稼动率",type: 'line',smooth: true,
- //symbol: 'none',
- data: efficiencyA,
- itemStyle: {
- normal: {
- color: 'black', // 这里设置折线的颜色
- lineStyle: {
- color: 'black' // 这里同时设置线头的颜色
- }
- }
- }}
- );
- v_series_efficiency.push(
- {name: "B班稼动率",type: 'line',smooth: true,
- //symbol: 'none',
- data: efficiencyB,
- itemStyle: {
- normal: {
- color: 'blue', // 这里设置折线的颜色
- lineStyle: {
- color: 'blue' // 这里同时设置线头的颜色
- }
- }
- }}
- );
- v_series_length.push(
- {name: "总产出米数",type: 'line',smooth: true,
- //symbol: 'none',
- data: length,
- itemStyle: {
- normal: {
- color: 'red', // 这里设置折线的颜色
- lineStyle: {
- color: 'red' // 这里同时设置线头的颜色
- }
- }
- }}
- );
- v_series_length.push(
- {name: "A班产出米数",type: 'line',smooth: true,
- //symbol: 'none',
- data: lengthA,
- itemStyle: {
- normal: {
- color: 'black', // 这里设置折线的颜色
- lineStyle: {
- color: 'black' // 这里同时设置线头的颜色
- }
- }
- }}
- );
- v_series_length.push(
- {name: "B班产出米数",type: 'line',smooth: true,
- //symbol: 'none',
- data: lengthB,
- itemStyle: {
- normal: {
- color: 'blue', // 这里设置折线的颜色
- lineStyle: {
- color: 'blue' // 这里同时设置线头的颜色
- }
- }
- }}
- );
- var opt = {
- title: {
- show: false, //不显示标题
- text: '',
- textStyle: {
- color: "rgb(89, 151, 229)",
- fontWeight: "bold"
- },
- top: "0px",
- left: "30px"
- },
- tooltip: {
- trigger: 'axis',
- formatter: function (params) {
- let xv='';
- let result = '';
- params.forEach(function (item) {
- xv=`${item.name}<br/>`;
- result += ` ${item.marker} ${item.value}<br/>`;
- });
- return xv+result;
- }
- },
- legend: {
- show: true, //不显示图例
- inactiveColor: "#04417A",
- data: ["总金额","A班金额","B班金额"],
- textStyle: {color: "#999",fontSize:16},
- top: "0px"
- },
- grid: {
- left: '1%',
- right: '1%',
- bottom: '2%',
- top: '16%',
- containLabel: true
- },
- xAxis: {
- type: 'category',
- boundaryGap: false,
- axisLabel: {
- rotate: 45,
- color: "#999"
- },
- data: times
- },
- yAxis: {
- type: 'value',
- nameTextStyle: {
- color: "#999"
- },
- axisLabel: {
- color: "#999"
- },
- splitLine: {
- lineStyle: {
- color: "#7DA7CD",
- type: "dashed",
- width: 1
- }
- }
- },
- series: v_series
- };
- var opt_efficiency = {
- title: {
- show: false, //不显示标题
- text: '',
- textStyle: {
- color: "rgb(89, 151, 229)",
- fontWeight: "bold"
- },
- top: "0px",
- left: "30px"
- },
- tooltip: {
- trigger: 'axis',
- formatter: function (params) {
- let xv='';
- let result = '';
- params.forEach(function (item) {
- xv=`${item.name}<br/>`;
- result += ` ${item.marker} ${item.value}<br/>`;
- });
- return xv+result;
- }
- },
- legend: {
- show: true, //不显示图例
- inactiveColor: "#04417A",
- data: ["总稼动率","A班稼动率","B班稼动率"],
- textStyle: {color: "#999",fontSize:16},
- top: "0px"
- },
- grid: {
- left: '1%',
- right: '1%',
- bottom: '2%',
- top: '16%',
- containLabel: true
- },
- xAxis: {
- type: 'category',
- boundaryGap: false,
- axisLabel: {
- rotate: 45,
- color: "#999"
- },
- data: times
- },
- yAxis: {
- type: 'value',
- nameTextStyle: {
- color: "#999"
- },
- axisLabel: {
- color: "#999"
- },
- splitLine: {
- lineStyle: {
- color: "#7DA7CD",
- type: "dashed",
- width: 1
- }
- }
- },
- series: v_series_efficiency
- };
- var opt_length = {
- title: {
- show: false, //不显示标题
- text: '',
- textStyle: {
- color: "rgb(89, 151, 229)",
- fontWeight: "bold"
- },
- top: "0px",
- left: "30px"
- },
- tooltip: {
- trigger: 'axis',
- formatter: function (params) {
- let xv='';
- let result = '';
- params.forEach(function (item) {
- xv=`${item.name}<br/>`;
- result += ` ${item.marker} ${item.value}<br/>`;
- });
- return xv+result;
- }
- },
- legend: {
- show: true, //不显示图例
- inactiveColor: "#04417A",
- data: ["总产出米数","A班产出米数","B班产出米数"],
- textStyle: {color: "#999",fontSize:16},
- top: "0px"
- },
- grid: {
- left: '1%',
- right: '1%',
- bottom: '2%',
- top: '16%',
- containLabel: true
- },
- xAxis: {
- type: 'category',
- boundaryGap: false,
- axisLabel: {
- rotate: 45,
- color: "#999"
- },
- data: times
- },
- yAxis: {
- type: 'value',
- nameTextStyle: {
- color: "#999"
- },
- axisLabel: {
- color: "#999"
- },
- splitLine: {
- lineStyle: {
- color: "#7DA7CD",
- type: "dashed",
- width: 1
- }
- }
- },
- series: v_series_length
- };
- setTimeout(() => {
- var echartsEle = echarts.init(price_echarts_line.value);
- echartsEle.setOption(opt);
- var echartsEle2 = echarts.init(efficiency_echarts_line.value);
- echartsEle2.setOption(opt_efficiency);
- var echartsEle3 = echarts.init(lenght_echarts_line.value);
- echartsEle3.setOption(opt_length);
- },500);
- }
- function load4(data){
- var price=[];
- var efficiency=[];
- var length=[];
- var priceA=[];
- var efficiencyA=[];
- var lengthA=[];
- var priceB=[];
- var efficiencyB=[];
- var lengthB=[];
- for (var i = 0; i < data.length; i++) {
- price.push(data[i]['totalPrice']);
- efficiency.push(data[i]['efficiency']);
- length.push(data[i]['length']);
- priceA.push(data[i]['totalPriceA']);
- efficiencyA.push(data[i]['efficiencyA']);
- lengthA.push(data[i]['lengthA']);
- priceB.push(data[i]['totalPriceB']);
- efficiencyB.push(data[i]['efficiencyB']);
- lengthB.push(data[i]['lengthB']);
- }
- var option = {
- title: {
- show: true, //不显示标题
- text: '金额分析',
- textStyle: {
- color: "#666",
- fontWeight: "bold"
- },
- top: "0px",
- left: "center"
- },
- grid: {
- left: '1%',
- right: '1%',
- bottom: '2%',
- top: '16%',
- containLabel: true
- },
- tooltip: {
- trigger: 'item',
- formatter: function (params) {
- var res = '';
- res += '最 小 值:' + params.data[0].toFixed(2) + '<br/>';
- res += '第一四分位数:' + params.data[1].toFixed(2) + '<br/>';
- res += '中 位 数:' + params.data[2].toFixed(2) + '<br/>';
- res += '第三四分位数:' + params.data[3].toFixed(2) + '<br/>';
- res += '最 大 值:' + params.data[4].toFixed(2);
- return res;
- },
- axisPointer: {
- type: 'shadow'
- }
- },
- xAxis: {
- type: 'category',
- data: ['总金额', 'A班金额', 'B班金额'] // X轴数据,每个项目对应一个箱形图
- },
- yAxis: {},
- series: [
- {
- name: '箱形图',
- type: 'boxplot',
- data: [
- price, // 项目A的数据
- priceA, // 项目B的数据
- priceB, // 项目C的数据
- ]
- }
- ]
- };
- var option2 = {
- title: {
- show: true, //不显示标题
- text: '产出米数分析',
- textStyle: {
- color: "#666",
- fontWeight: "bold"
- },
- top: "0px",
- left: "center"
- },
- grid: {
- left: '1%',
- right: '1%',
- bottom: '2%',
- top: '16%',
- containLabel: true
- },
- tooltip: {
- trigger: 'item',
- formatter: function (params) {
- var res = '';
- res += '最 小 值:' + params.data[0].toFixed(2) + '<br/>';
- res += '第一四分位数:' + params.data[1].toFixed(2) + '<br/>';
- res += '中 位 数:' + params.data[2].toFixed(2) + '<br/>';
- res += '第三四分位数:' + params.data[3].toFixed(2) + '<br/>';
- res += '最 大 值:' + params.data[4].toFixed(2);
- return res;
- },
- axisPointer: {
- type: 'shadow'
- }
- },
- xAxis: {
- type: 'category',
- data: ['总产出', 'A班产出', 'B班产出'] // X轴数据,每个项目对应一个箱形图
- },
- yAxis: {},
- series: [
- {
- name: '箱形图',
- type: 'boxplot',
- data: [
- length, // 项目A的数据
- lengthA, // 项目B的数据
- lengthB, // 项目C的数据
- ]
- }
- ]
- };
- var option3 = {
- title: {
- show: true, //不显示标题
- text: '嫁动率分析',
- textStyle: {
- color: "#666",
- fontWeight: "bold"
- },
- top: "0px",
- left: "center"
- },
- grid: {
- left: '1%',
- right: '1%',
- bottom: '2%',
- top: '16%',
- containLabel: true
- },
- tooltip: {
- trigger: 'item',
- formatter: function (params) {
- var res = '';
- res += '最 小 值:' + params.data[0].toFixed(2) + '<br/>';
- res += '第一四分位数:' + params.data[1].toFixed(2) + '<br/>';
- res += '中 位 数:' + params.data[2].toFixed(2) + '<br/>';
- res += '第三四分位数:' + params.data[3].toFixed(2) + '<br/>';
- res += '最 大 值:' + params.data[4].toFixed(2);
- return res;
- },
- axisPointer: {
- type: 'shadow'
- }
- },
- xAxis: {
- type: 'category',
- data: ['总嫁动率', 'A班嫁动率', 'B班嫁动率'] // X轴数据,每个项目对应一个箱形图
- },
- yAxis: {},
- series: [
- {
- name: '箱形图',
- type: 'boxplot',
- data: [
- efficiency, // 项目A的数据
- efficiencyA, // 项目B的数据
- efficiencyB, // 项目C的数据
- ]
- }
- ]
- };
- setTimeout(() => {
- var echartsEle = echarts.init(echarts41.value);
- echartsEle.setOption(option);
- var echartsEle2 = echarts.init(echarts42.value);
- echartsEle2.setOption(option2);
- var echartsEle3 = echarts.init(echarts43.value);
- echartsEle3.setOption(option3);
- },500);
- }
- init();
- </script>
|