Commit 08dda679 authored by jingnan's avatar jingnan 👀

采购入库导入修改

parent 3774a0c4
......@@ -122,13 +122,25 @@ export default {
},
// 上传excel
upLoadExcel(id, isNew) {
const reqParams = {
id: this.param.id || id || '',
billType: this.param.billType || '',
arrivalDate: this.param.arrivalDate || '',
materialTypeId: this.param.materialTypeId || '',
extDxProductAreaId: this.param.extDxProductAreaId || '',
extDxSipplierId: this.param.extDxSipplierId || ''
}
const arrReaParams = []
for (const key in reqParams) {
arrReaParams.push(`${key}=${reqParams[key] || ''}`)
}
const formData = new FormData()
formData.append('file', this.file.raw)
this.$api.apiUploadFile(`/InStorageRequestItem/importByExcel?id=${id}`, formData).then(res => { // 调用接口
this.$api.apiUploadFile(`/InStorageRequestItem/importByExcel?${arrReaParams.join('&')}`, formData).then(res => { // 调用接口
this.uploading = false
this.$utils.showMessageSuccess(res.data.message)
const reqId = isNew ? id : null
this.$emit('refreshTable', reqId)
const reqObj = isNew ? res.data.items : null
this.$emit('refreshTable', reqObj)
this.close()
}).catch(err => {
this.uploading = false
......
......@@ -490,7 +490,7 @@ export default {
importParam: function() {
if (this.form.id) {
return {
'id': this.form.id
...this.form
}
} else {
return {
......@@ -652,8 +652,9 @@ export default {
})
},
// 编辑采购入库明细查询InStorageRequestItem/search
searchInStorageRequestItem(id) {
this.newDataImportResId = id
searchInStorageRequestItem(reqObj) {
!this.form.id && reqObj && typeof (reqObj.id) === 'number' && (this.form = JSON.parse(JSON.stringify(reqObj)))
this.newDataImportResId = reqObj && reqObj.id || ''
const param = {
'rootCondition': {
'pageFrom': this.pagination.currentPage,
......@@ -665,7 +666,7 @@ export default {
{
'fieldName': 'inventoryReq.id',
'operator': 'EQ',
'value': id || this.currBasicData.id
'value': reqObj && reqObj.id || this.currBasicData && this.currBasicData.id
},
{
'fieldName': 'isRoot',
......@@ -820,54 +821,60 @@ export default {
this.treeTableNoArrange(tableData)
},
submit(saveAndImport, newData) {
const tableData = this.submitData.slice()
tableData.forEach((obj, i) => {
for (const key in obj) {
if (key === 'storageZone') {
delete tableData[i][key]
// 导入时如果存在明细先调用保存接口再导入,如果不存在明细直接调用导入接口
if (this.submitData && this.submitData.length) {
const tableData = this.submitData.slice()
tableData.forEach((obj, i) => {
for (const key in obj) {
if (key === 'storageZone') {
delete tableData[i][key]
}
}
}
if (obj.children.length > 0) {
obj.children.forEach((child, j) => {
for (const ckey in child) {
if (ckey === 'storageZone') {
delete tableData[i]['children'][j][ckey]
if (obj.children.length > 0) {
obj.children.forEach((child, j) => {
for (const ckey in child) {
if (ckey === 'storageZone') {
delete tableData[i]['children'][j][ckey]
}
}
}
})
})
}
})
const isVirtualHasChild = tableData.find(item => item.isVirtual && item.operator !== 'REMOVE' && (!item.children || !item.children.length || item.children && !(item.children.find(child => child.operator !== 'REMOVE'))))
if (isVirtualHasChild) return this.$utils.showMessageWarning('父件为虚拟件时,必须添加子件!')
const paramOperator = this.newDataImportResId ? 'MODIFY' : this.operator
const param = {
'operator': paramOperator,
'billType': this.form.billType,
'arrivalDate': this.form.arrivalDate,
'materialTypeIdType': 'ExtDxProcessResourceType',
'extDxProductAreaIdType': 'ExtDxProductArea',
'extDxSipplierIdType': 'ExtDxSipplier',
'subTypeName': 'InStoragePurchase',
'reqStatus': this.form.id ? this.form.reqStatus : 'Apply',
'extDxProductAreaId': this.form.extDxProductAreaId,
'extDxSipplierId': this.form.extDxSipplierId,
'materialTypeId': this.form.materialTypeId,
'inStorageRequestItems': tableData
}
})
const isVirtualHasChild = tableData.find(item => item.isVirtual && item.operator !== 'REMOVE' && (!item.children || !item.children.length || item.children && !(item.children.find(child => child.operator !== 'REMOVE'))))
if (isVirtualHasChild) return this.$utils.showMessageWarning('父件为虚拟件时,必须添加子件!')
const paramOperator = this.newDataImportResId ? 'MODIFY' : this.operator
const param = {
'operator': paramOperator,
'billType': this.form.billType,
'arrivalDate': this.form.arrivalDate,
'materialTypeIdType': 'ExtDxProcessResourceType',
'extDxProductAreaIdType': 'ExtDxProductArea',
'extDxSipplierIdType': 'ExtDxSipplier',
'subTypeName': 'InStoragePurchase',
'reqStatus': this.form.id ? this.form.reqStatus : 'Apply',
'extDxProductAreaId': this.form.extDxProductAreaId,
'extDxSipplierId': this.form.extDxSipplierId,
'materialTypeId': this.form.materialTypeId,
'inStorageRequestItems': tableData
}
if (paramOperator === 'MODIFY') {
param.id = this.newDataImportResId || this.form.id
}
post('/InventoryRequest/batch/recursionAdd', param).then(res => {
if (saveAndImport === 'saveAndImport') {
this.$refs.importFile.upLoadExcel(res.items.id, newData)
this.form = this.$utils.deepClone(res.items)
} else {
this.cancel()
this.$utils.showMessageSuccess('保存成功')
if (paramOperator === 'MODIFY') {
param.id = this.newDataImportResId || this.form.id
}
}).catch((err) => {
console.log(err)
})
post('/InventoryRequest/batch/recursionAdd', param).then(res => {
if (saveAndImport === 'saveAndImport') {
this.$refs.importFile.upLoadExcel(res.items.id, newData)
this.form = this.$utils.deepClone(res.items)
} else {
this.cancel()
this.$utils.showMessageSuccess('保存成功')
}
}).catch((err) => {
console.log(err)
})
} else {
if (saveAndImport !== 'saveAndImport') return this.$utils.showMessageWarning('请添加明细!')
this.$refs.importFile.upLoadExcel(this.form.id, newData)
}
},
treeTableNoArrange(tableData, type) {
if (type !== 'remove') {
......
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