mirror of
https://gitee.com/JavaLionLi/plus-ui.git
synced 2026-11-02 13:31:50 +08:00
升级warm-flow到2.1.0
This commit is contained in:
parent
395dc0cc31
commit
1804f5b569
@ -25,4 +25,5 @@ export interface LeaveVO {
|
|||||||
leaveDays?: number;
|
leaveDays?: number;
|
||||||
remark?: string;
|
remark?: string;
|
||||||
status?: string;
|
status?: string;
|
||||||
|
flowCode?: string;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,6 +6,7 @@ import dayjs from 'dayjs';
|
|||||||
import { useEffect, useMemo, useState } from 'react';
|
import { useEffect, useMemo, useState } from 'react';
|
||||||
import type { LeaveForm } from '@/api/workflow/leave/types';
|
import type { LeaveForm } from '@/api/workflow/leave/types';
|
||||||
import type { StartProcessBo } from '@/api/workflow/workflowCommon/types';
|
import type { StartProcessBo } from '@/api/workflow/workflowCommon/types';
|
||||||
|
import { listDefinition } from '@/api/workflow/definition';
|
||||||
import { addLeave, getLeave, updateLeave } from '@/api/workflow/leave';
|
import { addLeave, getLeave, updateLeave } from '@/api/workflow/leave';
|
||||||
import { startWorkFlow } from '@/api/workflow/task';
|
import { startWorkFlow } from '@/api/workflow/task';
|
||||||
import ApprovalButton from '@/components/workflow/ApprovalButton';
|
import ApprovalButton from '@/components/workflow/ApprovalButton';
|
||||||
@ -18,15 +19,6 @@ const leaveTypeOptions = [
|
|||||||
{ value: '4', label: '婚假' }
|
{ value: '4', label: '婚假' }
|
||||||
];
|
];
|
||||||
|
|
||||||
const flowCodeOptions = [
|
|
||||||
{ value: 'leave1', label: '请假申请-普通' },
|
|
||||||
{ value: 'leave2', label: '请假申请-排他网关' },
|
|
||||||
{ value: 'leave3', label: '请假申请-并行网关' },
|
|
||||||
{ value: 'leave4', label: '请假申请-会签' },
|
|
||||||
{ value: 'leave5', label: '请假申请-并行会签网关' },
|
|
||||||
{ value: 'leave6', label: '请假申请-排他并行会签' }
|
|
||||||
];
|
|
||||||
|
|
||||||
const leaveTimeDefaultOpenValue = [dayjs().startOf('day'), dayjs().endOf('day')] as [dayjs.Dayjs, dayjs.Dayjs];
|
const leaveTimeDefaultOpenValue = [dayjs().startOf('day'), dayjs().endOf('day')] as [dayjs.Dayjs, dayjs.Dayjs];
|
||||||
|
|
||||||
type PageType = 'add' | 'update' | 'view' | 'approval';
|
type PageType = 'add' | 'update' | 'view' | 'approval';
|
||||||
@ -37,10 +29,7 @@ function calcLeaveDays(range?: [dayjs.Dayjs, dayjs.Dayjs]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function buildTaskVariables(data?: Partial<LeaveForm>) {
|
function buildTaskVariables(data?: Partial<LeaveForm>) {
|
||||||
return {
|
return { day: data?.leaveDays };
|
||||||
leaveDays: data?.leaveDays,
|
|
||||||
userList: ['1', '3', '4']
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function WorkflowLeaveEditPage() {
|
export default function WorkflowLeaveEditPage() {
|
||||||
@ -51,7 +40,9 @@ export default function WorkflowLeaveEditPage() {
|
|||||||
const id = query.get('id');
|
const id = query.get('id');
|
||||||
const taskId = query.get('taskId') || '';
|
const taskId = query.get('taskId') || '';
|
||||||
const readonly = pageType === 'view';
|
const readonly = pageType === 'view';
|
||||||
const [flowCode, setFlowCode] = useState('leave1');
|
const [flowCode, setFlowCode] = useState('');
|
||||||
|
const [flowCodeOptions, setFlowCodeOptions] = useState<Array<{ value: string; label: string }>>([]);
|
||||||
|
const [flowCodeLocked, setFlowCodeLocked] = useState(false);
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
const [submitLoading, setSubmitLoading] = useState(false);
|
const [submitLoading, setSubmitLoading] = useState(false);
|
||||||
const [approvalOpen, { setTrue: openApprovalModal, set: setApprovalOpen }] = useBoolean(false);
|
const [approvalOpen, { setTrue: openApprovalModal, set: setApprovalOpen }] = useBoolean(false);
|
||||||
@ -62,6 +53,15 @@ export default function WorkflowLeaveEditPage() {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const load = async () => {
|
const load = async () => {
|
||||||
form.resetFields();
|
form.resetFields();
|
||||||
|
if (pageType === 'add' || pageType === 'update') {
|
||||||
|
const definitions = await listDefinition({ pageNum: 1, pageSize: 200 });
|
||||||
|
const options = (definitions.data?.rows || [])
|
||||||
|
.filter(item => item.isPublish === 1)
|
||||||
|
.map(item => ({ value: item.flowCode, label: `${item.flowName}(${item.flowCode})` }));
|
||||||
|
setFlowCodeOptions(options);
|
||||||
|
setFlowCode(options[0]?.value || '');
|
||||||
|
setFlowCodeLocked(false);
|
||||||
|
}
|
||||||
if (!id || pageType === 'add') {
|
if (!id || pageType === 'add') {
|
||||||
form.setFieldsValue({});
|
form.setFieldsValue({});
|
||||||
return;
|
return;
|
||||||
@ -69,6 +69,15 @@ export default function WorkflowLeaveEditPage() {
|
|||||||
setLoading(true);
|
setLoading(true);
|
||||||
try {
|
try {
|
||||||
const res = await getLeave(id);
|
const res = await getLeave(id);
|
||||||
|
if (pageType === 'update' && res.data.flowCode) {
|
||||||
|
setFlowCode(res.data.flowCode);
|
||||||
|
setFlowCodeLocked(true);
|
||||||
|
setFlowCodeOptions(current =>
|
||||||
|
current.some(item => item.value === res.data.flowCode)
|
||||||
|
? current
|
||||||
|
: [...current, { value: res.data.flowCode!, label: res.data.flowCode! }]
|
||||||
|
);
|
||||||
|
}
|
||||||
form.setFieldsValue({
|
form.setFieldsValue({
|
||||||
...res.data,
|
...res.data,
|
||||||
leaveTime:
|
leaveTime:
|
||||||
@ -137,6 +146,10 @@ export default function WorkflowLeaveEditPage() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const submitFlow = async () => {
|
const submitFlow = async () => {
|
||||||
|
if (!flowCode) {
|
||||||
|
message.error('请选择流程定义');
|
||||||
|
return;
|
||||||
|
}
|
||||||
const data = await saveLeave(false, false);
|
const data = await saveLeave(false, false);
|
||||||
if (!data?.id) return;
|
if (!data?.id) return;
|
||||||
const payload: StartProcessBo = {
|
const payload: StartProcessBo = {
|
||||||
@ -183,9 +196,15 @@ export default function WorkflowLeaveEditPage() {
|
|||||||
<Form.Item name="status" hidden>
|
<Form.Item name="status" hidden>
|
||||||
<Input />
|
<Input />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
{pageType === 'add' && (
|
{(pageType === 'add' || pageType === 'update') && (
|
||||||
<Form.Item label="流程定义">
|
<Form.Item label="流程定义">
|
||||||
<Select value={flowCode} options={flowCodeOptions} onChange={setFlowCode} />
|
<Select
|
||||||
|
value={flowCode || undefined}
|
||||||
|
options={flowCodeOptions}
|
||||||
|
disabled={flowCodeLocked}
|
||||||
|
onChange={setFlowCode}
|
||||||
|
placeholder="选择流程定义"
|
||||||
|
/>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
)}
|
)}
|
||||||
<Form.Item name="leaveType" label="请假类型" rules={[{ required: true, message: '请假类型不能为空' }]}>
|
<Form.Item name="leaveType" label="请假类型" rules={[{ required: true, message: '请假类型不能为空' }]}>
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import type { FormInstance } from 'antd';
|
import type { FormInstance } from 'antd';
|
||||||
import { ModalForm, ProFormText, ProFormTreeSelect } from '@ant-design/pro-components';
|
import { ModalForm, ProFormText, ProFormTreeSelect } from '@ant-design/pro-components';
|
||||||
import { Checkbox, Form, Radio } from 'antd';
|
import { Form, Radio } from 'antd';
|
||||||
import type { CategoryTreeVO } from '@/api/workflow/category/types';
|
import type { CategoryTreeVO } from '@/api/workflow/category/types';
|
||||||
import type { FlowDefinitionForm } from '@/api/workflow/definition/types';
|
import type { FlowDefinitionForm } from '@/api/workflow/definition/types';
|
||||||
|
|
||||||
@ -9,8 +9,6 @@ interface DefinitionFormModalProps {
|
|||||||
title: string;
|
title: string;
|
||||||
form: FormInstance<FlowDefinitionForm>;
|
form: FormInstance<FlowDefinitionForm>;
|
||||||
categoryOptions: CategoryTreeVO[];
|
categoryOptions: CategoryTreeVO[];
|
||||||
autoPass: boolean;
|
|
||||||
onAutoPassChange: (autoPass: boolean) => void;
|
|
||||||
onCancel: () => void;
|
onCancel: () => void;
|
||||||
onFinish: (fields: FlowDefinitionForm) => Promise<boolean>;
|
onFinish: (fields: FlowDefinitionForm) => Promise<boolean>;
|
||||||
}
|
}
|
||||||
@ -20,13 +18,9 @@ export default function DefinitionFormModal({
|
|||||||
title,
|
title,
|
||||||
form,
|
form,
|
||||||
categoryOptions,
|
categoryOptions,
|
||||||
autoPass,
|
|
||||||
onAutoPassChange,
|
|
||||||
onCancel,
|
onCancel,
|
||||||
onFinish
|
onFinish
|
||||||
}: DefinitionFormModalProps) {
|
}: DefinitionFormModalProps) {
|
||||||
const editId = Form.useWatch('id', form);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ModalForm<FlowDefinitionForm>
|
<ModalForm<FlowDefinitionForm>
|
||||||
title={title}
|
title={title}
|
||||||
@ -37,7 +31,6 @@ export default function DefinitionFormModal({
|
|||||||
onOpenChange={nextOpen => !nextOpen && onCancel()}
|
onOpenChange={nextOpen => !nextOpen && onCancel()}
|
||||||
onFinish={onFinish}
|
onFinish={onFinish}
|
||||||
>
|
>
|
||||||
<ProFormText name="id" hidden />
|
|
||||||
<ProFormTreeSelect
|
<ProFormTreeSelect
|
||||||
name="category"
|
name="category"
|
||||||
label="流程类别"
|
label="流程类别"
|
||||||
@ -64,16 +57,11 @@ export default function DefinitionFormModal({
|
|||||||
rules={[{ required: true, message: '流程定义名称不能为空' }]}
|
rules={[{ required: true, message: '流程定义名称不能为空' }]}
|
||||||
/>
|
/>
|
||||||
<Form.Item name="modelValue" label="设计器模式" rules={[{ required: true, message: '设计器模式不能为空' }]}>
|
<Form.Item name="modelValue" label="设计器模式" rules={[{ required: true, message: '设计器模式不能为空' }]}>
|
||||||
<Radio.Group disabled={!!editId}>
|
<Radio.Group>
|
||||||
<Radio.Button value="CLASSICS">经典模式</Radio.Button>
|
<Radio.Button value="CLASSICS">经典模式</Radio.Button>
|
||||||
<Radio.Button value="MIMIC">仿钉钉模式</Radio.Button>
|
<Radio.Button value="MIMIC">仿钉钉模式</Radio.Button>
|
||||||
</Radio.Group>
|
</Radio.Group>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item label="流程配置">
|
|
||||||
<Checkbox checked={autoPass} onChange={event => onAutoPassChange(event.target.checked)}>
|
|
||||||
下一节点执行人是当前任务处理人自动审批
|
|
||||||
</Checkbox>
|
|
||||||
</Form.Item>
|
|
||||||
<Form.Item name="formCustom" label="是否动态表单" rules={[{ required: true, message: '请选择是否动态表单' }]}>
|
<Form.Item name="formCustom" label="是否动态表单" rules={[{ required: true, message: '请选择是否动态表单' }]}>
|
||||||
<Radio.Group>
|
<Radio.Group>
|
||||||
<Radio.Button value="Y" disabled>
|
<Radio.Button value="Y" disabled>
|
||||||
|
|||||||
@ -11,7 +11,6 @@ export default function WorkflowProcessDefinitionDesignPage() {
|
|||||||
const definitionId = search.get('definitionId') || '';
|
const definitionId = search.get('definitionId') || '';
|
||||||
const params = new URLSearchParams({
|
const params = new URLSearchParams({
|
||||||
id: definitionId,
|
id: definitionId,
|
||||||
onlyDesignShow: 'true',
|
|
||||||
Authorization: `Bearer ${getToken() || ''}`,
|
Authorization: `Bearer ${getToken() || ''}`,
|
||||||
clientid: appEnv.clientId
|
clientid: appEnv.clientId
|
||||||
});
|
});
|
||||||
|
|||||||
@ -22,9 +22,7 @@ import {
|
|||||||
addDefinition,
|
addDefinition,
|
||||||
copyDefinition,
|
copyDefinition,
|
||||||
deleteDefinition,
|
deleteDefinition,
|
||||||
editDefinition,
|
|
||||||
exportDefinition,
|
exportDefinition,
|
||||||
getDefinition,
|
|
||||||
listDefinition,
|
listDefinition,
|
||||||
publishDefinition,
|
publishDefinition,
|
||||||
unPublishList
|
unPublishList
|
||||||
@ -82,11 +80,9 @@ export default function WorkflowProcessDefinitionPage() {
|
|||||||
const [selectedRows, setSelectedRows] = useState<FlowDefinitionVO[]>([]);
|
const [selectedRows, setSelectedRows] = useState<FlowDefinitionVO[]>([]);
|
||||||
const [modalOpen, { setTrue: openModal, setFalse: closeModal }] = useBoolean(false);
|
const [modalOpen, { setTrue: openModal, setFalse: closeModal }] = useBoolean(false);
|
||||||
const [modalTitle, setModalTitle] = useState('新增流程');
|
const [modalTitle, setModalTitle] = useState('新增流程');
|
||||||
const [autoPass, setAutoPass] = useState(false);
|
|
||||||
const [uploadOpen, { setTrue: openUploadModal, setFalse: closeUploadModal }] = useBoolean(false);
|
const [uploadOpen, { setTrue: openUploadModal, setFalse: closeUploadModal }] = useBoolean(false);
|
||||||
|
|
||||||
const canAdd = hasPermi(userInfo, ['workflow:definition:add']);
|
const canAdd = hasPermi(userInfo, ['workflow:definition:add']);
|
||||||
const canEdit = hasPermi(userInfo, ['workflow:definition:edit']);
|
|
||||||
const canRemove = hasPermi(userInfo, ['workflow:definition:remove']);
|
const canRemove = hasPermi(userInfo, ['workflow:definition:remove']);
|
||||||
const canImport = hasPermi(userInfo, ['workflow:definition:import']);
|
const canImport = hasPermi(userInfo, ['workflow:definition:import']);
|
||||||
const canExport = hasPermi(userInfo, ['workflow:definition:export']);
|
const canExport = hasPermi(userInfo, ['workflow:definition:export']);
|
||||||
@ -135,44 +131,16 @@ export default function WorkflowProcessDefinitionPage() {
|
|||||||
...defaultForm,
|
...defaultForm,
|
||||||
category: category || ''
|
category: category || ''
|
||||||
});
|
});
|
||||||
setAutoPass(false);
|
|
||||||
setModalTitle('新增流程');
|
setModalTitle('新增流程');
|
||||||
openModal();
|
openModal();
|
||||||
};
|
};
|
||||||
|
|
||||||
const openEdit = async (row?: FlowDefinitionVO) => {
|
|
||||||
const target = row || selectedOne;
|
|
||||||
if (!target?.id) return;
|
|
||||||
const res = await getDefinition(target.id);
|
|
||||||
const data = res.data || {};
|
|
||||||
form.resetFields();
|
|
||||||
form.setFieldsValue(data);
|
|
||||||
setAutoPass(false);
|
|
||||||
if (data.ext) {
|
|
||||||
try {
|
|
||||||
setAutoPass(!!JSON.parse(data.ext).autoPass);
|
|
||||||
} catch {
|
|
||||||
setAutoPass(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
setModalTitle('修改流程');
|
|
||||||
openModal();
|
|
||||||
};
|
|
||||||
|
|
||||||
const submitForm = async (fields: FlowDefinitionForm) => {
|
const submitForm = async (fields: FlowDefinitionForm) => {
|
||||||
const values = { ...form.getFieldsValue(true), ...fields };
|
const values = { ...form.getFieldsValue(true), ...fields };
|
||||||
const data = { ...values, ext: JSON.stringify({ autoPass }) };
|
await addDefinition(values);
|
||||||
if (data.id) {
|
|
||||||
await editDefinition(data);
|
|
||||||
} else {
|
|
||||||
await addDefinition(data);
|
|
||||||
switchTab('1');
|
switchTab('1');
|
||||||
}
|
|
||||||
message.success('操作成功');
|
message.success('操作成功');
|
||||||
form.resetFields();
|
form.resetFields();
|
||||||
if (data.id) {
|
|
||||||
actionRef.current?.reload();
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -377,11 +345,6 @@ export default function WorkflowProcessDefinitionPage() {
|
|||||||
添加
|
添加
|
||||||
</Button>
|
</Button>
|
||||||
),
|
),
|
||||||
canEdit && (
|
|
||||||
<Button key="edit" icon={<EditOutlined />} disabled={!selectedOne} onClick={() => openEdit()}>
|
|
||||||
修改
|
|
||||||
</Button>
|
|
||||||
),
|
|
||||||
canRemove && (
|
canRemove && (
|
||||||
<Popconfirm key="delete" title="是否确认删除选中的流程定义?" onConfirm={() => handleDelete()}>
|
<Popconfirm key="delete" title="是否确认删除选中的流程定义?" onConfirm={() => handleDelete()}>
|
||||||
<Button danger icon={<DeleteOutlined />} disabled={!selectedIds.length}>
|
<Button danger icon={<DeleteOutlined />} disabled={!selectedIds.length}>
|
||||||
@ -409,8 +372,6 @@ export default function WorkflowProcessDefinitionPage() {
|
|||||||
open={modalOpen}
|
open={modalOpen}
|
||||||
form={form}
|
form={form}
|
||||||
categoryOptions={categoryOptions}
|
categoryOptions={categoryOptions}
|
||||||
autoPass={autoPass}
|
|
||||||
onAutoPassChange={setAutoPass}
|
|
||||||
onCancel={closeModal}
|
onCancel={closeModal}
|
||||||
onFinish={submitForm}
|
onFinish={submitForm}
|
||||||
/>
|
/>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user