Compare commits
	
		
			2 Commits
		
	
	
		
			3c4fe6daaa
			...
			b89f510e61
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| b89f510e61 | |||
| 067cd4765e | 
@@ -6,197 +6,239 @@
 | 
				
			|||||||
 * @Description: 
 | 
					 * @Description: 
 | 
				
			||||||
-->
 | 
					-->
 | 
				
			||||||
<template>
 | 
					<template>
 | 
				
			||||||
  <div class="weekly">
 | 
						<div class="weekly">
 | 
				
			||||||
    <el-form :inline="true" :model="listQuery" class="blueTip">
 | 
							<el-form
 | 
				
			||||||
      <el-form-item label="月" prop="reportTime">
 | 
								:inline="true"
 | 
				
			||||||
        <el-date-picker v-model="listQuery.time" value-format="yyyy-MM-dd HH:mm:ss" type="month" size="small" placeholder="选择月">
 | 
								:model="listQuery"
 | 
				
			||||||
        </el-date-picker>
 | 
								class="blueTip">
 | 
				
			||||||
      </el-form-item>
 | 
								<el-form-item
 | 
				
			||||||
      <el-button v-if="this.$auth.hasPermi('base:report-auto-production:query')" type="primary" size="small" @click="getList">
 | 
									label="月"
 | 
				
			||||||
        查询
 | 
									prop="reportTime">
 | 
				
			||||||
      </el-button>
 | 
									<el-date-picker
 | 
				
			||||||
      <el-button v-if="this.$auth.hasPermiAnd(['base:report-auto-original-glass:export', 'base:report-auto-production:export'])" type="primary" size="small" plain
 | 
										v-model="listQuery.time"
 | 
				
			||||||
        @click="handleExport">导出</el-button>
 | 
										value-format="yyyy-MM-dd HH:mm:ss"
 | 
				
			||||||
    </el-form>
 | 
										type="month"
 | 
				
			||||||
    <base-table
 | 
										size="small"
 | 
				
			||||||
 | 
										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="mergeColumnHandler"
 | 
								:span-method="objectSpanMethod1"
 | 
				
			||||||
			@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() {
 | 
						},
 | 
				
			||||||
    // this.getCurrentMonthFirst()
 | 
						created() {
 | 
				
			||||||
    // this.glassWeekShow = true
 | 
							// this.getCurrentMonthFirst()
 | 
				
			||||||
    // this.proWeekShow = true
 | 
							// this.glassWeekShow = true
 | 
				
			||||||
  },
 | 
							// this.proWeekShow = true
 | 
				
			||||||
  mounted() {
 | 
						},
 | 
				
			||||||
    this.getList()
 | 
						mounted() {
 | 
				
			||||||
  },
 | 
							this.getList();
 | 
				
			||||||
  methods: {
 | 
						},
 | 
				
			||||||
    /** 合并table列的规则 */
 | 
						methods: {
 | 
				
			||||||
		mergeColumnHandler({ row, column, rowIndex, columnIndex }) {
 | 
							async getList() {
 | 
				
			||||||
			// if (columnIndex == 0 || columnIndex == 1) {
 | 
								this.tableData = [];
 | 
				
			||||||
			// 	if (this.spanInfo[rowIndex]) {
 | 
								this.tableProps = [
 | 
				
			||||||
			// 		return [
 | 
									{
 | 
				
			||||||
			// 			this.spanInfo[rowIndex], // row span
 | 
										prop: 'lineName',
 | 
				
			||||||
			// 			1, // col span
 | 
										label: '',
 | 
				
			||||||
			// 		];
 | 
										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() {
 | 
							// 设置表格数据
 | 
				
			||||||
      this.tableData = []
 | 
							buildTableData(data) {
 | 
				
			||||||
      this.tableProps = [
 | 
								let keys = Object.keys(data);
 | 
				
			||||||
        {
 | 
								let tempData = [];
 | 
				
			||||||
          prop: 'lineName',
 | 
								let subKeys = Object.keys(data[keys[0]]);
 | 
				
			||||||
          label: ''
 | 
								let sub2Keys = Object.keys(data[keys[0]][subKeys[0]]);
 | 
				
			||||||
        },
 | 
								for (let i = 0; i < keys.length; i++) {
 | 
				
			||||||
        {
 | 
									if (i === 0) {
 | 
				
			||||||
          prop: 'paramsName',
 | 
										for (let j = 0; j < subKeys.length; j++) {
 | 
				
			||||||
          label: ''
 | 
											for (let k = 0; k < sub2Keys.length; k++) {
 | 
				
			||||||
        }
 | 
												let obj = {};
 | 
				
			||||||
      ]
 | 
												obj.lineName = subKeys[j];
 | 
				
			||||||
      await productionMonthY(this.listQuery).then(res => {
 | 
												obj.paramsName = sub2Keys[k];
 | 
				
			||||||
        this.resData = res.data
 | 
												obj[keys[0]] = data[keys[0]][subKeys[j]][sub2Keys[k]];
 | 
				
			||||||
        // 设置表头
 | 
												tempData.push(obj);
 | 
				
			||||||
        Object.keys(this.resData).forEach(item => {
 | 
											}
 | 
				
			||||||
          this.tableProps.push({
 | 
										}
 | 
				
			||||||
            prop: item,
 | 
									} else {
 | 
				
			||||||
            label: item,
 | 
										for (let j = 0; j < subKeys.length; j++) {
 | 
				
			||||||
            'show-overflow-tooltip': true
 | 
											for (let k = 0; k < sub2Keys.length; k++) {
 | 
				
			||||||
          })
 | 
												for (let v = 0; v < tempData.length; v++) {
 | 
				
			||||||
        })
 | 
													if (
 | 
				
			||||||
        this.buildTableData()
 | 
														tempData[v].lineName === subKeys[j] &&
 | 
				
			||||||
      })
 | 
														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)
 | 
								}
 | 
				
			||||||
        // const date = en[0]
 | 
								this.tableData = tempData;
 | 
				
			||||||
        // let valueArray = []
 | 
								this.getSpanArr(this.tableData);
 | 
				
			||||||
        // Object.entries(en[1]).forEach((values, sequence) => {
 | 
							},
 | 
				
			||||||
        //   let yValue = {}
 | 
							// 获取合并行
 | 
				
			||||||
        //   yValue['line'] = values[0]
 | 
							getSpanArr(data) {
 | 
				
			||||||
        //   Object.entries(values[1]).forEach((lastV, index) => {
 | 
								this.span1 = [];
 | 
				
			||||||
        //     console.log(lastV)
 | 
								for (var i = 0; i < data.length; i++) {
 | 
				
			||||||
        //     const tempValue = {}
 | 
									if (i === 0) {
 | 
				
			||||||
        //     if (values[0] === yValue['line']) {
 | 
										this.span1.push(1);
 | 
				
			||||||
        //       tempValue[values[0]] = lastV[1]
 | 
										this.index = 0;
 | 
				
			||||||
        //     }
 | 
									} else {
 | 
				
			||||||
        //     valueArray.push(tempValue)
 | 
										if (data[i].lineName === data[i - 1].lineName) {
 | 
				
			||||||
        //   })
 | 
											this.span1[this.index] += 1;
 | 
				
			||||||
        //   yValue[date+'-'+sequence] = valueArray
 | 
											this.span1.push(0);
 | 
				
			||||||
        //   dataArray.push(yValue)
 | 
										} else {
 | 
				
			||||||
        // })
 | 
											this.span1.push(1);
 | 
				
			||||||
      // })
 | 
											this.index = i;
 | 
				
			||||||
      // for (let key in temp) {
 | 
										}
 | 
				
			||||||
      //   console.log('你好', temp[key])
 | 
									}
 | 
				
			||||||
      // }
 | 
								}
 | 
				
			||||||
      // 产线
 | 
							},
 | 
				
			||||||
      Object.keys(temp[0]).forEach(item => {
 | 
							objectSpanMethod1({ rowIndex, columnIndex }) {
 | 
				
			||||||
        // 规格循环
 | 
								if (columnIndex === 0) {
 | 
				
			||||||
        Object.keys(Object.values(temp[0])[0]).forEach(it => {
 | 
									const _row = this.span1[rowIndex];
 | 
				
			||||||
          const row = {
 | 
									return {
 | 
				
			||||||
            lineName: item,
 | 
										rowspan: _row,
 | 
				
			||||||
            paramsName: it
 | 
										colspan: 1,
 | 
				
			||||||
          }
 | 
									};
 | 
				
			||||||
          this.tableData.push(row)
 | 
								}
 | 
				
			||||||
        })
 | 
							},
 | 
				
			||||||
      })
 | 
							handleExport() {
 | 
				
			||||||
    },
 | 
								const xlsxParam = { raw: true };
 | 
				
			||||||
    handleExport() {
 | 
								let workbook = XLSX.utils.book_new();
 | 
				
			||||||
      const xlsxParam = { raw: true }
 | 
								var ws = XLSX.utils.table_to_sheet(
 | 
				
			||||||
      let workbook = XLSX.utils.book_new()
 | 
									document.querySelector('#exportTable'),
 | 
				
			||||||
      var ws = XLSX.utils.table_to_sheet( document.querySelector('#exportTable'), xlsxParam)
 | 
									xlsxParam
 | 
				
			||||||
      XLSX.utils.book_append_sheet(workbook, ws, '许昌安彩月原片生产汇总')
 | 
								);
 | 
				
			||||||
      var prows = XLSX.utils.table_to_sheet( document.querySelector('#exportproductionTable'), xlsxParam)
 | 
								XLSX.utils.book_append_sheet(workbook, ws, '许昌安彩月原片生产汇总');
 | 
				
			||||||
      XLSX.utils.book_append_sheet(workbook, prows, '许昌安彩月成品生产汇总')
 | 
								var prows = XLSX.utils.table_to_sheet(
 | 
				
			||||||
      let fileName = '生产数据汇总表-月报.xlsx';
 | 
									document.querySelector('#exportproductionTable'),
 | 
				
			||||||
      var wbout = XLSX.write(workbook, {
 | 
									xlsxParam
 | 
				
			||||||
        bookType: 'xlsx',
 | 
								);
 | 
				
			||||||
        bookSST: true,
 | 
								XLSX.utils.book_append_sheet(workbook, prows, '许昌安彩月成品生产汇总');
 | 
				
			||||||
        type: 'array',
 | 
								let fileName = '生产数据汇总表-月报.xlsx';
 | 
				
			||||||
      });
 | 
								var wbout = XLSX.write(workbook, {
 | 
				
			||||||
      try {
 | 
									bookType: 'xlsx',
 | 
				
			||||||
        FileSaver.saveAs(
 | 
									bookSST: true,
 | 
				
			||||||
          new Blob([wbout], { type: 'application/octet-stream' }),
 | 
									type: 'array',
 | 
				
			||||||
          fileName
 | 
								});
 | 
				
			||||||
        );
 | 
								try {
 | 
				
			||||||
        this.$message.success('导出成功');
 | 
									FileSaver.saveAs(
 | 
				
			||||||
      } catch (e) {
 | 
										new Blob([wbout], { type: 'application/octet-stream' }),
 | 
				
			||||||
        if (typeof console !== 'undefined') console.log(e, wbout);
 | 
										fileName
 | 
				
			||||||
      }
 | 
									);
 | 
				
			||||||
      return wbout;
 | 
									this.$message.success('导出成功');
 | 
				
			||||||
    },
 | 
								} catch (e) {
 | 
				
			||||||
    handleEmitFun(payload) {
 | 
									if (typeof console !== 'undefined') console.log(e, wbout);
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								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>
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user