Commit b4a438f4 authored by jingnan's avatar jingnan 👀

领用出库申请调整占用联调

parent 3dbfd88a
......@@ -1565,6 +1565,15 @@ export function findForm(elem = this) {
return null // 没有找到 el-form,返回 null
}
// 计算列表数据中某一项的和
export function sumArray(array, key) {
const baseNum = 1000 // 解决js计算精度丢失问题
let sum = 0
for (let i = 0; i < array.length; i++) {
sum += Number(array[i][key]) * baseNum
}
return sum / baseNum
}
export default {
treeFindBackArray,
throttle,
......@@ -1647,5 +1656,6 @@ export default {
filterParams,
deepClone,
fileByIdDownload,
findForm
findForm,
sumArray
}
......@@ -17,7 +17,8 @@
<el-input-number v-model="applyForm.reqAmount" placeholder="申领数量" :min="0" size="small" />
</el-form-item>
<el-form-item class="foot-btn-box">
<el-button type="primary" @click="submitEvent">确认</el-button>
<el-button type="primary" @click="submitEvent(true)">添加</el-button>
<el-button type="primary" @click="submitEvent(false)">确认</el-button>
<el-button @click="cancelEvent">取消</el-button>
</el-form-item>
</el-form>
......@@ -68,7 +69,7 @@ export default {
handleRowClick(val) {
this.selection = val.row
},
submitEvent() {
submitEvent(addContinue) {
this.$refs['applyForm'].validate((valid) => {
if (valid && this.selection) {
if (this.applyForm.reqAmount > this.selection.unableAmount) return this.$utils.showMessageWarning('申领数量不能大于当前选中物料的可用数量!')
......@@ -82,7 +83,7 @@ export default {
'unableAmount': this.selection.unableAmount,
'reqAmount': this.applyForm.reqAmount
}]
this.$emit('submitEvent', { formData: data })
this.$emit('submitEvent', { formData: data, addContinue },)
} else {
this.$utils.showMessageWarning('至少选择一条物料并且申领数量必填!')
return false
......
......@@ -20,16 +20,19 @@
@selectionChange="selectionChange"
/>
<dee-dialog
title="添加出库物料"
width="1000px"
:title="dialogTitle"
width="70%"
:dialog-visible="dialogShow"
@handleClose="dialogShow = false"
>
<AddOutStorageUseDetailDialog
v-if="dialogShow"
<component
:is="componentName"
:basic-data="{...form,...basicData}"
:component-prop="componentProp"
:select-datas="selectionRows"
:form="form"
@submitEvent="submitEvent"
@refreshResponses="refreshResponses"
@cancel="dialogShow = false"
/>
</dee-dialog>
......@@ -37,12 +40,13 @@
</template>
<script>
import AddOutStorageUseDetailDialog from '../AddOutStorageUseDetailDialog'
import AddOutStorageUseDetailDialog from './components/AddOutStorageUseDetailDialog.vue'
import AdjustOccupyCom from '../adjustOccupyCom'
import { post } from '@/utils/http'
export default {
componentName: '领用出库明细',
name: 'AddOutStorageUseDetail',
components: { AddOutStorageUseDetailDialog },
components: { AddOutStorageUseDetailDialog, AdjustOccupyCom },
props: {
basicData: {
type: Object,
......@@ -94,7 +98,9 @@ export default {
},
dialogShow: false,
selectionRows: [],
tableData: []
tableData: [],
dialogTitle: '',
componentName: ''
}
},
computed: {
......@@ -114,11 +120,14 @@ export default {
const btnValue = val.key.btnValue
switch (btnValue) {
case 'add':
this.dialogShow = true
this.openDialog('添加出库物料', 'AddOutStorageUseDetailDialog')
break
case 'occupy':
this.occupy()
break
case 'adjustOccupy':
this.adjustOccupy()
break
case 'remove':
this.remove()
break
......@@ -151,7 +160,8 @@ export default {
v.id = item.id
v.operator = 'MODIFY'
v.outStorageOutId = res.items.id
v.allocatedAmount = this.sumArray(item.inventoryJobResponses, 'allocatedAmount')
v.inventoryJobResponses = item.inventoryJobResponses
v.allocatedAmount = this.$utils.sumArray(item.inventoryJobResponses, 'allocatedAmount')
}
})
})
......@@ -160,6 +170,24 @@ export default {
console.log(err)
})
},
adjustOccupy() {
if (this.selectionRows.length === 1) {
if (this.selectionRows[0].hasOwnProperty('id')) {
this.openDialog('调整占用', 'AdjustOccupyCom')
} else {
this.$utils.showMessageWarning('请先保存占用!')
}
} else if (this.selectionRows.length > 1) {
this.$utils.showMessageWarning('只能勾选一条明细!')
} else {
this.$utils.showMessageWarning('请先选择要调整的明细!')
}
},
openDialog(dialogTitle, componentName) {
this.dialogTitle = dialogTitle
this.componentName = componentName
this.dialogShow = true
},
remove() {
this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
confirmButtonText: '确定',
......@@ -182,16 +210,13 @@ export default {
})
})
},
sumArray(array, key) {
let sum = 0
for (let i = 0; i < array.length; i++) {
sum += Number(array[i][key])
}
return sum
},
submitEvent({ formData }) {
submitEvent({ formData, addContinue }) {
this.tableData.push(...formData)
this.dialogShow = false
this.dialogShow = addContinue || false
},
refreshResponses({ inventoryJobResponses }) {
this.selectionRows[0].inventoryJobResponses = inventoryJobResponses
this.selectionRows[0].allocatedAmount = this.$utils.sumArray(inventoryJobResponses, 'allocatedAmount')
}
}
}
......
<!--
* @Author: gjn
* @Date: 2023-08-31 17:40:24
* @Description:调整占用
-->
<template>
<div class="adjustOccupyCom">
<DeeAsCom
ref="adjustOccupyInfo"
:basic-data="selectDatas[0]"
:form="form"
:lay-config="topLayCoinfig"
@selectionChange="infoSelectionChange"
/>
<div style="height: 80px; text-align: center;display: flex;justify-content: center;align-items: center;">
<el-button type="primary" size="medium" round icon="el-icon-caret-top" @click="relieve">解除</el-button>
<el-button type="primary" round icon="el-icon-caret-bottom" @click="occupy">占用</el-button>
</div>
<DeeAsCom
ref="adjustOccupyJobResponse"
:basic-data="selectDatas[0]"
:lay-config="bottomLayCoinfig"
@selectionChange="jobResponseSelectionChange"
@requestSuccess="onRequestSuccess"
/>
</div>
</template>
<script>
import { post } from '@/utils/http'
export default {
componentName: '调整占用',
name: 'AdjustOccupyCom',
components: {},
props: {
topLayCoinfig: {
type: Object,
default: () => ({
typeName: 'Inventory',
layKey: 'adjustOccupyTable'
})
},
bottomLayCoinfig: {
type: Object,
default: () => ({
typeName: 'JobResponseOutStorageOut',
layKey: 'table'
})
},
selectDatas: {
type: Array,
default: () => []
},
form: {
type: Object,
default: () => {}
}
},
data() {
return {
infoSelection: [],
jobResponseSelection: [],
isRefresh: false
}
},
computed: {},
created() {
// 初始化数据
},
methods: {
infoSelectionChange(v) {
this.infoSelection = v
},
jobResponseSelectionChange(v) {
this.jobResponseSelection = v
},
// 解除占用
relieve() {
if (this.jobResponseSelection.length === 0) {
return this.$utils.showMessageWarning('请选择响应数据!')
}
const ids = this.jobResponseSelection.map(item => item.id).join(',')
post('InStorageRequestItem/adjust/cancelTake?jobResponseIds=' + ids).then(res => {
this.$utils.showMessageSuccess('解除占用成功!')
this.refresh()
}).catch((err) => {
console.log(err)
})
},
// 手动占用
occupy() {
const param = this.infoSelection.map(item => {
if (item.allocatedAmount === 0 || !item.hasOwnProperty('allocatedAmount')) {
return this.$utils.showMessageWarning('请输入分配数量!')
} else {
return {
inventoryId: item.id,
allocatedAmount: item.allocatedAmount
}
}
})
if (!param.includes(undefined)) {
post('InStorageRequestItem/adjust/reTake?itemId=' + this.selectDatas[0].id, param).then(res => {
this.$utils.showMessageSuccess('占用成功!')
this.refresh()
}).catch((err) => {
console.log(err)
})
}
},
refresh() {
this.isRefresh = true
this.$refs.adjustOccupyInfo.$refs.asCom.getData()
this.$refs.adjustOccupyJobResponse.$refs.asCom.getData()
},
onRequestSuccess(res) {
if (this.isRefresh) {
const inventoryJobResponses = res.items.content || []
this.$emit('refreshResponses', { inventoryJobResponses })
}
this.isRefresh = false
}
}
}
</script>
<style lang='scss'>
</style>
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