feat(标签系统): 添加脱脂原料库标签类型并优化透视表功能

新增脱脂原料库标签类型6及相关组件TuoZhiTag
优化透视表功能,增加保存明细选项和导出功能
在标签渲染组件中添加对脱脂原料库类型的判断
更新相关API调用和UI交互逻辑
This commit is contained in:
砂糖
2026-03-10 15:38:22 +08:00
parent e937ff50f6
commit 6e909212bf
8 changed files with 465 additions and 24 deletions

View File

@@ -5,7 +5,11 @@
<LeftList ref="leftList" @add="handleAdd" @select="handleSelect" />
</el-col>
<el-col :span="18">
<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>
<div style="height: calc(100vh - 124px); overflow-y: scroll; overflow-x: hidden;">
<div v-if="currentRow.summaryId">
<Preview :data="currentRow.statJson" :statType="currentRow.statType" />
@@ -17,9 +21,21 @@
</el-col>
</el-row>
<el-dialog v-loading="previewLoading" title="效果预览" :visible.sync="previewOpen" width="100vw" fullscreen append-to-body>
<Preview :data="liveData" :statType="form.statType" />
<el-button type="primary" @click="handleSave">保存</el-button>
<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;">
<div v-if="currentRow.summaryId">
<Preview :data="liveData" :statType="form.statType" />
</div>
<div v-else>
<div>钢卷生产统计详情</div>
</div>
</div>
</el-dialog>
</div>
</template>
@@ -30,7 +46,8 @@ import LeftList from "./components/LeftList.vue";
import Preview from "@/views/wms/coil/panels/Perspective/index.vue";
import { listRawMaterialPerspective } from "@/api/wms/rawMaterial";
import { listCoilTrimStatistics, categoryWidthStatistics } from "@/api/wms/coil";
import { uploadFile } from "@/api/system/oss";
import { listCoilTrimStatistics, categoryWidthStatistics, listMaterialCoil, exportCoilWithAll } from "@/api/wms/coil";
export default {
name: "CoilStatisticsSummary",
@@ -67,6 +84,7 @@ export default {
title: undefined,
statType: undefined,
},
saveDetail: false,
// 表单参数
form: {},
// 表单校验
@@ -171,19 +189,97 @@ export default {
}
this.previewLoading = false;
},
handleSave() {
addCoilStatisticsSummary({
...this.form,
statJson: JSON.stringify(this.liveData)
}).then(response => {
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',
})
const { rows: coils2 } = await listCoilTrimStatistics({
pageNum: 1,
pageSize: 9999,
selectType: 'product',
dataType: 1,
status: 0,
itemName: '冷硬卷',
itemType: 'raw_material',
})
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,
});
}
this.$modal.msgSuccess("新增成功");
this.open = false;
this.previewOpen = false;
this.liveData = [];
this.form = {};
this.$refs.leftList.getList();
}).finally(() => {
} finally {
this.buttonLoading = false;
});
loading.close();
}
},
handleDownload(row) {
this.$download.oss(row.attachmentInfo)
},
/** 修改按钮操作 */
handleUpdate(row) {