生产数据管理
This commit is contained in:
@@ -1,26 +1,26 @@
|
||||
<!--
|
||||
* @Author: zhp
|
||||
* @Date: 2024-04-15 10:49:13
|
||||
* @LastEditTime: 2024-06-07 09:41:56
|
||||
* @LastEditTime: 2024-06-19 15:47:17
|
||||
* @LastEditors: DY
|
||||
* @Description:
|
||||
-->
|
||||
<template>
|
||||
<div style="display: flex; flex-direction: column; min-height: calc(100vh - 96px - 31px)">
|
||||
<div class="app-container" style="padding: 16px 24px 0;height: auto; flex-grow: 1;">
|
||||
<div style="display: flex; flex-direction: column; min-height: calc(100vh - 200px - 31px)">
|
||||
<div class="app-container" style="padding: 16px 24px 0; height: auto; flex-grow: 1;">
|
||||
<el-form :model="listQuery" :inline="true" ref="dataForm" class="blueTip">
|
||||
<el-form-item label="时间维度" prop="date">
|
||||
<el-select size="small" clearable v-model="listQuery.date" placeholder="请选择">
|
||||
<el-form-item label="时间维度" prop="type">
|
||||
<el-select size="small" clearable v-model="listQuery.type" placeholder="请选择">
|
||||
<el-option v-for="item in timeList" :key="item.value" :label="item.label" :value="item.value">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item v-show="listQuery.date === 0 || listQuery.date === ''" label="时间范围" prop="reportTime">
|
||||
<el-form-item v-show="listQuery.type === 0 || listQuery.type === ''" label="时间范围" prop="reportTime">
|
||||
<el-date-picker size="small" clearable v-model="listQuery.reportTime" type="datetimerange" range-separator="至"
|
||||
start-placeholder="开始日期" value-format="timestamp" format="yyyy-MM-dd" @change="changeDayTime" end-placeholder="结束日期">
|
||||
start-placeholder="开始日期" value-format="yyyy-MM-dd" format="yyyy-MM-dd" @change="changeDayTime" end-placeholder="结束日期">
|
||||
</el-date-picker>
|
||||
</el-form-item>
|
||||
<el-form-item v-show="listQuery.date === 1" label="时间范围" prop="reportTime">
|
||||
<el-form-item v-show="listQuery.type === 1" label="时间范围" prop="reportTime">
|
||||
<el-date-picker size="small" clearable v-model="listQuery.start" type="week" format="yyyy 第 WW 周" placeholder="选择周"
|
||||
style="width: 180px" @change="onValueChange">
|
||||
</el-date-picker>
|
||||
@@ -28,26 +28,26 @@
|
||||
<el-date-picker size="small" clearable v-model="listQuery.end" type="week" format="yyyy 第 WW 周" placeholder="选择周"
|
||||
style="width: 180px" @change="onValueChange">
|
||||
</el-date-picker>
|
||||
<span v-if="listQuery.start && listQuery.end" style="margin-left: 10px">
|
||||
<!-- <span v-if="listQuery.start && listQuery.end" style="margin-left: 10px">
|
||||
{{ date1 }} 至 {{ date2 }},共 {{ weekNum }} 周
|
||||
</span>
|
||||
</span> -->
|
||||
</el-form-item>
|
||||
<el-form-item v-show="listQuery.date === 2" label="时间范围" prop="reportTime">
|
||||
<el-date-picker size="small" clearable v-model="listQuery.reportTime" type="monthrange" value-format="timestamp" range-separator="至"
|
||||
<el-form-item v-show="listQuery.type === 2" label="时间范围" prop="reportTime">
|
||||
<el-date-picker size="small" clearable v-model="listQuery.reportTime" type="monthrange" value-format="yyyy-MM-dd" range-separator="至"
|
||||
start-placeholder="开始月份" end-placeholder="结束月份" @change="changeTime">
|
||||
</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" format="yyyy-MM-dd" value-format="timestamp" type="year"
|
||||
<el-form-item v-show="listQuery.type === 3" label="时间范围" prop="reportTime">
|
||||
<el-date-picker size="small" clearable v-model="listQuery.start" value-format="yyyy-MM-dd" type="year"
|
||||
placeholder="开始时间">
|
||||
</el-date-picker>
|
||||
~
|
||||
<el-date-picker size="small" clearable v-model="listQuery.end" format="yyyy-MM-dd" value-format="timestamp" type="year" placeholder="结束时间"
|
||||
<el-date-picker size="small" clearable v-model="listQuery.end" value-format="yyyy-MM-dd" type="year" placeholder="结束时间"
|
||||
@change="getYear">
|
||||
</el-date-picker>
|
||||
</el-form-item>
|
||||
<el-form-item label="工厂名称" prop="factorys">
|
||||
<el-select size="small" clearable v-model="listQuery.factorys" placeholder="请选择工厂名称" multiple >
|
||||
<el-form-item label="工厂名称" prop="factory">
|
||||
<el-select size="small" clearable v-model="listQuery.factory" placeholder="请选择工厂名称" multiple >
|
||||
<el-option v-for="item in factoryArray" :key="item.id" :label="item.name" :value="item.id">
|
||||
</el-option>
|
||||
</el-select>
|
||||
@@ -58,8 +58,8 @@
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item> -->
|
||||
<el-form-item label="玻璃类型" prop="type">
|
||||
<el-select size="small" clearable v-model="listQuery.type" multiple placeholder="请选择玻璃类型">
|
||||
<el-form-item label="玻璃类型" prop="glass">
|
||||
<el-select size="small" clearable v-model="listQuery.glass" multiple placeholder="请选择玻璃类型">
|
||||
<el-option v-for="item in typeList" :key="item.id" :label="item.name" :value="item.id">
|
||||
</el-option>
|
||||
</el-select>
|
||||
@@ -82,19 +82,19 @@
|
||||
</div>
|
||||
<div class="app-container" style="margin-top: 8px;flex-grow: 1; height: auto; padding: 16px;">
|
||||
<search-bar :formConfigs="formConfig" ref="searchBarForm" @headBtnClick="buttonClick" style="margin-bottom: 0" />
|
||||
<base-table :table-props="tableProps" :page="listQuery.current" :limit="listQuery.size"
|
||||
:table-data="tableData">
|
||||
<base-table :table-props="tableProps" :page="listQuery.pageNo" :limit="listQuery.pageSize"
|
||||
:table-data="tableData" :max-height="tableH">
|
||||
<method-btn v-if="tableBtn.length" slot="handleBtn" label="操作" :width="120" fixed="right"
|
||||
:method-list="tableBtn" @clickBtn="handleClick" />
|
||||
</base-table>
|
||||
<pagination
|
||||
:limit.sync="listQuery.size"
|
||||
:page.sync="listQuery.current"
|
||||
:limit.sync="listQuery.pageSize"
|
||||
:page.sync="listQuery.pageNo"
|
||||
:total="listQuery.total"
|
||||
@pagination="getDataList"
|
||||
/>
|
||||
</div>
|
||||
<add-or-update v-if="detailOrUpdateVisible" ref="detailOrUpdate" :date="listQuery.date" @refreshDataList="successSubmit" @destroy="detailOrUpdateVisible = false" />
|
||||
<add-or-update v-if="detailOrUpdateVisible" ref="detailOrUpdate" @refreshDataList="successSubmit" @destroy="detailOrUpdateVisible = false" />
|
||||
<!-- <inputTable :date="date" :data="tableData" :time="[startTimeStamp, endTimeStamp]" :sum="all"
|
||||
:type="listQuery.reportType" @refreshDataList="getDataList" /> -->
|
||||
<!-- <pagination
|
||||
@@ -106,8 +106,9 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
// import { parseTime } from '../../core/mixins/code-filter';
|
||||
import { getProduceDataPage, prodOutputDataList, exportOutPutExcel } from '@/api/produceData';
|
||||
// import { parseTime } from "@/utils/ruoyi";
|
||||
import tableHeightMixin from "@/mixins/tableHeightMixin";
|
||||
import { getProduceDataPage, getproddata, exportOutPutExcel } from '@/api/produceData';
|
||||
// import inputTable from './inputTable.vue';
|
||||
import lineChart from './lineChart';
|
||||
import moment from 'moment'
|
||||
@@ -118,22 +119,22 @@ import { factoryList, factoryArray, factoryArray1 } from "@/utils/constants";
|
||||
|
||||
export default {
|
||||
components: { lineChart, ButtonNav, AddOrUpdate },
|
||||
mixins: [basicPage],
|
||||
mixins: [basicPage, tableHeightMixin],
|
||||
data() {
|
||||
return {
|
||||
factoryList,
|
||||
factoryArray,
|
||||
factoryArray1,
|
||||
listQuery: {
|
||||
size: 20,
|
||||
current: 1,
|
||||
factorys: undefined,
|
||||
pageSize: 20,
|
||||
pageNo: 1,
|
||||
factory: undefined,
|
||||
total: 0,
|
||||
date: 0,
|
||||
type:undefined,
|
||||
type: 0, // 时间维度
|
||||
glass: undefined, // 玻璃类型
|
||||
// reportType: 2,
|
||||
beginTime: undefined,
|
||||
endTime:undefined,
|
||||
startDate: undefined,
|
||||
endDate:undefined,
|
||||
reportTime: [],
|
||||
start: undefined,
|
||||
end: undefined
|
||||
@@ -153,7 +154,7 @@ export default {
|
||||
].filter((v) => v),
|
||||
typeList: [
|
||||
{
|
||||
name: '芯片',
|
||||
name: '玻璃芯片',
|
||||
id: 0,
|
||||
},
|
||||
{
|
||||
@@ -164,6 +165,10 @@ export default {
|
||||
name: 'BIPV产品',
|
||||
id: 2,
|
||||
},
|
||||
// {
|
||||
// name: '定制组件',
|
||||
// id: 3,
|
||||
// },
|
||||
],
|
||||
formConfig: [
|
||||
{
|
||||
@@ -197,16 +202,16 @@ export default {
|
||||
],
|
||||
tableProps: [
|
||||
{
|
||||
prop: 'groupTime',
|
||||
prop: 'datestr',
|
||||
label: '日期',
|
||||
minWidth: 100,
|
||||
minWidth: 120,
|
||||
showOverflowtooltip: true
|
||||
},
|
||||
{
|
||||
prop: 'factory',
|
||||
label: '工厂名称',
|
||||
filter: (val) => factoryList[val],
|
||||
minWidth: 200,
|
||||
minWidth: 180,
|
||||
showOverflowtooltip: true
|
||||
},
|
||||
{
|
||||
@@ -215,19 +220,19 @@ export default {
|
||||
filter: (val) => ['玻璃芯片', '标准组件', 'BIPV', '定制组件'][val]
|
||||
},
|
||||
{
|
||||
prop: 'inputNumber',
|
||||
prop: 'inputNum',
|
||||
label: '投入数量',
|
||||
},
|
||||
{
|
||||
prop: 'outputNumber',
|
||||
prop: 'outputNum',
|
||||
label: '产出数量',
|
||||
},
|
||||
{
|
||||
prop: 'goodNumber',
|
||||
prop: 'goodNum',
|
||||
label: '良品数量',
|
||||
},
|
||||
{
|
||||
prop: 'yieldRate',
|
||||
prop: 'goodRatio',
|
||||
label: '良品率%',
|
||||
filter: (val) => (val * 100) + '%'
|
||||
},
|
||||
@@ -235,22 +240,23 @@ export default {
|
||||
tableData: [],
|
||||
lineData: [],
|
||||
chart: null,
|
||||
seriesList: []
|
||||
seriesList: [],
|
||||
colorList: ['#2760FF', '#8167F6', '#5B9BFF', '#FFD160']
|
||||
// proLineList: [],
|
||||
// all: {}
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
weekNum() {
|
||||
return Math.round((this.listQuery.end - this.listQuery.start) / (24 * 60 * 60 * 1000 * 7)) + 1
|
||||
},
|
||||
},
|
||||
// computed: {
|
||||
// weekNum() {
|
||||
// return Math.round((this.listQuery.end - this.listQuery.start) / (24 * 60 * 60 * 1000 * 7)) + 1
|
||||
// },
|
||||
// },
|
||||
created() {
|
||||
const today = new Date()
|
||||
const sevenDaysAgo = new Date(today.getTime() - (7 * 24 * 60 * 60 * 1000))
|
||||
this.listQuery.beginTime = sevenDaysAgo.getTime()
|
||||
this.listQuery.endTime = today.getTime()
|
||||
this.listQuery.reportTime = [this.listQuery.beginTime, this.listQuery.endTime]
|
||||
this.listQuery.startDate = moment(sevenDaysAgo).format('yyyy-MM-DD')
|
||||
this.listQuery.endDate = moment(today).format('yyyy-MM-DD')
|
||||
this.listQuery.reportTime = [this.listQuery.startDate, this.listQuery.endDate]
|
||||
},
|
||||
mounted() {
|
||||
},
|
||||
@@ -259,7 +265,7 @@ export default {
|
||||
this.detailOrUpdateVisible = true;
|
||||
this.addOrEditTitle = "详情";
|
||||
this.$nextTick(() => {
|
||||
this.$refs.detailOrUpdate.init(val.data.id);
|
||||
this.$refs.detailOrUpdate.init(val.data.id, this.listQuery.type, val.data.glassType);
|
||||
});
|
||||
},
|
||||
getYear(e) {
|
||||
@@ -273,8 +279,12 @@ export default {
|
||||
this.listQuery.end = undefined
|
||||
// console.log();
|
||||
} else {
|
||||
this.listQuery.beginTime = this.listQuery.start
|
||||
this.listQuery.endTime = this.listQuery.end
|
||||
this.listQuery.startDate = this.listQuery.start
|
||||
this.listQuery.endDate = this.listQuery.end
|
||||
}
|
||||
if (!this.listQuery.start && !this.listQuery.end) {
|
||||
this.listQuery.startDate = undefined
|
||||
this.listQuery.endDate = undefined
|
||||
}
|
||||
// console.log(e);
|
||||
},
|
||||
@@ -292,10 +302,14 @@ export default {
|
||||
type: 'warning'
|
||||
});
|
||||
} else {
|
||||
this.listQuery.beginTime = this.listQuery.start.getTime() - 24 * 60 * 60 * 1000
|
||||
this.listQuery.endTime = this.listQuery.end.getTime() + 5 * 24 * 60 * 60 * 1000
|
||||
this.listQuery.startDate = moment(this.listQuery.start.getTime() - 24 * 60 * 60 * 1000).format('YYYY-MM-DD')
|
||||
this.listQuery.endDate = moment(this.listQuery.end.getTime() + 5 * 24 * 60 * 60 * 1000).format('YYYY-MM-DD')
|
||||
}
|
||||
}
|
||||
if (!this.listQuery.start && !this.listQuery.end) {
|
||||
this.listQuery.startDate = undefined
|
||||
this.listQuery.endDate = undefined
|
||||
}
|
||||
},
|
||||
changeDayTime() {
|
||||
if (this.listQuery.reportTime) {
|
||||
@@ -310,10 +324,12 @@ export default {
|
||||
});
|
||||
this.listQuery.reportTime = [];
|
||||
} else {
|
||||
this.listQuery.beginTime = this.listQuery.reportTime[0]
|
||||
this.listQuery.endTime = this.listQuery.reportTime[1]
|
||||
this.listQuery.startDate = this.listQuery.reportTime[0]
|
||||
this.listQuery.endDate = this.listQuery.reportTime[1]
|
||||
}
|
||||
} else {
|
||||
this.listQuery.startDate = undefined
|
||||
this.listQuery.endDate = undefined
|
||||
}
|
||||
},
|
||||
changeTime(value) {
|
||||
@@ -326,114 +342,115 @@ export default {
|
||||
});
|
||||
this.listQuery.reportTime = [];
|
||||
} else {
|
||||
this.listQuery.beginTime = this.listQuery.reportTime[0]
|
||||
this.listQuery.endTime = this.listQuery.reportTime[1]
|
||||
this.listQuery.startDate = this.listQuery.reportTime[0]
|
||||
this.listQuery.endDate = this.listQuery.reportTime[1]
|
||||
}
|
||||
} else {
|
||||
console.log(this.listQuery.reportTime[0])
|
||||
this.listQuery.startDate = undefined
|
||||
this.listQuery.endDate = undefined
|
||||
}
|
||||
},
|
||||
async getDataList() {
|
||||
const res = await getProduceDataPage(this.listQuery)
|
||||
console.log(res)
|
||||
if (res.code === 0) {
|
||||
this.tableData = res.data.records
|
||||
this.listQuery.total = res.data.total
|
||||
// if (this.listQuery.total > 0) {
|
||||
// this.tableData.forEach(item => {
|
||||
// item.tableTime = item?.reportDate?.length > 0 ? item.reportDate[0] + '-' + item.reportDate[1] + '-' + item.reportDate[2] : '--'
|
||||
// })
|
||||
// }
|
||||
}
|
||||
await getProduceDataPage(this.listQuery).then(res => {
|
||||
console.log(res)
|
||||
if (res.code === 0) {
|
||||
this.tableData = res.data.records
|
||||
this.listQuery.total = res.data.total
|
||||
}
|
||||
})
|
||||
|
||||
// 图表
|
||||
await prodOutputDataList({
|
||||
current: 1,
|
||||
size: 99,
|
||||
beginTime: this.listQuery.beginTime,
|
||||
endTime: this.listQuery.endTime,
|
||||
factorys: this.listQuery.factorys,
|
||||
date: this.listQuery.date,
|
||||
type: this.listQuery.type
|
||||
}).then(resp => {
|
||||
console.log('Aaa', resp.data)
|
||||
this.lineData = resp?.data || []
|
||||
if (this.lineData.length > 0) {
|
||||
this.buildChart(this.lineData)
|
||||
await getproddata(this.listQuery).then(resp => {
|
||||
if (resp.data?.length > 0) {
|
||||
const chartData = Object.groupBy(resp.data, (member) => member.datestr)
|
||||
this.buildChart(chartData, resp.data)
|
||||
} else {
|
||||
this.$refs.lineChart.initChart([], [])
|
||||
}
|
||||
})
|
||||
// this.buildChart(this.tableData)
|
||||
},
|
||||
buildChart(list) {
|
||||
let temp = []
|
||||
buildChart(data, dataList) {
|
||||
let xAxisData = []
|
||||
list.forEach(item => {
|
||||
temp.push(item.groupTime)
|
||||
})
|
||||
this.seriesList = []
|
||||
// x轴数据
|
||||
xAxisData = Array.from(new Set(temp))
|
||||
xAxisData = Object.keys(data)
|
||||
|
||||
// y轴数据
|
||||
for (const y of this.factoryArray1) {
|
||||
for (const type of this.typeList) {
|
||||
const seriesItem = {
|
||||
name: y.name,
|
||||
record: type.name,
|
||||
type: 'bar',
|
||||
emphasis: {
|
||||
focus: 'series'
|
||||
},
|
||||
data: Array(xAxisData.length).fill(0)
|
||||
}
|
||||
list.forEach(data => {
|
||||
xAxisData.forEach((x, index) => {
|
||||
if (x === data.groupTime && y.id === data.factory && type.id === data.glassType) {
|
||||
seriesItem.data[index] = data.goodNumber
|
||||
this.factoryArray.forEach(fac => {
|
||||
let i = 0
|
||||
while ( i < 3) {
|
||||
// 下标
|
||||
const index1 = ['chipYield', 'componentYield', 'bipvProductOutput'][i]
|
||||
// let oneChart = {}
|
||||
xAxisData.forEach((x, index) => {
|
||||
if (this.listQuery.glass.length === 0 || this.listQuery.glass.length === 3) {
|
||||
let series = {
|
||||
name: ['玻璃芯片', '标准组件', 'BIPV'][i] + '-' + fac.id,
|
||||
type: 'bar',
|
||||
stack: String(fac.id),
|
||||
data: Array(xAxisData.length).fill(0),
|
||||
barWidth: 20,
|
||||
itemStyle: {
|
||||
color: this.colorList[i]
|
||||
}
|
||||
}
|
||||
})
|
||||
dataList.forEach(item => {
|
||||
if (fac.id === item.factory && item.datestr === x) {
|
||||
series.data[index] = item[index1]
|
||||
}
|
||||
})
|
||||
this.seriesList.push(series)
|
||||
} else {
|
||||
this.listQuery.glass.forEach(gl => {
|
||||
if (gl === i) {
|
||||
let series = {
|
||||
name: ['玻璃芯片', '标准组件', 'BIPV'][i] + '-' + fac.id,
|
||||
type: 'bar',
|
||||
stack: String(fac.id),
|
||||
data: Array(xAxisData.length).fill(0),
|
||||
barWidth: 20,
|
||||
itemStyle: {
|
||||
color: this.colorList[i]
|
||||
}
|
||||
}
|
||||
dataList.forEach(item => {
|
||||
if (fac.id === item.factory && item.datestr === x) {
|
||||
series.data[index] = item[index1]
|
||||
}
|
||||
})
|
||||
this.seriesList.push(series)
|
||||
}
|
||||
})
|
||||
}
|
||||
// let series = {
|
||||
// name: ['玻璃芯片', '标准组件', 'BIPV'][i] + '-' + fac.id,
|
||||
// type: 'bar',
|
||||
// stack: String(fac.id),
|
||||
// data: Array(xAxisData.length).fill(0),
|
||||
// barWidth: 20,
|
||||
// itemStyle: {
|
||||
// color: this.colorList[i]
|
||||
// }
|
||||
// }
|
||||
// dataList.forEach(item => {
|
||||
// if (fac.id === item.factory && item.datestr === x) {
|
||||
// series.data[index] = item[index1]
|
||||
// }
|
||||
// })
|
||||
// this.seriesList.push(series)
|
||||
})
|
||||
this.seriesList.push(seriesItem)
|
||||
i ++
|
||||
}
|
||||
}
|
||||
console.log('啊啊', this.seriesList)
|
||||
})
|
||||
console.log('你好', this.seriesList)
|
||||
this.$refs.lineChart.initChart(xAxisData, this.seriesList)
|
||||
// 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.factoryArray) {
|
||||
// // 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)
|
||||
},
|
||||
buttonClick(val) {
|
||||
this.listQuery.reportTime = val.reportTime ? val.reportTime : undefined;
|
||||
switch (val.btnName) {
|
||||
case 'search':
|
||||
this.listQuery.current = 1;
|
||||
this.listQuery.size = 20;
|
||||
this.listQuery.pageNo = 1;
|
||||
this.listQuery.pageSize = 20;
|
||||
this.getDataList();
|
||||
break;
|
||||
case 'export':
|
||||
@@ -448,8 +465,8 @@ export default {
|
||||
this.$modal.confirm('是否确认导出生产数据?').then(() => {
|
||||
// 处理查询参数
|
||||
let params = {...this.listQuery};
|
||||
params.current = 1;
|
||||
params.size = 999;
|
||||
params.pageNo = 1;
|
||||
params.pageSize = 999;
|
||||
this.exportLoading = true;
|
||||
return exportOutPutExcel(params);
|
||||
}).then(response => {
|
||||
|
||||
Reference in New Issue
Block a user