生产管理
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user