Commit 08dda679 authored by jingnan's avatar jingnan 👀

采购入库导入修改

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