fix:库存查询,库存对账,
This commit is contained in:
@@ -32,7 +32,7 @@
|
||||
v-model="materialCode"
|
||||
clearable
|
||||
size="small"
|
||||
placeholder="请输入物料编号"
|
||||
placeholder="物料编号(不填则按库区库存逐个查SAP)"
|
||||
style="width: 200px;"
|
||||
class="filter-item"
|
||||
@keyup.enter.native="queryReconcile"
|
||||
@@ -53,6 +53,9 @@
|
||||
|
||||
<div v-if="queried" class="summary">
|
||||
对比来源:SAP / {{ compareSourceName }},共 {{ displayData.length }} 条,不一致 {{ diffCount }} 条
|
||||
<span v-if="failedMaterials.length" style="color: #e6a23c; margin-left: 8px;">
|
||||
({{ failedMaterials.length }} 个物料查询SAP库存失败,已按无库存处理)
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<el-table
|
||||
@@ -138,6 +141,7 @@ export default {
|
||||
downloadLoading: false,
|
||||
queried: false,
|
||||
compareSourceName: '对比库存',
|
||||
failedMaterials: [],
|
||||
tableData: [],
|
||||
page: {
|
||||
page: 1,
|
||||
@@ -202,13 +206,21 @@ export default {
|
||||
this.$message.warning('请选择库区')
|
||||
return
|
||||
}
|
||||
const materialCode = (this.materialCode || '').trim()
|
||||
this.loading = true
|
||||
reconcile({ sectCode: this.sectCode, materialCode: this.materialCode }).then(res => {
|
||||
reconcile({ sectCode: this.sectCode, materialCode }).then(res => {
|
||||
const data = res.data || {}
|
||||
this.compareSourceName = data.compareSourceName || '对比库存'
|
||||
this.failedMaterials = data.failedMaterials || []
|
||||
this.tableData = data.rows || []
|
||||
this.page.page = 1
|
||||
this.queried = true
|
||||
if (this.failedMaterials.length) {
|
||||
const preview = this.failedMaterials.slice(0, 5).join('、')
|
||||
this.$message.warning(
|
||||
`${this.failedMaterials.length} 个物料查询SAP库存失败(${preview}${this.failedMaterials.length > 5 ? ' 等' : ''}),已按无库存处理`
|
||||
)
|
||||
}
|
||||
}).catch(() => {
|
||||
this.tableData = []
|
||||
}).finally(() => {
|
||||
@@ -224,7 +236,7 @@ export default {
|
||||
return
|
||||
}
|
||||
this.downloadLoading = true
|
||||
download('/api/bi/reconcile/download', { sectCode: this.sectCode, materialCode: this.materialCode, onlyDiff: this.onlyDiff }).then(result => {
|
||||
download('/api/bi/reconcile/download', { sectCode: this.sectCode, materialCode: (this.materialCode || '').trim(), onlyDiff: this.onlyDiff }).then(result => {
|
||||
downloadFile(result, '库存对账', 'xlsx')
|
||||
}).catch(() => {
|
||||
this.$message.error('导出失败')
|
||||
|
||||
@@ -129,21 +129,37 @@
|
||||
<el-dialog
|
||||
title="库存同步"
|
||||
:visible.sync="syncDialogVisible"
|
||||
width="400px"
|
||||
width="520px"
|
||||
:close-on-click-modal="false"
|
||||
>
|
||||
<el-form label-width="80px" label-suffix=":">
|
||||
<el-form-item label="仓库编码">
|
||||
<el-form label-width="90px" label-suffix=":" size="small">
|
||||
<el-form-item label="仓库">
|
||||
<el-input
|
||||
v-model="syncWarehouseCode"
|
||||
placeholder="请输入仓库编码"
|
||||
v-model.trim="syncWarehouseCode"
|
||||
clearable
|
||||
placeholder="请输入仓库编码"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="物料清单">
|
||||
<el-input
|
||||
v-model="syncMaterials"
|
||||
type="textarea"
|
||||
:rows="8"
|
||||
placeholder="一行一个物料号,可直接从 Excel 粘贴一列"
|
||||
/>
|
||||
<div style="color: #909399; font-size: 12px; line-height: 18px; margin-top: 4px;">
|
||||
按清单逐个物料查询 SAP 库存(MM027),已去重:{{ parsedMaterials.length }} 个
|
||||
</div>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button @click="syncDialogVisible = false">取消</el-button>
|
||||
<el-button type="primary" :loading="syncLoading" @click="doSyncStock">确定</el-button>
|
||||
<el-button
|
||||
type="primary"
|
||||
:loading="syncLoading"
|
||||
:disabled="!syncWarehouseCode || !parsedMaterials.length"
|
||||
@click="doSyncStock"
|
||||
>确定</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
|
||||
@@ -237,6 +253,7 @@ export default {
|
||||
rules: {},
|
||||
syncDialogVisible: false,
|
||||
syncWarehouseCode: '',
|
||||
syncMaterials: '',
|
||||
syncLoading: false,
|
||||
exporting: false,
|
||||
printDialogVisible: false,
|
||||
@@ -248,6 +265,17 @@ export default {
|
||||
}
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
// 物料清单:按换行/逗号/空格拆分,去空去重
|
||||
parsedMaterials() {
|
||||
const text = this.syncMaterials || ''
|
||||
const codes = text
|
||||
.split(/[,,;;\s]+/)
|
||||
.map(item => item.trim())
|
||||
.filter(item => !!item)
|
||||
return Array.from(new Set(codes))
|
||||
}
|
||||
},
|
||||
created() {
|
||||
crudSectattr.getSect({ 'stor_id': '' }).then(res => {
|
||||
this.sects = res.data
|
||||
@@ -337,6 +365,7 @@ export default {
|
||||
},
|
||||
openSyncDialog() {
|
||||
this.syncWarehouseCode = ''
|
||||
this.syncMaterials = ''
|
||||
this.syncDialogVisible = true
|
||||
},
|
||||
doSyncStock() {
|
||||
@@ -344,15 +373,20 @@ export default {
|
||||
this.$message.warning('请输入仓库编码')
|
||||
return
|
||||
}
|
||||
const materials = this.parsedMaterials
|
||||
if (!materials.length) {
|
||||
this.$message.warning('请输入物料清单,一行一个物料号')
|
||||
return
|
||||
}
|
||||
this.syncLoading = true
|
||||
request({
|
||||
url: 'api/structivt/syncStock',
|
||||
method: 'post',
|
||||
data: { warehouseno: this.syncWarehouseCode }
|
||||
data: { warehouseno: this.syncWarehouseCode, materials }
|
||||
}).then(res => {
|
||||
const data = res.data || res
|
||||
this.$message.success(
|
||||
`同步完成!EAS总数:${data.easTotal}, 本地总数:${data.localTotal}, 更新:${data.updateCount}, 新增:${data.addCount}, 删除:${data.deleteCount}`
|
||||
`同步完成!清单物料:${data.materialTotal || 0}, SAP返回物料:${data.sapTotal || 0}, 更新:${data.updateCount}, 新增:${data.addCount}, 删除:${data.deleteCount}`
|
||||
)
|
||||
this.syncDialogVisible = false
|
||||
this.crud.refresh()
|
||||
|
||||
Reference in New Issue
Block a user