质量检验报表-导出全部数据

This commit is contained in:
2024-05-11 15:24:22 +08:00
parent 4c9fb794a7
commit 43935ea410
2 changed files with 257 additions and 261 deletions

View File

@@ -1,41 +1,51 @@
import request from '@/utils/request'
// 获取首检表
export function GetQualityStatisticsTable_first(query) {
return request({
url: 'mes/qc/statistics/queryQualityStatisticsTable_first',
method: 'get',
params: query,
})
}
return request({
url: 'mes/qc/statistics/queryQualityStatisticsTable_first',
method: 'get',
params: query,
})
}
//获取二检表
export function GetQualityStatisticsTable_again(query) {
return request({
url: 'mes/qc/statistics/queryQualityStatisticsTable_again',
method: 'get',
params: query,
})
}
export function GetQualityStatisticsTable_again(query) {
return request({
url: 'mes/qc/statistics/queryQualityStatisticsTable_again',
method: 'get',
params: query,
})
}
// 获取包装表
export function GetQualityStatisticsTable_final(query) {
return request({
url: 'mes/qc/statistics/queryQualityStatisticsTable_final',
method: 'get',
params: query,
})
}
export function GetQualityStatisticsTable_final(query) {
return request({
url: 'mes/qc/statistics/queryQualityStatisticsTable_final',
method: 'get',
params: query,
})
}
// 获取总表
export function GetQualityStatisticsTable_total(query) {
return request({
url: 'mes/qc/statistics/queryQualityStatisticsTable_total',
method: 'get',
params: query,
})
}
// 删除一条记录
export function deleteStatisticsTable(query) {
return request({
url: 'mes/qc/statistics/delete_statisticsTable',
method: 'get',
params: query,
})
}
export function GetQualityStatisticsTable_total(query) {
return request({
url: 'mes/qc/statistics/queryQualityStatisticsTable_total',
method: 'get',
params: query,
})
}
// 删除一条记录
export function deleteStatisticsTable(query) {
return request({
url: 'mes/qc/statistics/delete_statisticsTable',
method: 'get',
params: query,
})
}
// 根据查询条件导出Excel
export function downloadStatisticsTableExcel(query) {
return request({
url: 'mes/qc/statistics/downloadStatisticsTableExcel',
method: 'get',
params: query,
responseType:'blob'
})
}

View File

