projects/mesxc-zhp #364

Merged
juzi merged 2 commits from projects/mesxc-zhp into projects/mesxc-test 2024-04-25 10:08:48 +08:00
13 changed files with 784 additions and 254 deletions
Showing only changes of commit be607e4bf3 - Show all commits

View File

@ -1,3 +1,3 @@
.dockerignore .dockerignore
dist #dist
node_modules node_modules

59
.drone.yml Normal file
View File

@ -0,0 +1,59 @@
---
kind: pipeline
type: docker
name: default
steps:
- name: build
image: node:16-alpine
pull: if_not_exists
environment:
NODE_ENV: ""
commands:
#- yarn install --frozen-lockfile
- yarn install
- env ${NODE_ENV} yarn build:prod
- name: publish
image: docker:dind
pull: if_not_exists
volumes:
- name: dockersock
path: /var/run/docker.sock
- name: dockerconfig
path: /root/.docker
commands:
- docker build -t hub.kszny.picaiba.com/kszny/xcac-ui ./
- docker push hub.kszny.picaiba.com/kszny/xcac-ui
depends_on:
- build
- name: deploy
image: appleboy/drone-ssh
pull: if-not-exists
settings:
host:
- 172.24.145.74
username: root
password: Root@123
port: 22
command_timeout: 2m
script:
- docker pull hub.kszny.picaiba.com/kszny/xcac-ui
- docker run --rm -v /data/www/xcac:/tmp hub.kszny.picaiba.com/kszny/xcac-ui sh -c "rm -rf /tmp/* && mv -f /html /tmp"
depends_on:
- publish
volumes:
- name: dockersock
host:
path: /var/run/docker.sock
- name: dockerconfig
host:
path: /root/.docker
trigger:
branch:
- projects/mesxc-test
event:
- push

View File

@ -1,7 +1,7 @@
### ###
# @Author: zhp # @Author: zhp
# @Date: 2024-04-12 14:30:48 # @Date: 2024-04-12 14:30:48
# @LastEditTime: 2024-04-25 09:43:17 # @LastEditTime: 2024-04-25 10:07:02
# @LastEditors: zhp # @LastEditors: zhp
# @Description: # @Description:
### ###

View File

@ -1,21 +1,3 @@
FROM node:16-alpine as build-stage FROM busybox
LABEL maintainer thomas.hairong@gmail.com
WORKDIR /admim COPY dist /html/
COPY .npmrc package.json yarn.lock ./
RUN --mount=type=cache,id=yarn-store,target=/root/.yarn-store \
yarn install --frozen-lockfile
COPY . .
ARG NODE_ENV=""
RUN env ${NODE_ENV} yarn build:prod
## -- stage: dist => nginx --
FROM nginx:alpine
ENV TZ=Asia/Shanghai
COPY ./nginx.conf /etc/nginx/conf.d/default.conf
COPY --from=build-stage /admim/dist /usr/share/nginx/html
EXPOSE 80

View File

@ -1,7 +1,7 @@
/* /*
* @Author: Do not edit * @Author: Do not edit
* @Date: 2023-12-08 10:26:48 * @Date: 2023-12-08 10:26:48
* @LastEditTime: 2023-12-13 17:16:00 * @LastEditTime: 2024-04-24 16:31:37
* @LastEditors: DY * @LastEditors: DY
* @Description: * @Description:
*/ */
@ -59,3 +59,39 @@ export function exportGlasscExcel(query) {
responseType: 'blob' responseType: 'blob'
}) })
} }
// 生产月报查询--冷端生产线
export function productionMonthY(data) {
return request({
url: '/extend/customized-reports/productionMonthY',
method: 'post',
data: data
})
}
// 生产月报查询--深加工生产线
export function productionMonthD(data) {
return request({
url: '/extend/customized-reports/productionMonthD',
method: 'post',
data: data
})
}
// 生产年报查询--冷端生产线
export function productionYearY(data) {
return request({
url: '/extend/customized-reports/productionYearY',
method: 'post',
data: data
})
}
// 生产年报查询--冷端生产线
export function productionYearD(data) {
return request({
url: '/extend/customized-reports/productionYearD',
method: 'post',
data: data
})
}

View File

