生产管理

This commit is contained in:
helloDy
2024-05-22 16:28:47 +08:00
parent 2061384d96
commit fe39f72045
9 changed files with 275 additions and 204 deletions

View File

@@ -1,7 +1,7 @@
<!--
* @Author: zhp
* @Date: 2023-11-06 15:15:30
* @LastEditTime: 2024-05-13 15:43:45
* @LastEditTime: 2024-05-20 18:02:10
* @LastEditors: DY
* @Description:
-->
@@ -111,7 +111,7 @@
<!-- <p class="text">{{ dataForm.productName }}</p> -->
</el-col>
<el-col :span="6">
<p class="title">标准组件人均产量</p>
<p class="title">标准组件平均功率</p>
<!-- <p class="text">{{ dataForm.productName }}</p> -->
</el-col>
</el-row>

View File

@@ -1,7 +1,7 @@
<!--
* @Author: zhp
* @Date: 2024-04-15 10:49:13
* @LastEditTime: 2024-05-16 14:15:46
* @LastEditTime: 2024-05-22 15:25:11
* @LastEditors: DY
* @Description:
-->
@@ -15,7 +15,7 @@
</el-option>
</el-select>
</el-form-item>
<el-form-item v-show="listQuery.date === 0" label="时间范围" prop="reportTime">
<el-form-item v-show="listQuery.date === 0 || listQuery.date === ''" label="时间范围" prop="reportTime">
<el-date-picker size="small" clearable v-model="listQuery.reportTime" type="datetimerange" range-separator="至"
start-placeholder="开始日期" value-format="timestamp" @change="changeDayTime" end-placeholder="结束日期">
</el-date-picker>
@@ -38,11 +38,11 @@
</el-date-picker>
</el-form-item>
<el-form-item v-show="listQuery.date === 3" label="时间范围" prop="reportTime">
<el-date-picker size="small" clearable v-model="listQuery.start" value-format="timestamp" type="year"
<el-date-picker size="small" clearable v-model="listQuery.start" format="yyyy-MM-dd" value-format="timestamp" type="year"
placeholder="开始时间">
</el-date-picker>
~
<el-date-picker size="small" clearable v-model="listQuery.end" value-format="timestamp" type="year" placeholder="结束时间"
<el-date-picker size="small" clearable v-model="listQuery.end" format="yyyy-MM-dd" value-format="timestamp" type="year" placeholder="结束时间"
@change="getYear">
</el-date-picker>
</el-form-item>
@@ -132,7 +132,9 @@ export default {
// reportType: 2,
beginTime: undefined,
endTime:undefined,
reportTime: []
reportTime: [],
start: undefined,
end: undefined
},
detailOrUpdateVisible:false,
date1: undefined,
@@ -283,19 +285,18 @@ export default {
},
],
tableData: [],
xAxis: []
// proLineList: [],
// all: {}
};
},
computed: {
weekNum() {
return Math.round((this.listQuery.reportTime[1] - this.listQuery.reportTime[0]) / (24 * 60 * 60 * 1000 * 7)) + 1
return Math.round((this.listQuery.end - this.listQuery.start) / (24 * 60 * 60 * 1000 * 7)) + 1
},
},
mounted() {
this.getDict()
// this.getCurrentYearFirst()
// this.getDataList()
this.getDataList()
},
methods: {
otherMethods(val) {
@@ -309,25 +310,27 @@ export default {
// },
getYear(e) {
if (this.listQuery.reportTime[1] - this.listQuery.reportTime[0] > 10*365*24*60*60*1000) {
if (this.listQuery.end - this.listQuery.start > 10*365*24*60*60*1000) {
this.$message({
message: '年份起止时间不能超过十年',
type: 'warning'
});
this.listQuery.reportTime = []
this.listQuery.start = undefined
this.listQuery.end = undefined
// console.log();
} else {
this.listQuery.beginTime = this.listQuery.reportTime[0]
this.listQuery.endTime = this.listQuery.reportTime[1]
this.listQuery.beginTime = this.listQuery.start
this.listQuery.endTime = this.listQuery.end
}
// console.log(e);
},
onValueChange(picker, k) { // 选中近k周后触发的操作
// console.log(this.listQuery.reportTime[0], this.listQuery.reportTime[1])
if (this.listQuery.reportTime[0] && this.listQuery.reportTime[1]) {
if (this.listQuery.start && this.listQuery.end) {
console.log(this.listQuery.reportTime)
this.date1 = moment(this.listQuery.reportTime[0].getTime() - 24 * 60 * 60 * 1000).format('YYYY-MM-DD HH:mm:ss')
this.date2 = moment(this.listQuery.reportTime[1].getTime() + 5 * 24 * 60 * 60 * 1000).format('YYYY-MM-DD HH:mm:ss')
this.date1 = moment(this.listQuery.start.getTime() - 24 * 60 * 60 * 1000).format('YYYY-MM-DD HH:mm:ss')
this.date2 = moment(this.listQuery.end.getTime() + 5 * 24 * 60 * 60 * 1000).format('YYYY-MM-DD HH:mm:ss')
const numDays = (new Date(this.date2).getTime() - new Date(this.date1).getTime()) / (24 * 3600 * 1000);
if (numDays > 168) {
console.log(numDays)
@@ -336,8 +339,8 @@ export default {
type: 'warning'
});
} else {
this.listQuery.beginTime = this.listQuery.reportTime[0].getTime() - 24 * 60 * 60 * 1000
this.listQuery.endTime = this.listQuery.reportTime[1].getTime() + 5 * 24 * 60 * 60 * 1000
this.listQuery.beginTime = this.listQuery.start.getTime() - 24 * 60 * 60 * 1000
this.listQuery.endTime = this.listQuery.end.getTime() + 5 * 24 * 60 * 60 * 1000
}
}
},
@@ -377,12 +380,11 @@ export default {
console.log(this.listQuery.reportTime[0])
}
},
async getDict() {
this.$refs.lineChart.initChart()
// async getDict() {
// 产线列表
// const res = await getCorePLList();
// this.proLineList = res.data;
},
// },
// 获取数据列表
multipliedByHundred(str) {
console.log(str);
@@ -411,33 +413,43 @@ export default {
console.log(res)
this.tableData = res.data.records
this.tableData.forEach(item => {
item.tableTime = item?.reportDate?.length > 0 ? item.reportDate[0] + '' + item.reportDate[1] + '' + item.reportDate[2] + '日' : '--'
item.tableTime = item?.reportDate?.length > 0 ? item.reportDate[0] + '-' + item.reportDate[1] + '-' + item.reportDate[2] : '--'
})
this.listQuery.total = res.data.total
this.buildChart(this.tableData)
},
add0(m) {
return m < 10 ? '0' + m : m
buildChart(list) {
const chartList = Object.groupBy(list, (item) => item.tableTime)
this.xAxis = []
this.seriesList = []
for (const keyIndex in chartList) {
// X坐标轴数据
this.xAxis.push(keyIndex)
}
// y轴数据
for (const y of this.factoryList) {
// y: {name: , id: }
const seriesItem = {
name: y.name,
type: 'bar',
emphasis: {
focus: 'series'
},
data: Array(this.xAxis.length).fill(0)
}
for (const a in chartList) {
for (const z of chartList[a]) {
this.xAxis.forEach((item, index) => {
if (z.factory === y.id && a === item) {
seriesItem.data[index] = z.goodNumber
}
})
}
}
this.seriesList.push(seriesItem)
}
this.$refs.lineChart.initChart(this.xAxis, this.seriesList)
},
format(shijianchuo) {
//shijianchuo是整数否则要parseInt转换
var time = moment(new Date(shijianchuo)).format('YYYY-MM-DD HH:mm:ss')
// console.log(time)
// var y = time.getFullYear();
// var m = time.getMonth() + 1;
// var d = time.getDate();
// var h = time.getHours();
// var mm = time.getMinutes();
// var s = time.getSeconds();
return time
},
//时间戳转为yy-mm-dd hh:mm:ss
timeFun(unixtimestamp) {
var unixtimestamp = new Date(unixtimestamp);
var year = 1900 + unixtimestamp.getYear();
var month = "0" + (unixtimestamp.getMonth() + 1);
var date = "0" + unixtimestamp.getDate();
return year + "-" + month.substring(month.length - 2, month.length) + "-" + date.substring(date.length - 2, date.length)
},
buttonClick(val) {
this.listQuery.reportTime = val.reportTime ? val.reportTime : undefined;
switch (val.btnName) {

View File

@@ -1,8 +1,8 @@
<!--
* @Author: zwq
* @Date: 2022-01-21 14:43:06
* @LastEditors: zhp
* @LastEditTime: 2024-04-17 10:03:39
* @LastEditors: DY
* @LastEditTime: 2024-05-22 13:48:58
* @Description:
-->
<template>
@@ -58,11 +58,11 @@ export default {
chart: null
}
},
mounted() {
this.$nextTick(() => {
this.initChart()
})
},
// mounted() {
// this.$nextTick(() => {
// this.initChart()
// })
// },
beforeDestroy() {
if (!this.chart) {
return
@@ -71,8 +71,7 @@ export default {
this.chart = null
},
methods: {
initChart() {
console.log(1111)
initChart(xAxis, seriesList) {
this.chart = echarts.init(document.getElementById(this.id))
console.log(this.$parent);
this.chart.setOption({
@@ -85,7 +84,7 @@ export default {
},
grid: { top: 100, right: 90, bottom: 10, left: 10, containLabel: true },
legend: {
data: ['工厂1', '工厂2'],
// data: ['工厂1', '工厂2'],
right: '90px',
top: '0%',
icon: 'rect',
@@ -107,7 +106,7 @@ export default {
{
type: 'category',
// prettier-ignore
data: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
data: xAxis
}
],
yAxis: [
@@ -122,39 +121,8 @@ export default {
bottom: "1%",
containLabel: true
},
series: [
{
name: '工厂1',
type: 'bar',
itemStyle: {
normal: {
color: 'rgba(99, 189, 255, 1)', //改变折线点的颜色
lineStyle: {
color: 'rgba(99, 189, 255, 1)' //改变折线颜色
}
}
},
data: [
2.0, 4.9, 7.0, 23.2, 25.6, 76.7, 135.6, 162.2, 32.6, 20.0, 6.4, 3.3
],
},
{
name: '工厂2',
type: 'bar',
itemStyle: {
normal: {
color: 'rgba(142, 240, 171, 1)', //改变折线点的颜色
lineStyle: {
color: 'rgba(142, 240, 171, 1)' //改变折线颜色
}
}
},
data: [
2.6, 5.9, 9.0, 26.4, 28.7, 70.7, 175.6, 182.2, 48.7, 18.8, 6.0, 2.3
],
},
]
})
series: seriesList
}, true)
}
}
}