refactor(组件): 重构产品与原材料信息组件,使用直接传递对象替代ID映射

将ProductInfo和RawMaterialInfo组件从基于ID映射数据改为直接接收product/material对象
移除对vuex state的依赖和相关的计算属性
创建缓存版本组件ProductInfoCache和RawMaterialInfoCache
更新所有使用这些组件的视图文件以传递完整对象
This commit is contained in:
砂糖
2025-11-15 16:04:41 +08:00
parent 9e02caecf2
commit ef3a764b19
15 changed files with 291 additions and 85 deletions

View File

@@ -6,7 +6,7 @@
<el-button v-if="canAdd" @click="add" icon="el-icon-plus">未搜索到产品点击添加</el-button>
<div v-else style="padding: 10px;">未搜索到产品</div>
</template>
<el-option v-for="item in productOptions" :key="item.productId"
<el-option v-for="item in productList" :key="item.productId"
:label="getLabel(item)" :value="item.productId">
<div>
<div class="option-label">
@@ -55,14 +55,15 @@
<el-button @click="cancel"> </el-button>
</div>
<BomPanel v-if="activeStep === 1" :id="bomId" :itemId="itemId" :type="addForm.type" @addBom="handleBom" />
<!-- <BomPanel v-if="activeStep === 1" :id="bomId" :itemId="itemId" :type="addForm.type" @addBom="handleBom" /> -->
</el-dialog>
</span>
</template>
<script>
import { listProductWithBom, addProduct } from '@/api/wms/product';
import BomPanel from '../BomPanel/index.vue';
// import { listProductWithBom, addProduct } from '@/api/wms/product';
// import BomPanel from '../BomPanel/index.vue';
import { mapGetters } from 'vuex';
export default {
name: 'ProductSelect',
@@ -82,12 +83,12 @@ export default {
type: Boolean
}
},
components: {
BomPanel
},
// components: {
// BomPanel
// },
data() {
return {
productOptions: [],
// productOptions: [],
selected: this.value,
addForm: {
productCode: undefined,
@@ -136,15 +137,18 @@ export default {
}
}
},
computed: {
...mapGetters(['productList']),
},
created() {
this.getProductOptions();
// this.getProductOptions();
},
methods: {
getProductOptions() {
listProductWithBom({ pageNum: 1, pageSize: 1000 }).then(res => {
this.productOptions = res.rows || [];
});
},
// getProductOptions() {
// listProductWithBom({ pageNum: 1, pageSize: 1000 }).then(res => {
// this.productOptions = res.rows || [];
// });
// },
getLabel(item) {
// 产品名称[规格](参数),如果有则写,没有则省略
const sku = this.getSku(item);