Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion apps/app-pc/src/api/workflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,29 @@ export const changeState = (id:string) => {
}

/**
* 当前用户是否可执行「强制同步运行中实例」(仅流程管理员)
* 当前用户是否可执行「同步流程」(仅流程管理员)
*/
export const forceSyncPermission = () => {
return httpClient.get('/api/query/workflow/permission/forceSync');
}

export interface ForceSyncRequest {
/** 流程编码 */
workCode: string;
/** 需要同步的流程实例,未指定的实例不受影响 */
processIds: string[];
}

export interface ForceSyncResult {
workflowRuntimeId: number;
workVersion: number;
syncedProcessIds: string[];
skippedProcessIds: string[];
}

/**
* 把指定流程实例的配置同步为最新流程设计
*/
export const forceSync = (request: ForceSyncRequest) => {
return httpClient.post('/api/cmd/record/forceSync', request);
}
30 changes: 2 additions & 28 deletions apps/app-pc/src/components/workflow-list/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import {Table, type TableProps} from "@coding-flow/flow-pc-ui";
import {type ActionType} from "@coding-flow/flow-core";
import React from "react";
import {Button, message, Popconfirm, Space} from "antd";
import {DesignImport, DesignPanel, DesignSyncInstance} from "@coding-flow/flow-design";
import {changeState, forceSyncPermission, list, remove} from "@/api/workflow.ts";
import {DesignImport, DesignPanel} from "@coding-flow/flow-design";
import {changeState, list, remove} from "@/api/workflow.ts";
import dayjs from "dayjs";
import { FlowMessageKey, FlowMessageRegistry } from "@coding-flow/flow-core";

Expand All @@ -13,16 +13,6 @@ export const WorkflowList = () => {
const [currentId, setCurrentId] = React.useState<string>('');
const [editable, setEditable] = React.useState<boolean>(false);
const [importVisible, setImportVisible] = React.useState<boolean>(false);
const [syncVisible, setSyncVisible] = React.useState<boolean>(false);
const [syncWorkCode, setSyncWorkCode] = React.useState<string>('');
// 强制同步属于流程管理员的干预操作,非管理员不展示该操作
const [canForceSync, setCanForceSync] = React.useState<boolean>(false);

React.useEffect(() => {
forceSyncPermission().then(res => {
setCanForceSync(!!res.data);
})
}, []);


const handleChangeState = (id: any) => {
Expand Down Expand Up @@ -118,14 +108,6 @@ export const WorkflowList = () => {
setCurrentId(record.id);
setEditable(true);
}}>编辑</a>
{
canForceSync && (
<a onClick={() => {
setSyncWorkCode(record.code);
setSyncVisible(true);
}}>强制同步</a>
)
}
<Popconfirm
title={"确认要删除该流程吗?"}
onConfirm={() => {
Expand Down Expand Up @@ -195,14 +177,6 @@ export const WorkflowList = () => {
actionType.current?.reload();
}}
/>

<DesignSyncInstance
open={syncVisible}
workCode={syncWorkCode}
onClose={() => {
setSyncVisible(false);
}}
/>
</div>
)
}
56 changes: 55 additions & 1 deletion apps/app-pc/src/pages/todo.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import React from "react";
import { done, list, notify, todo } from "@/api/record.ts";
import { forceSync, forceSyncPermission, type ForceSyncResult } from "@/api/workflow.ts";
import { ApprovalPanelDrawer, FlowTitle, WorkflowSelectModal } from "@coding-flow/flow-pc-approval";
import { Table, type TableProps } from "@coding-flow/flow-pc-ui";
import { Button, Space, Tabs, type TabsProps } from "antd";
import { Button, message, Popconfirm, Space, Tabs, type TabsProps } from "antd";
import dayjs from "dayjs";
import { EventBus, type ActionType } from "@coding-flow/flow-core";

