✨ feat: 机组管理迁移l2代码
This commit is contained in:
@@ -0,0 +1,310 @@
|
||||
<template>
|
||||
<el-form
|
||||
:model="formData"
|
||||
ref="correctionForm"
|
||||
label-width="120px"
|
||||
:rules="formRules"
|
||||
>
|
||||
<el-row :gutter="20">
|
||||
<!-- 成品卷 -->
|
||||
<el-col :span="8">
|
||||
<el-form-item label="成品卷" prop="exitMatId">
|
||||
<el-input v-model="formData.exitMatId"></el-input>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<!-- 来料卷 -->
|
||||
<el-col :span="8">
|
||||
<el-form-item label="来料卷" prop="entryMatId">
|
||||
<el-input v-model="formData.entryMatId"></el-input>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<!-- 分切数 -->
|
||||
<el-col :span="8">
|
||||
<el-form-item label="分切数" prop="subId">
|
||||
<el-input-number size="mini" v-model="formData.subId" :min="0" :step="1" style="width: 100%;"></el-input-number>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<!-- 开始位置 -->
|
||||
<el-col :span="8">
|
||||
<el-form-item label="开始位置" prop="startPosition">
|
||||
<el-input-number size="mini" v-model="formData.startPosition" :step="0.01" style="width: 100%;"></el-input-number>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<!-- 结束位置 -->
|
||||
<el-col :span="8">
|
||||
<el-form-item label="结束位置" prop="endPosition">
|
||||
<el-input-number size="mini" v-model="formData.endPosition" :step="0.01" style="width: 100%;"></el-input-number>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<!-- 计划ID -->
|
||||
<el-col :span="8">
|
||||
<el-form-item label="计划ID" prop="planId">
|
||||
<el-input-number size="mini" v-model="formData.planId" :step="1" style="width: 100%;"></el-input-number>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<!-- 计划号 -->
|
||||
<el-col :span="8">
|
||||
<el-form-item label="计划号" prop="planNo">
|
||||
<el-input size="mini" v-model="formData.planNo"></el-input>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<!-- 产品类型 -->
|
||||
<el-col :span="8">
|
||||
<el-form-item label="产品类型" prop="prodCode">
|
||||
<el-input size="mini" v-model="formData.prodCode"></el-input>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<!-- 班号 -->
|
||||
<el-col :span="8">
|
||||
<el-form-item label="班号" prop="groupNo">
|
||||
<el-input size="mini" v-model="formData.groupNo"></el-input>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<!-- 组号 -->
|
||||
<el-col :span="8">
|
||||
<el-form-item label="组号" prop="shiftNo">
|
||||
<el-input size="mini" v-model="formData.shiftNo"></el-input>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<!-- 状态 -->
|
||||
<el-col :span="8">
|
||||
<el-form-item label="状态" prop="status">
|
||||
<el-input size="mini" v-model="formData.status"></el-input>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<!-- 钢种 -->
|
||||
<el-col :span="8">
|
||||
<el-form-item label="钢种" prop="steelGrade">
|
||||
<el-input size="mini" v-model="formData.steelGrade"></el-input>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<!-- 来料厚度 -->
|
||||
<el-col :span="8">
|
||||
<el-form-item label="来料厚度" prop="entryThick">
|
||||
<el-input-number size="mini" v-model="formData.entryThick" :step="0.01" style="width: 100%;"></el-input-number>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<!-- 来料宽度 -->
|
||||
<el-col :span="8">
|
||||
<el-form-item label="来料宽度" prop="entryWidth">
|
||||
<el-input-number size="mini" v-model="formData.entryWidth" :step="0.01" style="width: 100%;"></el-input-number>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<!-- 来料长度 -->
|
||||
<el-col :span="8">
|
||||
<el-form-item label="来料长度" prop="entryLength">
|
||||
<el-input-number size="mini" v-model="formData.entryLength" :step="0.01" style="width: 100%;"></el-input-number>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<!-- 来料重量 -->
|
||||
<el-col :span="8">
|
||||
<el-form-item label="来料重量" prop="entryWeight">
|
||||
<el-input-number size="mini" v-model="formData.entryWeight" :step="0.01" style="width: 100%;"></el-input-number>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<!-- 上表面镀锌 -->
|
||||
<el-col :span="8">
|
||||
<el-form-item label="上表面镀锌" prop="weightTop">
|
||||
<el-input-number size="mini" v-model="formData.weightTop" :step="0.01" style="width: 100%;"></el-input-number>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<!-- 下表面镀锌 -->
|
||||
<el-col :span="8">
|
||||
<el-form-item label="下表面镀锌" prop="weightBottom">
|
||||
<el-input-number size="mini" v-model="formData.weightBottom" :step="0.01" style="width: 100%;"></el-input-number>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<!-- 成品长度 -->
|
||||
<el-col :span="8">
|
||||
<el-form-item label="成品长度" prop="exitLength">
|
||||
<el-input-number size="mini" v-model="formData.exitLength" :step="0.01" style="width: 100%;"></el-input-number>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<!-- 成品带涂料重量 -->
|
||||
<el-col :span="8">
|
||||
<el-form-item label="成品带涂料重量" prop="exitNetWeight">
|
||||
<el-input-number size="mini" v-model="formData.exitNetWeight" :step="0.01" style="width: 100%;"></el-input-number>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<!-- 理论重量 -->
|
||||
<el-col :span="8">
|
||||
<el-form-item label="理论重量" prop="theoryWeight">
|
||||
<el-input-number size="mini" v-model="formData.theoryWeight" :step="0.01" style="width: 100%;"></el-input-number>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<!-- 实际重量 -->
|
||||
<el-col :span="8">
|
||||
<el-form-item label="实际重量" prop="actualWeight">
|
||||
<el-input-number size="mini" v-model="formData.actualWeight" :step="0.01" style="width: 100%;"></el-input-number>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<!-- 成品外径 -->
|
||||
<el-col :span="8">
|
||||
<el-form-item label="成品外径" prop="exitOuterDiameter">
|
||||
<el-input-number size="mini" v-model="formData.exitOuterDiameter" :step="0.01" style="width: 100%;"></el-input-number>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<!-- 成品厚度 -->
|
||||
<el-col :span="8">
|
||||
<el-form-item label="成品厚度" prop="exitThickness">
|
||||
<el-input-number size="mini" v-model="formData.exitThickness" :step="0.01" style="width: 100%;"></el-input-number>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<!-- 成品宽度 -->
|
||||
<el-col :span="8">
|
||||
<el-form-item label="成品宽度" prop="exitWidth">
|
||||
<el-input-number size="mini" v-model="formData.exitWidth" :step="0.01" style="width: 100%;"></el-input-number>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<!-- 客户 -->
|
||||
<el-col :span="8">
|
||||
<el-form-item label="客户" prop="customer">
|
||||
<el-input size="mini" v-model="formData.customer"></el-input>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<!-- 上线时间 -->
|
||||
<el-col :span="8">
|
||||
<el-form-item label="上线时间" prop="onlineTime">
|
||||
<el-date-picker size="mini" v-model="formData.onlineTime" type="datetime" value-format="yyyy-MM-ddTHH:mm:ss" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<!-- 开始时间 -->
|
||||
<el-col :span="8">
|
||||
<el-form-item label="开始时间" prop="startTime">
|
||||
<el-date-picker size="mini" v-model="formData.startTime" type="datetime" value-format="yyyy-MM-ddTHH:mm:ss" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<!-- 结束时间 -->
|
||||
<el-col :span="8">
|
||||
<el-form-item label="结束时间" prop="endTime">
|
||||
<el-date-picker size="mini" v-model="formData.endTime" type="datetime" value-format="yyyy-MM-ddTHH:mm:ss" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<!-- 机组号 -->
|
||||
<el-col :span="8">
|
||||
<el-form-item label="机组号" prop="unitCode">
|
||||
<el-input size="mini" v-model="formData.unitCode"></el-input>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<!-- 工序号 -->
|
||||
<el-col :span="8">
|
||||
<el-form-item label="工序号" prop="processCode">
|
||||
<el-input size="mini" v-model="formData.processCode"></el-input>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<!-- 是否尾卷 -->
|
||||
<el-col :span="8">
|
||||
<el-form-item label="是否尾卷" prop="lastFlag">
|
||||
<el-switch v-model="formData.lastFlag"></el-switch>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<!-- 是否分卷 -->
|
||||
<el-col :span="8">
|
||||
<el-form-item label="是否分卷" prop="separateFlag">
|
||||
<el-switch v-model="formData.separateFlag"></el-switch>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<!-- 计划来源 -->
|
||||
<el-col :span="8">
|
||||
<el-form-item label="计划来源" prop="planOrigin">
|
||||
<el-select v-model="formData.planOrigin" placeholder="请选择计划来源">
|
||||
<el-option label="L3计划" value="L3"></el-option>
|
||||
<el-option label="人工" value="MANUAL"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<!-- 保存按钮 -->
|
||||
<div class="dialog-footer">
|
||||
<el-button type="primary" @click="handleSave" :loading="saveLoading">保存</el-button>
|
||||
</div>
|
||||
</el-form>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'PdoDataCorrection',
|
||||
props: {
|
||||
// 接收父组件传递的详情数据
|
||||
detail: {
|
||||
type: Object,
|
||||
required: true,
|
||||
default: () => ({})
|
||||
},
|
||||
// 保存回调函数(父组件处理实际保存逻辑)
|
||||
saveCallback: {
|
||||
type: Function,
|
||||
required: true
|
||||
},
|
||||
// 保存按钮loading状态(由父组件控制)
|
||||
saveLoading: {
|
||||
type: Boolean,
|
||||
required: true,
|
||||
default: false
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
// 内部表单数据(拷贝父组件传递的detail,避免直接修改父组件数据)
|
||||
formData: {},
|
||||
// 表单验证规则
|
||||
formRules: {
|
||||
exitMatId: [{ required: true, message: '请输入成品卷号', trigger: 'blur' }],
|
||||
entryMatId: [{ required: true, message: '请输入来料卷号', trigger: 'blur' }],
|
||||
planNo: [{ required: true, message: '请输入计划号', trigger: 'blur' }],
|
||||
steelGrade: [{ required: true, message: '请输入钢种', trigger: 'blur' }]
|
||||
// 可根据实际需求补充其他字段验证规则
|
||||
}
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
// 监听detail变化,深拷贝更新内部formData
|
||||
detail: {
|
||||
handler(newVal) {
|
||||
// 深拷贝避免引用类型数据相互影响
|
||||
this.formData = JSON.parse(JSON.stringify(newVal))
|
||||
// 初始化数值类型字段(防止null/undefined导致输入框异常)
|
||||
this.initNumberFields()
|
||||
},
|
||||
immediate: true, // 初始渲染时立即执行
|
||||
deep: true // 深度监听对象内部变化
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
// 初始化数值类型字段(确保默认值为0而非null/undefined)
|
||||
initNumberFields() {
|
||||
const numberFields = [
|
||||
'subId', 'startPosition', 'endPosition', 'planId', 'entryThick',
|
||||
'entryWidth', 'entryLength', 'entryWeight', 'weightTop', 'weightBottom',
|
||||
'exitLength', 'exitNetWeight', 'theoryWeight', 'actualWeight',
|
||||
'exitOuterDiameter', 'exitThickness', 'exitWidth'
|
||||
]
|
||||
numberFields.forEach(field => {
|
||||
if (this.formData[field] === undefined || this.formData[field] === null) {
|
||||
this.formData[field] = 0
|
||||
}
|
||||
})
|
||||
// 初始化布尔类型字段
|
||||
this.formData.lastFlag = this.formData.lastFlag ?? false
|
||||
this.formData.separateFlag = this.formData.separateFlag ?? false
|
||||
},
|
||||
// 处理保存逻辑(先验证表单,通过后触发父组件回调)
|
||||
handleSave() {
|
||||
this.$refs.correctionForm.validate(valid => {
|
||||
if (valid) {
|
||||
// 触发父组件保存回调,传递内部修改后的表单数据
|
||||
this.saveCallback(this.formData)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.dialog-footer {
|
||||
text-align: right;
|
||||
margin-top: 20px;
|
||||
}
|
||||
</style>
|
||||
271
klp-ui/src/views/lines/panels/quality/components/LabelPrint.vue
Normal file
271
klp-ui/src/views/lines/panels/quality/components/LabelPrint.vue
Normal file
@@ -0,0 +1,271 @@
|
||||
<template>
|
||||
<div class="label-print-container">
|
||||
<!-- 预览区域(与打印内容一致且可编辑) -->
|
||||
<div class="label-preview" v-if="Object.keys(editableData).length">
|
||||
<!-- 给打印区域添加一个唯一ID -->
|
||||
<div id="printContent" class="label-content">
|
||||
<!-- 公司名称 -->
|
||||
<div class="company-name">
|
||||
{{ editableData.companyName }}
|
||||
</div>
|
||||
|
||||
<!-- 内容区域:使用Flexbox布局 -->
|
||||
<div class="content-grid">
|
||||
<div class="grid-item label">钢卷号</div>
|
||||
<div class="grid-item value">
|
||||
<input v-model="editableData.exitMatId" :border="false" class="editable-input"
|
||||
placeholder="钢卷号"></input>
|
||||
</div>
|
||||
<div class="grid-item label">热卷号</div>
|
||||
<div class="grid-item value">
|
||||
<input v-model="editableData.entryMatId" :border="false" class="editable-input"
|
||||
placeholder="热卷号"></input>
|
||||
</div>
|
||||
|
||||
<div class="grid-item label">规格</div>
|
||||
<div class="grid-item value">
|
||||
<input v-model="editableData.spec" :border="false" class="editable-input" placeholder="规格"></input>
|
||||
</div>
|
||||
<div class="grid-item label">材质</div>
|
||||
<div class="grid-item value">
|
||||
<input v-model="editableData.steelGrade" :border="false" class="editable-input"
|
||||
placeholder="材质"></input>
|
||||
</div>
|
||||
|
||||
<div class="grid-item label">净重</div>
|
||||
<div class="grid-item value">
|
||||
<input v-model="editableData.actualWeight" :border="false" class="editable-input"
|
||||
placeholder="净重"></input>
|
||||
</div>
|
||||
<div class="grid-item label">生产班组</div>
|
||||
<div class="grid-item value">
|
||||
<input v-model="editableData.groupNo" :border="false" class="editable-input"
|
||||
placeholder="生产班组"></input>
|
||||
</div>
|
||||
|
||||
<div class="grid-item label">产品名称</div>
|
||||
<div class="grid-item value">
|
||||
<input v-model="editableData.prodCode" :border="false" class="editable-input"
|
||||
placeholder="产品名称"></input>
|
||||
</div>
|
||||
<div class="grid-item label">生产日期</div>
|
||||
<div class="grid-item value">
|
||||
<input v-model="editableData.productionDate" :border="false" class="editable-input"
|
||||
placeholder="生产日期"></input>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 打印按钮 -->
|
||||
<div class="print-btn-container">
|
||||
<el-button type="primary" @click="handlePrint" icon="el-icon-printer"
|
||||
:disabled="!Object.keys(editableData).length">
|
||||
打印标签
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import printJS from 'print-js';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
export default {
|
||||
name: 'PdoLabelPrint',
|
||||
props: {
|
||||
detail: {
|
||||
type: Object,
|
||||
required: true,
|
||||
default: () => ({})
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
// 可编辑的数据对象
|
||||
editableData: {}
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
// 监听detail变化,初始化可编辑数据
|
||||
detail: {
|
||||
handler(newVal) {
|
||||
if (newVal) {
|
||||
this.initEditableData(newVal);
|
||||
}
|
||||
},
|
||||
immediate: true,
|
||||
deep: true
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
// 初始化可编辑数据
|
||||
initEditableData(detail) {
|
||||
const {
|
||||
exitMatId, entryMatId, exitThickness, exitWidth,
|
||||
actualWeight, steelGrade, groupNo, prodCode
|
||||
} = detail;
|
||||
|
||||
// 格式化规格
|
||||
const spec = exitThickness && exitWidth
|
||||
? `${exitThickness}*${exitWidth}`
|
||||
: '';
|
||||
|
||||
// 格式化生产日期
|
||||
const productionDate = dayjs().format('M月D日');
|
||||
|
||||
// 初始化可编辑数据
|
||||
this.editableData = {
|
||||
companyName: '嘉祥科伦普重工有限公司',
|
||||
exitMatId: exitMatId || '',
|
||||
entryMatId: entryMatId || '',
|
||||
spec: spec || '',
|
||||
steelGrade: steelGrade || '',
|
||||
actualWeight: actualWeight || '',
|
||||
groupNo: groupNo || '',
|
||||
prodCode: prodCode || '',
|
||||
productionDate: productionDate
|
||||
};
|
||||
},
|
||||
|
||||
// 处理打印逻辑
|
||||
handlePrint() {
|
||||
// 定义打印样式,确保打印效果与预览一致
|
||||
const printStyle = `
|
||||
.label-content {
|
||||
width: 200mm;
|
||||
height: 160mm;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
font-family: SimSun;
|
||||
}
|
||||
.company-name {
|
||||
text-align: center;
|
||||
padding: 8mm 0;
|
||||
font-size: 16pt;
|
||||
font-weight: bold;
|
||||
border: 1px solid #000;
|
||||
}
|
||||
.content-grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr 1fr 1fr;
|
||||
gap: 0;
|
||||
}
|
||||
.grid-item {
|
||||
min-height: 15mm;
|
||||
display: flex;
|
||||
border: 1px solid #000;
|
||||
align-items: center;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.label {
|
||||
font-weight: bold;
|
||||
font-size: 12pt;
|
||||
padding-left: 2mm;
|
||||
}
|
||||
.value {
|
||||
font-size: 12pt;
|
||||
}
|
||||
input {
|
||||
border: none !important;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
font-size: 12pt;
|
||||
padding: 0 2mm;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
`;
|
||||
|
||||
// 调用printJS进行打印
|
||||
printJS({
|
||||
printable: 'printContent', // 要打印的元素ID
|
||||
type: 'html',
|
||||
header: null, // 不显示默认页眉
|
||||
footer: null, // 不显示默认页脚
|
||||
style: printStyle, // 应用打印样式
|
||||
scanStyles: false, // 不扫描页面现有样式
|
||||
targetStyles: ['*'], // 允许所有目标样式
|
||||
documentTitle: '标签打印', // 打印文档标题
|
||||
onPrintDialogClose: () => {
|
||||
console.log('打印对话框已关闭');
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.label-print-container {
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
/* 预览区域样式 */
|
||||
.label-preview {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
/* 标签内容样式(与打印尺寸等比例) */
|
||||
.label-content {
|
||||
width: 500px; /* 200mm × 2.5 = 500px */
|
||||
height: 400px; /* 160mm × 2.5 = 400px */
|
||||
border: 1px solid #ccc;
|
||||
padding: 25px; /* 10mm × 2.5 = 25px */
|
||||
box-sizing: border-box;
|
||||
font-family: SimSun;
|
||||
}
|
||||
|
||||
.company-name {
|
||||
text-align: center;
|
||||
padding: 20px;
|
||||
border: 1px solid black;
|
||||
font-size: 24px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
/* 内容网格布局 */
|
||||
.content-grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr 1fr 1fr;
|
||||
gap: 0;
|
||||
border: 1px solid black;
|
||||
}
|
||||
|
||||
.grid-item {
|
||||
border: 1px solid black;
|
||||
min-height: 40px;
|
||||
align-items: center;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.label {
|
||||
font-weight: bold;
|
||||
line-height: 60px;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
/* 无边框输入框样式 */
|
||||
.editable-input {
|
||||
width: 100%;
|
||||
padding: 4px;
|
||||
text-align: inherit;
|
||||
background: transparent;
|
||||
font-size: inherit;
|
||||
border: none;
|
||||
outline: none;
|
||||
height: 60px;
|
||||
box-sizing: border-box;
|
||||
line-height: 60px;
|
||||
}
|
||||
|
||||
.editable-input:hover,
|
||||
.editable-input:focus {
|
||||
background: rgba(255, 255, 255, 0.8);
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.print-btn-container {
|
||||
text-align: left;
|
||||
margin-top: 10px;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,68 @@
|
||||
<template>
|
||||
<el-descriptions
|
||||
:column="1"
|
||||
border
|
||||
size="mini"
|
||||
>
|
||||
<!-- 循环渲染汇总项,从计算属性获取数据 -->
|
||||
<el-descriptions-item
|
||||
v-for="(item, index) in summaryResult"
|
||||
:key="index"
|
||||
:label="item.label"
|
||||
>
|
||||
<!-- 根据类型格式化显示(重量/百分比/数量) -->
|
||||
<span :class="item.type === 'rate' ? 'summary-rate' : ''">
|
||||
{{ item.value }}
|
||||
{{ item.unit }}
|
||||
</span>
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'PdoSummary',
|
||||
props: {
|
||||
// 接收表格原始数据(父组件传递)
|
||||
tableData: {
|
||||
type: Array,
|
||||
required: true,
|
||||
default: () => [] // 默认空数组,避免无数据时报错
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
// 核心:根据tableData计算汇总结果
|
||||
summaryResult() {
|
||||
// 1. 基础数值汇总(处理字符串转数字,避免NaN)
|
||||
const totalEntryWeight = this.tableData.reduce((sum, item) => {
|
||||
return sum + (Number(item.entryWeight) || 0)
|
||||
}, 0) // 原料总重(来料重量求和)
|
||||
|
||||
const totalExitWeight = this.tableData.reduce((sum, item) => {
|
||||
return sum + (Number(item.exitNetWeight) || 0)
|
||||
}, 0) // 产品总重(成品带涂料重量求和)
|
||||
|
||||
const totalZincRemoved = totalEntryWeight - totalExitWeight // 去锌总理重(原料总重 - 产品总重)
|
||||
|
||||
// 2. 成材率计算(避免除数为0)
|
||||
const yieldRate = totalEntryWeight > 0
|
||||
? ((totalExitWeight / totalEntryWeight) * 100).toFixed(2)
|
||||
: '0.00'
|
||||
|
||||
// 3. 卷数统计(原料/成品卷数默认按表格行数,可根据实际业务调整,如去重entryMatId)
|
||||
const totalEntryCoils = this.tableData.length // 原料总卷数
|
||||
const totalExitCoils = this.tableData.length // 成品总卷数
|
||||
|
||||
// 4. 返回格式化后的汇总项
|
||||
return [
|
||||
{ label: '原料总重', value: totalEntryWeight.toFixed(1), unit: 't', type: 'weight' },
|
||||
{ label: '去锌总理重', value: totalZincRemoved.toFixed(1), unit: 't', type: 'weight' },
|
||||
{ label: '产品总重', value: totalExitWeight.toFixed(1), unit: 't', type: 'weight' },
|
||||
{ label: '成材率', value: yieldRate, unit: '%', type: 'rate' },
|
||||
{ label: '原料总卷数', value: totalEntryCoils, unit: '卷', type: 'count' },
|
||||
{ label: '成品总卷数', value: totalExitCoils, unit: '卷', type: 'count' }
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
450
klp-ui/src/views/lines/panels/quality/components/line.vue
Normal file
450
klp-ui/src/views/lines/panels/quality/components/line.vue
Normal file
@@ -0,0 +1,450 @@
|
||||
<template>
|
||||
<el-row :gutter="20" class="monitoring-container">
|
||||
<!-- 实时数据折线图 -->
|
||||
<el-col :span="20">
|
||||
<div class="chart-wrapper">
|
||||
<!-- 参数选择下拉框 -->
|
||||
<el-select
|
||||
v-model="paramField"
|
||||
class="param-select"
|
||||
@change="handleParamChange"
|
||||
size="mini"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in paramFields"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"
|
||||
></el-option>
|
||||
</el-select>
|
||||
|
||||
<!-- 图表容器 -->
|
||||
<div ref="chart" class="chart-content"></div>
|
||||
</div>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import * as echarts from 'echarts'
|
||||
import createFetch from '@/api/l2/pdo'
|
||||
|
||||
export default {
|
||||
name: 'DeviceMonitoring',
|
||||
props: {
|
||||
enCoilID: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
baseURL: {
|
||||
type: String,
|
||||
default: ''
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
fetchApi: {},
|
||||
paramFields: [
|
||||
{ label: '带钢速度', value: 'stripSpeed' },
|
||||
{ label: '张力PorBr1', value: 'tensionPorBr1' },
|
||||
{ label: '清洗电压', value: 'cleaningVoltage' }
|
||||
],
|
||||
paramField: 'stripSpeed',
|
||||
treeProps: {
|
||||
children: 'children',
|
||||
label: 'label'
|
||||
},
|
||||
currentParam: null, // 当前选中的参数
|
||||
chart: null, // 图表实例
|
||||
chartData: [], // 图表数据
|
||||
timeStamps: [], // 时间戳
|
||||
timeRange: '1', // 时间范围(分钟)
|
||||
socket: null, // 模拟socket
|
||||
latestValue: 0,
|
||||
maxValue: 0,
|
||||
minValue: 0,
|
||||
avgValue: 0
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
enCoilID: {
|
||||
handler(newVal) {
|
||||
if (newVal) {
|
||||
this.fetchChartData();
|
||||
} else {
|
||||
this.drawEmptyChart();
|
||||
}
|
||||
},
|
||||
immediate: true
|
||||
},
|
||||
paramField: {
|
||||
handler() {
|
||||
if (this.enCoilID) {
|
||||
this.fetchChartData();
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
// 初始化图表
|
||||
this.fetchApi = createFetch(this.baseURL)
|
||||
this.initChart();
|
||||
},
|
||||
beforeDestroy() {
|
||||
// 销毁图表实例和事件监听
|
||||
if (this.chart) {
|
||||
this.chart.dispose();
|
||||
}
|
||||
window.removeEventListener('resize', this.handleResize);
|
||||
},
|
||||
methods: {
|
||||
// 初始化图表
|
||||
initChart() {
|
||||
if (this.$refs.chart) {
|
||||
this.chart = echarts.init(this.$refs.chart);
|
||||
// 监听窗口大小变化,调整图表尺寸
|
||||
window.addEventListener('resize', this.handleResize);
|
||||
|
||||
// 初始显示
|
||||
if (this.enCoilID) {
|
||||
this.fetchChartData();
|
||||
} else {
|
||||
this.drawEmptyChart();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
// 处理窗口大小变化
|
||||
handleResize() {
|
||||
if (this.chart) {
|
||||
this.chart.resize();
|
||||
}
|
||||
},
|
||||
|
||||
// 获取图表数据
|
||||
fetchChartData() {
|
||||
this.fetchApi.getSegmentList({
|
||||
enCoilID: this.enCoilID,
|
||||
paramField: this.paramField
|
||||
}).then(res => {
|
||||
// 假设res.data格式为[{ segNo: '时间戳', value: '数值' }]
|
||||
if (res.data && res.data.length) {
|
||||
this.processChartData(res.data);
|
||||
this.drawLineChart();
|
||||
} else {
|
||||
this.drawNoDataChart();
|
||||
}
|
||||
}).catch(err => {
|
||||
console.error('获取数据失败:', err);
|
||||
this.drawErrorChart();
|
||||
});
|
||||
},
|
||||
|
||||
// 处理图表数据
|
||||
processChartData(rawData) {
|
||||
// 排序数据(按segNo,假设是时间戳或序号)
|
||||
rawData.sort((a, b) => a.segNo - b.segNo);
|
||||
|
||||
// 提取时间戳和数值
|
||||
this.timeStamps = rawData.map(item => item.segNo);
|
||||
this.chartData = rawData.map(item => parseFloat(item.value));
|
||||
|
||||
// 计算统计值
|
||||
if (this.chartData.length) {
|
||||
this.latestValue = this.chartData[this.chartData.length - 1];
|
||||
this.maxValue = Math.max(...this.chartData);
|
||||
this.minValue = Math.min(...this.chartData);
|
||||
this.avgValue = this.chartData.reduce((sum, val) => sum + val, 0) / this.chartData.length;
|
||||
}
|
||||
},
|
||||
|
||||
// 绘制折线图
|
||||
drawLineChart() {
|
||||
if (!this.chart) return;
|
||||
|
||||
const option = {
|
||||
tooltip: {
|
||||
trigger: 'axis',
|
||||
axisPointer: {
|
||||
type: 'shadow'
|
||||
},
|
||||
formatter: (params) => {
|
||||
const param = params[0];
|
||||
return `
|
||||
时间: ${param.name}<br>
|
||||
值: ${param.value.toFixed(2)}<br>
|
||||
单位: ${this.getParamUnit()}
|
||||
`;
|
||||
}
|
||||
},
|
||||
grid: {
|
||||
left: '3%',
|
||||
right: '4%',
|
||||
bottom: '3%',
|
||||
top: '15%',
|
||||
containLabel: true
|
||||
},
|
||||
xAxis: {
|
||||
type: 'category',
|
||||
boundaryGap: false,
|
||||
data: this.timeStamps,
|
||||
axisLabel: {
|
||||
rotate: 45,
|
||||
interval: 0
|
||||
}
|
||||
},
|
||||
yAxis: {
|
||||
type: 'value',
|
||||
name: this.getParamUnit(),
|
||||
nameLocation: 'middle',
|
||||
nameGap: 30
|
||||
},
|
||||
series: [
|
||||
{
|
||||
name: this.getParamLabel(),
|
||||
type: 'line',
|
||||
data: this.chartData,
|
||||
smooth: true,
|
||||
symbol: 'circle',
|
||||
symbolSize: 6,
|
||||
markPoint: {
|
||||
data: [
|
||||
{ type: 'max', name: '最大值' },
|
||||
{ type: 'min', name: '最小值' }
|
||||
]
|
||||
},
|
||||
areaStyle: {},
|
||||
markLine: {
|
||||
data: [
|
||||
{ type: 'average', name: '平均值' }
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
this.chart.setOption(option);
|
||||
},
|
||||
|
||||
// 绘制空图表(未选择实绩)
|
||||
drawEmptyChart() {
|
||||
if (!this.chart) return;
|
||||
|
||||
const option = {
|
||||
graphic: {
|
||||
elements: [
|
||||
{
|
||||
type: 'text',
|
||||
left: 'center',
|
||||
top: 'center',
|
||||
style: {
|
||||
text: '请选择实绩',
|
||||
fontSize: 16,
|
||||
fontWeight: 'bold',
|
||||
fill: '#999'
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
xAxis: {
|
||||
type: 'category',
|
||||
data: []
|
||||
},
|
||||
yAxis: {
|
||||
type: 'value'
|
||||
},
|
||||
series: []
|
||||
};
|
||||
|
||||
this.chart.setOption(option);
|
||||
},
|
||||
|
||||
// 绘制无数据图表
|
||||
drawNoDataChart() {
|
||||
if (!this.chart) return;
|
||||
|
||||
const option = {
|
||||
graphic: {
|
||||
elements: [
|
||||
{
|
||||
type: 'text',
|
||||
left: 'center',
|
||||
top: 'center',
|
||||
style: {
|
||||
text: '暂无数据',
|
||||
fontSize: 16,
|
||||
fontWeight: 'bold',
|
||||
fill: '#999'
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
xAxis: {
|
||||
type: 'category',
|
||||
data: []
|
||||
},
|
||||
yAxis: {
|
||||
type: 'value'
|
||||
},
|
||||
series: []
|
||||
};
|
||||
|
||||
this.chart.setOption(option);
|
||||
},
|
||||
|
||||
// 绘制错误图表
|
||||
drawErrorChart() {
|
||||
if (!this.chart) return;
|
||||
|
||||
const option = {
|
||||
graphic: {
|
||||
elements: [
|
||||
{
|
||||
type: 'text',
|
||||
left: 'center',
|
||||
top: 'center',
|
||||
style: {
|
||||
text: '数据加载失败',
|
||||
fontSize: 16,
|
||||
fontWeight: 'bold',
|
||||
fill: '#f56c6c'
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
xAxis: {
|
||||
type: 'category',
|
||||
data: []
|
||||
},
|
||||
yAxis: {
|
||||
type: 'value'
|
||||
},
|
||||
series: []
|
||||
};
|
||||
|
||||
this.chart.setOption(option);
|
||||
},
|
||||
|
||||
// 处理参数变更
|
||||
handleParamChange() {
|
||||
// 清空现有数据
|
||||
this.chartData = [];
|
||||
this.timeStamps = [];
|
||||
|
||||
// 重新获取数据
|
||||
if (this.enCoilID) {
|
||||
this.fetchChartData();
|
||||
}
|
||||
},
|
||||
|
||||
// 获取参数标签
|
||||
getParamLabel() {
|
||||
const param = this.paramFields.find(item => item.value === this.paramField);
|
||||
return param ? param.label : this.paramField;
|
||||
},
|
||||
|
||||
// 获取参数单位
|
||||
getParamUnit() {
|
||||
// 根据不同参数返回不同单位
|
||||
switch(this.paramField) {
|
||||
case 'stripSpeed':
|
||||
return 'm/s';
|
||||
case 'tensionPorBr1':
|
||||
return 'N';
|
||||
case 'cleaningVoltage':
|
||||
return 'V';
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.monitoring-container {
|
||||
padding: 10px;
|
||||
height: 100%;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.chart-wrapper {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.param-select {
|
||||
position: absolute;
|
||||
top: 10px;
|
||||
left: 10px;
|
||||
z-index: 10;
|
||||
width: 150px;
|
||||
}
|
||||
|
||||
.chart-content {
|
||||
width: 100%;
|
||||
height: 300px;
|
||||
}
|
||||
|
||||
/* 原有样式保留 */
|
||||
.tree-container,
|
||||
.chart-container {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.el-card {
|
||||
height: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.tree-header,
|
||||
.chart-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.tree-header i,
|
||||
.chart-header i {
|
||||
margin-right: 8px;
|
||||
color: #409EFF;
|
||||
}
|
||||
|
||||
.device-tree {
|
||||
overflow-y: auto;
|
||||
flex: 1;
|
||||
padding-top: 10px;
|
||||
}
|
||||
|
||||
.custom-tree-node {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 5px 0;
|
||||
color: #606266;
|
||||
}
|
||||
|
||||
.custom-tree-node .online-status {
|
||||
display: inline-block;
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
border-radius: 50%;
|
||||
background-color: #13ce66;
|
||||
margin-left: 5px;
|
||||
}
|
||||
|
||||
:deep(.el-tree-node__content:hover) {
|
||||
background-color: transparent !important;
|
||||
color: white !important;
|
||||
}
|
||||
|
||||
:deep(.el-tree-node .el-tree-node__content:hover) {
|
||||
background-color: transparent !important;
|
||||
}
|
||||
|
||||
:deep(.el-tree-indent) {
|
||||
width: 16px;
|
||||
}
|
||||
</style>
|
||||
282
klp-ui/src/views/lines/panels/quality/index.vue
Normal file
282
klp-ui/src/views/lines/panels/quality/index.vue
Normal file
@@ -0,0 +1,282 @@
|
||||
<template>
|
||||
<div>
|
||||
<el-row>
|
||||
<!-- 查询表单(保持不变) -->
|
||||
<el-form :inline="true" :model="queryForm" ref="queryForm" label-width="100px">
|
||||
<el-form-item label="钢卷号" prop="coilid">
|
||||
<el-input size="mini" v-model="queryForm.coilid" placeholder="请输入钢卷号"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="开始日期" prop="startDate">
|
||||
<el-date-picker size="mini" v-model="queryForm.startDate" type="date" placeholder="选择开始日期"
|
||||
value-format="yyyy-MM-dd" clearable></el-date-picker>
|
||||
</el-form-item>
|
||||
<el-form-item label="结束日期" prop="endDate">
|
||||
<el-date-picker size="mini" v-model="queryForm.endDate" type="date" placeholder="选择结束日期"
|
||||
value-format="yyyy-MM-dd" clearable></el-date-picker>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="handleQuery" :loading="btnLoading" icon="el-icon-search"
|
||||
size="mini">查询</el-button>
|
||||
<el-button @click="handleReset" icon="el-icon-refresh" size="mini">重置</el-button>
|
||||
<el-button type="success" @click="handleAdd" icon="el-icon-plus" size="mini">补录</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<!-- 数据表格(保持不变) -->
|
||||
<el-table v-loading="tableLoading" :data="tableData" border style="width: 100%; margin-top: 20px;"
|
||||
@row-click="handleRowClick" highlight-current-row>
|
||||
<el-table-column prop="exitMatId" label="成品卷" width="150" align="center" />
|
||||
<el-table-column prop="entryMatId" label="来料卷" width="150" align="center" />
|
||||
<el-table-column prop="subId" label="分切数" width="100" align="center" />
|
||||
<el-table-column prop="status" label="状态" width="100" align="center" />
|
||||
<el-table-column prop="startPosition" label="开始位置" width="100" align="center" />
|
||||
<el-table-column prop="endPosition" label="结束位置" width="100" align="center" />
|
||||
<el-table-column prop="planId" label="计划ID" width="120" align="center" />
|
||||
<el-table-column prop="planNo" label="计划号" width="150" align="center" />
|
||||
<el-table-column prop="prodCode" label="产品类型" width="120" align="center" />
|
||||
<el-table-column prop="groupNo" label="班号" width="100" align="center" />
|
||||
<el-table-column prop="shiftNo" label="组号" width="100" align="center" />
|
||||
<el-table-column prop="steelGrade" label="钢种" width="100" align="center" />
|
||||
<el-table-column prop="entryThick" label="来料厚度" width="100" align="center" />
|
||||
<el-table-column prop="entryWidth" label="来料宽带" width="100" align="center" />
|
||||
<el-table-column prop="entryLength" label="来料长度" width="100" align="center" />
|
||||
<el-table-column prop="entryWeight" label="来料重量" width="100" align="center" />
|
||||
<el-table-column prop="weightTop" label="上表面镀锌" width="100" align="center" />
|
||||
<el-table-column prop="weightBottom" label="下表面镀锌" width="100" align="center" />
|
||||
<el-table-column prop="exitLength" label="成品长度" width="100" align="center" />
|
||||
<el-table-column prop="exitNetWeight" label="成品带涂料重量" width="120" align="center" />
|
||||
<el-table-column prop="theoryWeight" label="理论重量" width="100" align="center" />
|
||||
<el-table-column prop="actualWeight" label="实际重量" width="100" align="center" />
|
||||
<el-table-column prop="exitOuterDiameter" label="成品外径" width="100" align="center" />
|
||||
<el-table-column prop="exitThickness" label="成品厚度" width="100" align="center" />
|
||||
<el-table-column prop="exitWidth" label="成品宽度" width="100" align="center" />
|
||||
<el-table-column prop="customer" label="客户" width="120" align="center" />
|
||||
<el-table-column label="上线时间" prop="onlineTime" width="180" align="center">
|
||||
<template slot-scope="scope">{{ parseTime(scope.row.onlineTime, '{y}-{m}-{d} {h}:{i}:{s}') }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="开始时间" prop="startTime" width="180" align="center">
|
||||
<template slot-scope="scope">{{ parseTime(scope.row.startTime, '{y}-{m}-{d} {h}:{i}:{s}') }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="结束时间" prop="endTime" width="180" align="center">
|
||||
<template slot-scope="scope">{{ parseTime(scope.row.endTime, '{y}-{m}-{d} {h}:{i}:{s}') }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="unitCode" label="机组号" width="100" align="center" />
|
||||
<el-table-column prop="processCode" label="工序号" width="100" align="center" />
|
||||
<el-table-column label="是否尾卷" width="100" align="center">
|
||||
<template slot-scope="scope">
|
||||
<span>{{ scope.row.lastFlag ? '是' : '否' }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="是否分卷" width="100" align="center">
|
||||
<template slot-scope="scope">
|
||||
<span>{{ scope.row.separateFlag ? '是' : '否' }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="计划来源" align="center" prop="planOrigin" width="120">
|
||||
<template slot-scope="scope">
|
||||
<dict-tag :options="dict.type.pdo_plan_origin" :value="scope.row.planOrigin" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="200" align="center" fixed="right" prop="action">
|
||||
<template slot-scope="scope">
|
||||
<el-button size="mini" type="primary" @click="handleEdit(scope.row)" icon="el-icon-edit">操作</el-button>
|
||||
<el-button size="mini" type="danger" @click="handleDelete(scope.row)" :loading="scope.row.deleteLoading"
|
||||
icon="el-icon-delete">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-row>
|
||||
|
||||
<el-row>
|
||||
<el-col :span="3">
|
||||
<pdo-summary :table-data="tableData" />
|
||||
</el-col>
|
||||
|
||||
<el-col :span="21">
|
||||
<line-chart :enCoilID="currentRow.exitMatId" :baseURL="baseURL" />
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<!-- 编辑/新增弹窗:根据isAdd条件渲染内容 -->
|
||||
<el-dialog
|
||||
:title="dialogTitle"
|
||||
:visible.sync="dialogVisible"
|
||||
width="60%"
|
||||
:close-on-click-modal="false"
|
||||
>
|
||||
<!-- 补录(新增):仅显示数据修正组件,无tab -->
|
||||
<div v-if="isAdd">
|
||||
<pdo-data-correction
|
||||
:detail="formData"
|
||||
:save-callback="handleSave"
|
||||
:save-loading="saveLoading"
|
||||
></pdo-data-correction>
|
||||
</div>
|
||||
|
||||
<!-- 编辑:保留原有tab,显示数据修正+标签打印 -->
|
||||
<el-tabs v-else v-model="activeTab">
|
||||
<el-tab-pane label="数据修正" name="basicInfo">
|
||||
<pdo-data-correction
|
||||
:detail="formData"
|
||||
:save-callback="handleSave"
|
||||
:save-loading="saveLoading"
|
||||
></pdo-data-correction>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane label="标签打印" name="labelPrint">
|
||||
<pdo-label-print
|
||||
:detail="formData"
|
||||
></pdo-label-print>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
// import { getPdoList, addPdo, updatePdo, deletePdo } from '@/api/l2/pdo'
|
||||
import createFetch from '@/api/l2/pdo'
|
||||
import LineChart from './components/line.vue'
|
||||
// 引入封装的两个组件
|
||||
import PdoDataCorrection from './components/DataCorrection.vue'
|
||||
import PdoLabelPrint from './components/LabelPrint.vue'
|
||||
import PdoSummary from './components/PdoSummary.vue'
|
||||
|
||||
export default {
|
||||
name: 'PdoManagement',
|
||||
dicts: ['pdo_plan_origin'],
|
||||
components: {
|
||||
LineChart,
|
||||
PdoDataCorrection, // 注册数据修正组件
|
||||
PdoLabelPrint, // 注册标签打印组件
|
||||
PdoSummary
|
||||
},
|
||||
props: {
|
||||
baseURL: {
|
||||
type: String,
|
||||
default: ''
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
fetchApi: {},
|
||||
activeTab: 'basicInfo',
|
||||
queryForm: { coilid: '', startDate: '', endDate: '' },
|
||||
tableData: [],
|
||||
tableLoading: false,
|
||||
btnLoading: false,
|
||||
dialogVisible: false,
|
||||
dialogTitle: '新增实绩',
|
||||
// 新增:区分「补录(新增)」和「编辑」的状态标识
|
||||
isAdd: false,
|
||||
// 传递给子组件的详情数据(父组件仅做数据中转,不直接修改)
|
||||
formData: {},
|
||||
saveLoading: false,
|
||||
currentRow: {},
|
||||
socketType: [
|
||||
{ value: 'alarm', label: '报警' },
|
||||
{ value: 'track_position', label: '跟踪位置' },
|
||||
{ value: 'track_measure', label: '跟踪测量' },
|
||||
{ value: 'track_signal', label: '跟踪信号' },
|
||||
{ value: 'track_matmap', label: '跟踪料号' },
|
||||
{ value: 'calc_setup_result', label: '计算结果' }
|
||||
]
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.fetchApi = createFetch(this.baseURL)
|
||||
this.getPdoList()
|
||||
},
|
||||
methods: {
|
||||
// 获取列表数据(保持不变)
|
||||
getPdoList() {
|
||||
this.tableLoading = true
|
||||
this.fetchApi.getPdoList(this.queryForm).then(res => {
|
||||
this.tableData = res.data.map(item => ({ ...item, deleteLoading: false }))
|
||||
}).catch(err => {
|
||||
console.error(err)
|
||||
this.$message.error('获取数据失败')
|
||||
}).finally(() => {
|
||||
this.tableLoading = false
|
||||
this.btnLoading = false
|
||||
})
|
||||
},
|
||||
// 查询(保持不变)
|
||||
handleQuery() {
|
||||
this.btnLoading = true;
|
||||
this.getPdoList()
|
||||
},
|
||||
// 重置(保持不变)
|
||||
handleReset() {
|
||||
this.$refs.queryForm.resetFields();
|
||||
this.getPdoList()
|
||||
},
|
||||
// 行点击(保持不变)
|
||||
handleRowClick(row) {
|
||||
this.currentRow = row;
|
||||
},
|
||||
// 补录(新增):设置isAdd=true,初始化空表单
|
||||
handleAdd() {
|
||||
this.isAdd = true; // 标记为「补录」
|
||||
this.dialogTitle = '新增实绩';
|
||||
// 初始化空表单数据(传递给子组件)
|
||||
this.formData = {
|
||||
subId: 0,
|
||||
startPosition: 0,
|
||||
endPosition: 0,
|
||||
planId: 0,
|
||||
entryThick: 0,
|
||||
entryWidth: 0,
|
||||
entryLength: 0,
|
||||
entryWeight: 0,
|
||||
weightTop: 0,
|
||||
weightBottom: 0,
|
||||
exitLength: 0,
|
||||
exitNetWeight: 0,
|
||||
theoryWeight: 0,
|
||||
actualWeight: 0,
|
||||
exitOuterDiameter: 0,
|
||||
exitThickness: 0,
|
||||
exitWidth: 0,
|
||||
lastFlag: false,
|
||||
separateFlag: false
|
||||
};
|
||||
this.dialogVisible = true
|
||||
},
|
||||
// 编辑:设置isAdd=false,赋值行数据
|
||||
handleEdit(row) {
|
||||
this.isAdd = false; // 标记为「编辑」
|
||||
this.dialogTitle = '编辑实绩';
|
||||
// 深拷贝行数据(避免直接修改表格数据)
|
||||
this.formData = JSON.parse(JSON.stringify(row));
|
||||
this.dialogVisible = true
|
||||
},
|
||||
// 删除(保持不变)
|
||||
handleDelete(row) {
|
||||
this.$confirm(`确定删除成品卷 ${row.exitMatId}?`, '确认删除', { type: 'danger' }).then(() => {
|
||||
row.deleteLoading = true
|
||||
this.fetchApi.deletePdo(row.exitMatId, row.planId).then(res => {
|
||||
if (res.code === 200) {
|
||||
this.$message.success('删除成功');
|
||||
this.getPdoList()
|
||||
} else this.$message.error(res.msg || '删除失败')
|
||||
}).finally(() => row.deleteLoading = false)
|
||||
})
|
||||
},
|
||||
// 保存回调(子组件触发,处理实际API调用)
|
||||
handleSave(formData) {
|
||||
this.saveLoading = true
|
||||
// 根据是否有id判断是新增还是编辑
|
||||
const request = formData.id ? this.fetchApi.updatePdo(formData) : this.fetchApi.addPdo(formData)
|
||||
request.then(res => {
|
||||
if (res.code === 200) {
|
||||
this.$message.success('保存成功');
|
||||
this.dialogVisible = false;
|
||||
this.getPdoList() // 刷新列表
|
||||
} else this.$message.error(res.msg || '保存失败')
|
||||
}).finally(() => {
|
||||
this.saveLoading = false
|
||||
})
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user