2026-03-09 13:06:30 +08:00
|
|
|
|
<template>
|
|
|
|
|
|
<div class="app-container">
|
|
|
|
|
|
<el-row :gutter="10">
|
|
|
|
|
|
<el-col :span="6">
|
|
|
|
|
|
<LeftList ref="leftList" @add="handleAdd" @select="handleSelect" />
|
|
|
|
|
|
</el-col>
|
|
|
|
|
|
|
2026-03-10 15:38:22 +08:00
|
|
|
|
<el-col :span="18" style="position: relative;">
|
|
|
|
|
|
<ul style="float: right; position: absolute; right: 0; top: 0; z-index: 100;">
|
|
|
|
|
|
<li v-show="currentRow.attachmentInfo" @click="handleDownload(currentRow)"><el-button
|
|
|
|
|
|
icon="el-icon-download">下载明细</el-button></li>
|
|
|
|
|
|
</ul>
|
2026-03-09 13:06:30 +08:00
|
|
|
|
<div style="height: calc(100vh - 124px); overflow-y: scroll; overflow-x: hidden;">
|
|
|
|
|
|
<div v-if="currentRow.summaryId">
|
2026-03-09 16:07:07 +08:00
|
|
|
|
<Preview :data="currentRow.statJson" :statType="currentRow.statType" />
|
2026-03-09 13:06:30 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
<div v-else>
|
2026-03-10 17:02:11 +08:00
|
|
|
|
<div>
|
|
|
|
|
|
<el-empty description="请点击左侧列表查看或创建透视表" />
|
|
|
|
|
|
</div>
|
2026-03-09 13:06:30 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</el-col>
|
|
|
|
|
|
</el-row>
|
|
|
|
|
|
|
2026-03-10 15:38:22 +08:00
|
|
|
|
<el-dialog v-loading="previewLoading" title="效果预览" :visible.sync="previewOpen" width="80vw" append-to-body>
|
|
|
|
|
|
<div>
|
|
|
|
|
|
<el-button type="primary" @click="handleSave" :loading="buttonLoading">保存</el-button>
|
|
|
|
|
|
<!-- <el-button type="primary" @click="handleDetail" :loading="buttonLoading">查看明细</el-button> -->
|
|
|
|
|
|
<el-checkbox style="margin-left: 10px;" v-model="saveDetail"
|
|
|
|
|
|
label="orderBy">保存透视表时保存明细,勾选后在保存时会消耗更长的时间且会占用更多内存和存储</el-checkbox>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div style="height: calc(100vh - 300px); overflow-y: scroll; overflow-x: hidden;">
|
2026-03-10 16:18:21 +08:00
|
|
|
|
<div v-if="liveData">
|
2026-03-10 15:38:22 +08:00
|
|
|
|
<Preview :data="liveData" :statType="form.statType" />
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div v-else>
|
2026-03-10 17:02:11 +08:00
|
|
|
|
<div>
|
|
|
|
|
|
<el-empty description="未知的透视表" />
|
|
|
|
|
|
</div>
|
2026-03-10 15:38:22 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
2026-03-09 13:06:30 +08:00
|
|
|
|
</el-dialog>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script>
|
2026-03-10 17:02:11 +08:00
|
|
|
|
import { getCoilStatisticsSummary, delCoilStatisticsSummary, addCoilStatisticsSummary, updateCoilStatisticsSummary, checkCoilStatisticsSummaryExist } from "@/api/wms/coilStatisticsSummary";
|
2026-03-09 13:06:30 +08:00
|
|
|
|
import LeftList from "./components/LeftList.vue";
|
|
|
|
|
|
import Preview from "@/views/wms/coil/panels/Perspective/index.vue";
|
|
|
|
|
|
|
|
|
|
|
|
import { listRawMaterialPerspective } from "@/api/wms/rawMaterial";
|
2026-03-10 15:38:22 +08:00
|
|
|
|
import { uploadFile } from "@/api/system/oss";
|
|
|
|
|
|
import { listCoilTrimStatistics, categoryWidthStatistics, listMaterialCoil, exportCoilWithAll } from "@/api/wms/coil";
|
2026-03-09 13:06:30 +08:00
|
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
|
name: "CoilStatisticsSummary",
|
|
|
|
|
|
components: {
|
|
|
|
|
|
LeftList,
|
|
|
|
|
|
Preview
|
|
|
|
|
|
},
|
|
|
|
|
|
data() {
|
|
|
|
|
|
return {
|
|
|
|
|
|
// 按钮loading
|
|
|
|
|
|
buttonLoading: false,
|
|
|
|
|
|
// 遮罩层
|
|
|
|
|
|
loading: true,
|
|
|
|
|
|
// 选中数组
|
|
|
|
|
|
ids: [],
|
|
|
|
|
|
// 非单个禁用
|
|
|
|
|
|
single: true,
|
|
|
|
|
|
// 非多个禁用
|
|
|
|
|
|
multiple: true,
|
|
|
|
|
|
// 显示搜索条件
|
|
|
|
|
|
showSearch: true,
|
|
|
|
|
|
// 总条数
|
|
|
|
|
|
total: 0,
|
|
|
|
|
|
// 钢卷生产统计表格数据
|
|
|
|
|
|
coilStatisticsSummaryList: [],
|
|
|
|
|
|
// 弹出层标题
|
|
|
|
|
|
title: "",
|
|
|
|
|
|
// 是否显示弹出层
|
|
|
|
|
|
open: false,
|
|
|
|
|
|
// 查询参数
|
|
|
|
|
|
queryParams: {
|
|
|
|
|
|
pageNum: 1,
|
|
|
|
|
|
pageSize: 10,
|
|
|
|
|
|
title: undefined,
|
|
|
|
|
|
statType: undefined,
|
|
|
|
|
|
},
|
2026-03-10 15:38:22 +08:00
|
|
|
|
saveDetail: false,
|
2026-03-09 13:06:30 +08:00
|
|
|
|
// 表单参数
|
|
|
|
|
|
form: {},
|
|
|
|
|
|
// 表单校验
|
|
|
|
|
|
rules: {
|
|
|
|
|
|
},
|
|
|
|
|
|
previewLoading: false,
|
|
|
|
|
|
previewOpen: false,
|
2026-03-09 16:07:07 +08:00
|
|
|
|
liveData: [],
|
2026-03-09 13:06:30 +08:00
|
|
|
|
currentRow: {},
|
|
|
|
|
|
};
|
|
|
|
|
|
},
|
|
|
|
|
|
methods: {
|
|
|
|
|
|
// 取消按钮
|
|
|
|
|
|
cancel() {
|
|
|
|
|
|
this.open = false;
|
|
|
|
|
|
this.reset();
|
|
|
|
|
|
},
|
|
|
|
|
|
// 表单重置
|
|
|
|
|
|
reset() {
|
|
|
|
|
|
this.form = {
|
|
|
|
|
|
summaryId: undefined,
|
|
|
|
|
|
title: undefined,
|
|
|
|
|
|
statType: undefined,
|
|
|
|
|
|
statJson: undefined,
|
|
|
|
|
|
remark: undefined,
|
|
|
|
|
|
createBy: undefined,
|
|
|
|
|
|
createTime: undefined,
|
|
|
|
|
|
updateBy: undefined,
|
|
|
|
|
|
updateTime: undefined,
|
|
|
|
|
|
delFlag: undefined
|
|
|
|
|
|
};
|
|
|
|
|
|
this.resetForm("form");
|
|
|
|
|
|
},
|
|
|
|
|
|
/** 搜索按钮操作 */
|
|
|
|
|
|
handleQuery() {
|
|
|
|
|
|
this.queryParams.pageNum = 1;
|
|
|
|
|
|
this.getList();
|
|
|
|
|
|
},
|
|
|
|
|
|
/** 重置按钮操作 */
|
|
|
|
|
|
resetQuery() {
|
|
|
|
|
|
this.resetForm("queryForm");
|
|
|
|
|
|
this.handleQuery();
|
|
|
|
|
|
},
|
|
|
|
|
|
// 多选框选中数据
|
|
|
|
|
|
handleSelect(row) {
|
|
|
|
|
|
this.currentRow = {
|
|
|
|
|
|
...row,
|
|
|
|
|
|
statJson: JSON.parse(row.statJson)
|
|
|
|
|
|
};
|
|
|
|
|
|
},
|
|
|
|
|
|
/** 新增按钮操作 */
|
2026-03-10 17:02:11 +08:00
|
|
|
|
async handleAdd(form) {
|
2026-03-09 13:06:30 +08:00
|
|
|
|
this.form = form;
|
2026-03-10 17:02:11 +08:00
|
|
|
|
// 先检查今天是否已经创建过该类型的透视表
|
|
|
|
|
|
const {data: existingSummary} = await checkCoilStatisticsSummaryExist(form.statType);
|
|
|
|
|
|
// 如果已经创建过
|
|
|
|
|
|
if (existingSummary) {
|
|
|
|
|
|
// 先提示是否继续创建
|
|
|
|
|
|
try {
|
|
|
|
|
|
await this.$confirm('该类型已存在透视表,是否继续创建?', '提示', {
|
|
|
|
|
|
confirmButtonText: '确定',
|
|
|
|
|
|
cancelButtonText: '取消',
|
|
|
|
|
|
type: 'warning'
|
|
|
|
|
|
});
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
// 如果要继续创建,则提示是否要覆盖已经存在的透视表
|
|
|
|
|
|
try {
|
|
|
|
|
|
await this.$confirm('是否覆盖已存在的透视表?', '提示', {
|
|
|
|
|
|
confirmButtonText: '删除并重新创建',
|
|
|
|
|
|
cancelButtonText: '保留已有透视表',
|
|
|
|
|
|
type: 'warning'
|
|
|
|
|
|
});
|
|
|
|
|
|
delCoilStatisticsSummary(existingSummary).then(() => {
|
|
|
|
|
|
this.$modal.msgSuccess("删除成功");
|
|
|
|
|
|
this.getList();
|
|
|
|
|
|
});
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
this.previewOpen = true;
|
|
|
|
|
|
|
2026-03-09 13:06:30 +08:00
|
|
|
|
if (form.statType == '热轧原料') {
|
|
|
|
|
|
this.previewLoading = true;
|
|
|
|
|
|
listRawMaterialPerspective().then(response => {
|
|
|
|
|
|
const data = response.data;
|
|
|
|
|
|
// 处理数据
|
|
|
|
|
|
const filteredData = data.filter(manufacturer => {
|
|
|
|
|
|
// 确保manufacturer和其materials存在
|
|
|
|
|
|
if (!manufacturer || !Array.isArray(manufacturer.materials)) {
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
// 过滤材质:totalCoilCount > 0
|
|
|
|
|
|
manufacturer.materials = manufacturer.materials.filter(material => {
|
|
|
|
|
|
// 确保material和其specifications存在
|
|
|
|
|
|
if (!material || !Array.isArray(material.specifications)) {
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
// 过滤规格:coilCount > 0
|
|
|
|
|
|
material.specifications = material.specifications.filter(spec => spec.coilCount > 0);
|
|
|
|
|
|
// 只有当规格数组不为空时,才保留该材质
|
|
|
|
|
|
return material.specifications.length > 0;
|
|
|
|
|
|
});
|
|
|
|
|
|
// 只有当材质数组不为空时,才保留该厂家
|
|
|
|
|
|
return manufacturer.materials.length > 0;
|
|
|
|
|
|
});
|
|
|
|
|
|
this.liveData = filteredData;
|
|
|
|
|
|
}).finally(() => {
|
|
|
|
|
|
this.previewLoading = false;
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
2026-03-09 16:07:07 +08:00
|
|
|
|
else if (form.statType == '冷硬卷板') {
|
|
|
|
|
|
this.previewLoading = true;
|
|
|
|
|
|
listCoilTrimStatistics().then(response => {
|
|
|
|
|
|
this.liveData = response.data;
|
|
|
|
|
|
}).finally(() => {
|
|
|
|
|
|
this.previewLoading = false;
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (form.statType == '汇总') {
|
|
|
|
|
|
this.previewLoading = true;
|
|
|
|
|
|
categoryWidthStatistics().then(response => {
|
|
|
|
|
|
this.liveData = response.data;
|
|
|
|
|
|
}).finally(() => {
|
|
|
|
|
|
this.previewLoading = false;
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
else {
|
|
|
|
|
|
this.$modal.msgError("未知类型");
|
|
|
|
|
|
}
|
|
|
|
|
|
this.previewLoading = false;
|
2026-03-09 13:06:30 +08:00
|
|
|
|
},
|
2026-03-10 15:38:22 +08:00
|
|
|
|
async handleSave() {
|
|
|
|
|
|
const loading = this.$loading({
|
|
|
|
|
|
lock: true,
|
|
|
|
|
|
text: '保存中...',
|
|
|
|
|
|
background: 'rgba(0, 0, 0, 0.7)'
|
|
|
|
|
|
})
|
|
|
|
|
|
try {
|
|
|
|
|
|
this.buttonLoading = true;
|
|
|
|
|
|
|
|
|
|
|
|
const { data: summary } = await addCoilStatisticsSummary({
|
|
|
|
|
|
...this.form,
|
|
|
|
|
|
statJson: JSON.stringify(this.liveData)
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
if (this.saveDetail) {
|
|
|
|
|
|
// 获取原始数据,组装coilIds,
|
|
|
|
|
|
let coilIds = ''
|
|
|
|
|
|
if (this.form.statType == '热轧原料') {
|
|
|
|
|
|
const { rows: coils } = await listMaterialCoil({
|
|
|
|
|
|
pageNum: 1,
|
|
|
|
|
|
pageSize: 9999,
|
|
|
|
|
|
selectType: 'raw_material',
|
|
|
|
|
|
dataType: 1,
|
|
|
|
|
|
status: 0,
|
|
|
|
|
|
itemName: '热轧卷板',
|
|
|
|
|
|
itemType: 'raw_material',
|
|
|
|
|
|
})
|
|
|
|
|
|
coilIds = coils.map(item => item.coilId).join(',')
|
|
|
|
|
|
} else if (this.form.statType == '冷硬卷板') {
|
|
|
|
|
|
const { rows: coils1 } = await listMaterialCoil({
|
|
|
|
|
|
pageNum: 1,
|
|
|
|
|
|
pageSize: 9999,
|
|
|
|
|
|
selectType: 'raw_material',
|
|
|
|
|
|
dataType: 1,
|
|
|
|
|
|
status: 0,
|
|
|
|
|
|
itemName: '冷硬卷',
|
|
|
|
|
|
itemType: 'raw_material',
|
|
|
|
|
|
})
|
2026-03-10 16:18:21 +08:00
|
|
|
|
const { rows: coils2 } = await listMaterialCoil({
|
2026-03-10 15:38:22 +08:00
|
|
|
|
pageNum: 1,
|
|
|
|
|
|
pageSize: 9999,
|
|
|
|
|
|
selectType: 'product',
|
|
|
|
|
|
dataType: 1,
|
|
|
|
|
|
status: 0,
|
|
|
|
|
|
itemName: '冷硬卷',
|
2026-03-10 16:18:21 +08:00
|
|
|
|
itemType: 'product',
|
2026-03-10 15:38:22 +08:00
|
|
|
|
})
|
|
|
|
|
|
coilIds = coils1.concat(coils2).map(item => item.coilId).join(',')
|
|
|
|
|
|
} else if (this.form.statType == '汇总') {
|
|
|
|
|
|
const { rows: coils } = await listMaterialCoil({
|
|
|
|
|
|
pageNum: 1,
|
|
|
|
|
|
pageSize: 9999,
|
|
|
|
|
|
dataType: 1,
|
|
|
|
|
|
status: 0,
|
|
|
|
|
|
})
|
|
|
|
|
|
coilIds = coils.map(item => item.coilId).join(',')
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 使用exportCoilWithAll接口传入coilIds获取二进制文件数据
|
|
|
|
|
|
const response = await exportCoilWithAll({
|
|
|
|
|
|
coilIds: coilIds,
|
|
|
|
|
|
})
|
|
|
|
|
|
const file = new Blob([response], { type: 'application/vnd.ms-excel' })
|
|
|
|
|
|
const fileName = this.form.statType + '明细.xlsx'
|
|
|
|
|
|
// 通过new File构建出excel文件
|
|
|
|
|
|
const excelFile = new File([file], fileName, { type: 'application/vnd.ms-excel' })
|
|
|
|
|
|
|
|
|
|
|
|
console.log(excelFile)
|
|
|
|
|
|
// 上传文件到minio
|
|
|
|
|
|
const uploadResponse = await uploadFile(excelFile)
|
|
|
|
|
|
console.log(uploadResponse)
|
|
|
|
|
|
|
|
|
|
|
|
// 关联附件信息
|
|
|
|
|
|
await updateCoilStatisticsSummary({
|
|
|
|
|
|
...summary,
|
|
|
|
|
|
attachmentInfo: uploadResponse.data.ossId,
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
2026-03-09 13:06:30 +08:00
|
|
|
|
this.$modal.msgSuccess("新增成功");
|
|
|
|
|
|
this.open = false;
|
2026-03-10 15:38:22 +08:00
|
|
|
|
this.previewOpen = false;
|
2026-03-09 13:06:30 +08:00
|
|
|
|
this.liveData = [];
|
|
|
|
|
|
this.form = {};
|
|
|
|
|
|
this.$refs.leftList.getList();
|
2026-03-10 15:38:22 +08:00
|
|
|
|
} finally {
|
2026-03-09 13:06:30 +08:00
|
|
|
|
this.buttonLoading = false;
|
2026-03-10 15:38:22 +08:00
|
|
|
|
loading.close();
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
handleDownload(row) {
|
|
|
|
|
|
this.$download.oss(row.attachmentInfo)
|
2026-03-09 13:06:30 +08:00
|
|
|
|
},
|
|
|
|
|
|
/** 修改按钮操作 */
|
|
|
|
|
|
handleUpdate(row) {
|
|
|
|
|
|
this.loading = true;
|
|
|
|
|
|
this.reset();
|
|
|
|
|
|
const summaryId = row.summaryId || this.ids
|
|
|
|
|
|
getCoilStatisticsSummary(summaryId).then(response => {
|
|
|
|
|
|
this.loading = false;
|
|
|
|
|
|
this.form = response.data;
|
|
|
|
|
|
this.open = true;
|
|
|
|
|
|
this.title = "修改钢卷生产统计";
|
|
|
|
|
|
});
|
|
|
|
|
|
},
|
|
|
|
|
|
/** 提交按钮 */
|
|
|
|
|
|
submitForm() {
|
|
|
|
|
|
this.$refs["form"].validate(valid => {
|
|
|
|
|
|
if (valid) {
|
|
|
|
|
|
this.buttonLoading = true;
|
|
|
|
|
|
if (this.form.summaryId != null) {
|
|
|
|
|
|
updateCoilStatisticsSummary(this.form).then(response => {
|
|
|
|
|
|
this.$modal.msgSuccess("修改成功");
|
|
|
|
|
|
this.open = false;
|
|
|
|
|
|
this.getList();
|
|
|
|
|
|
}).finally(() => {
|
|
|
|
|
|
this.buttonLoading = false;
|
|
|
|
|
|
});
|
|
|
|
|
|
} else {
|
|
|
|
|
|
addCoilStatisticsSummary(this.form).then(response => {
|
|
|
|
|
|
this.$modal.msgSuccess("新增成功");
|
|
|
|
|
|
this.open = false;
|
|
|
|
|
|
this.getList();
|
|
|
|
|
|
}).finally(() => {
|
|
|
|
|
|
this.buttonLoading = false;
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
},
|
|
|
|
|
|
/** 删除按钮操作 */
|
|
|
|
|
|
handleDelete(row) {
|
|
|
|
|
|
const summaryIds = row.summaryId || this.ids;
|
|
|
|
|
|
this.$modal.confirm('是否确认删除钢卷生产统计编号为"' + summaryIds + '"的数据项?').then(() => {
|
|
|
|
|
|
this.loading = true;
|
|
|
|
|
|
return delCoilStatisticsSummary(summaryIds);
|
|
|
|
|
|
}).then(() => {
|
|
|
|
|
|
this.loading = false;
|
|
|
|
|
|
this.getList();
|
|
|
|
|
|
this.$modal.msgSuccess("删除成功");
|
|
|
|
|
|
}).catch(() => {
|
|
|
|
|
|
}).finally(() => {
|
|
|
|
|
|
this.loading = false;
|
|
|
|
|
|
});
|
|
|
|
|
|
},
|
|
|
|
|
|
/** 导出按钮操作 */
|
|
|
|
|
|
handleExport() {
|
|
|
|
|
|
this.download('wms/coilStatisticsSummary/export', {
|
|
|
|
|
|
...this.queryParams
|
|
|
|
|
|
}, `coilStatisticsSummary_${new Date().getTime()}.xlsx`)
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
</script>
|