Commit 42d37ea3 authored by jingnan's avatar jingnan 👀

领用申请换件联调

parent 76e14c44
......@@ -24,11 +24,13 @@
:lay-config="cmpOptions"
:basic-data="{useRequestType:typeName}"
:on-form-event-hander="formEventHander"
@on-cancel="cancelHandler"
/>
</div>
</template>
<script>
import { post } from '@/utils/http'
export default {
componentName: '领用出库申请新建',
name: 'AddOutStorageUseCom',
......@@ -45,13 +47,13 @@ export default {
},
data() {
return {
typeName: 'useAO',
typeName: 'swapUse',
options: [
],
showCmp: true,
cmpOptions: {
typeName: 'OutStorageUse',
layKey: 'outStorageUseApply_add_instruct'
layKey: 'outStorageUseApply_add_useAO'
},
formEventHander: {
'on-submit': () => {
......@@ -63,7 +65,8 @@ export default {
'on-cancel': () => {
this.$emit('on-cancel')
}
}
},
outStorageUseId: [] // 取消使解除占用操作需要
}
},
computed: {},
......@@ -71,13 +74,15 @@ export default {
typeName: {
immediate: true,
handler(val) {
// this.changeModelCode()
this.$set(this.cmpOptions, 'layKey', `outStorageUseApply_add_${val}`)
// this.formData.subTypeName = this.typeName
}
}
},
created() {},
created() {
this.$bus.$on('getApplyId', (data) => {
this.outStorageUseId = data
})
},
mounted() {
this.getUseRequestTypes()
},
......@@ -87,16 +92,36 @@ export default {
this.options = await this.$utils.getDicListByCode('UseRequestType')
},
changeVal(val) {
console.log('🚀 file: index.vue:40 val:', val)
},
dataChangeHandler(val) {
if (val) {
console.log('🚀 file: index.vue:99 val:', val)
this.formData = Object.assign({}, val)
this.formData.typeName = this.typeName
}
},
changeModelCode() {
},
cancelHandler(val) {
this.$confirm('此操作将解除已占用的操作, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
post(`OutStorageRequest/outStorageOut/delete?applyIds=${this.outStorageUseId}`).then(res => {
this.$message({
type: 'success',
message: '删除成功!'
})
this.$emit('cancel')
}).catch((err) => {
console.log(err)
})
}).catch(() => {
this.$message({
type: 'info',
message: '已取消删除'
})
})
}
}
}
......
......@@ -13,11 +13,11 @@
@row-click="handleRowClick"
/>
<el-form ref="applyForm" :rules="rules" :model="applyForm" class="applyForm">
<el-form-item label="申领数量" prop="reqAmount" label-width="100px">
<el-input-number v-model="applyForm.reqAmount" placeholder="申领数量" :min="0" size="small" />
<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 v-if="basicData.useRequestType!=='swapUse'" 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>
......@@ -35,6 +35,10 @@ export default {
type: Object,
default: () => {}
},
selectDatas: {
type: Array,
default: () => []
},
parentTableData: {
type: Object,
default: () => {}
......@@ -45,9 +49,10 @@ export default {
selection: null,
defaultData: {},
applyForm: {},
amountItemLabel: '申领数量',
rules: {
reqAmount: [
{ required: true, message: '请填写申领数量', trigger: 'blur' }
{ required: true, message: '该项必填', trigger: 'blur' }
]
}
}
......@@ -59,11 +64,25 @@ export default {
handler(val) {
console.log('val', val)
}
},
'basicData.useRequestType': {
immediate: true,
handler(val) {
switch (val) {
case 'useAO':
this.amountItemLabel = '申领数量'
break
case 'swapUse':
this.amountItemLabel = '换件数量'
break
default:
break
}
}
}
},
created() {
// 初始化数据
console.log('basicData', this.basicData)
},
methods: {
handleRowClick(val) {
......@@ -83,9 +102,12 @@ export default {
'unableAmount': this.selection.unableAmount,
'reqAmount': this.applyForm.reqAmount
}]
this.$emit('submitEvent', { formData: data, addContinue },)
if (this.basicData.useRequestType === 'swapUse') {
data[0].extSupportingItemVO = this.selectDatas[0].extSupportingItemVO
}
this.$emit('submitEvent', { formData: data, addContinue })
} else {
this.$utils.showMessageWarning('至少选择一条物料并且申领数量必填!')
this.$utils.showMessageWarning(`至少选择一条物料并且${this.amountItemLabel}必填!`)
return false
}
})
......
......@@ -9,10 +9,7 @@
ref="table"
:im-show-table-data="imShowTableData"
:basic-data="{...form,...basicData}"
:lay-config="{
typeName: 'OutStorageUseItem',
layKey: 'add_outStorageUseItem_instruct'
}"
:lay-config="cmpOptions"
table-height="auto"
:dis-business="true"
:result-data="tableData"
......@@ -40,7 +37,7 @@
</template>
<script>
import AddOutStorageUseDetailDialog from './components/AddOutStorageUseDetailDialog.vue'
import AddOutStorageUseDetailDialog from './components/AddOutStorageUseDetailDialog'
import AdjustOccupyCom from '../adjustOccupyCom'
import { post } from '@/utils/http'
export default {
......@@ -100,7 +97,11 @@ export default {
selectionRows: [],
tableData: [],
dialogTitle: '',
componentName: ''
componentName: '',
cmpOptions: {
typeName: 'OutStorageUseItem',
layKey: 'add_outStorageUseItem_useAO'
}
}
},
computed: {
......@@ -113,14 +114,34 @@ export default {
handler(data) {
this.$emit('input', data)
}
},
'basicData.useRequestType': {
immediate: true,
deep: true,
handler(val) {
this.$set(this.cmpOptions, 'layKey', `add_outStorageUseItem_${val}`)
}
}
},
created() {
this.$bus.$on('swapUseData', (data) => {
if (data && data.length) {
data.map(item => {
if (!this.tableData.find(row => row.extSupportingItemVO && row.extSupportingItemVO.id === item.id)) {
this.tableData.push({
extSupportingItemVO: item
})
}
})
}
})
},
methods: {
tableToolHandler(val) {
const btnValue = val.key.btnValue
switch (btnValue) {
case 'add':
this.openDialog('添加出库物料', 'AddOutStorageUseDetailDialog')
this.addHandle()
break
case 'occupy':
this.occupy()
......@@ -138,6 +159,18 @@ export default {
selectionChange(val) {
this.selectionRows = val
},
addHandle() {
const useRequestType = this.basicData.useRequestType
if (useRequestType === 'useAO') {
this.openDialog('添加出库物料', 'AddOutStorageUseDetailDialog')
} else if (useRequestType === 'swapUse') {
if (this.selectionRows && this.selectionRows.length === 1) {
this.openDialog('添加出库物料', 'AddOutStorageUseDetailDialog')
} else {
this.$utils.showMessageWarning('请勾选一条数据进行操作!')
}
}
},
occupy() {
const form = Object.assign({}, this.form)
form.aircraftType = form.aircraftType.split('+')[1]
......@@ -151,6 +184,7 @@ export default {
operator: 'ADD'
}
post('/OutStorageRequest/outStorageUse/saveAndTake', param).then(res => {
this.$bus.$emit('getApplyId', res.items.id)
this.form.id = res.items.id
const data = res.items.inStorageRequestItems
const tableData = [...this.tableData]
......@@ -199,7 +233,13 @@ export default {
type: 'success',
message: '删除成功!'
})
this.tableData = this.tableData.filter(item => !this.selectionRows.map(item => item.extMaterialId).includes(item.extMaterialId))
if (this.basicData.useRequestType === 'swapUse') {
this.tableData = this.tableData.filter(item => !this.selectionRows.map(item => item.extSupportingItemVO.id).includes(item.extSupportingItemVO.id))
this.$bus.$emit('removeItems', this.selectionRows)
} else {
this.tableData = this.tableData.filter(item => !this.selectionRows.map(item => item.extMaterialId).includes(item.extMaterialId))
}
}).catch((err) => {
console.log(err)
})
......@@ -211,7 +251,16 @@ export default {
})
},
submitEvent({ formData, addContinue }) {
this.tableData.push(...formData)
if (this.basicData.useRequestType === 'swapUse') {
this.tableData.forEach((item, index) => {
if (item.extSupportingItemVO && item.extSupportingItemVO.id === formData[0].extSupportingItemVO.id) {
// this.tableData[index] = formData[0]
this.$set(this.tableData, index, formData[0])
}
})
} else {
this.tableData.push(...formData)
}
this.dialogShow = addContinue || false
},
refreshResponses({ inventoryJobResponses }) {
......
<!--
* @Author: gjn
* @Date: 2023-09-03 10:39:00
* @Description:领用出库——换件物料
-->
<template>
<div :style="layoutStyle" class="AddOutStorageUseSwapUse">
<dee-as-com
ref="table"
:im-show-table-data="imShowTableData"
:basic-data="{...form,...basicData}"
:lay-config="{
typeName: 'OutStorageMatchItem',
layKey: 'outStorageUseMaterial_swapUse'
}"
table-height="300px"
:dis-business="true"
:result-data="tableData"
@tableToolHandler="tableToolHandler"
@selectionChange="selectionChange"
/>
</div>
</template>
<script>
export default {
componentName: '领用出库换件物料',
name: 'AddOutStorageUseSwapUse',
components: {},
props: {
basicData: {
type: Object,
default: () => {}
},
itemId: {
type: String,
default: () => ''
},
form: {
type: Object,
default: () => {
return {}
}
},
imShowTableData: {
type: Array,
default: () => {
return []
}
},
layoutStyle: {
type: Object,
default: () => {
return {}
}
}
},
data() {
return {
tableData: [],
selectionRows: []
}
},
computed: {},
watch: {
'form.aoNo': {
immediate: true,
handler(val) {
if (this.form.aoNo && this.form.sorties && this.form.extResourceTypeId) {
this.getTableData()
}
}
},
'form.sorties': {
immediate: true,
handler(val) {
if (this.form.aoNo && this.form.sorties && this.form.extResourceTypeId) {
this.getTableData()
}
}
},
'form.extResourceTypeId': {
immediate: true,
handler(val) {
if (this.form.aoNo && this.form.sorties && this.form.extResourceTypeId) {
this.getTableData()
}
}
}
},
created() {
this.$bus.$on('removeItems', (data) => {
if (data && data.length) {
const targetData = data.map(item => item.extSupportingItemVO)
this.dealRowIsSwapUse(targetData, '否')
}
})
},
mounted() {
// this.getTableData()
},
// 组件方法
methods: {
tableToolHandler(val) {
const btnValue = val.key.btnValue
switch (btnValue) {
case 'confirm':
this.confirmSwap()
break
default:
break
}
},
getTableData() {
this.tableData = []
const params = {
'pageFrom': 1,
'pageSize': 9999,
'searchItems': {
'items': [
{
'fieldName': 'extSupporting.extProcessPlanId',
'operator': 'EQ',
'value': this.form.aoNo
},
{
'fieldName': 'extMaterial.resType2Id',
'operator': 'EQ',
'value': this.form.extResourceTypeId
},
{
'fieldName': 'sorties',
'operator': 'EQ',
'value': this.form.sorties.split('+')[1]
}
// 勿删,测试所需数据
// {
// 'fieldName': 'extSupporting.extProcessPlanId',
// 'operator': 'EQ',
// 'value': '204662455135000'
// },
// {
// 'fieldName': 'extMaterial.resType2Id',
// 'operator': 'EQ',
// 'value': '195492405035000'
// },
// {
// 'fieldName': 'sorties',
// 'operator': 'EQ',
// 'value': '1003'
// }
],
'operator': 'AND'
},
'openProps': [
{
'name': 'extMaterial',
'openProps': [
{
'name': 'resType2'
}
]
}
],
'sortItem': [
{
'fieldName': 'modifyTime',
'sortOrder': 'desc'
}
]
}
this.$api.searchApi(`ExtSupportingItem`, params).then(res => {
if (!res.items || !res.items.content) return
this.tableData = res.items.content.map(item => {
item.isSwapUse = '否'
return item
})
// this.$bus.$emit('swapUseData', [])
}).catch((err) => {
console.log(err)
})
},
selectionChange(val) {
this.selectionRows = val
},
confirmSwap() {
const swapUseData = this.selectionRows.filter(row => row.isSwapUse !== '是')
this.$bus.$emit('swapUseData', swapUseData)
this.dealRowIsSwapUse(this.selectionRows, '是')
},
dealRowIsSwapUse(data, isSwapUse) {
data.map(item => {
const oriData = JSON.parse(JSON.stringify(this.tableData))
this.tableData = oriData.map(row => {
if (row && row.id === item.id) {
row.isSwapUse = isSwapUse
}
return row
})
})
}
}
}
</script>
<style lang='scss'>
</style>
......@@ -89,7 +89,7 @@ export default {
this.options = res.items.content.map((item) => {
return {
label: item.serialNumber,
value: item.serialNumber
value: item.id + ''
}
})
} else {
......
......@@ -90,6 +90,7 @@ export default {
},
// 手动占用
occupy() {
if (!this.infoSelection || !this.infoSelection.length) return this.$utils.showMessageWarning('请勾选需要占用的数据!')
const param = this.infoSelection.map(item => {
if (item.allocatedAmount === 0 || !item.hasOwnProperty('allocatedAmount')) {
return this.$utils.showMessageWarning('请输入分配数量!')
......
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