fix:统计导出

This commit is contained in:
shijing 2025-05-13 08:59:32 +08:00
parent 2d0e779ce4
commit 84a6f8c41b
2 changed files with 212 additions and 54 deletions

View File

@ -3634,17 +3634,6 @@ const routes = [
},
component: "statistics/check_record_gx.vue",
},
//扫边车间数据汇总——光芯
// {
// path: "/statistics_saobian",
// name: "statistics_saobian",
// meta: {
// title: "扫边车间统计",
// icon: "el-icon-trend-charts",
// perms: ["statistic_inm"],
// },
// component: "statistics/statistics_saobian.vue",
// },
//综合查询
{
name: "total_statistics",
@ -3678,50 +3667,18 @@ const routes = [
},
component: "statistics/statistics_guan.vue",
},
//综合统计--AVG
//综合统计导出
{
name: "total_export",
path: "/statistic/total_export",
meta: {
title: "统计导出",
icon: "el-icon-DataAnalysis",
perms: ["statistic_total"],
},
component: "statistics/all.vue",
},
],
// children:[
// {
// "path": "/product_statistics",
// "name": "product_statistics",
// "meta": {
// "title": "生产统计",
// "icon": "el-icon-trend-charts",
// "perms": ["bigScreenP"],
// },
// "component": "statistics/product_statistics.vue"
// },
// {
// "path": "/quality_statistics",
// "name": "quality_statistics",
// "meta": {
// "title": "质量统计",
// "icon": "el-icon-trend-charts",
// "perms": ["bigScreenP"],
// },
// "component": "statistics/quality_statistics.vue"
// },
// {
// "path": "/sale_statistics",
// "name": "sale_statistics",
// "meta": {
// "title": "销售统计",
// "icon": "el-icon-trend-charts",
// "perms": ["bigScreenP"],
// },
// "component": "statistics/sale_statistics.vue"
// },
// {
// "path": "/material_statistics",
// "name": "material_statistics",
// "meta": {
// "title": "物料统计",
// "icon": "el-icon-trend-charts",
// "perms": ["bigScreenP"],
// },
// "component": "statistics/material_statistics.vue"
// },
// ],
},
//报表
{

View File

@ -0,0 +1,201 @@
<!-- 最新版生产执行页面 -->
<template>
<el-container>
<el-header>
<div class="right-panel">
<el-date-picker v-model="queryDate" type="month" placeholder="查询月份"
value-format="YYYY-MM" style="width:200px">
</el-date-picker>
<el-button type="primary" icon="el-icon-search" @click="handleQuery"></el-button>
</div>
</el-header>
<el-main id="elMain" class="nopadding" style="width: 1024px;">
<div id="bachart1" style="width:100%;height:300px;"></div>
<el-table :data="dataList" id="exportDiv1">
<el-table-column type="index" width="50" />
<el-table-column label="物料名" prop="物料名">
</el-table-column>
<el-table-column label="月份" prop="月" v-if="queryType == '年'">
</el-table-column>
<el-table-column label="周" prop="周" v-else>
</el-table-column>
<el-table-column label="规格" prop="规格">
</el-table-column>
<el-table-column label="型号" prop="型号">
</el-table-column>
<el-table-column label="桶数" prop="合格数">
</el-table-column>
<el-table-column label="总重量" prop="总重量">
</el-table-column>
</el-table>
</el-main>
</el-container>
</template>
<script>
import * as echarts from "echarts";
import T from '@/components/scEcharts/echarts-theme-T.js';
echarts.registerTheme('T', T);
function deepCopy(obj) {
return JSON.parse(JSON.stringify(obj));
}
export default {
name: "bx",
data() {
return {
queryDate: '',
mgroups:[],
dataList: [],
xAxisData:[],
xAxisOrigin:[],
firstWeekNum: 1,
endWeekNum: 4,
basicOption: {
backgroundColor: 'transparent',
title: {
text: '',
},
grid: {
top: '80px'
},
tooltip: {
trigger: 'axis'
},
xAxis: {
type: 'category',
data: []
},
yAxis: {
type: 'value'
},
lenged: [],
series: [{
data: [0, 0, 0, 0, 0, 0, 0],
stack: 'Ad',
type: 'bar',
barWidth: '15px',
}]
},
};
},
mounted() {
let that = this;
let date = new Date();
let year = date.getFullYear();
let month = date.getMonth() + 1;
let days = new Date(year, month, 0).getDate();
that.currentYear = year;
that.currentMonth = month;
that.firstWeekNum = that.getWeekOfYear(year,month,1);
that.endWeekNum = that.getWeekOfYear(year,month,days);
month = month < 10 ? '0' + month : month;
that.start_date = year + '-' + month + '-01';
that.end_date = year + '-' + month + '-' + days;
that.queryDate = year + '-' + month;
let duration = that.endWeekNum - that.firstWeekNum + 1;
for (let i = 1; i <= duration; i++) {
that.xAxisOrigin.push('第' + i + '周');
}
that.xAxisData = that.xAxisOrigin;
that.getDataHL();//
},
methods: {
getWeekOfYear(a,b,c) {
var date1 = new Date(a, parseInt(b) - 1, c), //  
date2 = new Date(a, 0, 1), //  
// d  
d = Math.round((date1.valueOf() - date2.valueOf()) / 86400000);
// d + 7  
return Math.ceil((d + (date2.getDay() + 1 - 1)) / 7);
},
setChart(name, option = null) {
// name , optionoption
var myChart = echarts.getInstanceByDom(document.getElementById(name));
if (myChart == undefined) {
myChart = echarts.init(document.getElementById(name), 'T');
}
if (option == null) {
option = Object.assign({}, this.basicOption)
}
setTimeout(() => {
try {
myChart.setOption(option);
} catch (error) { }
}, 500)
},
handleQuery() {
if (that.queryDate !== '' && that.queryDate !== null) {
let arr = that.queryDate.split('-');
let year = arr[0];
let month = arr[1];
let days = new Date(year, month, 0).getDate();
that.start_date = that.queryDate + '-01';
that.end_date = that.queryDate + '-' + days;
that.firstWeekNum = that.getWeekOfYear(year,month,1);
that.endWeekNum = that.getWeekOfYear(year,month,days);
let duration = that.endWeekNum - that.firstWeekNum + 1;
let xAxisData = [];
for (let i = 1; i <= duration; i++) {
xAxisData.push('第' + i + '周');
}
that.xAxisData = xAxisData;
} else {
that.start_date = that.currentYear + '-' + that.currentMonth + '-01';
that.end_date = that.currentYear + '-' + that.currentMonth + '-' + new Date(that.currentYear, that.currentMonth, 0).getDate();
that.firstWeekNum = that.getWeekOfYear(that.currentYear,that.currentMonth,1);
that.xAxisData = that.xAxisOrigin;
}
},
getMgroups(code){
let that = this;
that.$API.mtm.mgroup.list.req({page:0,code}).then((res) => {
that.mgroups = res;
that.componentsShow = true;
});
},
getDataHL() {
let that = this;
let obj = {
query: { start_date: that.start_date, end_date: that.end_date, mgroup_name: "混料", is_count_utask: -1 },
};
let option = deepCopy(that.basicOption);
option.xAxis.data = that.xAxisData;
option.title.text = '混料统计';
that.$API.bi.dataset.exec.req('lineWeek', obj).then((res) => {
let dataList = res.data2.ds0 ? res.data2.ds0 : [];
that.dataList = dataList;
if (dataList.length > 0) {
option.series = [];
let seriesData = [], nameList = [];
dataList.forEach(ite => {
if (nameList.indexOf(ite.物料名) > -1) { } else {
nameList.push(ite.物料名);
seriesData.push([0,0,0,0,0,0,0,0,0,0,0,0])
}
})
dataList.forEach(item => {
let indexX = 0, indexY = 0;
indexX = nameList.indexOf(item.物料名);
indexY = item. - that.firstWeekNum;
seriesData[indexX][indexY] += item.合格数;
});
for (let n = 0; n < seriesData.length; n++) {
let obj = {};
obj.name = nameList[n];
obj.stack = 'Ad';
obj.type = 'bar';
obj.barWidth = '15px';
obj.data = seriesData[n];
option.series.push(obj)
}
that.setChart("bachart1", option);
} else {
that.setChart("bachart1", option);
}
});
},
},
};
</script>
<style scoped>
</style>