feat(workspace): 增加工作活动日报引擎
This commit is contained in:
@@ -4,6 +4,12 @@ import type { Bug, BugStatus, BugLog } from '@/lib/bug';
|
||||
import { generateBugNo } from '@/lib/bug';
|
||||
import { applyBugTransition } from '@/lib/bug-workflow';
|
||||
import { loadServerData, saveServerData } from '@/lib/server-data';
|
||||
import {
|
||||
makeBugCreatedActivity,
|
||||
makeBugStatusActivity,
|
||||
makeBugTransferredActivity,
|
||||
} from '@/lib/work-activity-factory';
|
||||
import { useWorkActivityStore } from './useWorkActivityStore';
|
||||
|
||||
function saveStored(items: Bug[]) {
|
||||
saveServerData('bugs', items).catch(() => {});
|
||||
@@ -57,6 +63,7 @@ export const useBugStore = create<BugState>((set, get) => ({
|
||||
const updated = [...list, bug];
|
||||
set({ bugs: updated });
|
||||
saveStored(updated);
|
||||
useWorkActivityStore.getState().addActivity(makeBugCreatedActivity(bug, operator));
|
||||
return bug;
|
||||
},
|
||||
|
||||
@@ -83,6 +90,8 @@ export const useBugStore = create<BugState>((set, get) => ({
|
||||
});
|
||||
if (!result.ok || !result.patch) return { ok: false, message: result.message };
|
||||
get().updateBug(id, result.patch);
|
||||
const activity = makeBugStatusActivity(bug, bug.status, to, operator);
|
||||
if (activity) useWorkActivityStore.getState().addActivity(activity);
|
||||
return { ok: true };
|
||||
},
|
||||
|
||||
@@ -92,6 +101,7 @@ export const useBugStore = create<BugState>((set, get) => ({
|
||||
if (bug.assigneeId === newAssigneeId) return { ok: false, message: '已是当前负责人' };
|
||||
const log = makeLog('transfer', operator, bug.assigneeId, newAssigneeId, remark);
|
||||
get().updateBug(id, { assigneeId: newAssigneeId, logs: [...(bug.logs || []), log] });
|
||||
useWorkActivityStore.getState().addActivity(makeBugTransferredActivity(bug, operator, newAssigneeId));
|
||||
return { ok: true };
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user