feat(钢卷管理): 新增生产时间记录及耗时计算功能

添加TimeInput组件用于时间输入,并在钢卷合并、分条、打字、分步操作中增加生产开始/结束时间字段
实现生产耗时自动计算功能,支持显示xx天xx小时xx分钟格式
在基础面板中增加生产时间修正对话框,支持批量修改时间
This commit is contained in:
砂糖
2026-03-17 18:01:46 +08:00
parent 3c9f82add4
commit 3d6391bf32
7 changed files with 552 additions and 42 deletions

View File

@@ -173,7 +173,7 @@
<el-table-column label="业务目的" align="center" prop="businessPurpose" v-if="showBusinessPurpose" width="150">
<template slot-scope="scope">
<el-select v-model="scope.row.businessPurpose" placeholder="业务目的" filterable
@change="handleBusinessPurposeChange(scope.row)">
@change="handleRowChange(scope.row)">
<el-option v-for="item in dict.type.coil_business_purpose" :key="item.value" :value="item.value"
:label="item.label" />
</el-select>
@@ -182,8 +182,8 @@
<el-table-column label="关联订单" align="center" prop="relatedToOrder" v-if="showRelatedToOrder" width="150">
<template slot-scope="scope">
<el-switch @change="handleRelatedToOrderChange(scope.row)" v-model="scope.row.isRelatedToOrder"
:active-value="1" :inactive-value="0" />
<el-switch @change="handleRowChange(scope.row)" v-model="scope.row.isRelatedToOrder" :active-value="1"
:inactive-value="0" />
</template>
</el-table-column>
@@ -230,7 +230,21 @@
<el-tag v-else type="info" size="mini">未发货</el-tag>
</template>
</el-table-column>
<!-- <el-table-column label="备注" align="center" prop="remark" show-overflow-tooltip/> -->
<el-table-column label="实测宽度" align="center" prop="width" v-if="showWidthEdit" width="150">
<template slot-scope="scope">
<el-input v-model="scope.row.actualWidth" placeholder="请输入实测宽度"
@change="handleRowChange(scope.row)"></el-input>
</template>
</el-table-column>
<el-table-column label="预留宽度" align="center" prop="width" v-if="showWidthEdit" width="150">
<template slot-scope="scope">
<el-input v-model="scope.row.reservedWidth" placeholder="请输入预留宽度"
@change="handleRowChange(scope.row)"></el-input>
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button size="mini" type="text" icon="el-icon-view" @click="handlePreviewLabel(scope.row)">
@@ -247,18 +261,16 @@
@click="handleCancelExport(scope.row)">
撤回发货
</el-button>
<el-button size="mini" v-if="showProductionTimeEdit" type="text" icon="el-icon-close"
@click="handleProductionTimeEdit(scope.row)">
加工修正
</el-button>
<el-button size="mini" v-if="showExportTime" type="text" icon="el-icon-sold-out"
@click="handleReturnCoil(scope.row)">
退货钢卷
</el-button>
<!-- <el-button size="mini" v-if="showAbnormal" type="text" icon="el-icon-upload"
@click="handleAbnormal(scope.row)">查看异常</el-button> -->
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleCheck(scope.row)"
v-if="showControl">修正</el-button>
<!-- <el-button size="mini" type="text" icon="el-icon-time" @click="handleLog(scope.row)"
v-if="showWareLog">吞吐记录</el-button> -->
<!-- <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
v-if="showControl">删除</el-button> -->
<el-button size="mini" type="text" icon="el-icon-search" @click="handleTrace(scope.row)">追溯</el-button>
</template>
</el-table-column>
@@ -396,6 +408,28 @@
</div>
</el-dialog>
<el-dialog title="生产时间修正" :visible.sync="productionTimeFormVisible" width="500px" append-to-body>
<el-form ref="productionTimeForm" :model="productionTimeForm" :rules="productionTimeFormRules"
label-width="100px">
<el-form-item label="生产开始时间" prop="productionStartTime">
<el-date-picker v-model="productionTimeForm.productionStartTime" type="datetime"
value-format="yyyy-MM-dd HH:mm:ss" placeholder="请选择生产时间" @change="(value) => { productionTimeForm.productionStartTime = value; calculateProductionDuration(); }" />
</el-form-item>
<el-form-item label="生产结束时间" prop="productionEndTime">
<el-date-picker v-model="productionTimeForm.productionEndTime" type="datetime"
value-format="yyyy-MM-dd HH:mm:ss" placeholder="请选择生产时间" @change="(value) => { productionTimeForm.productionEndTime = value; calculateProductionDuration(); }" />
</el-form-item>
<el-form-item label="生产耗时" prop="productionDuration">
<!-- <div>{{ productionTimeForm.formattedDuration }}</div> -->
<el-input v-model="productionTimeForm.formattedDuration" placeholder="自动计算" disabled />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button :loading="buttonLoading" type="primary" @click="submitProductionTimeForm"> </el-button>
<el-button @click="productionTimeFormVisible = false"> </el-button>
</div>
</el-dialog>
<!-- <el-dialog title="异常信息" :visible.sync="abnormalOpen" width="90%" append-to-body> -->
<abnormal-list v-if="showAbnormal && currentCoilId" :coil-id="currentCoilId"></abnormal-list>
<!-- </el-dialog> -->
@@ -553,7 +587,17 @@ export default {
showNewExport: {
type: Boolean,
default: false,
}
},
// 展示宽度快捷编辑
showWidthEdit: {
type: Boolean,
default: false,
},
// 展示生产时间快捷编辑
showProductionTimeEdit: {
type: Boolean,
default: false,
},
},
data() {
return {
@@ -724,6 +768,18 @@ export default {
currentCoilId: '',
userList: [],
logOpen: false,
productionTimeForm: {
productionStartTime: '',
productionEndTime: '',
formattedDuration: '',
productionDuration: 0,
},
productionTimeFormRules: {
productionTime: [
{ required: true, message: "生产时间不能为空", trigger: "blur" }
],
},
productionTimeFormVisible: false,
};
},
computed: {
@@ -759,6 +815,88 @@ export default {
this.userList = res.rows || [];
});
},
handleProductionTimeEdit(row) {
// 创建一个新对象避免直接引用row
this.productionTimeForm = { ...row };
this.productionTimeFormVisible = true;
// 初始化时计算一次
this.calculateProductionDuration();
},
// 格式化毫秒值为xx天xx小时xx分钟
formatDuration(milliseconds) {
if (!milliseconds || milliseconds < 0) return '';
const seconds = Math.floor(milliseconds / 1000);
const minutes = Math.floor(seconds / 60);
const hours = Math.floor(minutes / 60);
const days = Math.floor(hours / 24);
const remainingHours = hours % 24;
const remainingMinutes = minutes % 60;
let result = '';
if (days > 0) result += `${days}`;
if (remainingHours > 0) result += `${remainingHours}小时`;
if (remainingMinutes > 0) result += `${remainingMinutes}分钟`;
return result || '0分钟';
},
// 计算生产耗时
calculateProductionDuration() {
const { productionStartTime, productionEndTime } = this.productionTimeForm;
if (productionStartTime && productionEndTime) {
const start = new Date(productionStartTime).getTime();
const end = new Date(productionEndTime).getTime();
if (end < start) {
this.$message({
message: '结束时间不能早于开始时间',
type: 'error',
});
this.$set(this.productionTimeForm, 'productionDuration', '');
this.$set(this.productionTimeForm, 'formattedDuration', '');
} else {
const durationMs = end - start;
const durationMinutes = Math.round(durationMs / (1000 * 60));
this.$set(this.productionTimeForm, 'productionDuration', durationMinutes);
// 同时保存格式化后的显示值
this.$set(this.productionTimeForm, 'formattedDuration', this.formatDuration(durationMinutes * 60 * 1000));
}
} else {
this.$set(this.productionTimeForm, 'productionDuration', '');
this.$set(this.productionTimeForm, 'formattedDuration', '');
}
},
// 处理生产时间提交
submitProductionTimeForm() {
this.$refs.productionTimeForm.validate((valid) => {
if (valid) {
// 再次验证时间逻辑
const { productionStartTime, productionEndTime } = this.productionTimeForm;
if (productionStartTime && productionEndTime) {
const start = new Date(productionStartTime).getTime();
const end = new Date(productionEndTime).getTime();
if (end < start) {
this.$message({
message: '结束时间不能早于开始时间',
type: 'error',
});
return false;
}
}
this.buttonLoading = true;
updateMaterialCoilSimple(this.productionTimeForm).then(res => {
this.buttonLoading = false;
this.$message({
message: '更新成功',
type: 'success',
});
this.productionTimeFormVisible = false;
})
} else {
return false;
}
})
},
handleNextWarehouseChange(row) {
if (!this.editNext) {
return;
@@ -777,37 +915,13 @@ export default {
}
})
},
handleBusinessPurposeChange(row) {
if (!this.showBusinessPurpose) {
return;
}
// 处理行数据变化
handleRowChange(row) {
updateMaterialCoilSimple(row).then(res => {
if (res.code === 200) {
this.$message({
message: '更新成功',
type: 'success',
});
} else {
this.$message({
message: res.msg || '更新失败',
type: 'error',
});
}
})
},
handleRelatedToOrderChange(row) {
updateMaterialCoilSimple(row).then(res => {
if (res.code === 200) {
this.$message({
message: '更新成功',
type: 'success',
});
} else {
this.$message({
message: res.msg || '更新失败',
type: 'error',
});
}
this.$message({
message: '更新成功',
type: 'success',
});
})
},
// 打印标签