Compare commits

..

No commits in common. "b89f510e61d85409a0fc2d07303cd4cf6d38c3aa" and "3c4fe6daaa22f4ea529872bbadcfe4edde5123a6" have entirely different histories.

View File

@ -6,239 +6,197 @@
* @Description: * @Description:
--> -->
<template> <template>
<div class="weekly"> <div class="weekly">
<el-form <el-form :inline="true" :model="listQuery" class="blueTip">
:inline="true" <el-form-item label="月" prop="reportTime">
:model="listQuery" <el-date-picker v-model="listQuery.time" value-format="yyyy-MM-dd HH:mm:ss" type="month" size="small" placeholder="选择月">
class="blueTip"> </el-date-picker>
<el-form-item </el-form-item>
label="月" <el-button v-if="this.$auth.hasPermi('base:report-auto-production:query')" type="primary" size="small" @click="getList">
prop="reportTime"> 查询
<el-date-picker </el-button>
v-model="listQuery.time" <el-button v-if="this.$auth.hasPermiAnd(['base:report-auto-original-glass:export', 'base:report-auto-production:export'])" type="primary" size="small" plain
value-format="yyyy-MM-dd HH:mm:ss" @click="handleExport">导出</el-button>
type="month" </el-form>
size="small" <base-table
placeholder="选择月"></el-date-picker>
</el-form-item>
<el-button
v-if="this.$auth.hasPermi('base:report-auto-production:query')"
type="primary"
size="small"
@click="getList">
查询
</el-button>
<el-button
v-if="
this.$auth.hasPermiAnd([
'base:report-auto-original-glass:export',
'base:report-auto-production:export',
])
"
type="primary"
size="small"
plain
@click="handleExport">
导出
</el-button>
</el-form>
<base-table
:table-props="tableProps" :table-props="tableProps"
:table-data="tableData" :table-data="tableData"
:span-method="objectSpanMethod1" :span-method="mergeColumnHandler"
@emitFun="handleEmitFun" @emitFun="handleEmitFun"
:max-height="tableH" /> :max-height="tableH"
<!-- <monthWeek v-if="glassWeekShow" ref="monthWeek" :product="false" :params="listQuery" /> />
<!-- <monthWeek v-if="glassWeekShow" ref="monthWeek" :product="false" :params="listQuery" />
<proMonth v-if="proWeekShow" ref="proMonth" :product="false" :params="listQuery" /> --> <proMonth v-if="proWeekShow" ref="proMonth" :product="false" :params="listQuery" /> -->
</div> </div>
</template> </template>
<script> <script>
// import monthWeek from '../glass/month.vue' // import monthWeek from '../glass/month.vue'
// import proMonth from '../productionMonthReport/index.vue' // import proMonth from '../productionMonthReport/index.vue'
import { productionMonthY } from '@/api/report/glass'; import { productionMonthY } from '@/api/report/glass';
import { parseTime } from '../../core/mixins/code-filter'; import { parseTime } from '../../core/mixins/code-filter'
import FileSaver from 'file-saver'; import FileSaver from 'file-saver'
import * as XLSX from 'xlsx/xlsx.mjs'; import * as XLSX from 'xlsx/xlsx.mjs'
import tableHeightMixin from '@/mixins/lb/tableHeightMixin'; import tableHeightMixin from '@/mixins/lb/tableHeightMixin';
export default { export default {
// components: { monthWeek, proMonth }, // components: { monthWeek, proMonth },
mixins: [tableHeightMixin], mixins: [tableHeightMixin],
data() { data() {
return { return {
heightNum: 240, heightNum: 240,
listQuery: { listQuery: {
time: parseTime(new Date()), time: parseTime(new Date())
}, },
// startTimeStamp: '', // startTimeStamp: '',
// endTimeStamp: '', // endTimeStamp: '',
// reportTime: '', // reportTime: '',
// glassWeekShow: false, // glassWeekShow: false,
// proWeekShow: false, // proWeekShow: false,
tableData: [], tableData: [],
tableProps: [ tableProps: [
{ {
prop: 'lineName', prop: 'lineName',
label: '', label: ''
}, },
{ {
prop: 'paramsName', prop: 'paramsName',
label: '', label: ''
}, }
], ],
resData: [], resData: []
span1: [], //1 }
}; },
}, created() {
created() { // this.getCurrentMonthFirst()
// this.getCurrentMonthFirst() // this.glassWeekShow = true
// this.glassWeekShow = true // this.proWeekShow = true
// this.proWeekShow = true },
}, mounted() {
mounted() { this.getList()
this.getList(); },
}, methods: {
methods: { /** 合并table列的规则 */
async getList() { mergeColumnHandler({ row, column, rowIndex, columnIndex }) {
this.tableData = []; // if (columnIndex == 0 || columnIndex == 1) {
this.tableProps = [ // if (this.spanInfo[rowIndex]) {
{ // return [
prop: 'lineName', // this.spanInfo[rowIndex], // row span
label: '', // 1, // col span
fixed: true, // ];
}, // } else {
{ // return [0, 0];
prop: 'paramsName', // }
label: '', // }
fixed: true,
},
];
await productionMonthY(this.listQuery).then((res) => {
this.resData = res.data;
//
Object.keys(this.resData).forEach((item) => {
this.tableProps.push({
prop: item,
label: item,
'show-overflow-tooltip': true,
});
});
this.buildTableData(this.resData);
});
}, },
// async getList() {
buildTableData(data) { this.tableData = []
let keys = Object.keys(data); this.tableProps = [
let tempData = []; {
let subKeys = Object.keys(data[keys[0]]); prop: 'lineName',
let sub2Keys = Object.keys(data[keys[0]][subKeys[0]]); label: ''
for (let i = 0; i < keys.length; i++) { },
if (i === 0) { {
for (let j = 0; j < subKeys.length; j++) { prop: 'paramsName',
for (let k = 0; k < sub2Keys.length; k++) { label: ''
let obj = {}; }
obj.lineName = subKeys[j]; ]
obj.paramsName = sub2Keys[k]; await productionMonthY(this.listQuery).then(res => {
obj[keys[0]] = data[keys[0]][subKeys[j]][sub2Keys[k]]; this.resData = res.data
tempData.push(obj); //
} Object.keys(this.resData).forEach(item => {
} this.tableProps.push({
} else { prop: item,
for (let j = 0; j < subKeys.length; j++) { label: item,
for (let k = 0; k < sub2Keys.length; k++) { 'show-overflow-tooltip': true
for (let v = 0; v < tempData.length; v++) { })
if ( })
tempData[v].lineName === subKeys[j] && this.buildTableData()
tempData[v].paramsName === sub2Keys[k] })
) { },
tempData[v][keys[i]] = data[keys[i]][subKeys[j]][sub2Keys[k]]; //
} buildTableData() {
} const temp = Object.values(this.resData)
} console.log('temp', temp)
} const dataArray = []
} // Object.entries(this.resData).forEach(en => {
} // console.log('', en)
this.tableData = tempData; // const date = en[0]
this.getSpanArr(this.tableData); // let valueArray = []
}, // Object.entries(en[1]).forEach((values, sequence) => {
// // let yValue = {}
getSpanArr(data) { // yValue['line'] = values[0]
this.span1 = []; // Object.entries(values[1]).forEach((lastV, index) => {
for (var i = 0; i < data.length; i++) { // console.log(lastV)
if (i === 0) { // const tempValue = {}
this.span1.push(1); // if (values[0] === yValue['line']) {
this.index = 0; // tempValue[values[0]] = lastV[1]
} else { // }
if (data[i].lineName === data[i - 1].lineName) { // valueArray.push(tempValue)
this.span1[this.index] += 1; // })
this.span1.push(0); // yValue[date+'-'+sequence] = valueArray
} else { // dataArray.push(yValue)
this.span1.push(1); // })
this.index = i; // })
} // for (let key in temp) {
} // console.log('', temp[key])
} // }
}, // 线
objectSpanMethod1({ rowIndex, columnIndex }) { Object.keys(temp[0]).forEach(item => {
if (columnIndex === 0) { //
const _row = this.span1[rowIndex]; Object.keys(Object.values(temp[0])[0]).forEach(it => {
return { const row = {
rowspan: _row, lineName: item,
colspan: 1, paramsName: it
}; }
} this.tableData.push(row)
}, })
handleExport() { })
const xlsxParam = { raw: true }; },
let workbook = XLSX.utils.book_new(); handleExport() {
var ws = XLSX.utils.table_to_sheet( const xlsxParam = { raw: true }
document.querySelector('#exportTable'), let workbook = XLSX.utils.book_new()
xlsxParam var ws = XLSX.utils.table_to_sheet( document.querySelector('#exportTable'), xlsxParam)
); XLSX.utils.book_append_sheet(workbook, ws, '许昌安彩月原片生产汇总')
XLSX.utils.book_append_sheet(workbook, ws, '许昌安彩月原片生产汇总'); var prows = XLSX.utils.table_to_sheet( document.querySelector('#exportproductionTable'), xlsxParam)
var prows = XLSX.utils.table_to_sheet( XLSX.utils.book_append_sheet(workbook, prows, '许昌安彩月成品生产汇总')
document.querySelector('#exportproductionTable'), let fileName = '生产数据汇总表-月报.xlsx';
xlsxParam var wbout = XLSX.write(workbook, {
); bookType: 'xlsx',
XLSX.utils.book_append_sheet(workbook, prows, '许昌安彩月成品生产汇总'); bookSST: true,
let fileName = '生产数据汇总表-月报.xlsx'; type: 'array',
var wbout = XLSX.write(workbook, { });
bookType: 'xlsx', try {
bookSST: true, FileSaver.saveAs(
type: 'array', new Blob([wbout], { type: 'application/octet-stream' }),
}); fileName
try { );
FileSaver.saveAs( this.$message.success('导出成功');
new Blob([wbout], { type: 'application/octet-stream' }), } catch (e) {
fileName if (typeof console !== 'undefined') console.log(e, wbout);
); }
this.$message.success('导出成功'); return wbout;
} catch (e) { },
if (typeof console !== 'undefined') console.log(e, wbout); handleEmitFun(payload) {
}
return wbout;
},
handleEmitFun(payload) {
console.log('payload', payload); console.log('payload', payload);
}, }
}, }
}; }
</script> </script>
<style scoped> <style scoped>
.weekly { .weekly {
padding: 16px; padding: 16px;
} }
.blueTip::before { .blueTip::before{
display: inline-block; display: inline-block;
content: ''; content: '';
width: 4px; width: 4px;
height: 18px; height: 18px;
background: #0b58ff; background: #0B58FF;
border-radius: 1px; border-radius: 1px;
margin-right: 8px; margin-right: 8PX;
margin-top: 8px; margin-top: 8px;
margin-left: 16px; margin-left: 16px;
} }
</style> </style>