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