Commit 3e30bb4d authored by jingnan's avatar jingnan 👀

退库入库界面联调

parent 9397eb74
<template>
<div class="addInStorageBackItemDialog">
<dee-as-com
v-if="basicData.subTypeName==='InStorageMatchBack'"
ref="topTable"
:lay-config="{ typeName: 'OutStorageMatchItem', layKey: 'addInStorageBackMatchItem_top' }"
:basic-data="basicData"
table-height="400px"
@row-click="handleRowClickTop"
/>
<dee-as-com
ref="bottomTable"
:table-height="basicData.subTypeName==='InStorageMatchBack'?'300px':'500px'"
:lay-config="cmpOptions"
:basic-data="basicData"
@row-click="handleRowClickBottom"
/>
<el-form ref="applyForm" :rules="rules" :model="applyForm" class="applyForm">
<el-form-item :label="amountItemLabel" prop="reqAmount" label-width="100px">
<el-input-number v-model="applyForm.reqAmount" :placeholder="amountItemLabel" :min="0" size="small" />
</el-form-item>
<el-form-item class="foot-btn-box">
<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>
</div>
</template>
<script>
export default {
// componentName: '退库入库添加明细',
name: 'AddInStorageBackItemDialog',
components: {},
props: {
basicData: {
type: Object,
default: () => {}
},
selectDatas: {
type: Array,
default: () => []
}
},
data() {
return {
selection: null,
defaultData: {},
applyForm: {},
amountItemLabel: '退库数量',
rules: {
reqAmount: [
{ required: true, message: '该项必填', trigger: 'blur' }
]
},
cmpOptions: { typeName: 'JobResponseOutStorageMatch', layKey: 'add_InStorageBackMatchItem_bottom' }
}
},
computed: {},
watch: {
'basicData.subTypeName': {
immediate: true,
handler(val) {
if (val === 'InStorageMatchBack') {
this.$set(this.cmpOptions, 'layKey', 'add_InStorageBackMatchItem_bottom')
} else if (val === 'InStorageOutBack' || val === 'InStorageUseBack') {
this.$set(this.cmpOptions, 'layKey', 'add_InStorageBackItem_Use&Out')
} else {
this.$set(this.cmpOptions, 'layKey', '')
}
}
}
},
created() {
},
methods: {
handleRowClickTop({ row }) {
if (row.id) {
this.$refs.bottomTable.$refs.asCom.getData(row.id)
}
},
handleRowClickBottom(val) {
this.selection = val.row
},
submitEvent(addContinue) {
this.$refs['applyForm'].validate((valid) => {
if (valid && this.selection) {
const maxAmount = this.selection.outsideAmount - this.selection.backedAmount - this.selection.backAmount - this.selection.scrapCount
if (this.applyForm.reqAmount > maxAmount) return this.$utils.showMessageWarning(`当前选中物料的退库数量不足!`)
const inventoryData = this.selection.inventory
const data = [{
'subTypeName': `${this.basicData.subTypeName}Item`,
'extMaterial': inventoryData.extMaterial,
'extMaterialId': inventoryData.extMaterialId,
'testNo': inventoryData.testNo,
'suppname': inventoryData.suppname,
'backItemId': this.selection.id,
'backItemIdType': this.selection.subTypeName,
'backAmount': this.selection.backAmount || 0,
'backedAmount': this.selection.backedAmount || 0,
'scrapCount': this.selection.scrapCount || 0,
'outsideAmount': this.selection.outsideAmount || 0,
'reqAmount': this.applyForm.reqAmount
}]
this.$emit('submitEvent', { formData: data, addContinue })
addContinue && this.cleanAddForm()
} else {
this.$utils.showMessageWarning(`至少选择一条物料并且${this.amountItemLabel}必填!`)
return false
}
})
},
cleanAddForm() {
this.$refs.bottomTable.$refs.asCom.getData()
this.applyForm = {}
},
cancelEvent() {
this.$emit('cancel')
}
}
}
</script>
<style lang='scss'>
.addInStorageBackItemDialog{
.applyForm{
margin-top: 30px;
.el-input-number{
width: 180px;
}
}
.foot-btn-box{
display: flex;
margin-top: 10px;
justify-content: center;
align-content: center;
}
}
</style>
<!--
* @Author: gjn
* @Date: 2023-09-09 153:07:44
* @Description:退库入库申请明细
-->
<template>
<div v-if="form&&form.subTypeName" :style="layoutStyle" class="addInStorageBackItem">
<dee-as-com
ref="table"
:im-show-table-data="imShowTableData"
:basic-data="{...form,...basicData}"
:lay-config="cmpOptions"
table-height="auto"
:dis-business="true"
:result-data="tableData"
@tableToolHandler="tableToolHandler"
@selectionChange="selectionChange"
/>
<dee-dialog
:title="dialogTitle"
width="70%"
:dialog-visible="dialogShow"
@handleClose="dialogShow = false"
>
<component
:is="componentName"
:basic-data="{...form,...basicData}"
:select-datas="selectionRows"
:form="form"
@submitEvent="submitEvent"
@cancel="dialogShow = false"
/>
</dee-dialog>
</div>
</template>
<script>
import AddInStorageBackItemDialog from './components/AddInStorageBackItemDialog'
import { post } from '@/utils/http'
export default {
componentName: '退库入库添加明细',
name: 'AddInStorageBackItem',
components: { AddInStorageBackItemDialog },
props: {
basicData: {
type: Object,
default: () => {}
},
form: {
type: Object,
default: () => {
return {}
}
},
imShowTableData: {
type: Array,
default: () => {
return []
}
},
layoutStyle: {
type: Object,
default: () => {
return {}
}
},
showBtn: {
type: Boolean,
default: true
}
},
data() {
return {
dialogShow: false,
selectionRows: [],
tableData: [],
dialogTitle: '',
componentName: '',
cmpOptions: {
typeName: 'InStorageBackItem',
layKey: 'InStorageMatchBack_details'
}
}
},
computed: {
},
watch: {
tableData: {
immediate: true,
deep: true,
handler(data) {
this.$emit('input', data)
}
},
'form.subTypeName': {
immediate: true,
deep: true,
handler(val) {
if (val && !this.basicData.id) {
this.tableData = []
}
}
},
basicData: {
immediate: true,
deep: true,
handler(val) {
if (val && val.id) {
if (this.basicData.inStorageRequestItems) {
this.tableData = this.basicData.inStorageRequestItems.map(item => {
return item
})
}
}
}
}
},
created() {
},
provide() {
return {
parentType_Inject: '退库入库'
}
},
methods: {
tableToolHandler(val) {
const btnValue = val.key.btnValue
switch (btnValue) {
case 'add':
this.addHandle()
break
case 'remove':
this.remove()
break
default:
break
}
},
selectionChange(val) {
this.selectionRows = val
},
addHandle() {
this.$utils.findForm(this).validate((valid) => {
if (valid) {
this.openDialog('添加退库明细', 'AddInStorageBackItemDialog')
} else {
this.$utils.showMessageWarning('请填写基本信息!')
}
})
},
openDialog(dialogTitle, componentName) {
this.dialogTitle = dialogTitle
this.componentName = componentName
this.dialogShow = true
},
remove() {
this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
post(`/InStorageRequestItem/inStorageBackItem/delete?itemIds=${this.selectionRows.map(item => item.id).join(',')}`).then(res => {
this.$message({
type: 'success',
message: '删除成功!'
})
this.tableData = this.tableData.filter(item => !this.selectionRows.map(item => item.extMaterialId).includes(item.extMaterialId))
}).catch((err) => {
console.log(err)
})
}).catch(() => {
this.$message({
type: 'info',
message: '已取消删除'
})
})
},
submitEvent({ formData, addContinue }) {
const extMaterialIds = this.tableData.map(item => item.extMaterialId).includes(formData[0].extMaterialId)
if (extMaterialIds) return this.$utils.showMessageWarning('相同物料不能重复添加,请重新选择!')
this.tableData.push(...formData)
this.dialogShow = addContinue || false
}
}
}
</script>
<style>
</style>
......@@ -25,7 +25,6 @@
<component
:is="componentName"
:basic-data="{...form,...basicData}"
:component-prop="componentProp"
:select-datas="selectionRows"
:form="form"
@submitEvent="submitEvent"
......@@ -46,7 +45,7 @@ export default {
components: { AddOutStorageUseDetailDialog, AdjustOccupyCom },
provide() { // 用于报废领用申领数量编辑校验
return {
parentType_Inject: this.basicData.useRequestType
parentType_Inject: this.basicData && this.basicData.useRequestType || ''
}
},
props: {
......@@ -70,14 +69,6 @@ export default {
return []
}
},
typeName: {
type: String,
default: () => ''
},
typeKey: {
type: String,
default: () => ''
},
buttonFilter: {
type: String,
default: () => ''
......@@ -95,9 +86,6 @@ export default {
},
data() {
return {
componentProp: {
showSubType: true
},
dialogShow: false,
selectionRows: [],
tableData: [],
......@@ -106,8 +94,7 @@ export default {
cmpOptions: {
typeName: 'OutStorageUseItem',
layKey: 'add_outStorageUseItem_useAO'
},
editMaterialItem: null
}
}
},
computed: {
......@@ -121,16 +108,14 @@ export default {
this.$emit('input', data)
}
},
'basicData.useRequestType': {
basicData: {
immediate: true,
deep: true,
handler(val) {
this.$set(this.cmpOptions, 'layKey', `add_outStorageUseItem_${val}`)
if (val && val.useRequestType) {
this.$set(this.cmpOptions, 'layKey', `add_outStorageUseItem_${val.useRequestType}`)
}
},
'basicData.id': {
immediate: true,
handler(val) {
if (val && val.id) {
if (this.basicData.inStorageRequestItems && (!this.tableData || !this.tableData.length)) {
this.tableData = this.basicData.inStorageRequestItems.map(item => {
item.allocatedAmount = this.$utils.sumArray(item.inventoryJobResponses, 'allocatedAmount')
......@@ -139,6 +124,7 @@ export default {
}
}
}
}
},
created() {
this.$bus.$on('swapUseData', (data) => {
......
......@@ -69,7 +69,7 @@ export default {
this.maxNum = maxAmount
}
this.$emit('input', this.reqAmount)
if (this.form.id) {
if (this.form.id && this.parentType_Inject !== '退库入库') {
this.changeAmount()
}
},
......
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