🐞 fix: 部分位置需要判空

This commit is contained in:
砂糖
2025-08-11 16:17:27 +08:00
parent 542b481155
commit 6f415c44d1
7 changed files with 21 additions and 17 deletions

View File

@@ -48,7 +48,7 @@
},
_itemId: {
get() {
return this.itemId;
return this.itemId.toString();
},
set(val) {
this.$emit('update:itemId', val);

View File

@@ -63,9 +63,9 @@ export default {
let bomId = this.bomId;
if (!bomId) {
if (this.itemType === 'product') {
bomId = this.productMap[this.itemId].bomId;
bomId = this.productMap[this.itemId]?.bomId;
} else if (this.itemType === 'raw_material') {
bomId = this.rawMaterialMap[this.itemId].bomId;
bomId = this.rawMaterialMap[this.itemId]?.bomId;
}
}
if (!bomId) {

View File

@@ -63,12 +63,13 @@ export default {
let bomId = this.bomId;
if (!bomId) {
if (this.itemType === 'product') {
bomId = this.productMap[this.itemId].bomId;
bomId = this.productMap[this.itemId]?.bomId;
} else if (this.itemType === 'raw_material') {
bomId = this.rawMaterialMap[this.itemId].bomId;
bomId = this.rawMaterialMap[this.itemId]?.bomId;
}
}
if (!bomId) {
this.bomInfo = [];
return;
}
if (bomMap[bomId]) {

View File

@@ -62,9 +62,9 @@ export default {
watch: {
productId: {
handler(newVal) {
this.product = this.productMap && this.productMap[this.productId]
? { ...this.productMap[this.productId] }
: {};
const res = this.productMap[this.productId] ? this.productMap[this.productId] : {};
console.log(res)
this.product = res;
},
immediate: true
}

View File

@@ -3,7 +3,7 @@
<!-- 作用域插槽 -->
<span class="material-name" @click="showDetail = true">
<slot name="default" :material="material">
{{ material.rawMaterialName ? material.rawMaterialName : '--' }}
{{ material.rawMaterialName ? material.rawMaterialName : '-' }}
</slot>
</span>
<el-dialog :visible="showDetail" @close="showDetail = false" :title="material.rawMaterialName" width="600px"
@@ -47,7 +47,8 @@ export default {
watch: {
materialId: {
handler: function (newVal) {
const res = this.materialMap ? this.materialMap[this.materialId] : {};
const res = this.materialMap[this.materialId] ? this.materialMap[this.materialId] : {};
console.log(res)
this.material = res;
},
immediate: true

View File

@@ -5,6 +5,7 @@
<WarehouseSelect v-model="queryParams.warehouseId" placeholder="请选择仓库/库区/库位" clearable @change="getList" />
</el-form-item>
<MaterialSelect :itemType.sync="queryParams.itemType" :itemId.sync="queryParams.itemId" @change="getList" />
<el-form-item label="变动时间" prop="changeTime">
<el-date-picker
clearable
@@ -36,7 +37,7 @@
<el-table v-loading="loading" :data="stockLogList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="主键ID" align="center" prop="id" v-if="true"/>
<el-table-column label="仓库/库区/库位ID" align="center" prop="warehouseId" />
<el-table-column label="存储位置" align="center" prop="warehouseName" />
<el-table-column label="物品ID" align="center" prop="itemId">
<template slot-scope="scope">
<RawMaterialInfo v-if="scope.row.itemType == 'raw_material'" :material-id="scope.row.itemId" />
@@ -80,19 +81,20 @@
<!-- 添加或修改库存流水对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="仓库/库区/库位ID" prop="warehouseId" disabled>
<el-form-item label="存储位置" prop="warehouseId" disabled>
<el-input v-model="form.warehouseId" placeholder="请输入仓库/库区/库位ID" disabled />
</el-form-item>
<el-form-item label="物品ID" prop="itemId" disabled>
<el-input v-model="form.itemId" placeholder="请输入物品ID" disabled />
<el-form-item label="物品信息" prop="itemId" disabled>
<RawMaterialInfo v-if="form.itemType == 'raw_material'" :material-id="form.itemId" />
<ProductInfo v-else-if="form.itemType == 'product' || form.itemType == 'semi'" :product-id="form.itemId" />
</el-form-item>
<el-form-item label="变动数量" prop="changeQty" disabled>
<el-input v-model="form.changeQty" placeholder="请输入变动数量" disabled />
</el-form-item>
<el-form-item label="变动后的库存数量" prop="afterQty" disabled>
<el-form-item label="库存数量" prop="afterQty" disabled>
<el-input v-model="form.afterQty" placeholder="请输入变动后的库存数量" disabled />
</el-form-item>
<el-form-item label="实际库存变动时间" prop="changeTime" disabled>
<el-form-item label="变动时间" prop="changeTime" disabled>
<el-date-picker clearable
v-model="form.changeTime"
type="datetime"

View File

@@ -1,5 +1,5 @@
<template>
<StockIoPage ioType="move" />
<StockIoPage ioType="transfer" />
</template>
<script>