Authored by 邱骏

TDK批量导入修改提示

... ... @@ -180,7 +180,7 @@ r.post('/save', async (ctx) => {
return ctx.response.body = result;
});
r.post('/upload', async(ctx) => {
r.post('/upload', async(ctx) => { // 导入关键词EXCEL
if (ctx.request.body._files) {
let file = ctx.request.body._files.up_excel;
const workbook = xlsx.readFile(file.path);
... ... @@ -201,7 +201,7 @@ r.post('/upload', async(ctx) => {
});
console.log(post_data);
if (post_data.length > 0) {
return Req({
return Req({ // 传数据给爬虫接口
method: 'POST',
uri: 'http://spiderwebhook.yoho.cn/importApiHot', // 'http://172.16.6.84:9100/importApiHot',
body: {
... ...
... ... @@ -231,6 +231,7 @@ const tdk = {
let json_data = xlsx.utils.sheet_to_json(worksheet);
let post_data = [];
let success = 0;
// 处理EXCEL数据,并插入redis
let createRedisData = async function (ctx, data, index) {
... ... @@ -266,7 +267,7 @@ const tdk = {
ctx.redis.lpush(`tdk:${type}:links`, hashKey);
}
}
success += 1;
return createRedisData(ctx, data, index + 1);
} else {
... ... @@ -276,7 +277,7 @@ const tdk = {
result = {
code: 200,
data: data,
message: `导入完成${index}条`
message: `导入完成${success}条`
};
console.log(result);
ctx.response.body = result;
... ...
... ... @@ -429,8 +429,10 @@
contentType: false,
success: function(res) {
if(res.code === 200) {
alert('上传完成!');
alert(res.message);
document.location.reload();
} else {
alert('导入失败!');
}
}
});
... ...