Authored by 郝肖肖

'task-del-all'

... ... @@ -662,10 +662,11 @@ const task = {
},
del: async(ctx, next) => {
let params = ctx.request.body || {};
let key_name = JOB_TASK[parseInt(`0${params.type}`)];
let field_name = params.code || '';
let data = JSON.parse(_.get(ctx.request.body, 'data', '[]'));
return ctx.redis.hdelAsync(key_name.k, field_name).then(status => {
ctx.redis.multi(
_.map(data, job => ['hdel', JOB_TASK[parseInt(`0${job.tpe}`)].k || '', job.code || ''])
).execAsync().then(status => {
return ctx.body = {
code: 200,
message: 'success',
... ...
... ... @@ -87,60 +87,41 @@
var that = this;
this.$base = $('.contentpanel');
this.$popTitle = $('.cover-title', this.$base);
this.$base.on('change', '#select-type', function() {
if ($(this).val() === 'img') {
that.$imgLink.removeClass('hide');
} else {
that.$imgLink.addClass('hide');
}
}).on('click', '.clear-input', function() {
that.clearInput();
}).on('click', '.sure-btn', function() {
var data;
if (that.saving) {
return;
}
data = that.packReqData();
if (!data) {
that.$errTip.text('请填写完整友链信息');
return;
}
// 单个删除
this.$base.on('click', '.del-btn', function() {
let $tr = $(this).closest('tr');
that.del([$tr.data()]).then(result => {
result && $tr.remove();
});
});
that.saving = true;
// 删除全部
this.$base.on('click', '.delete-all', function() {
let arr = [];
$.ajax({
url: that.editInfo ? '/seo/friendlink/edit' : '/seo/friendlink/add',
type: 'POST',
data: data,
}).done(function(res) {
if (res.code === 200) {
history.go(0);
}
}).always(function() {
that.saving = false;
$('.tab-task input[type=checkbox]:checked').each(function(){
arr.push($(this).closest('tr').data());
});
});
// 单个删除
this.$base.on('click', '.del-btn', function() {
let $tr = $(this).closest('tr');
that.del($tr.data()).then(() => {
$tr.remove();
that.del(arr).then(result => {
result && history.go(0);
});
});
},
del: function(data) {
return $.ajax({
url: '/seo/task/del',
type: 'POST',
data: data,
});
if (confirm('您确定要删除吗!!!') && data.length) {
return this.ajax({
url: '/seo/task/del',
type: 'POST',
data: {data: JSON.stringify(data)},
});
} else {
return Promise.resolve(false);
}
},
ajax: function(options) {
return Promise.resolve($.ajax(options));
}
};
... ...