月度报表、计件工资

yangwl
Yangwl 5 months ago
parent 390a40ae15
commit 5465aec2c9

@ -1,5 +1,5 @@
<template> <template>
<div class="app-container"> <div class="app-container">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="98px"> <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="98px">
<el-form-item label="生产时间"> <el-form-item label="生产时间">
<el-date-picker <el-date-picker
@ -13,168 +13,223 @@
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery"></el-button> <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery"></el-button>
</el-form-item> </el-form-item>
</el-form> </el-form>
<!-- <el-row :gutter="10" class="mb8">-->
<!-- <el-col :span="1.5">--> <el-tabs type="border-card" @tab-click="handleTabClick">
<!-- <el-button--> <el-tab-pane label="当月产线产量汇总" >
<!-- type="warning"--> <el-table :data="tableData" border style="width: 100%" :header-cell-style="getHeaderCellStyle" :summary-method="getSummaries" show-summary>
<!-- plain--> <el-table-column prop="equipment_name" label="产线" fixed="left" width="150"></el-table-column>
<!-- icon="el-icon-download"--> <el-table-column prop="category" label="类别" fixed="left" width="150"></el-table-column>
<!-- size="mini"--> <el-table-column prop="total_monthly_summary" label="当月汇总" fixed="left" width="150"></el-table-column>
<!-- @click="handleExport"--> <el-table-column v-for="day in days" :key="day" :prop="day" :label="`${day.replace('day', '')}`" :width="150" align="center" :formatter="formatNullToZero">
<!-- v-hasPermi="['mes:prepare:export']"--> </el-table-column>
<!-- >导出</el-button>--> </el-table>
<!-- </el-col>--> <div id="main" style="width: 100%; height: 820px; background: #fff"></div>
<!-- <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>--> </el-tab-pane>
<!-- </el-row>-->
<el-tab-pane label="当月产线品类汇总" >
<el-table :data="tableDatas" border style="width: 100%" :header-cell-style="getHeaderCellStyle" :summary-method="getSummaries" show-summary>
<el-table :data="tableData" border style="width: 100%"> <el-table-column prop="category" label="类别" fixed="left" width="150"></el-table-column>
<el-table-column <el-table-column prop="total_monthly_summarys" label="当月汇总" fixed="left" width="150"></el-table-column>
prop="equipment_name" <el-table-column v-for="day in days" :key="day" :prop="day" :label="`${day.replace('day', '')}`" :width="150" align="center" :formatter="formatNullToZero">
label="产线" </el-table-column>
fixed="left" </el-table>
width="150"> <div id="mains" style="width: 100%; height: 820px; background: #fff"></div>
</el-table-column> </el-tab-pane>
<el-table-column </el-tabs>
prop="category" </div>
label="类别"
fixed="left"
width="150">
</el-table-column>
<el-table-column
prop="total_monthly_summary"
label="当月汇总"
fixed="left"
width="150">
</el-table-column>
<el-table-column
v-for="day in days"
:key="day"
:prop="day"
:label="`${day.replace('day', '')}`"
:width="150"
align="center"
:formatter="formatNullToZero">
</el-table-column>
</el-table>
<div id="main" style="width: 100%; height: 820px; background: #fff"></div>
</div>
</template> </template>
<script> <script>
import { getmonthProductionSut} from "@/api/mes/reportWork"; import { getmonthProductionSut } from "@/api/mes/reportWork";
import * as echarts from 'echarts' import * as echarts from 'echarts';
export default { export default {
name: "Index", name: "Index",
data() { data() {
return { return {
//
loading: true, loading: true,
//
ids: [],
//
single: true,
//
multiple: true,
//
showSearch: true, showSearch: true,
//
total: 0,
//
//
tableData: [], tableData: [],
tableDatas: [],
days: [], days: [],
//
title: "",
//
open: false,
//
queryParams: { queryParams: {
pageNum: 1, pageNum: 1,
pageSize: 10, pageSize: 10,
monthValue:'' monthValue: ''
}, },
// charts: null,
form: {}, chartss: null,
// legendData: [],
rules: { seriesData: [],
monthValue: [ legendDatas: [],
{ required: true, message: '生产时间不能为空', trigger: 'change' } seriesDatas: []
]
},
charts: "",
legendData:[],
seriesData:[]
}; };
}, },
created() { created() {
},
mounted() {
// Set current month initially
const currentMonth = new Date().toISOString().substr(0, 7); const currentMonth = new Date().toISOString().substr(0, 7);
this.queryParams.monthValue = currentMonth; this.queryParams.monthValue = currentMonth;
this.getList(); this.getList();
}, },
methods: { methods: {
indexMethod(index) { pad(number) {
return index + 1; return number.toString().padStart(2, '0');
},
getHeaderCellStyle({rowIndex, columnIndex}) {
if (rowIndex === 0 && columnIndex === 0) {
return 'background-color: #afccfd; color: #000000;'; //
} else if (rowIndex === 0 && columnIndex === 1) {
return 'background-color: #c0e33c; color: #000000;'; // 绿
} else if (rowIndex === 0 && columnIndex === 2) {
return 'background-color: #fbc57b; color: #000000;'; //
} else {
return 'color: #000000; background: #ffffff;';
}
},
getSummaries(param) {
const {columns, data} = param;
const sums = [];
columns.forEach((column, index) => {
if (index === 0) {
sums[index] = '合计';
return;
}
const values = data.map(item => Number(item[column.property]));
if (!values.every(value => isNaN(value))) {
sums[index] = values.reduce((prev, curr) => {
const value = Number(curr);
if (!isNaN(value)) {
return prev + curr;
} else {
return prev;
}
}, 0);
sums[index] += '';
if (sums[index] > 1000000) {
sums[index] = '';
}
} else {
sums[index] = '';
}
});
return sums;
},
async handleTabClick(tab,event){
// if (tab.index==1){
await this.$nextTick();
this.drawLine("main")
this.drawLine_two("mains")
// }
}, },
/** 查询备料单列表 */
getList() { getList() {
this.seriesData=[]; this.seriesData = [];
this.legendData=[]; this.legendData = [];
this.seriesDatas = [];
this.legendDatas = [];
this.charts = null;
this.loading = true; this.loading = true;
const [year, month] = this.queryParams.monthValue.split('-').map(Number);
const daysInMonth = new Date(year, month, 0).getDate();
this.days = [];
for (let day = 1; day <= daysInMonth; day++) {
const formattedDate = `${year}-${this.pad(month)}-${this.pad(day)}`;
this.days.push(formattedDate);
}
getmonthProductionSut(this.queryParams).then(response => { getmonthProductionSut(this.queryParams).then(response => {
// this.prepareList = response.rows; const data = response.data.mapList_one || [];
const data = response.data; const datas = response.data.mapList_two || [];
// this.total = response.total;
this.loading = false; this.loading = false;
// Process data for mapList_one
if (data.length > 0) { if (data.length > 0) {
//
const allKeys = Object.keys(data[0]);
// 使
this.days = allKeys.filter(key => /^\d{4}-\d{2}-\d{2}$/.test(key)).sort();
// 'total_monthly_summary'
data.forEach(row => { data.forEach(row => {
let totalSummary = 0; let totalSummary = 0;
const dailyValues = []; // const dailyValues = [];
this.days.forEach(day => { this.days.forEach(day => {
const value = row[day] || 0; const value = row[day] || 0;
totalSummary += value; totalSummary += value;
dailyValues.push(value); // dailyValues dailyValues.push(value);
totalSummary += (row[day] || 0);
}); });
row.total_monthly_summary = totalSummary; row.total_monthly_summary = totalSummary;
this.legendData.push(row.equipment_name); this.legendData.push(row.equipment_name);
this.seriesData.push({ this.seriesData.push({
name: row.equipment_name, // 使 name: row.equipment_name,
type: 'line', type: 'line',
stack: 'Total', stack: 'Total',
data: dailyValues, data: dailyValues,
itemStyle: { itemStyle: {
color: this.getRandomColor(), // color: this.getRandomColor(),
lineStyle: { lineStyle: {
color: this.getRandomColor(), color: this.getRandomColor(),
}, },
}, },
}); });
}); });
} else {
// No data for mapList_one
this.legendData.push('无数据');
this.seriesData.push({
name: '无数据',
type: 'line',
data: [],
itemStyle: {
color: '#CCCCCC',
lineStyle: {
color: '#CCCCCC',
},
},
});
} }
if (datas.length > 0) {
datas.forEach(row => {
let totalSummary = 0;
const dailyValues = [];
this.days.forEach(day => {
const value = row[day] || 0;
totalSummary += value;
dailyValues.push(value);
});
row.total_monthly_summarys = totalSummary;
this.legendDatas.push(row.category);
this.seriesDatas.push({
name: row.category,
type: 'line',
stack: 'Total',
data: dailyValues,
itemStyle: {
color: this.getRandomColor(),
lineStyle: {
color: this.getRandomColor(),
},
},
});
});
}
this.tableData = data; this.tableData = data;
// 线 this.tableDatas = datas;
this.drawLine("main");
}).catch(() => { // 线
this.drawLine("main");
this.drawLine_two("mains");
}).catch(error => {
this.loading = false; this.loading = false;
console.error("Error fetching data:", error);
}); });
}, },
formatNullToZero(row, column, cellValue) { formatNullToZero(row, column, cellValue) {
return cellValue === null || cellValue === undefined ? 0 : cellValue; return cellValue === null || cellValue === undefined ? 0 : cellValue;
}, },
getRandomColor() { getRandomColor() {
const letters = '0123456789ABCDEF'; const letters = '0123456789ABCDEF';
let color = '#'; let color = '#';
@ -183,37 +238,11 @@ export default {
} }
return color; return color;
}, },
//
cancel() {
this.open = false;
this.reset();
},
//
reset() {
this.form = {};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1
this.getList()
},
/** 导出按钮操作 */
handleExport() {
this.download('mes/reportWork/getDailyReportExport', {
...this.queryParams
}, `dailyReport${new Date().getTime()}.xlsx`)
},
drawLine(id) { drawLine(id) {
// 线
this.charts = echarts.init(document.getElementById(id)); this.charts = echarts.init(document.getElementById(id));
this.charts.clear()
const options = {
// 线
this.charts.setOption({
title: { title: {
text: '产量趋势' text: '产量趋势'
}, },
@ -242,9 +271,68 @@ export default {
yAxis: { yAxis: {
type: 'value', type: 'value',
}, },
series: this.seriesData series: this.seriesData || [] // Use empty array if seriesData is falsy
};
this.charts.setOption(options);
},
drawLine_two(id) {
if (this.chartss){
this.chartss.dispose()
}
this.chartss = echarts.init(document.getElementById(id));
this.chartss.clear()
this.chartss.setOption({
title: {
text: '产量趋势'
},
tooltip: {
trigger: 'axis'
},
legend: {
data: this.legendDatas
},
grid: {
left: '3%',
right: '4%',
bottom: '3%',
containLabel: true
},
toolbox: {
feature: {
saveAsImage: {}
}
},
xAxis: {
type: 'category',
boundaryGap: false,
data: this.days
},
yAxis: {
type: 'value',
},
series: this.seriesDatas
}); });
}, },
cancel() {
this.reset();
},
reset() {
this.queryParams.monthValue = '';
this.getList();
},
handleQuery() {
this.getList();
}
} }
}; };
</script> </script>
<style scoped>
.app-container {
padding: 20px;
}
</style>

