Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
M
mini-wms
概览
Overview
Details
Activity
Cycle Analytics
版本库
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
问题
0
Issues
0
列表
Board
标记
里程碑
合并请求
0
Merge Requests
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
Snippets
成员
Members
Collapse sidebar
Close sidebar
活动
图像
聊天
创建新问题
作业
提交
Issue Boards
Open sidebar
周海峰
mini-wms
Commits
1f9d9564
Commit
1f9d9564
authored
Dec 16, 2025
by
yubin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
组件双击 去选框 弹窗修改高度 物料根据库存排序反显 列表id修改
parent
b0192161
显示空白字符变更
内嵌
并排
正在显示
15 个修改的文件
包含
820 行增加
和
515 行删除
+820
-515
ruoyi-admin-vue/src/api/inventory/items.js
+7
-1
ruoyi-admin-vue/src/api/inventory/materials.js
+7
-0
ruoyi-admin-vue/src/components/materialsSeletor.vue
+203
-61
ruoyi-admin-vue/src/views/inventory/locations/index.vue
+355
-338
ruoyi-admin-vue/src/views/inventory/orders/OutboundOrderFormWithItems.vue
+78
-91
ruoyi-admin-vue/src/views/inventory/orders/index.vue
+22
-20
ruoyi-admin/src/main/java/com/ruoyi/web/controller/inventory/MaterialsController.java
+15
-0
ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/Materials.java
+17
-4
ruoyi-inventory/src/main/java/com/ruoyi/inventory/controller/InventoryController.java
+3
-0
ruoyi-inventory/src/main/java/com/ruoyi/inventory/controller/OutboundOrderItemsController.java
+19
-0
ruoyi-inventory/src/main/java/com/ruoyi/inventory/mapper/MaterialsMapper.java
+11
-0
ruoyi-inventory/src/main/java/com/ruoyi/inventory/service/IMaterialsService.java
+8
-0
ruoyi-inventory/src/main/java/com/ruoyi/inventory/service/impl/InventoryServiceImpl.java
+1
-0
ruoyi-inventory/src/main/java/com/ruoyi/inventory/service/impl/MaterialsServiceImpl.java
+6
-0
ruoyi-inventory/src/main/resources/mapper/inventory/MaterialsMapper.xml
+68
-0
没有找到文件。
ruoyi-admin-vue/src/api/inventory/items.js
View file @
1f9d9564
...
@@ -8,7 +8,13 @@ export function listItems(query) {
...
@@ -8,7 +8,13 @@ export function listItems(query) {
params
:
query
params
:
query
})
})
}
}
export
function
listLog
(
query
)
{
return
request
({
url
:
'/inventory/items/listLog'
,
method
:
'get'
,
params
:
query
})
}
export
function
getStatistics
(
query
)
{
export
function
getStatistics
(
query
)
{
return
request
({
return
request
({
url
:
'/inventory/items/getStatistics'
,
url
:
'/inventory/items/getStatistics'
,
...
...
ruoyi-admin-vue/src/api/inventory/materials.js
View file @
1f9d9564
...
@@ -49,3 +49,10 @@ export function getMaterialsdicts() {
...
@@ -49,3 +49,10 @@ export function getMaterialsdicts() {
method
:
'get'
method
:
'get'
})
})
}
}
export
function
ListMaterialsInventory
(
query
){
return
request
({
url
:
'/inventory/materials/ListMaterialsInventory'
,
method
:
'post'
,
params
:
query
})
}
ruoyi-admin-vue/src/components/materialsSeletor.vue
View file @
1f9d9564
<
template
>
<
template
>
<div
class=
"material-selector-container"
style=
"overflow: hidden;"
>
<div
class=
"material-selector-container"
>
<splitpanes
class=
"default-theme"
>
<splitpanes
class=
"default-theme"
>
<!-- 左侧分类树 -->
<!-- 左侧分类树 -->
<pane
size=
"16"
style=
"overflow: auto;
"
>
<pane
size=
"16"
class=
"tree-pane
"
>
<TreeComponent
<TreeComponent
ref=
"treeComponent"
ref=
"treeComponent"
:tree-data=
"categoryTreeData"
:tree-data=
"categoryTreeData"
...
@@ -22,9 +22,8 @@
...
@@ -22,9 +22,8 @@
</pane>
</pane>
<!-- 右侧物料列表 -->
<!-- 右侧物料列表 -->
<pane
size=
"84"
style=
"overflow: auto;"
>
<pane
size=
"84"
class=
"table-pane"
>
<div
style=
"padding: 10px; display: flex; flex-direction: column;"
>
<div
class=
"table-header"
>
<!-- 查询表单(恢复所有查询项,保留ID核心逻辑) -->
<el-form
:model=
"queryParams"
ref=
"queryForm"
size=
"small"
:inline=
"true"
label-width=
"88px"
>
<el-form
:model=
"queryParams"
ref=
"queryForm"
size=
"small"
:inline=
"true"
label-width=
"88px"
>
<el-form-item
label=
"SAP物料号"
prop=
"sapNo"
>
<el-form-item
label=
"SAP物料号"
prop=
"sapNo"
>
<el-input
<el-input
...
@@ -55,9 +54,10 @@
...
@@ -55,9 +54,10 @@
<el-button
icon=
"el-icon-refresh"
size=
"mini"
@
click=
"resetQuery"
>
重置
</el-button>
<el-button
icon=
"el-icon-refresh"
size=
"mini"
@
click=
"resetQuery"
>
重置
</el-button>
</el-form-item>
</el-form-item>
</el-form>
</el-form>
</div>
<div
class=
"table-container"
style=
"flex: 1; min-height: 400px; max-height: 600px; overflow: auto; margin: 10px 0;"
>
<!-- 表格容器:唯一滚动区域 --
>
<!-- 物料表格(恢复所有字段显示) --
>
<div
class=
"table-container"
>
<el-table
<el-table
ref=
"materialTable"
ref=
"materialTable"
v-loading=
"loading"
v-loading=
"loading"
...
@@ -95,10 +95,20 @@
...
@@ -95,10 +95,20 @@
</el-tag>
</el-tag>
</
template
>
</
template
>
</el-table-column>
</el-table-column>
<el-table-column
label=
"原始库存"
align=
"center"
prop=
"originalStock"
/>
<el-table-column
label=
"新增数量"
align=
"center"
prop=
"addedQuantity"
/>
<el-table-column
label=
"可用库存"
align=
"center"
prop=
"availableStock"
>
<
template
slot-scope=
"scope"
>
<span
:style=
"
{color: scope.row.availableStock
<
=
0
?
'
red
'
:
'
inherit
'}"
>
{{
scope
.
row
.
availableStock
}}
</span>
</
template
>
</el-table-column>
</el-table>
</el-table>
</div>
</div>
<!-- 分页 -->
<!-- 分页:固定在底部 -->
<div
class=
"pagination-container"
>
<pagination
<pagination
v-show=
"total>0"
v-show=
"total>0"
:total=
"total"
:total=
"total"
...
@@ -113,8 +123,9 @@
...
@@ -113,8 +123,9 @@
</template>
</template>
<
script
>
<
script
>
import
{
listMaterials
}
from
"@/api/inventory/materials"
import
{
ListMaterialsInventory
}
from
"@/api/inventory/materials"
import
{
listMaterials_category
}
from
"@/api/inventory/materials_category"
import
{
listMaterials_category
}
from
"@/api/inventory/materials_category"
import
{
listLog
}
from
"@/api/inventory/items"
import
TreeComponent
from
'@/views/inventory/materials_category/treeComponent.vue'
import
TreeComponent
from
'@/views/inventory/materials_category/treeComponent.vue'
import
{
Splitpanes
,
Pane
}
from
'splitpanes'
import
{
Splitpanes
,
Pane
}
from
'splitpanes'
import
'splitpanes/dist/splitpanes.css'
import
'splitpanes/dist/splitpanes.css'
...
@@ -135,9 +146,17 @@ export default {
...
@@ -135,9 +146,17 @@ export default {
type
:
Array
,
type
:
Array
,
default
:
()
=>
[]
default
:
()
=>
[]
},
},
selectedMaterialIds
:
{
// 核心:基于ID的选中项
selectedMaterialIds
:
{
type
:
Array
,
type
:
Array
,
default
:
()
=>
[]
default
:
()
=>
[]
},
detailList
:
{
type
:
Array
,
default
:
()
=>
[]
},
ordersId
:
{
type
:
[
String
,
Number
],
default
:
''
}
}
},
},
data
()
{
data
()
{
...
@@ -146,11 +165,11 @@ export default {
...
@@ -146,11 +165,11 @@ export default {
treeProps
:
{
children
:
'children'
,
label
:
'label'
,
value
:
'sid'
},
treeProps
:
{
children
:
'children'
,
label
:
'label'
,
value
:
'sid'
},
nodeKey
:
'sid'
,
nodeKey
:
'sid'
,
loadingTree
:
false
,
loadingTree
:
false
,
categoryMap
:
{},
// 恢复分类名称映射(显示用)
categoryMap
:
{},
categoryNameToCodeMap
:
{},
// 恢复分类名称转编码(查询用)
categoryNameToCodeMap
:
{},
categoryCodeToSidMap
:
{},
// 恢复分类编码转SID(树选择用)
categoryCodeToSidMap
:
{},
currentNodeId
:
null
,
currentNodeId
:
null
,
queryParams
:
{
// 恢复所有查询参数(显示+查询用)
queryParams
:
{
pageNum
:
1
,
pageNum
:
1
,
pageSize
:
10
,
pageSize
:
10
,
sapNo
:
null
,
sapNo
:
null
,
...
@@ -166,7 +185,10 @@ export default {
...
@@ -166,7 +185,10 @@ export default {
selectedRows
:
[],
selectedRows
:
[],
singleSelectedId
:
null
,
singleSelectedId
:
null
,
isSelecting
:
false
,
isSelecting
:
false
,
isRetrySync
:
false
isRetrySync
:
false
,
inventoryCache
:
{},
// 新增:存储listLog返回的订单明细数据
orderLogData
:
[]
}
}
},
},
watch
:
{
watch
:
{
...
@@ -218,29 +240,93 @@ export default {
...
@@ -218,29 +240,93 @@ export default {
})
})
}
}
}
}
},
detailList
:
{
immediate
:
true
,
deep
:
true
,
handler
()
{
if
(
this
.
materialsList
.
length
>
0
)
{
this
.
calculateMaterialStock
()
}
}
},
// 监听订单ID变化,重新获取日志数据并计算库存
ordersId
:
{
immediate
:
true
,
handler
(
val
)
{
console
.
log
(
'MaterialSelector 接收的 ordersId 更新:'
,
val
);
if
(
val
)
{
this
.
getOrderLogData
(
val
)
}
}
}
}
},
},
async
created
()
{
async
created
()
{
// 恢复分类列表和树数据加载(显示分类名称用)
await
Promise
.
all
([
this
.
getCategoryList
(),
this
.
getCategoryTreeData
()])
await
Promise
.
all
([
this
.
getCategoryList
(),
this
.
getCategoryTreeData
()])
// 如果有订单ID,先获取日志数据
if
(
this
.
ordersId
)
{
await
this
.
getOrderLogData
(
this
.
ordersId
)
}
this
.
getList
()
this
.
getList
()
console
.
log
(
'父组件接收的 ordersId:'
,
this
.
ordersId
);
},
},
methods
:
{
methods
:
{
// 新增:双击行事件处理
// 新增:获取订单日志数据(listLog接口)
async
getOrderLogData
(
orderId
)
{
try
{
const
res
=
await
listLog
({
orderId
})
if
(
res
.
code
===
200
&&
res
.
rows
)
{
this
.
orderLogData
=
res
.
rows
console
.
log
(
'获取订单日志数据成功:'
,
this
.
orderLogData
)
// 获取数据后重新计算库存
if
(
this
.
materialsList
.
length
>
0
)
{
this
.
calculateMaterialStock
()
}
}
}
catch
(
error
)
{
console
.
error
(
'获取订单日志数据失败:'
,
error
)
}
},
// 重写:库存计算逻辑(可用库存 = 原始库存 + actualQuantity)
calculateMaterialStock
()
{
console
.
log
(
"开始计算库存 - 订单日志数据:"
,
this
.
orderLogData
)
if
(
!
this
.
orderLogData
.
length
)
return
// 按materialId汇总actualQuantity
const
materialQtyMap
=
{}
this
.
orderLogData
.
forEach
(
item
=>
{
const
materialId
=
item
.
materialId
const
actualQty
=
Number
(
item
.
actualQuantity
)
||
0
if
(
!
materialQtyMap
[
materialId
])
{
materialQtyMap
[
materialId
]
=
0
}
materialQtyMap
[
materialId
]
+=
actualQty
})
// 更新物料列表的库存数据
this
.
materialsList
.
forEach
(
material
=>
{
const
addedQty
=
materialQtyMap
[
material
.
id
]
||
0
// 新增数量
this
.
$set
(
material
,
'addedQuantity'
,
addedQty
)
// 可用库存 = 原始库存 + 新增数量
this
.
$set
(
material
,
'availableStock'
,
(
material
.
originalStock
||
0
)
+
addedQty
)
})
},
// 双击行事件处理
handleRowDblClick
(
row
)
{
handleRowDblClick
(
row
)
{
if
(
this
.
isSelecting
||
!
this
.
$refs
.
materialTable
)
return
if
(
this
.
isSelecting
||
!
this
.
$refs
.
materialTable
)
return
this
.
isSelecting
=
true
this
.
isSelecting
=
true
try
{
try
{
// 单选模式下双击直接选择并关闭组件
if
(
!
this
.
multiple
)
{
if
(
!
this
.
multiple
)
{
// 选中当前行
this
.
$refs
.
materialTable
.
clearSelection
()
this
.
$refs
.
materialTable
.
clearSelection
()
this
.
$refs
.
materialTable
.
toggleRowSelection
(
row
,
true
)
this
.
$refs
.
materialTable
.
toggleRowSelection
(
row
,
true
)
this
.
singleSelectedId
=
row
.
id
this
.
singleSelectedId
=
row
.
id
this
.
selectedRows
=
[
row
]
this
.
selectedRows
=
[
row
]
// 构造返回数据
const
selectedData
=
{
const
selectedData
=
{
id
:
row
.
id
,
id
:
row
.
id
,
sapNo
:
row
.
sapNo
,
sapNo
:
row
.
sapNo
,
...
@@ -250,10 +336,12 @@ export default {
...
@@ -250,10 +336,12 @@ export default {
categoryName
:
this
.
categoryMap
[
row
.
categoryCode
]
||
row
.
categoryCode
,
categoryName
:
this
.
categoryMap
[
row
.
categoryCode
]
||
row
.
categoryCode
,
specification
:
row
.
specification
,
specification
:
row
.
specification
,
materialUnit
:
row
.
materialUnit
,
materialUnit
:
row
.
materialUnit
,
isBatchManaged
:
row
.
isBatchManaged
isBatchManaged
:
row
.
isBatchManaged
,
originalStock
:
row
.
originalStock
,
addedQuantity
:
row
.
addedQuantity
,
availableStock
:
row
.
availableStock
}
}
// 触发事件
this
.
$emit
(
'input'
,
row
.
id
)
this
.
$emit
(
'input'
,
row
.
id
)
this
.
$emit
(
'change'
,
selectedData
)
this
.
$emit
(
'change'
,
selectedData
)
this
.
$emit
(
'selection-change'
,
{
this
.
$emit
(
'selection-change'
,
{
...
@@ -263,11 +351,9 @@ export default {
...
@@ -263,11 +351,9 @@ export default {
categoryIds
:
[
row
.
categoryCode
||
''
]
categoryIds
:
[
row
.
categoryCode
||
''
]
})
})
// 触发关闭事件(需要父组件监听此事件并关闭弹窗)
this
.
$emit
(
'confirm'
,
selectedData
)
this
.
$emit
(
'confirm'
,
selectedData
)
this
.
$emit
(
'close'
)
this
.
$emit
(
'close'
)
}
else
{
}
else
{
// 多选模式下双击仅切换选择状态
this
.
$refs
.
materialTable
.
toggleRowSelection
(
row
)
this
.
$refs
.
materialTable
.
toggleRowSelection
(
row
)
}
}
}
finally
{
}
finally
{
...
@@ -275,7 +361,7 @@ export default {
...
@@ -275,7 +361,7 @@ export default {
}
}
},
},
//
恢复分类列表加载(分类名称映射)
//
获取分类列表
async
getCategoryList
()
{
async
getCategoryList
()
{
try
{
try
{
const
response
=
await
listMaterials_category
({
pageNum
:
1
,
pageSize
:
1000
})
const
response
=
await
listMaterials_category
({
pageNum
:
1
,
pageSize
:
1000
})
...
@@ -402,15 +488,29 @@ export default {
...
@@ -402,15 +488,29 @@ export default {
this
.
getList
()
this
.
getList
()
},
},
// 改造:获取物料列表并初始化库存字段
getList
()
{
getList
()
{
this
.
loading
=
true
this
.
loading
=
true
listMaterials
(
this
.
queryParams
).
then
(
response
=>
{
ListMaterialsInventory
(
this
.
queryParams
).
then
(
response
=>
{
// 恢复所有字段映射(显示用)
const
materialRows
=
(
response
.
rows
||
[]).
filter
(
item
=>
item
.
isUsed
!==
0
&&
item
.
isUsed
!==
'0'
).
map
(
item
=>
({
this
.
materialsList
=
(
response
.
rows
||
[]).
filter
(
item
=>
item
.
isUsed
!==
0
&&
item
.
isUsed
!==
'0'
).
map
(
item
=>
({
...
item
,
...
item
,
displayCategory
:
this
.
categoryMap
[
item
.
categoryCode
]
||
'未匹配分类'
displayCategory
:
this
.
categoryMap
[
item
.
categoryCode
]
||
'未匹配分类'
,
originalStock
:
item
.
stock
||
0
,
// 原始库存
addedQuantity
:
0
,
// 初始化新增数量(actualQuantity)
availableStock
:
item
.
stock
||
0
// 初始化可用库存
}))
}))
this
.
materialsList
=
materialRows
this
.
total
=
response
.
total
||
0
this
.
total
=
response
.
total
||
0
// 缓存库存数据
materialRows
.
forEach
(
item
=>
{
this
.
inventoryCache
[
item
.
id
]
=
item
.
stock
||
0
})
// 计算库存(可用库存 = 原始库存 + actualQuantity)
this
.
calculateMaterialStock
()
this
.
$nextTick
(()
=>
{
this
.
$nextTick
(()
=>
{
setTimeout
(()
=>
this
.
handleValueSync
(),
400
)
setTimeout
(()
=>
this
.
handleValueSync
(),
400
)
})
})
...
@@ -424,7 +524,6 @@ export default {
...
@@ -424,7 +524,6 @@ export default {
},
},
handleQuery
()
{
handleQuery
()
{
// 恢复分类名称查询逻辑
const
inputName
=
this
.
queryParams
.
categoryNameInput
const
inputName
=
this
.
queryParams
.
categoryNameInput
if
(
inputName
)
{
if
(
inputName
)
{
const
matchedCode
=
this
.
categoryNameToCodeMap
[
inputName
]
const
matchedCode
=
this
.
categoryNameToCodeMap
[
inputName
]
...
@@ -444,7 +543,6 @@ export default {
...
@@ -444,7 +543,6 @@ export default {
},
},
resetQuery
()
{
resetQuery
()
{
// 恢复所有查询参数重置
this
.
queryParams
=
{
this
.
queryParams
=
{
pageNum
:
1
,
pageNum
:
1
,
pageSize
:
10
,
pageSize
:
10
,
...
@@ -463,7 +561,7 @@ export default {
...
@@ -463,7 +561,7 @@ export default {
this
.
getList
()
this
.
getList
()
},
},
//
核心:基于 ID 的选择事件(保留所有字段返回)
//
改造:选择事件返回新增的库存数据
handleSelectionChange
(
selection
)
{
handleSelectionChange
(
selection
)
{
if
(
this
.
isSelecting
||
!
this
.
$refs
.
materialTable
)
return
if
(
this
.
isSelecting
||
!
this
.
$refs
.
materialTable
)
return
...
@@ -474,8 +572,8 @@ export default {
...
@@ -474,8 +572,8 @@ export default {
const
lastRow
=
selection
.
pop
()
const
lastRow
=
selection
.
pop
()
this
.
$refs
.
materialTable
.
clearSelection
()
this
.
$refs
.
materialTable
.
clearSelection
()
this
.
$refs
.
materialTable
.
toggleRowSelection
(
lastRow
,
true
)
this
.
$refs
.
materialTable
.
toggleRowSelection
(
lastRow
,
true
)
this
.
selectedRows
=
[
lastRow
]
this
.
singleSelectedId
=
lastRow
.
id
this
.
singleSelectedId
=
lastRow
.
id
this
.
selectedRows
=
[
lastRow
]
}
else
{
}
else
{
this
.
selectedRows
=
selection
this
.
selectedRows
=
selection
this
.
singleSelectedId
=
selection
.
length
>
0
?
selection
[
0
].
id
:
null
this
.
singleSelectedId
=
selection
.
length
>
0
?
selection
[
0
].
id
:
null
...
@@ -484,7 +582,6 @@ export default {
...
@@ -484,7 +582,6 @@ export default {
this
.
selectedRows
=
selection
this
.
selectedRows
=
selection
}
}
// 返回数据保留所有字段,但核心标识为id
const
selectedIds
=
this
.
selectedRows
.
map
(
row
=>
row
.
id
)
const
selectedIds
=
this
.
selectedRows
.
map
(
row
=>
row
.
id
)
const
selectedData
=
this
.
selectedRows
.
map
(
item
=>
({
const
selectedData
=
this
.
selectedRows
.
map
(
item
=>
({
id
:
item
.
id
,
id
:
item
.
id
,
...
@@ -495,18 +592,21 @@ export default {
...
@@ -495,18 +592,21 @@ export default {
categoryName
:
this
.
categoryMap
[
item
.
categoryCode
]
||
item
.
categoryCode
,
categoryName
:
this
.
categoryMap
[
item
.
categoryCode
]
||
item
.
categoryCode
,
specification
:
item
.
specification
,
specification
:
item
.
specification
,
materialUnit
:
item
.
materialUnit
,
materialUnit
:
item
.
materialUnit
,
isBatchManaged
:
item
.
isBatchManaged
isBatchManaged
:
item
.
isBatchManaged
,
originalStock
:
item
.
originalStock
,
addedQuantity
:
item
.
addedQuantity
,
availableStock
:
item
.
availableStock
}))
}))
this
.
$emit
(
'selection-change'
,
{
this
.
$emit
(
'selection-change'
,
{
materialIds
:
selectedIds
,
// 核心:返回ID数组
materialIds
:
selectedIds
,
materials
:
selectedData
,
// 保留所有字段数据
materials
:
selectedData
,
names
:
selectedData
.
map
(
item
=>
item
.
materialName
),
names
:
selectedData
.
map
(
item
=>
item
.
materialName
),
categoryIds
:
selectedData
.
map
(
item
=>
item
.
categoryCode
)
categoryIds
:
selectedData
.
map
(
item
=>
item
.
categoryCode
)
})
})
if
(
this
.
multiple
)
{
if
(
this
.
multiple
)
{
this
.
$emit
(
'input'
,
selectedIds
)
// v-model绑定ID
this
.
$emit
(
'input'
,
selectedIds
)
this
.
$emit
(
'change'
,
selectedData
)
this
.
$emit
(
'change'
,
selectedData
)
}
else
{
}
else
{
const
singleId
=
selectedIds
.
length
>
0
?
selectedIds
[
0
]
:
''
const
singleId
=
selectedIds
.
length
>
0
?
selectedIds
[
0
]
:
''
...
@@ -519,7 +619,6 @@ export default {
...
@@ -519,7 +619,6 @@ export default {
}
}
},
},
// 单选模式下的选择事件(纯 ID 逻辑,保留字段返回)
handleTableSelect
(
selection
,
row
)
{
handleTableSelect
(
selection
,
row
)
{
if
(
this
.
isSelecting
||
this
.
multiple
)
return
if
(
this
.
isSelecting
||
this
.
multiple
)
return
...
@@ -531,7 +630,6 @@ export default {
...
@@ -531,7 +630,6 @@ export default {
this
.
$refs
.
materialTable
.
toggleRowSelection
(
row
,
true
)
this
.
$refs
.
materialTable
.
toggleRowSelection
(
row
,
true
)
this
.
singleSelectedId
=
row
.
id
this
.
singleSelectedId
=
row
.
id
this
.
selectedRows
=
[
row
]
this
.
selectedRows
=
[
row
]
// 返回完整字段数据
const
selectedData
=
{
const
selectedData
=
{
id
:
row
.
id
,
id
:
row
.
id
,
sapNo
:
row
.
sapNo
,
sapNo
:
row
.
sapNo
,
...
@@ -541,7 +639,10 @@ export default {
...
@@ -541,7 +639,10 @@ export default {
categoryName
:
this
.
categoryMap
[
row
.
categoryCode
]
||
row
.
categoryCode
,
categoryName
:
this
.
categoryMap
[
row
.
categoryCode
]
||
row
.
categoryCode
,
specification
:
row
.
specification
,
specification
:
row
.
specification
,
materialUnit
:
row
.
materialUnit
,
materialUnit
:
row
.
materialUnit
,
isBatchManaged
:
row
.
isBatchManaged
isBatchManaged
:
row
.
isBatchManaged
,
originalStock
:
row
.
originalStock
,
addedQuantity
:
row
.
addedQuantity
,
availableStock
:
row
.
availableStock
}
}
this
.
$emit
(
'input'
,
row
.
id
)
this
.
$emit
(
'input'
,
row
.
id
)
this
.
$emit
(
'change'
,
selectedData
)
this
.
$emit
(
'change'
,
selectedData
)
...
@@ -568,7 +669,6 @@ export default {
...
@@ -568,7 +669,6 @@ export default {
}
}
},
},
// 行点击事件(纯 ID 逻辑,保留字段返回)
handleRowClick
(
row
)
{
handleRowClick
(
row
)
{
if
(
this
.
isSelecting
||
!
this
.
$refs
.
materialTable
)
return
if
(
this
.
isSelecting
||
!
this
.
$refs
.
materialTable
)
return
...
@@ -582,7 +682,6 @@ export default {
...
@@ -582,7 +682,6 @@ export default {
this
.
$refs
.
materialTable
.
toggleRowSelection
(
row
,
true
)
this
.
$refs
.
materialTable
.
toggleRowSelection
(
row
,
true
)
this
.
singleSelectedId
=
row
.
id
this
.
singleSelectedId
=
row
.
id
this
.
selectedRows
=
[
row
]
this
.
selectedRows
=
[
row
]
// 返回完整字段数据
const
selectedData
=
{
const
selectedData
=
{
id
:
row
.
id
,
id
:
row
.
id
,
sapNo
:
row
.
sapNo
,
sapNo
:
row
.
sapNo
,
...
@@ -592,7 +691,10 @@ export default {
...
@@ -592,7 +691,10 @@ export default {
categoryName
:
this
.
categoryMap
[
row
.
categoryCode
]
||
row
.
categoryCode
,
categoryName
:
this
.
categoryMap
[
row
.
categoryCode
]
||
row
.
categoryCode
,
specification
:
row
.
specification
,
specification
:
row
.
specification
,
materialUnit
:
row
.
materialUnit
,
materialUnit
:
row
.
materialUnit
,
isBatchManaged
:
row
.
isBatchManaged
isBatchManaged
:
row
.
isBatchManaged
,
originalStock
:
row
.
originalStock
,
addedQuantity
:
row
.
addedQuantity
,
availableStock
:
row
.
availableStock
}
}
this
.
$emit
(
'input'
,
row
.
id
)
this
.
$emit
(
'input'
,
row
.
id
)
this
.
$emit
(
'change'
,
selectedData
)
this
.
$emit
(
'change'
,
selectedData
)
...
@@ -622,7 +724,6 @@ export default {
...
@@ -622,7 +724,6 @@ export default {
}
}
},
},
// 清空选择(纯 ID 逻辑)
clearSelection
()
{
clearSelection
()
{
if
(
this
.
isSelecting
||
!
this
.
$refs
.
materialTable
)
return
if
(
this
.
isSelecting
||
!
this
.
$refs
.
materialTable
)
return
...
@@ -644,13 +745,11 @@ export default {
...
@@ -644,13 +745,11 @@ export default {
}
}
},
},
// 核心:基于 ID 的反显逻辑(保留所有字段显示)
handleValueSync
(
isRetry
=
false
)
{
handleValueSync
(
isRetry
=
false
)
{
if
(
this
.
loading
||
this
.
isSelecting
||
!
this
.
$refs
.
materialTable
)
return
if
(
this
.
loading
||
this
.
isSelecting
||
!
this
.
$refs
.
materialTable
)
return
if
(
isRetry
)
this
.
isRetrySync
=
true
if
(
isRetry
)
this
.
isRetrySync
=
true
// 优先使用 selectedMaterialIds,其次是 value
const
val
=
this
.
selectedMaterialIds
.
length
?
this
.
selectedMaterialIds
:
this
.
value
const
val
=
this
.
selectedMaterialIds
.
length
?
this
.
selectedMaterialIds
:
this
.
value
if
(
!
val
||
(
Array
.
isArray
(
val
)
&&
!
val
.
length
))
{
if
(
!
val
||
(
Array
.
isArray
(
val
)
&&
!
val
.
length
))
{
this
.
clearSelection
()
this
.
clearSelection
()
...
@@ -658,7 +757,6 @@ export default {
...
@@ -658,7 +757,6 @@ export default {
return
return
}
}
// 统一处理 ID 格式(兼容字符串/数字)
const
targetIds
=
this
.
multiple
const
targetIds
=
this
.
multiple
?
Array
.
isArray
(
val
)
?
val
.
map
(
id
=>
String
(
id
))
:
[
String
(
val
)]
?
Array
.
isArray
(
val
)
?
val
.
map
(
id
=>
String
(
id
))
:
[
String
(
val
)]
:
[
String
(
Array
.
isArray
(
val
)
?
val
[
0
]
:
val
)]
:
[
String
(
Array
.
isArray
(
val
)
?
val
[
0
]
:
val
)]
...
@@ -675,7 +773,6 @@ export default {
...
@@ -675,7 +773,6 @@ export default {
this
.
$refs
.
materialTable
.
clearSelection
()
this
.
$refs
.
materialTable
.
clearSelection
()
let
matchedCount
=
0
let
matchedCount
=
0
// 基于 ID 精准匹配反显(保留所有字段)
this
.
materialsList
.
forEach
(
row
=>
{
this
.
materialsList
.
forEach
(
row
=>
{
const
rowId
=
String
(
row
.
id
)
const
rowId
=
String
(
row
.
id
)
if
(
validTargetIds
.
includes
(
rowId
))
{
if
(
validTargetIds
.
includes
(
rowId
))
{
...
@@ -684,13 +781,11 @@ export default {
...
@@ -684,13 +781,11 @@ export default {
}
}
})
})
// 更新选中行
this
.
selectedRows
=
this
.
materialsList
.
filter
(
row
=>
this
.
selectedRows
=
this
.
materialsList
.
filter
(
row
=>
validTargetIds
.
includes
(
String
(
row
.
id
))
validTargetIds
.
includes
(
String
(
row
.
id
))
)
)
this
.
singleSelectedId
=
this
.
multiple
?
null
:
(
this
.
selectedRows
[
0
]?.
id
||
null
)
this
.
singleSelectedId
=
this
.
multiple
?
null
:
(
this
.
selectedRows
[
0
]?.
id
||
null
)
// 未匹配到的处理
if
(
matchedCount
===
0
&&
!
isRetry
)
{
if
(
matchedCount
===
0
&&
!
isRetry
)
{
this
.
$emit
(
'selection-change'
,
{
this
.
$emit
(
'selection-change'
,
{
materialIds
:
[],
materialIds
:
[],
...
@@ -715,7 +810,6 @@ export default {
...
@@ -715,7 +810,6 @@ export default {
}
}
},
},
// 外部设置选中 ID 的方法
setSelectedIds
(
ids
)
{
setSelectedIds
(
ids
)
{
if
(
this
.
isSelecting
)
return
if
(
this
.
isSelecting
)
return
...
@@ -735,7 +829,6 @@ export default {
...
@@ -735,7 +829,6 @@ export default {
}
}
},
},
// 获取选中物料(返回完整字段,核心为ID)
getSelectedMaterials
()
{
getSelectedMaterials
()
{
if
(
this
.
multiple
)
{
if
(
this
.
multiple
)
{
return
this
.
selectedRows
.
map
(
row
=>
({
return
this
.
selectedRows
.
map
(
row
=>
({
...
@@ -747,7 +840,10 @@ export default {
...
@@ -747,7 +840,10 @@ export default {
categoryName
:
this
.
categoryMap
[
row
.
categoryCode
]
||
row
.
categoryCode
,
categoryName
:
this
.
categoryMap
[
row
.
categoryCode
]
||
row
.
categoryCode
,
specification
:
row
.
specification
,
specification
:
row
.
specification
,
materialUnit
:
row
.
materialUnit
,
materialUnit
:
row
.
materialUnit
,
isBatchManaged
:
row
.
isBatchManaged
isBatchManaged
:
row
.
isBatchManaged
,
originalStock
:
row
.
originalStock
,
addedQuantity
:
row
.
addedQuantity
,
availableStock
:
row
.
availableStock
}))
}))
}
else
{
}
else
{
return
this
.
selectedRows
[
0
]
?
{
return
this
.
selectedRows
[
0
]
?
{
...
@@ -759,12 +855,14 @@ export default {
...
@@ -759,12 +855,14 @@ export default {
categoryName
:
this
.
categoryMap
[
this
.
selectedRows
[
0
].
categoryCode
]
||
this
.
selectedRows
[
0
].
categoryCode
,
categoryName
:
this
.
categoryMap
[
this
.
selectedRows
[
0
].
categoryCode
]
||
this
.
selectedRows
[
0
].
categoryCode
,
specification
:
this
.
selectedRows
[
0
].
specification
,
specification
:
this
.
selectedRows
[
0
].
specification
,
materialUnit
:
this
.
selectedRows
[
0
].
materialUnit
,
materialUnit
:
this
.
selectedRows
[
0
].
materialUnit
,
isBatchManaged
:
this
.
selectedRows
[
0
].
isBatchManaged
isBatchManaged
:
this
.
selectedRows
[
0
].
isBatchManaged
,
originalStock
:
this
.
selectedRows
[
0
].
originalStock
,
addedQuantity
:
this
.
selectedRows
[
0
].
addedQuantity
,
availableStock
:
this
.
selectedRows
[
0
].
availableStock
}
:
null
}
:
null
}
}
},
},
// 单选模式下设置选中 ID
setSingleSelection
(
id
)
{
setSingleSelection
(
id
)
{
if
(
this
.
isSelecting
||
this
.
multiple
)
return
if
(
this
.
isSelecting
||
this
.
multiple
)
return
...
@@ -777,7 +875,6 @@ export default {
...
@@ -777,7 +875,6 @@ export default {
if
(
targetRow
)
{
if
(
targetRow
)
{
this
.
$refs
.
materialTable
.
toggleRowSelection
(
targetRow
,
true
)
this
.
$refs
.
materialTable
.
toggleRowSelection
(
targetRow
,
true
)
this
.
selectedRows
=
[
targetRow
]
this
.
selectedRows
=
[
targetRow
]
// 返回完整字段数据
const
selectedData
=
{
const
selectedData
=
{
id
:
targetRow
.
id
,
id
:
targetRow
.
id
,
sapNo
:
targetRow
.
sapNo
,
sapNo
:
targetRow
.
sapNo
,
...
@@ -787,7 +884,10 @@ export default {
...
@@ -787,7 +884,10 @@ export default {
categoryName
:
this
.
categoryMap
[
targetRow
.
categoryCode
]
||
targetRow
.
categoryCode
,
categoryName
:
this
.
categoryMap
[
targetRow
.
categoryCode
]
||
targetRow
.
categoryCode
,
specification
:
targetRow
.
specification
,
specification
:
targetRow
.
specification
,
materialUnit
:
targetRow
.
materialUnit
,
materialUnit
:
targetRow
.
materialUnit
,
isBatchManaged
:
targetRow
.
isBatchManaged
isBatchManaged
:
targetRow
.
isBatchManaged
,
originalStock
:
targetRow
.
originalStock
,
addedQuantity
:
targetRow
.
addedQuantity
,
availableStock
:
targetRow
.
availableStock
}
}
this
.
$emit
(
'input'
,
id
)
this
.
$emit
(
'input'
,
id
)
this
.
$emit
(
'change'
,
selectedData
)
this
.
$emit
(
'change'
,
selectedData
)
...
@@ -820,22 +920,64 @@ export default {
...
@@ -820,22 +920,64 @@ export default {
.material-selector-container
{
.material-selector-container
{
height
:
100%
;
height
:
100%
;
min-height
:
500px
;
min-height
:
500px
;
overflow
:
hidden
!important
;
}
}
.custom-tree-node
{
.custom-tree-node
{
font-size
:
14px
;
font-size
:
14px
;
}
}
.tree-pane
{
overflow
:
hidden
!important
;
max-height
:
100%
;
scrollbar-width
:
none
;
-ms-overflow-style
:
none
;
}
.tree-pane
::-webkit-scrollbar
{
display
:
none
;
}
.table-pane
{
display
:
flex
;
flex-direction
:
column
;
height
:
100%
;
overflow
:
hidden
!important
;
}
.table-header
{
flex-shrink
:
0
;
padding
:
10px
;
}
.table-container
{
flex
:
1
;
padding
:
0
10px
;
overflow
:
auto
!important
;
scrollbar-width
:
thin
;
scrollbar-color
:
#ccc
#f5f5f5
;
}
.table-container
::-webkit-scrollbar
{
width
:
6px
;
height
:
6px
;
}
.table-container
::-webkit-scrollbar-thumb
{
background-color
:
#ccc
;
border-radius
:
3px
;
}
.table-container
::-webkit-scrollbar-track
{
background-color
:
#f5f5f5
;
}
.pagination-container
{
flex-shrink
:
0
;
padding
:
10px
;
text-align
:
right
;
}
/
deep
/
.el-table
.el-table__header
.cell
{
/
deep
/
.el-table
.el-table__header
.cell
{
text-align
:
center
;
text-align
:
center
;
}
}
/
deep
/
.el-table--enable-row-hover
.el-table__body
tr
:hover
>
td
{
/
deep
/
.el-table--enable-row-hover
.el-table__body
tr
:hover
>
td
{
background-color
:
#f5f
7fa
;
background-color
:
#f5f
5f5
;
cursor
:
pointer
;
/* 新增:鼠标悬停显示指针 */
cursor
:
pointer
;
}
}
/
deep
/
.el-table__fixed-right
,
/
deep
/
.el-table__fixed-right
,
/
deep
/
.el-table__fixed-left
{
/
deep
/
.el-table__fixed-left
{
pointer-events
:
auto
!important
;
pointer-events
:
auto
!important
;
}
}
/* 单选模式下表格行样式优化 */
/
deep
/
.el-table__body
tr
.el-table__row--striped
td
{
/
deep
/
.el-table__body
tr
.el-table__row--striped
td
{
background-color
:
#fafafa
;
background-color
:
#fafafa
;
}
}
...
...
ruoyi-admin-vue/src/views/inventory/locations/index.vue
View file @
1f9d9564
...
@@ -71,6 +71,7 @@
...
@@ -71,6 +71,7 @@
@
keyup
.
enter
.
native=
"handleQuery"
@
keyup
.
enter
.
native=
"handleQuery"
/>
/>
</el-form-item>
</el-form-item>
<!-- 注释掉仓库查询相关 -->
<!-- <el-form-item label="仓库" prop="warehouseId">
<!-- <el-form-item label="仓库" prop="warehouseId">
<el-input
<el-input
v-model="queryWarehouseName"
v-model="queryWarehouseName"
...
@@ -221,15 +222,17 @@
...
@@ -221,15 +222,17 @@
</el-col>
</el-col>
</el-row>
</el-row>
<el-row
:gutter=
"20"
style=
"margin: 10px 0;"
>
<el-row
:gutter=
"20"
style=
"margin: 10px 0;"
>
<el-col
:span=
"24"
>
<!-- 注释掉物料分类相关 -->
<!--
<el-col
:span=
"24"
>
<div><strong>
允许存放物料名称:
</strong>
{{
scope
.
row
.
allowedCategoryNames
||
'-'
}}
</div>
<div><strong>
允许存放物料名称:
</strong>
{{
scope
.
row
.
allowedCategoryNames
||
'-'
}}
</div>
</el-col>
</el-col>
-->
</el-row>
</el-row>
</
template
>
</
template
>
</el-table-column>
</el-table-column>
<el-table-column
type=
"selection"
width=
"55"
align=
"center"
fixed
/>
<el-table-column
type=
"selection"
width=
"55"
align=
"center"
fixed
/>
<el-table-column
label=
"库位编码"
align=
"center"
prop=
"locationCode"
width=
"120"
fixed
/>
<el-table-column
label=
"库位编码"
align=
"center"
prop=
"locationCode"
width=
"120"
fixed
/>
<el-table-column
label=
"库位名称"
align=
"center"
prop=
"locationName"
width=
"150"
/>
<el-table-column
label=
"库位名称"
align=
"center"
prop=
"locationName"
width=
"150"
/>
<!-- 注释掉仓库列 -->
<!-- <el-table-column label="仓库" align="center" prop="warehousesName" width="180">
<!-- <el-table-column label="仓库" align="center" prop="warehousesName" width="180">
<template slot-scope="scope">
<template slot-scope="scope">
{{ scope.row.warehousesName }}
{{ scope.row.warehousesName }}
...
@@ -263,7 +266,8 @@
...
@@ -263,7 +266,8 @@
<el-table-column
label=
"库位容量(千克)"
align=
"center"
prop=
"capacity"
width=
"120"
/>
<el-table-column
label=
"库位容量(千克)"
align=
"center"
prop=
"capacity"
width=
"120"
/>
<el-table-column
label=
"体积容量(立方米)"
align=
"center"
prop=
"volumeCapacity"
width=
"120"
/>
<el-table-column
label=
"体积容量(立方米)"
align=
"center"
prop=
"volumeCapacity"
width=
"120"
/>
<el-table-column
label=
"允许存放的危险等级"
align=
"center"
prop=
"allowedHazardLevels"
width=
"140"
/>
<el-table-column
label=
"允许存放的危险等级"
align=
"center"
prop=
"allowedHazardLevels"
width=
"140"
/>
<el-table-column
label=
"允许存放的物料名称"
align=
"center"
prop=
"allowedCategoryNames"
width=
"200"
>
<!-- 注释掉物料分类列 -->
<!-- <el-table-column label="允许存放的物料名称" align="center" prop="allowedCategoryNames" width="200">
<template slot-scope="scope">
<template slot-scope="scope">
<el-tooltip
<el-tooltip
:content="scope.row.allowedCategoryNames"
:content="scope.row.allowedCategoryNames"
...
@@ -293,7 +297,7 @@
...
@@ -293,7 +297,7 @@
</div>
</div>
</el-tooltip>
</el-tooltip>
</template>
</template>
</el-table-column>
</el-table-column>
-->
<el-table-column
label=
"温区"
align=
"center"
prop=
"temperatureZone"
width=
"100"
/>
<el-table-column
label=
"温区"
align=
"center"
prop=
"temperatureZone"
width=
"100"
/>
<el-table-column
label=
"应用状态"
align=
"center"
prop=
"isEnabled"
width=
"100"
>
<el-table-column
label=
"应用状态"
align=
"center"
prop=
"isEnabled"
width=
"100"
>
<
template
slot-scope=
"scope"
>
<
template
slot-scope=
"scope"
>
...
@@ -357,6 +361,7 @@
...
@@ -357,6 +361,7 @@
</el-form-item>
</el-form-item>
</el-col>
</el-col>
</el-row>
</el-row>
<!-- 注释掉仓库选择 -->
<!-- <el-form-item label="仓库" prop="warehouseId">
<!-- <el-form-item label="仓库" prop="warehouseId">
<el-input
<el-input
v-model="form.warehouseName"
v-model="form.warehouseName"
...
@@ -510,7 +515,8 @@
...
@@ -510,7 +515,8 @@
<el-input
v-model=
"form.allowedHazardLevels"
placeholder=
"请输入允许存放的危险等级"
/>
<el-input
v-model=
"form.allowedHazardLevels"
placeholder=
"请输入允许存放的危险等级"
/>
</el-form-item>
</el-form-item>
</el-col>
</el-col>
<el-col
:span=
"12"
>
<!-- 注释掉物料分类选择 -->
<!-- <el-col :span="12">
<el-form-item label="允许存放物料" prop="allowedCategoryIds">
<el-form-item label="允许存放物料" prop="allowedCategoryIds">
<div style="display: flex; align-items: center; flex-direction: column; gap: 8px;">
<div style="display: flex; align-items: center; flex-direction: column; gap: 8px;">
<el-input
<el-input
...
@@ -522,7 +528,7 @@
...
@@ -522,7 +528,7 @@
/>
/>
</div>
</div>
</el-form-item>
</el-form-item>
</el-col>
</el-col>
-->
</el-row>
</el-row>
<el-row
:gutter=
"20"
>
<el-row
:gutter=
"20"
>
<el-col
:span=
"12"
>
<el-col
:span=
"12"
>
...
@@ -549,8 +555,8 @@
...
@@ -549,8 +555,8 @@
</div>
</div>
</el-dialog>
</el-dialog>
<!--
选择允许存放的物料
对话框 -->
<!--
注释掉物料选择
对话框 -->
<el-dialog
<
!-- <
el-dialog
title="选择允许存放的物料"
title="选择允许存放的物料"
:visible.sync="showMaterialSelect"
:visible.sync="showMaterialSelect"
width="1000px"
width="1000px"
...
@@ -570,7 +576,7 @@
...
@@ -570,7 +576,7 @@
<el-button @click="handleMaterialSelectionCancel">取消</el-button>
<el-button @click="handleMaterialSelectionCancel">取消</el-button>
<el-button type="primary" @click="confirmMaterialSelection">确认选择</el-button>
<el-button type="primary" @click="confirmMaterialSelection">确认选择</el-button>
</div>
</div>
</el-dialog>
</el-dialog>
-->
<!-- 导入组件 -->
<!-- 导入组件 -->
<import-excel
<import-excel
...
@@ -582,7 +588,7 @@
...
@@ -582,7 +588,7 @@
@
success=
"getList"
@
success=
"getList"
/>
/>
<!-- 仓库选择器组件 -->
<!--
注释掉
仓库选择器组件 -->
<!-- <WarehouseSelector
<!-- <WarehouseSelector
v-model="warehouseSelectorVisible"
v-model="warehouseSelectorVisible"
@selected="handleWarehouseSelected"
@selected="handleWarehouseSelected"
...
@@ -592,15 +598,24 @@
...
@@ -592,15 +598,24 @@
<
script
>
<
script
>
import
{
listLocations
,
getLocations
,
delLocations
,
addLocations
,
updateLocations
}
from
"@/api/inventory/locations"
import
{
listLocations
,
getLocations
,
delLocations
,
addLocations
,
updateLocations
}
from
"@/api/inventory/locations"
import
{
listWarehouses
}
from
"@/api/inventory/warehouses"
// 注释掉仓库相关api
import
materialsSeletor
from
"../../../components/materialsSeletor.vue"
// import { listWarehouses } from "@/api/inventory/warehouses"
// 注释掉物料选择器组件
// import materialsSeletor from "../../../components/materialsSeletor.vue"
// 注释掉仓库选择器组件
// import WarehouseSelector from "@/views/compononents/WarehouseSelector.vue"
// import WarehouseSelector from "@/views/compononents/WarehouseSelector.vue"
import
ImportExcel
from
"@/components/ImportExcel/index"
import
ImportExcel
from
"@/components/ImportExcel/index"
import
{
listMaterials
}
from
"@/api/inventory/materials"
// 注释掉物料相关api
// import { listMaterials } from "@/api/inventory/materials"
export
default
{
export
default
{
name
:
"Locations"
,
name
:
"Locations"
,
components
:
{
materialsSeletor
,
WarehouseSelector
,
ImportExcel
},
components
:
{
// 注释掉物料选择器和仓库选择器组件
// materialsSeletor,
// WarehouseSelector,
ImportExcel
},
dicts
:
[
'sys_normal_disable'
,
'location_type'
,
'location_usage'
,
'yorn'
,
'is_enabled'
],
dicts
:
[
'sys_normal_disable'
,
'location_type'
,
'location_usage'
,
'yorn'
,
'is_enabled'
],
data
()
{
data
()
{
return
{
return
{
...
@@ -620,7 +635,8 @@ export default {
...
@@ -620,7 +635,8 @@ export default {
pageSize
:
10
,
pageSize
:
10
,
locationCode
:
null
,
locationCode
:
null
,
locationName
:
null
,
locationName
:
null
,
warehouseId
:
null
,
// 注释掉仓库查询参数
// warehouseId: null,
locationType
:
null
,
locationType
:
null
,
layerCode
:
null
,
layerCode
:
null
,
locationUsage
:
null
,
locationUsage
:
null
,
...
@@ -634,8 +650,9 @@ export default {
...
@@ -634,8 +650,9 @@ export default {
id
:
null
,
id
:
null
,
locationCode
:
null
,
locationCode
:
null
,
locationName
:
null
,
locationName
:
null
,
warehouseId
:
null
,
// 注释掉仓库相关字段
warehouseName
:
null
,
// warehouseId: null,
// warehouseName: null,
locationType
:
null
,
locationType
:
null
,
zoneCode
:
null
,
zoneCode
:
null
,
rowCode
:
null
,
rowCode
:
null
,
...
@@ -644,8 +661,9 @@ export default {
...
@@ -644,8 +661,9 @@ export default {
capacity
:
null
,
capacity
:
null
,
volumeCapacity
:
null
,
volumeCapacity
:
null
,
allowedHazardLevels
:
null
,
allowedHazardLevels
:
null
,
allowedCategoryIds
:
null
,
// 原materialCodes
// 注释掉物料分类相关字段
allowedCategoryNames
:
null
,
// 原materialNames
// allowedCategoryIds: null, // 原materialCodes
// allowedCategoryNames: null, // 原materialNames
temperatureZone
:
null
,
temperatureZone
:
null
,
isEnabled
:
1
,
isEnabled
:
1
,
isUsed
:
1
,
isUsed
:
1
,
...
@@ -670,6 +688,7 @@ export default {
...
@@ -670,6 +688,7 @@ export default {
{
required
:
true
,
message
:
'库位名称不能为空'
,
trigger
:
'blur'
},
{
required
:
true
,
message
:
'库位名称不能为空'
,
trigger
:
'blur'
},
{
min
:
1
,
max
:
100
,
message
:
'库位名称长度不能超过100个字符'
,
trigger
:
'blur'
}
{
min
:
1
,
max
:
100
,
message
:
'库位名称长度不能超过100个字符'
,
trigger
:
'blur'
}
],
],
// 注释掉仓库验证规则
// warehouseId: [
// warehouseId: [
// { required: true, message: '仓库不能为空', trigger: 'change' }
// { required: true, message: '仓库不能为空', trigger: 'change' }
// ],
// ],
...
@@ -688,172 +707,173 @@ export default {
...
@@ -688,172 +707,173 @@ export default {
isEnabled
:
[
isEnabled
:
[
{
required
:
true
,
message
:
'应用状态不能为空'
,
trigger
:
'change'
}
{
required
:
true
,
message
:
'应用状态不能为空'
,
trigger
:
'change'
}
]
]
// 注释掉物料分类验证规则
// allowedCategoryIds: [
// { required: true, message: '允许存放物料不能为空', trigger: 'change' }
// ]
},
},
//
仓库相关
//
注释掉仓库相关数据
warehouseList
:
[],
//
warehouseList: [],
loadingWarehouse
:
false
,
//
loadingWarehouse: false,
queryWarehouseName
:
''
,
//
queryWarehouseName: '',
//
物料选择相关
//
注释掉物料选择相关数据
showMaterialSelect
:
false
,
//
showMaterialSelect: false,
tempSelectedMaterials
:
{
//
tempSelectedMaterials: {
materialCodes
:
[],
//
materialCodes: [],
names
:
[],
//
names: [],
categoryIds
:
[]
//
categoryIds: []
},
//
},
materialCodeToNameMap
:
{},
//
materialCodeToNameMap: {},
materialMapLoaded
:
false
,
//
materialMapLoaded: false,
//
仓库选择器相关
//
注释掉仓库选择器相关数据
warehouseSelectorVisible
:
false
,
//
warehouseSelectorVisible: false,
warehouseSelectTarget
:
''
,
//
warehouseSelectTarget: '',
currentDetailItem
:
null
//
currentDetailItem: null
}
}
},
},
created
()
{
created
()
{
console
.
log
(
'【Locations组件】开始初始化'
)
console
.
log
(
'【Locations组件】开始初始化'
)
this
.
getList
()
this
.
getList
()
this
.
getWarehouseList
()
// 注释掉仓库列表和物料映射表初始化
this
.
initMaterialCodeToNameMap
()
// this.getWarehouseList()
// this.initMaterialCodeToNameMap()
},
},
methods
:
{
methods
:
{
// ========== 新增:初始化物料选择器(核心修复数据残留) ==========
// 注释掉物料选择器初始化方法
initMaterialSelector
()
{
// initMaterialSelector() {
console
.
log
(
'【初始化物料选择器】清空残留数据'
)
// console.log('【初始化物料选择器】清空残留数据')
// 1. 清空临时选择数据(区分新增/修改)
// this.tempSelectedMaterials = {
this
.
tempSelectedMaterials
=
{
// materialCodes: this.form.id ? (this.form.allowedCategoryIds ? this.form.allowedCategoryIds.split(',').filter(u => u.trim()) : []) : [],
materialCodes
:
this
.
form
.
id
?
(
this
.
form
.
allowedCategoryIds
?
this
.
form
.
allowedCategoryIds
.
split
(
','
).
filter
(
u
=>
u
.
trim
())
:
[])
:
[],
// names: this.form.id ? (this.form.allowedCategoryNames ? this.form.allowedCategoryNames.split(',').filter(n => n.trim()) : []) : [],
names
:
this
.
form
.
id
?
(
this
.
form
.
allowedCategoryNames
?
this
.
form
.
allowedCategoryNames
.
split
(
','
).
filter
(
n
=>
n
.
trim
())
:
[])
:
[],
// categoryIds: this.form.id ? (this.form.allowedCategoryIds ? this.form.allowedCategoryIds.split(',').filter(c => c.trim()) : []) : []
categoryIds
:
this
.
form
.
id
?
(
this
.
form
.
allowedCategoryIds
?
this
.
form
.
allowedCategoryIds
.
split
(
','
).
filter
(
c
=>
c
.
trim
())
:
[])
:
[]
// }
}
// this.$nextTick(() => {
// 2. 延迟打开弹窗,确保数据先清空
// this.showMaterialSelect = true
this
.
$nextTick
(()
=>
{
// if (this.$refs.materialsSeletor && this.$refs.materialsSeletor.clearSelection) {
this
.
showMaterialSelect
=
true
// this.$refs.materialsSeletor.clearSelection()
// 3. 兼容子组件清空选中状态(如果有该方法)
// if (this.form.id) {
if
(
this
.
$refs
.
materialsSeletor
&&
this
.
$refs
.
materialsSeletor
.
clearSelection
)
{
// this.$refs.materialsSeletor.setSelection(this.tempSelectedMaterials.materialCodes)
this
.
$refs
.
materialsSeletor
.
clearSelection
()
// }
// 修改模式下重新设置选中值
// }
if
(
this
.
form
.
id
)
{
// })
this
.
$refs
.
materialsSeletor
.
setSelection
(
this
.
tempSelectedMaterials
.
materialCodes
)
// },
}
}
// 注释掉清空查询仓库方法
})
// clearQueryWarehouse() {
},
// console.log('【清空查询仓库】执行清空操作')
// this.queryWarehouseName = ''
// 清空查询仓库
// this.queryParams.warehouseId = null
clearQueryWarehouse
()
{
// this.handleQuery()
console
.
log
(
'【清空查询仓库】执行清空操作'
)
// },
this
.
queryWarehouseName
=
''
this
.
queryParams
.
warehouseId
=
null
// 注释掉清空表单仓库方法
this
.
handleQuery
()
// clearFormWarehouse() {
},
// console.log('【清空表单仓库】执行清空操作')
// this.form.warehouseName = ''
// 清空表单仓库
// this.form.warehouseId = null
clearFormWarehouse
()
{
// },
console
.
log
(
'【清空表单仓库】执行清空操作'
)
this
.
form
.
warehouseName
=
''
// 注释掉仓库选择回调方法
this
.
form
.
warehouseId
=
null
// handleWarehouseSelected(warehouse) {
},
// console.log('【仓库选择回调】选中的仓库数据:', warehouse)
// if (!warehouse) return
// 仓库选择回调
// const warehouseId = warehouse.warehousesId || warehouse.warehouseId || warehouse.id
handleWarehouseSelected
(
warehouse
)
{
// const warehouseName = warehouse.warehousesName || warehouse.name || warehouse.warehouseName
console
.
log
(
'【仓库选择回调】选中的仓库数据:'
,
warehouse
)
if
(
!
warehouse
)
return
// if (this.warehouseSelectTarget === 'query') {
const
warehouseId
=
warehouse
.
warehousesId
||
warehouse
.
warehouseId
||
warehouse
.
id
// this.queryParams.warehouseId = warehouseId
const
warehouseName
=
warehouse
.
warehousesName
||
warehouse
.
name
||
warehouse
.
warehouseName
// this.queryWarehouseName = warehouseName
// this.handleQuery()
if
(
this
.
warehouseSelectTarget
===
'query'
)
{
// } else {
this
.
queryParams
.
warehouseId
=
warehouseId
// this.form.warehouseId = warehouseId
this
.
queryWarehouseName
=
warehouseName
// this.form.warehouseName = warehouseName
this
.
handleQuery
()
}
else
{
// if (this.currentDetailItem) {
this
.
form
.
warehouseId
=
warehouseId
// this.currentDetailItem.warehouseId = warehouseId
this
.
form
.
warehouseName
=
warehouseName
// this.currentDetailItem.warehouseName = warehouseName
// }
if
(
this
.
currentDetailItem
)
{
// }
this
.
currentDetailItem
.
warehouseId
=
warehouseId
// this.warehouseSelectorVisible = false
this
.
currentDetailItem
.
warehouseName
=
warehouseName
// },
}
}
// 注释掉打开仓库选择器方法
this
.
warehouseSelectorVisible
=
false
// openWarehouseSelector(target = 'form') {
},
// console.log('【打开仓库选择器】目标:', target)
// this.warehouseSelectTarget = target
// 打开仓库选择器
// this.warehouseSelectorVisible = true
openWarehouseSelector
(
target
=
'form'
)
{
// },
console
.
log
(
'【打开仓库选择器】目标:'
,
target
)
this
.
warehouseSelectTarget
=
target
// 注释掉获取仓库列表方法
this
.
warehouseSelectorVisible
=
true
// getWarehouseList() {
},
// console.log('【获取仓库列表】开始请求仓库数据')
// this.loadingWarehouse = true
// 获取仓库列表
// listWarehouses({ pageNum: 1, pageSize: 1000, isUsed: 1 }).then(response => {
getWarehouseList
()
{
// console.log('【获取仓库列表】请求成功,返回数据:', response)
console
.
log
(
'【获取仓库列表】开始请求仓库数据'
)
// this.warehouseList = response.rows || []
this
.
loadingWarehouse
=
true
// this.loadingWarehouse = false
listWarehouses
({
pageNum
:
1
,
pageSize
:
1000
,
isUsed
:
1
}).
then
(
response
=>
{
// }).catch(error => {
console
.
log
(
'【获取仓库列表】请求成功,返回数据:'
,
response
)
// console.error('【获取仓库列表】请求失败:', error)
this
.
warehouseList
=
response
.
rows
||
[]
// this.warehouseList = []
this
.
loadingWarehouse
=
false
// this.loadingWarehouse = false
}).
catch
(
error
=>
{
// })
console
.
error
(
'【获取仓库列表】请求失败:'
,
error
)
// },
this
.
warehouseList
=
[]
this
.
loadingWarehouse
=
false
// 注释掉根据仓库ID获取名称方法
})
// getWarehouseNameById(warehouseId) {
},
// console.log('【根据仓库ID获取名称】仓库ID:', warehouseId)
// if (!warehouseId) return '-'
// 根据仓库ID获取仓库名称
// const warehouse = this.warehouseList.find(item =>
getWarehouseNameById
(
warehouseId
)
{
// item.warehousesId === warehouseId || item.warehouseId === warehouseId || item.id === warehouseId
console
.
log
(
'【根据仓库ID获取名称】仓库ID:'
,
warehouseId
)
// )
if
(
!
warehouseId
)
return
'-'
// const warehouseName = warehouse ? (warehouse.warehousesName || warehouse.name || warehouse.warehouseName || '-') : '-'
const
warehouse
=
this
.
warehouseList
.
find
(
item
=>
// console.log('【根据仓库ID获取名称】匹配到的仓库名称:', warehouseName)
item
.
warehousesId
===
warehouseId
||
item
.
warehouseId
===
warehouseId
||
item
.
id
===
warehouseId
// return warehouseName
)
// },
const
warehouseName
=
warehouse
?
(
warehouse
.
warehousesName
||
warehouse
.
name
||
warehouse
.
warehouseName
||
'-'
)
:
'-'
console
.
log
(
'【根据仓库ID获取名称】匹配到的仓库名称:'
,
warehouseName
)
// 注释掉初始化物料编码-名称映射表方法
return
warehouseName
// async initMaterialCodeToNameMap() {
},
// console.log('【初始化物料映射表】开始加载物料数据')
// try {
// 初始化物料编码-名称映射表
// this.materialMapLoaded = true
async
initMaterialCodeToNameMap
()
{
// let pageNum = 1
console
.
log
(
'【初始化物料映射表】开始加载物料数据'
)
// const pageSize = 1000
try
{
// let hasMore = true
this
.
materialMapLoaded
=
true
// this.materialCodeToNameMap = {}
let
pageNum
=
1
const
pageSize
=
1000
// while (hasMore) {
let
hasMore
=
true
// console.log(`【初始化物料映射表】请求第${pageNum}页物料数据,每页${pageSize}条`)
this
.
materialCodeToNameMap
=
{}
// const response = await listMaterials({
// pageNum,
while
(
hasMore
)
{
// pageSize,
console
.
log
(
`【初始化物料映射表】请求第
${
pageNum
}
页物料数据,每页
${
pageSize
}
条`
)
// isUsed: 1,
const
response
=
await
listMaterials
({
// materialCode: null,
pageNum
,
// materialName: null
pageSize
,
// })
isUsed
:
1
,
materialCode
:
null
,
// if (response.rows && response.rows.length) {
materialName
:
null
// console.log(`【初始化物料映射表】第${pageNum}页返回${response.rows.length}条物料数据`)
})
// response.rows.forEach(item => {
// if (item.materialCode && item.materialName) {
if
(
response
.
rows
&&
response
.
rows
.
length
)
{
// const code = item.materialCode.trim().toUpperCase()
console
.
log
(
`【初始化物料映射表】第
${
pageNum
}
页返回
${
response
.
rows
.
length
}
条物料数据`
)
// this.materialCodeToNameMap[code] = item.materialName
response
.
rows
.
forEach
(
item
=>
{
// }
if
(
item
.
materialCode
&&
item
.
materialName
)
{
// })
const
code
=
item
.
materialCode
.
trim
().
toUpperCase
()
// hasMore = pageNum * pageSize
<
response
.
total
this
.
materialCodeToNameMap
[
code
]
=
item
.
materialName
// pageNum++
}
// } else {
})
// hasMore = false
hasMore
=
pageNum
*
pageSize
<
response
.
total
// }
pageNum
++
// }
}
else
{
// console.log('【初始化物料映射表】完成,映射表长度:', Object.keys(this.materialCodeToNameMap).length)
hasMore
=
false
// } catch (error) {
}
// console.error('【初始化物料映射表】失败:', error)
}
// this.materialMapLoaded = false
console
.
log
(
'【初始化物料映射表】完成,映射表长度:'
,
Object
.
keys
(
this
.
materialCodeToNameMap
).
length
)
// this.$modal.msgError('物料数据加载失败,请刷新页面重试!')
}
catch
(
error
)
{
// }
console
.
error
(
'【初始化物料映射表】失败:'
,
error
)
// },
this
.
materialMapLoaded
=
false
this
.
$modal
.
msgError
(
'物料数据加载失败,请刷新页面重试!'
)
}
},
// 行点击事件
// 行点击事件
handleRowClick
(
row
,
event
,
column
)
{
handleRowClick
(
row
,
event
,
column
)
{
...
@@ -870,8 +890,9 @@ export default {
...
@@ -870,8 +890,9 @@ export default {
const
params
=
{
const
params
=
{
...
this
.
queryParams
,
...
this
.
queryParams
,
isUsed
:
1
,
isUsed
:
1
,
warehousesId
:
this
.
queryParams
.
warehouseId
,
// 注释掉仓库ID参数
warehouseId
:
undefined
// warehousesId: this.queryParams.warehouseId,
// warehouseId: undefined
}
}
console
.
log
(
'【获取库位列表】最终请求参数:'
,
params
)
console
.
log
(
'【获取库位列表】最终请求参数:'
,
params
)
listLocations
(
params
).
then
(
response
=>
{
listLocations
(
params
).
then
(
response
=>
{
...
@@ -902,7 +923,8 @@ export default {
...
@@ -902,7 +923,8 @@ export default {
pageSize
:
10
,
pageSize
:
10
,
locationCode
:
null
,
locationCode
:
null
,
locationName
:
null
,
locationName
:
null
,
warehouseId
:
null
,
// 注释掉仓库查询参数
// warehouseId: null,
locationType
:
null
,
locationType
:
null
,
layerCode
:
null
,
layerCode
:
null
,
locationUsage
:
null
,
locationUsage
:
null
,
...
@@ -910,7 +932,8 @@ export default {
...
@@ -910,7 +932,8 @@ export default {
zoneCode
:
null
,
zoneCode
:
null
,
pickingArea
:
null
pickingArea
:
null
}
}
this
.
queryWarehouseName
=
''
// 注释掉查询仓库名称重置
// this.queryWarehouseName = ''
this
.
getList
()
this
.
getList
()
},
},
...
@@ -950,73 +973,68 @@ export default {
...
@@ -950,73 +973,68 @@ export default {
// 映射后端字段到前端
// 映射后端字段到前端
const
formData
=
{
const
formData
=
{
...
rowData
,
...
rowData
,
warehouseId
:
rowData
.
warehousesId
||
rowData
.
warehouseId
||
rowData
.
id
,
// 注释掉仓库相关字段映射
warehousesId
:
undefined
// warehouseId: rowData.warehousesId || rowData.warehouseId || rowData.id,
// warehousesId: undefined
}
}
this
.
form
=
JSON
.
parse
(
JSON
.
stringify
(
formData
))
this
.
form
=
JSON
.
parse
(
JSON
.
stringify
(
formData
))
// 设置仓库名称
// 注释掉仓库名称设置
if
(
this
.
form
.
warehouseId
)
{
// if (this.form.warehouseId) {
this
.
form
.
warehouseName
=
this
.
getWarehouseNameById
(
this
.
form
.
warehouseId
)
// this.form.warehouseName = this.getWarehouseNameById(this.form.warehouseId)
}
// }
await
this
.
initMaterialCodeToNameMap
()
// 注释掉物料映射表初始化
// await this.initMaterialCodeToNameMap()
// 处理物料编码和名称(支持数组或字符串格式)
let
materialCodes
=
[]
// 注释掉物料编码和名称处理
let
materialNames
=
[]
// let materialCodes = []
// let materialNames = []
// 优先从allowedCategoryIds数组读取(原materialIds)
if
(
Array
.
isArray
(
rowData
.
allowedCategoryIds
)
&&
rowData
.
allowedCategoryIds
.
length
)
{
// if (Array.isArray(rowData.allowedCategoryIds) && rowData.allowedCategoryIds.length) {
materialCodes
=
rowData
.
allowedCategoryIds
// materialCodes = rowData.allowedCategoryIds
.
filter
(
code
=>
code
&&
code
.
trim
())
// .filter(code => code && code.trim())
.
map
(
code
=>
code
.
trim
().
toUpperCase
())
// .map(code => code.trim().toUpperCase())
.
filter
((
code
,
index
,
self
)
=>
self
.
indexOf
(
code
)
===
index
)
// .filter((code, index, self) => self.indexOf(code) === index)
}
// }
// 兼容字符串格式
// else if (rowData.allowedCategoryIds) {
else
if
(
rowData
.
allowedCategoryIds
)
{
// materialCodes = rowData.allowedCategoryIds.split(',')
materialCodes
=
rowData
.
allowedCategoryIds
.
split
(
','
)
// .filter(code => code && code.trim())
.
filter
(
code
=>
code
&&
code
.
trim
())
// .map(code => code.trim().toUpperCase())
.
map
(
code
=>
code
.
trim
().
toUpperCase
())
// .filter((code, index, self) => self.indexOf(code) === index)
.
filter
((
code
,
index
,
self
)
=>
self
.
indexOf
(
code
)
===
index
)
// }
}
// if (Array.isArray(rowData.allowedCategoryNames) && rowData.allowedCategoryNames.length) {
// 处理物料名称
// materialNames = rowData.allowedCategoryNames
if
(
Array
.
isArray
(
rowData
.
allowedCategoryNames
)
&&
rowData
.
allowedCategoryNames
.
length
)
{
// .filter(name => name && name.trim())
materialNames
=
rowData
.
allowedCategoryNames
// .filter((name, index, self) => self.indexOf(name) === index)
.
filter
(
name
=>
name
&&
name
.
trim
())
// }
.
filter
((
name
,
index
,
self
)
=>
self
.
indexOf
(
name
)
===
index
)
// else if (rowData.allowedCategoryNames) {
}
// materialNames = rowData.allowedCategoryNames.split(',')
else
if
(
rowData
.
allowedCategoryNames
)
{
// .filter(name => name && name.trim())
materialNames
=
rowData
.
allowedCategoryNames
.
split
(
','
)
// .filter((name, index, self) => self.indexOf(name) === index)
.
filter
(
name
=>
name
&&
name
.
trim
())
// }
.
filter
((
name
,
index
,
self
)
=>
self
.
indexOf
(
name
)
===
index
)
// else if (materialCodes.length) {
}
// materialNames = materialCodes.map(code => {
// 兜底:通过物料编码映射名称
// return this.materialCodeToNameMap[code] || `【未匹配】${code}`
else
if
(
materialCodes
.
length
)
{
// })
materialNames
=
materialCodes
.
map
(
code
=>
{
// }
return
this
.
materialCodeToNameMap
[
code
]
||
`【未匹配】
${
code
}
`
})
// let categoryIds = materialCodes
}
// this.form.allowedCategoryIds = materialCodes.join(',')
// 处理分类ID(现在存储的是物料编码)
// this.form.allowedCategoryNames = materialNames.join(',')
let
categoryIds
=
materialCodes
// this.tempSelectedMaterials = {
// 更新表单数据
// materialCodes: materialCodes,
this
.
form
.
allowedCategoryIds
=
materialCodes
.
join
(
','
)
// names: materialNames,
this
.
form
.
allowedCategoryNames
=
materialNames
.
join
(
','
)
// categoryIds: categoryIds
// }
// 更新临时选择数据
this
.
tempSelectedMaterials
=
{
// console.log('【修改库位】处理后的物料数据:', {
materialCodes
:
materialCodes
,
// allowedCategoryIds: this.form.allowedCategoryIds,
names
:
materialNames
,
// allowedCategoryNames: this.form.allowedCategoryNames
categoryIds
:
categoryIds
// })
}
console
.
log
(
'【修改库位】处理后的物料数据:'
,
{
allowedCategoryIds
:
this
.
form
.
allowedCategoryIds
,
allowedCategoryNames
:
this
.
form
.
allowedCategoryNames
})
this
.
open
=
true
this
.
open
=
true
this
.
title
=
"修改库位"
this
.
title
=
"修改库位"
...
@@ -1032,26 +1050,27 @@ export default {
...
@@ -1032,26 +1050,27 @@ export default {
this
.
$refs
[
"form"
].
validate
(
valid
=>
{
this
.
$refs
[
"form"
].
validate
(
valid
=>
{
if
(
valid
)
{
if
(
valid
)
{
console
.
log
(
'【提交表单】表单验证通过,开始格式化数据'
)
console
.
log
(
'【提交表单】表单验证通过,开始格式化数据'
)
//
格式化物料相关字段(去重、过滤空值)
//
注释掉物料字段格式化
const
formatField
=
(
value
)
=>
{
//
const formatField = (value) => {
if
(
!
value
)
return
''
//
if (!value) return ''
const
result
=
value
.
split
(
','
)
//
const result = value.split(',')
.
filter
(
item
=>
item
&&
item
.
trim
())
//
.filter(item => item && item.trim())
.
filter
((
item
,
index
,
self
)
=>
self
.
indexOf
(
item
)
===
index
)
//
.filter((item, index, self) => self.indexOf(item) === index)
.
join
(
','
)
//
.join(',')
console
.
log
(
`【提交表单】格式化字段值 "
${
value
}
" 结果: "
${
result
}
"`
)
//
console.log(`【提交表单】格式化字段值 "${value}" 结果: "${result}"`)
return
result
//
return result
}
//
}
this
.
form
.
allowedCategoryIds
=
formatField
(
this
.
form
.
allowedCategoryIds
)
//
this.form.allowedCategoryIds = formatField(this.form.allowedCategoryIds)
this
.
form
.
allowedCategoryNames
=
formatField
(
this
.
form
.
allowedCategoryNames
)
//
this.form.allowedCategoryNames = formatField(this.form.allowedCategoryNames)
// 转换表单数据
// 转换表单数据
const
submitData
=
{
const
submitData
=
{
...
this
.
form
,
...
this
.
form
,
warehousesId
:
this
.
form
.
warehouseId
,
// 注释掉仓库相关字段转换
warehouseId
:
undefined
,
// warehousesId: this.form.warehouseId,
warehouseName
:
undefined
// warehouseId: undefined,
// warehouseName: undefined
}
}
console
.
log
(
'【提交表单】最终提交数据:'
,
submitData
)
console
.
log
(
'【提交表单】最终提交数据:'
,
submitData
)
...
@@ -1100,76 +1119,71 @@ export default {
...
@@ -1100,76 +1119,71 @@ export default {
console
.
log
(
'【导出库位】执行导出操作,查询参数:'
,
this
.
queryParams
)
console
.
log
(
'【导出库位】执行导出操作,查询参数:'
,
this
.
queryParams
)
const
exportParams
=
{
const
exportParams
=
{
...
this
.
queryParams
,
...
this
.
queryParams
,
warehousesId
:
this
.
queryParams
.
warehouseId
,
// 注释掉仓库导出参数
warehouseId
:
undefined
// warehousesId: this.queryParams.warehouseId,
// warehouseId: undefined
}
}
console
.
log
(
'【导出库位】最终导出参数:'
,
exportParams
)
console
.
log
(
'【导出库位】最终导出参数:'
,
exportParams
)
this
.
download
(
'inventory/locations/export'
,
exportParams
,
`locations_
${
new
Date
().
getTime
()}
.xlsx`
)
this
.
download
(
'inventory/locations/export'
,
exportParams
,
`locations_
${
new
Date
().
getTime
()}
.xlsx`
)
},
},
// 物料选择变化
// 注释掉物料选择变化方法
handleMaterialSelectionChange
(
selectedData
)
{
// handleMaterialSelectionChange(selectedData) {
console
.
log
(
'【物料选择变化】接收到的选择数据:'
,
selectedData
)
// console.log('【物料选择变化】接收到的选择数据:', selectedData)
// 修复:从selectedData中取materialIds(而非materialCodes)
// const materialCodes = (selectedData.materialIds || [])
const
materialCodes
=
(
selectedData
.
materialIds
||
[])
// .filter(code => code && code.trim())
.
filter
(
code
=>
code
&&
code
.
trim
())
// .map(code => code.trim().toUpperCase())
.
map
(
code
=>
code
.
trim
().
toUpperCase
())
// .filter((code, index, self) => self.indexOf(code) === index)
.
filter
((
code
,
index
,
self
)
=>
self
.
indexOf
(
code
)
===
index
)
// const names = (selectedData.names || [])
// 物料名称取selectedData.names
// .filter(name => name && name.trim())
const
names
=
(
selectedData
.
names
||
[])
// .filter((name, index, self) => self.indexOf(name) === index)
.
filter
(
name
=>
name
&&
name
.
trim
())
.
filter
((
name
,
index
,
self
)
=>
self
.
indexOf
(
name
)
===
index
)
// const categoryIds = materialCodes
// 分类ID取selectedData.categoryIds(现在存储的是物料编码)
// this.tempSelectedMaterials = {
const
categoryIds
=
materialCodes
// materialCodes,
// names,
this
.
tempSelectedMaterials
=
{
// categoryIds
materialCodes
,
// }
names
,
categoryIds
// console.log('【物料选择变化】处理后的临时选择数据:', this.tempSelectedMaterials)
}
// },
console
.
log
(
'【物料选择变化】处理后的临时选择数据:'
,
this
.
tempSelectedMaterials
)
// 注释掉取消物料选择方法
},
// handleMaterialSelectionCancel() {
// console.log('【取消物料选择】执行取消操作,恢复原有选择状态')
// 取消物料选择
// this.showMaterialSelect = false
handleMaterialSelectionCancel
()
{
// this.tempSelectedMaterials = {
console
.
log
(
'【取消物料选择】执行取消操作,恢复原有选择状态'
)
// materialCodes: this.form.allowedCategoryIds ? this.form.allowedCategoryIds.split(',').filter(u => u.trim()) : [],
this
.
showMaterialSelect
=
false
// names: this.form.allowedCategoryNames ? this.form.allowedCategoryNames.split(',').filter(n => n.trim()) : [],
// 恢复原有选择状态
// categoryIds: this.form.allowedCategoryIds ? this.form.allowedCategoryIds.split(',').filter(c => c.trim()) : []
this
.
tempSelectedMaterials
=
{
// }
materialCodes
:
this
.
form
.
allowedCategoryIds
?
this
.
form
.
allowedCategoryIds
.
split
(
','
).
filter
(
u
=>
u
.
trim
())
:
[],
// console.log('【取消物料选择】恢复后的临时选择数据:', this.tempSelectedMaterials)
names
:
this
.
form
.
allowedCategoryNames
?
this
.
form
.
allowedCategoryNames
.
split
(
','
).
filter
(
n
=>
n
.
trim
())
:
[],
// },
categoryIds
:
this
.
form
.
allowedCategoryIds
?
this
.
form
.
allowedCategoryIds
.
split
(
','
).
filter
(
c
=>
c
.
trim
())
:
[]
}
// 注释掉确认物料选择方法
console
.
log
(
'【取消物料选择】恢复后的临时选择数据:'
,
this
.
tempSelectedMaterials
)
// confirmMaterialSelection() {
},
// console.log('【确认物料选择】当前临时选择数据:', this.tempSelectedMaterials)
// 确认物料选择
// if (!this.tempSelectedMaterials.materialCodes.length) {
confirmMaterialSelection
()
{
// console.warn('【确认物料选择】未选择任何物料,提示用户')
console
.
log
(
'【确认物料选择】当前临时选择数据:'
,
this
.
tempSelectedMaterials
)
// this.$modal.msgWarning('请至少选择一个物料!')
// return
// 修复:判断tempSelectedMaterials.materialCodes是否有值
// }
if
(
!
this
.
tempSelectedMaterials
.
materialCodes
.
length
)
{
console
.
warn
(
'【确认物料选择】未选择任何物料,提示用户'
)
// this.form.allowedCategoryIds = this.tempSelectedMaterials.materialCodes.join(',')
this
.
$modal
.
msgWarning
(
'请至少选择一个物料!'
)
// this.form.allowedCategoryNames = this.tempSelectedMaterials.names.join(',')
return
}
// console.log('【确认物料选择】更新后的表单物料数据:', {
// allowedCategoryIds: this.form.allowedCategoryIds,
// 更新表单数据(确保去重和过滤)
// allowedCategoryNames: this.form.allowedCategoryNames
this
.
form
.
allowedCategoryIds
=
this
.
tempSelectedMaterials
.
materialCodes
.
join
(
','
)
// })
this
.
form
.
allowedCategoryNames
=
this
.
tempSelectedMaterials
.
names
.
join
(
','
)
// this.showMaterialSelect = false
console
.
log
(
'【确认物料选择】更新后的表单物料数据:'
,
{
// this.$modal.msgSuccess(`成功选择 ${this.tempSelectedMaterials.names.length} 个物料`)
allowedCategoryIds
:
this
.
form
.
allowedCategoryIds
,
// },
allowedCategoryNames
:
this
.
form
.
allowedCategoryNames
})
this
.
showMaterialSelect
=
false
this
.
$modal
.
msgSuccess
(
`成功选择
${
this
.
tempSelectedMaterials
.
names
.
length
}
个物料`
)
},
// 导入库位
// 导入库位
handleImport
()
{
handleImport
()
{
...
@@ -1184,8 +1198,9 @@ export default {
...
@@ -1184,8 +1198,9 @@ export default {
id
:
null
,
id
:
null
,
locationCode
:
null
,
locationCode
:
null
,
locationName
:
null
,
locationName
:
null
,
warehouseId
:
null
,
// 注释掉仓库相关字段重置
warehouseName
:
null
,
// warehouseId: null,
// warehouseName: null,
locationType
:
null
,
locationType
:
null
,
zoneCode
:
null
,
zoneCode
:
null
,
rowCode
:
null
,
rowCode
:
null
,
...
@@ -1194,8 +1209,9 @@ export default {
...
@@ -1194,8 +1209,9 @@ export default {
capacity
:
null
,
capacity
:
null
,
volumeCapacity
:
null
,
volumeCapacity
:
null
,
allowedHazardLevels
:
null
,
allowedHazardLevels
:
null
,
allowedCategoryIds
:
null
,
// 原materialCodes
// 注释掉物料分类相关字段重置
allowedCategoryNames
:
null
,
// 原materialNames
// allowedCategoryIds: null,
// allowedCategoryNames: null,
temperatureZone
:
null
,
temperatureZone
:
null
,
isEnabled
:
1
,
isEnabled
:
1
,
isUsed
:
1
,
isUsed
:
1
,
...
@@ -1209,15 +1225,16 @@ export default {
...
@@ -1209,15 +1225,16 @@ export default {
allowMixedProducts
:
null
,
allowMixedProducts
:
null
,
allowMixedBatches
:
null
allowMixedBatches
:
null
}
}
this
.
tempSelectedMaterials
=
{
// 注释掉物料选择临时数据重置
materialCodes
:
[],
// this.tempSelectedMaterials = {
names
:
[],
// materialCodes: [],
categoryIds
:
[]
// names: [],
}
// categoryIds: []
// 修复:清空物料选择器残留
// }
if
(
this
.
$refs
.
materialsSeletor
&&
this
.
$refs
.
materialsSeletor
.
clearSelection
)
{
// 注释掉物料选择器清空
this
.
$refs
.
materialsSeletor
.
clearSelection
()
// if (this.$refs.materialsSeletor && this.$refs.materialsSeletor.clearSelection) {
}
// this.$refs.materialsSeletor.clearSelection()
// }
if
(
this
.
$refs
.
form
)
{
if
(
this
.
$refs
.
form
)
{
this
.
$refs
.
form
.
resetFields
()
this
.
$refs
.
form
.
resetFields
()
}
}
...
...
ruoyi-admin-vue/src/views/inventory/orders/OutboundOrderFormWithItems.vue
View file @
1f9d9564
...
@@ -49,12 +49,13 @@
...
@@ -49,12 +49,13 @@
<div
style=
"height: 70vh; overflow: auto; padding: 0 10px;"
>
<div
style=
"height: 70vh; overflow: auto; padding: 0 10px;"
>
<MaterialSelector
<MaterialSelector
ref=
"materialsSeletor"
ref=
"materialsSeletor"
@
selection-change=
"confirmMaterialSelect"
@
selection-change=
"handleMaterialSelectionChange"
:selected-material-codes=
"form.materialUuids ? [form.materialUuids] : []"
:selected-material-ids=
"form.materialId ? [form.materialId] : []"
:orders-id=
"ordersId || outboundOrderId"
:multiple=
"false"
:multiple=
"false"
:detail-list=
"details"
/>
/>
</div>
</div>
</el-dialog>
</el-dialog>
<!-- 库存信息列表 -->
<!-- 库存信息列表 -->
...
@@ -76,7 +77,7 @@
...
@@ -76,7 +77,7 @@
:row-key=
"item => item.inventoryId"
:row-key=
"item => item.inventoryId"
>
>
<el-table-column
prop=
"materialName"
label=
"物料名称"
width=
"180"
/>
<el-table-column
prop=
"materialName"
label=
"物料名称"
width=
"180"
/>
<el-table-column
prop=
"batchId"
label=
"批次
ID
"
width=
"150"
/>
<el-table-column
prop=
"batchId"
label=
"批次
号
"
width=
"150"
/>
<el-table-column
prop=
"warehousesName"
label=
"仓库名称"
width=
"120"
/>
<el-table-column
prop=
"warehousesName"
label=
"仓库名称"
width=
"120"
/>
<el-table-column
prop=
"locationName"
label=
"库位名称"
width=
"120"
/>
<el-table-column
prop=
"locationName"
label=
"库位名称"
width=
"120"
/>
<el-table-column
<el-table-column
...
@@ -224,7 +225,6 @@
...
@@ -224,7 +225,6 @@
<el-table-column
prop=
"batchId"
label=
"批次ID"
width=
"150"
/>
<el-table-column
prop=
"batchId"
label=
"批次ID"
width=
"150"
/>
<el-table-column
prop=
"warehousesName"
label=
"仓库名称"
width=
"120"
/>
<el-table-column
prop=
"warehousesName"
label=
"仓库名称"
width=
"120"
/>
<el-table-column
prop=
"locationName"
label=
"库位名称"
width=
"120"
/>
<el-table-column
prop=
"locationName"
label=
"库位名称"
width=
"120"
/>
<el-table-column
prop=
"plannedQuantity"
label=
"计划数量"
width=
"100"
/>
<el-table-column
prop=
"plannedQuantity"
label=
"计划数量"
width=
"100"
/>
<el-table-column
prop=
"actualQuantity"
label=
"实际数量"
width=
"100"
fixed=
"right"
/>
<el-table-column
prop=
"actualQuantity"
label=
"实际数量"
width=
"100"
fixed=
"right"
/>
<el-table-column
prop=
"unitPrice"
label=
"单价"
width=
"100"
/>
<el-table-column
prop=
"unitPrice"
label=
"单价"
width=
"100"
/>
...
@@ -311,6 +311,7 @@ export default {
...
@@ -311,6 +311,7 @@ export default {
},
},
data
()
{
data
()
{
return
{
return
{
orderId
:
this
.
ordersId
||
this
.
outboundOrderId
||
''
,
form
:
{
form
:
{
materialUuids
:
''
,
materialUuids
:
''
,
materialId
:
''
,
materialId
:
''
,
...
@@ -333,7 +334,7 @@ export default {
...
@@ -333,7 +334,7 @@ export default {
selectedMaterialInfo
:
null
,
selectedMaterialInfo
:
null
,
currentSelectedRowId
:
null
,
currentSelectedRowId
:
null
,
isInitEcho
:
false
,
isInitEcho
:
false
,
openMaterialSelector
:
false
,
// 确保初始为关闭状态
isUserInitiatedSelect
:
false
};
};
},
},
computed
:
{
computed
:
{
...
@@ -344,6 +345,10 @@ export default {
...
@@ -344,6 +345,10 @@ export default {
return
this
.
initDetails
.
length
>
0
||
!!
this
.
initForm
.
materialId
;
return
this
.
initDetails
.
length
>
0
||
!!
this
.
initForm
.
materialId
;
}
}
},
},
created
()
{
console
.
log
(
'子组件接收的 ordersId:'
,
this
.
ordersId
);
console
.
log
(
'子组件接收的 initDetails:'
,
this
.
initDetails
);
},
watch
:
{
watch
:
{
open
:
{
open
:
{
handler
(
newVal
)
{
handler
(
newVal
)
{
...
@@ -358,7 +363,10 @@ export default {
...
@@ -358,7 +363,10 @@ export default {
this
.
selectedMaterialId
=
this
.
form
.
materialId
||
''
;
this
.
selectedMaterialId
=
this
.
form
.
materialId
||
''
;
this
.
selectedMaterialInfo
=
null
;
this
.
selectedMaterialInfo
=
null
;
this
.
currentSelectedRowId
=
null
;
this
.
currentSelectedRowId
=
null
;
this
.
details
=
this
.
initDetails
.
length
>
0
?
JSON
.
parse
(
JSON
.
stringify
(
this
.
initDetails
))
:
[];
// 初始化 details:使用传入的 initDetails
this
.
details
=
this
.
initDetails
.
length
>
0
?
JSON
.
parse
(
JSON
.
stringify
(
this
.
initDetails
))
:
[];
this
.
$nextTick
(
async
()
=>
{
this
.
$nextTick
(
async
()
=>
{
if
(
this
.
form
.
materialId
&&
this
.
form
.
materialId
.
trim
())
{
if
(
this
.
form
.
materialId
&&
this
.
form
.
materialId
.
trim
())
{
await
this
.
handleMaterialIdChange
();
await
this
.
handleMaterialIdChange
();
...
@@ -513,6 +521,8 @@ export default {
...
@@ -513,6 +521,8 @@ export default {
}
finally
{
}
finally
{
this
.
$nextTick
(()
=>
{
this
.
$nextTick
(()
=>
{
this
.
closeLoading
();
this
.
closeLoading
();
// 主动触发明细同步,确保 details 有初始值
this
.
syncDetails
(
false
);
});
});
}
}
},
},
...
@@ -603,25 +613,46 @@ export default {
...
@@ -603,25 +613,46 @@ export default {
this
.
$set
(
row
,
'plannedQuantity'
,
1
);
this
.
$set
(
row
,
'plannedQuantity'
,
1
);
}
}
},
},
// 改造后的 syncDetails:仅校验有实际数量的行,且有值才校验
syncDetails
(
strict
=
true
)
{
syncDetails
(
strict
=
true
)
{
this
.
details
=
[];
this
.
details
=
[];
const
errorMessages
=
[];
// 收集有值但不合规的字段提示
const
errorMessages
=
[];
let
validRows
=
[];
let
validRows
=
[];
// 第一步:先过滤出「实际数量有值」的行(核心:无实际数量的行直接排除)
if
(
!
strict
)
{
validRows
=
this
.
inventoryList
.
filter
(
row
=>
{
return
row
.
actualQuantity
!==
null
||
row
.
plannedQuantity
!==
null
||
row
.
unitPrice
!==
null
||
row
.
labelColor
!==
''
||
row
.
voucherNumber
!==
''
||
row
.
shippedBy
!==
''
;
});
validRows
.
forEach
((
row
,
index
)
=>
{
const
availableQty
=
(
row
.
quantity
||
0
)
-
(
row
.
lockedQuantity
||
0
);
if
(
row
.
actualQuantity
!==
null
&&
row
.
actualQuantity
<
1
)
{
this
.
$set
(
row
,
'actualQuantity'
,
1
);
}
if
(
row
.
actualQuantity
!==
null
&&
row
.
actualQuantity
>
availableQty
)
{
this
.
$set
(
row
,
'actualQuantity'
,
availableQty
);
}
if
(
row
.
plannedQuantity
!==
null
&&
row
.
plannedQuantity
<
1
)
{
this
.
$set
(
row
,
'plannedQuantity'
,
1
);
}
if
(
row
.
plannedQuantity
!==
null
&&
row
.
plannedQuantity
>
availableQty
)
{
this
.
$set
(
row
,
'plannedQuantity'
,
availableQty
);
}
});
}
else
{
const
rowsWithActualQty
=
this
.
inventoryList
.
filter
(
row
=>
{
const
rowsWithActualQty
=
this
.
inventoryList
.
filter
(
row
=>
{
return
row
.
actualQuantity
!==
null
&&
row
.
actualQuantity
!==
undefined
;
return
row
.
actualQuantity
!==
null
&&
row
.
actualQuantity
!==
undefined
;
});
});
if
(
strict
&&
rowsWithActualQty
.
length
>
0
)
{
// 严格模式:仅校验有实际数量的行,且「有值才校验」
validRows
=
rowsWithActualQty
.
filter
((
row
,
index
)
=>
{
validRows
=
rowsWithActualQty
.
filter
((
row
,
index
)
=>
{
const
rowErrors
=
[];
const
rowErrors
=
[];
const
rowName
=
`第
${
index
+
1
}
行【
${
row
.
materialName
||
'未知物料'
}
】`
;
const
rowName
=
`第
${
index
+
1
}
行【
${
row
.
materialName
||
'未知物料'
}
】`
;
const
availableQty
=
(
row
.
quantity
||
0
)
-
(
row
.
lockedQuantity
||
0
);
const
availableQty
=
(
row
.
quantity
||
0
)
-
(
row
.
lockedQuantity
||
0
);
// 1. 实际数量(必校验,因为能走到这步说明有值)
if
(
row
.
actualQuantity
<
1
)
{
if
(
row
.
actualQuantity
<
1
)
{
rowErrors
.
push
(
'实际数量不能小于1'
);
rowErrors
.
push
(
'实际数量不能小于1'
);
}
}
...
@@ -629,7 +660,6 @@ syncDetails(strict = true) {
...
@@ -629,7 +660,6 @@ syncDetails(strict = true) {
rowErrors
.
push
(
`实际数量不能超过可用库存(
${
availableQty
}
)`
);
rowErrors
.
push
(
`实际数量不能超过可用库存(
${
availableQty
}
)`
);
}
}
// 2. 计划数量(有值才校验)
if
(
row
.
plannedQuantity
!==
null
&&
row
.
plannedQuantity
!==
undefined
)
{
if
(
row
.
plannedQuantity
!==
null
&&
row
.
plannedQuantity
!==
undefined
)
{
if
(
row
.
plannedQuantity
<
1
)
{
if
(
row
.
plannedQuantity
<
1
)
{
rowErrors
.
push
(
'计划数量不能小于1'
);
rowErrors
.
push
(
'计划数量不能小于1'
);
...
@@ -637,19 +667,14 @@ syncDetails(strict = true) {
...
@@ -637,19 +667,14 @@ syncDetails(strict = true) {
if
(
row
.
plannedQuantity
>
availableQty
)
{
if
(
row
.
plannedQuantity
>
availableQty
)
{
rowErrors
.
push
(
`计划数量不能超过可用库存(
${
availableQty
}
)`
);
rowErrors
.
push
(
`计划数量不能超过可用库存(
${
availableQty
}
)`
);
}
}
}
else
{
}
else
{
rowErrors
.
push
(
`请填写计划数量`
);
rowErrors
.
push
(
`请填写计划数量`
);
}
}
// 3. 除数(有值才校验,无值不提示)
if
(
row
.
unitPrice
===
null
||
row
.
unitPrice
===
undefined
||
row
.
unitPrice
<=
0
)
{
if
(
row
.
unitPrice
!==
null
&&
row
.
unitPrice
!==
undefined
)
{
rowErrors
.
push
(
'请填写有效的单价(大于0)'
);
// 若有值但为0/负数,可补充校验(按需)
if
(
row
.
unitPrice
<=
0
)
{
rowErrors
.
push
(
'请填写单价'
);
}
}
}
// 收集当前行的错误(仅有值但不合规的字段)
if
(
rowErrors
.
length
>
0
)
{
if
(
rowErrors
.
length
>
0
)
{
errorMessages
.
push
(
`
${
rowName
}
:
${
rowErrors
.
join
(
'、'
)}
`
);
errorMessages
.
push
(
`
${
rowName
}
:
${
rowErrors
.
join
(
'、'
)}
`
);
return
false
;
return
false
;
...
@@ -658,7 +683,6 @@ syncDetails(strict = true) {
...
@@ -658,7 +683,6 @@ syncDetails(strict = true) {
});
});
}
}
// 格式化通过校验的行并同步到details
validRows
.
forEach
(
row
=>
{
validRows
.
forEach
(
row
=>
{
const
newDetail
=
{
const
newDetail
=
{
inventoryId
:
row
.
inventoryId
,
inventoryId
:
row
.
inventoryId
,
...
@@ -683,19 +707,15 @@ syncDetails(strict = true) {
...
@@ -683,19 +707,15 @@ syncDetails(strict = true) {
this
.
details
.
push
(
newDetail
);
this
.
details
.
push
(
newDetail
);
});
});
// 返回错误信息,供提交方法使用
console
.
log
(
'syncDetails 执行结果:'
,
this
.
details
);
return
errorMessages
;
return
errorMessages
;
},
},
handleSubmit
()
{
// 提交方法:集成精准提示
handleSubmit
()
{
// 1. 校验物料ID
if
(
!
this
.
form
.
materialId
?.
trim
())
{
if
(
!
this
.
form
.
materialId
?.
trim
())
{
this
.
$message
.
error
(
'请先选择物料ID'
);
this
.
$message
.
error
(
'请先选择物料ID'
);
return
;
return
;
}
}
// 2. 校验表单基础项
this
.
$refs
.
detailForm
.
validate
(
async
(
valid
)
=>
{
this
.
$refs
.
detailForm
.
validate
(
async
(
valid
)
=>
{
if
(
!
valid
)
{
if
(
!
valid
)
{
this
.
$message
.
error
(
'表单校验失败,请检查必填项'
);
this
.
$message
.
error
(
'表单校验失败,请检查必填项'
);
...
@@ -703,11 +723,9 @@ handleSubmit() {
...
@@ -703,11 +723,9 @@ handleSubmit() {
}
}
console
.
log
(
"syncDetails前"
,
this
.
details
);
console
.
log
(
"syncDetails前"
,
this
.
details
);
// 执行明细校验,接收错误信息
const
detailErrors
=
this
.
syncDetails
(
true
);
const
detailErrors
=
this
.
syncDetails
(
true
);
console
.
log
(
"syncDetails后"
,
this
.
details
);
console
.
log
(
"syncDetails后"
,
this
.
details
);
// 3. 提示有值但不合规的字段
if
(
detailErrors
.
length
>
0
)
{
if
(
detailErrors
.
length
>
0
)
{
this
.
$message
.
error
({
this
.
$message
.
error
({
title
:
'明细数据校验失败'
,
title
:
'明细数据校验失败'
,
...
@@ -719,13 +737,11 @@ handleSubmit() {
...
@@ -719,13 +737,11 @@ handleSubmit() {
return
;
return
;
}
}
// 4. 兜底:有实际数量的行都校验通过,但无有效行(比如实际数量都
<
1
)
if
(
this
.
details
.
length
===
0
)
{
if
(
this
.
details
.
length
===
0
)
{
this
.
$message
.
error
(
'无有效明细数据,请检查实际数量及相关字段'
);
this
.
$message
.
error
(
'无有效明细数据,请检查实际数量及相关字段'
);
return
;
return
;
}
}
// 5. 组装提交数据
const
submitDetails
=
this
.
details
.
map
(
detail
=>
({
const
submitDetails
=
this
.
details
.
map
(
detail
=>
({
...
detail
,
...
detail
,
materialName
:
this
.
form
.
materialName
||
detail
.
materialName
,
materialName
:
this
.
form
.
materialName
||
detail
.
materialName
,
...
@@ -738,7 +754,7 @@ handleSubmit() {
...
@@ -738,7 +754,7 @@ handleSubmit() {
this
.
$emit
(
'submit'
,
submitDetails
);
this
.
$emit
(
'submit'
,
submitDetails
);
this
.
$emit
(
'update:open'
,
false
);
this
.
$emit
(
'update:open'
,
false
);
});
});
},
},
removeDetail
(
row
)
{
removeDetail
(
row
)
{
this
.
details
=
this
.
details
.
filter
(
d
=>
d
.
inventoryId
!==
row
.
inventoryId
);
this
.
details
=
this
.
details
.
filter
(
d
=>
d
.
inventoryId
!==
row
.
inventoryId
);
const
inventoryRow
=
this
.
inventoryList
.
find
(
item
=>
item
.
inventoryId
===
row
.
inventoryId
);
const
inventoryRow
=
this
.
inventoryList
.
find
(
item
=>
item
.
inventoryId
===
row
.
inventoryId
);
...
@@ -757,7 +773,6 @@ handleSubmit() {
...
@@ -757,7 +773,6 @@ handleSubmit() {
}
}
this
.
syncDetails
(
this
.
initDetails
.
length
===
0
);
this
.
syncDetails
(
this
.
initDetails
.
length
===
0
);
},
},
handleClose
()
{
handleClose
()
{
this
.
closeLoading
();
this
.
closeLoading
();
this
.
$nextTick
(()
=>
{
this
.
$nextTick
(()
=>
{
...
@@ -775,70 +790,42 @@ handleSubmit() {
...
@@ -775,70 +790,42 @@ handleSubmit() {
});
});
this
.
$emit
(
'update:open'
,
false
);
this
.
$emit
(
'update:open'
,
false
);
},
},
// 修复:接收selection-change事件参数,兼容多种字段名
handleMaterialSelectionChange
(
selectionData
)
{
handleMaterialSelectionChange
(
selectedData
)
{
console
.
log
(
'传给子组件的detailList:'
,
this
.
details
);
console
.
log
(
"【物料选择事件触发】选中数据:"
,
selectedData
);
// 兼容数组格式(multiple=false时可能返回对象,需转为数组)
const
selectList
=
Array
.
isArray
(
selectedData
)
?
selectedData
:
selectedData
?
[
selectedData
]
:
[];
if
(
selectList
.
length
>
0
)
{
this
.
selectedMaterialInfo
=
selectList
[
0
];
// 关键:兼容常见的物料ID字段名(id/materialId/uuid)
this
.
selectedMaterialId
=
this
.
selectedMaterialInfo
.
id
||
this
.
selectedMaterialInfo
.
materialId
||
this
.
selectedMaterialInfo
.
uuid
||
''
;
// 兼容常见的物料名称字段名(materialName/name)
this
.
$set
(
this
.
form
,
'materialName'
,
this
.
selectedMaterialInfo
.
materialName
||
this
.
selectedMaterialInfo
.
name
||
''
);
console
.
log
(
"【物料选择成功】ID:"
,
this
.
selectedMaterialId
,
"名称:"
,
this
.
form
.
materialName
);
}
else
{
this
.
selectedMaterialInfo
=
null
;
this
.
selectedMaterialInfo
=
null
;
this
.
selectedMaterialId
=
''
;
this
.
selectedMaterialId
=
''
;
this
.
$set
(
this
.
form
,
'materialName'
,
''
);
this
.
$set
(
this
.
form
,
'materialName'
,
''
);
console
.
log
(
"【物料选择清空】"
);
if
(
!
selectionData
||
!
selectionData
.
materials
)
{
console
.
log
(
"【物料选择清空】无有效选中数据"
);
return
;
}
}
},
// 修复:增强校验逻辑,增加组件存在性检查和异步同步
confirmMaterialSelect
()
{
// 标记为“用户主动操作”
this
.
isUserInitiatedSelect
=
true
;
// 1. 检查选择器组件是否存在
const
materials
=
Array
.
isArray
(
selectionData
.
materials
)
?
selectionData
.
materials
:
[];
if
(
!
this
.
$refs
.
materialsSeletor
)
{
if
(
materials
.
length
===
0
)
{
this
.
$message
.
error
(
'物料选择器组件加载失败,请重试'
);
console
.
log
(
"【物料选择清空】选中列表为空"
);
return
;
return
;
}
}
// 2. 异步等待组件数据同步(避免取值过早)
const
firstItem
=
materials
[
0
];
this
.
$nextTick
(()
=>
{
if
(
!
firstItem
)
{
// 3. 强制触发选中数据同步
console
.
log
(
"【物料选择清空】第一个选中项为空"
);
const
selector
=
this
.
$refs
.
materialsSeletor
;
return
;
let
selectedData
=
[];
}
// 兼容组件的多种取值方式
if
(
selector
.
getSelectedMaterials
)
{
this
.
selectedMaterialInfo
=
firstItem
;
selectedData
=
selector
.
getSelectedMaterials
();
this
.
selectedMaterialId
=
firstItem
.
id
||
firstItem
.
materialId
||
firstItem
.
uuid
||
''
;
}
else
if
(
selector
.
selectedList
)
{
this
.
$set
(
this
.
form
,
'materialName'
,
firstItem
.
materialName
||
firstItem
.
name
||
''
);
selectedData
=
selector
.
selectedList
;
this
.
$set
(
this
.
form
,
'materialId'
,
this
.
selectedMaterialId
);
}
else
if
(
selector
.
value
)
{
this
.
$set
(
this
.
form
,
'materialUuids'
,
this
.
selectedMaterialId
);
selectedData
=
selector
.
value
;
}
// 触发数据同步(覆盖事件未触发的场景)
this
.
handleMaterialSelectionChange
(
selectedData
);
// 5. 容错处理:确保物料ID有效
const
materialId
=
this
.
selectedMaterialInfo
.
id
||
this
.
selectedMaterialInfo
.
materialId
||
this
.
selectedMaterialInfo
.
uuid
||
''
;
// 6. 赋值并关闭弹窗
this
.
$set
(
this
.
form
,
'materialId'
,
materialId
);
this
.
$set
(
this
.
form
,
'materialUuids'
,
materialId
);
this
.
openMaterialSelector
=
false
;
this
.
openMaterialSelector
=
false
;
// 7. 查询库存并校验字段
console
.
log
(
"【物料选择成功】ID:"
,
this
.
selectedMaterialId
,
"名称:"
,
this
.
form
.
materialName
);
this
.
handleMaterialIdChange
();
this
.
$nextTick
(()
=>
{
this
.
$refs
.
detailForm
?.
validateField
(
'materialId'
);
});
// 重置标记
this
.
$nextTick
(
async
()
=>
{
this
.
isUserInitiatedSelect
=
false
;
await
this
.
handleMaterialIdChange
();
this
.
$refs
.
detailForm
?.
validateField
(
'materialId'
);
});
});
}
}
},
},
...
...
ruoyi-admin-vue/src/views/inventory/orders/index.vue
View file @
1f9d9564
...
@@ -3,14 +3,16 @@
...
@@ -3,14 +3,16 @@
<!-- 页面标题和操作按钮 -->
<!-- 页面标题和操作按钮 -->
<PageTitle>
<PageTitle>
<template
#
buttons
>
<template
#
buttons
>
<el-button
<el-button
type=
"primary"
type=
"primary"
plain
plain
icon=
"el-icon-plus"
icon=
"el-icon-plus"
size=
"medium"
size=
"medium"
@
click=
"handleAdd"
@
click=
"handleAdd"
v-hasPermi=
"['inventory:
orders
:add']"
v-hasPermi=
"['inventory:
inbound
:add']"
>
新增
</el-button>
>
新增
</el-button>
<el-button
<el-button
type=
"success"
type=
"success"
plain
plain
...
@@ -18,16 +20,9 @@
...
@@ -18,16 +20,9 @@
size=
"medium"
size=
"medium"
:disabled=
"single"
:disabled=
"single"
@
click=
"handleUpdate"
@
click=
"handleUpdate"
v-hasPermi=
"['inventory:
orders
:edit']"
v-hasPermi=
"['inventory:
inbound
:edit']"
>
修改
</el-button>
>
修改
</el-button>
<el-button
type=
"success"
plain
icon=
"el-icon-edit"
size=
"medium"
@
click=
"handleImport"
v-hasPermi=
"['inventory:orders:add']"
>
导入
</el-button>
<el-button
<el-button
type=
"danger"
type=
"danger"
plain
plain
...
@@ -35,15 +30,25 @@
...
@@ -35,15 +30,25 @@
size=
"medium"
size=
"medium"
:disabled=
"multiple"
:disabled=
"multiple"
@
click=
"handleDelete"
@
click=
"handleDelete"
v-hasPermi=
"['inventory:
orders
:remove']"
v-hasPermi=
"['inventory:
inbound
:remove']"
>
删除
</el-button>
>
删除
</el-button>
<el-button
type=
"warning"
plain
icon=
"el-icon-upload"
size=
"medium"
@
click=
"handleImport"
v-hasPermi=
"['inventory:inbound:import']"
>
导入
</el-button>
<el-button
<el-button
type=
"warning"
type=
"warning"
plain
plain
icon=
"el-icon-download"
icon=
"el-icon-download"
size=
"medium"
size=
"medium"
@
click=
"handleExport"
@
click=
"handleExport"
v-hasPermi=
"['inventory:
orders
:export']"
v-hasPermi=
"['inventory:
inbound
:export']"
>
导出
</el-button>
>
导出
</el-button>
</
template
>
</
template
>
</PageTitle>
</PageTitle>
...
@@ -98,10 +103,10 @@
...
@@ -98,10 +103,10 @@
/>
/>
</el-select>
</el-select>
</el-form-item>
</el-form-item>
<el-form-item
label=
"批次
ID
"
prop=
"batchCode"
>
<el-form-item
label=
"批次
号
"
prop=
"batchCode"
>
<el-input
<el-input
v-model=
"queryParams.batchCode"
v-model=
"queryParams.batchCode"
placeholder=
"请输入批次
ID
"
placeholder=
"请输入批次
号
"
clearable
clearable
@
keyup
.
enter
.
native=
"handleQuery"
@
keyup
.
enter
.
native=
"handleQuery"
/>
/>
...
@@ -205,7 +210,7 @@
...
@@ -205,7 +210,7 @@
<span
v-else
>
-
</span>
<span
v-else
>
-
</span>
</
template
>
</
template
>
</el-table-column>
</el-table-column>
<el-table-column
label=
"批次
ID
"
align=
"center"
prop=
"batchCode"
width=
"120"
/>
<el-table-column
label=
"批次
号
"
align=
"center"
prop=
"batchCode"
width=
"120"
/>
<el-table-column
label=
"仓库"
align=
"center"
prop=
"warehouseName"
width=
"120"
>
<el-table-column
label=
"仓库"
align=
"center"
prop=
"warehouseName"
width=
"120"
>
<
template
slot-scope=
"scope"
>
<
template
slot-scope=
"scope"
>
{{
scope
.
row
.
warehouseName
||
'-'
}}
{{
scope
.
row
.
warehouseName
||
'-'
}}
...
@@ -336,8 +341,8 @@
...
@@ -336,8 +341,8 @@
<
/el-row
>
<
/el-row
>
<
el
-
row
:
gutter
=
"20"
>
<
el
-
row
:
gutter
=
"20"
>
<
el
-
col
:
span
=
"12"
>
<
el
-
col
:
span
=
"12"
>
<
el
-
form
-
item
label
=
"批次
ID
"
prop
=
"batchCode"
>
<
el
-
form
-
item
label
=
"批次
号
"
prop
=
"batchCode"
>
<
el
-
input
v
-
model
=
"form.batchCode"
placeholder
=
"请输入批次
ID
"
:
disabled
=
"isViewDetail || formDisabled.batchCode"
/>
<
el
-
input
v
-
model
=
"form.batchCode"
placeholder
=
"请输入批次
号
"
:
disabled
=
"isViewDetail || formDisabled.batchCode"
/>
<
/el-form-item
>
<
/el-form-item
>
<
/el-col
>
<
/el-col
>
<
el
-
col
:
span
=
"12"
>
<
el
-
col
:
span
=
"12"
>
...
@@ -420,13 +425,10 @@
...
@@ -420,13 +425,10 @@
<
/el-col
>
<
/el-col
>
<
/el-row
>
<
/el-row
>
<!--
【修改
1
】新增
materialName
展示
-->
<
div
v
-
for
=
"(group, materialId) in outboundOrderItemsGroup"
:
key
=
"materialId"
class
=
"material-group mb10"
>
<
div
v
-
for
=
"(group, materialId) in outboundOrderItemsGroup"
:
key
=
"materialId"
class
=
"material-group mb10"
>
<
div
class
=
"group-header"
style
=
"background: #f5f7fa; padding: 8px 12px; border-radius: 4px; margin-bottom: 8px;"
>
<
div
class
=
"group-header"
style
=
"background: #f5f7fa; padding: 8px 12px; border-radius: 4px; margin-bottom: 8px;"
>
<!--
【修改
2
】展示物料名称(优先取分组的
materialName
,无则用
getMaterialName
方法)
-->
<
span
style
=
"font-weight: 600; margin-right: 16px;"
>
物料:
{{
group
.
materialName
}}
<
/span
>
<
span
style
=
"font-weight: 600; margin-right: 16px;"
>
物料:
{{
group
.
materialName
}}
<
/span
>
<
span
style
=
"color: #666;"
>
明细数量:
{{
group
.
items
.
length
}}
条
<
/span
>
<
span
style
=
"color: #666;"
>
明细数量:
{{
group
.
items
.
length
}}
条
<
/span
>
<!--
仅编辑模式显示分组操作按钮
-->
<
el
-
button
<
el
-
button
type
=
"text"
type
=
"text"
size
=
"mini"
size
=
"mini"
...
...
ruoyi-admin/src/main/java/com/ruoyi/web/controller/inventory/MaterialsController.java
View file @
1f9d9564
...
@@ -7,6 +7,8 @@ import java.util.UUID;
...
@@ -7,6 +7,8 @@ import java.util.UUID;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpServletResponse
;
import
com.ruoyi.common.core.domain.entity.Materials
;
import
com.ruoyi.common.core.domain.entity.Materials
;
import
com.ruoyi.inventory.domain.Inventory
;
import
com.ruoyi.inventory.domain.OutboundOrderItems
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
...
@@ -45,6 +47,19 @@ public class MaterialsController extends BaseController
...
@@ -45,6 +47,19 @@ public class MaterialsController extends BaseController
}
}
/**
/**
* 查询库存列表
*/
@PreAuthorize
(
"@ss.hasPermi('inventory:inventory:list')"
)
@PostMapping
(
"/ListMaterialsInventory"
)
public
TableDataInfo
ListMaterialsInventory
(
Materials
materials
)
{
startPage
();
List
<
Materials
>
list
=
materialsService
.
ListMaterialsInventory
(
materials
);
return
getDataTable
(
list
);
}
/**
* 导出物料列表
* 导出物料列表
*/
*/
@PreAuthorize
(
"@ss.hasPermi('inventory:materials:export')"
)
@PreAuthorize
(
"@ss.hasPermi('inventory:materials:export')"
)
...
...
ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/Materials.java
View file @
1f9d9564
...
@@ -2,8 +2,6 @@ package com.ruoyi.common.core.domain.entity;
...
@@ -2,8 +2,6 @@ package com.ruoyi.common.core.domain.entity;
import
com.ruoyi.common.annotation.Excel
;
import
com.ruoyi.common.annotation.Excel
;
import
com.ruoyi.common.core.domain.BaseEntity
;
import
com.ruoyi.common.core.domain.BaseEntity
;
import
org.apache.commons.lang3.builder.ToStringBuilder
;
import
org.apache.commons.lang3.builder.ToStringStyle
;
/**
/**
* 物料对象 materials
* 物料对象 materials
...
@@ -11,7 +9,6 @@ import org.apache.commons.lang3.builder.ToStringStyle;
...
@@ -11,7 +9,6 @@ import org.apache.commons.lang3.builder.ToStringStyle;
* @author ruoyi
* @author ruoyi
* @date 2025-11-28
* @date 2025-11-28
*/
*/
public
class
Materials
extends
BaseEntity
public
class
Materials
extends
BaseEntity
{
{
private
static
final
long
serialVersionUID
=
1L
;
private
static
final
long
serialVersionUID
=
1L
;
...
@@ -38,7 +35,6 @@ public class Materials extends BaseEntity
...
@@ -38,7 +35,6 @@ public class Materials extends BaseEntity
@Excel
(
name
=
"中文描述"
)
@Excel
(
name
=
"中文描述"
)
private
String
materialName
;
private
String
materialName
;
/** 物料名称 检索条件 */
/** 物料名称 检索条件 */
@Excel
(
name
=
"英文描述"
)
@Excel
(
name
=
"英文描述"
)
private
String
materialEname
;
private
String
materialEname
;
...
@@ -136,6 +132,12 @@ public class Materials extends BaseEntity
...
@@ -136,6 +132,12 @@ public class Materials extends BaseEntity
/** 排序号 */
/** 排序号 */
private
String
updateUserCode
;
private
String
updateUserCode
;
// ======================== 仅新增这一个库存字段 ========================
/** 库存数量(关联inventory表) */
@Excel
(
name
=
"库存数量"
)
private
Long
stock
;
// ======================== 原有所有getter/setter(完整保留) ========================
public
String
getId
()
{
public
String
getId
()
{
return
id
;
return
id
;
}
}
...
@@ -386,6 +388,15 @@ public class Materials extends BaseEntity
...
@@ -386,6 +388,15 @@ public class Materials extends BaseEntity
this
.
updateUserCode
=
updateUserCode
;
this
.
updateUserCode
=
updateUserCode
;
}
}
// ======================== 仅新增库存字段的getter/setter ========================
public
Long
getStock
()
{
return
stock
;
}
public
void
setStock
(
Long
stock
)
{
this
.
stock
=
stock
;
}
@Override
@Override
public
String
toString
()
{
public
String
toString
()
{
return
"Materials{"
+
return
"Materials{"
+
...
@@ -420,6 +431,7 @@ public class Materials extends BaseEntity
...
@@ -420,6 +431,7 @@ public class Materials extends BaseEntity
", sortNo="
+
sortNo
+
", sortNo="
+
sortNo
+
", createUserCode='"
+
createUserCode
+
'\''
+
", createUserCode='"
+
createUserCode
+
'\''
+
", updateUserCode='"
+
updateUserCode
+
'\''
+
", updateUserCode='"
+
updateUserCode
+
'\''
+
", stock="
+
stock
+
// 仅追加这一行
'}'
;
'}'
;
}
}
}
}
\ No newline at end of file
ruoyi-inventory/src/main/java/com/ruoyi/inventory/controller/InventoryController.java
View file @
1f9d9564
...
@@ -99,6 +99,9 @@ public class InventoryController extends BaseController
...
@@ -99,6 +99,9 @@ public class InventoryController extends BaseController
List
<
Inventory
>
list
=
inventoryService
.
listByMatreialId
(
inventory
);
List
<
Inventory
>
list
=
inventoryService
.
listByMatreialId
(
inventory
);
return
getDataTable
(
list
);
return
getDataTable
(
list
);
}
}
/**
/**
* 导出库存列表
* 导出库存列表
*/
*/
...
...
ruoyi-inventory/src/main/java/com/ruoyi/inventory/controller/OutboundOrderItemsController.java
View file @
1f9d9564
...
@@ -3,9 +3,11 @@ package com.ruoyi.inventory.controller;
...
@@ -3,9 +3,11 @@ package com.ruoyi.inventory.controller;
import
java.util.List
;
import
java.util.List
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpServletResponse
;
import
com.ruoyi.inventory.domain.OutboundOrderLog
;
import
com.ruoyi.inventory.domain.vo.inboundVO.InboundTemplateVO
;
import
com.ruoyi.inventory.domain.vo.inboundVO.InboundTemplateVO
;
import
com.ruoyi.inventory.domain.vo.OutboundOrdersSummaryVO
;
import
com.ruoyi.inventory.domain.vo.OutboundOrdersSummaryVO
;
import
com.ruoyi.inventory.domain.vo.OutboundTemplateVO
;
import
com.ruoyi.inventory.domain.vo.OutboundTemplateVO
;
import
com.ruoyi.inventory.service.IOutboundOrderLogService
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.GetMapping
;
...
@@ -39,6 +41,9 @@ public class OutboundOrderItemsController extends BaseController
...
@@ -39,6 +41,9 @@ public class OutboundOrderItemsController extends BaseController
{
{
@Autowired
@Autowired
private
IOutboundOrderItemsService
outboundOrderItemsService
;
private
IOutboundOrderItemsService
outboundOrderItemsService
;
@Autowired
private
IOutboundOrderLogService
outboundOrderLogService
;
/**
/**
* 查询出库单明细列表
* 查询出库单明细列表
...
@@ -55,6 +60,19 @@ public class OutboundOrderItemsController extends BaseController
...
@@ -55,6 +60,19 @@ public class OutboundOrderItemsController extends BaseController
* 查询出库单明细列表
* 查询出库单明细列表
*/
*/
@PreAuthorize
(
"@ss.hasPermi('inventory:items:list')"
)
@PreAuthorize
(
"@ss.hasPermi('inventory:items:list')"
)
@GetMapping
(
"/listLog"
)
public
TableDataInfo
listLog
(
OutboundOrderItems
outboundOrderItems
)
{
startPage
();
OutboundOrderLog
outboundOrderLog
=
new
OutboundOrderLog
();
outboundOrderLog
.
setOrderId
(
outboundOrderItems
.
getOrderId
());
List
<
OutboundOrderLog
>
list
=
outboundOrderLogService
.
selectOutboundOrderLogList
(
outboundOrderLog
);
return
getDataTable
(
list
);
}
/**
* 查询出库单明细列表
*/
@PreAuthorize
(
"@ss.hasPermi('inventory:items:list')"
)
@GetMapping
(
"/getStatistics"
)
@GetMapping
(
"/getStatistics"
)
public
TableDataInfo
getStatistics
(
OutboundOrdersSummaryVO
outboundOrderItems
)
public
TableDataInfo
getStatistics
(
OutboundOrdersSummaryVO
outboundOrderItems
)
{
{
...
@@ -146,4 +164,5 @@ public class OutboundOrderItemsController extends BaseController
...
@@ -146,4 +164,5 @@ public class OutboundOrderItemsController extends BaseController
return
toAjax
(
outboundOrderItemsService
.
deleteOutboundOrderItemsByIds
(
ids
));
return
toAjax
(
outboundOrderItemsService
.
deleteOutboundOrderItemsByIds
(
ids
));
}
}
}
}
ruoyi-inventory/src/main/java/com/ruoyi/inventory/mapper/MaterialsMapper.java
View file @
1f9d9564
...
@@ -4,6 +4,7 @@ import java.util.List;
...
@@ -4,6 +4,7 @@ import java.util.List;
import
java.util.Map
;
import
java.util.Map
;
import
com.ruoyi.common.core.domain.entity.Materials
;
import
com.ruoyi.common.core.domain.entity.Materials
;
import
com.ruoyi.inventory.domain.OutboundOrderItems
;
import
org.apache.ibatis.annotations.MapKey
;
import
org.apache.ibatis.annotations.MapKey
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Mapper
;
...
@@ -41,6 +42,14 @@ public interface MaterialsMapper
...
@@ -41,6 +42,14 @@ public interface MaterialsMapper
public
List
<
Materials
>
selectMaterialsList
(
Materials
materials
);
public
List
<
Materials
>
selectMaterialsList
(
Materials
materials
);
/**
/**
* 查询物料列表
*
* @param materials 物料
* @return 物料集合
*/
public
List
<
Materials
>
selectMaterialsInventoryList
(
Materials
materials
);
/**
* 新增物料
* 新增物料
*
*
* @param materials 物料
* @param materials 物料
...
@@ -104,4 +113,6 @@ public interface MaterialsMapper
...
@@ -104,4 +113,6 @@ public interface MaterialsMapper
*/
*/
@MapKey
(
"sap_no"
)
@MapKey
(
"sap_no"
)
public
Map
<
String
,
Map
<
String
,
String
>>
selectMaterialIdAndSapMap
();
public
Map
<
String
,
Map
<
String
,
String
>>
selectMaterialIdAndSapMap
();
}
}
ruoyi-inventory/src/main/java/com/ruoyi/inventory/service/IMaterialsService.java
View file @
1f9d9564
package
com
.
ruoyi
.
inventory
.
service
;
package
com
.
ruoyi
.
inventory
.
service
;
import
com.ruoyi.common.core.domain.entity.Materials
;
import
com.ruoyi.common.core.domain.entity.Materials
;
import
com.ruoyi.inventory.domain.OutboundOrderItems
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -30,6 +31,13 @@ public interface IMaterialsService
...
@@ -30,6 +31,13 @@ public interface IMaterialsService
public
List
<
Materials
>
selectMaterialsList
(
Materials
materials
);
public
List
<
Materials
>
selectMaterialsList
(
Materials
materials
);
/**
/**
* 查询物料列表
*
* @param materials 物料
* @return 物料集合
*/
public
List
<
Materials
>
ListMaterialsInventory
(
Materials
materials
);
/**
* 新增物料
* 新增物料
*
*
* @param materials 物料
* @param materials 物料
...
...
ruoyi-inventory/src/main/java/com/ruoyi/inventory/service/impl/InventoryServiceImpl.java
View file @
1f9d9564
...
@@ -55,6 +55,7 @@ public class InventoryServiceImpl implements IInventoryService
...
@@ -55,6 +55,7 @@ public class InventoryServiceImpl implements IInventoryService
return
inventoryMapper
.
selectInventoryById
(
id
);
return
inventoryMapper
.
selectInventoryById
(
id
);
}
}
/**
/**
* 查询库存列表
* 查询库存列表
*
*
...
...
ruoyi-inventory/src/main/java/com/ruoyi/inventory/service/impl/MaterialsServiceImpl.java
View file @
1f9d9564
...
@@ -10,6 +10,7 @@ import com.ruoyi.common.exception.ServiceException;
...
@@ -10,6 +10,7 @@ import com.ruoyi.common.exception.ServiceException;
import
com.ruoyi.common.utils.DateUtils
;
import
com.ruoyi.common.utils.DateUtils
;
import
com.ruoyi.common.utils.SecurityUtils
;
import
com.ruoyi.common.utils.SecurityUtils
;
import
com.ruoyi.common.utils.StringUtils
;
import
com.ruoyi.common.utils.StringUtils
;
import
com.ruoyi.inventory.domain.OutboundOrderItems
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
com.ruoyi.inventory.mapper.MaterialsMapper
;
import
com.ruoyi.inventory.mapper.MaterialsMapper
;
...
@@ -51,6 +52,11 @@ public class MaterialsServiceImpl implements IMaterialsService
...
@@ -51,6 +52,11 @@ public class MaterialsServiceImpl implements IMaterialsService
return
materialsMapper
.
selectMaterialsList
(
materials
);
return
materialsMapper
.
selectMaterialsList
(
materials
);
}
}
@Override
public
List
<
Materials
>
ListMaterialsInventory
(
Materials
materials
)
{
return
materialsMapper
.
selectMaterialsInventoryList
(
materials
);
}
/**
/**
* 新增物料
* 新增物料
*
*
...
...
ruoyi-inventory/src/main/resources/mapper/inventory/MaterialsMapper.xml
View file @
1f9d9564
...
@@ -34,6 +34,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
...
@@ -34,6 +34,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result
property=
"createUserCode"
column=
"create_user_code"
/>
<result
property=
"createUserCode"
column=
"create_user_code"
/>
<result
property=
"updateTime"
column=
"update_time"
/>
<result
property=
"updateTime"
column=
"update_time"
/>
<result
property=
"updateUserCode"
column=
"update_user_code"
/>
<result
property=
"updateUserCode"
column=
"update_user_code"
/>
<result
property=
"stock"
column=
"stock"
/>
</resultMap>
</resultMap>
<sql
id=
"selectMaterialsVo"
>
<sql
id=
"selectMaterialsVo"
>
...
@@ -73,6 +74,73 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
...
@@ -73,6 +74,73 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
order by sort_no asc
order by sort_no asc
</select>
</select>
<select
id=
"selectMaterialsInventoryList"
parameterType=
"Materials"
resultMap=
"MaterialsResult"
>
select
m.id,
m.material_code,
m.material_name,
m.material_ename,
m.sap_no,
m.ts_code,
m.category_code,
m.hazard_id,
m.specification,
m.material_unit,
m.unit_weight,
m.package_weight,
m.total_weight,
m.volume,
m.shelf_life_days,
m.storage_temperature,
m.special_requirements,
m.is_batch_managed,
m.is_serial_managed,
m.min_stock_level,
m.max_stock_level,
IFNULL(i.quantity-locked_quantity, 0) as stock, -- 无库存时默认显示0
m.is_used,
m.is_active,
m.risk_level,
m.sort_no,
m.create_time,
m.create_user_code,
m.update_time,
m.update_user_code
from materials m
left join inventory i on m.id = i.material_id
<where>
m.is_used = 1
<if
test=
"materialCode != null and materialCode != ''"
>
and m.material_code like concat('%', #{materialCode}, '%')
</if>
<if
test=
"materialName != null and materialName != ''"
>
and m.material_name like concat('%', #{materialName}, '%')
</if>
<if
test=
"sapNo != null and sapNo != ''"
>
and m.sap_no like concat('%', #{sapNo}, '%')
</if>
<if
test=
"tsCode != null and tsCode != ''"
>
and m.ts_code like concat('%', #{tsCode}, '%')
</if>
<if
test=
"categoryCode != null and categoryCode != ''"
>
and m.category_code = #{categoryCode}
</if>
<if
test=
"hazardId != null and hazardId != ''"
>
and m.hazard_id like concat('%', #{hazardId}, '%')
</if>
<if
test=
"specification != null and specification != ''"
>
and m.specification like concat('%', #{specification}, '%')
</if>
<if
test=
"materialUnit != null and materialUnit != ''"
>
and m.material_unit like concat('%', #{materialUnit}, '%')
</if>
<if
test=
"unitWeight != null "
>
and m.unit_weight = #{unitWeight}
</if>
<if
test=
"packageWeight != null "
>
and m.package_weight = #{packageWeight}
</if>
<if
test=
"totalWeight != null "
>
and m.total_weight = #{totalWeight}
</if>
<if
test=
"volume != null "
>
and m.volume = #{volume}
</if>
<if
test=
"shelfLifeDays != null "
>
and m.shelf_life_days = #{shelfLifeDays}
</if>
<if
test=
"storageTemperature != null and storageTemperature != ''"
>
and m.storage_temperature like concat('%', #{storageTemperature}, '%')
</if>
<if
test=
"specialRequirements != null and specialRequirements != ''"
>
and m.special_requirements like concat('%', #{specialRequirements}, '%')
</if>
<if
test=
"isBatchManaged != null "
>
and m.is_batch_managed = #{isBatchManaged}
</if>
<if
test=
"isSerialManaged != null "
>
and m.is_serial_managed = #{isSerialManaged}
</if>
<if
test=
"minStockLevel != null "
>
and m.min_stock_level = #{minStockLevel}
</if>
<if
test=
"maxStockLevel != null "
>
and m.max_stock_level = #{maxStockLevel}
</if>
<if
test=
"isUsed != null "
>
and m.is_used = #{isUsed}
</if>
<if
test=
"isActive != null "
>
and m.is_active = #{isActive}
</if>
<if
test=
"riskLevel != null and riskLevel != ''"
>
and m.risk_level like concat('%', #{riskLevel}, '%')
</if>
<if
test=
"sortNo != null "
>
and m.sort_no = #{sortNo}
</if>
<if
test=
"createTime != null "
>
and m.create_time like concat('%', #{createTime}, '%')
</if>
<if
test=
"updateTime != null "
>
and m.update_time like concat('%', #{updateTime}, '%')
</if>
-- 可选:添加库存数量的查询条件(如果需要)
<if
test=
"stock != null "
>
and i.stock = #{stock}
</if>
</where>
order by stock desc
</select>
<select
id=
"selectMaterialsById"
parameterType=
"String"
resultMap=
"MaterialsResult"
>
<select
id=
"selectMaterialsById"
parameterType=
"String"
resultMap=
"MaterialsResult"
>
<include
refid=
"selectMaterialsVo"
/>
<include
refid=
"selectMaterialsVo"
/>
where id = #{id}
where id = #{id}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论