refactor(组件): 重构产品与原材料信息组件,使用直接传递对象替代ID映射
将ProductInfo和RawMaterialInfo组件从基于ID映射数据改为直接接收product/material对象 移除对vuex state的依赖和相关的计算属性 创建缓存版本组件ProductInfoCache和RawMaterialInfoCache 更新所有使用这些组件的视图文件以传递完整对象
This commit is contained in:
@@ -64,12 +64,12 @@
|
||||
min-width="250"
|
||||
>
|
||||
<template slot-scope="scope">
|
||||
<ProductInfo v-if="scope.row.itemType === 'product'" :productId="scope.row.itemId">
|
||||
<ProductInfo v-if="scope.row.itemType === 'product'" :product="scope.row.product">
|
||||
<template #default="{ product }">
|
||||
{{ product.productName || '未知' }}({{ product.productCode || '无编码' }})
|
||||
</template>
|
||||
</ProductInfo>
|
||||
<RawMaterialInfo v-else-if="scope.row.itemType === 'raw_material'" :materialId="scope.row.itemId">
|
||||
<RawMaterialInfo v-else-if="scope.row.itemType === 'raw_material'" :material="scope.row.rawMaterial">
|
||||
<template #default="{ material }">
|
||||
{{ material.rawMaterialName || '未知' }}({{ material.rawMaterialCode || '无编码' }})
|
||||
</template>
|
||||
|
||||
@@ -45,12 +45,12 @@
|
||||
<!-- 物料ID/名称列:仅物料统计时有效 -->
|
||||
<el-table-column v-if="queryParams.statType === '1'" label="物料信息" align="center" min-width="250">
|
||||
<template slot-scope="scope">
|
||||
<ProductInfo v-if="scope.row.itemType === 'product'" :productId="scope.row.itemId">
|
||||
<ProductInfo v-if="scope.row.itemType === 'product'" :product="scope.row.product">
|
||||
<template #default="{ product }">
|
||||
{{ product.productName || '未知' }}({{ product.productCode || '无编码' }})
|
||||
</template>
|
||||
</ProductInfo>
|
||||
<RawMaterialInfo v-else-if="scope.row.itemType === 'raw_material'" :materialId="scope.row.itemId">
|
||||
<RawMaterialInfo v-else-if="scope.row.itemType === 'raw_material'" :material="scope.row.rawMaterial">
|
||||
<template #default="{ material }">
|
||||
{{ material.rawMaterialName || '未知' }}({{ material.rawMaterialCode || '无编码' }})
|
||||
</template>
|
||||
@@ -104,12 +104,12 @@
|
||||
</el-table-column>
|
||||
<el-table-column label="产品类型" align="center" min-width="250">
|
||||
<template slot-scope="scope">
|
||||
<ProductInfo v-if="scope.row.itemType === 'product'" :productId="scope.row.itemId">
|
||||
<ProductInfo v-if="scope.row.itemType === 'product'" :product="scope.row.product">
|
||||
<template #default="{ product }">
|
||||
{{ product.itemName || '未知' }}({{ product.itemCode || '无编码' }})
|
||||
</template>
|
||||
</ProductInfo>
|
||||
<RawMaterialInfo v-else-if="scope.row.itemType === 'raw_material'" :materialId="scope.row.itemId">
|
||||
<RawMaterialInfo v-else-if="scope.row.itemType === 'raw_material'" :material="scope.row.rawMaterial">
|
||||
<template #default="{ material }">
|
||||
{{ material.itemName || '未知' }}({{ material.itemCode || '无编码' }})
|
||||
</template>
|
||||
|
||||
@@ -64,12 +64,12 @@
|
||||
min-width="250"
|
||||
>
|
||||
<template slot-scope="scope">
|
||||
<ProductInfo v-if="scope.row.itemType === 'product'" :productId="scope.row.itemId">
|
||||
<ProductInfo v-if="scope.row.itemType === 'product'" :product="scope.row.product">
|
||||
<template #default="{ product }">
|
||||
{{ product.productName || '未知' }}({{ product.productCode || '无编码' }})
|
||||
</template>
|
||||
</ProductInfo>
|
||||
<RawMaterialInfo v-else-if="scope.row.itemType === 'raw_material'" :materialId="scope.row.itemId">
|
||||
<RawMaterialInfo v-else-if="scope.row.itemType === 'raw_material'" :material="scope.row.rawMaterial">
|
||||
<template #default="{ material }">
|
||||
{{ material.rawMaterialName || '未知' }}({{ material.rawMaterialCode || '无编码' }})
|
||||
</template>
|
||||
|
||||
@@ -47,12 +47,12 @@
|
||||
</el-table-column>
|
||||
<el-table-column label="产品类型" align="center" min-width="250">
|
||||
<template slot-scope="scope">
|
||||
<ProductInfo v-if="scope.row.itemType === 'product'" :productId="scope.row.itemId">
|
||||
<ProductInfo v-if="scope.row.itemType === 'product'" :product="scope.row.product">
|
||||
<template #default="{ product }">
|
||||
{{ product.productName || '未知' }}({{ product.productCode || '无编码' }})
|
||||
</template>
|
||||
</ProductInfo>
|
||||
<RawMaterialInfo v-else-if="scope.row.itemType === 'raw_material'" :materialId="scope.row.itemId">
|
||||
<RawMaterialInfo v-else-if="scope.row.itemType === 'raw_material'" :material="scope.row.rawMaterial">
|
||||
<template #default="{ material }">
|
||||
{{ material.rawMaterialName || '未知' }}({{ material.rawMaterialCode || '无编码' }})
|
||||
</template>
|
||||
|
||||
@@ -84,12 +84,12 @@
|
||||
<el-table-column label="物料类型" align="center" prop="materialType" />
|
||||
<el-table-column label="产品类型" align="center" prop="itemName">
|
||||
<template slot-scope="scope">
|
||||
<ProductInfo v-if="scope.row.itemType == 'product'" :productId="scope.row.itemId">
|
||||
<ProductInfo v-if="scope.row.itemType == 'product'" :product="scope.row.product">
|
||||
<template slot-scope="{ product }">
|
||||
{{ product.productName }}[{{ product.specification }}]
|
||||
</template>
|
||||
</ProductInfo>
|
||||
<RawMaterialInfo v-else-if="scope.row.itemType === 'raw_material'" :materialId="scope.row.itemId">
|
||||
<RawMaterialInfo v-else-if="scope.row.itemType === 'raw_material'" :material="scope.row.rawMaterial">
|
||||
<template slot-scope="{ material }">
|
||||
{{ material.rawMaterialName }}[{{ material.specification }}]
|
||||
</template>
|
||||
|
||||
Reference in New Issue
Block a user