|
|
@ -25,7 +25,7 @@ |
|
|
|
<el-upload :show-file-list="false" v-model="fileOriData" :before-upload="beforeAvatarUpload" |
|
|
|
:http-request="successSubmit" accept=".txt" |
|
|
|
style="display: inline-block;position: relative;top: 3px;left: 12px;margin-right: 24px;" multiple> |
|
|
|
<el-button type="success" size="large"> |
|
|
|
<el-button type="success" size="large" :disabled="!!count"> |
|
|
|
<el-icon> |
|
|
|
<Upload /> |
|
|
|
</el-icon> |
|
|
@ -90,9 +90,25 @@ export default { |
|
|
|
emits: ["updateData"], |
|
|
|
watch: { |
|
|
|
count: { |
|
|
|
handler: function (val) { |
|
|
|
handler: function (val, ovl) { |
|
|
|
if (val == 0) { |
|
|
|
ElMessage.closeAll() |
|
|
|
ElMessage({ |
|
|
|
message: `正在将${this.fileData.length}数据存入数据库中,请稍后`, |
|
|
|
type: "info", |
|
|
|
grouping: true, |
|
|
|
showClose: true, |
|
|
|
duration: 0, |
|
|
|
}) |
|
|
|
this.submitImport() |
|
|
|
} else if (val <= ovl) { |
|
|
|
ElMessage({ |
|
|
|
message: `正在处理,请稍后`, |
|
|
|
type: "warning", |
|
|
|
grouping: true, |
|
|
|
showClose: true, |
|
|
|
duration: 0, |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -210,6 +226,8 @@ export default { |
|
|
|
ElMessage({ |
|
|
|
message: `Error reading file:, ${error}`, |
|
|
|
type: 'error', |
|
|
|
duration: 0, |
|
|
|
showClose: true, |
|
|
|
}) |
|
|
|
} |
|
|
|
fileReader.readAsText(file, 'UTF-8') |
|
|
@ -256,7 +274,8 @@ export default { |
|
|
|
//确认提交 |
|
|
|
async submitImport() { |
|
|
|
let that = this |
|
|
|
let skuObj = _.groupBy(this.fileData, 'SKU') |
|
|
|
let fileDataTemp = _.unionBy(this.fileData, o => `${o["唯一码"]}${o.SKU}`) |
|
|
|
let skuObj = _.groupBy(fileDataTemp, 'SKU') |
|
|
|
let skuList = _.keys(skuObj) |
|
|
|
let ziliaocollection = myDatabase.ziliao |
|
|
|
if (skuList.length) { |
|
|
@ -276,7 +295,12 @@ export default { |
|
|
|
let value = skuObj[key] |
|
|
|
let ziliaoItem = _.find(ziliaoList, { SKU: key }) || {} |
|
|
|
if (_.isEmpty(ziliaoItem)) { |
|
|
|
ElMessage.error(`资料表中找不到SKU为${key}的数据,请先完善资料数据`) |
|
|
|
ElMessage({ |
|
|
|
message: `资料表中找不到SKU为${key}的数据,请先完善资料数据`, |
|
|
|
type: "error", |
|
|
|
duration: 0, |
|
|
|
showClose: true, |
|
|
|
}) |
|
|
|
this.fileData = [] |
|
|
|
this.$emit("updateData", "ziliao") |
|
|
|
return |
|
|
@ -342,15 +366,16 @@ export default { |
|
|
|
} |
|
|
|
} |
|
|
|
try { |
|
|
|
console.log(346, allList); |
|
|
|
await myDatabase.shujuchuli.bulkAdd(allList) |
|
|
|
this.cancelDialog() |
|
|
|
ElMessage.closeAll() |
|
|
|
await that.updateSeach() |
|
|
|
} catch (error) { |
|
|
|
console.log(351, error); |
|
|
|
ElMessage({ |
|
|
|
message: `销售数据重复,error:${error}`, |
|
|
|
type: 'error', |
|
|
|
duration: 0, |
|
|
|
showClose: true, |
|
|
|
}) |
|
|
|
} |
|
|
|
await that.updateSeach() |
|
|
@ -367,7 +392,9 @@ export default { |
|
|
|
ElMessage( |
|
|
|
{ |
|
|
|
type: "error", |
|
|
|
message: "时间不允许重复,请重新设置时间" |
|
|
|
message: "时间不允许重复,请重新设置时间", |
|
|
|
duration: 0, |
|
|
|
showClose: true, |
|
|
|
} |
|
|
|
) |
|
|
|
} |
|
|
@ -590,6 +617,8 @@ export default { |
|
|
|
ElMessage({ |
|
|
|
type: 'error', |
|
|
|
message: '当前表格无数据,请有数据后在导出', |
|
|
|
duration: 0, |
|
|
|
showClose: true, |
|
|
|
}) |
|
|
|
} |
|
|
|
}, |
|
|
|