Commit f93f9219 authored by jingnan's avatar jingnan 👀

ERP相关_退库管理功能修改

parent ad9c66c9
...@@ -76,24 +76,36 @@ export default { ...@@ -76,24 +76,36 @@ export default {
}, },
submitEvent(addContinue) { submitEvent(addContinue) {
this.$refs['applyForm'].validate((valid) => { this.$refs['applyForm'].validate((valid) => {
let scrapCount = 0
if (valid && this.selection) { if (valid && this.selection) {
const maxAmount = this.$utils.subNum(this.selection.outsideAmount, -this.selection.backedAmount, -this.selection.backAmount) let responseName = ''
// 历史配套数据
if (this.selection.subTypeName === 'JobResponseOutStorageMatch') {
responseName = 'oldOutStorage'
scrapCount = -(this.selection.scrapCount)
} else {
responseName = 'jobResponseSorting'
}
const maxAmount = this.$utils.subNum(this.selection.outsideAmount, -this.selection.backedAmount, -this.selection.backAmount, scrapCount)
if (this.applyForm.reqAmount > maxAmount) return this.$utils.showMessageWarning(`当前选中物料的退库数量不足!`) if (this.applyForm.reqAmount > maxAmount) return this.$utils.showMessageWarning(`当前选中物料的退库数量不足!`)
const inventoryData = this.selection.erpInventory const inventoryData = this.selection.erpInventory
const data = [{ const data = [{
jobResponseSorting: this.selection,
'subTypeName': `${this.basicData.subTypeName}Item`, 'subTypeName': `${this.basicData.subTypeName}Item`,
'material': inventoryData.extMaterial, 'material': inventoryData.extMaterial,
'materialId': inventoryData.extMaterialId, 'materialId': inventoryData.extMaterialId,
'testNo': inventoryData.testNo, 'testNo': inventoryData.testNo,
'batchNo': inventoryData.batchNumber, 'batchNo': inventoryData.batchNumber,
'serialNo': inventoryData.serialNo, 'serialNo': inventoryData.serialNo,
'jobResponseId': this.selection.id,
'backAmount': this.selection.backAmount || 0, 'backAmount': this.selection.backAmount || 0,
'scrapCount': this.selection.scrapCount || 0,
'backedAmount': this.selection.backedAmount || 0, 'backedAmount': this.selection.backedAmount || 0,
'outsideAmount': this.selection.outsideAmount || 0, 'outsideAmount': this.selection.outsideAmount || 0,
'reqAmount': this.applyForm.reqAmount, 'reqAmount': this.applyForm.reqAmount,
'reqNo': this.selection.erpSortingItem && this.selection.erpSortingItem.erpSorting && this.selection.erpSortingItem.erpSorting.reqNo || '' 'unit': this.selection.unit,
'reqNo': this.selection.reqNo || ''
}] }]
data[0][responseName] = this.selection
this.$emit('submitEvent', { formData: data, addContinue }) this.$emit('submitEvent', { formData: data, addContinue })
addContinue && this.cleanAddForm() addContinue && this.cleanAddForm()
} else { } else {
......
...@@ -111,6 +111,27 @@ export default { ...@@ -111,6 +111,27 @@ export default {
if (item.jobResponseSorting) { if (item.jobResponseSorting) {
if (item.jobResponseSorting.erpSortingItem && item.jobResponseSorting.erpSortingItem.erpSorting) { if (item.jobResponseSorting.erpSortingItem && item.jobResponseSorting.erpSortingItem.erpSorting) {
item.reqNo = item.jobResponseSorting.erpSortingItem.erpSorting.reqNo || '' item.reqNo = item.jobResponseSorting.erpSortingItem.erpSorting.reqNo || ''
item.outsideAmount = item.jobResponseSorting.outsideAmount
item.backedAmount = item.jobResponseSorting.backedAmount
item.backAmount = item.jobResponseSorting.backAmount
item.outsideAmount = item.jobResponseSorting.outsideAmount
item.scrapCount = null
item.unit = item.jobResponseSorting.erpInventory && item.jobResponseSorting.erpInventory.unit
item.testNo = item.jobResponseSorting.erpInventory && item.jobResponseSorting.erpInventory.testNo
item.jobResponseId = item.jobResponseSorting.id
}
}
if (item.oldOutStorage) {
if (item.oldOutStorage.jobOrder && item.oldOutStorage.jobOrder.outStorageRequest) {
item.reqNo = item.oldOutStorage.jobOrder.outStorageRequest.reqNo || ''
item.outsideAmount = item.oldOutStorage.outsideAmount
item.backedAmount = item.oldOutStorage.backedAmount
item.backAmount = item.oldOutStorage.backAmount
item.outsideAmount = item.oldOutStorage.outsideAmount
item.scrapCount = item.oldOutStorage.scrapCount
item.unit = item.oldOutStorage.inventory && item.oldOutStorage.inventory.extUnit && item.oldOutStorage.inventory.extUnit.unitName
item.testNo = item.oldOutStorage.inventory && item.oldOutStorage.inventory.testNo
item.jobResponseId = item.oldOutStorage.id
} }
} }
return item return item
...@@ -159,21 +180,26 @@ export default { ...@@ -159,21 +180,26 @@ export default {
this.dialogShow = true this.dialogShow = true
}, },
remove() { remove() {
const ids = this.selectionRows.map(item => item.id) const ids = this.selectionRows.filter(item => item.id).map(item => item.id)
this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', { this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
confirmButtonText: '确定', confirmButtonText: '确定',
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning' type: 'warning'
}).then(() => { }).then(() => {
post(`/RetirementItem/batch/deleteItem?`, ids).then(res => { if (ids && ids.length) {
post(`/RetirementItem/batch/deleteItem`, ids).then(res => {
this.$message({ this.$message({
type: 'success', type: 'success',
message: '删除成功!' message: '删除成功!'
}) })
this.tableData = this.tableData.filter(item => !this.selectionRows.map(item => item.jobResponseSorting.id).includes(item.jobResponseSorting.id)) this.filterCurData()
this.$bus.$emit('cancelUnSaveRefresh')
}).catch((err) => { }).catch((err) => {
console.log(err) console.log(err)
}) })
} else {
this.filterCurData()
}
}).catch(() => { }).catch(() => {
this.$message({ this.$message({
type: 'info', type: 'info',
...@@ -181,10 +207,13 @@ export default { ...@@ -181,10 +207,13 @@ export default {
}) })
}) })
}, },
filterCurData() {
this.tableData = this.tableData.filter(item => !this.selectionRows.map(item => item.jobResponseId).includes(item.jobResponseId))
},
submitEvent({ formData, addContinue }) { submitEvent({ formData, addContinue }) {
const onlyFlag = this.tableData.find(item => item.reqNo !== formData[0].reqNo) const onlyFlag = this.tableData.find(item => !item.reqNo.includes(formData[0].reqNo) && !formData[0].reqNo.includes(item.reqNo))
if (onlyFlag) return this.$utils.showMessageWarning('只能添加同一单据下的数据,请重新选择!') if (onlyFlag) return this.$utils.showMessageWarning('只能添加同一单据下的数据,请重新选择!')
const extMaterialIds = this.tableData.map(item => item.jobResponseSorting.id).includes(formData[0].jobResponseSorting.id) const extMaterialIds = this.tableData.map(item => item.jobResponseId).includes(formData[0].jobResponseId)
if (extMaterialIds) return this.$utils.showMessageWarning('相同数据不能重复添加,请重新选择!') if (extMaterialIds) return this.$utils.showMessageWarning('相同数据不能重复添加,请重新选择!')
this.tableData.push(...formData) this.tableData.push(...formData)
this.dialogShow = addContinue || false this.dialogShow = addContinue || false
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment