add:差异对账新增盘点平账功能

This commit is contained in:
zhaoyf
2026-11-27 13:32:32 +08:00
parent c6181d6b25
commit eb6d871fe0
15 changed files with 524 additions and 2 deletions

View File

@@ -8,4 +8,15 @@ export function reconcile(params) {
})
}
export default { reconcile }
/**
* 库存平账:以本地库存作为盘点数量调用 SAP MM026 差异过账
*/
export function balance(data) {
return request({
url: 'api/bi/balance',
method: 'post',
data
})
}
export default { reconcile, balance }

View File

@@ -49,6 +49,17 @@
</el-dropdown-menu>
</el-dropdown>
</el-form-item>
<el-form-item>
<el-button
type="warning"
size="mini"
class="filter-item"
icon="el-icon-refresh-left"
:loading="balanceLoading"
:disabled="!selection.length"
@click="balanceStock"
>平账{{ selection.length ? '(' + selection.length + ')' : '' }}</el-button>
</el-form-item>
</el-form>
<div v-if="queried" class="summary">
@@ -56,15 +67,22 @@
<span v-if="failedMaterials.length" style="color: #e6a23c; margin-left: 8px;">
({{ failedMaterials.length }} 个物料查询SAP库存失败,已按无库存处理)
</span>
<span style="color: #909399; margin-left: 8px;">
勾选行后点「平账」,将以本地库存为盘点数量调用 SAP MM026 差异过账
</span>
</div>
<el-table
ref="reconcileTable"
v-loading="loading"
:data="pageData"
size="mini"
style="width: 100%;"
row-key="materialCode"
:row-class-name="rowClassName"
@selection-change="onSelectionChange"
>
<el-table-column type="selection" width="45" reserve-selection />
<el-table-column prop="warehouseCode" label="仓库编号" min-width="120" />
<el-table-column label="物料编码" min-width="160">
<template slot-scope="scope">
@@ -123,7 +141,7 @@
<script>
import { getStor } from '@/views/wms/basedata/bsrealstorattr/bsrealstorattr'
import { reconcile } from './bi'
import { reconcile, balance } from './bi'
import request from '@/utils/request'
import { download } from '@/api/data'
import { downloadFile } from '@/utils'
@@ -138,6 +156,8 @@ export default {
onlyDiff: false,
loading: false,
downloadLoading: false,
balanceLoading: false,
selection: [],
queried: false,
compareSourceName: '对比库存',
failedMaterials: [],
@@ -181,6 +201,7 @@ export default {
},
methods: {
onStorChange() {
this.clearSelection()
if (!this.storCode) {
this.tableData = []
this.queried = false
@@ -193,6 +214,65 @@ export default {
this.exportExcel()
}
},
onSelectionChange(selection) {
this.selection = selection || []
},
clearSelection() {
this.selection = []
const table = this.$refs.reconcileTable
if (table) {
table.clearSelection()
}
},
/**
* 平账:勾选行以本地库存为盘点数量,调用 SAP MM026 差异过账,使两边库存一致
*/
balanceStock() {
if (!this.storCode) {
this.$message.warning('请选择仓库')
return
}
// 库存已一致的行无需过账,自动跳过
const rows = this.selection.filter(row => row.diff)
const skipped = this.selection.length - rows.length
if (!rows.length) {
this.$message.warning('所选行库存已一致,无需平账')
return
}
const totalQty = rows.reduce((sum, row) => sum + Number(row.compareQty || 0), 0)
const tip = `将以【${this.compareSourceName}】作为盘点数量调用 SAP MM026 差异过账,把 SAP 库存调整为本地库存。` +
`本次共 ${rows.length} 个物料,数量合计 ${totalQty}` +
(skipped ? `;另有 ${skipped} 行库存一致,将自动跳过` : '') +
'。是否继续?'
this.$confirm(tip, '库存平账', {
type: 'warning',
confirmButtonText: '确认平账',
cancelButtonText: '取消'
}).then(() => {
this.balanceLoading = true
balance({
storCode: this.storCode,
items: rows.map(row => ({
materialCode: row.materialCode,
materialName: row.materialName,
qty: row.compareQty,
unitName: row.unitName
}))
}).then(res => {
// 业务失败已由请求拦截器统一提示,这里只处理成功返回
if (!res) {
return
}
const result = res.data || {}
this.$message.success(
`平账成功:${result.materialCount || rows.length} 个物料,数量合计 ${result.totalQty === undefined ? totalQty : result.totalQty}。${result.sapMessage || ''}`
)
this.queryReconcile()
}).catch(() => {}).finally(() => {
this.balanceLoading = false
})
}).catch(() => {})
},
queryReconcile() {
if (!this.storCode) {
this.$message.warning('请选择仓库')
@@ -207,6 +287,7 @@ export default {
this.tableData = data.rows || []
this.page.page = 1
this.queried = true
this.clearSelection()
if (this.failedMaterials.length) {
const preview = this.failedMaterials.slice(0, 5).join('、')
this.$message.warning(