Expand All @@ -19,6 +20,34 @@ const TodoPage: React.FC = () => {
const [workflowCode, setWorkflowCode] = React.useState<string>('');
const [currentRecordId, setCurrentRecordId] = React.useState<string>('');
const [currentTab, setCurrentTab] = React.useState<string>('todo');
// 同步流程属于流程管理员的干预操作,非管理员不展示该操作
const [canForceSync, setCanForceSync] = React.useState<boolean>(false);

React.useEffect(() => {
forceSyncPermission().then(res => {
setCanForceSync(!!res.data);
})
}, []);

/**
* 把该流程实例的配置同步为最新流程设计(仅未完成的流程允许操作)
*/
const handleForceSync = (record: any) => {
forceSync({
workCode: record.workCode,
processIds: [record.processId],
}).then(res => {
if (res.success) {
const result = res.data as ForceSyncResult | undefined;
if ((result?.syncedProcessIds?.length ?? 0) > 0) {
message.success('同步成功');
} else {
message.info('该流程已是最新设计,无需同步');
}
actionAll.current?.reload();
}
})
}

const columns: TableProps<any>['columns'] = [
{
Expand Down Expand Up @@ -86,6 +115,31 @@ const TodoPage: React.FC = () => {
>办理</a>
</Space>
)
} else if (currentTab === 'all') {
return (
<Space>
<a
onClick={() => {
setCurrentRecordId(record.recordId);
setReviewVisible(true);
setApprovalVisible(true);
}}
>详情</a>
{
// 仅未完成的流程(flowState=0 运行中)允许把配置同步为最新设计
canForceSync && record.flowState === 0 && (
<Popconfirm
title={"确认将该流程的配置同步为最新流程设计吗?"}
onConfirm={() => {
handleForceSync(record);
}}
>
<a>同步流程</a>
</Popconfirm>
)
}
</Space>
)
} else {
return (
<Space>
Expand Down
7 changes: 0 additions & 7 deletions packages/flow-core/src/message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,6 @@ export const FlowMessageKey = {
DESIGN_SCRIPT_COMPILE_ERROR: 'design.script_compile_error',
DESIGN_VIEW_CODE_SAVE_SUCCESS: 'design.view_code_save_success',
DESIGN_GROOVY_META_FAILED: 'design.groovy_meta_failed',
/** 运行中实例强制同步成功 */
DESIGN_FORCE_SYNC_SUCCESS: 'design.force_sync_success',
/** 运行中实例强制同步未选择实例 */
DESIGN_FORCE_SYNC_NO_SELECTED: 'design.force_sync_no_selected',

// ---- App 层 ----
APP_LOGIN_SUCCESS: 'app.login_success',
Expand Down Expand Up @@ -171,9 +167,6 @@ function getDefaultMessages(): Record<string, MessageTemplate> {
[FlowMessageKey.DESIGN_SCRIPT_COMPILE_ERROR]: '脚本编译请求失败',
[FlowMessageKey.DESIGN_VIEW_CODE_SAVE_SUCCESS]: '保存成功',
[FlowMessageKey.DESIGN_GROOVY_META_FAILED]: '获取脚本元数据失败',
[FlowMessageKey.DESIGN_FORCE_SYNC_SUCCESS]: (data: any) =>
`已同步 ${data?.count ?? 0} 条流程实例,跳过 ${data?.skipped ?? 0} 条已是最新配置的实例`,
[FlowMessageKey.DESIGN_FORCE_SYNC_NO_SELECTED]: '请先选择需要同步的流程实例',

// App 层
[FlowMessageKey.APP_LOGIN_SUCCESS]: 'login success',
Expand Down

This file was deleted.

128 changes: 0 additions & 128 deletions packages/flow-design/src/components/design-sync-instance/index.tsx

This file was deleted.

This file was deleted.

1 change: 0 additions & 1 deletion packages/flow-design/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
export * from '@/components/design-panel';
export * from '@/components/design-import';
export * from '@/components/design-sync-instance';
export * from '@/plugins';

This file was deleted.

Loading