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,6 +821,8 @@ export default { ...@@ -820,6 +821,8 @@ export default {
this.treeTableNoArrange(tableData) this.treeTableNoArrange(tableData)
}, },
submit(saveAndImport, newData) { submit(saveAndImport, newData) {
// 导入时如果存在明细先调用保存接口再导入,如果不存在明细直接调用导入接口
if (this.submitData && this.submitData.length) {
const tableData = this.submitData.slice() const tableData = this.submitData.slice()
tableData.forEach((obj, i) => { tableData.forEach((obj, i) => {
for (const key in obj) { for (const key in obj) {
...@@ -868,6 +871,10 @@ export default { ...@@ -868,6 +871,10 @@ export default {
}).catch((err) => { }).catch((err) => {
console.log(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