feat(产品/原材料): 添加规格字段支持

在产品和原材料相关组件中添加规格字段的显示和查询功能,包括:
1. 在详情弹窗中显示规格信息
2. 在列表页添加规格列和查询条件
3. 在表单中添加规格输入项
4. 优化选择器显示格式为"名称[规格](SKU)"
This commit is contained in:
砂糖
2025-11-04 16:45:30 +08:00
parent 9b2de46977
commit 1084f4b134
6 changed files with 47 additions and 8 deletions

View File

@@ -7,11 +7,12 @@
<div v-else style="padding: 10px;">未搜索到产品</div>
</template>
<el-option v-for="item in productOptions" :key="item.productId"
:label="`${item.productName}${getSku(item)}`" :value="item.productId">
<div>
:label="getLabel(item)" :value="item.productId">
<div>
<div class="option-label">
<span class="product-name">{{ item.productName }}</span>
<span class="product-code">{{ getSku(item) }}</span>
{{ getLabel(item) }}
<!-- <span class="product-name">{{ item.productName }}[{{ item.specification }}]</span>
<span class="product-code">{{ getSku(item) }}</span> -->
</div>
</div>
</el-option>
@@ -144,6 +145,13 @@ export default {
this.productOptions = res.rows || [];
});
},
getLabel(item) {
// 产品名称[规格](SKU),如果有则写,没有则省略
if (!item.specification) {
return `${item.productName}(${this.getSku(item)})`
}
return `${item.productName}[${item.specification}](${this.getSku(item)})`
},
getSku(item) {
const boms = item.bomItems || [];
console.log(boms, '产品BOM');

View File

@@ -7,11 +7,12 @@
<div v-else style="padding: 10px;">未搜索到原材料</div>
</template>
<el-option v-for="item in rawMaterialList" :key="item.rawMaterialId"
:label="`${item.rawMaterialName}${getSku(item)}`" :value="item.rawMaterialId">
:label="getLabel(item)" :value="item.rawMaterialId">
<div>
<div class="option-label">
<span class="material-name">{{ item.rawMaterialName }}</span>
<span class="material-code">{{ getSku(item) }}</span>
{{ getLabel(item) }}
<!-- <span class="material-name">{{ item.rawMaterialName }}[{{ item.specification }}]</span>
<span class="material-code">{{ getSku(item) }}</span> -->
</div>
</div>
</el-option>
@@ -148,6 +149,13 @@ export default {
const rawMaterial = this.options.find(p => p.rawMaterialId === val);
this.$emit('change', rawMaterial);
},
getLabel(item) {
// 原材料名称[规格](SKU),如果有则写,没有则省略
if (!item.specification) {
return `${item.rawMaterialName}(${this.getSku(item)})`
}
return `${item.rawMaterialName}[${item.specification}](${this.getSku(item)})`
},
getSku(item) {
const boms = item.bomItems;
if (!boms || boms.length === 0) {

View File

@@ -22,6 +22,9 @@
<el-descriptions-item label="产品编码">
{{ product.productCode || '--' }}
</el-descriptions-item>
<el-descriptions-item label="规格">
{{ product.specification || '--' }}
</el-descriptions-item>
</el-descriptions>
<BomInfo :bomId="product.bomId" />
</el-dialog>

View File

@@ -12,6 +12,7 @@
<el-descriptions-item label="原材料ID">{{ material.rawMaterialId }}</el-descriptions-item>
<el-descriptions-item label="原材料名称">{{ material.rawMaterialName }}</el-descriptions-item>
<el-descriptions-item label="原材料编码">{{ material.rawMaterialCode }}</el-descriptions-item>
<el-descriptions-item label="规格">{{ material.specification }}</el-descriptions-item>
</el-descriptions>
<BomInfo :bomId="material.bomId" />
</el-dialog>