|
|
|
@ -519,7 +519,16 @@ export default { |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
handleId(res) |
|
|
|
|
function handleDisabled (list) { |
|
|
|
|
list.map(e => { |
|
|
|
|
if (e.children && e.children.length) { |
|
|
|
|
if (e.children.every(e => e.disabled)) e.disabled = true |
|
|
|
|
handleDisabled(e.children) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
setTimeout(() => { |
|
|
|
|
handleDisabled(res) |
|
|
|
|
this.importTypeList = res |
|
|
|
|
},500) |
|
|
|
|
}).catch(res => {}) |
|
|
|
@ -581,9 +590,17 @@ export default { |
|
|
|
|
}).catch(res => {}) |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
saveSuccess() { |
|
|
|
|
this.$message.success('导入成功') |
|
|
|
|
this.getData() |
|
|
|
|
this.importVisible = false |
|
|
|
|
setTimeout(() => { |
|
|
|
|
this.submited = false |
|
|
|
|
},1000) |
|
|
|
|
}, |
|
|
|
|
confirmImport(){ |
|
|
|
|
if(this.submited) return false |
|
|
|
|
const checked = this.$refs.typeTree.getCheckedNodes() // 勾选的数据 |
|
|
|
|
const checked = this.$refs.typeTree.getCheckedNodes().filter(e => !e.disabled) // 勾选的数据 |
|
|
|
|
// 如果没有选择任何数据 |
|
|
|
|
if(!checked.length) return this.$message.warning('请选择数据') |
|
|
|
|
this.submited = true |
|
|
|
@ -607,25 +624,50 @@ export default { |
|
|
|
|
dataList.push(data.slice(i, i + 2000)) |
|
|
|
|
} |
|
|
|
|
const promiseList = [] |
|
|
|
|
dataList.map(e => { |
|
|
|
|
promiseList.push(new Promise((resolve,reject) => { |
|
|
|
|
this.$post(this.api.saveTable, e).then(res => { |
|
|
|
|
resolve() |
|
|
|
|
}).catch(res => { |
|
|
|
|
reject() |
|
|
|
|
if (dataList.length > 6) { |
|
|
|
|
dataList.slice(0, 6).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 => { |
|
|
|
|
dataList.slice(6).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(() => { |
|
|
|
|
Promise.all(promiseList).then(res => { |
|
|
|
|
this.saveSuccess() |
|
|
|
|
}).catch(err => { |
|
|
|
|
this.submited = false |
|
|
|
|
}) |
|
|
|
|
}).catch(err => { |
|
|
|
|
this.submited = false |
|
|
|
|
},1000) |
|
|
|
|
}).catch(err => { |
|
|
|
|
this.submited = false |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
} else { |
|
|
|
|
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.saveSuccess() |
|
|
|
|
}).catch(err => { |
|
|
|
|
this.submited = false |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
} else { |
|
|
|
|
this.$post(this.api.saveTable, tableIds).then(res => { |
|
|
|
|