Commit 883b7c52 by chuishuo

盘点功能。——完成。统计及详情功能。——完成。

parent c30de553
...@@ -8,12 +8,32 @@ export function listStocktakes(query) { ...@@ -8,12 +8,32 @@ export function listStocktakes(query) {
params: query params: query
}) })
} }
// 查询统计
export function listStocktakesCount(query) {
return request({
url: '/inventory/stocktakes/listCount',
method: 'get',
params: query
})
}
// 统计详情
export function getCountInfo(query) {
return request({
url: '/inventory/stocktakes/countInfo',
method: 'get',
params: query
})
}
// 查询盘点单主详细 // 查询盘点单主详细
export function getStocktakes(id) { export function getStocktakes(id, operationType) {
return request({ return request({
url: '/inventory/stocktakes/' + id, url: '/inventory/stocktakes/',
method: 'get' method: 'get',
params: {
id: id,
operationType: operationType
}
}) })
} }
......
...@@ -10,22 +10,21 @@ ...@@ -10,22 +10,21 @@
@click="handleAdd" @click="handleAdd"
v-hasPermi="['inventory:stocktakes:add']" v-hasPermi="['inventory:stocktakes:add']"
>新增</el-button> >新增</el-button>
<el-button <!-- <el-button-->
type="danger" <!-- type="danger"-->
plain <!-- plain-->
icon="el-icon-delete" <!-- icon="el-icon-delete"-->
size="medium" <!-- size="medium"-->
:disabled="multiple" <!-- :disabled="multiple"-->
@click="handleDelete" <!-- @click="handleDelete"-->
v-hasPermi="['inventory:stocktakes:remove']" <!-- v-hasPermi="['inventory:stocktakes:remove']"-->
>删除</el-button> <!-- >删除</el-button>-->
<el-button <el-button
type="success" type="success"
plain plain
icon="el-icon-tickets" icon="el-icon-tickets"
size="medium" size="medium"
:disabled="single" @click="handleCount"
@click="handleConfirm"
v-hasPermi="['inventory:stocktakes:count']" v-hasPermi="['inventory:stocktakes:count']"
>处理结果统计</el-button> >处理结果统计</el-button>
</template> </template>
...@@ -80,24 +79,26 @@ ...@@ -80,24 +79,26 @@
<!-- <el-table-column label="排序号" align="center" prop="updateUserCode" />--> <!-- <el-table-column label="排序号" align="center" prop="updateUserCode" />-->
<el-table-column label="操作" align="center" class-name="small-padding fixed-width"> <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope"> <template slot-scope="scope">
<!-- <el-button--> <el-button
<!-- size="mini"--> size="mini"
<!-- type="text"--> type="text"
<!-- icon="el-icon-edit"--> icon="el-icon-view"
<!-- @click="handleUpdate(scope.row)"--> @click="handleViewInfo(scope.row)"
<!-- v-hasPermi="['inventory:stocktakes:edit']"--> v-hasPermi="['inventory:stocktakes:query']"
<!-- >修改</el-button>--> >查看</el-button>
<el-button <el-button
size="mini" size="mini"
type="text" type="text"
icon="el-icon-edit" icon="el-icon-edit"
@click="handleCheck(scope.row)" @click="handleCheck(scope.row)"
v-if="scope.row.stocktakeStatus === '1'"
v-hasPermi="['inventory:stocktakes:check']" v-hasPermi="['inventory:stocktakes:check']"
>盘点</el-button> >盘点</el-button>
<el-button <el-button
size="mini" size="mini"
type="text" type="text"
icon="el-icon-delete" icon="el-icon-delete"
v-if="scope.row.stocktakeStatus === '1'"
@click="handleDelete(scope.row)" @click="handleDelete(scope.row)"
v-hasPermi="['inventory:stocktakes:remove']" v-hasPermi="['inventory:stocktakes:remove']"
>删除</el-button> >删除</el-button>
...@@ -106,6 +107,7 @@ ...@@ -106,6 +107,7 @@
type="text" type="text"
icon="el-icon-circle-check" icon="el-icon-circle-check"
@click="handleConfirm(scope.row)" @click="handleConfirm(scope.row)"
v-if="scope.row.stocktakeStatus === '2'"
v-hasPermi="['inventory:stocktakes:confirm']" v-hasPermi="['inventory:stocktakes:confirm']"
>盘点确认</el-button> >盘点确认</el-button>
</template> </template>
...@@ -199,7 +201,20 @@ ...@@ -199,7 +201,20 @@
/> />
</el-form> </el-form>
<div slot="footer" class="dialog-footer"> <div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitConfirmForm"> </el-button> <el-button type="primary"
v-if="this.buttonShow"
@click="submitConfirmForm"> </el-button>
<el-button @click="cancelConfirm"> </el-button>
</div>
</el-dialog>
<!-- 处理统计弹窗-->
<el-dialog :title="confirmTitle" :visible.sync="countOpen" width="1500px" append-to-body>
<el-form ref="confirmFormRef" :model="form" :rules="rules" label-width="80px">
<!-- 引入子表组件(核心:传递数据+监听事件) -->
<stocktake-count-table/>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="cancelConfirm"> </el-button> <el-button @click="cancelConfirm"> </el-button>
</div> </div>
</el-dialog> </el-dialog>
...@@ -208,14 +223,15 @@ ...@@ -208,14 +223,15 @@
<script> <script>
import { listStocktakes, getStocktakes, delStocktakes, addStocktakes, updateStocktakes } from "@/api/inventory/stocktakes" import { listStocktakes, getStocktakes, delStocktakes, addStocktakes, updateStocktakes } from "@/api/inventory/stocktakes"
// 引入子表组件 // 引入子表组件--盘点
import stocktakeItemsTable from '@/views/inventory/stocktakes/stocktakeItemsTable.vue'; import stocktakeItemsTable from '@/views/inventory/stocktakes/stocktakeItemsTable.vue';
// 引入子表组件--统计
import stocktakeCountTable from '@/views/inventory/stocktakes/stocktakeCountTable.vue';
export default { export default {
name: "Stocktakes", name: "Stocktakes",
dicts: ['stocktake_status'], dicts: ['stocktake_status'],
// 注册子组件 // 注册子组件
components: { stocktakeItemsTable }, components: { stocktakeItemsTable,stocktakeCountTable },
data() { data() {
return { return {
// 遮罩层 // 遮罩层
...@@ -243,10 +259,12 @@ export default { ...@@ -243,10 +259,12 @@ export default {
// 是否显示弹出层 // 是否显示弹出层
open: false, open: false,
checkOpen: false, buttonShow: true,//是否展示确认按钮
confirmOpen: false, checkOpen: false, // 盘点弹窗
confirmOpen: false, // 盘点确认弹窗
checkTitle: "库存盘点", checkTitle: "库存盘点",
confirmTitle: "盘点确认", confirmTitle: "盘点确认",
countOpen: false, // 盘点统计弹窗
// 查询参数 // 查询参数
queryParams: { queryParams: {
...@@ -358,24 +376,44 @@ export default { ...@@ -358,24 +376,44 @@ export default {
handleCheck(row) { handleCheck(row) {
this.reset(); this.reset();
const id = row.id || this.ids const id = row.id || this.ids
getStocktakes(id).then(response => { getStocktakes(id,'check').then(response => {
this.form = response.data this.form = response.data
// 过滤 undefined 行,避免子组件渲染报错 // 过滤 undefined 行,避免子组件渲染报错
this.stocktakeItemsList = (response.data.stocktakeItemsList || []).filter(item => item); this.stocktakeItemsList = (response.data.stocktakeItemsList || []).filter(item => item);
this.checkOpen = true this.checkOpen = true
}) })
}, },
// 盘点确认按钮:打开确认弹窗 // 盘点确认按钮:打开弹窗
handleConfirm(row) { handleConfirm(row) {
this.reset(); this.reset();
const id = row.id || this.ids const id = row.id || this.ids
getStocktakes(id).then(response => { this.confirmTitle = '盘点确认'
getStocktakes(id,'confirm').then(response => {
this.form = response.data
// 过滤 undefined 行,避免子组件渲染报错
this.stocktakeItemsList = (response.data.stocktakeItemsList || []).filter(item => item);
this.confirmOpen = true;
})
},
// 详情按钮:打开弹窗
handleViewInfo(row) {
this.reset();
const id = row.id || this.ids
this.buttonShow = false
this.confirmTitle = '盘点查看'
getStocktakes(id,'check').then(response => {
this.form = response.data this.form = response.data
// 过滤 undefined 行,避免子组件渲染报错 // 过滤 undefined 行,避免子组件渲染报错
this.stocktakeItemsList = (response.data.stocktakeItemsList || []).filter(item => item); this.stocktakeItemsList = (response.data.stocktakeItemsList || []).filter(item => item);
this.confirmOpen = true; this.confirmOpen = true;
}) })
}, },
/** 处理结果统计按钮操作 */
handleCount() {
this.reset()
this.countOpen = true
this.confirmTitle = " 处理结果统计"
},
/** 子组件字段编辑事件(确保父组件数据同步) */ /** 子组件字段编辑事件(确保父组件数据同步) */
handleStocktakeItemChange(updatedRow) { handleStocktakeItemChange(updatedRow) {
// 找到更新的行,替换数据(确保引用一致) // 找到更新的行,替换数据(确保引用一致)
...@@ -441,7 +479,7 @@ export default { ...@@ -441,7 +479,7 @@ export default {
// 取消操作 // 取消操作
cancelCheck() { this.checkOpen = false; this.reset(); }, cancelCheck() { this.checkOpen = false; this.reset(); },
cancelConfirm() { this.confirmOpen = false; this.reset(); }, cancelConfirm() { this.confirmOpen = false; this.countOpen = false; this.reset(); },
/** 新增提交按钮 */ /** 新增提交按钮 */
submitForm() { submitForm() {
......
<template>
<div class="app-container" >
<!-- 子表搜索栏(按需求添加搜索字段) -->
<div class="page-container">
<page-wrapper-search
:model="queryParams"
ref="queryForm"
size="small"
@search="handleQuery"
@reset="resetQuery"
>
<el-form-item label="计划日期">
<el-date-picker v-model="dateRange" style="width: 240px" value-format="yyyy-MM-dd" type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期"></el-date-picker>
</el-form-item>
<el-form-item label="物料" prop="materialId">
<common-dict-select
v-model="queryParams.materialId"
dict-url="/inventory/materials/getMapList"
value-key="sap_no"
label-key="material_name"
placeholder="请选择物料"
@change="handleQuery"
@loaded="handleDictLoaded('material', $event)"
@input="queryParams.materialId = $event"
/>
</el-form-item>
<el-form-item label="仓库" prop="warehouseId">
<el-input
v-model="queryWarehouseName"
placeholder="请选择仓库"
readonly
@focus="openWarehouseSelector"
:suffix-icon="''"
>
<template v-if="queryWarehouseName" #suffix>
<i
class="el-icon-circle-close el-input__icon"
style="cursor: pointer;"
@click.stop="clearQueryWarehouse"
></i>
</template>
</el-input>
</el-form-item>
<el-form-item label="库位" prop="locationId">
<el-input
v-model="queryLocationName"
placeholder="请选择库位"
readonly
@focus="openLocationSelector"
:suffix-icon="''"
:disabled="!queryParams.warehousesCode"
>
<template v-if="queryLocationName" #suffix>
<i
class="el-icon-circle-close el-input__icon"
style="cursor: pointer;"
@click.stop="clearQueryLocation"
></i>
</template>
</el-input>
</el-form-item>
</page-wrapper-search>
<div class="table-container">
<el-table v-loading="loading" :data="stocktakesList" @selection-change="handleSelectionChange">
<el-table-column label="计划日期" align="center" prop="plannedDates" width="180" fixed/>
<el-table-column label="物料" prop="materialId" >
<template slot-scope="scope">
{{ getDictLabel(materialDict, scope.row.materialId, 'sap_no', 'material_name') }}
</template>
</el-table-column>
<el-table-column label="SAP物料号" align="center" prop="sapNo" />
<el-table-column label="TS Code" align="center" prop="tsCode" />
<el-table-column label="危险类别" align="center" prop="hazardName" />
<!-- <el-table-column label="批次编号" prop="batchCode">-->
<!-- <template slot-scope="scope">-->
<!-- <el-input v-model="scope.row.batchCode" placeholder="请输入批次编号" disabled />-->
<!-- </template>-->
<!-- </el-table-column>-->
<el-table-column label="仓库Id" align="center" prop="warehousesId" v-if="false" />
<el-table-column label="库位Id" align="center" prop="locationId" v-if="false" />
<el-table-column label="仓库" align="center" prop="warehousesName" />
<el-table-column label="库位" align="center" prop="locationName" />
<el-table-column label="差异总数" align="center" prop="countQuantity" />
<!-- <template slot-scope="scope">-->
<!-- <el-input type="number" v-model="scope.row.varianceQuantity" placeholder="请输入差异数量" disabled />-->
<!-- </template>-->
<!-- </el-table-column>-->
<!-- <el-table-column label="单价" prop="unitPrice">-->
<!-- <template slot-scope="scope">-->
<!-- <el-input v-model="scope.row.unitPrice" placeholder="请输入单价" disabled />-->
<!-- </template>-->
<!-- </el-table-column>-->
<el-table-column label="差异总金额" prop="unitPrice">
<template slot-scope="scope">
{{ formatAmount(scope.row.countAmount) }}
</template>
<!-- <template slot-scope="scope">-->
<!-- <el-input v-model="scope.row.varianceAmount" placeholder="请输入差异金额" disabled />-->
<!-- </template>-->
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-view"
@click="handleCountViewInfo(scope.row)"
>查看</el-button>
</template>
</el-table-column>
</el-table>
</div>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<!-- 仓库选择组件 -->
<WarehouseSelector
v-model="warehouseSelectorVisible"
@selected="handleWarehouseSelected"
/>
<!-- 库位选择组件 -->
<LocationSelector
v-model="locationSelectorVisible"
:warehousesId="currentWarehouseId"
@selected="handleLocationSelected"
/>
</div>
<!-- 详情查看 -->
<el-dialog title="统计详情查看" :visible.sync="viewOpen" width="800px" append-to-body>
<el-table :data="detailList" border stripe size="small" style="width: 100%;">
<el-table-column label="计划日期" prop="plannedDates" />
<el-table-column label="物料" prop="materialId">
<template slot-scope="scope">
{{ getDictLabel(materialDict, scope.row.materialId, 'sap_no', 'material_name') || '无' }}
</template>
</el-table-column>
<el-table-column label="SAP物料号" prop="sapNo" />
<el-table-column label="仓库" prop="warehousesName" />
<el-table-column label="库位" prop="locationName" />
<el-table-column label="危险类别" prop="hazardName" />
<el-table-column label="差异数量" prop="varianceQuantity" />
<el-table-column label="差异金额" prop="varianceAmount">
<template slot-scope="scope">
{{ formatAmount(scope.row.varianceAmount) }}
</template>
</el-table-column>
</el-table>
<div slot="footer" class="dialog-footer">
<el-button @click="cancel">关 闭</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { listStocktakesCount,getCountInfo } from "@/api/inventory/stocktakes"
import { getDictLabel } from '@/utils/dictUtil'
import CommonDictSelect from '@/components/CommonDictSelect.vue'
import WarehouseSelector from "@/views/compononents/WarehouseSelector.vue"
import LocationSelector from "@/views/compononents/LocationSelector.vue"
export default {
name: "stocktakeCountTable",
components: { CommonDictSelect,WarehouseSelector,LocationSelector }, // 注册通用字典组件
props: {
// 接收父组件传递的子表原始数据(双向绑定)
itemsList: {
type: Array,
default: () => []
},
isConfirm: { // true=盘点确认(全部只读+显示所有字段),false=盘点(部分可编辑+隐藏部分字段)
type: Boolean,
default: false
}
},
data() {
return {
// 遮罩层
loading: true,
viewOpen:false,
queryParams: {
pageNum: 1,
pageSize: 10,
warehouseId: null,
stocktakeStatus: null,
plannedDates: null,
materialId: "",
locationId: ""
},
// 详情列表信息
detailList: [],
// 库存盘点表格数据
stocktakesList: [],
// 日期范围
dateRange: [],
// 仓库选择相关
warehouseSelectorVisible: false,
queryWarehouseName: null,
// 库位选择相关
locationSelectorVisible: false,
queryLocationName: null,
currentWarehouseId: "", // 存仓库原始ID(0eb22b11...),供库位联动
checkedRows: [], // 子表选中的行
materialDict: [], // 物料字典数组(存储sap_no和name)
warehouseDict: [], // 仓库数组
locationDict: [], // 库位数组
// 分页总数
total: 0,
// 表格加载状态
tableLoading: false
}
},
created() {
this.getList()
},
methods: {
// 挂载全局字典工具方法(模板中可直接调用)
getDictLabel,
/** 打开仓库选择器 */
openWarehouseSelector() {
this.warehouseSelectorVisible = true
},
// 取消按钮
cancel() {
this.viewOpen = false
this.detailList = []
},
// 详情按钮:打开弹窗
handleCountViewInfo(row) {
this.detailList = []; // 清空旧数据
// 接口请求添加try/catch和空值判断
getCountInfo(row).then(response => {
console.log('接口返回完整数据:', response); // 打印1
console.log('接口返回的rows数组:', response.rows); // 打印2
if (response && response.rows) {
this.detailList = response.rows; // 直接赋值数组给detailList
console.log('赋值后的detailList:', this.detailList); // 打印3
} else {
this.$message.warning('暂无详情数据');
}
this.viewOpen = true;
}).catch(error => {
console.error('获取详情失败:', error);
this.$message.error('获取详情失败,请重试');
this.viewOpen = false;
})
},
// 仓库清空时触发
handleWarehouseClear() {
this.queryParams.locationId = ''
this.queryParams.warehouseId = ''
this.currentWarehouseId = ''
this.handleQuery()
},
/** 库位选择回调 */
handleLocationSelected(location) {
if (!location) return
this.queryParams.locationId = location.locationCode
this.queryLocationName = location.locationName || location.locationCode
// console.log('selected LocationName', location);
this.handleQuery()
},
/** 仓库选择回调 */
handleWarehouseSelected(warehouse) {
if (!warehouse) return
// 供库位联动:存仓库原始ID(0eb22b11...)
this.currentWarehouseId = warehouse.warehouseId
// 供列表筛选:存仓库编码333(匹配列表里的warehouseId:333
this.queryParams.warehouseId = warehouse.warehousesCode
this.queryParams.warehousesCode = warehouse.warehousesCode
this.queryWarehouseName = warehouse.warehousesName || warehouse.warehousesCode
// 仓库选择后,清空库位信息
this.queryLocationName = null
this.queryParams.locationId = null
this.handleQuery()
// console.log('selected warehouse', warehouse);
},
/** 格式化金额,保留2位小数 */
formatAmount(amount) {
if (amount === null || amount === undefined || isNaN(amount)) {
return '0.00'
}
return parseFloat(amount).toFixed(2)
},
// 搜索,补全逻辑(无后端请求,仅重置页码)
handleQuery() {
this.queryParams.pageNum = 1 // 搜索后重置页码
this.$nextTick(() => {
this.getList();
});
},
/** 清空仓库选择 */
clearQueryWarehouse() {
this.queryWarehouseName = null
this.queryParams.warehouseId = null
this.queryParams.warehousesCode = null
this.currentWarehouseId = ""
// 清空仓库时,同时清空库位
this.queryLocationName = null
this.queryParams.locationId = null
this.handleQuery()
},
/** 打开库位选择器 */
openLocationSelector() {
// console.log('this.currentWarehouseId========',this.currentWarehouseId)
if (!this.currentWarehouseId) {
this.$message.warning("请先选择仓库")
return
}
this.locationSelectorVisible = true
},
/** 清空库位选择 */
clearQueryLocation() {
this.queryLocationName = null
this.queryParams.locationId = null
this.handleQuery()
},
// 重置
resetQuery() {
this.queryWarehouseName = null
this.queryLocationName = null
this.currentWarehouseId = ''
this.dateRange = []
this.queryParams = {
pageNum: 1,
pageSize: 10,
materialId: "",
batchCode: "",
warehouseId: "",
locationId: ""
};
// 重置库位选择器
this.handleWarehouseClear()
},
// 关联查询列表
getList() {
this.loading = true
listStocktakesCount(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
this.stocktakesList = response.rows
this.total = response.total
this.loading = false
})
},
// 字典加载完成回调(缓存字典数据,供表格展示使用)
handleDictLoaded(type, data) {
switch (type) {
case 'material':
this.materialDict = data
break
case 'warehouse':
this.warehouseDict = data
break
case 'location':
this.locationDict = data
break
}
},
// 给子表设置序号
setRowIndex({row, rowIndex}) {
row.index = rowIndex + 1;
},
// 选中行变化
handleSelectionChange(selection) {
this.checkedRows = selection;
}
}
}
</script>
<style scoped>
.app-container {
padding: 16px;
}
.page-container {
background: #fff;
padding: 16px;
border-radius: 4px;
}
.table-container {
margin-top: 16px;
}
.mb8 {
margin-bottom: 8px;
}
/* 表格样式优化 */
:deep(.el-table) {
--el-table-header-text-color: #606266;
--el-table-row-hover-bg-color: #f5f7fa;
}
.disabled-input {
background-color: #f5f7fa !important; /* ElementUI disabled 背景色 */
border: 1px solid #e5e6eb !important; /* ElementUI disabled 边框色 */
color: #909399 !important; /* ElementUI disabled 文字色 */
cursor: not-allowed !important;
border-radius: 4px !important; /* 和输入框圆角一致 */
}
</style>
...@@ -21,18 +21,52 @@ ...@@ -21,18 +21,52 @@
/> />
</el-form-item> </el-form-item>
<el-form-item label="仓库" prop="warehouseId"> <el-form-item label="仓库" prop="warehouseId">
<el-input
v-model="queryWarehouseName"
placeholder="请选择仓库"
readonly
@focus="openWarehouseSelector"
:suffix-icon="''"
>
<template v-if="queryWarehouseName" #suffix>
<i
class="el-icon-circle-close el-input__icon"
style="cursor: pointer;"
@click.stop="clearQueryWarehouse"
></i>
</template>
</el-input>
</el-form-item>
<el-form-item label="库位" prop="locationId">
<el-input
v-model="queryLocationName"
placeholder="请选择库位"
readonly
@focus="openLocationSelector"
:suffix-icon="''"
:disabled="!searchParams.warehousesCode"
>
<template v-if="queryLocationName" #suffix>
<i
class="el-icon-circle-close el-input__icon"
style="cursor: pointer;"
@click.stop="clearQueryLocation"
></i>
</template>
</el-input>
</el-form-item>
<el-form-item label="仓库" prop="warehouseId" style="display: none;">
<common-dict-select <common-dict-select
v-model="searchParams.warehouseId" v-model="searchParams.warehouseId"
dict-url="/inventory/warehouses/getMapList" dict-url="/inventory/warehouses/getMapList"
value-key="warehouses_code" value-key="warehouses_code"
label-key="warehouses_name" label-key="warehouses_name"
placeholder="请选择仓库" placeholder="请选择仓库"
@change="handleWarehouseChange"
@clear="handleWarehouseClear"
@loaded="handleDictLoaded('warehouse', $event)" @loaded="handleDictLoaded('warehouse', $event)"
/> />
</el-form-item> </el-form-item>
<el-form-item label="库位" prop="locationId"> <el-form-item label="库位" prop="locationId" style="display: none;">
<common-dict-select <common-dict-select
ref="locationSelect" ref="locationSelect"
v-model="searchParams.locationId" v-model="searchParams.locationId"
...@@ -41,13 +75,23 @@ ...@@ -41,13 +75,23 @@
value-key="location_code" value-key="location_code"
label-key="location_name" label-key="location_name"
placeholder="请选择库位" placeholder="请选择库位"
:disabled="!searchParams.warehouseId"
@change="handleQuery"
@loaded="handleDictLoaded('location', $event)" @loaded="handleDictLoaded('location', $event)"
/> />
</el-form-item> </el-form-item>
</page-wrapper-search> </page-wrapper-search>
<!-- 仓库选择组件 -->
<WarehouseSelector
v-model="warehouseSelectorVisible"
@selected="handleWarehouseSelected"
/>
<!-- 库位选择组件 -->
<LocationSelector
v-model="locationSelectorVisible"
:warehousesId="currentWarehouseId"
@selected="handleLocationSelected"
/>
<div class="table-container"> <div class="table-container">
<el-table :data="filteredItemsList" <el-table :data="filteredItemsList"
:row-class-name="setRowIndex" :row-class-name="setRowIndex"
...@@ -103,6 +147,22 @@ ...@@ -103,6 +147,22 @@
<el-input type="number" v-model="scope.row.varianceQuantity" placeholder="请输入差异数量" disabled /> <el-input type="number" v-model="scope.row.varianceQuantity" placeholder="请输入差异数量" disabled />
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="单价" prop="unitPrice">
<template slot-scope="scope">
<!-- <el-input v-model="scope.row.unitPrice" placeholder="请输入单价" disabled />-->
<div class="el-input__inner disabled-input" style="padding: 0 15px; height: 32px; line-height: 32px;">
{{ formatAmount(scope.row.unitPrice) }}
</div>
</template>
</el-table-column>
<el-table-column label="差异金额" prop="varianceQuantity">
<template slot-scope="scope">
<!-- <el-input v-model="scope.row.varianceAmount" placeholder="请输入差异金额" disabled />-->
<div class="el-input__inner disabled-input" style="padding: 0 15px; height: 32px; line-height: 32px;">
{{ formatAmount(scope.row.varianceQuantity) }}
</div>
</template>
</el-table-column>
<el-table-column label="是否已调整" prop="adjusted" v-if="isConfirm"> <el-table-column label="是否已调整" prop="adjusted" v-if="isConfirm">
<template slot-scope="scope"> <template slot-scope="scope">
<el-input v-model="scope.row.adjusted" placeholder="请输入是否已调整0否1是" disabled /> <el-input v-model="scope.row.adjusted" placeholder="请输入是否已调整0否1是" disabled />
...@@ -146,9 +206,12 @@ ...@@ -146,9 +206,12 @@
<script> <script>
import { getDictLabel } from '@/utils/dictUtil' import { getDictLabel } from '@/utils/dictUtil'
import CommonDictSelect from '@/components/CommonDictSelect.vue' import CommonDictSelect from '@/components/CommonDictSelect.vue'
import WarehouseSelector from "@/views/compononents/WarehouseSelector.vue"
import LocationSelector from "@/views/compononents/LocationSelector.vue"
export default { export default {
name: "stocktakeItemsTable", name: "stocktakeItemsTable",
components: { CommonDictSelect }, // 注册通用字典组件 components: { CommonDictSelect,WarehouseSelector,LocationSelector }, // 注册通用字典组件
props: { props: {
// 接收父组件传递的子表原始数据(双向绑定) // 接收父组件传递的子表原始数据(双向绑定)
itemsList: { itemsList: {
...@@ -168,8 +231,16 @@ export default { ...@@ -168,8 +231,16 @@ export default {
materialId: "", materialId: "",
batchCode: "", batchCode: "",
warehouseId: "", warehouseId: "",
warehousesCode: null,
locationId: "" locationId: ""
}, },
// 仓库选择相关
warehouseSelectorVisible: false,
queryWarehouseName: null,
// 库位选择相关
locationSelectorVisible: false,
queryLocationName: null,
currentWarehouseId: "", // 存仓库原始ID(0eb22b11...),供库位联动
checkedRows: [], // 子表选中的行 checkedRows: [], // 子表选中的行
materialDict: [], // 物料字典数组(存储sap_no和name) materialDict: [], // 物料字典数组(存储sap_no和name)
warehouseDict: [], // 仓库数组 warehouseDict: [], // 仓库数组
...@@ -180,6 +251,7 @@ export default { ...@@ -180,6 +251,7 @@ export default {
tableLoading: false tableLoading: false
} }
}, },
computed: { computed: {
// 筛选+分页后的表格数据 // 筛选+分页后的表格数据
filteredItemsList() { filteredItemsList() {
...@@ -228,18 +300,82 @@ export default { ...@@ -228,18 +300,82 @@ export default {
this.searchParams.warehouseId = warehouseId this.searchParams.warehouseId = warehouseId
this.handleQuery() this.handleQuery()
}, },
/** 打开仓库选择器 */
openWarehouseSelector() {
this.warehouseSelectorVisible = true
},
// 仓库清空时触发 // 仓库清空时触发
handleWarehouseClear() { handleWarehouseClear() {
this.searchParams.locationId = '' this.searchParams.locationId = ''
this.searchParams.warehouseId = '' this.searchParams.warehouseId = ''
this.currentWarehouseId = ''
this.handleQuery()
},
/** 库位选择回调 */
handleLocationSelected(location) {
if (!location) return
this.searchParams.locationId = location.locationCode
this.queryLocationName = location.locationName || location.locationCode
// console.log('selected LocationName', location);
this.handleQuery() this.handleQuery()
}, },
/** 仓库选择回调 */
handleWarehouseSelected(warehouse) {
if (!warehouse) return
// 供库位联动:存仓库原始ID(0eb22b11...)
this.currentWarehouseId = warehouse.warehouseId
// 供列表筛选:存仓库编码333(匹配列表里的warehouseId:333
this.searchParams.warehouseId = warehouse.warehousesCode
this.searchParams.warehousesCode = warehouse.warehousesCode
this.queryWarehouseName = warehouse.warehousesName || warehouse.warehousesCode
// 仓库选择后,清空库位信息
this.queryLocationName = null
this.searchParams.locationId = null
this.handleQuery()
// console.log('selected warehouse', warehouse);
},
/** 格式化金额,保留2位小数 */
formatAmount(amount) {
if (amount === null || amount === undefined || isNaN(amount)) {
return '0.00'
}
return parseFloat(amount).toFixed(2)
},
// 搜索,补全逻辑(无后端请求,仅重置页码) // 搜索,补全逻辑(无后端请求,仅重置页码)
handleQuery() { handleQuery() {
this.searchParams.pageNum = 1; // 搜索后重置页码 this.searchParams.pageNum = 1; // 搜索后重置页码
}, },
/** 清空仓库选择 */
clearQueryWarehouse() {
this.queryWarehouseName = null
this.searchParams.warehouseId = null
this.searchParams.warehousesCode = null
this.currentWarehouseId = ""
// 清空仓库时,同时清空库位
this.queryLocationName = null
this.searchParams.locationId = null
this.handleQuery()
},
/** 打开库位选择器 */
openLocationSelector() {
// console.log('this.currentWarehouseId========',this.currentWarehouseId)
if (!this.currentWarehouseId) {
this.$message.warning("请先选择仓库")
return
}
this.locationSelectorVisible = true
},
/** 清空库位选择 */
clearQueryLocation() {
this.queryLocationName = null
this.searchParams.locationId = null
this.handleQuery()
},
// 重置 // 重置
resetQuery() { resetQuery() {
this.queryWarehouseName = null
this.queryLocationName = null
this.currentWarehouseId = ''
this.searchParams = { this.searchParams = {
pageNum: 1, pageNum: 1,
pageSize: 10, pageSize: 10,
...@@ -317,6 +453,8 @@ export default { ...@@ -317,6 +453,8 @@ export default {
const systemQty = Number(row.systemQuantity) || 0 const systemQty = Number(row.systemQuantity) || 0
// 计算差异:实际数量 - 系统数量 // 计算差异:实际数量 - 系统数量
row.varianceQuantity = actualQty - systemQty row.varianceQuantity = actualQty - systemQty
// 计算差异金额:差异数量*单价
row.varianceAmount = row.varianceQuantity * row.unitPrice
} }
// 实时校验调整原因,触发样式更新 // 实时校验调整原因,触发样式更新
this.$nextTick(() => { this.$nextTick(() => {
......
...@@ -4,16 +4,10 @@ import java.util.List; ...@@ -4,16 +4,10 @@ import java.util.List;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import com.ruoyi.inventory.domain.TO.StocktakesTO; import com.ruoyi.inventory.domain.TO.StocktakesTO;
import com.ruoyi.inventory.domain.TO.StocktakesVo;
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.*;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log; import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.AjaxResult;
...@@ -65,10 +59,11 @@ public class StocktakesController extends BaseController ...@@ -65,10 +59,11 @@ public class StocktakesController extends BaseController
* 获取库存盘点详细信息 * 获取库存盘点详细信息
*/ */
@PreAuthorize("@ss.hasPermi('inventory:stocktakes:query')") @PreAuthorize("@ss.hasPermi('inventory:stocktakes:query')")
@GetMapping(value = "/{id}") @GetMapping(value = "/")
public AjaxResult getInfo(@PathVariable("id") String id) public AjaxResult getInfo(@RequestParam("id") String id,
@RequestParam(required = false) String operationType)
{ {
return success(stocktakesService.selectStocktakesById(id)); return success(stocktakesService.selectStocktakesById(id,operationType));
} }
/** /**
...@@ -103,4 +98,31 @@ public class StocktakesController extends BaseController ...@@ -103,4 +98,31 @@ public class StocktakesController extends BaseController
{ {
return toAjax(stocktakesService.deleteStocktakesByIds(ids)); return toAjax(stocktakesService.deleteStocktakesByIds(ids));
} }
/**
* @description: 查询处理统计
* @author cs
* @date 2025/12/8
* @version 1.0
*/
@GetMapping("/listCount")
public TableDataInfo listCount(StocktakesVo stocktakes)
{
startPage();
List<StocktakesVo> list = stocktakesService.selectStocktakesListCount(stocktakes);
return getDataTable(list);
}
/**
* @description: 查询处理统计-详情
* @author cs
* @date 2025/12/9
* @version 1.0
*/
@GetMapping("/countInfo")
public TableDataInfo countInfo(StocktakesVo stocktakes)
{
startPage();
List<StocktakesVo> list = stocktakesService.selectStocktakesCountInfo(stocktakes);
return getDataTable(list);
}
} }
...@@ -124,6 +124,18 @@ public class StocktakeItems extends BaseEntity ...@@ -124,6 +124,18 @@ public class StocktakeItems extends BaseEntity
@Excel(name = "排序号") @Excel(name = "排序号")
private String updateUserCode; private String updateUserCode;
/** 单价 */
@Excel(name = "单价")
private double unitPrice;
public double getUnitPrice() {
return unitPrice;
}
public void setUnitPrice(double unitPrice) {
this.unitPrice = unitPrice;
}
public String getInventoryId() { public String getInventoryId() {
return inventoryId; return inventoryId;
} }
......
package com.ruoyi.inventory.domain.TO;
import com.ruoyi.inventory.domain.Stocktakes;
import java.util.Date;
/**
* 库存盘点对象 stocktakes
*
* @author ruoyi
* @date 2025-12-02
*/
public class StocktakesVo extends Stocktakes
{
/** 提交按钮类型,check是盘点,confirm 是确认盘点 */
private String sapNo;
private String plannedDates;
private String materialId;
private String warehousesName;
private String locationName;
private String warehousesId;
private String locationId;
private String tsCode;
private String hazardName;
private String varianceQuantity;
private String varianceAmount;
private String countQuantity;
private String countAmount;
// 计划日期数组(接收拆分后的值)
private String[] plannedDateArray;
// 仓库ID数组
private String[] warehouseIdArray;
// 库位ID数组
private String[] locationIdArray;
public String[] getPlannedDateArray() {
return plannedDateArray;
}
public void setPlannedDateArray(String[] plannedDateArray) {
this.plannedDateArray = plannedDateArray;
}
public String[] getWarehouseIdArray() {
return warehouseIdArray;
}
public void setWarehouseIdArray(String[] warehouseIdArray) {
this.warehouseIdArray = warehouseIdArray;
}
public String[] getLocationIdArray() {
return locationIdArray;
}
public void setLocationIdArray(String[] locationIdArray) {
this.locationIdArray = locationIdArray;
}
public String getMaterialId() {
return materialId;
}
public String getPlannedDates() {
return plannedDates;
}
public void setPlannedDates(String plannedDates) {
this.plannedDates = plannedDates;
}
public String getLocationId() {
return locationId;
}
public void setLocationId(String locationId) {
this.locationId = locationId;
}
public void setMaterialId(String materialId) {
this.materialId = materialId;
}
public String getSapNo() {
return sapNo;
}
public void setSapNo(String sapNo) {
this.sapNo = sapNo;
}
public String getWarehousesName() {
return warehousesName;
}
public void setWarehousesName(String warehousesName) {
this.warehousesName = warehousesName;
}
public String getLocationName() {
return locationName;
}
public void setLocationName(String locationName) {
this.locationName = locationName;
}
public String getWarehousesId() {
return warehousesId;
}
public void setWarehousesId(String warehousesId) {
this.warehousesId = warehousesId;
}
public String getTsCode() {
return tsCode;
}
public void setTsCode(String tsCode) {
this.tsCode = tsCode;
}
public String getHazardName() {
return hazardName;
}
public void setHazardName(String hazardName) {
this.hazardName = hazardName;
}
public String getVarianceQuantity() {
return varianceQuantity;
}
public void setVarianceQuantity(String varianceQuantity) {
this.varianceQuantity = varianceQuantity;
}
public String getVarianceAmount() {
return varianceAmount;
}
public void setVarianceAmount(String varianceAmount) {
this.varianceAmount = varianceAmount;
}
public String getCountQuantity() {
return countQuantity;
}
public void setCountQuantity(String countQuantity) {
this.countQuantity = countQuantity;
}
public String getCountAmount() {
return countAmount;
}
public void setCountAmount(String countAmount) {
this.countAmount = countAmount;
}
}
package com.ruoyi.inventory.mapper; package com.ruoyi.inventory.mapper;
import java.util.List; import java.util.List;
import java.util.Map;
import com.ruoyi.inventory.domain.StocktakeItems; import com.ruoyi.inventory.domain.StocktakeItems;
import com.ruoyi.inventory.domain.TO.StocktakesVo;
/** /**
* 盘点单明细Mapper接口 * 盘点单明细Mapper接口
...@@ -58,4 +61,10 @@ public interface StocktakeItemsMapper ...@@ -58,4 +61,10 @@ public interface StocktakeItemsMapper
* @return 结果 * @return 结果
*/ */
public int deleteStocktakeItemsByIds(String[] ids); public int deleteStocktakeItemsByIds(String[] ids);
// 主表调用获取子表信息
public List<StocktakeItems> selectStocktakeItemsByMain(Map<String, Object> query);
// 查询处理统计-详情
public List<StocktakesVo> selectStocktakesCountInfo(StocktakesVo stocktakes);
} }
package com.ruoyi.inventory.mapper; package com.ruoyi.inventory.mapper;
import java.util.List; import java.util.List;
import java.util.Map;
import com.ruoyi.inventory.domain.Stocktakes; import com.ruoyi.inventory.domain.Stocktakes;
import com.ruoyi.inventory.domain.StocktakeItems; import com.ruoyi.inventory.domain.StocktakeItems;
import com.ruoyi.inventory.domain.TO.StocktakesVo;
/** /**
* 盘点单主Mapper接口 * 盘点单主Mapper接口
...@@ -15,7 +18,6 @@ public interface StocktakesMapper ...@@ -15,7 +18,6 @@ public interface StocktakesMapper
/** /**
* 查询盘点单主 * 查询盘点单主
* *
* @param id 盘点单主主键
* @return 盘点单主 * @return 盘点单主
*/ */
public Stocktakes selectStocktakesById(String id); public Stocktakes selectStocktakesById(String id);
...@@ -84,4 +86,12 @@ public interface StocktakesMapper ...@@ -84,4 +86,12 @@ public interface StocktakesMapper
* @return 结果 * @return 结果
*/ */
public int deleteStocktakeItemsByStocktakeId(String id); public int deleteStocktakeItemsByStocktakeId(String id);
/**
* @description: 查询处理统计
* @author cs
* @date 2025/12/8
* @version 1.0
*/
public List<StocktakesVo> selectStocktakesListCount(StocktakesVo stocktakes);
} }
package com.ruoyi.inventory.service; package com.ruoyi.inventory.service;
import java.util.List; import java.util.List;
import java.util.Map;
import com.ruoyi.inventory.domain.StocktakeItems; import com.ruoyi.inventory.domain.StocktakeItems;
import com.ruoyi.inventory.domain.TO.StocktakesVo;
/** /**
* 盘点单明细Service接口 * 盘点单明细Service接口
...@@ -19,6 +22,9 @@ public interface IStocktakeItemsService ...@@ -19,6 +22,9 @@ public interface IStocktakeItemsService
*/ */
public StocktakeItems selectStocktakeItemsById(String id); public StocktakeItems selectStocktakeItemsById(String id);
// 主表调用
public List<StocktakeItems> selectStocktakeItemsByMain(Map<String,Object> query);
/** /**
* 查询盘点单明细列表 * 查询盘点单明细列表
* *
...@@ -58,4 +64,7 @@ public interface IStocktakeItemsService ...@@ -58,4 +64,7 @@ public interface IStocktakeItemsService
* @return 结果 * @return 结果
*/ */
public int deleteStocktakeItemsById(String id); public int deleteStocktakeItemsById(String id);
// 查询处理统计-详情
public List<StocktakesVo> selectStocktakesCountInfo(StocktakesVo stocktakes);
} }
package com.ruoyi.inventory.service; package com.ruoyi.inventory.service;
import java.util.List; import java.util.List;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.inventory.domain.Stocktakes; import com.ruoyi.inventory.domain.Stocktakes;
import com.ruoyi.inventory.domain.TO.StocktakesTO; import com.ruoyi.inventory.domain.TO.StocktakesTO;
import com.ruoyi.inventory.domain.TO.StocktakesVo;
import org.springframework.web.bind.annotation.GetMapping;
/** /**
* 库存盘点Service接口 * 库存盘点Service接口
...@@ -15,10 +19,9 @@ public interface IStocktakesService ...@@ -15,10 +19,9 @@ public interface IStocktakesService
/** /**
* 查询库存盘点 * 查询库存盘点
* *
* @param id 库存盘点主键
* @return 库存盘点 * @return 库存盘点
*/ */
public Stocktakes selectStocktakesById(String id); public Stocktakes selectStocktakesById(String id,String operationType);
/** /**
* 查询库存盘点列表 * 查询库存盘点列表
...@@ -59,4 +62,22 @@ public interface IStocktakesService ...@@ -59,4 +62,22 @@ public interface IStocktakesService
* @return 结果 * @return 结果
*/ */
public int deleteStocktakesById(String id); public int deleteStocktakesById(String id);
/**
* @description: 查询处理统计
* @author cs
* @date 2025/12/8
* @version 1.0
*/
public List<StocktakesVo> selectStocktakesListCount(StocktakesVo stocktakes);
/**
* @description: 查询处理统计-详情
* @author cs
* @date 2025/12/9
* @version 1.0
*/
public List<StocktakesVo> selectStocktakesCountInfo(StocktakesVo stocktakes);
} }
package com.ruoyi.inventory.service.impl; package com.ruoyi.inventory.service.impl;
import java.util.List; import java.util.List;
import java.util.Map;
import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.inventory.domain.TO.StocktakesVo;
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.StocktakeItemsMapper; import com.ruoyi.inventory.mapper.StocktakeItemsMapper;
...@@ -33,6 +36,15 @@ public class StocktakeItemsServiceImpl implements IStocktakeItemsService ...@@ -33,6 +36,15 @@ public class StocktakeItemsServiceImpl implements IStocktakeItemsService
} }
/** /**
* @description: 主表调用获取子表信息
* @author cs
* @date 2025/12/5
* @version 1.0
*/
public List<StocktakeItems> selectStocktakeItemsByMain(Map<String,Object> query){
return stocktakeItemsMapper.selectStocktakeItemsByMain(query);
}
/**
* 查询盘点单明细列表 * 查询盘点单明细列表
* *
* @param stocktakeItems 盘点单明细 * @param stocktakeItems 盘点单明细
...@@ -93,4 +105,24 @@ public class StocktakeItemsServiceImpl implements IStocktakeItemsService ...@@ -93,4 +105,24 @@ public class StocktakeItemsServiceImpl implements IStocktakeItemsService
{ {
return stocktakeItemsMapper.deleteStocktakeItemsById(id); return stocktakeItemsMapper.deleteStocktakeItemsById(id);
} }
// 查询处理统计-详情
@Override
public List<StocktakesVo> selectStocktakesCountInfo(StocktakesVo stocktakes){
String plannedDates = stocktakes.getPlannedDates();
String warehousesId = stocktakes.getWarehousesId();
String locationId = stocktakes.getLocationId();
if (plannedDates != null && !plannedDates.isEmpty()) {
stocktakes.setPlannedDateArray(plannedDates.split(","));
}
// 2. 拆分仓库ID
if (warehousesId != null && !warehousesId.isEmpty()) {
stocktakes.setWarehouseIdArray(warehousesId.split(","));
}
// 3. 拆分库位ID
if (locationId != null && !locationId.isEmpty()) {
stocktakes.setLocationIdArray(locationId.split(","));
}
return stocktakeItemsMapper.selectStocktakesCountInfo(stocktakes);
}
} }
package com.ruoyi.inventory.service.impl; package com.ruoyi.inventory.service.impl;
import java.util.Date; import java.util.*;
import java.util.List;
import com.ruoyi.common.core.domain.model.LoginUser; import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.core.page.TableDataInfo;
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.uuid.IdUtils; import com.ruoyi.common.utils.uuid.IdUtils;
import com.ruoyi.inventory.domain.Inventory; import com.ruoyi.inventory.domain.Inventory;
import com.ruoyi.inventory.domain.InventoryTransactions; import com.ruoyi.inventory.domain.InventoryTransactions;
import com.ruoyi.inventory.domain.TO.StocktakesTO; import com.ruoyi.inventory.domain.TO.StocktakesTO;
import com.ruoyi.inventory.domain.TO.StocktakesVo;
import com.ruoyi.inventory.mapper.StocktakeItemsMapper; import com.ruoyi.inventory.mapper.StocktakeItemsMapper;
import com.ruoyi.inventory.service.IInventoryService; import com.ruoyi.inventory.service.IInventoryService;
import com.ruoyi.inventory.service.IInventoryTransactionsService; import com.ruoyi.inventory.service.IInventoryTransactionsService;
import com.ruoyi.inventory.service.IStocktakeItemsService; import com.ruoyi.inventory.service.IStocktakeItemsService;
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 java.util.ArrayList;
import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.StringUtils;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import com.ruoyi.inventory.domain.StocktakeItems; import com.ruoyi.inventory.domain.StocktakeItems;
import com.ruoyi.inventory.mapper.StocktakesMapper; import com.ruoyi.inventory.mapper.StocktakesMapper;
import com.ruoyi.inventory.domain.Stocktakes; import com.ruoyi.inventory.domain.Stocktakes;
import com.ruoyi.inventory.service.IStocktakesService; import com.ruoyi.inventory.service.IStocktakesService;
import org.springframework.web.bind.annotation.GetMapping;
/** /**
* 盘点单主Service业务层处理 * 盘点单主Service业务层处理
...@@ -51,9 +53,21 @@ public class StocktakesServiceImpl implements IStocktakesService ...@@ -51,9 +53,21 @@ public class StocktakesServiceImpl implements IStocktakesService
* @return 盘点单主 * @return 盘点单主
*/ */
@Override @Override
public Stocktakes selectStocktakesById(String id) public Stocktakes selectStocktakesById(String id,String operationType)
{ {
return stocktakesMapper.selectStocktakesById(id); // 获取主表信息
Stocktakes stocktakes = stocktakesMapper.selectStocktakesById(id);
// 获取子表信息
Map<String,Object> query = new HashMap<>();
query.put("stocktake_id",id);
if("confirm".equals(operationType)){
// 盘点确认时只查看 变更的
query.put("adjusted",1);
}
List<StocktakeItems> stocktakeItems = stocktakeItemsService.selectStocktakeItemsByMain(query);
stocktakes.setStocktakeItemsList(stocktakeItems);
return stocktakes;
} }
/** /**
...@@ -156,9 +170,10 @@ public class StocktakesServiceImpl implements IStocktakesService ...@@ -156,9 +170,10 @@ public class StocktakesServiceImpl implements IStocktakesService
Long actualQuantity = stocktakeItems.getActualQuantity(); Long actualQuantity = stocktakeItems.getActualQuantity();
// 库存表id // 库存表id
String inventoryId = stocktakeItems.getInventoryId(); String inventoryId = stocktakeItems.getInventoryId();
// 变更前数量 之所以不用库存表中的数量,是因为变更是从盘点计划时开始算的
Long quantity = stocktakeItems.getSystemQuantity();
// 获取库存信息 // 获取库存信息
Inventory inv = inventoryService.selectInventoryById(inventoryId); Inventory inv = inventoryService.selectInventoryById(inventoryId);
Long quantity = inv.getQuantity(); // 变更前数量
inv.setUpdateTime(nowDate);//更新时间 inv.setUpdateTime(nowDate);//更新时间
inv.setUpdateUserCode(loginUserId);//更新人 inv.setUpdateUserCode(loginUserId);//更新人
inv.setQuantity(actualQuantity);// 更新实际数量 inv.setQuantity(actualQuantity);// 更新实际数量
...@@ -260,4 +275,29 @@ public class StocktakesServiceImpl implements IStocktakesService ...@@ -260,4 +275,29 @@ public class StocktakesServiceImpl implements IStocktakesService
} }
} }
} }
/**
* @description: 查询处理统计
* @author cs
* @date 2025/12/8
* @version 1.0
*/
@Override
public List<StocktakesVo> selectStocktakesListCount(StocktakesVo stocktakes)
{
List<StocktakesVo> list = stocktakesMapper.selectStocktakesListCount(stocktakes);
return list;
}
/**
* @description: 查询处理统计-详情
* @author cs
* @date 2025/12/9
* @version 1.0
*/
@Override
public List<StocktakesVo> selectStocktakesCountInfo(StocktakesVo stocktakes)
{
List<StocktakesVo> list = stocktakeItemsService.selectStocktakesCountInfo(stocktakes);
return list;
}
} }
...@@ -52,7 +52,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -52,7 +52,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="adjustedAt" column="adjusted_at" /> <result property="adjustedAt" column="adjusted_at" />
<result property="startTime" column="start_time" /> <result property="startTime" column="start_time" />
<result property="endTime" column="end_time" /> <result property="endTime" column="end_time" />
<result property="inventoryId" column="inventory_id" />
</resultMap> </resultMap>
<resultMap type="com.ruoyi.inventory.domain.vo.InventorySummaryVO" id="InventorySummaryResult"> <resultMap type="com.ruoyi.inventory.domain.vo.InventorySummaryVO" id="InventorySummaryResult">
...@@ -189,7 +189,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -189,7 +189,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select> </select>
<select id="selectstocktakeItemsList" resultMap="StocktakeItemsResult"> <select id="selectstocktakeItemsList" resultMap="StocktakeItemsResult">
select material_id, batch_id, location_id, warehouse_id, quantity as system_quantity select id as inventory_id,material_id, batch_id, location_id, warehouse_id, quantity as system_quantity
from inventory from inventory
where is_used = 1 and inventory_status = 1 where is_used = 1 and inventory_status = 1
order by warehouse_id,location_id,material_id order by warehouse_id,location_id,material_id
......
...@@ -34,10 +34,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -34,10 +34,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<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="inventoryId" column="inventory_id" /> <result property="inventoryId" column="inventory_id" />
<result property="unitPrice" column="unit_price" />
</resultMap> </resultMap>
<sql id="selectStocktakeItemsVo"> <sql id="selectStocktakeItemsVo">
select id, inventory_id, stocktake_id, material_id, batch_code, warehouse_id, location_id, system_quantity, actual_quantity, variance_quantity, variance_amount, stocktake_status, counted_by, counted_at, adjusted, adjustment_reason, adjusted_by, adjusted_at, start_time, end_time, material_range, location_range, remark, is_used, sort_no, create_time, create_user_code, update_time, update_user_code from stocktake_items select id, inventory_id,unit_price, stocktake_id, material_id, batch_code, warehouse_id, location_id, system_quantity, actual_quantity, variance_quantity, variance_amount, stocktake_status, counted_by, counted_at, adjusted, adjustment_reason, adjusted_by, adjusted_at, start_time, end_time, material_range, location_range, remark, is_used, sort_no, create_time, create_user_code, update_time, update_user_code from stocktake_items
</sql> </sql>
<select id="selectStocktakeItemsList" parameterType="StocktakeItems" resultMap="StocktakeItemsResult"> <select id="selectStocktakeItemsList" parameterType="StocktakeItems" resultMap="StocktakeItemsResult">
...@@ -67,6 +68,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -67,6 +68,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="sortNo != null "> and sort_no = #{sortNo}</if> <if test="sortNo != null "> and sort_no = #{sortNo}</if>
<if test="createUserCode != null and createUserCode != ''"> and create_user_code = #{createUserCode}</if> <if test="createUserCode != null and createUserCode != ''"> and create_user_code = #{createUserCode}</if>
<if test="updateUserCode != null and updateUserCode != ''"> and update_user_code = #{updateUserCode}</if> <if test="updateUserCode != null and updateUserCode != ''"> and update_user_code = #{updateUserCode}</if>
<if test="unitPrice != null and unitPrice != ''"> and unit_price = #{unitPrice}</if>
</where> </where>
</select> </select>
...@@ -75,6 +77,56 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -75,6 +77,56 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where id = #{id} where id = #{id}
</select> </select>
<select id="selectStocktakeItemsByMain" parameterType="java.util.Map" resultMap="StocktakeItemsResult">
select id, inventory_id,unit_price, stocktake_id, material_id, batch_code, warehouse_id, location_id, system_quantity, actual_quantity, variance_quantity, variance_amount, stocktake_status, counted_by, counted_at, adjusted, adjustment_reason, adjusted_by, adjusted_at, start_time, end_time, material_range, location_range, remark, is_used, sort_no, create_time, create_user_code, update_time, update_user_code
from stocktake_items
where stocktake_id = #{stocktake_id} and is_used = 1
<if test="adjusted != null and adjusted != ''"> and adjusted = #{adjusted}</if>
</select>
<!-- 查询处理统计-详情-->
<select id="selectStocktakesCountInfo" resultType="com.ruoyi.inventory.domain.TO.StocktakesVo">
select
st_it.material_id as materialId
,ma.sap_no as sapNo
,date_format(st.planned_date,'%Y%m%d') as plannedDates
,w.warehouses_name as warehousesName
,sl.location_name as locationName
,st_it.warehouse_id as warehousesId
,st_it.location_id as locationID
,ma.ts_code as tsCode
,dict.dict_label as hazardName
,IFNULL(st_it.variance_quantity, '0') as varianceQuantity
,IFNULL(st_it.variance_amount, '0') as varianceAmount
from stocktakes st
left join stocktake_items st_it on st.id = st_it.stocktake_id and st_it.is_used = 1
left join materials ma on st_it.material_id = ma.sap_no and ma.is_used = 1
left join warehouses w on st_it.warehouse_id = w.warehouses_code and w.is_used = 1
left join storage_locations sl on st_it.location_id = sl.location_code and sl.is_used = 1
left join sys_dict_data dict on ma.hazard_id = dict.dict_sort and dict.status =0 and dict.dict_type ='danger_type'
where
st.is_used = 1
<if test="materialId != null "> and st_it.material_id = #{materialId}</if>
<if test="plannedDateArray != null and plannedDateArray.length > 0">
and date_format(st.planned_date,'%Y%m%d') in
<foreach item="date" collection="plannedDateArray" open="(" separator="," close=")">
#{date}
</foreach>
</if>
<if test="warehouseIdArray != null and warehouseIdArray.length > 0">
and st_it.warehouse_id in
<foreach item="warehouse" collection="warehouseIdArray" open="(" separator="," close=")">
#{warehouse}
</foreach>
</if>
<if test="locationIdArray != null and locationIdArray.length > 0">
and st_it.location_id in
<foreach item="location" collection="locationIdArray" open="(" separator="," close=")">
#{location}
</foreach>
</if>
order by st.planned_date
</select>
<insert id="insertStocktakeItems" parameterType="StocktakeItems"> <insert id="insertStocktakeItems" parameterType="StocktakeItems">
insert into stocktake_items insert into stocktake_items
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">
...@@ -107,6 +159,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -107,6 +159,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="createUserCode != null">create_user_code,</if> <if test="createUserCode != null">create_user_code,</if>
<if test="updateTime != null">update_time,</if> <if test="updateTime != null">update_time,</if>
<if test="updateUserCode != null">update_user_code,</if> <if test="updateUserCode != null">update_user_code,</if>
<if test="unitPrice != null"> unit_price,</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if> <if test="id != null">#{id},</if>
...@@ -138,6 +191,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -138,6 +191,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="createUserCode != null">#{createUserCode},</if> <if test="createUserCode != null">#{createUserCode},</if>
<if test="updateTime != null">#{updateTime},</if> <if test="updateTime != null">#{updateTime},</if>
<if test="updateUserCode != null">#{updateUserCode},</if> <if test="updateUserCode != null">#{updateUserCode},</if>
<if test="unitPrice != null"> #{unitPrice},</if>
</trim> </trim>
</insert> </insert>
...@@ -172,18 +226,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -172,18 +226,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="createUserCode != null">create_user_code = #{createUserCode},</if> <if test="createUserCode != null">create_user_code = #{createUserCode},</if>
<if test="updateTime != null">update_time = #{updateTime},</if> <if test="updateTime != null">update_time = #{updateTime},</if>
<if test="updateUserCode != null">update_user_code = #{updateUserCode},</if> <if test="updateUserCode != null">update_user_code = #{updateUserCode},</if>
<if test="unitPrice != null"> unit_price = #{unitPrice},</if>
</trim> </trim>
where id = #{id} where id = #{id}
</update> </update>
<delete id="deleteStocktakeItemsById" parameterType="String"> <update id="deleteStocktakeItemsById" parameterType="String">
delete from stocktake_items where id = #{id} update stocktake_items
</delete> set is_used = 0
where id = #{id}
</update>
<delete id="deleteStocktakeItemsByIds" parameterType="String"> <update id="deleteStocktakeItemsByIds" parameterType="String">
delete from stocktake_items where id in update from stocktake_items
set is_used = 0
where id in
<foreach item="id" collection="array" open="(" separator="," close=")"> <foreach item="id" collection="array" open="(" separator="," close=")">
#{id} #{id}
</foreach> </foreach>
</delete> </update>
</mapper> </mapper>
\ No newline at end of file
...@@ -23,41 +23,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -23,41 +23,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="updateUserCode" column="update_user_code" /> <result property="updateUserCode" column="update_user_code" />
</resultMap> </resultMap>
<resultMap id="StocktakesStocktakeItemsResult" type="Stocktakes" extends="StocktakesResult">
<collection property="stocktakeItemsList" ofType="StocktakeItems" column="id" select="selectStocktakeItemsList" />
</resultMap>
<resultMap type="StocktakeItems" id="StocktakeItemsResult">
<result property="id" column="id" />
<result property="stocktakeId" column="stocktake_id" />
<result property="inventoryId" column="inventory_id" />
<result property="materialId" column="material_id" />
<result property="batchCode" column="batch_code" />
<result property="warehouseId" column="warehouse_id" />
<result property="locationId" column="location_id" />
<result property="systemQuantity" column="system_quantity" />
<result property="actualQuantity" column="actual_quantity" />
<result property="varianceQuantity" column="variance_quantity" />
<result property="varianceAmount" column="variance_amount" />
<result property="stocktakeStatus" column="stocktake_status" />
<result property="countedBy" column="counted_by" />
<result property="countedAt" column="counted_at" />
<result property="adjusted" column="adjusted" />
<result property="adjustmentReason" column="adjustment_reason" />
<result property="adjustedBy" column="adjusted_by" />
<result property="adjustedAt" column="adjusted_at" />
<result property="startTime" column="start_time" />
<result property="endTime" column="end_time" />
<result property="materialRange" column="material_range" />
<result property="locationRange" column="location_range" />
<result property="remark" column="remark" />
<result property="isUsed" column="is_used" />
<result property="sortNo" column="sort_no" />
<result property="createTime" column="create_time" />
<result property="createUserCode" column="create_user_code" />
<result property="updateTime" column="update_time" />
<result property="updateUserCode" column="update_user_code" />
</resultMap>
<sql id="selectStocktakesVo"> <sql id="selectStocktakesVo">
select id, stocktake_id, stocktake_type, warehouse_id, stocktake_status, planned_date, material_range, location_range, total_variance_amount, remark, is_used, sort_no, create_time, create_user_code, update_time, update_user_code from stocktakes select id, stocktake_id, stocktake_type, warehouse_id, stocktake_status, planned_date, material_range, location_range, total_variance_amount, remark, is_used, sort_no, create_time, create_user_code, update_time, update_user_code from stocktakes
...@@ -88,20 +54,47 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -88,20 +54,47 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
${params.dataScope} ${params.dataScope}
</select> </select>
<select id="selectStocktakesById" parameterType="String" resultMap="StocktakesStocktakeItemsResult"> <select id="selectStocktakesById" parameterType="String" resultMap="StocktakesResult">
select id, stocktake_id, stocktake_type, warehouse_id, stocktake_status, planned_date, material_range, location_range select id, stocktake_id, stocktake_type, warehouse_id, stocktake_status, planned_date, material_range, location_range
, total_variance_amount, remark, is_used, sort_no, create_time, create_user_code, update_time, update_user_code , total_variance_amount, remark, is_used, sort_no, create_time, create_user_code, update_time, update_user_code
from stocktakes from stocktakes
where id = #{id} where id = #{id}
</select> </select>
<!-- 查询处理统计-->
<select id="selectStocktakeItemsList" resultMap="StocktakeItemsResult"> <select id="selectStocktakesListCount" resultType="com.ruoyi.inventory.domain.TO.StocktakesVo">
select id, inventory_id, stocktake_id, material_id, batch_code, warehouse_id, location_id, system_quantity, actual_quantity, variance_quantity, variance_amount, stocktake_status, counted_by, counted_at, adjusted, adjustment_reason, adjusted_by, adjusted_at, start_time, end_time, material_range, location_range, remark, is_used, sort_no, create_time, create_user_code, update_time, update_user_code select
from stocktake_items st_it.material_id as materialId
where stocktake_id = #{stocktake_id} and is_used = 1 ,ma.sap_no as sapNo
,GROUP_CONCAT(DISTINCT date_format(st.planned_date,'%Y%m%d') SEPARATOR ',') as plannedDates
,GROUP_CONCAT(DISTINCT w.warehouses_name SEPARATOR ',') as warehousesName
,GROUP_CONCAT(DISTINCT sl.location_name SEPARATOR ',') as locationName
,GROUP_CONCAT(DISTINCT st_it.warehouse_id SEPARATOR ',') as warehousesId
,GROUP_CONCAT(DISTINCT st_it.location_id SEPARATOR ',') as locationId
,ma.ts_code as tsCode
,GROUP_CONCAT(DISTINCT dict.dict_label SEPARATOR ',') as hazardName
,IFNULL(sum(st_it.variance_quantity), '0') as countQuantity
,IFNULL(sum(st_it.variance_amount), '0') as countAmount
from stocktakes st
left join stocktake_items st_it on st.id = st_it.stocktake_id and st_it.is_used = 1
left join materials ma on st_it.material_id = ma.sap_no and ma.is_used = 1
left join warehouses w on st_it.warehouse_id = w.warehouses_code and w.is_used = 1
left join storage_locations sl on st_it.location_id = sl.location_code and sl.is_used = 1
left join sys_dict_data dict on ma.hazard_id = dict.dict_sort and dict.status =0 and dict.dict_type ='danger_type'
where
st.is_used = 1
<if test="materialId != null "> and st_it.material_id = #{materialId}</if>
<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
AND date_format(st.planned_date,'%Y%m%d') &gt;= date_format(#{params.beginTime},'%Y%m%d')
</if>
<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
AND date_format(st.planned_date,'%Y%m%d') &lt;= date_format(#{params.endTime},'%Y%m%d')
</if>
<if test="warehouseId != null "> and st_it.warehouse_id = #{warehouseId}</if>
<if test="locationId != null "> and st_it.location_id = #{locationId}</if>
group by st_it.material_id
</select> </select>
<insert id="insertStocktakes" parameterType="Stocktakes"> <insert id="insertStocktakes" parameterType="Stocktakes">
insert into stocktakes insert into stocktakes
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论