请加入操作按钮 审核,点击之后 状态从草稿变成已排期状态。只有草稿状态审核按钮才显示。
This commit is contained in:
@@ -416,3 +416,47 @@ def upload_file():
|
||||
'success': False,
|
||||
'message': '不支持的文件类型'
|
||||
})
|
||||
|
||||
|
||||
@message_push_bp.route('/api/tasks/<task_id>/audit', methods=['POST'])
|
||||
@login_required
|
||||
def audit_task(task_id):
|
||||
"""审核任务"""
|
||||
try:
|
||||
# 获取任务信息
|
||||
db = current_app.dashboard_server.task_db
|
||||
task = db.get_task(task_id)
|
||||
if not task:
|
||||
return jsonify({
|
||||
'success': False,
|
||||
'message': '任务不存在'
|
||||
})
|
||||
|
||||
# 检查任务状态
|
||||
if task['status'] != 'draft':
|
||||
return jsonify({
|
||||
'success': False,
|
||||
'message': '只能审核草稿状态的任务'
|
||||
})
|
||||
|
||||
# 更新任务状态为已排期
|
||||
db.update_task(task_id, {'status': 'scheduled'})
|
||||
|
||||
# 记录操作日志
|
||||
db.log_task_action({
|
||||
'log_id': f"log_{datetime.now().strftime('%Y%m%d%H%M%S')}",
|
||||
'task_id': task_id,
|
||||
'action': 'audit',
|
||||
'user_id': session.get('user_id'),
|
||||
'changes': {'status': 'scheduled'}
|
||||
})
|
||||
|
||||
return jsonify({
|
||||
'success': True,
|
||||
'message': '审核成功'
|
||||
})
|
||||
except Exception as e:
|
||||
return jsonify({
|
||||
'success': False,
|
||||
'message': f'审核失败: {str(e)}'
|
||||
})
|
||||
|
||||
@@ -141,6 +141,13 @@
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="300">
|
||||
<template slot-scope="scope">
|
||||
<el-button
|
||||
{% raw %}v-if="scope.row.status === 'draft'" {% endraw %}
|
||||
size="mini"
|
||||
type="success"
|
||||
{% raw %}@click="auditTask(scope.row)" {% endraw %}>
|
||||
审核
|
||||
</el-button>
|
||||
<el-button
|
||||
size="mini"
|
||||
type="primary"
|
||||
@@ -761,6 +768,19 @@ new Vue({
|
||||
this.loadTasks();
|
||||
this.loadStatistics();
|
||||
this.$message.success('数据已刷新');
|
||||
},
|
||||
// 审核任务
|
||||
async auditTask(task) {
|
||||
try {
|
||||
const response = await axios.post(`/message_push/api/tasks/${task.task_id}/audit`);
|
||||
if (response.data.success) {
|
||||
this.$message.success('任务已审核通过');
|
||||
this.loadTasks();
|
||||
this.loadStatistics();
|
||||
}
|
||||
} catch (error) {
|
||||
this.$message.error('审核任务失败');
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user