feat(组件): 新增多选组件并优化钢卷选择器

新增MutiSelect多选组件,支持逗号分隔字符串绑定
优化CoilSelector组件,使用MutiSelect替换输入框并新增规格字段
移除多处钢种字段显示及输入
增强CoilNo组件,支持悬停显示钢卷详细信息
在收货详情页添加删除按钮功能
This commit is contained in:
砂糖
2025-12-15 11:05:27 +08:00
parent 1cf1b23ca2
commit d90f72c662
9 changed files with 202 additions and 54 deletions

View File

@@ -23,17 +23,18 @@
<el-input v-model="queryParams.currentCoilNo" placeholder="请输入卷号" clearable size="small"
@keyup.enter.native="handleQuery" />
</el-form-item>
<el-form-item label="钢种">
<el-input v-model="queryParams.itemName" placeholder="请输入钢种" clearable size="small"
<el-form-item label="物料">
<muti-select v-model="queryParams.itemName" :options="dict.type.coil_itemname" placeholder="请选择物料" clearable />
</el-form-item>
<el-form-item label="规格">
<memo-input storageKey="coilSpec" v-model="queryParams.specification" placeholder="请输入规格" clearable size="small"
@keyup.enter.native="handleQuery" />
</el-form-item>
<el-form-item label="材质">
<el-input v-model="queryParams.itemMaterial" placeholder="请输入材质" clearable size="small"
@keyup.enter.native="handleQuery" />
<muti-select v-model="queryParams.itemMaterial" :options="dict.type.coil_material" placeholder="请选择材质" clearable />
</el-form-item>
<el-form-item label="厂家">
<el-input v-model="queryParams.itemManufacturer" placeholder="请输入厂家" clearable size="small"
@keyup.enter.native="handleQuery" />
<muti-select v-model="queryParams.itemManufacturer" :options="dict.type.coil_manufacturer" placeholder="请选择厂家" clearable />
</el-form-item>
<el-form-item>
@@ -68,9 +69,16 @@
<script>
import { listMaterialCoil } from '@/api/wms/coil';
import MemoInput from '@/components/MemoInput/index.vue';
import MutiSelect from '@/components/MutiSelect/index.vue';
export default {
name: 'CoilSelector',
components: {
MemoInput,
MutiSelect
},
dicts: ['coil_itemname', 'coil_material', 'coil_manufacturer'],
props: {
// 非触发器模式下,外部控制显隐(触发器模式下无效)
visible: {

View File

@@ -1,22 +1,104 @@
<template>
<div :class="{'g-coil-no': isGCoilNo}">
<el-tag type="info" size="small">{{ coilNo }}</el-tag>
<!-- coilId时显示popover无则只显示标签 -->
<el-popover
v-if="coilId"
placement="left"
width="200"
trigger="hover"
>
<div class="coil-info">
<div class="info-item">
<span class="label">物料名称</span>
<span class="value">{{ itemName }}</span>
</div>
<div class="info-item">
<span class="label">材质</span>
<span class="value">{{ material }}</span>
</div>
<div class="info-item">
<span class="label">生产厂家</span>
<span class="value">{{ manufacturer }}</span>
</div>
<div class="info-item">
<span class="label">规格</span>
<span class="value">
{{ specification }}
</span>
</div>
</div>
<el-tag type="info" size="small" slot="reference">{{ coilNo }}</el-tag>
</el-popover>
<!-- 无coilId时仅显示标签 -->
<el-tag v-else type="info" size="small">{{ coilNo }}</el-tag>
</div>
</template>
<script>
import { getMaterialCoil } from '@/api/wms/coil'
export default {
props: {
coilNo: {
type: String,
default: ''
},
coilId: {
type: String,
default: ''
},
},
data() { // 修正data应该是函数
return {
coilInfo: {}
}
},
computed: {
isGCoilNo() {
return this.coilNo.startsWith('G');
return this.coilNo && this.coilNo.startsWith('G');
},
specification() {
return this.coilInfo.product?.specification || this.coilInfo.rawMaterial?.specification || '-'
},
itemName() {
return this.coilInfo.product?.productName || this.coilInfo.rawMaterial?.rawMaterialName || '-'
},
material() {
return this.coilInfo.product?.material || this.coilInfo.rawMaterial?.material || '-'
},
manufacturer() {
return this.coilInfo.product?.manufacturer || this.coilInfo.rawMaterial?.manufacturer || '-'
},
},
methods: {
getCoilInfo() {
if (!this.coilId) {
return;
}
getMaterialCoil(this.coilId).then(res => {
this.coilInfo = res.data || {};
}).catch(err => {
console.error('获取钢卷信息失败:', err);
this.coilInfo = {};
})
}
},
mounted() {
// 组件挂载时获取线圈信息
this.getCoilInfo();
},
watch: {
// 监听coilId变化重新获取信息
coilId(newVal) {
if (newVal) {
this.getCoilInfo();
} else {
this.coilInfo = {};
}
}
}
}
</script>
@@ -26,5 +108,33 @@ export default {
display: inline-block; /* 让容器尺寸贴合内部el-tag */
border: 2px solid #67c23a !important;
border-radius: 4px; /* 可选和el-tag圆角保持一致更美观 */
padding: 1px; /* 调整内边距,避免边框和标签重叠 */
}
/* 弹窗信息样式 */
.coil-info {
font-size: 12px;
line-height: 1.8;
}
.coil-info .info-item {
display: flex;
margin-bottom: 4px;
}
.coil-info .info-item:last-child {
margin-bottom: 0;
}
.coil-info .label {
color: #666;
width: 70px;
flex-shrink: 0;
}
.coil-info .value {
color: #333;
flex: 1;
word-break: break-all;
}
</style>

View File

@@ -0,0 +1,40 @@
<template>
<el-select v-model="innerValue" multiple placeholder="请选择" filterable clearable :allow-create="allowAdd">
<el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
</template>
<!-- v-model上床绑定逗号分隔的字符串可以props配置是否允许新增 -->
<script>
export default {
name: 'MutiSelect',
props: {
value: {
type: String,
default: ''
},
options: {
type: Array,
default: () => []
},
allowAdd: {
type: Boolean,
default: false
}
},
// 计算属性捕获实现双向绑定
computed: {
innerValue: {
get() {
if (!this.value) {
return [];
}
return this.value.split(',');
},
set(val) {
this.$emit('input', val.join(','));
}
}
}
}
</script>