|
|
|
@ -576,16 +576,32 @@ export default { |
|
|
|
|
const checked = this.$refs.typeTree.getCheckedNodes() // 勾选的数据 |
|
|
|
|
// 如果没有选择任何数据 |
|
|
|
|
if(!checked.length) return this.$message.warning('请选择数据') |
|
|
|
|
this.submited = true |
|
|
|
|
const typeIds = checked.filter(e => !e.name).map(e => e.realId) // 先筛选出分类id,再获取分类真正的id |
|
|
|
|
this.getNames(typeIds).then(() => { |
|
|
|
|
this.$post(this.api.saveTable, this.names).then(res => { |
|
|
|
|
const data = this.names |
|
|
|
|
const dataList = [] |
|
|
|
|
for (let i = 0, len = data.length; i < len; i += 3000) { |
|
|
|
|
dataList.push(data.slice(i, i + 3000)) |
|
|
|
|
} |
|
|
|
|
const promiseList = [] |
|
|
|
|
dataList.map(e => { |
|
|
|
|
promiseList.push(new Promise((resolve,reject) => { |
|
|
|
|
this.$post(this.api.saveTable, e).then(res => { |
|
|
|
|
resolve() |
|
|
|
|
}).catch(res => { |
|
|
|
|
reject() |
|
|
|
|
}) |
|
|
|
|
})) |
|
|
|
|
}) |
|
|
|
|
Promise.all(promiseList).then(res => { |
|
|
|
|
this.$message.success('导入成功') |
|
|
|
|
this.getData() |
|
|
|
|
this.importVisible = false |
|
|
|
|
setTimeout(() => { |
|
|
|
|
this.submited = false |
|
|
|
|
},1000) |
|
|
|
|
}).catch(res => { |
|
|
|
|
}).catch(err => { |
|
|
|
|
this.submited = false |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|