@ -85,7 +85,7 @@ export default {
color: this.colors, color: this.colors,
title: { title: {
text: num, text: num,
subtext: '总数', subtext: '总数/个',
top: '32%', top: '32%',
left: '49%', left: '49%',
textAlign: 'center', textAlign: 'center',

View File

@ -66,8 +66,10 @@ export default {
`<span title=${item.name || ''}>${item.name || ''}</span>`, `<span title=${item.name || ''}>${item.name || ''}</span>`,
`<span title=${item.code || ''}>${item.code || ''}</span>`, `<span title=${item.code || ''}>${item.code || ''}</span>`,
`<span><div style="${ `<span><div style="${
item.status == '正常' item.status == '运行'
? 'box-shadow: 0px 0px 2px 1px #2760FF;width:6px;height:6px;border-radius: 50%;background-color: #2760FF;float:left;margin:13px 10px 0 0 ' ? 'box-shadow: 0px 0px 2px 1px #2760FF;width:6px;height:6px;border-radius: 50%;background-color: #2760FF;float:left;margin:13px 10px 0 0 '
: item.status == '故障'
? 'box-shadow: 0px 0px 2px 1px red;width:6px;height:6px;border-radius: 50%; background-color: red;float:left;margin:13px 10px 0 0 '
: 'box-shadow: 0px 0px 2px 1px #FFBD02;width:6px;height:6px;border-radius: 50%; background-color: #FFBD02;float:left;margin:13px 10px 0 0 ' : 'box-shadow: 0px 0px 2px 1px #FFBD02;width:6px;height:6px;border-radius: 50%; background-color: #FFBD02;float:left;margin:13px 10px 0 0 '
}"></div> ${item.status || ''}</span>`, }"></div> ${item.status || ''}</span>`,
`<span"><div style="${ `<span"><div style="${

View File

@ -1,141 +1,341 @@
<!-- <!--
* @Author: Do not edit * @Author: Do not edit
* @Date: 2024-04-22 15:49:56 * @Date: 2024-04-22 15:49:56
* @LastEditTime: 2024-04-23 17:06:16 * @LastEditTime: 2024-04-25 09:53:41
* @LastEditors: DY * @LastEditors: DY
* @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="reportTime" type="month" size="small" @change="changeTime" 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="search()"> 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"
<monthWeek v-if="glassWeekShow" ref="monthWeek" :product="false" :params="listQuery" /> size="small"
<proMonth v-if="proWeekShow" ref="proMonth" :product="false" :params="listQuery" /> placeholder="选择月"></el-date-picker>
</div> </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-data="tableData"
:span-method="objectSpanMethod1"
@emitFun="handleEmitFun"
:max-height="tableH" />
<base-table
:table-props="tableProps1"
:table-data="tableData1"
:span-method="objectSpanMethod1"
@emitFun="handleEmitFun"
:max-height="tableH"
style="margin-top: 15px" />
</div>
</template> </template>
<script> <script>
import monthWeek from '../glass/month.vue' import { productionMonthY, productionMonthD } from '@/api/report/glass';
import proMonth from '../productionMonthReport/index.vue'
import { parseTime } from '../../core/mixins/code-filter'; import { parseTime } from '../../core/mixins/code-filter';
import FileSaver from 'file-saver';
import * as XLSX from 'xlsx/xlsx.mjs';
import tableHeightMixin from '@/mixins/lb/tableHeightMixin';
export default { export default {
components: { monthWeek, proMonth }, // components: { monthWeek, proMonth },
data() { mixins: [tableHeightMixin],
return { data() {
listQuery: { return {
// pageSize: 10, heightNum: 350,
// pageNo: 1, listQuery: {
// total: 0, time: '',
reportType: 4, },
reportTime: [] // startTimeStamp: '',
}, // endTimeStamp: '',
startTimeStamp: '', // reportTime: '',
endTimeStamp: '', // glassWeekShow: false,
reportTime: '', // proWeekShow: false,
glassWeekShow: false, tableData: [],
proWeekShow: false tableProps: [],
} tableData1: [],
}, tableProps1: [],
created() { resData: [],
this.getCurrentMonthFirst() span1: [], //1
this.glassWeekShow = true resData1: [],
this.proWeekShow = true span2: []
}, };
methods: { },
getCurrentMonthFirst() { created() {
const date = new Date(); let now = new Date()
date.setDate(1); now.setHours(0, 0, 0, 0)
this.reportTime = date now.setDate(1)
// console.log(date) let startOfMonth = now.getTime()
this.changeTime(date) let firstDayOfMonth = new Date(startOfMonth)
// console.log(date.valueOf()); this.listQuery.time = parseTime(firstDayOfMonth)
}, },
handleExport() { mounted() {
this.$nextTick(() => { this.getList();
this.$refs['monthWeek'].handleExport() },
this.$refs['proMonth'].handleExport() methods: {
}) async getList() {
}, this.tableData = [];
search() { this.tableProps = [
this.$nextTick(() => { {
this.$refs['monthWeek'].getDataList() prop: 'lineName',
this.$refs['proMonth'].getDataList() label: '',
}) fixed: true,
}, },
changeTime(val) { {
console.log(val) prop: 'paramsName',
if(val) { label: '',
const timeStamp = val.getMonth(); // fixed: true,
const fullyear = val.getFullYear() },
let days = 0 ];
switch (timeStamp) { this.tableData1 = [];
case 0: this.tableProps1 = [
case 2: {
case 4: prop: 'lineName',
case 6: label: '',
case 7: fixed: true,
case 9: },
case 11: {
days = 31 prop: 'paramsName',
break label: '',
case 3: fixed: true,
case 4: },
case 8: ];
case 10: await productionMonthY(this.listQuery).then((res) => {
days = 30 this.resData = res.data;
break //
case 1: Object.keys(this.resData).forEach((item) => {
if ((fullyear % 400 === 0) || (fullyear % 4 === 0 && fullyear % 100 !== 0)) { this.tableProps.push({
days = 29 prop: item,
} else { label: item,
days = 28 'show-overflow-tooltip': true,
} });
break });
this.buildTableData(this.resData);
});
await productionMonthD(this.listQuery).then((res) => {
this.resData1 = res.data;
//
Object.keys(this.resData1).forEach((item) => {
this.tableProps1.push({
prop: item,
label: item,
'show-overflow-tooltip': true,
});
});
this.buildTableData1(this.resData1);
});
},
// 2
buildTableData1(data) {
let keys = Object.keys(data);
let tempData = [];
let subKeys = Object.keys(data[keys[0]]);
let sub2Keys = Object.keys(data[keys[0]][subKeys[0]]);
for (let i = 0; i < keys.length; i++) {
if (i === 0) {
for (let j = 0; j < subKeys.length; j++) {
for (let k = 0; k < sub2Keys.length; k++) {
let obj = {};
obj.lineName = subKeys[j];
obj.paramsName = sub2Keys[k];
obj[keys[0]] = data[keys[0]][subKeys[j]][sub2Keys[k]];
tempData.push(obj);
}
} }
this.startTimeStamp = this.timeFun(new Date(fullyear, timeStamp, 1, 7, 0, 1).getTime()); // } else {
this.endTimeStamp = this.timeFun(new Date(fullyear, timeStamp, days, 7, 0, 0).getTime()); // for (let j = 0; j < subKeys.length; j++) {
console.log(this.startTimeStamp, this.endTimeStamp) for (let k = 0; k < sub2Keys.length; k++) {
this.listQuery.reportTime[0] = parseTime(new Date(fullyear, timeStamp, 1, 7, 0, 1).getTime()) //+ ' 00:00:00' //new Date(this.startTimeStamp + ' 00:00:00').getTime() / 1000 for (let v = 0; v < tempData.length; v++) {
this.listQuery.reportTime[1] = parseTime(new Date(fullyear, timeStamp, days, 7, 0, 0).getTime()) //+ ' 23:59:59' //new Date(this.endTimeStamp + ' 23:59:59').getTime() / 1000 if (
} else { tempData[v].lineName === subKeys[j] &&
this.listQuery.reportTime = [] tempData[v].paramsName === sub2Keys[k]
) {
tempData[v][keys[i]] = data[keys[i]][subKeys[j]][sub2Keys[k]];
}
}
}
}
}
}
this.tableData1 = tempData;
this.getSpanArr1(this.tableData1);
},
//
buildTableData(data) {
let keys = Object.keys(data);
let tempData = [];
let subKeys = Object.keys(data[keys[0]]);
let sub2Keys = Object.keys(data[keys[0]][subKeys[0]]);
for (let i = 0; i < keys.length; i++) {
if (i === 0) {
for (let j = 0; j < subKeys.length; j++) {
for (let k = 0; k < sub2Keys.length; k++) {
let obj = {};
obj.lineName = subKeys[j];
obj.paramsName = sub2Keys[k];
obj[keys[0]] = data[keys[0]][subKeys[j]][sub2Keys[k]];
tempData.push(obj);
}
}
} else {
for (let j = 0; j < subKeys.length; j++) {
for (let k = 0; k < sub2Keys.length; k++) {
for (let v = 0; v < tempData.length; v++) {
if (
tempData[v].lineName === subKeys[j] &&
tempData[v].paramsName === sub2Keys[k]
) {
tempData[v][keys[i]] = data[keys[i]][subKeys[j]][sub2Keys[k]];
}
}
}
}
}
}
this.tableData = tempData;
this.getSpanArr(this.tableData);
},
getSpanArr1(data) {
this.span2 = [];
for (var i = 0; i < data.length; i++) {
if (i === 0) {
this.span2.push(1);
this.index1 = 0;
} else {
if (data[i].lineName === data[i - 1].lineName) {
this.span2[this.index1] += 1;
this.span2.push(0);
} else {
this.span2.push(1);
this.index1 = i;
}
}
} }
}, },
//yy-mm-dd hh:mm:ss //
timeFun(unixtimestamp) { getSpanArr(data) {
var unixtimestamp = new Date(unixtimestamp); this.span1 = [];
var year = 1900 + unixtimestamp.getYear(); for (var i = 0; i < data.length; i++) {
var month = "0" + (unixtimestamp.getMonth() + 1); if (i === 0) {
var date = "0" + unixtimestamp.getDate(); this.span1.push(1);
return year + "-" + month.substring(month.length - 2, month.length) + "-" + date.substring(date.length - 2, date.length) this.index = 0;
} } else {
} if (data[i].lineName === data[i - 1].lineName) {
} this.span1[this.index] += 1;
this.span1.push(0);
} else {
this.span1.push(1);
this.index = i;
}
}
}
},
objectSpanMethod1({ rowIndex, columnIndex }) {
if (columnIndex === 0) {
const _row = this.span1[rowIndex];
return {
rowspan: _row,
colspan: 1,
};
}
},
handleExport() {
const xlsxParam = { raw: true };
let tables = document.querySelector('.el-table').cloneNode(true)
const fix = tables.querySelector('.el-table__fixed')
const fixRight = tables.querySelector('.el-table__fixed-right')
if (fix) {
tables.removeChild(tables.querySelector('.el-table__fixed'))
}
if (fixRight) {
tables.removeChild(tables.querySelector('.el-table__fixed-right'))
}
let workbook = XLSX.utils.book_new();
var ws = XLSX.utils.table_to_sheet(
tables,
xlsxParam
);
XLSX.utils.book_append_sheet(workbook, ws, '许昌安彩月原片生产汇总');
let tables1 = document.querySelectorAll('.el-table')[1].cloneNode(true)
const fix1 = tables1.querySelector('.el-table__fixed')
const fixRight1 = tables1.querySelector('.el-table__fixed-right')
if (fix1) {
tables1.removeChild(fix1)
}
if (fixRight1) {
tables1.removeChild(fixRight1)
}
var prows = XLSX.utils.table_to_sheet(
tables1,
xlsxParam
);
XLSX.utils.book_append_sheet(workbook, prows, '许昌安彩月成品生产汇总');
let fileName = '生产数据汇总表-月报.xlsx';
var wbout = XLSX.write(workbook, {
bookType: 'xlsx',
bookSST: true,
type: 'array',
});
try {
FileSaver.saveAs(
new Blob([wbout], { type: 'application/octet-stream' }),
fileName
);
this.$message.success('导出成功');
} catch (e) {
if (typeof console !== 'undefined') console.log(e, wbout);
}
return wbout;
},
handleEmitFun(payload) {
console.log('payload', payload);
},
},
};
</script> </script>
<style scoped> <style scoped>
.weekly { .weekly {
padding-top: 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>

View File

@ -1,7 +1,7 @@
<!-- <!--
* @Author: Do not edit * @Author: Do not edit
* @Date: 2024-04-22 15:49:56 * @Date: 2024-04-22 15:49:56
* @LastEditTime: 2024-04-23 15:43:36 * @LastEditTime: 2024-04-24 15:28:44
* @LastEditors: DY * @LastEditors: DY
* @Description: * @Description:
--> -->
@ -28,7 +28,9 @@
<script> <script>
import glassWeek from '../glass/weekly.vue' import glassWeek from '../glass/weekly.vue'
import proWeek from '../productionWeekReport/index.vue' import proWeek from '../productionWeekReport/index.vue'
import { parseTime } from '../../core/mixins/code-filter'; import { parseTime } from '../../core/mixins/code-filter'
import FileSaver from 'file-saver'
import * as XLSX from 'xlsx/xlsx.mjs'
export default { export default {
components: { glassWeek, proWeek }, components: { glassWeek, proWeek },
@ -45,7 +47,8 @@ export default {
endTimeStamp: '', endTimeStamp: '',
reportTime: '', reportTime: '',
glassWeekShow: false, glassWeekShow: false,
proWeekShow: false proWeekShow: false,
proTabaleData: []
} }
}, },
created() { created() {
@ -54,11 +57,35 @@ export default {
this.proWeekShow = true this.proWeekShow = true
}, },
methods: { methods: {
// handleExport() {
// this.$nextTick(() => {
// this.$refs['glassWeek'].handleExport()
// this.$refs['proWeek'].handleExport()
// })
// },
handleExport() { handleExport() {
this.$nextTick(() => { const xlsxParam = { raw: true }
this.$refs['glassWeek'].handleExport() let workbook = XLSX.utils.book_new()
this.$refs['proWeek'].handleExport() var ws = XLSX.utils.table_to_sheet( document.querySelector('#exportTable'), 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, prows, '许昌安彩周成品生产汇总')
let fileName = '生产数据汇总表-周报.xlsx';
var wbout = XLSX.write(workbook, {
bookType: 'xlsx',
bookSST: true,
type: 'array',
});
try {
FileSaver.saveAs(
new Blob([wbout], { type: 'application/octet-stream' }),
fileName
);
this.$message.success('导出成功');
} catch (e) {
if (typeof console !== 'undefined') console.log(e, wbout);
}
return wbout;
}, },
search() { search() {
this.$nextTick(() => { this.$nextTick(() => {

View File

@ -1,117 +1,341 @@
<!-- <!--
* @Author: Do not edit * @Author: Do not edit
* @Date: 2024-04-22 15:49:56 * @Date: 2024-04-22 15:49:56
* @LastEditTime: 2024-04-23 17:16:11 * @LastEditTime: 2024-04-25 09:54:39
* @LastEditors: DY * @LastEditors: DY
* @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="reportTime" type="year" size="small" @change="changeTime" :model="listQuery"
:picker-options="{firstDayOfWeek: 1}" :format="'yyyy 年' + '\u3000' + startTimeStamp + '-' + endTimeStamp" class="blueTip">
style="width: 350px" placeholder="选择年"> <el-form-item
</el-date-picker> label="月"
</el-form-item> prop="reportTime">
<el-button v-if="this.$auth.hasPermi('base:report-auto-production:query')" type="primary" size="small" @click="search()"> <el-date-picker
查询 v-model="listQuery.time"
</el-button> value-format="yyyy-MM-dd HH:mm:ss"
<el-button v-if="this.$auth.hasPermiAnd(['base:report-auto-original-glass:export', 'base:report-auto-production:export'])" type="primary" size="small" plain type="year"
@click="handleExport">导出</el-button> size="small"
</el-form> placeholder="选择年"></el-date-picker>
<glassYear v-if="glassYearShow" ref="glassYear" :product="false" :params="listQuery" /> </el-form-item>
<proYear v-if="proYearShow" ref="proYear" :product="false" :params="listQuery" /> <el-button
</div> 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-data="tableData"
:span-method="objectSpanMethod1"
@emitFun="handleEmitFun"
:max-height="tableH" />
<base-table
:table-props="tableProps1"
:table-data="tableData1"
:span-method="objectSpanMethod1"
@emitFun="handleEmitFun"
:max-height="tableH"
style="margin-top: 15px" />
</div>
</template> </template>
<script> <script>
import glassYear from '../glass/year.vue' import { productionYearY, productionYearD } from '@/api/report/glass';
import proYear from '../productionYearReport/index.vue'
import { parseTime } from '../../core/mixins/code-filter'; import { parseTime } from '../../core/mixins/code-filter';
import FileSaver from 'file-saver';
import * as XLSX from 'xlsx/xlsx.mjs';
import tableHeightMixin from '@/mixins/lb/tableHeightMixin';
export default { export default {
components: { glassYear, proYear }, // components: { monthWeek, proMonth },
data() { mixins: [tableHeightMixin],
return { data() {
listQuery: { return {
// pageSize: 10, heightNum: 350,
// pageNo: 1, listQuery: {
// total: 0, time: '',
reportType: 5, },
reportTime: [] // startTimeStamp: '',
}, // endTimeStamp: '',
startTimeStamp: '', // reportTime: '',
endTimeStamp: '', // glassWeekShow: false,
reportTime: '', // proWeekShow: false,
glassYearShow: false, tableData: [],
proYearShow: false tableProps: [],
} tableData1: [],
}, tableProps1: [],
created() { resData: [],
this.getCurrentYearFirst() span1: [], //1
this.glassYearShow = true resData1: [],
this.proYearShow = true span2: []
}, };
methods: { },
handleExport() { created() {
this.$nextTick(() => { let now = new Date()
this.$refs['glassYear'].handleExport() now.setHours(0, 0, 0, 0)
this.$refs['proYear'].handleExport() now.setDate(1)
}) let startOfMonth = now.getTime()
}, let firstDayOfMonth = new Date(startOfMonth)
search() { this.listQuery.time = parseTime(firstDayOfMonth)
this.$nextTick(() => { },
this.$refs['glassYear'].getDataList() mounted() {
this.$refs['proYear'].getDataList() this.getList();
}) },
}, methods: {
changeTime(val) { async getList() {
if(val) { this.tableData = [];
// let timeStamp = val.getTime(); // this.tableProps = [
this.endTimeStamp = this.timeFun(new Date(val.getFullYear(),11, 31, 7, 0, 0).getTime()); // {
this.startTimeStamp = this.timeFun(new Date(val.getFullYear(), 0, 1, 7, 0, 1).getTime()); // prop: 'lineName',
this.listQuery.reportTime[0] = parseTime(new Date(val.getFullYear(), 0, 1, 7, 0, 1).getTime()) //+ ' 00:00:00' //new Date(this.startTimeStamp + ' 00:00:00').getTime() / 1000 label: '',
this.listQuery.reportTime[1] = parseTime(new Date(val.getFullYear(), 11, 31, 7, 0, 0).getTime()) //+ ' 23:59:59' //new Date(this.endTimeStamp + ' 23:59:59').getTime() / 1000 fixed: true,
} else { },
this.listQuery.reportTime = [] {
prop: 'paramsName',
label: '',
fixed: true,
},
];
this.tableData1 = [];
this.tableProps1 = [
{
prop: 'lineName',
label: '',
fixed: true,
},
{
prop: 'paramsName',
label: '',
fixed: true,
},
];
await productionYearY(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);
});
await productionYearD(this.listQuery).then((res) => {
this.resData1 = res.data;
//
Object.keys(this.resData1).forEach((item) => {
this.tableProps1.push({
prop: item,
label: item,
'show-overflow-tooltip': true,
});
});
this.buildTableData1(this.resData1);
});
},
// 2
buildTableData1(data) {
let keys = Object.keys(data);
let tempData = [];
let subKeys = Object.keys(data[keys[0]]);
let sub2Keys = Object.keys(data[keys[0]][subKeys[0]]);
for (let i = 0; i < keys.length; i++) {
if (i === 0) {
for (let j = 0; j < subKeys.length; j++) {
for (let k = 0; k < sub2Keys.length; k++) {
let obj = {};
obj.lineName = subKeys[j];
obj.paramsName = sub2Keys[k];
obj[keys[0]] = data[keys[0]][subKeys[j]][sub2Keys[k]];
tempData.push(obj);
}
}
} else {
for (let j = 0; j < subKeys.length; j++) {
for (let k = 0; k < sub2Keys.length; k++) {
for (let v = 0; v < tempData.length; v++) {
if (
tempData[v].lineName === subKeys[j] &&
tempData[v].paramsName === sub2Keys[k]
) {
tempData[v][keys[i]] = data[keys[i]][subKeys[j]][sub2Keys[k]];
}
}
}
}
}
}
this.tableData1 = tempData;
this.getSpanArr1(this.tableData1);
},
//
buildTableData(data) {
let keys = Object.keys(data);
let tempData = [];
let subKeys = Object.keys(data[keys[0]]);
let sub2Keys = Object.keys(data[keys[0]][subKeys[0]]);
for (let i = 0; i < keys.length; i++) {
if (i === 0) {
for (let j = 0; j < subKeys.length; j++) {
for (let k = 0; k < sub2Keys.length; k++) {
let obj = {};
obj.lineName = subKeys[j];
obj.paramsName = sub2Keys[k];
obj[keys[0]] = data[keys[0]][subKeys[j]][sub2Keys[k]];
tempData.push(obj);
}
}
} else {
for (let j = 0; j < subKeys.length; j++) {
for (let k = 0; k < sub2Keys.length; k++) {
for (let v = 0; v < tempData.length; v++) {
if (
tempData[v].lineName === subKeys[j] &&
tempData[v].paramsName === sub2Keys[k]
) {
tempData[v][keys[i]] = data[keys[i]][subKeys[j]][sub2Keys[k]];
}
}
}
}
}
}
this.tableData = tempData;
this.getSpanArr(this.tableData);
},
getSpanArr1(data) {
this.span2 = [];
for (var i = 0; i < data.length; i++) {
if (i === 0) {
this.span2.push(1);
this.index1 = 0;
} else {
if (data[i].lineName === data[i - 1].lineName) {
this.span2[this.index1] += 1;
this.span2.push(0);
} else {
this.span2.push(1);
this.index1 = i;
}
}
} }
}, },
getCurrentYearFirst() { //
let date = new Date(); getSpanArr(data) {
date.setDate(1); this.span1 = [];
date.setMonth(0); for (var i = 0; i < data.length; i++) {
this.reportTime = date; if (i === 0) {
this.startTimeStamp = this.timeFun(new Date(new Date().getFullYear(), 0, 1,7,0,1).getTime()); // this.span1.push(1);
this.endTimeStamp = this.timeFun(new Date(new Date().getFullYear(), 11, 31, 7, 0, 0).getTime()); // this.index = 0;
this.listQuery.reportTime[0] = parseTime(new Date(new Date().getFullYear(), 0, 1, 7, 0, 1).getTime()) //+ ' 00:00:00' //new Date(this.startTimeStamp + ' 00:00:00').getTime() / 1000 } else {
this.listQuery.reportTime[1] = parseTime(new Date(new Date().getFullYear(), 11, 31, 7, 0, 0).getTime()) //+ ' 23:59:59' //new Date(this.endTimeStamp + ' 23:59:59').getTime() / 100 if (data[i].lineName === data[i - 1].lineName) {
}, this.span1[this.index] += 1;
//yy-mm-dd hh:mm:ss this.span1.push(0);
timeFun(unixtimestamp) { } else {
var unixtimestamp = new Date(unixtimestamp); this.span1.push(1);
var year = 1900 + unixtimestamp.getYear(); this.index = i;
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) }
}, },
} objectSpanMethod1({ rowIndex, columnIndex }) {
} if (columnIndex === 0) {
const _row = this.span1[rowIndex];
return {
rowspan: _row,
colspan: 1,
};
}
},
handleExport() {
const xlsxParam = { raw: true };
let tables = document.querySelector('.el-table').cloneNode(true)
const fix = tables.querySelector('.el-table__fixed')
const fixRight = tables.querySelector('.el-table__fixed-right')
if (fix) {
tables.removeChild(tables.querySelector('.el-table__fixed'))
}
if (fixRight) {
tables.removeChild(tables.querySelector('.el-table__fixed-right'))
}
let workbook = XLSX.utils.book_new();
var ws = XLSX.utils.table_to_sheet(
tables,
xlsxParam
);
XLSX.utils.book_append_sheet(workbook, ws, '许昌安彩年原片生产汇总');
let tables1 = document.querySelectorAll('.el-table')[1].cloneNode(true)
const fix1 = tables1.querySelector('.el-table__fixed')
const fixRight1 = tables1.querySelector('.el-table__fixed-right')
if (fix1) {
tables1.removeChild(tables1.querySelector('.el-table__fixed'))
}
if (fixRight1) {
tables1.removeChild(tables1.querySelector('.el-table__fixed-right'))
}
var prows = XLSX.utils.table_to_sheet(
tables1,
xlsxParam
);
XLSX.utils.book_append_sheet(workbook, prows, '许昌安彩年成品生产汇总');
let fileName = '生产数据汇总表-年报.xlsx';
var wbout = XLSX.write(workbook, {
bookType: 'xlsx',
bookSST: true,
type: 'array',
});
try {
FileSaver.saveAs(
new Blob([wbout], { type: 'application/octet-stream' }),
fileName
);
this.$message.success('导出成功');
} catch (e) {
if (typeof console !== 'undefined') console.log(e, wbout);
}
return wbout;
},
handleEmitFun(payload) {
console.log('payload', payload);
},
},
};
</script> </script>
<style scoped> <style scoped>
.weekly { .weekly {
padding-top: 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>

View File

@ -1,7 +1,7 @@
<!-- <!--
* @Author: zhp * @Author: zhp
* @Date: 2023-12-12 13:45:25 * @Date: 2023-12-12 13:45:25
* @LastEditTime: 2024-04-23 16:58:06 * @LastEditTime: 2024-04-24 15:27:49
* @LastEditors: DY * @LastEditors: DY
* @Description: * @Description:
--> -->
@ -26,7 +26,7 @@
<el-button size="small" v-if="isSave" @click="saveDataList()">保存</el-button> <el-button size="small" v-if="isSave" @click="saveDataList()">保存</el-button>
</el-row> </el-row>
</div> </div>
<el-table id="exportTable" :data="list" style="width: 100%" :header-cell-style="{ <el-table id="exportproductionTable" :data="list" style="width: 100%" :header-cell-style="{
background: '#F2F4F9', background: '#F2F4F9',
color: '#606266' color: '#606266'
}"> }">
@ -496,7 +496,7 @@ export default {
/* 从表生成工作簿对象 */ /* 从表生成工作簿对象 */
import('xlsx').then(excel => { import('xlsx').then(excel => {
var wb = excel.utils.table_to_book( var wb = excel.utils.table_to_book(
document.querySelector("#exportTable"), document.querySelector("#exportproductionTable"),
xlsxParam xlsxParam
); );
/* 获取二进制字符串作为输出 */ /* 获取二进制字符串作为输出 */

View File

@ -1,7 +1,7 @@
<!-- <!--
* @Author: zhp * @Author: zhp
* @Date: 2023-12-12 13:45:25 * @Date: 2023-12-12 13:45:25
* @LastEditTime: 2024-04-23 16:58:12 * @LastEditTime: 2024-04-24 15:29:21
* @LastEditors: DY * @LastEditors: DY
* @Description: * @Description:
--> -->
@ -28,7 +28,7 @@
<el-button size="small" v-if="isSave" @click="saveDataList()">保存</el-button> <el-button size="small" v-if="isSave" @click="saveDataList()">保存</el-button>
</el-row> </el-row>
</div> </div>
<el-table id="exportTable" :data="list" style="width: 100%" :header-cell-style="{ <el-table id="exportproductionTable" :data="list" style="width: 100%" :header-cell-style="{
background: '#F2F4F9', background: '#F2F4F9',
color: '#606266' color: '#606266'
}"> }">
@ -517,7 +517,7 @@ export default {
/* 从表生成工作簿对象 */ /* 从表生成工作簿对象 */
import('xlsx').then(excel => { import('xlsx').then(excel => {
var wb = excel.utils.table_to_book( var wb = excel.utils.table_to_book(
document.querySelector("#exportTable"), document.querySelector("#exportproductionTable"),
xlsxParam xlsxParam
); );
/* 获取二进制字符串作为输出 */ /* 获取二进制字符串作为输出 */

View File

@ -1,7 +1,7 @@
<!-- <!--
* @Author: zhp * @Author: zhp
* @Date: 2023-12-12 13:45:25 * @Date: 2023-12-12 13:45:25
* @LastEditTime: 2024-04-23 17:21:04 * @LastEditTime: 2024-04-24 15:28:10
* @LastEditors: DY * @LastEditors: DY
* @Description: * @Description:
--> -->
@ -30,7 +30,7 @@
<el-button size="small" v-if="isSave" @click="saveDataList()">保存</el-button> <el-button size="small" v-if="isSave" @click="saveDataList()">保存</el-button>
</el-row> </el-row>
</div> </div>
<el-table id="exportTable" :data="list" style="width: 100%" :header-cell-style="{ <el-table id="exportproductionTable" :data="list" style="width: 100%" :header-cell-style="{
background: '#F2F4F9', background: '#F2F4F9',
color: '#606266' color: '#606266'
}"> }">
@ -452,7 +452,7 @@ export default {
/* 从表生成工作簿对象 */ /* 从表生成工作簿对象 */
import('xlsx').then(excel => { import('xlsx').then(excel => {
var wb = excel.utils.table_to_book( var wb = excel.utils.table_to_book(
document.querySelector("#exportTable"), document.querySelector("#exportproductionTable"),
xlsxParam xlsxParam
); );
/* 获取二进制字符串作为输出 */ /* 获取二进制字符串作为输出 */