@ -42,7 +42,25 @@
@keyup.enter.native="handleQuery" @keyup.enter.native="handleQuery"
/> />
</el-form-item> </el-form-item>
<el-form-item label="员工姓名" prop="nickName">
<el-input
v-model="queryParams.equipmentName"
placeholder="请输入员工姓名"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="创建时间">
<el-date-picker
v-model="dateRange"
style="width: 240px"
value-format="yyyy-MM-dd"
type="daterange"
range-separator="-"
start-placeholder="开始日期"
end-placeholder="结束日期"
></el-date-picker>
</el-form-item>
<el-form-item> <el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery"></el-button> <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery"></el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery"></el-button> <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"></el-button>
@ -77,40 +95,43 @@
<el-table-column label="操作者" width="110" align="center" prop="nickName" /> <el-table-column label="操作者" width="110" align="center" prop="nickName" />
<el-table-column label="子工序名称" width="110" align="center" prop="childprocessName" /> <el-table-column label="子工序名称" width="110" align="center" prop="childprocessName" />
<el-table-column label="工序单价" width="110" align="center" prop="attr1" /> <el-table-column label="工序单价" width="110" align="center" prop="attr1" />
<el-table-column label="工时" width="110" align="center" prop="attr2" />
<el-table-column label="工时工资" width="100" align="center" prop="realWages" />
<el-table-column label="件数PC" width="100" align="center" prop="totalQuantity" /> <el-table-column label="件数PC" width="100" align="center" prop="totalQuantity" />
<el-table-column label="薪酬(元)" width="110" align="center" prop="result" /> <el-table-column label="薪酬(元)" width="110" align="center" prop="result" />
<el-table-column label="人数" align="center" prop="headCount" /> <el-table-column label="创建时间" width="110" align="center" prop="createTime" />
<!-- <el-table-column label="平均工资(元)" width="110" align="center" prop="avgResult" />--> <!-- <el-table-column label="人数" align="center" prop="headCount" />-->
<el-table-column label="实际工资(元)" width="110" align="center" prop="realWages" /> <!--&lt;!&ndash; <el-table-column label="平均工资(元)" width="110" align="center" prop="avgResult" />&ndash;&gt;-->
<el-table-column label="备注" align="center" prop="remark"> <!-- <el-table-column label="实际工资(元)" width="110" align="center" prop="realWages" />-->
<template slot-scope="scope"> <!-- <el-table-column label="备注" align="center" prop="remark">-->
<dict-tag :options="dict.type.unit_price" :value="scope.row.remark"/>
</template>
</el-table-column>
<!-- <el-table-column label="实际工资" align="center" prop="realWages">-->
<!-- <template slot-scope="scope">--> <!-- <template slot-scope="scope">-->
<!-- <el-input type="text" size="small" v-model="scope.row.realWages" @change="handleEdit(scope.$index,scope.row)"></el-input>--> <!-- <dict-tag :options="dict.type.unit_price" :value="scope.row.remark"/>-->
<!-- </template>--> <!-- </template>-->
<!-- </el-table-column>--> <!-- </el-table-column>-->
<!-- <el-table-column label="实际工资" align="center" prop="realWages" />--> <!--&lt;!&ndash; <el-table-column label="实际工资" align="center" prop="realWages">&ndash;&gt;-->
<el-table-column fixed="right" label="操作" align="center" class-name="small-padding fixed-width"> <!--&lt;!&ndash; <template slot-scope="scope">&ndash;&gt;-->
<template slot-scope="scope"> <!--&lt;!&ndash; <el-input type="text" size="small" v-model="scope.row.realWages" @change="handleEdit(scope.$index,scope.row)"></el-input>&ndash;&gt;-->
<el-button <!--&lt;!&ndash; </template>&ndash;&gt;-->
size="mini" <!--&lt;!&ndash; </el-table-column>&ndash;&gt;-->
type="text" <!--&lt;!&ndash; <el-table-column label="实际工资" align="center" prop="realWages" />&ndash;&gt;-->
icon="el-icon-edit"p <!-- <el-table-column fixed="right" label="操作" align="center" class-name="small-padding fixed-width">-->
@click="handleUpdate(scope.row)" <!-- <template slot-scope="scope">-->
v-hasPermi="['unitPriceReport:report:edit']"
>工资修改</el-button>
<!-- <el-button--> <!-- <el-button-->
<!-- size="mini"--> <!-- size="mini"-->
<!-- type="text"--> <!-- type="text"-->
<!-- icon="el-icon-delete"--> <!-- icon="el-icon-edit"p-->
<!-- @click="handleDelete(scope.row)"--> <!-- @click="handleUpdate(scope.row)"-->
<!-- v-hasPermi="['system:unitPrice:remove']"--> <!-- v-hasPermi="['unitPriceReport:report:edit']"-->
<!-- >删除</el-button>--> <!-- >工资修改</el-button>-->
</template> <!--&lt;!&ndash; <el-button&ndash;&gt;-->
</el-table-column> <!--&lt;!&ndash; size="mini"&ndash;&gt;-->
<!--&lt;!&ndash; type="text"&ndash;&gt;-->
<!--&lt;!&ndash; icon="el-icon-delete"&ndash;&gt;-->
<!--&lt;!&ndash; @click="handleDelete(scope.row)"&ndash;&gt;-->
<!--&lt;!&ndash; v-hasPermi="['system:unitPrice:remove']"&ndash;&gt;-->
<!--&lt;!&ndash; >删除</el-button>&ndash;&gt;-->
<!-- </template>-->
<!-- </el-table-column>-->
</el-table> </el-table>
@ -217,6 +238,8 @@ export default {
// //
open: false, open: false,
value: '', value: '',
//
dateRange: [],
// //
queryParams: { queryParams: {
pageNum: 1, pageNum: 1,
@ -262,7 +285,7 @@ export default {
/** 查询unitPrice列表 */ /** 查询unitPrice列表 */
getList() { getList() {
this.loading = true; this.loading = true;
listUnitPriceReport(this.queryParams).then(response => { listUnitPriceReport(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
this.unitPriceList = response.rows; this.unitPriceList = response.rows;
this.total = response.total; this.total = response.total;
this.loading = false; this.loading = false;
@ -328,11 +351,6 @@ export default {
getReport(picId).then(response => { getReport(picId).then(response => {
this.form = response.data.MesUnitpriceReport; this.form = response.data.MesUnitpriceReport;
this.open = true; this.open = true;
if (response.data.attr2 === null || response.data.attr2 === undefined) {
this.form.attr2 = row.result;
} else {
this.form.attr2 = response.data.attr2;
}
this.MesUnitPriceInfo=response.data.MesUnitPriceInfo; this.MesUnitPriceInfo=response.data.MesUnitPriceInfo;
}); });
}, },

Loading…
Cancel
Save