diff --git a/packages/plugins/@tachybase/plugin-workflow/src/client/features/approval/usage/approval-block/ApprovalBlock.schema.tsx b/packages/plugins/@tachybase/plugin-workflow/src/client/features/approval/usage/approval-block/ApprovalBlock.schema.tsx index 198191bca..55c81f49d 100644 --- a/packages/plugins/@tachybase/plugin-workflow/src/client/features/approval/usage/approval-block/ApprovalBlock.schema.tsx +++ b/packages/plugins/@tachybase/plugin-workflow/src/client/features/approval/usage/approval-block/ApprovalBlock.schema.tsx @@ -7,6 +7,7 @@ import { TableOutlined } from '@ant-design/icons'; import { NAMESPACE } from '../../locale'; import { ApprovalBlockProvider } from './ApprovalBlock.provider'; import { ApprovalBlockLaunch } from './launch/VC.ApprovalBlockLaunch'; +import { ApprovalBlockLaunchApplication } from './launch/VC.ApprovalBlockLaunchApplication'; import { ApprovalBlockTodos } from './todos/VC.ApprovalBlockTodos'; export class SCApprovalBlock extends Plugin { @@ -14,6 +15,7 @@ export class SCApprovalBlock extends Plugin { this.app.addComponents({ 'ApprovalBlock.Decorator': ApprovalBlockProvider, 'ApprovalBlock.Launch': ApprovalBlockLaunch, + 'ApprovalBlock.Launch.Application': ApprovalBlockLaunchApplication, 'ApprovalBlock.Todos': ApprovalBlockTodos, }); } @@ -21,14 +23,28 @@ export class SCApprovalBlock extends Plugin { const schemaItems = [ { - type: 'item', + type: 'itemGroup', + name: 'Launch', title: `{{t("Launch", { ns: "${NAMESPACE}" })}}`, - 'x-component': 'ApprovalBlock.Launch', - collection: 'approvals', - params: { - appends: ['createdBy.nickname', 'workflow.title', 'workflow.enabled'], - except: ['data'], - }, + children: [ + { + type: 'item', + title: `{{t("Launch", { ns: "${NAMESPACE}" })}}`, + 'x-component': 'ApprovalBlock.Launch.Application', + collection: 'workflows', + action: 'list', + }, + { + type: 'item', + title: `{{t("MyLaunch", { ns: "${NAMESPACE}" })}}`, + 'x-component': 'ApprovalBlock.Launch', + collection: 'approvals', + params: { + appends: ['createdBy.nickname', 'workflow.title', 'workflow.enabled'], + except: ['data'], + }, + }, + ], }, { type: 'item', @@ -56,7 +72,7 @@ const schemaItems = [ const getSchemaInsert = ({ item }) => { const id = uid(); - const { collection, params, ['x-component']: xcomponent } = item; + const { collection, params, ['x-component']: xcomponent, action } = item; return { type: 'void', name: id, @@ -66,7 +82,7 @@ const getSchemaInsert = ({ item }) => { 'x-decorator-props': { collection, params, - action: 'listCentralized', + action: action || 'listCentralized', }, 'x-component': 'CardItem', properties: { diff --git a/packages/plugins/@tachybase/plugin-workflow/src/client/features/approval/usage/approval-block/launch/VC.ApprovalBlockLaunchApplication.tsx b/packages/plugins/@tachybase/plugin-workflow/src/client/features/approval/usage/approval-block/launch/VC.ApprovalBlockLaunchApplication.tsx new file mode 100644 index 000000000..804ce2242 --- /dev/null +++ b/packages/plugins/@tachybase/plugin-workflow/src/client/features/approval/usage/approval-block/launch/VC.ApprovalBlockLaunchApplication.tsx @@ -0,0 +1,161 @@ +import React, { useCallback, useContext, useEffect, useState } from 'react'; +import { + ActionContextProvider, + CollectionProvider_deprecated, + css, + parseCollectionName, + RemoteSchemaComponent, + SchemaComponent, + SchemaComponentContext, + useRequest, +} from '@tachybase/client'; +import { useFieldSchema } from '@tachybase/schema'; + +import { Button, Col, Row } from 'antd'; + +import { FlowContextProvider } from '../common/FlowContext.provider'; +import { useCreateSubmit } from './apply-button/hooks/useSubmit'; +import { ActionBarProvider } from './apply-button/Pd.ActionBar'; +import { ApplyActionStatusProvider } from './apply-button/Pd.ActionStatus'; +import { useActionResubmit } from './hooks/useActionResubmit'; +import { useWithdrawAction } from './hooks/useWithdrawAction'; +import { WithdrawActionProvider } from './Pd.WithdrawAction'; + +// 审批-发起: 申请区块 +export const ApprovalBlockLaunchApplication = (props) => { + const fieldSchema = useFieldSchema(); + const decorator = fieldSchema?.parent?.['x-decorator-props']; + const [options, setOptions] = useState([]); + const [visible, setVisible] = useState(false); + const [schema, setSchema] = useState(null); + const context = useContext(SchemaComponentContext); + const { run } = useRequest( + { + resource: decorator?.collection, + action: decorator?.action, + params: { pageSize: 99999, filter: { ...decorator?.params?.filter } }, + }, + { + manual: true, + onSuccess(res) { + const result = { + items: [], + data: [], + }; + res.data?.forEach((item, index) => { + if ((index + 1) % 4 === 0) { + result.items.push(item); + result.data.push(result.items); + result.items = []; + } else { + result.items.push(item); + } + if (index + 1 === res.data.length) { + result.data.push(result.items); + } + }); + setOptions(result.data); + }, + }, + ); + + useEffect(() => { + run(); + }, []); + + const onClick = useCallback( + (targetItems) => { + const { applyForm } = targetItems?.config ?? {}; + const [dataSource, name] = parseCollectionName(targetItems.config.collection); + + setSchema({ + type: 'void', + properties: { + [`drawer-${targetItems.id}`]: { + type: 'void', + title: targetItems.title, + 'x-decorator': 'FlowContextProvider', + 'x-decorator-props': { + workflow: targetItems, + }, + 'x-component': 'Action.Drawer', + 'x-component-props': { + className: css` + .ant-drawer-body { + background: var(--tb-box-bg); + } + `, + }, + properties: { + [applyForm]: { + type: 'void', + 'x-decorator': 'CollectionProvider_deprecated', + 'x-decorator-props': { + name, + dataSource, + }, + 'x-component': 'RemoteSchemaComponent', + 'x-component-props': { + uid: applyForm, + noForm: true, + }, + }, + }, + }, + }, + }); + setVisible(true); + }, + [options], + ); + + return ( + + {options?.map((data, index) => { + return ( + + {data?.map((item, index) => { + return ( + + + + ); + })} + + ); + })} + + null, + WithdrawActionProvider, + }} + scope={{ + useSubmit: useCreateSubmit, + useWithdrawAction, + useActionResubmit, + }} + /> + + + ); +}; diff --git a/packages/plugins/@tachybase/plugin-workflow/src/locale/en-US.json b/packages/plugins/@tachybase/plugin-workflow/src/locale/en-US.json index f8841fa17..22077b4f9 100644 --- a/packages/plugins/@tachybase/plugin-workflow/src/locale/en-US.json +++ b/packages/plugins/@tachybase/plugin-workflow/src/locale/en-US.json @@ -277,5 +277,6 @@ "concat": "concat", "ms": "ms", "Resubmit": "Resubmit", - "Are you sure you want to resubmit it?": "Are you sure you want to resubmit it?" + "Are you sure you want to resubmit it?": "Are you sure you want to resubmit it?", + "MyLaunch":"MyLaunch" } diff --git a/packages/plugins/@tachybase/plugin-workflow/src/locale/zh-CN.json b/packages/plugins/@tachybase/plugin-workflow/src/locale/zh-CN.json index 57c97817f..a84f4223a 100644 --- a/packages/plugins/@tachybase/plugin-workflow/src/locale/zh-CN.json +++ b/packages/plugins/@tachybase/plugin-workflow/src/locale/zh-CN.json @@ -358,5 +358,6 @@ "concat": "连接", "ms": "毫秒", "Resubmit": "重新发起", - "Are you sure you want to resubmit it?": "是否确定重新发起?" + "Are you sure you want to resubmit it?": "是否确定重新发起?", + "MyLaunch":"我的发起" }