Compare commits

..

No commits in common. "65984ae4a0ad8ce46285f43bbda40f03f70e3684" and "72f04fdbbaeb3cca303dc58d4856b1badf57992b" have entirely different histories.

2 changed files with 114 additions and 15 deletions

74
wwwroot/pipeline_task.js Normal file
View File

@ -0,0 +1,74 @@
// pipeline_task.js — 产线任务交互辅助函数
var currentTaskId = '';
// 加载任务列表
function loadTaskList() {
var filterPipeline = $('[name="filter_pipeline"]').val() || '';
var url = entire_url('api/task_list.dspy');
if (filterPipeline) {
url += '?pipeline_id=' + filterPipeline;
}
$.get(url, function(resp) {
var data = typeof resp === 'string' ? JSON.parse(resp) : resp;
if (!data.success) {
$('#task_table_area').html('<div class="alert error">' + (data.message || '加载失败') + '</div>');
return;
}
var tasks = data.tasks || [];
if (tasks.length === 0) {
$('#task_table_area').html('<div class="empty-state">暂无任务</div>');
return;
}
var html = '<table class="data-table"><thead><tr>';
html += '<th>任务ID</th><th>标题</th><th>状态</th><th>版本</th><th>创建时间</th><th>操作</th>';
html += '</tr></thead><tbody>';
tasks.forEach(function(t) {
html += '<tr>';
html += '<td>' + (t.id || '').substring(0, 8) + '</td>';
html += '<td>' + (t.title || '') + '</td>';
html += '<td><span class="badge state-' + (t.state || '') + '">' + (t.state || '') + '</span></td>';
html += '<td>v' + (t.current_version || 1) + '</td>';
html += '<td>' + (t.created_at || '') + '</td>';
html += '<td><button class="btn-small" onclick="viewTask(\'' + t.id + '\')">查看</button></td>';
html += '</tr>';
});
html += '</tbody></table>';
$('#task_table_area').html(html);
});
}
// 查看任务详情
function viewTask(taskId) {
currentTaskId = taskId;
var url = entire_url('task_detail.ui');
window.location.href = url + '?task_id=' + taskId;
}
// 控制任务(暂停/恢复/取消)
function controlTask(action) {
if (!currentTaskId) return;
var url = entire_url('api/task_control.dspy');
$.post(url, {task_id: currentTaskId, action: action}, function(resp) {
var data = typeof resp === 'string' ? JSON.parse(resp) : resp;
if (data.success) {
alert('操作成功: ' + data.message);
location.reload();
} else {
alert('操作失败: ' + (data.message || '未知错误'));
}
});
}
// 页面加载完成
$(function() {
if ($('#task_table_area').length > 0) {
loadTaskList();
}
});

View File

@ -1,17 +1,42 @@
{
"widgettype": "DataViewer",
"options": {
"url": "{{entire_url('/pipeline_task/api/task_list.dspy')}}",
"title": "任务中心",
"pageSize": 20,
"new_data_url": "{{entire_url('/pipeline_task/task_submit.ui')}}",
"fields": [
{"name": "id", "title": "任务ID", "width": "120px"},
{"name": "title", "title": "标题", "width": "30%"},
{"name": "pipeline_type", "title": "产线类型", "width": "100px"},
{"name": "state", "title": "状态", "width": "100px"},
{"name": "current_version", "title": "版本", "width": "80px"},
{"name": "created_at", "title": "创建时间", "width": "160px"}
]
}
"widgettype": "VBox",
"options": {"width": "100%", "padding": "16px"},
"subwidgets": [
{
"widgettype": "HBox",
"options": {"width": "100%", "marginBottom": "16px", "gap": "12px"},
"subwidgets": [
{
"widgettype": "Input",
"options": {"name": "filter_pipeline", "placeholder": "按产线筛选", "width": "200px"}
},
{
"widgettype": "Button",
"options": {"label": "查询", "icon": "search"},
"binds": [{
"wid": "self", "event": "click", "actiontype": "script",
"target": "task_table_area",
"script": "loadTaskList();"
}]
},
{
"widgettype": "Button",
"options": {"label": "刷新", "icon": "refresh"},
"binds": [{
"wid": "self", "event": "click", "actiontype": "script",
"target": "task_table_area",
"script": "loadTaskList();"
}]
}
]
},
{
"widgettype": "VBox",
"id": "task_table_area",
"options": {"width": "100%", "flex": "1", "minHeight": "400px", "bgcolor": "var(--card-bg)", "padding": "16px"},
"subwidgets": [
{"widgettype": "Text", "options": {"text": "加载中..."}}
]
}
]
}