feat: 添加 CurrentCoilNo 组件并替换原有钢卷号显示

引入新的 CurrentCoilNo 组件用于统一显示钢卷号,支持不同长度钢卷号的格式化显示和颜色区分
替换多个视图中的 el-tag 和 CoilNo 组件为新的 CurrentCoilNo 组件
This commit is contained in:
砂糖
2026-03-04 10:58:18 +08:00
parent 809a4506e7
commit 0aaa01f4bf
10 changed files with 87 additions and 12 deletions

View File

@@ -0,0 +1,69 @@
<template>
<div class="current-coil-no">
<template v-if="currentCoilNo.length < 10">
{{ currentCoilNo }}
</template>
<template v-else>
<span v-if="remainingPart" class="green-part">{{ firstFive }}</span>
<span v-if="middlePart" class="default-part">{{ middlePart }}</span>
<span v-if="remainingPart && lastTwo" class="blue-part">{{ lastTwo }}</span>
<span v-if="splitPart" class="red-part">{{ splitPart }}</span>
</template>
</div>
</template>
<script>
export default {
name: 'CurrentCoilNo',
props: {
currentCoilNo: {
type: String,
required: true
}
},
computed: {
splitPart() {
const index = Math.max(this.currentCoilNo.indexOf('-'), this.currentCoilNo.indexOf('/'));
return index > -1 ? this.currentCoilNo.substring(index) : '';
},
mainPart() {
const index = Math.max(this.currentCoilNo.indexOf('-'), this.currentCoilNo.indexOf('/'));
return index > -1 ? this.currentCoilNo.substring(0, index) : this.currentCoilNo;
},
firstFive() {
return this.mainPart.substring(0, 5);
},
middlePart() {
return this.mainPart.length > 7 ? this.mainPart.substring(5, this.mainPart.length - 2) : '';
},
lastTwo() {
return this.mainPart.length > 5 ? this.mainPart.substring(this.mainPart.length - 2) : '';
},
remainingPart() {
return this.mainPart.length > 0;
}
}
}
</script>
<style scoped>
.current-coil-no {
display: inline-block;
font-size: 12px;
background-color: #f4f4f5;
padding: 2px 4px;
border-radius: 4px;
}
.green-part {
color: rgb(0, 130, 46);
}
.default-part {
color: inherit;
}
.blue-part {
color: rgb(0, 149, 248);
}
.red-part {
color: rgb(250, 72, 72);
}
</style>