Commit 358760de by wangchunyang
parents 82fd5953 6dd5c256
......@@ -113,24 +113,35 @@
</el-form-item>
</el-form>
<!-- 物料查询表格 -->
<!-- 物料查询表格(折叠面板分组) -->
<div class="table-container">
<el-table v-loading="loading" :data="returnOrderItemList" border height="100%" style="width: 100%">
<el-table-column type="index" label="序号" width="60" align="center" fixed="left" />
<el-collapse v-loading="loading" accordion>
<!-- 遍历SAP分组 -->
<el-collapse-item
v-for="(group, groupIndex) in groupedList"
:key="groupIndex"
:title="`SAP物料号:${group.sapNo || '未分类'}(共${group.items.length}条)`"
:name="group.sapNo || `uncategorized-${groupIndex}`"
>
<el-table
:data="group.items"
border
style="width: 100%; margin-top: 8px;"
>
<el-table-column type="index" label="序号" width="60" align="center" />
<el-table-column label="物料名称" align="center" prop="materialName" min-width="150" show-overflow-tooltip />
<el-table-column label="SAP物料号" align="center" prop="sapNo" width="120" />
<el-table-column label="TS Code" align="center" prop="tsCode" width="120" />
<el-table-column label="危险类别" align="center" prop="hazardId" width="120" />
<el-table-column label="规格型号" align="center" prop="specification" width="120" />
<el-table-column label="计量单位" align="center" prop="materialUnit" width="120" />
<el-table-column label="单位重量" align="center" prop="unitWeight" width="120" >
<el-table-column label="单位重量" align="center" prop="unitWeight" width="120">
<template slot-scope="scope">
{{ formatAmount(scope.row.unitWeight || 0) }}
</template>
</el-table-column>
<el-table-column label="计划数量" align="center" prop="plannedQuantity" width="100" />
<el-table-column label="实际数量" align="center" prop="actualQuantity" width="100" />
<el-table-column label="总额" align="center" prop="totalAmount" width="100" >
<el-table-column label="总额" align="center" prop="totalAmount" width="100">
<template slot-scope="scope">
{{ formatAmount(scope.row.totalAmount || 0) }}
</template>
......@@ -146,9 +157,13 @@
</template>
</el-table-column>
</el-table>
</el-collapse-item>
<!-- 无数据提示 -->
<div v-if="!loading && groupedList.length === 0" class="no-data">暂无数据</div>
</el-collapse>
</div>
<!-- 分页组件 -->
<!-- 分页组件(全局分页,按原始数据总数分页) -->
<pagination
v-show="total>0"
:total="total"
......@@ -310,7 +325,7 @@ export default {
loading: true,
showSearch: true,
total: 0,
returnOrderItemList: [],
groupedList: [], // 按SAP分组后的列表
queryParams: {
pageNum: 1,
pageSize: 10,
......@@ -371,11 +386,36 @@ export default {
delete params.dateRange
listInboundOutboundStatistics(params).then(response => {
this.returnOrderItemList = response.rows || []
const rawList = response.rows || []
this.total = response.total || 0
// 核心:按sapNo分组
const groupedMap = {}
rawList.forEach(item => {
// sapNo为空时归为"未分类"
const sapKey = item.sapNo || '未分类'
if (!groupedMap[sapKey]) {
groupedMap[sapKey] = []
}
groupedMap[sapKey].push(item)
})
// 转换为分组列表(用于折叠面板渲染)
this.groupedList = Object.keys(groupedMap).map(sapNo => ({
sapNo,
items: groupedMap[sapNo],
expanded: false // 默认全部折叠,可改为 true 全部展开
}))
// 默认展开第一个分组(可选)
if (this.groupedList.length > 0) {
this.groupedList[0].expanded = true
}
this.loading = false
}).catch(() => {
this.loading = false
this.groupedList = []
})
},
handleQuery() {
......@@ -569,4 +609,21 @@ export default {
.w20 {
width: 150px;
}
.no-data {
text-align: center;
padding: 20px;
color: #999;
font-size: 14px;
}
/* 折叠面板样式优化 */
::v-deep .el-collapse-item__header {
font-size: 14px;
font-weight: 500;
}
::v-deep .el-collapse-item__content {
padding: 0 !important;
}
</style>
\ No newline at end of file
......@@ -222,7 +222,7 @@
</el-row>
<el-row :gutter="20" style="margin: 10px 0;">
<el-col :span="24">
<div><strong>允许存放物料名称:</strong>{{ scope.row.materialNames || '-' }}</div>
<div><strong>允许存放物料名称:</strong>{{ scope.row.allowedCategoryNames || '-' }}</div>
</el-col>
</el-row>
</template>
......@@ -263,7 +263,7 @@
<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="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">
<el-tooltip
:content="scope.row.allowedCategoryNames"
......@@ -294,22 +294,13 @@
</el-tooltip>
</template>
</el-table-column>
<el-table-column label="允许存放物料编码" align="center" prop="materialCodes" width="200">
<template slot-scope="scope">
<el-tooltip :content="scope.row.materialCodes" placement="top">
<div class="material-names">
{{ scope.row.materialCodes ? (scope.row.materialCodes.length > 20 ? scope.row.materialCodes.substring(0, 20) + '...' : scope.row.materialCodes) : '-' }}
</div>
</el-tooltip>
</template>
</el-table-column>
<el-table-column label="温区" align="center" prop="temperatureZone" width="100" />
<el-table-column label="应用状态" align="center" prop="isEnabled" width="100">
<template slot-scope="scope">
<dict-tag :options="dict.type.is_enabled" :value="scope.row.isEnabled"/>
</template>
</el-table-column>
<el-table-column label="排序" align="center" prop="sortNo" width="80" />
<el-table-column label="创建日期" align="center" prop="createTime" width="160" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="120" fixed="right">
<template slot-scope="scope">
......@@ -520,21 +511,14 @@
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="允许存放物料" prop="materialCodes">
<el-form-item label="允许存放物料" prop="allowedCategoryIds">
<div style="display: flex; align-items: center; flex-direction: column; gap: 8px;">
<el-input
v-model="form.materialNames"
v-model="form.allowedCategoryNames"
@click="initMaterialSelector"
placeholder="请选择允许存放的物料"
readonly
style="width: 100%;"
/>
<!-- 修复:点击事件改为初始化方法 -->
<el-button
type="primary"
size="small"
@click.stop="initMaterialSelector"
style="align-self: flex-end;"
>选择物料</el-button>
</div>
</el-form-item>
</el-col>
......@@ -548,17 +532,7 @@
</el-radio-group>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="排序" prop="sortNo">
<el-input-number
v-model="form.sortNo"
placeholder="请输入排序"
:min="0"
:step="1"
style="width: 100%;"
/>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="20">
<el-col :span="24">
......@@ -586,7 +560,7 @@
<materialsSeletor
ref="materialsSeletor"
@selection-change="handleMaterialSelectionChange"
:selected-material-codes="form.materialCodes ? form.materialCodes.split(',').filter(u => u.trim()) : []"
:selected-material-codes="form.allowedCategoryIds ? form.allowedCategoryIds.split(',').filter(u => u.trim()) : []"
:multiple="true"
:default-category-codes="form.allowedCategoryIds ? form.allowedCategoryIds.split(',').filter(c => c.trim()) : []"
/>
......@@ -669,10 +643,8 @@ export default {
capacity: null,
volumeCapacity: null,
allowedHazardLevels: null,
materialCodes: null,
materialNames: null,
allowedCategoryIds: null,
allowedCategoryNames: null,
allowedCategoryIds: null, // 原materialCodes
allowedCategoryNames: null, // 原materialNames
temperatureZone: null,
isEnabled: 1,
isUsed: 1,
......@@ -750,8 +722,8 @@ export default {
console.log('【初始化物料选择器】清空残留数据')
// 1. 清空临时选择数据(区分新增/修改)
this.tempSelectedMaterials = {
materialCodes: this.form.id ? (this.form.materialCodes ? this.form.materialCodes.split(',').filter(u => u.trim()) : []) : [],
names: this.form.id ? (this.form.materialNames ? this.form.materialNames.split(',').filter(n => n.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()) : []) : [],
categoryIds: this.form.id ? (this.form.allowedCategoryIds ? this.form.allowedCategoryIds.split(',').filter(c => c.trim()) : []) : []
}
// 2. 延迟打开弹窗,确保数据先清空
......@@ -993,29 +965,29 @@ export default {
let materialCodes = []
let materialNames = []
// 优先从materialIds数组读取
if (Array.isArray(rowData.materialIds) && rowData.materialIds.length) {
materialCodes = rowData.materialIds
// 优先从allowedCategoryIds数组读取(原materialIds)
if (Array.isArray(rowData.allowedCategoryIds) && rowData.allowedCategoryIds.length) {
materialCodes = rowData.allowedCategoryIds
.filter(code => code && code.trim())
.map(code => code.trim().toUpperCase())
.filter((code, index, self) => self.indexOf(code) === index)
}
// 兼容字符串格式
else if (rowData.materialCodes) {
materialCodes = rowData.materialCodes.split(',')
else if (rowData.allowedCategoryIds) {
materialCodes = rowData.allowedCategoryIds.split(',')
.filter(code => code && code.trim())
.map(code => code.trim().toUpperCase())
.filter((code, index, self) => self.indexOf(code) === index)
}
// 处理物料名称
if (Array.isArray(rowData.names) && rowData.names.length) {
materialNames = rowData.names
if (Array.isArray(rowData.allowedCategoryNames) && rowData.allowedCategoryNames.length) {
materialNames = rowData.allowedCategoryNames
.filter(name => name && name.trim())
.filter((name, index, self) => self.indexOf(name) === index)
}
else if (rowData.materialNames) {
materialNames = rowData.materialNames.split(',')
else if (rowData.allowedCategoryNames) {
materialNames = rowData.allowedCategoryNames.split(',')
.filter(name => name && name.trim())
.filter((name, index, self) => self.indexOf(name) === index)
}
......@@ -1026,36 +998,12 @@ export default {
})
}
// 处理分类ID
let categoryIds = []
if (Array.isArray(rowData.categoryIds) && rowData.categoryIds.length) {
categoryIds = rowData.categoryIds
.filter(id => id && id.trim())
.filter((id, index, self) => self.indexOf(id) === index)
}
else if (rowData.allowedCategoryIds) {
categoryIds = rowData.allowedCategoryIds.split(',')
.filter(id => id && id.trim())
.filter((id, index, self) => self.indexOf(id) === index)
}
// 处理分类ID(现在存储的是物料编码)
let categoryIds = materialCodes
// 更新表单数据
this.form.materialCodes = materialCodes.join(',')
this.form.materialNames = materialNames.join(',')
this.form.allowedCategoryIds = categoryIds.join(',')
// 处理分类名称
if (categoryIds.length && this.$refs.materialsSeletor) {
const categoryNames = categoryIds.map(code => {
const rawCode = code.replace(/-/g, '')
return this.$refs.materialsSeletor.categoryMap?.[rawCode] || code
})
this.form.allowedCategoryNames = categoryNames.join(',')
console.log('【修改库位】处理后的分类名称:', categoryNames)
} else if (rowData.allowedCategoryNames) {
this.form.allowedCategoryNames = rowData.allowedCategoryNames
console.log('【修改库位】使用原始分类名称:', rowData.allowedCategoryNames)
}
this.form.allowedCategoryIds = materialCodes.join(',')
this.form.allowedCategoryNames = materialNames.join(',')
// 更新临时选择数据
this.tempSelectedMaterials = {
......@@ -1065,9 +1013,8 @@ export default {
}
console.log('【修改库位】处理后的物料数据:', {
materialCodes: this.form.materialCodes,
materialNames: this.form.materialNames,
categoryIds: this.form.allowedCategoryIds
allowedCategoryIds: this.form.allowedCategoryIds,
allowedCategoryNames: this.form.allowedCategoryNames
})
this.open = true
......@@ -1095,8 +1042,6 @@ export default {
return result
}
this.form.materialCodes = formatField(this.form.materialCodes)
this.form.materialNames = formatField(this.form.materialNames)
this.form.allowedCategoryIds = formatField(this.form.allowedCategoryIds)
this.form.allowedCategoryNames = formatField(this.form.allowedCategoryNames)
......@@ -1176,10 +1121,8 @@ export default {
.filter(name => name && name.trim())
.filter((name, index, self) => self.indexOf(name) === index)
// 分类ID取selectedData.categoryIds
const categoryIds = (selectedData.categoryIds || [])
.filter(id => id && id.trim())
.filter((id, index, self) => self.indexOf(id) === index)
// 分类ID取selectedData.categoryIds(现在存储的是物料编码)
const categoryIds = materialCodes
this.tempSelectedMaterials = {
materialCodes,
......@@ -1196,8 +1139,8 @@ export default {
this.showMaterialSelect = false
// 恢复原有选择状态
this.tempSelectedMaterials = {
materialCodes: this.form.materialCodes ? this.form.materialCodes.split(',').filter(u => u.trim()) : [],
names: this.form.materialNames ? this.form.materialNames.split(',').filter(n => n.trim()) : [],
materialCodes: this.form.allowedCategoryIds ? this.form.allowedCategoryIds.split(',').filter(u => u.trim()) : [],
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)
......@@ -1215,24 +1158,10 @@ export default {
}
// 更新表单数据(确保去重和过滤)
this.form.materialCodes = this.tempSelectedMaterials.materialCodes.join(',')
this.form.materialNames = this.tempSelectedMaterials.names.join(',')
this.form.allowedCategoryIds = this.tempSelectedMaterials.categoryIds.join(',')
// 生成分类名称
if (this.$refs.materialsSeletor && this.tempSelectedMaterials.categoryIds.length) {
const categoryNames = this.tempSelectedMaterials.categoryIds.map(code => {
const rawCode = code.replace(/-/g, '')
return this.$refs.materialsSeletor.categoryMap?.[rawCode] || code
}).filter(name => name && name.trim())
this.form.allowedCategoryNames = categoryNames.join(',')
console.log('【确认物料选择】生成的分类名称:', categoryNames)
}
this.form.allowedCategoryIds = this.tempSelectedMaterials.materialCodes.join(',')
this.form.allowedCategoryNames = this.tempSelectedMaterials.names.join(',')
console.log('【确认物料选择】更新后的表单物料数据:', {
materialCodes: this.form.materialCodes,
materialNames: this.form.materialNames,
allowedCategoryIds: this.form.allowedCategoryIds,
allowedCategoryNames: this.form.allowedCategoryNames
})
......@@ -1264,10 +1193,8 @@ export default {
capacity: null,
volumeCapacity: null,
allowedHazardLevels: null,
materialCodes: null,
materialNames: null,
allowedCategoryIds: null,
allowedCategoryNames: null,
allowedCategoryIds: null, // 原materialCodes
allowedCategoryNames: null, // 原materialNames
temperatureZone: null,
isEnabled: 1,
isUsed: 1,
......
......@@ -133,7 +133,6 @@
</el-tag>
</template>
</el-table-column>
<el-table-column label="排序" align="center" prop="sortNo" width="80" />
<el-table-column label="创建日期" align="center" prop="createTime" width="160" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="120" fixed="right">
<template slot-scope="scope">
......@@ -232,19 +231,6 @@
</el-col>
</el-row>
<el-row :gutter="20">
<el-col :span="12">
<el-form-item label="排序" prop="sortNo">
<el-input-number
v-model="form.sortNo"
placeholder="请输入排序"
:min="0"
:step="1"
style="width: 100%"
/>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="20">
<el-col :span="24">
<el-form-item label="仓库地点" prop="address">
<el-input v-model="form.address" type="textarea" placeholder="请输入内容" :rows="3" />
......@@ -374,10 +360,6 @@ export default {
isEnabled: [
{ required: true, message: '应用状态不能为空', trigger: 'change' }
],
sortNo: [
{ required: true, message: '排序不能为空', trigger: 'blur' },
{ type: 'number', message: '排序必须为数字值', trigger: 'blur' }
],
area: [
{
validator: (rule, value, callback) => {
......
......@@ -49,7 +49,21 @@ public class StorageLocationsServiceImpl implements IStorageLocationsService
@Override
public StorageLocations selectStorageLocationsById(String id)
{
return storageLocationsMapper.selectStorageLocationsById(id);
StorageLocations storageLocations = storageLocationsMapper.selectStorageLocationsById(id);
String[] AllowedCategoryIds = storageLocations.getAllowedCategoryIds().split(",");
String AllowedCategoryName = "";
for (String AllowedCategoryId : AllowedCategoryIds) {
Materials materials = materialsMapper.selectMaterialsById(AllowedCategoryId);
if (materials != null && materials.getMaterialName() != null) {
String categoryName = materials.getMaterialName().trim(); // 去除首尾空格
if (AllowedCategoryName != "") {
AllowedCategoryName += ",";
}
AllowedCategoryName += categoryName;
}
}
storageLocations.setAllowedCategoryNames(AllowedCategoryName);
return storageLocations;
}
@Override
......@@ -77,18 +91,14 @@ public class StorageLocationsServiceImpl implements IStorageLocationsService
if (storageLocations2.getAllowedCategoryIds() != null && !storageLocations2.getAllowedCategoryIds().isEmpty()){
String[] AllowedCategoryIds = storageLocations2.getAllowedCategoryIds().split(",");
for (String AllowedCategoryId : AllowedCategoryIds) {
List<Materials> materials = materialsMapper.selectMaterialsBySapNo(AllowedCategoryId);
if (materials != null && !materials.isEmpty()) {
Materials materials1 = materials.get(0);
if (materials1 != null && materials1.getMaterialName() != null) {
String categoryName = materials1.getMaterialName().trim(); // 去除首尾空格
Materials materials = materialsMapper.selectMaterialsById(AllowedCategoryId);
if (materials != null && materials.getMaterialName() != null) {
String categoryName = materials.getMaterialName().trim(); // 去除首尾空格
if (AllowedCategoryName != "") {
AllowedCategoryName += ",";
}
AllowedCategoryName += categoryName;
} }
}
}
}
storageLocations2.setAllowedCategoryNames(AllowedCategoryName);
......@@ -123,11 +133,8 @@ public class StorageLocationsServiceImpl implements IStorageLocationsService
storageLocationsCategory.setCategoryId(categoryId);
storageLocationsCategory.setCreateTime(DateUtils.getNowDate());
storageLocationsCategory.setCreateUserCode(String.valueOf(SecurityUtils.getUserId()));
List<Materials> materials = materialsMapper.selectMaterialsBySapNo(categoryId);
if (materials != null && !materials.isEmpty()) {
Materials materials1 = materials.get(0);
storageLocationsCategory.setCategoryName(materials1.getMaterialName());
}
Materials materials = materialsMapper.selectMaterialsById(categoryId);
storageLocationsCategory.setCategoryName(materials.getMaterialName());
storageLocationsCategoryMapper.insertStorageLocationsCategory(storageLocationsCategory);
}
}
......@@ -162,11 +169,8 @@ public class StorageLocationsServiceImpl implements IStorageLocationsService
storageLocationsCategory.setCategoryId(categoryId);
storageLocationsCategory.setUpdateTime(DateUtils.getNowDate());
storageLocationsCategory.setUpdateUserCode(String.valueOf(SecurityUtils.getUserId()));
List<Materials> materials = materialsMapper.selectMaterialsBySapNo(categoryId);
if (materials != null && !materials.isEmpty()) {
Materials materials1 = materials.get(0);
storageLocationsCategory.setCategoryName(materials1.getMaterialName());
}
Materials materials = materialsMapper.selectMaterialsById(categoryId);
storageLocationsCategory.setCategoryName(materials.getMaterialName());
storageLocationsCategoryMapper.insertStorageLocationsCategory(storageLocationsCategory);
}
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论