BOM展示组件封装
This commit is contained in:
@@ -0,0 +1,41 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<el-descriptions :column="1" border v-if="bomInfo.length > 0">
|
||||||
|
<el-descriptions-item v-for="item in bomInfo" :key="item.attrKey" :label="item.attrKey">
|
||||||
|
{{ item.attrValue }}
|
||||||
|
</el-descriptions-item>
|
||||||
|
</el-descriptions>
|
||||||
|
<div v-else>
|
||||||
|
<el-empty description="暂无BOM信息" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { listBomItem } from '../../../api/wms/bomItem';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'BomInfo',
|
||||||
|
props: {
|
||||||
|
bomId: {
|
||||||
|
type: [String, Number],
|
||||||
|
required: true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
bomInfo: []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
this.getBomInfo();
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
getBomInfo() {
|
||||||
|
listBomItem({ bomId: this.bomId }).then(res => {
|
||||||
|
this.bomInfo = res.rows;
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
@@ -5,20 +5,38 @@
|
|||||||
{{ product.productName ? product.productName : '--' }}
|
{{ product.productName ? product.productName : '--' }}
|
||||||
</slot>
|
</slot>
|
||||||
</span>
|
</span>
|
||||||
<el-dialog :visible="showDetail" @close="showDetail = false" title="产品信息" width="400px" append-to-body>
|
<el-dialog
|
||||||
<div>
|
:visible="showDetail"
|
||||||
<p><strong>ID:</strong> {{ product.productId }}</p>
|
@close="showDetail = false"
|
||||||
<p><strong>名称:</strong> {{ product.productName }}</p>
|
title="产品信息"
|
||||||
<p><strong>描述:</strong> {{ product.productCode }}</p>
|
width="500px"
|
||||||
</div>
|
append-to-body
|
||||||
|
>
|
||||||
|
<el-descriptions :column="1" border>
|
||||||
|
<el-descriptions-item label="ID">
|
||||||
|
{{ product.productId || '--' }}
|
||||||
|
</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="名称">
|
||||||
|
{{ product.productName || '--' }}
|
||||||
|
</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="产品编码">
|
||||||
|
{{ product.productCode || '--' }}
|
||||||
|
</el-descriptions-item>
|
||||||
|
</el-descriptions>
|
||||||
|
<BomInfo :bomId="product.bomId" />
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { mapState } from 'vuex';
|
import { mapState } from 'vuex';
|
||||||
|
import BomInfo from './BomInfo.vue';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'ProductInfo',
|
name: 'ProductInfo',
|
||||||
|
components: {
|
||||||
|
BomInfo
|
||||||
|
},
|
||||||
props: {
|
props: {
|
||||||
productId: {
|
productId: {
|
||||||
type: [String, Number],
|
type: [String, Number],
|
||||||
@@ -33,21 +51,24 @@ export default {
|
|||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapState({
|
...mapState({
|
||||||
productMap: state => state.category.productMap // 假设vuex中为product模块
|
productMap: state => state.category.productMap
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
clickHandle() {
|
clickHandle() {
|
||||||
console.log('clickHandle');
|
console.log('clickHandle');
|
||||||
this.showDetail = true;
|
this.showDetail = true;
|
||||||
|
},
|
||||||
|
getStatusText(status) {
|
||||||
|
return status === 1 ? '启用中' : '已禁用';
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
productId: {
|
productId: {
|
||||||
handler: function (newVal) {
|
handler(newVal) {
|
||||||
const res = this.productMap ? this.productMap[this.productId] : {};
|
this.product = this.productMap && this.productMap[this.productId]
|
||||||
console.log(this.productMap, this.productId, 'productMap', 'productId', res);
|
? { ...this.productMap[this.productId] }
|
||||||
this.product = res;
|
: {};
|
||||||
},
|
},
|
||||||
immediate: true
|
immediate: true
|
||||||
}
|
}
|
||||||
@@ -61,4 +82,9 @@ export default {
|
|||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
text-decoration: underline;
|
text-decoration: underline;
|
||||||
}
|
}
|
||||||
</style>
|
|
||||||
|
/* 可选:调整描述列表的外边距 */
|
||||||
|
:deep(.el-descriptions) {
|
||||||
|
margin-top: -10px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -8,11 +8,13 @@
|
|||||||
</span>
|
</span>
|
||||||
<el-dialog :visible="showDetail" @close="showDetail = false" :title="material.name" width="400px"
|
<el-dialog :visible="showDetail" @close="showDetail = false" :title="material.name" width="400px"
|
||||||
append-to-body>
|
append-to-body>
|
||||||
<div>
|
<el-descriptions :column="1" border>
|
||||||
<p><strong>ID:</strong> {{ material.rawMaterialId }}</p>
|
<el-descriptions-item label="ID">{{ material.rawMaterialId }}</el-descriptions-item>
|
||||||
<p><strong>名称:</strong> {{ material.rawMaterialName }}</p>
|
<el-descriptions-item label="名称">{{ material.rawMaterialName }}</el-descriptions-item>
|
||||||
<p><strong>描述:</strong> {{ material.rawMaterialCode }}</p>
|
<el-descriptions-item label="描述">{{ material.rawMaterialCode }}</el-descriptions-item>
|
||||||
</div>
|
</el-descriptions>
|
||||||
|
|
||||||
|
<BomInfo :bomId="material.bomId" />
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
Reference in New Issue
Block a user