@@ -4,25 +4,11 @@
<div>
<el-form :model="search" inline size="mini" label-width="80px">
<el-form-item label="开始日期">
<el-date-picker
:style="{ width: inputWidth }"
v-model="search.starttime"
type="datetime"
placeholder="选择日期时间"
align="right"
:picker-options="pickerOptions"
>
<el-date-picker :style="{ width: inputWidth }" v-model="search.starttime" type="datetime" placeholder="选择日期时间" align="right" :picker-options="pickerOptions">
</el-date-picker>
</el-form-item>
<el-form-item label="结束日期">
<el-date-picker
:style="{ width: inputWidth }"
v-model="search.endtime"
type="datetime"
placeholder="选择日期时间"
align="right"
:picker-options="pickerOptions"
>
<el-date-picker :style="{ width: inputWidth }" v-model="search.endtime" type="datetime" placeholder="选择日期时间" align="right" :picker-options="pickerOptions">
</el-date-picker>
</el-form-item>
<el-form-item label="工单号">
@@ -49,17 +35,12 @@
<el-form-item label=" ">
<el-button size="mini" type="primary" icon="el-icon-search" @click="getList">搜索</el-button>
<el-button size="mini" type="warning" @click="exportDataEvent">EXCEL导出</el-button>
<el-button size="mini" type="warning" @click="exportAllDataEvent">导出全部记录</el-button>
</el-form-item>
</el-form>
</div>
<div style="width: 100%; display: flex; justify-content: flex-end">
<pagination
:pageSizes="[12, 60, 120, 300]"
:total="pagination.total"
:page.sync="pagination.pageNum"
:limit.sync="pagination.pageSize"
@pagination="getList"
/>
<pagination :pageSizes="[12, 60, 120, 300]" :total="pagination.total" :page.sync="pagination.pageNum" :limit.sync="pagination.pageSize" @pagination="getList" />
</div>
<div style="width: 100%">
<div style="font-size: 20px;text-align: center; margin 0 auto">
@@ -67,25 +48,7 @@
</div>
</div>
<!-- 表格部分 -->
<vxe-table
@menu-click="contextMenuClickEvent"
:menu-config="tableMenu"
border
resizable
show-overflow
:header-cell-style="headerCellStyle"
ref="xTable"
:column-config="{ resizable: true }"
:row-config="{ isHover: true, isCurrent: true, height: 20 }"
:loading="loading"
:data="QualityStatisticsTable"
:merge-cells="mergeCells"
:cell-style="cellStyle"
size="mini"
align="center"
max-height="800px"
:export-config="{}"
>
<vxe-table @menu-click="contextMenuClickEvent" :menu-config="tableMenu" border resizable show-overflow :header-cell-style="headerCellStyle" ref="xTable" :column-config="{ resizable: true }" :row-config="{ isHover: true, isCurrent: true, height: 20 }" :loading="loading" :data="QualityStatisticsTable" :merge-cells="mergeCells" :cell-style="cellStyle" size="mini" align="center" max-height="800px" :export-config="{}">
<vxe-colgroup title="订单信息" align="center" fixed="left">
<vxe-column field="workorderId" title="工单号" width="140px" sortable></vxe-column>
<vxe-column field="finishedPartNumber" title="零件号" min-width="120px" :show-overflow="false" sortable></vxe-column>
@@ -211,25 +174,26 @@
</vxe-colgroup>
</vxe-table>
</div>
</template>
<script>
import {
GetQualityStatisticsTable_first,
GetQualityStatisticsTable_again,
GetQualityStatisticsTable_final,
GetQualityStatisticsTable_total,
deleteStatisticsTable,
} from '@/api/qualityManagement/qualityStatistics_V2'
export default {
name: 'qualityStatistics',
data() {
return {
inputWidth: '180px',
pickerOptions: {
shortcuts: [
import {
GetQualityStatisticsTable_first,
GetQualityStatisticsTable_again,
GetQualityStatisticsTable_final,
GetQualityStatisticsTable_total,
deleteStatisticsTable,
downloadStatisticsTableExcel
} from '@/api/qualityManagement/qualityStatistics_V2'
export default {
name: 'qualityStatistics',
data() {
return {
inputWidth: '180px',
pickerOptions: {
shortcuts: [
{
text: '今天',
onClick(picker) {
@@ -251,108 +215,107 @@ export default {
date.setTime(date.getTime() - 3600 * 1000 * 24 * 7)
picker.$emit('pick', date)
},
},
}, ],
},
search: {
starttime: new Date(new Date(new Date().toLocaleDateString()).getTime()),
endtime: new Date(new Date(new Date().toLocaleDateString()).getTime() + 24 * 60 * 60 * 1000 - 1),
team: null,
workorderid: null,
partnumber: null,
reportType: 0,
product_description: '',
},
reportType_options: [
{ label: '首检报表', value: 0 },
{ label: '抛光报表', value: 1 },
{ label: '包装报表', value: 2 },
{ label: '总报表', value: 3 },
],
},
search: {
starttime: new Date(new Date(new Date().toLocaleDateString()).getTime()),
endtime: new Date(new Date(new Date().toLocaleDateString()).getTime() + 24 * 60 * 60 * 1000 - 1),
team: null,
workorderid: null,
partnumber: null,
reportType: 0,
product_description: '',
},
reportType_options: [
{ label: '首检报表', value: 0 },
{ label: '抛光报表', value: 1 },
{ label: '包装报表', value: 2 },
{ label: '总报表', value: 3 },
],
pagination: {
total: 0,
pageNum: 1,
pageSize: 60,
},
realTotal: 0,
loading: false,
QualityStatisticsTable: [],
mergeCells: [
// { row: 0, col: 0, rowspan: 3, colspan: 0 },
// { row: 0, col: 1, rowspan: 3, colspan: 0 },
// { row: 0, col: 2, rowspan: 3, colspan: 0 },
// { row: 0, col: 3, rowspan: 3, colspan: 0 },
// { row: 0, col: 4, rowspan: 3, colspan: 0 },
// { row: 0, col: 5, rowspan: 3, colspan: 0 },
// { row: 0, col: 6, rowspan: 3, colspan: 0 },
// { row: 0, col: 7, rowspan: 3, colspan: 0 },
// { row: 0, col: 8, rowspan: 3, colspan: 0 },
// { row: 0, col: 9, rowspan: 3, colspan: 0 },
// { row: 0, col: 10, rowspan: 3, colspan: 0 },
// { row: 0, col: 11, rowspan: 3, colspan: 0 },
],
// 右键菜单
tableMenu: {
header: {
options: [
[
{ code: 'hideColumn', name: '隐藏列', disabled: false },
{ code: 'showAllColumn', name: '取消所有隐藏列', disabled: false },
],
],
pagination: {
total: 0,
pageNum: 1,
pageSize: 60,
},
body: {
options: [
[
// { code: 'copy', name: '复制', prefixIcon: 'vxe-icon-copy', disabled: false },
// { code: 'reload', name: '刷新', disabled: false },
// { code: 'insertAt', name: '插入', disabled: false },
{ code: 'remove', name: '删除', disabled: false },
// { code: 'save', name: '保存', prefixIcon: 'vxe-icon-save', disabled: false },
{ code: 'update', name: '修改', disabled: false },
realTotal: 0,
loading: false,
QualityStatisticsTable: [],
mergeCells: [
// { row: 0, col: 0, rowspan: 3, colspan: 0 },
// { row: 0, col: 1, rowspan: 3, colspan: 0 },
// { row: 0, col: 2, rowspan: 3, colspan: 0 },
// { row: 0, col: 3, rowspan: 3, colspan: 0 },
// { row: 0, col: 4, rowspan: 3, colspan: 0 },
// { row: 0, col: 5, rowspan: 3, colspan: 0 },
// { row: 0, col: 6, rowspan: 3, colspan: 0 },
// { row: 0, col: 7, rowspan: 3, colspan: 0 },
// { row: 0, col: 8, rowspan: 3, colspan: 0 },
// { row: 0, col: 9, rowspan: 3, colspan: 0 },
// { row: 0, col: 10, rowspan: 3, colspan: 0 },
// { row: 0, col: 11, rowspan: 3, colspan: 0 },
],
// 右键菜单
tableMenu: {
header: {
options: [
[
{ code: 'hideColumn', name: '隐藏列', disabled: false },
{ code: 'showAllColumn', name: '取消所有隐藏列', disabled: false },
],
],
],
},
body: {
options: [
[
// { code: 'copy', name: '复制', prefixIcon: 'vxe-icon-copy', disabled: false },
// { code: 'reload', name: '刷新', disabled: false },
// { code: 'insertAt', name: '插入', disabled: false },
{ code: 'remove', name: '删除', disabled: false },
// { code: 'save', name: '保存', prefixIcon: 'vxe-icon-save', disabled: false },
{ code: 'update', name: '修改', disabled: false },
],
],
},
visibleMethod: this.visibleMethod,
},
visibleMethod: this.visibleMethod,
},
}
},
mounted() {
this.getList()
},
created() {},
methods: {
//todo 设置表合并行
mergeTable(num) {
this.mergeCells = []
for (let i = 0; i < this.QualityStatisticsTable.length; i = i + num) {
this.mergeCells.push({ row: i, col: 0, rowspan: num, colspan: 0 })
this.mergeCells.push({ row: i, col: 1, rowspan: num, colspan: 0 })
this.mergeCells.push({ row: i, col: 2, rowspan: num, colspan: 0 })
this.mergeCells.push({ row: i, col: 3, rowspan: num, colspan: 0 })
this.mergeCells.push({ row: i, col: 4, rowspan: num, colspan: 0 })
this.mergeCells.push({ row: i, col: 5, rowspan: num, colspan: 0 })
this.mergeCells.push({ row: i, col: 6, rowspan: num, colspan: 0 })
this.mergeCells.push({ row: i, col: 7, rowspan: num, colspan: 0 })
this.mergeCells.push({ row: i, col: 8, rowspan: num, colspan: 0 })
this.mergeCells.push({ row: i, col: 9, rowspan: num, colspan: 0 })
this.mergeCells.push({ row: i, col: 10, rowspan: num, colspan: 0 })
this.mergeCells.push({ row: i, col: 11, rowspan: num, colspan: 0 })
this.mergeCells.push({ row: i, col: 12, rowspan: num, colspan: 0 })
}
},
mounted() {
this.getList()
},
created() {},
methods: {
//todo 设置表合并行
mergeTable(num) {
this.mergeCells = []
for (let i = 0; i < this.QualityStatisticsTable.length; i = i + num) {
this.mergeCells.push({ row: i, col: 0, rowspan: num, colspan: 0 })
this.mergeCells.push({ row: i, col: 1, rowspan: num, colspan: 0 })
this.mergeCells.push({ row: i, col: 2, rowspan: num, colspan: 0 })
this.mergeCells.push({ row: i, col: 3, rowspan: num, colspan: 0 })
this.mergeCells.push({ row: i, col: 4, rowspan: num, colspan: 0 })
this.mergeCells.push({ row: i, col: 5, rowspan: num, colspan: 0 })
this.mergeCells.push({ row: i, col: 6, rowspan: num, colspan: 0 })
this.mergeCells.push({ row: i, col: 7, rowspan: num, colspan: 0 })
this.mergeCells.push({ row: i, col: 8, rowspan: num, colspan: 0 })
this.mergeCells.push({ row: i, col: 9, rowspan: num, colspan: 0 })
this.mergeCells.push({ row: i, col: 10, rowspan: num, colspan: 0 })
this.mergeCells.push({ row: i, col: 11, rowspan: num, colspan: 0 })
this.mergeCells.push({ row: i, col: 12, rowspan: num, colspan: 0 })
}
},
//todo 获取统计数据
getList() {
this.loading = true
setTimeout(() => {
this.loading = false
}, 30000)
let query = { ...this.search, ...this.pagination }
delete query['reportType']
delete query['total']
console.log('query', query)
switch (this.search.reportType) {
//todo 获取统计数据
getList() {
this.loading = true
setTimeout(() => {
this.loading = false
}, 30000)
let query = { ...this.search, ...this.pagination }
delete query['reportType']
delete query['total']
console.log('query', query)
switch (this.search.reportType) {
case 0:
GetQualityStatisticsTable_first(query).then((res) => {
if (res.code == 200) {
@@ -397,50 +360,73 @@ export default {
}
})
break
}
},
}
},
//todo 设置表头颜色
headerCellStyle() {
return {
backgroundColor: '#2D3D51',
color: '#ffffff',
border: '1px solid #161823',
fontSize: '18px',
}
},
//todo 设置表头颜色
headerCellStyle() {
return {
backgroundColor: '#2D3D51',
color: '#ffffff',
border: '1px solid #161823',
fontSize: '18px',
}
},
cellStyle() {
return {
border: '1px solid #161823',
fontSize: '16px',
fontWeight: '700',
}
},
cellStyle() {
return {
border: '1px solid #161823',
fontSize: '16px',
fontWeight: '700',
}
},
//todo 导出excel
exportDataEvent() {
this.$refs.xTable.openExport()
},
// 合格率去除小数
offsetRate(num) {
if (num === null) {
return ''
}
return parseInt(num)
},
// 数据去除0
offsetValue(num) {
if (num === 0 || num === '0') {
return ''
}
return num
},
// 右键菜单
contextMenuClickEvent({ menu, row, column }) {
const $table = this.$refs.xTable
switch (menu.code) {
//todo 导出excel
exportDataEvent() {
this.$refs.xTable.openExport()
},
// 导出全部数据
exportAllDataEvent() {
let data = { ...this.search, ...this.pagination };
data.type = this.search.reportType + 1;
data.isShowDetail = false;
let fileName = this.reportType_options[this.search.reportType].label + '.xlsx';
downloadStatisticsTableExcel(data).then(res => {
console.log(res);
let blobURL = URL.createObjectURL(res.data)
//创建标签
let link = document.createElement('a')
//设置href
link.href = blobURL
//设置a标签的行为是download,不然就跳转了,同时设置名字是"test.ppt"
link.download = fileName;
//隐藏a标签他只是下载没必要出现
link.style.display = "none"
//模拟点击
link.click()
//最后把这个URL进行销毁,免得他占内存
URL.revokeObjectURL()
})
// this.download('/mes/qc/statistics/downloadStatisticsTableExcel');
},
// 合格率去除小数
offsetRate(num) {
if (num === null) {
return ''
}
return parseInt(num)
},
// 数据去除0
offsetValue(num) {
if (num === 0 || num === '0') {
return ''
}
return num
},
// 右键菜单
contextMenuClickEvent({ menu, row, column }) {
const $table = this.$refs.xTable
switch (menu.code) {
case 'hideColumn':
$table.hideColumn(column)
break
@@ -453,42 +439,42 @@ export default {
case 'update':
this.updateData(row)
break
}
},
// 删除数据
removeData(row) {
this.$confirm('此操作将永久删除该条记录, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
}).then(() => {
const deleteData = {
workorderid: row.workorderId,
}
deleteStatisticsTable(deleteData).then((res) => {
if (res.code === 200) {
this.$message({
type: 'success',
message: '删除成功!',
})
this.getList()
} else {
this.$message({
type: 'error',
message: '删除失败!请检查!',
})
},
// 删除数据
removeData(row) {
this.$confirm('此操作将永久删除该条记录, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
}).then(() => {
const deleteData = {
workorderid: row.workorderId,
}
deleteStatisticsTable(deleteData).then((res) => {
if (res.code === 200) {
this.$message({
type: 'success',
message: '删除成功!',
})
this.getList()
} else {
this.$message({
type: 'error',
message: '删除失败!请检查!',
})
}
})
})
})
},
//修改数据
updateDate(row) {
}
},
//修改数据
updateDate(row){
}
},
}
}
</script>
<style lang="scss" scoped></style>
<style lang="scss" scoped></style>