库存前端页面优化
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
|
||||
<el-form-item label="出入库单号" prop="stockIoCode">
|
||||
<el-form-item label="出入库单号" prop="stockIoCode" style="min-width:200px;max-width:220px;">
|
||||
<el-input
|
||||
v-model="queryParams.stockIoCode"
|
||||
placeholder="请输入出入库单号"
|
||||
@@ -94,12 +94,16 @@
|
||||
<el-table-column label="出入库单号" align="center" prop="stockIoCode" />
|
||||
<el-table-column label="类型" align="center" prop="ioType">
|
||||
<template slot-scope="scope">
|
||||
<dict-tag :options="dict.type.stock_io_type" :value="scope.row.ioType"/>
|
||||
<el-tag :type="getIoTypeTagType(scope.row.ioType)">
|
||||
{{ getIoTypeLabel(scope.row.ioType) }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="业务类型" align="center" prop="bizType">
|
||||
<template slot-scope="scope">
|
||||
<dict-tag :options="dict.type.stock_biz_type" :value="scope.row.bizType"/>
|
||||
<el-tag :type="getBizTypeTagType(scope.row.bizType)">
|
||||
{{ getBizTypeLabel(scope.row.bizType) }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="单据状态" align="center" prop="status">
|
||||
@@ -401,6 +405,35 @@ export default {
|
||||
}
|
||||
// 刷新列表
|
||||
this.getList();
|
||||
},
|
||||
getIoTypeTagType(type) {
|
||||
if (type === 'in') return 'success';
|
||||
if (type === 'out') return 'primary';
|
||||
if (type === 'transfer') return 'warning';
|
||||
return '';
|
||||
},
|
||||
getIoTypeLabel(type) {
|
||||
if (type === 'in') return '入库';
|
||||
if (type === 'out') return '出库';
|
||||
if (type === 'transfer') return '移库';
|
||||
return type;
|
||||
},
|
||||
getBizTypeTagType(type) {
|
||||
if (type === 'purchase') return 'success';
|
||||
if (type === 'sales') return 'primary';
|
||||
if (type === 'return') return 'warning';
|
||||
if (type === 'relocation') return 'info';
|
||||
return 'default';
|
||||
},
|
||||
getBizTypeLabel(type) {
|
||||
const map = {
|
||||
purchase: '采购',
|
||||
sales: '销售',
|
||||
return: '退货',
|
||||
relocation: '调拨',
|
||||
other: '其他'
|
||||
};
|
||||
return map[type] || type;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -3,8 +3,16 @@
|
||||
<template v-if="stockIo && stockIo.stockIoId">
|
||||
<!-- 主表信息 -->
|
||||
<el-descriptions :title="'单号:' + (stockIo.stockIoCode || '-')" :column="2" border>
|
||||
<el-descriptions-item label="类型">{{ stockIo.ioType }}</el-descriptions-item>
|
||||
<el-descriptions-item label="业务类型">{{ stockIo.bizType }}</el-descriptions-item>
|
||||
<el-descriptions-item label="类型">
|
||||
<el-tag :type="getIoTypeTagType(stockIo.ioType)">
|
||||
{{ getIoTypeLabel(stockIo.ioType) }}
|
||||
</el-tag>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="业务类型">
|
||||
<el-tag :type="getBizTypeTagType(stockIo.bizType)">
|
||||
{{ getBizTypeLabel(stockIo.bizType) }}
|
||||
</el-tag>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="状态">
|
||||
<el-tag :type="stockIo.status === 2 ? 'success' : (stockIo.status === 1 ? 'warning' : 'info')">
|
||||
{{ stockIo.status === 2 ? '已完成' : (stockIo.status === 0 ? '草稿' : '待审核') }}
|
||||
@@ -63,12 +71,12 @@
|
||||
<el-table v-loading="loading" :data="stockIoDetailList" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="明细ID" align="center" prop="detailId"/>
|
||||
<el-table-column label="库区/库位ID" align="center" prop="warehouseId" />
|
||||
<el-table-column label="库区/库位" align="center" prop="warehouseName" />
|
||||
<el-table-column
|
||||
v-if="stockIo.ioType === 'transfer'"
|
||||
label="源库区/库位ID"
|
||||
label="源库区/库位"
|
||||
align="center"
|
||||
prop="fromWarehouseId"
|
||||
prop="fromWarehouseName"
|
||||
/>
|
||||
<el-table-column label="物品类型" align="center" prop="itemType" />
|
||||
<el-table-column label="物品ID" align="center" prop="itemId" />
|
||||
@@ -469,6 +477,35 @@ export default {
|
||||
console.error('刷新主表状态失败:', error);
|
||||
});
|
||||
}
|
||||
},
|
||||
getIoTypeTagType(type) {
|
||||
if (type === 'in') return 'success';
|
||||
if (type === 'out') return 'primary';
|
||||
if (type === 'transfer') return 'warning';
|
||||
return '';
|
||||
},
|
||||
getIoTypeLabel(type) {
|
||||
if (type === 'in') return '入库';
|
||||
if (type === 'out') return '出库';
|
||||
if (type === 'transfer') return '移库';
|
||||
return type;
|
||||
},
|
||||
getBizTypeLabel(type) {
|
||||
const map = {
|
||||
purchase: '采购',
|
||||
sales: '销售',
|
||||
return: '退货',
|
||||
relocation: '调拨',
|
||||
other: '其他'
|
||||
};
|
||||
return map[type] || type;
|
||||
},
|
||||
getBizTypeTagType(type) {
|
||||
if (type === 'purchase') return 'success';
|
||||
if (type === 'sales') return 'primary';
|
||||
if (type === 'return') return 'warning';
|
||||
if (type === 'relocation') return 'info';
|
||||
return 'default';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,6 +75,15 @@ public class WmsStockIoDetailVo {
|
||||
@ExcelProperty(value = "备注")
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 库区/库位名称
|
||||
*/
|
||||
private String warehouseName;
|
||||
/**
|
||||
* 源库区/库位名称(移库用)
|
||||
*/
|
||||
private String fromWarehouseName;
|
||||
|
||||
/**
|
||||
* 源库位ID(移库时使用)
|
||||
*/
|
||||
|
||||
@@ -3,13 +3,29 @@ package com.klp.mapper;
|
||||
import com.klp.domain.WmsStockIoDetail;
|
||||
import com.klp.domain.vo.WmsStockIoDetailVo;
|
||||
import com.klp.common.core.mapper.BaseMapperPlus;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
|
||||
/**
|
||||
* 出入库单明细Mapper接口
|
||||
*
|
||||
* VO带有库区/库位名称和源库区/库位名称
|
||||
*
|
||||
* @author Joshi
|
||||
* @date 2025-07-18
|
||||
*/
|
||||
public interface WmsStockIoDetailMapper extends BaseMapperPlus<WmsStockIoDetailMapper, WmsStockIoDetail, WmsStockIoDetailVo> {
|
||||
|
||||
/**
|
||||
* 联查库区/库位名称的明细列表,返回Map
|
||||
*/
|
||||
List<Map<String, Object>> selectDetailWithWarehouseName(@Param("stockIoId") Long stockIoId);
|
||||
|
||||
/**
|
||||
* 分页联查库区/库位名称的明细列表,支持Wrapper动态条件,返回Page<WmsStockIoDetailVo>
|
||||
*/
|
||||
Page<WmsStockIoDetailVo> selectVoPagePlus(Page<?> page, @Param("ew") Wrapper<WmsStockIoDetail> wrapper);
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ public class WmsStockIoDetailServiceImpl implements IWmsStockIoDetailService {
|
||||
@Override
|
||||
public TableDataInfo<WmsStockIoDetailVo> queryPageList(WmsStockIoDetailBo bo, PageQuery pageQuery) {
|
||||
LambdaQueryWrapper<WmsStockIoDetail> lqw = buildQueryWrapper(bo);
|
||||
Page<WmsStockIoDetailVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
||||
Page<WmsStockIoDetailVo> result = baseMapper.selectVoPagePlus(pageQuery.build(), lqw);
|
||||
return TableDataInfo.build(result);
|
||||
}
|
||||
|
||||
@@ -88,13 +88,13 @@ public class WmsStockIoDetailServiceImpl implements IWmsStockIoDetailService {
|
||||
if (stockIo != null && stockIo.getStatus() >= 2) {
|
||||
throw new ServiceException("已审核的单据不能修改明细");
|
||||
}
|
||||
|
||||
|
||||
WmsStockIoDetail add = BeanUtil.toBean(bo, WmsStockIoDetail.class);
|
||||
validEntityBeforeSave(add);
|
||||
boolean flag = baseMapper.insert(add) > 0;
|
||||
if (flag) {
|
||||
bo.setDetailId(add.getDetailId());
|
||||
|
||||
|
||||
// 检查主表状态,如果有明细且状态为草稿,则自动变为待审核
|
||||
if (stockIo != null && stockIo.getStatus() == 0) {
|
||||
// 检查是否有明细
|
||||
@@ -102,7 +102,7 @@ public class WmsStockIoDetailServiceImpl implements IWmsStockIoDetailService {
|
||||
new LambdaQueryWrapper<WmsStockIoDetail>()
|
||||
.eq(WmsStockIoDetail::getStockIoId, bo.getStockIoId())
|
||||
);
|
||||
|
||||
|
||||
if (detailCount > 0) {
|
||||
// 自动更新状态为待审核
|
||||
stockIo.setStatus(1);
|
||||
@@ -124,7 +124,7 @@ public class WmsStockIoDetailServiceImpl implements IWmsStockIoDetailService {
|
||||
if (stockIo != null && stockIo.getStatus() >= 2) {
|
||||
throw new ServiceException("已审核的单据不能修改明细");
|
||||
}
|
||||
|
||||
|
||||
WmsStockIoDetail update = BeanUtil.toBean(bo, WmsStockIoDetail.class);
|
||||
validEntityBeforeSave(update);
|
||||
return baseMapper.updateById(update) > 0;
|
||||
@@ -146,7 +146,7 @@ public class WmsStockIoDetailServiceImpl implements IWmsStockIoDetailService {
|
||||
if(isValid){
|
||||
//TODO 做一些业务上的校验,判断是否需要校验
|
||||
}
|
||||
|
||||
|
||||
// 获取要删除的明细对应的主表ID,检查状态
|
||||
List<WmsStockIoDetail> details = baseMapper.selectBatchIds(ids);
|
||||
if (details != null && !details.isEmpty()) {
|
||||
@@ -160,9 +160,9 @@ public class WmsStockIoDetailServiceImpl implements IWmsStockIoDetailService {
|
||||
// 按主表ID分组
|
||||
Map<Long, List<WmsStockIoDetail>> stockIoIdMap = details.stream()
|
||||
.collect(java.util.stream.Collectors.groupingBy(WmsStockIoDetail::getStockIoId));
|
||||
|
||||
|
||||
boolean flag = baseMapper.deleteBatchIds(ids) > 0;
|
||||
|
||||
|
||||
if (flag) {
|
||||
// 检查每个主表是否还有其他明细
|
||||
for (Long stockIoId : stockIoIdMap.keySet()) {
|
||||
@@ -170,7 +170,7 @@ public class WmsStockIoDetailServiceImpl implements IWmsStockIoDetailService {
|
||||
new LambdaQueryWrapper<WmsStockIoDetail>()
|
||||
.eq(WmsStockIoDetail::getStockIoId, stockIoId)
|
||||
);
|
||||
|
||||
|
||||
// 如果没有明细了,状态回退为草稿
|
||||
if (remainingCount == 0) {
|
||||
WmsStockIo stockIo = stockIoMapper.selectById(stockIoId);
|
||||
@@ -182,10 +182,10 @@ public class WmsStockIoDetailServiceImpl implements IWmsStockIoDetailService {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return flag;
|
||||
}
|
||||
|
||||
|
||||
return baseMapper.deleteBatchIds(ids) > 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,5 +22,59 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="fromWarehouseId" column="from_warehouse_id"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- 联查库区/库位名称的明细列表SQL,直接返回Map -->
|
||||
<select id="selectDetailWithWarehouseName" resultType="map">
|
||||
SELECT
|
||||
d.detail_id,
|
||||
d.stock_io_id,
|
||||
d.warehouse_id,
|
||||
d.item_type,
|
||||
d.item_id,
|
||||
d.quantity,
|
||||
d.unit,
|
||||
d.batch_no,
|
||||
d.remark,
|
||||
d.del_flag,
|
||||
d.create_time,
|
||||
d.create_by,
|
||||
d.update_time,
|
||||
d.update_by,
|
||||
d.from_warehouse_id,
|
||||
w1.warehouse_name AS warehouseName,
|
||||
w2.warehouse_name AS fromWarehouseName
|
||||
FROM wms_stock_io_detail d
|
||||
LEFT JOIN wms_warehouse w1 ON d.warehouse_id = w1.warehouse_id
|
||||
LEFT JOIN wms_warehouse w2 ON d.from_warehouse_id = w2.warehouse_id
|
||||
<where>
|
||||
<if test="stockIoId != null">d.stock_io_id = #{stockIoId}</if>
|
||||
<!-- 其他条件可补充 -->
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<!-- 分页联查库区/库位名称的明细列表SQL,支持Wrapper动态条件,返回Page<WmsStockIoDetailVo> -->
|
||||
<select id="selectVoPagePlus" resultType="com.klp.domain.vo.WmsStockIoDetailVo">
|
||||
SELECT
|
||||
d.detail_id,
|
||||
d.stock_io_id,
|
||||
d.warehouse_id,
|
||||
d.item_type,
|
||||
d.item_id,
|
||||
d.quantity,
|
||||
d.unit,
|
||||
d.batch_no,
|
||||
d.remark,
|
||||
d.del_flag,
|
||||
d.create_time,
|
||||
d.create_by,
|
||||
d.update_time,
|
||||
d.update_by,
|
||||
d.from_warehouse_id,
|
||||
w1.warehouse_name AS warehouseName,
|
||||
w2.warehouse_name AS fromWarehouseName
|
||||
FROM wms_stock_io_detail d
|
||||
LEFT JOIN wms_warehouse w1 ON d.warehouse_id = w1.warehouse_id
|
||||
LEFT JOIN wms_warehouse w2 ON d.from_warehouse_id = w2.warehouse_id
|
||||
${ew.customSqlSegment}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
Reference in New Issue
Block a user