浏览代码

feat: add start-progress action (ASSIGNED → IN_PROGRESS)

YY968XX 3 月之前
父节点
当前提交
3f9e806831

+ 2 - 0
Web/src/views/aidop/s8/api/s8ExceptionApi.ts

@@ -80,6 +80,8 @@ export const s8ExceptionApi = {
 		service.post(`/api/aidop/s8/exceptions/${id}/reject`, body ?? {}).then(unwrap),
 	close: (id: number, body?: { remark?: string }) =>
 		service.post(`/api/aidop/s8/exceptions/${id}/close`, body ?? {}).then(unwrap),
+	startProgress: (id: number, body?: { remark?: string }, currentUserId?: number) =>
+		service.post(`/api/aidop/s8/exceptions/${id}/start-progress?currentUserId=${currentUserId ?? 0}`, body ?? {}).then(unwrap),
 	comment: (id: number, body?: { remark?: string }) =>
 		service.post(`/api/aidop/s8/exceptions/${id}/comment`, body ?? {}).then(unwrap),
 	submitVerification: (id: number, body: { verifierId: number; remark?: string }, currentUserId: number) =>

+ 5 - 0
Web/src/views/aidop/s8/exceptions/S8TaskDetailPage.vue

@@ -30,6 +30,7 @@ const currentStatus = computed(() => String(detail.value?.status || ''));
 const hasActiveFlow = computed(() => !!detail.value?.activeFlowInstanceId);
 const activeBizType = computed(() => detail.value?.activeFlowBizType ?? '');
 const canClaim = computed(() => currentStatus.value === 'NEW');
+const canStartProgress = computed(() => currentStatus.value === 'ASSIGNED');
 const canTransfer = computed(() => !['', 'CLOSED'].includes(currentStatus.value));
 const canUpgrade = computed(() => !hasActiveFlow.value && ['ASSIGNED', 'IN_PROGRESS'].includes(currentStatus.value));
 const canReject = computed(() => ['NEW', 'ASSIGNED', 'IN_PROGRESS'].includes(currentStatus.value));
@@ -85,6 +86,7 @@ function actionTitle() {
 	return (
 		{
 			claim: '认领',
+			startProgress: '开始处理',
 			transfer: '转派',
 			upgrade: '升级',
 			reject: '驳回',
@@ -121,6 +123,8 @@ async function submitAction() {
 	try {
 		if (dialogMode.value === 'claim') {
 			await s8ExceptionApi.claim(id, { assigneeId: actionForm.assigneeId!, remark: actionForm.remark || undefined });
+		} else if (dialogMode.value === 'startProgress') {
+			await s8ExceptionApi.startProgress(id, { remark: actionForm.remark || undefined }, currentUserId.value);
 		} else if (dialogMode.value === 'transfer') {
 			await s8ExceptionApi.transfer(id, { assigneeId: actionForm.assigneeId!, remark: actionForm.remark || undefined });
 		} else if (dialogMode.value === 'upgrade') {
@@ -204,6 +208,7 @@ onMounted(async () => {
 						<template v-else>
 							<div class="action-grid">
 								<el-button type="primary" :disabled="!canClaim" @click="openAction('claim')">认领</el-button>
+								<el-button type="primary" :disabled="!canStartProgress" @click="openAction('startProgress')">开始处理</el-button>
 								<el-button :disabled="!canTransfer" @click="openAction('transfer')">转派</el-button>
 								<el-button type="warning" :disabled="!canUpgrade" @click="openAction('upgrade')">升级</el-button>
 								<el-button type="danger" :disabled="!canReject" @click="openAction('reject')">驳回</el-button>

+ 12 - 0
server/Plugins/Admin.NET.Plugin.AiDOP/Controllers/S8/AdoS8ExceptionsController.cs

@@ -76,6 +76,18 @@ public class AdoS8ExceptionsController : ControllerBase
         catch (S8BizException ex) { return BadRequest(new { message = ex.Message }); }
     }
 
+    [HttpPost("{id:long}/start-progress")]
+    public async Task<IActionResult> StartProgressAsync(long id, [FromQuery] long tenantId = 1, [FromQuery] long factoryId = 1,
+        [FromQuery] long currentUserId = 0, [FromBody] AdoS8CommentDto? body = null)
+    {
+        try
+        {
+            var e = await _taskFlowSvc.StartProgressAsync(id, tenantId, factoryId, currentUserId, body?.Remark);
+            return Ok(new { id = e.Id, status = e.Status });
+        }
+        catch (S8BizException ex) { return BadRequest(new { message = ex.Message }); }
+    }
+
     [HttpPost("{id:long}/upgrade")]
     public async Task<IActionResult> UpgradeAsync(long id, [FromQuery] long tenantId = 1, [FromQuery] long factoryId = 1,
         [FromBody] AdoS8CommentDto? body = null)

+ 19 - 0
server/Plugins/Admin.NET.Plugin.AiDOP/Service/S8/S8TaskFlowService.cs

@@ -60,6 +60,25 @@ public class S8TaskFlowService : ITransient
         return e;
     }
 
+    public async Task<AdoS8Exception> StartProgressAsync(long id, long tenantId, long factoryId, long currentUserId, string? remark)
+    {
+        var e = await LoadAsync(id, tenantId, factoryId) ?? throw new S8BizException("异常不存在");
+        if (!S8StatusRules.IsAllowedTransition(e.Status, "IN_PROGRESS"))
+            throw new S8BizException($"状态 {e.Status} 不可开始处理");
+
+        var fromStatus = e.Status;
+        e.Status = "IN_PROGRESS";
+        e.UpdatedAt = DateTime.Now;
+
+        await _rep.AsTenant().UseTranAsync(async () =>
+        {
+            await _rep.UpdateAsync(e);
+            await InsertTimelineAsync(e.Id, "START_PROGRESS", "开始处理", fromStatus, "IN_PROGRESS", currentUserId, null, remark);
+        }, ex => throw ex);
+
+        return e;
+    }
+
     public async Task<AdoS8Exception> UpgradeAsync(long id, long tenantId, long factoryId, string? remark)
     {
         var e = await LoadAsync(id, tenantId, factoryId) ?? throw new S8BizException("异常不存在");