refactor: @hera/plugin-core, departments-plugin (#979)
Reviewed-on: daoyoucloud/tachybase#979 Co-authored-by: bai.zixv <bai.zixv@foxmail.com> Co-committed-by: bai.zixv <bai.zixv@foxmail.com>
This commit is contained in:
parent
84608f9a3e
commit
236c308d23
@ -1,5 +1,5 @@
|
||||
import { SchemaSettingOptions, SchemaSettingsItemType, SchemaSettingsItemTypeWithoutName } from './types';
|
||||
import { defaultSettingItems } from './SchemaSettingsDefaults';
|
||||
import { SchemaSettingOptions, SchemaSettingsItemType, SchemaSettingsItemTypeWithoutName } from './types';
|
||||
|
||||
export class SchemaSettings<T = {}> {
|
||||
options: SchemaSettingOptions<T>;
|
||||
|
@ -1,4 +1,4 @@
|
||||
import React, { FC, ReactNode, createContext, useContext, useMemo } from 'react';
|
||||
import React, { createContext, FC, ReactNode, useContext, useMemo } from 'react';
|
||||
|
||||
import { ACLCollectionProvider } from '../../acl/ACLProvider';
|
||||
import { UseRequestOptions, UseRequestService } from '../../api-client';
|
||||
@ -6,9 +6,9 @@ import { withDynamicSchemaProps } from '../../application/hoc';
|
||||
import { Designable, useDesignable } from '../../schema-component';
|
||||
import { AssociationProvider, CollectionManagerProvider, CollectionOptions, CollectionProvider } from '../collection';
|
||||
import { CollectionRecord } from '../collection-record';
|
||||
import { ConfigSettingProvider } from './context/ConfigSetting.provider';
|
||||
import { BlockRequestProvider } from './DataBlockRequestProvider';
|
||||
import { DataBlockResourceProvider } from './DataBlockResourceProvider';
|
||||
import { ConfigSettingProvider } from './context/ConfigSetting.provider';
|
||||
|
||||
export interface AllDataBlockProps {
|
||||
collection: string | CollectionOptions;
|
||||
|
@ -1,7 +1,9 @@
|
||||
import { useCallback, useEffect, useState } from 'react';
|
||||
import { Schema, useFieldSchema } from '@tachybase/schema';
|
||||
import { flatten, getValuesByPath } from '@tachybase/utils/client';
|
||||
|
||||
import _ from 'lodash';
|
||||
import { useCallback, useEffect, useState } from 'react';
|
||||
|
||||
import { FilterTarget, findFilterTargets } from '../block-provider/hooks';
|
||||
import {
|
||||
Collection_deprecated,
|
||||
|
@ -1,21 +1,22 @@
|
||||
import { useContextConfigSetting } from '@tachybase/client';
|
||||
import { ArrayCollapse, FormLayout } from '@tachybase/components';
|
||||
import { Field } from '@tachybase/schema';
|
||||
import { ISchema, useField, useFieldSchema } from '@tachybase/schema';
|
||||
import { Field, ISchema, useField, useFieldSchema } from '@tachybase/schema';
|
||||
|
||||
import _ from 'lodash';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { useApp, useSchemaToolbar } from '../../../../application';
|
||||
import { SchemaSettings } from '../../../../application/schema-settings/SchemaSettings';
|
||||
import { useFormBlockContext } from '../../../../block-provider';
|
||||
import { useCollectionManager_deprecated, useCollection_deprecated } from '../../../../collection-manager';
|
||||
import { useCollection_deprecated, useCollectionManager_deprecated } from '../../../../collection-manager';
|
||||
import { useFieldComponentName } from '../../../../common/useFieldComponentName';
|
||||
import { useDesignable, useValidateSchema } from '../../../../schema-component';
|
||||
import { useIsFormReadPretty } from '../../../../schema-component/antd/form-item/FormItem.Settings';
|
||||
import { getTempFieldState } from '../../../../schema-component/antd/form-v2/utils';
|
||||
import { isPatternDisabled } from '../../../../schema-settings';
|
||||
import { useIsAllowToSetDefaultValue } from '../../../../schema-settings/hooks/useIsAllowToSetDefaultValue';
|
||||
import { ActionType } from '../../../../schema-settings/LinkageRules/type';
|
||||
import { SchemaSettingsDefaultValue } from '../../../../schema-settings/SchemaSettingsDefaultValue';
|
||||
import { useIsAllowToSetDefaultValue } from '../../../../schema-settings/hooks/useIsAllowToSetDefaultValue';
|
||||
import { useContextConfigSetting } from '@tachybase/client';
|
||||
|
||||
export const fieldSettingsFormItem = new SchemaSettings({
|
||||
name: 'fieldSettings:FormItem',
|
||||
|
@ -1,9 +1,10 @@
|
||||
import { ArrayItems } from '@tachybase/components';
|
||||
import { ISchema } from '@tachybase/schema';
|
||||
import { useField, useFieldSchema } from '@tachybase/schema';
|
||||
import _ from 'lodash';
|
||||
import { useMemo } from 'react';
|
||||
import { ArrayItems } from '@tachybase/components';
|
||||
import { ISchema, useField, useFieldSchema } from '@tachybase/schema';
|
||||
|
||||
import _ from 'lodash';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { SchemaSettings } from '../../../../application/schema-settings/SchemaSettings';
|
||||
import { useFormBlockContext } from '../../../../block-provider';
|
||||
import { useCollection_deprecated, useSortFields } from '../../../../collection-manager';
|
||||
@ -16,9 +17,9 @@ import {
|
||||
screenSizeTitleMaps,
|
||||
} from '../../../../schema-component/antd/grid-card/options';
|
||||
import { SchemaSettingsTemplate } from '../../../../schema-settings';
|
||||
import { columnCountMarks } from './utils';
|
||||
import { SchemaSettingsDataScope } from '../../../../schema-settings/SchemaSettingsDataScope';
|
||||
import { setDataLoadingModeSettingsItem } from '../details-multi/setDataLoadingModeSettingsItem';
|
||||
import { columnCountMarks } from './utils';
|
||||
|
||||
export const gridCardBlockSettings = new SchemaSettings({
|
||||
name: 'blockSettings:gridCard',
|
||||
|
@ -1,8 +1,11 @@
|
||||
import { Field, useField, useFieldSchema } from '@tachybase/schema';
|
||||
import { SchemaSettings } from '../../../../application/schema-settings/SchemaSettings';
|
||||
import { useColumnSchema } from '../../../../schema-component/antd/table-v2/Table.Column.Decorator';
|
||||
import { useDesignable } from '../../../../schema-component';
|
||||
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { SchemaSettings } from '../../../../application/schema-settings/SchemaSettings';
|
||||
import { useDesignable } from '../../../../schema-component';
|
||||
import { useColumnSchema } from '../../../../schema-component/antd/table-v2/Table.Column.Decorator';
|
||||
|
||||
export const checkboxComponentFieldSettings = new SchemaSettings({
|
||||
name: 'fieldSettings:component:Checkbox',
|
||||
items: [
|
||||
|
@ -1,10 +1,11 @@
|
||||
import { observer, RecursionField, useField, useFieldSchema } from '@tachybase/schema';
|
||||
import React from 'react';
|
||||
import { observer, RecursionField, useField, useFieldSchema } from '@tachybase/schema';
|
||||
|
||||
import { useActionContext } from '.';
|
||||
import { ActionDrawer } from './Action.Drawer';
|
||||
import { ActionSheet } from './Action.Sheet';
|
||||
import { ActionModal } from './Action.Modal';
|
||||
import { ActionPage } from './Action.Page';
|
||||
import { ActionSheet } from './Action.Sheet';
|
||||
import { ComposedActionDrawer } from './types';
|
||||
|
||||
export const ActionContainer: ComposedActionDrawer = observer(
|
||||
|
@ -1,6 +1,8 @@
|
||||
import { Schema } from '@tachybase/schema';
|
||||
import { DrawerProps, ModalProps } from 'antd';
|
||||
import React, { createContext } from 'react';
|
||||
import { Schema } from '@tachybase/schema';
|
||||
|
||||
import { DrawerProps, ModalProps } from 'antd';
|
||||
|
||||
import { useActionContext } from './hooks';
|
||||
|
||||
export const ActionContext = createContext<ActionContextProps>({});
|
||||
|
@ -1,8 +1,10 @@
|
||||
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
||||
|
||||
import { CloseCircleFilled } from '@ant-design/icons';
|
||||
import { Tag, TreeSelect } from 'antd';
|
||||
import type { DefaultOptionType, TreeSelectProps } from 'rc-tree-select/es/TreeSelect';
|
||||
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import {
|
||||
CollectionFieldOptions_deprecated,
|
||||
parseCollectionName,
|
||||
|
@ -1,15 +1,25 @@
|
||||
import { LoadingOutlined, PlusOutlined } from '@ant-design/icons';
|
||||
import { onFieldInputValueChange } from '@tachybase/schema';
|
||||
import { RecursionField, connect, mapProps, observer, useField, useFieldSchema, useForm } from '@tachybase/schema';
|
||||
import { uid } from '@tachybase/schema';
|
||||
import { Space, message } from 'antd';
|
||||
import { isFunction } from 'mathjs';
|
||||
import React, { useEffect, useMemo, useState } from 'react';
|
||||
import {
|
||||
connect,
|
||||
mapProps,
|
||||
observer,
|
||||
onFieldInputValueChange,
|
||||
RecursionField,
|
||||
uid,
|
||||
useField,
|
||||
useFieldSchema,
|
||||
useForm,
|
||||
} from '@tachybase/schema';
|
||||
|
||||
import { LoadingOutlined, PlusOutlined } from '@ant-design/icons';
|
||||
import { message, Space } from 'antd';
|
||||
import { isFunction } from 'mathjs';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { RecordProvider, useAPIClient, useApp, useCollectionRecordData } from '../../../';
|
||||
import { isVariable } from '../../../variables/utils/isVariable';
|
||||
import { getInnermostKeyAndValue } from '../../common/utils/uitls';
|
||||
import { RemoteSelectProps, RemoteSelect } from '../remote-select';
|
||||
import { RemoteSelect, RemoteSelectProps } from '../remote-select';
|
||||
import useServiceOptions, { useAssociationFieldContext } from './hooks';
|
||||
|
||||
export type AssociationSelectProps<P = any> = RemoteSelectProps<P> & {
|
||||
|
@ -1,13 +1,14 @@
|
||||
import React from 'react';
|
||||
import { connect, isValid, mapProps, mapReadPretty, useField } from '@tachybase/schema';
|
||||
|
||||
import { CheckOutlined, CloseOutlined } from '@ant-design/icons';
|
||||
import { connect, mapProps, mapReadPretty, useField } from '@tachybase/schema';
|
||||
import { isValid } from '@tachybase/schema';
|
||||
import { Checkbox as AntdCheckbox, Radio, Tag } from 'antd';
|
||||
import type { CheckboxGroupProps, CheckboxProps } from 'antd/es/checkbox';
|
||||
import uniq from 'lodash/uniq';
|
||||
import React from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { useCollectionField } from '../../../data-source/collection-field/CollectionFieldProvider';
|
||||
import { EllipsisWithTooltip } from '../input/EllipsisWithTooltip';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
type ComposedCheckbox = React.ForwardRefExoticComponent<
|
||||
Pick<Partial<any>, string | number | symbol> & React.RefAttributes<unknown>
|
||||
|
@ -1,11 +1,11 @@
|
||||
import { FormLayout } from '@tachybase/components';
|
||||
import { createForm } from '@tachybase/schema';
|
||||
import { FormContext, useField, useFieldSchema } from '@tachybase/schema';
|
||||
import React, { createContext, useContext, useEffect, useMemo } from 'react';
|
||||
import { BlockProvider, useBlockRequestContext, useParsedFilter } from '../../../block-provider';
|
||||
import useStyles from './GridCard.Decorator.style';
|
||||
import { useGridCardBlockParams } from '../../../modules/blocks/data-blocks/grid-card/hooks/useGridCardBlockParams';
|
||||
import { FormLayout } from '@tachybase/components';
|
||||
import { createForm, FormContext, useField, useFieldSchema } from '@tachybase/schema';
|
||||
|
||||
import { withDynamicSchemaProps } from '../../../application/hoc/withDynamicSchemaProps';
|
||||
import { BlockProvider, useBlockRequestContext, useParsedFilter } from '../../../block-provider';
|
||||
import { useGridCardBlockParams } from '../../../modules/blocks/data-blocks/grid-card/hooks/useGridCardBlockParams';
|
||||
import useStyles from './GridCard.Decorator.style';
|
||||
|
||||
export const GridCardBlockContext = createContext<any>({});
|
||||
GridCardBlockContext.displayName = 'GridCardBlockContext';
|
||||
|
@ -1,8 +1,10 @@
|
||||
import React, { ReactNode, useEffect, useRef, useState } from 'react';
|
||||
import { getScrollParent, merge } from '@tachybase/utils/client';
|
||||
|
||||
import { useLockFn, useThrottleFn } from 'ahooks';
|
||||
import { Spin } from 'antd';
|
||||
import React, { ReactNode, useEffect, useRef, useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import useStyles from './style';
|
||||
|
||||
function isWindow(element: any | Window): element is Window {
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { createForm } from '@tachybase/schema';
|
||||
import { Schema } from '@tachybase/schema';
|
||||
// import { Spin } from 'antd';
|
||||
import React, { PropsWithChildren, useMemo } from 'react';
|
||||
import { createForm, Schema } from '@tachybase/schema';
|
||||
|
||||
import { useRequest } from '../../api-client';
|
||||
import { useSchemaComponentContext } from '../hooks';
|
||||
import { FormProvider } from './FormProvider';
|
||||
|
@ -1,7 +1,9 @@
|
||||
import { useField, useFieldSchema } from '@tachybase/schema';
|
||||
import { Select } from 'antd';
|
||||
import React from 'react';
|
||||
import { useField, useFieldSchema } from '@tachybase/schema';
|
||||
|
||||
import { Select } from 'antd';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { SchemaInitializerItem, SchemaInitializerSelect } from '../application';
|
||||
import { useDesignable } from '../schema-component';
|
||||
import { SchemaSettingsSelectItem } from '../schema-settings';
|
||||
|
@ -39,21 +39,21 @@ import { filterCollapseItemFieldSettings } from '../modules/blocks/filter-blocks
|
||||
import { filterFormBlockSettings } from '../modules/blocks/filter-blocks/form/filterFormBlockSettings';
|
||||
import { filterFormItemFieldSettings } from '../modules/blocks/filter-blocks/form/filterFormItemFieldSettings';
|
||||
import { markdownBlockSettings } from '../modules/blocks/other-blocks/markdown/markdownBlockSettings';
|
||||
import { cascadeSelectComponentFieldSettings } from '../modules/fields/component/CascadeSelect/cascadeSelectComponentFieldSettings';
|
||||
import { cascaderComponentFieldSettings } from '../modules/fields/component/Cascader/cascaderComponentFieldSettings';
|
||||
import { cascadeSelectComponentFieldSettings } from '../modules/fields/component/CascadeSelect/cascadeSelectComponentFieldSettings';
|
||||
import { checkboxComponentFieldSettings } from '../modules/fields/component/Checkbox/checkboxComponentFieldSettings';
|
||||
import { datePickerComponentFieldSettings } from '../modules/fields/component/DatePicker/datePickerComponentFieldSettings';
|
||||
import { drawerSubTableComponentFieldSettings } from '../modules/fields/component/DrawerSubTable/drawerSubTableComponentFieldSettings';
|
||||
import { fileManagerComponentFieldSettings } from '../modules/fields/component/FileManager/fileManagerComponentFieldSettings';
|
||||
import { uploadAttachmentComponentFieldSettings } from '../modules/fields/component/FileManager/uploadAttachmentComponentFieldSettings';
|
||||
import { inputNumberComponentFieldSettings } from '../modules/fields/component/InputNumber/inputNumberComponentFieldSettings';
|
||||
import { subformComponentFieldSettings } from '../modules/fields/component/Nester/subformComponentFieldSettings';
|
||||
import { recordPickerComponentFieldSettings } from '../modules/fields/component/Picker/recordPickerComponentFieldSettings';
|
||||
import { subformPopoverComponentFieldSettings } from '../modules/fields/component/PopoverNester/subformPopoverComponentFieldSettings';
|
||||
import { drawerSubTableComponentFieldSettings } from '../modules/fields/component/DrawerSubTable/drawerSubTableComponentFieldSettings';
|
||||
import { selectComponentFieldSettings } from '../modules/fields/component/Select/selectComponentFieldSettings';
|
||||
import { subTablePopoverComponentFieldSettings } from '../modules/fields/component/SubTable/subTablePopoverComponentFieldSettings';
|
||||
import { tagComponentFieldSettings } from '../modules/fields/component/Tag/tagComponentFieldSettings';
|
||||
import { unixTimestampComponentFieldSettings } from '../modules/fields/component/UnixTimestamp/unixTimestampComponentFieldSettings';
|
||||
import { inputNumberComponentFieldSettings } from '../modules/fields/component/InputNumber/inputNumberComponentFieldSettings';
|
||||
import { checkboxComponentFieldSettings } from '../modules/fields/component/Checkbox/checkboxComponentFieldSettings';
|
||||
|
||||
export class SchemaSettingsPlugin extends Plugin {
|
||||
async load() {
|
||||
|
@ -1,4 +1,5 @@
|
||||
import lodash from 'lodash';
|
||||
|
||||
import { dayjs } from './dayjs';
|
||||
|
||||
export * from './collections-graph';
|
||||
|
@ -1,6 +1,7 @@
|
||||
import { SchemaInitializerItem, useSchemaInitializer, useSchemaInitializerItem } from '@tachybase/client';
|
||||
import React from 'react';
|
||||
import { SchemaInitializerItem, useSchemaInitializer, useSchemaInitializerItem } from '@tachybase/client';
|
||||
import { ISchema } from '@tachybase/schema';
|
||||
|
||||
import { CalendarOutline } from 'antd-mobile-icons';
|
||||
|
||||
export const ApprovalBlockInitializer = () => {
|
||||
|
@ -1,13 +1,15 @@
|
||||
import React, { useMemo } from 'react';
|
||||
import { createStyles, useCurrentUserContext } from '@tachybase/client';
|
||||
import { EXECUTION_STATUS } from '@tachybase/plugin-workflow/client';
|
||||
import { dayjs } from '@tachybase/utils/client';
|
||||
|
||||
import { Space, Steps, Tag } from 'antd-mobile';
|
||||
import _ from 'lodash';
|
||||
import React, { useMemo } from 'react';
|
||||
|
||||
import { APPROVAL_ACTION_STATUS, APPROVAL_STATUS, ApprovalStatusEnums, approvalStatusOptions } from '../constants';
|
||||
import { lang, usePluginTranslation, useTranslation } from '../locale';
|
||||
import { useContextApprovalExecution } from '../context/ApprovalExecution';
|
||||
import { ContextWithActionEnabled } from '../context/WithActionEnabled';
|
||||
import { Space, Steps, Tag } from 'antd-mobile';
|
||||
import { dayjs } from '@tachybase/utils/client';
|
||||
import { lang, usePluginTranslation, useTranslation } from '../locale';
|
||||
|
||||
export const ApprovalProcess = (props) => {
|
||||
const { t } = usePluginTranslation();
|
||||
|
@ -1,8 +1,9 @@
|
||||
import React, { useState } from 'react';
|
||||
import { observer } from '@tachybase/schema';
|
||||
import { dayjs } from '@tachybase/utils/client';
|
||||
|
||||
import { AutoCenter, Button, DatePicker, Grid, Popup, Space, Toast } from 'antd-mobile';
|
||||
import { DownOutline } from 'antd-mobile-icons';
|
||||
import React, { useState } from 'react';
|
||||
|
||||
export const ApprovalReachDataType = observer((props) => {
|
||||
const { changeFilter, filter } = props as any;
|
||||
|
@ -1,8 +1,10 @@
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { useAPIClient } from '@tachybase/client';
|
||||
import { observer, useFieldSchema } from '@tachybase/schema';
|
||||
|
||||
import { Picker, Space } from 'antd-mobile';
|
||||
import { DownOutline } from 'antd-mobile-icons';
|
||||
import React, { useEffect, useState } from 'react';
|
||||
|
||||
import { useTranslation } from '../locale';
|
||||
|
||||
export const ApprovalTemplateType = observer((props) => {
|
||||
|
@ -1,5 +1,6 @@
|
||||
import { JOB_STATUS } from '@tachybase/plugin-workflow/client';
|
||||
import { NAMESPACE, lang, tval } from './locale';
|
||||
|
||||
import { lang, NAMESPACE, tval } from './locale';
|
||||
|
||||
/**显示状态 */
|
||||
export const APPROVAL_STATUS = {
|
||||
|
@ -1,4 +1,5 @@
|
||||
import { createContext, useContext } from 'react';
|
||||
|
||||
import { ApprovalExecution } from '../todos/interface/interface';
|
||||
|
||||
export const ContextApprovalExecution = createContext<Partial<ApprovalExecution>>({});
|
||||
|
@ -1,4 +1,4 @@
|
||||
import React from 'react';
|
||||
import React, { Fragment, useContext, useMemo, useRef } from 'react';
|
||||
import {
|
||||
BlockRequestContext_deprecated,
|
||||
CollectionProvider_deprecated,
|
||||
@ -11,8 +11,8 @@ import {
|
||||
useAssociationNames,
|
||||
useDesignable,
|
||||
} from '@tachybase/client';
|
||||
import { RecursionField, createForm, useField, useFieldSchema } from '@tachybase/schema';
|
||||
import { Fragment, useContext, useMemo, useRef } from 'react';
|
||||
import { createForm, RecursionField, useField, useFieldSchema } from '@tachybase/schema';
|
||||
|
||||
import { useContextApprovalExecution } from './ApprovalExecution';
|
||||
|
||||
export const FormBlockProvider = (props) => {
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { SchemaComponentContext, useSchemaComponentContext } from '@tachybase/client';
|
||||
import React from 'react';
|
||||
import { SchemaComponentContext, useSchemaComponentContext } from '@tachybase/client';
|
||||
|
||||
export function SchemaComponentContextProvider({ designable, children }) {
|
||||
const schemaComponentContext = useSchemaComponentContext();
|
||||
|
@ -1,13 +1,14 @@
|
||||
import { Plugin } from '@tachybase/client';
|
||||
|
||||
import { ApprovalBlockInitializer } from './ApprovalBlockInitializer';
|
||||
import { ApprovalSettings } from './ApprovalSettings';
|
||||
import { TodosBlock } from './todos/TodosBlock';
|
||||
import { InitiationsBlock } from './initiations/InitiationsBlock';
|
||||
import { LauncherActionConfigInitializer } from './initiations/config/LauncherActionConfig';
|
||||
import { ViewActionTodosContent } from './todos/component/ViewActionTodosContent';
|
||||
import { ViewActionUserInitiationsContent } from './initiations/component/ViewActionUserInitiationsContent';
|
||||
import { ApprovalProcess } from './component/ApprovalProcess.view';
|
||||
import { ViewActionInitiationsContent } from './initiations/component/ViewActionInitiationsContent';
|
||||
import { ViewActionUserInitiationsContent } from './initiations/component/ViewActionUserInitiationsContent';
|
||||
import { LauncherActionConfigInitializer } from './initiations/config/LauncherActionConfig';
|
||||
import { InitiationsBlock } from './initiations/InitiationsBlock';
|
||||
import { ViewActionTodosContent } from './todos/component/ViewActionTodosContent';
|
||||
import { TodosBlock } from './todos/TodosBlock';
|
||||
|
||||
class PluginApproval extends Plugin {
|
||||
async load() {
|
||||
|
@ -1,11 +1,13 @@
|
||||
import { useAPIClient, useCurrentUserContext } from '@tachybase/client';
|
||||
import { Badge, Empty, List, Space, Tag } from 'antd-mobile';
|
||||
import React, { useContext, useEffect, useState } from 'react';
|
||||
import { useDeepCompareEffect } from 'ahooks';
|
||||
import { ApprovalPriorityType, ApprovalStatusEnums } from '../../constants';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { useTranslation } from '../../locale';
|
||||
import { useAPIClient, useCurrentUserContext } from '@tachybase/client';
|
||||
import { observer } from '@tachybase/schema';
|
||||
|
||||
import { useDeepCompareEffect } from 'ahooks';
|
||||
import { Badge, Empty, List, Space, Tag } from 'antd-mobile';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
|
||||
import { ApprovalPriorityType, ApprovalStatusEnums } from '../../constants';
|
||||
import { useTranslation } from '../../locale';
|
||||
import { InitiationsBlockContext } from '../InitiationsBlock';
|
||||
|
||||
export const ApprovalItem = observer((props) => {
|
||||
|
@ -1,8 +1,10 @@
|
||||
import React, { useState } from 'react';
|
||||
import { observer, useFieldSchema } from '@tachybase/schema';
|
||||
|
||||
import { Picker, Space } from 'antd-mobile';
|
||||
import { DownOutline } from 'antd-mobile-icons';
|
||||
import React, { useState } from 'react';
|
||||
|
||||
import { useTranslation } from '../../locale';
|
||||
import { observer, useFieldSchema } from '@tachybase/schema';
|
||||
|
||||
export const ApprovalStatus = observer((props) => {
|
||||
const { changeFilter, filter } = props as any;
|
||||
|
@ -1,11 +1,14 @@
|
||||
import { BlockItem } from '@tachybase/client';
|
||||
import { Space } from 'antd-mobile';
|
||||
import React, { useState } from 'react';
|
||||
import { BlockItem } from '@tachybase/client';
|
||||
import { observer } from '@tachybase/schema';
|
||||
import { ApprovalTemplateType } from '../../component/ApprovalTemplateType';
|
||||
import { ApprovalStatus } from './ApprovalStatus';
|
||||
import { ApprovalItem } from './ApprovalItem';
|
||||
|
||||
import { Space } from 'antd-mobile';
|
||||
|
||||
import { ApprovalReachDataType } from '../../component/ApprovalReachDataType';
|
||||
import { ApprovalTemplateType } from '../../component/ApprovalTemplateType';
|
||||
import { ApprovalItem } from './ApprovalItem';
|
||||
import { ApprovalStatus } from './ApprovalStatus';
|
||||
|
||||
import '../../style/style.css';
|
||||
|
||||
export const UserInitiationsItem = observer((props) => {
|
||||
|
@ -1,7 +1,8 @@
|
||||
import { SchemaInitializer } from '@tachybase/client';
|
||||
import { LauncherActionConfigComponent } from './LauncherActionConfigComponent';
|
||||
import { NAMESPACE } from '../../locale';
|
||||
|
||||
import { APPROVAL_ACTION_STATUS, APPROVAL_STATUS } from '../../constants';
|
||||
import { NAMESPACE } from '../../locale';
|
||||
import { LauncherActionConfigComponent } from './LauncherActionConfigComponent';
|
||||
|
||||
// 区块-配置操作
|
||||
export const LauncherActionConfigInitializer = new SchemaInitializer({
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { ActionInitializer, useSchemaInitializerItem } from '@tachybase/client';
|
||||
import React from 'react';
|
||||
import { ActionInitializer, useSchemaInitializerItem } from '@tachybase/client';
|
||||
|
||||
// 区块-配置操作
|
||||
export const LauncherActionConfigComponent = () => {
|
||||
|
@ -1,6 +1,8 @@
|
||||
import { useAPIClient, useActionContext } from '@tachybase/client';
|
||||
import { useActionContext, useAPIClient } from '@tachybase/client';
|
||||
import { useField } from '@tachybase/schema';
|
||||
|
||||
import _ from 'lodash';
|
||||
|
||||
import { useContextApprovalExecution } from '../../context/ApprovalExecution';
|
||||
|
||||
export function useDestroyAction() {
|
||||
|
@ -1,9 +1,10 @@
|
||||
import { useEffect } from 'react';
|
||||
import { useCurrentUserContext } from '@tachybase/client';
|
||||
import { useFlowContext } from '@tachybase/plugin-workflow/client';
|
||||
import { useForm } from '@tachybase/schema';
|
||||
import { useEffect } from 'react';
|
||||
import { useContextApprovalExecution } from '../../context/ApprovalExecution';
|
||||
|
||||
import { ApprovalStatusEnums } from '../../constants';
|
||||
import { useContextApprovalExecution } from '../../context/ApprovalExecution';
|
||||
|
||||
export function useFormBlockProps() {
|
||||
const { approval, id } = useContextApprovalExecution();
|
||||
|
@ -1,9 +1,11 @@
|
||||
import { useAPIClient, useActionContext } from '@tachybase/client';
|
||||
import { useActionContext, useAPIClient } from '@tachybase/client';
|
||||
import { useField, useForm } from '@tachybase/schema';
|
||||
|
||||
import { Toast } from 'antd-mobile';
|
||||
import _ from 'lodash';
|
||||
|
||||
import { useContextApprovalExecution } from '../../context/ApprovalExecution';
|
||||
import { useContextApprovalStatus } from '../provider/ApplyActionStatus';
|
||||
import { Toast } from 'antd-mobile';
|
||||
|
||||
export function useUpdateSubmit() {
|
||||
const from = useForm();
|
||||
|
@ -1,8 +1,10 @@
|
||||
import { useAPIClient, useActionContext } from '@tachybase/client';
|
||||
import { useActionContext, useAPIClient } from '@tachybase/client';
|
||||
import { useField } from '@tachybase/schema';
|
||||
import { useContextApprovalExecution } from '../../context/ApprovalExecution';
|
||||
|
||||
import { Toast } from 'antd-mobile';
|
||||
|
||||
import { useContextApprovalExecution } from '../../context/ApprovalExecution';
|
||||
|
||||
// 撤回
|
||||
export function useWithdrawAction() {
|
||||
const field = useField();
|
||||
|
@ -1,6 +1,7 @@
|
||||
import { useCurrentUserContext } from '@tachybase/client';
|
||||
import { useContextApprovalExecution } from '../../context/ApprovalExecution';
|
||||
|
||||
import { APPROVAL_ACTION_STATUS } from '../../constants';
|
||||
import { useContextApprovalExecution } from '../../context/ApprovalExecution';
|
||||
|
||||
export function ActionBarProvider(props) {
|
||||
const { data } = useCurrentUserContext();
|
||||
|
@ -1,7 +1,7 @@
|
||||
import React, { useContext } from 'react';
|
||||
import React, { createContext, useContext } from 'react';
|
||||
import { useCurrentUserContext } from '@tachybase/client';
|
||||
import { useFlowContext } from '@tachybase/plugin-workflow/client';
|
||||
import { createContext } from 'react';
|
||||
|
||||
import { APPROVAL_ACTION_STATUS } from '../../constants';
|
||||
import { useContextApprovalExecution } from '../../context/ApprovalExecution';
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
import { useCurrentUserContext } from '@tachybase/client';
|
||||
|
||||
import { APPROVAL_ACTION_STATUS } from '../../constants';
|
||||
import { useContextApprovalExecution } from '../../context/ApprovalExecution';
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { tval as nTval, i18n } from '@tachybase/client';
|
||||
import { i18n, tval as nTval } from '@tachybase/client';
|
||||
|
||||
export const NAMESPACE = '@hera/plugin-approval-mobile';
|
||||
|
||||
|
@ -1,18 +1,22 @@
|
||||
import { BlockItem, ExtendCollectionsProvider } from '@tachybase/client';
|
||||
import { SearchBar, Space, Tabs } from 'antd-mobile';
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { TabApplicantType } from './component/TabApplicantType';
|
||||
import { TabApprovalType } from './component/TabApprovalType';
|
||||
import { TabApprovalItem } from './component/TabApprovalItem';
|
||||
import { BlockItem, ExtendCollectionsProvider } from '@tachybase/client';
|
||||
import { observer } from '@tachybase/schema';
|
||||
|
||||
import { SearchBar, Space, Tabs } from 'antd-mobile';
|
||||
|
||||
import { TabApplicantType } from './component/TabApplicantType';
|
||||
import { TabApprovalItem } from './component/TabApprovalItem';
|
||||
import { TabApprovalType } from './component/TabApprovalType';
|
||||
|
||||
import '../style/style.css';
|
||||
|
||||
import { CollectionApprovals } from '../collection/Approvals.collection';
|
||||
import { CollectionApprovalTodos } from '../collection/ApprovalTodos';
|
||||
import { CollectionFlowNodes } from '../collection/FlowNodes.collection';
|
||||
import { CollectionWorkflows } from '../collection/Workflows.collection';
|
||||
import { ApprovalReachDataType } from '../component/ApprovalReachDataType';
|
||||
import { ApprovalTemplateType } from '../component/ApprovalTemplateType';
|
||||
import { PendingStatus, ProcessedStatus } from '../constants';
|
||||
import { CollectionWorkflows } from '../collection/Workflows.collection';
|
||||
import { CollectionFlowNodes } from '../collection/FlowNodes.collection';
|
||||
import { CollectionApprovals } from '../collection/Approvals.collection';
|
||||
import { CollectionApprovalTodos } from '../collection/ApprovalTodos';
|
||||
|
||||
export const TodosBlock = observer((props) => {
|
||||
const [filter, setFilter] = useState({
|
||||
|
@ -1,8 +1,10 @@
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { useAPIClient } from '@tachybase/client';
|
||||
import { observer, useFieldSchema } from '@tachybase/schema';
|
||||
|
||||
import { Picker, Space } from 'antd-mobile';
|
||||
import { DownOutline } from 'antd-mobile-icons';
|
||||
import React, { useEffect, useState } from 'react';
|
||||
|
||||
import { useTranslation } from '../../locale';
|
||||
|
||||
export const TabApplicantType = observer((props) => {
|
||||
|
@ -1,8 +1,10 @@
|
||||
import React, { useState } from 'react';
|
||||
import { observer } from '@tachybase/schema';
|
||||
|
||||
import { Picker, Space } from 'antd-mobile';
|
||||
import { DownOutline } from 'antd-mobile-icons';
|
||||
import React, { useState } from 'react';
|
||||
import { ProcessedStatus, approvalStatusOptions } from '../../constants';
|
||||
|
||||
import { approvalStatusOptions, ProcessedStatus } from '../../constants';
|
||||
import { useTranslation } from '../../locale';
|
||||
|
||||
export const TabApprovalType = observer((props) => {
|
||||
|
@ -1,5 +1,6 @@
|
||||
import { useFormBlockContext } from '@tachybase/client';
|
||||
import { useEffect } from 'react';
|
||||
import { useFormBlockContext } from '@tachybase/client';
|
||||
|
||||
import { useContextApprovalExecution } from '../../context/ApprovalExecution';
|
||||
|
||||
export function useApprovalDetailBlockProps() {
|
||||
|
@ -1,6 +1,8 @@
|
||||
import { useAPIClient, useActionContext } from '@tachybase/client';
|
||||
import { useActionContext, useAPIClient } from '@tachybase/client';
|
||||
import { useField } from '@tachybase/schema';
|
||||
|
||||
import _ from 'lodash';
|
||||
|
||||
import { useContextApprovalExecution } from '../../context/ApprovalExecution';
|
||||
|
||||
export function useDestroyAction() {
|
||||
|
@ -1,8 +1,9 @@
|
||||
import { useEffect } from 'react';
|
||||
import { useCurrentUserContext } from '@tachybase/client';
|
||||
import { useForm } from '@tachybase/schema';
|
||||
import { useEffect } from 'react';
|
||||
import { useContextApprovalExecution } from '../../context/ApprovalExecution';
|
||||
|
||||
import { ApprovalStatusEnumDict } from '../../constants';
|
||||
import { useContextApprovalExecution } from '../../context/ApprovalExecution';
|
||||
|
||||
export function useFormBlockProps() {
|
||||
const { approval, id, workflow } = useContextApprovalExecution();
|
||||
|
@ -1,8 +1,10 @@
|
||||
import { useAPIClient, useActionContext } from '@tachybase/client';
|
||||
import { useActionContext, useAPIClient } from '@tachybase/client';
|
||||
import { useField, useForm } from '@tachybase/schema';
|
||||
|
||||
import { Toast } from 'antd-mobile';
|
||||
|
||||
import { useContextApprovalExecution } from '../../context/ApprovalExecution';
|
||||
import { useContextApprovalAction } from '../provider/ApprovalAction';
|
||||
import { Toast } from 'antd-mobile';
|
||||
|
||||
export function useSubmit() {
|
||||
const field = useField();
|
||||
|
@ -1,9 +1,11 @@
|
||||
import React from 'react';
|
||||
import { ActionBarProvider as ClientActionBarProvider, useCompile } from '@tachybase/client';
|
||||
import { str2moment } from '@tachybase/utils/client';
|
||||
|
||||
import { Space, Tag } from 'antd';
|
||||
import { useContextApprovalExecution } from '../../context/ApprovalExecution';
|
||||
|
||||
import { approvalStatusOptions } from '../../constants';
|
||||
import { useContextApprovalExecution } from '../../context/ApprovalExecution';
|
||||
|
||||
export function ActionBarProvider(props) {
|
||||
const { status } = useContextApprovalExecution();
|
||||
|
@ -1,6 +1,6 @@
|
||||
import React, { useContext } from 'react';
|
||||
import React, { createContext, useContext } from 'react';
|
||||
import { useCurrentUserContext } from '@tachybase/client';
|
||||
import { createContext } from 'react';
|
||||
|
||||
import { APPROVAL_ACTION_STATUS } from '../../constants';
|
||||
import { useContextApprovalExecution } from '../../context/ApprovalExecution';
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
import React, { useContext } from 'react';
|
||||
import { createContext } from 'react';
|
||||
import React, { createContext, useContext } from 'react';
|
||||
|
||||
import { useContextApprovalExecution } from '../../context/ApprovalExecution';
|
||||
|
||||
export interface ApprovalAction {
|
||||
|
@ -1,3 +1,4 @@
|
||||
import React, { Fragment, useContext, useMemo, useRef } from 'react';
|
||||
import {
|
||||
BlockRequestContext_deprecated,
|
||||
FormActiveFieldsProvider,
|
||||
@ -8,9 +9,10 @@ import {
|
||||
useCurrentUserContext,
|
||||
useDesignable,
|
||||
} from '@tachybase/client';
|
||||
import { RecursionField, createForm, useField, useFieldSchema } from '@tachybase/schema';
|
||||
import { createForm, RecursionField, useField, useFieldSchema } from '@tachybase/schema';
|
||||
|
||||
import _ from 'lodash';
|
||||
import React, { Fragment, useContext, useMemo, useRef } from 'react';
|
||||
|
||||
import { useContextApprovalExecution } from '../../context/ApprovalExecution';
|
||||
|
||||
export function ApprovalFormBlockDecorator(props) {
|
||||
|
@ -1,4 +1,5 @@
|
||||
import { useCurrentUserContext } from '@tachybase/client';
|
||||
|
||||
import { APPROVAL_ACTION_STATUS } from '../../constants';
|
||||
import { useContextApprovalExecution } from '../../context/ApprovalExecution';
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
import { Plugin } from '@tachybase/client';
|
||||
|
||||
import PluginApproval from './approval';
|
||||
|
||||
export class PluginApprovalMobileClient extends Plugin {
|
||||
|
@ -1,4 +1,4 @@
|
||||
import React from 'react';
|
||||
import React, { Fragment, useContext, useMemo, useRef } from 'react';
|
||||
import {
|
||||
BlockRequestContext_deprecated,
|
||||
CollectionProvider_deprecated,
|
||||
@ -11,8 +11,8 @@ import {
|
||||
useAssociationNames,
|
||||
useDesignable,
|
||||
} from '@tachybase/client';
|
||||
import { RecursionField, createForm, useField, useFieldSchema } from '@tachybase/schema';
|
||||
import { Fragment, useContext, useMemo, useRef } from 'react';
|
||||
import { createForm, RecursionField, useField, useFieldSchema } from '@tachybase/schema';
|
||||
|
||||
import { useContextApprovalExecution } from '../usage/approval-block/common/ApprovalExecution.provider';
|
||||
|
||||
export const FormBlockProvider = (props) => {
|
||||
|
@ -1,5 +1,6 @@
|
||||
import { useActionContext } from '@tachybase/client';
|
||||
import React from 'react';
|
||||
import { useActionContext } from '@tachybase/client';
|
||||
|
||||
import { ConfigButtonView } from '../../trigger/ConfigButton.view';
|
||||
import { ContextApproverConfig } from '../Pd.ContextApproverConfig';
|
||||
|
||||
|
@ -1,8 +1,9 @@
|
||||
import { Plugin } from '@tachybase/client';
|
||||
import PluginWorkflow from '@tachybase/plugin-workflow/client';
|
||||
import { ApprovalInstruction } from './node.ApprovalInstruction';
|
||||
|
||||
import { ApproverActionConfigInitializer } from './approver-interface/Iz.ApproverActionConfig';
|
||||
import { ApproverAddBlockInitializer } from './approver-interface/Iz.ApproverAddBlock';
|
||||
import { ApprovalInstruction } from './node.ApprovalInstruction';
|
||||
|
||||
export class KitApprovalInstruction extends Plugin {
|
||||
async load() {
|
||||
|
@ -1,4 +1,5 @@
|
||||
import { Plugin } from '@tachybase/client';
|
||||
|
||||
import { KitApprovalInstruction } from './instruction/plugin';
|
||||
import { KitApprovalTrigger } from './trigger/plugin';
|
||||
|
||||
|
@ -1,6 +1,8 @@
|
||||
import { ActionContextProvider } from '@tachybase/client';
|
||||
import { Button } from 'antd';
|
||||
import React, { useState } from 'react';
|
||||
import { ActionContextProvider } from '@tachybase/client';
|
||||
|
||||
import { Button } from 'antd';
|
||||
|
||||
import { useTranslation } from '../../locale';
|
||||
|
||||
// 发起人操作界面->进入配置按钮
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { ActionInitializer, useSchemaInitializerItem } from '@tachybase/client';
|
||||
import React from 'react';
|
||||
import { ActionInitializer, useSchemaInitializerItem } from '@tachybase/client';
|
||||
|
||||
// 区块-配置操作
|
||||
export const LauncherActionConfigComponent = () => {
|
||||
|
@ -1,6 +1,7 @@
|
||||
import { SchemaInitializer } from '@tachybase/client';
|
||||
import { NAMESPACE } from '../../../locale';
|
||||
|
||||
import { APPROVAL_STATUS } from '../../../constants';
|
||||
import { NAMESPACE } from '../../../locale';
|
||||
import { LauncherActionConfigComponent } from './LauncherActionConfig.component';
|
||||
|
||||
// 区块-配置操作
|
||||
|
@ -1,4 +1,5 @@
|
||||
import { SchemaInitializer, gridRowColWrap } from '@tachybase/client';
|
||||
import { gridRowColWrap, SchemaInitializer } from '@tachybase/client';
|
||||
|
||||
import { NAMESPACE } from '../../../locale';
|
||||
import { LauncherAddBlockButtonComponent } from './LauncherBlockButton.component';
|
||||
|
||||
|
@ -1,16 +1,16 @@
|
||||
import React from 'react';
|
||||
import {
|
||||
SchemaInitializerItem,
|
||||
createFormBlockSchema,
|
||||
SchemaInitializerItem,
|
||||
useCollection_deprecated,
|
||||
useRecordCollectionDataSourceItems,
|
||||
useSchemaInitializer,
|
||||
useSchemaInitializerItem,
|
||||
useSchemaTemplateManager,
|
||||
} from '@tachybase/client';
|
||||
|
||||
import { APPROVAL_STATUS, flatSchemaArray } from '../../../constants';
|
||||
import { NAMESPACE } from '../../../locale';
|
||||
import { flatSchemaArray } from '../../../constants';
|
||||
import { APPROVAL_STATUS } from '../../../constants';
|
||||
|
||||
// 创建区块-Initializer的component
|
||||
export const LauncherAddBlockButtonComponent = () => {
|
||||
|
@ -1,3 +1,4 @@
|
||||
import React, { useContext } from 'react';
|
||||
import {
|
||||
SchemaComponent,
|
||||
SchemaComponentContext,
|
||||
@ -8,8 +9,8 @@ import {
|
||||
} from '@tachybase/client';
|
||||
import { useFlowContext } from '@tachybase/plugin-workflow/client';
|
||||
import { uid } from '@tachybase/utils/client';
|
||||
|
||||
import { Spin } from 'antd';
|
||||
import React, { useContext } from 'react';
|
||||
|
||||
// 发起人操作界面-创建区块
|
||||
export const SchemaAddBlock = ({ value, onChange }) => {
|
||||
|
@ -1,5 +1,6 @@
|
||||
import { Plugin } from '@tachybase/client';
|
||||
import PluginWorkflow from '@tachybase/plugin-workflow/client';
|
||||
|
||||
import { ApprovalTrigger } from './Approval.trigger';
|
||||
import { LauncherActionConfigInitializer } from './launcher-interface/LauncherActionConfig.initializer';
|
||||
import { LauncherAddBlockButtonIntializer } from './launcher-interface/LauncherAddBlockButton.initializer';
|
||||
|
@ -1,11 +1,12 @@
|
||||
import { Plugin } from '@tachybase/client';
|
||||
import { TableOutlined } from '@ant-design/icons';
|
||||
import { SchemaInitializerItem, useSchemaInitializer, useSchemaInitializerItem } from '@tachybase/client';
|
||||
import { uid } from '@tachybase/utils/client';
|
||||
import React from 'react';
|
||||
import { Plugin, SchemaInitializerItem, useSchemaInitializer, useSchemaInitializerItem } from '@tachybase/client';
|
||||
import { uid } from '@tachybase/utils/client';
|
||||
|
||||
import { TableOutlined } from '@ant-design/icons';
|
||||
|
||||
import { NAMESPACE } from '../../locale';
|
||||
import { ApprovalBlockLaunch } from './launch/VC.ApprovalBlockLaunch';
|
||||
import { ApprovalBlockProvider } from './ApprovalBlock.provider';
|
||||
import { ApprovalBlockLaunch } from './launch/VC.ApprovalBlockLaunch';
|
||||
import { ApprovalBlockTodos } from './todos/VC.ApprovalBlockTodos';
|
||||
|
||||
export class SCApprovalBlock extends Plugin {
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { FlowContext } from '@tachybase/plugin-workflow/client';
|
||||
import React, { useContext } from 'react';
|
||||
import { FlowContext } from '@tachybase/plugin-workflow/client';
|
||||
|
||||
export function useFlowContext() {
|
||||
return useContext(FlowContext);
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { SchemaComponentContext, useSchemaComponentContext } from '@tachybase/client';
|
||||
import React from 'react';
|
||||
import { SchemaComponentContext, useSchemaComponentContext } from '@tachybase/client';
|
||||
|
||||
export function SchemaComponentContextProvider({ designable, children }) {
|
||||
const schemaComponentContext = useSchemaComponentContext();
|
||||
|
@ -1,7 +1,8 @@
|
||||
import { useCurrentUserContext } from '@tachybase/client';
|
||||
import { useContextApprovalExecution } from '../common/ApprovalExecution.provider';
|
||||
import { useApproval } from '../../approval-common/ApprovalData.provider';
|
||||
|
||||
import { APPROVAL_STATUS } from '../../../constants';
|
||||
import { useApproval } from '../../approval-common/ApprovalData.provider';
|
||||
import { useContextApprovalExecution } from '../common/ApprovalExecution.provider';
|
||||
|
||||
export function ActionBarProvider(props) {
|
||||
const { data } = useCurrentUserContext();
|
||||
|
@ -1,9 +1,9 @@
|
||||
import React, { useContext } from 'react';
|
||||
import React, { createContext, useContext } from 'react';
|
||||
import { useCurrentUserContext } from '@tachybase/client';
|
||||
import { useFlowContext } from '@tachybase/plugin-workflow/client';
|
||||
import { createContext } from 'react';
|
||||
import { useApproval } from '../../approval-common/ApprovalData.provider';
|
||||
|
||||
import { APPROVAL_STATUS } from '../../../constants';
|
||||
import { useApproval } from '../../approval-common/ApprovalData.provider';
|
||||
|
||||
const ContextApprovalStatus = createContext(APPROVAL_STATUS.SUBMITTED);
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
import { useCurrentUserContext } from '@tachybase/client';
|
||||
import { useFlowContext } from '@tachybase/plugin-workflow/client';
|
||||
|
||||
import { APPROVAL_STATUS } from '../../../constants';
|
||||
import { useApproval } from '../../approval-common/ApprovalData.provider';
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import React from 'react';
|
||||
import React, { useContext } from 'react';
|
||||
import {
|
||||
RemoteSchemaComponent,
|
||||
SchemaComponent,
|
||||
@ -9,22 +9,23 @@ import {
|
||||
} from '@tachybase/client';
|
||||
import { DetailsBlockProvider, FlowContext } from '@tachybase/plugin-workflow/client';
|
||||
import { useForm } from '@tachybase/schema';
|
||||
|
||||
import { Result, Spin } from 'antd';
|
||||
import { useContext } from 'react';
|
||||
import { NAMESPACE } from '../../../locale';
|
||||
|
||||
import { FormBlockProvider } from '../../../common/Pd.FormBlock';
|
||||
import { ContextApprovalExecution } from '../common/ApprovalExecution.provider';
|
||||
import { NAMESPACE } from '../../../locale';
|
||||
import { ApprovalContext } from '../../approval-common/ApprovalData.provider';
|
||||
import { ContextWithActionEnabled } from '../../approval-common/WithActionEnabled.provider';
|
||||
import { ContextApprovalExecution } from '../common/ApprovalExecution.provider';
|
||||
import { FlowContextProvider } from '../common/FlowContext.provider';
|
||||
import { SchemaComponentContextProvider } from '../common/SchemaComponent.provider';
|
||||
import { useDestroyAction } from './hooks/useDestroyAction';
|
||||
import { useFormBlockProps } from './hooks/useFormBlockProps';
|
||||
import { useSubmit } from './hooks/useSubmit';
|
||||
import { useWithdrawAction } from './hooks/useWithdrawAction';
|
||||
import { useDestroyAction } from './hooks/useDestroyAction';
|
||||
import { ActionBarProvider } from './Pd.ActionBar';
|
||||
import { WithdrawActionProvider } from './Pd.WithdrawAction';
|
||||
import { SchemaComponentContextProvider } from '../common/SchemaComponent.provider';
|
||||
import { ApplyActionStatusProvider } from './Pd.ApplyActionStatus';
|
||||
import { FlowContextProvider } from '../common/FlowContext.provider';
|
||||
import { WithdrawActionProvider } from './Pd.WithdrawAction';
|
||||
|
||||
export const ViewActionLaunchContent = () => {
|
||||
const { id } = useRecord();
|
||||
|
@ -1,8 +1,10 @@
|
||||
import { useAPIClient, useActionContext } from '@tachybase/client';
|
||||
import { useActionContext, useAPIClient } from '@tachybase/client';
|
||||
import { useField } from '@tachybase/schema';
|
||||
import { useApproval } from '../../../approval-common/ApprovalData.provider';
|
||||
|
||||
import _ from 'lodash';
|
||||
|
||||
import { useApproval } from '../../../approval-common/ApprovalData.provider';
|
||||
|
||||
export function useDestroyAction() {
|
||||
const field = useField();
|
||||
const { setVisible, setSubmitted } = useActionContext() as any;
|
||||
|
@ -1,10 +1,11 @@
|
||||
import { useEffect } from 'react';
|
||||
import { useCurrentUserContext } from '@tachybase/client';
|
||||
import { useFlowContext } from '@tachybase/plugin-workflow/client';
|
||||
import { useForm } from '@tachybase/schema';
|
||||
import { useEffect } from 'react';
|
||||
import { useContextApprovalExecution } from '../../common/ApprovalExecution.provider';
|
||||
import { useApproval } from '../../../approval-common/ApprovalData.provider';
|
||||
|
||||
import { ApprovalStatusEnumDict } from '../../../../constants';
|
||||
import { useApproval } from '../../../approval-common/ApprovalData.provider';
|
||||
import { useContextApprovalExecution } from '../../common/ApprovalExecution.provider';
|
||||
|
||||
export function useFormBlockProps() {
|
||||
const approval = useApproval() as any;
|
||||
|
@ -1,7 +1,9 @@
|
||||
import { useAPIClient, useActionContext } from '@tachybase/client';
|
||||
import { useActionContext, useAPIClient } from '@tachybase/client';
|
||||
import { useFlowContext } from '@tachybase/plugin-workflow/client';
|
||||
import { useField, useForm } from '@tachybase/schema';
|
||||
|
||||
import _ from 'lodash';
|
||||
|
||||
import { useApproval } from '../../../approval-common/ApprovalData.provider';
|
||||
import { useContextApprovalStatus } from '../Pd.ApplyActionStatus';
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
import { useAPIClient, useActionContext } from '@tachybase/client';
|
||||
import { useActionContext, useAPIClient } from '@tachybase/client';
|
||||
import { useField } from '@tachybase/schema';
|
||||
|
||||
import { useApproval } from '../../../approval-common/ApprovalData.provider';
|
||||
|
||||
// 撤回
|
||||
|
@ -1,4 +1,5 @@
|
||||
import { createContext, useContext } from 'react';
|
||||
|
||||
export interface Approval {
|
||||
id: number;
|
||||
collectionName: string;
|
||||
|
@ -1,3 +1,4 @@
|
||||
import React, { useContext } from 'react';
|
||||
import {
|
||||
RemoteSchemaComponent,
|
||||
SchemaComponent,
|
||||
@ -7,9 +8,10 @@ import {
|
||||
useRequest,
|
||||
} from '@tachybase/client';
|
||||
import { DetailsBlockProvider, ExecutionContextProvider } from '@tachybase/plugin-workflow/client';
|
||||
|
||||
import { Result, Spin } from 'antd';
|
||||
import _ from 'lodash';
|
||||
import React, { useContext } from 'react';
|
||||
|
||||
import { FormBlockProvider } from '../../../common/Pd.FormBlock';
|
||||
import { NAMESPACE, useTranslation } from '../../../locale';
|
||||
import { ApprovalContext } from '../../approval-common/ApprovalData.provider';
|
||||
@ -17,12 +19,12 @@ import { ContextWithActionEnabled } from '../../approval-common/WithActionEnable
|
||||
import { ContextApprovalExecution } from '../common/ApprovalExecution.provider';
|
||||
import { SchemaComponentContextProvider } from '../common/SchemaComponent.provider';
|
||||
import { ApprovalFormBlockDecorator } from './Dt.ApprovalFormBlock';
|
||||
import { ActionBarProvider } from './Pd.ActionBarProvider';
|
||||
import { ApprovalActionProvider } from './Pd.ApprovalAction';
|
||||
import { ContextApprovalExecutions } from './Pd.ApprovalExecutions';
|
||||
import { useApprovalDetailBlockProps } from './hooks/useApprovalDetailBlockProps';
|
||||
import { useApprovalFormBlockProps } from './hooks/useApprovalFormBlockProps';
|
||||
import { useSubmit } from './hooks/useSubmit';
|
||||
import { ActionBarProvider } from './Pd.ActionBarProvider';
|
||||
import { ApprovalActionProvider } from './Pd.ApprovalAction';
|
||||
import { ContextApprovalExecutions } from './Pd.ApprovalExecutions';
|
||||
|
||||
// 审批-待办-查看: 内容
|
||||
export const ViewActionTodosContent = () => {
|
||||
|
@ -1,5 +1,6 @@
|
||||
import { useRecord } from '@tachybase/client';
|
||||
import React, { createContext, useContext } from 'react';
|
||||
import { useRecord } from '@tachybase/client';
|
||||
|
||||
import { Approval } from '../approval-block/todos/Pd.ApprovalExecutions';
|
||||
|
||||
export const ApprovalContext = createContext<Partial<Approval>>({});
|
||||
|
@ -1,13 +1,15 @@
|
||||
import React, { useMemo } from 'react';
|
||||
import { createStyles, useCurrentUserContext } from '@tachybase/client';
|
||||
import { EXECUTION_STATUS } from '@tachybase/plugin-workflow/client';
|
||||
|
||||
import { Space, Table } from 'antd';
|
||||
import _ from 'lodash';
|
||||
import React, { useMemo } from 'react';
|
||||
|
||||
import { APPROVAL_ACTION_STATUS, APPROVAL_STATUS } from '../../constants';
|
||||
import { lang, usePluginTranslation } from '../../locale';
|
||||
import { useApproval } from './ApprovalData.provider';
|
||||
import { ContextWithActionEnabled } from './WithActionEnabled.provider';
|
||||
import { getAntdTableColumns } from './process-columns/columns';
|
||||
import { ContextWithActionEnabled } from './WithActionEnabled.provider';
|
||||
|
||||
// 审批(发起/待办)区块-查看-审批处理
|
||||
export const ApprovalProcess = (props) => {
|
||||
|
@ -1,8 +1,9 @@
|
||||
import { DatePicker, InputReadPretty, RecordProvider, useCurrentUserContext } from '@tachybase/client';
|
||||
import React, { useContext } from 'react';
|
||||
import { ContextWithActionEnabled } from '../WithActionEnabled.provider';
|
||||
import { DatePicker, InputReadPretty, RecordProvider, useCurrentUserContext } from '@tachybase/client';
|
||||
|
||||
import { ViewActionLaunch } from '../../approval-block/launch/VC.ViewActionLaunch';
|
||||
import { ViewActionTodos } from '../../approval-block/todos/VC.ViewActionTodos';
|
||||
import { ContextWithActionEnabled } from '../WithActionEnabled.provider';
|
||||
|
||||
// Component开头的是,不知道起什么名字合适的
|
||||
export function renderColumnDetail(e, props, exist) {
|
||||
|
@ -1,14 +1,15 @@
|
||||
import React, { useMemo } from 'react';
|
||||
import {
|
||||
CollectionProvider_deprecated,
|
||||
ExtendCollectionsProvider,
|
||||
List,
|
||||
joinCollectionName,
|
||||
List,
|
||||
useCollection_deprecated,
|
||||
useRecord,
|
||||
} from '@tachybase/client';
|
||||
import React, { useMemo } from 'react';
|
||||
import { CollectionApprovals } from '../approval-common/Approvals.collection';
|
||||
|
||||
import { CollectionApprovalTodos } from '../../common/Cn.ApprovalTodos';
|
||||
import { CollectionApprovals } from '../approval-common/Approvals.collection';
|
||||
import { CollectionFlowNodes } from '../approval-common/FlowNodes.collection';
|
||||
import { CollectionWorkflows } from '../approval-common/Workflows.collection';
|
||||
|
||||
|
@ -1,7 +1,8 @@
|
||||
import { AuditOutlined } from '@ant-design/icons';
|
||||
import React from 'react';
|
||||
import { SchemaInitializerItem, useSchemaInitializer, useSchemaInitializerItem } from '@tachybase/client';
|
||||
import { uid } from '@tachybase/utils/client';
|
||||
import React from 'react';
|
||||
|
||||
import { AuditOutlined } from '@ant-design/icons';
|
||||
|
||||
// 初始化器,创建区块-相关审批
|
||||
export function RecordApprovalsInitializer() {
|
||||
|
@ -1,5 +1,6 @@
|
||||
import { SchemaComponent } from '@tachybase/client';
|
||||
import React from 'react';
|
||||
import { SchemaComponent } from '@tachybase/client';
|
||||
|
||||
import { ApprovalRecordStatusColumn } from '../approval-common/approval-columns/column.status';
|
||||
import { UserColumn } from '../approval-common/approval-columns/column.user';
|
||||
import { WorkflowColumn } from '../approval-common/approval-columns/column.workflow';
|
||||
|
@ -1,14 +1,19 @@
|
||||
import React, { forwardRef, useEffect, useImperativeHandle, useState } from 'react';
|
||||
import { Spin, Tag } from 'antd';
|
||||
|
||||
import { LoadingOutlined } from '@ant-design/icons';
|
||||
import { Document, Page, pdfjs } from 'react-pdf';
|
||||
import { Spin, Tag } from 'antd';
|
||||
import { saveAs } from 'file-saver';
|
||||
import { Document, Page, pdfjs } from 'react-pdf';
|
||||
|
||||
import 'react-pdf/dist/Page/AnnotationLayer.css';
|
||||
import 'react-pdf/dist/Page/TextLayer.css';
|
||||
import { uid } from '@tachybase/schema';
|
||||
|
||||
import { css, useRequest } from '@tachybase/client';
|
||||
import { uid } from '@tachybase/schema';
|
||||
|
||||
import { TransformComponent, TransformWrapper } from 'react-zoom-pan-pinch';
|
||||
|
||||
import { useTranslation } from '../locale';
|
||||
import { TransformWrapper, TransformComponent } from 'react-zoom-pan-pinch';
|
||||
|
||||
const options = {
|
||||
cMapUrl: '/cmaps/',
|
||||
|
@ -0,0 +1,10 @@
|
||||
// 1. 拆解 refined 文件, 根据归类原则
|
||||
// 2. 反编译文件
|
||||
// 3. 根据功能进行归类, 根据就近原则
|
||||
|
||||
## 1. 拆解 refined 文件, 根据归类原则
|
||||
// 完成
|
||||
## 2. 反编译文件
|
||||
// 正在进行中
|
||||
// 备份代码, 可查看标签 backup-dev-20240527-departments
|
||||
## 3. 根据功能进行归类, 根据就近原则
|
@ -0,0 +1,91 @@
|
||||
// 数据表-部门
|
||||
export const collectionDepartments = {
|
||||
name: 'departments',
|
||||
fields: [
|
||||
{
|
||||
interface: 'id',
|
||||
type: 'bigInt',
|
||||
name: 'id',
|
||||
primaryKey: true,
|
||||
autoIncrement: true,
|
||||
uiSchema: {
|
||||
type: 'id',
|
||||
title: '{{t("ID")}}',
|
||||
},
|
||||
},
|
||||
{
|
||||
interface: 'input',
|
||||
type: 'string',
|
||||
name: 'title',
|
||||
uiSchema: {
|
||||
type: 'string',
|
||||
title: '{{t("Department name")}}',
|
||||
'x-component': 'Input',
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
interface: 'm2o',
|
||||
type: 'belongsTo',
|
||||
name: 'parent',
|
||||
collectionName: 'departments',
|
||||
foreignKey: 'parentId',
|
||||
target: 'departments',
|
||||
targetKey: 'id',
|
||||
treeParent: true,
|
||||
uiSchema: {
|
||||
title: '{{t("Superior department")}}',
|
||||
'x-component': 'DepartmentSelect',
|
||||
},
|
||||
},
|
||||
{
|
||||
interface: 'm2m',
|
||||
type: 'belongsToMany',
|
||||
name: 'roles',
|
||||
target: 'roles',
|
||||
collectionName: 'departments',
|
||||
through: 'departmentsRoles',
|
||||
foreignKey: 'departmentId',
|
||||
otherKey: 'roleName',
|
||||
targetKey: 'name',
|
||||
sourceKey: 'id',
|
||||
uiSchema: {
|
||||
title: '{{t("Roles")}}',
|
||||
'x-component': 'AssociationField',
|
||||
'x-component-props': {
|
||||
multiple: true,
|
||||
fieldNames: {
|
||||
label: 'title',
|
||||
value: 'name',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
interface: 'm2m',
|
||||
type: 'belongsToMany',
|
||||
name: 'owners',
|
||||
collectionName: 'departments',
|
||||
target: 'users',
|
||||
through: 'departmentsUsers',
|
||||
foreignKey: 'departmentId',
|
||||
otherKey: 'userId',
|
||||
targetKey: 'id',
|
||||
sourceKey: 'id',
|
||||
scope: {
|
||||
isOwner: true,
|
||||
},
|
||||
uiSchema: {
|
||||
title: '{{t("Owners")}}',
|
||||
'x-component': 'AssociationField',
|
||||
'x-component-props': {
|
||||
multiple: true,
|
||||
fieldNames: {
|
||||
label: 'nickname',
|
||||
value: 'id',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
@ -0,0 +1,132 @@
|
||||
// 数据表-用户
|
||||
export const collectionUsers = {
|
||||
name: 'users',
|
||||
fields: [
|
||||
{
|
||||
interface: 'id',
|
||||
type: 'bigInt',
|
||||
name: 'id',
|
||||
primaryKey: true,
|
||||
autoIncrement: true,
|
||||
allowNull: false,
|
||||
uiSchema: {
|
||||
type: 'number',
|
||||
title: '{{t("ID")}}',
|
||||
'x-component': 'InputNumber',
|
||||
'x-read-pretty': true,
|
||||
},
|
||||
},
|
||||
{
|
||||
interface: 'input',
|
||||
type: 'string',
|
||||
name: 'nickname',
|
||||
uiSchema: {
|
||||
type: 'string',
|
||||
title: '{{t("Nickname")}}',
|
||||
'x-component': 'Input',
|
||||
},
|
||||
},
|
||||
{
|
||||
interface: 'input',
|
||||
type: 'string',
|
||||
name: 'username',
|
||||
unique: true,
|
||||
uiSchema: {
|
||||
type: 'string',
|
||||
title: '{{t("Username")}}',
|
||||
'x-component': 'Input',
|
||||
'x-validator': {
|
||||
username: true,
|
||||
},
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
interface: 'email',
|
||||
type: 'string',
|
||||
name: 'email',
|
||||
unique: true,
|
||||
uiSchema: {
|
||||
type: 'string',
|
||||
title: '{{t("Email")}}',
|
||||
'x-component': 'Input',
|
||||
'x-validator': 'email',
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
interface: 'phone',
|
||||
type: 'string',
|
||||
name: 'phone',
|
||||
unique: true,
|
||||
uiSchema: {
|
||||
type: 'string',
|
||||
title: '{{t("Phone")}}',
|
||||
'x-component': 'Input',
|
||||
'x-validator': 'phone',
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
interface: 'm2m',
|
||||
type: 'belongsToMany',
|
||||
name: 'roles',
|
||||
target: 'roles',
|
||||
foreignKey: 'userId',
|
||||
otherKey: 'roleName',
|
||||
onDelete: 'CASCADE',
|
||||
sourceKey: 'id',
|
||||
targetKey: 'name',
|
||||
through: 'rolesUsers',
|
||||
uiSchema: {
|
||||
type: 'array',
|
||||
title: '{{t("Roles")}}',
|
||||
'x-component': 'AssociationField',
|
||||
'x-component-props': {
|
||||
multiple: true,
|
||||
fieldNames: {
|
||||
label: 'title',
|
||||
value: 'name',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
interface: 'm2m',
|
||||
type: 'belongsToMany',
|
||||
name: 'departments',
|
||||
target: 'departments',
|
||||
foreignKey: 'userId',
|
||||
otherKey: 'departmentId',
|
||||
onDelete: 'CASCADE',
|
||||
sourceKey: 'id',
|
||||
targetKey: 'id',
|
||||
through: 'departmentsUsers',
|
||||
uiSchema: {
|
||||
type: 'array',
|
||||
title: '{{t("Departments")}}',
|
||||
'x-component': 'DepartmentField',
|
||||
},
|
||||
},
|
||||
{
|
||||
interface: 'm2m',
|
||||
type: 'belongsToMany',
|
||||
name: 'mainDepartment',
|
||||
target: 'departments',
|
||||
foreignKey: 'userId',
|
||||
otherKey: 'departmentId',
|
||||
onDelete: 'CASCADE',
|
||||
sourceKey: 'id',
|
||||
targetKey: 'id',
|
||||
through: 'departmentsUsers',
|
||||
throughScope: {
|
||||
isMain: true,
|
||||
},
|
||||
uiSchema: {
|
||||
type: 'array',
|
||||
title: '{{t("Main department")}}',
|
||||
'x-component': 'DepartmentField',
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
@ -0,0 +1,59 @@
|
||||
import { SchemaComponent, useAPIClient, useResourceActionContext } from '@tachybase/client';
|
||||
import { useContext, useRef } from 'react';
|
||||
import { contextK } from '../context/contextK';
|
||||
import { k } from '../others/k';
|
||||
import { schemaAddMembers } from '../schema/addMembers.schema';
|
||||
import React from 'react';
|
||||
|
||||
export const AddMembersNnt = () => {
|
||||
const { department, useAddMembersAction, handleSelect } = useAction();
|
||||
return (
|
||||
<SchemaComponent
|
||||
scope={{
|
||||
useAddMembersAction,
|
||||
department,
|
||||
handleSelect,
|
||||
}}
|
||||
schema={schemaAddMembers}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
function useAction() {
|
||||
const { department } = useContext(contextK);
|
||||
const { refresh } = useResourceActionContext();
|
||||
const ref = useRef([]);
|
||||
const api = useAPIClient();
|
||||
const useAddMembersAction = () => ({
|
||||
run() {
|
||||
return k(this, null, function* () {
|
||||
const x = ref.current;
|
||||
|
||||
x != null &&
|
||||
x.length &&
|
||||
(yield api.resource('departments.members', department.id).add({ values: x }), (ref.current = []), refresh());
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
const useAddMembersAction2 = () => ({
|
||||
async run() {
|
||||
const x = ref.current;
|
||||
if (x?.length > 0) {
|
||||
await api.resource('departments.members', department.id).add({ values: x });
|
||||
ref.current = [];
|
||||
refresh();
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
const handleSelect = (val) => {
|
||||
ref.current = val;
|
||||
};
|
||||
|
||||
return {
|
||||
department,
|
||||
useAddMembersAction,
|
||||
handleSelect,
|
||||
};
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
import { CollectionProvider_deprecated, ResourceActionContext } from '@tachybase/client';
|
||||
import React from 'react';
|
||||
import { collectionDepartments } from '../collections/departments.collection';
|
||||
import { useContextK } from '../context/contextK';
|
||||
|
||||
export const CeComponent = ({ children }) => {
|
||||
const context = useContextK();
|
||||
const { departmentsResource } = context;
|
||||
const { service } = departmentsResource || {};
|
||||
|
||||
return (
|
||||
<ResourceActionContext.Provider value={{ ...service }}>
|
||||
<CollectionProvider_deprecated collection={collectionDepartments}>{children}</CollectionProvider_deprecated>
|
||||
</ResourceActionContext.Provider>
|
||||
);
|
||||
};
|
@ -0,0 +1,21 @@
|
||||
import { CollectionProvider_deprecated, ResourceActionContext } from '@tachybase/client';
|
||||
import React, { useContext } from 'react';
|
||||
// import { jsx } from 'react/jsx-runtime';
|
||||
import { collectionUsers } from '../collections/users.collection';
|
||||
import { contextK } from '../context/contextK';
|
||||
|
||||
export const BeComponent = ({ children }) => {
|
||||
const { usersResource } = useContext(contextK);
|
||||
const { service } = usersResource || {};
|
||||
|
||||
return (
|
||||
<ResourceActionContext.Provider value={{ ...service }}>
|
||||
<CollectionProvider_deprecated collection={collectionUsers}>{children}</CollectionProvider_deprecated>
|
||||
</ResourceActionContext.Provider>
|
||||
);
|
||||
|
||||
// return jsx(ResourceActionContext.Provider, {
|
||||
// value: { ...o },
|
||||
// children: jsx(CollectionProvider_deprecated, { collection: collectionUsers, children: e.children }),
|
||||
// });
|
||||
};
|
@ -0,0 +1,124 @@
|
||||
import { UserOutlined } from '@ant-design/icons';
|
||||
import { ActionContextProvider, RecordProvider, SchemaComponent, SchemaComponentOptions } from '@tachybase/client';
|
||||
import { Button, Divider, Row, theme } from 'antd';
|
||||
import React, { useContext, useState } from 'react';
|
||||
import { useTranslation } from '../../../locale';
|
||||
import { contextK } from '../context/contextK';
|
||||
import { ContextNProvider } from '../context/contextN';
|
||||
import { useCreateDepartment } from '../hooks/useCreateDepartment';
|
||||
import { useHooksG } from '../hooks/useHooksG';
|
||||
import { useUpdateDepartmentLe } from '../hooks/useUpdateDepartmentLe';
|
||||
import { ComponentSe } from './ComponentSe';
|
||||
import { ComponentX } from './ComponentX';
|
||||
import { ComponentXxe } from './ComponentXxe';
|
||||
import { DepartmentOwnersField } from './DepartmentOwnersField';
|
||||
|
||||
interface drawerState {
|
||||
node?: object;
|
||||
schema?: object;
|
||||
}
|
||||
|
||||
export const ComponentEEE = () => {
|
||||
const { t: tval } = useTranslation();
|
||||
|
||||
const [visible, setVisible] = useState(false);
|
||||
const [drawer, setDrawer] = useState<drawerState>({});
|
||||
|
||||
const { department, setDepartment } = useContext(contextK);
|
||||
const { token } = theme.useToken();
|
||||
const m = useHooksG({
|
||||
label: ({ node }) => <ComponentX.Item node={node} setVisible={setVisible} setDrawer={setDrawer} />,
|
||||
});
|
||||
|
||||
return (
|
||||
<SchemaComponentOptions
|
||||
scope={{
|
||||
useCreateDepartment,
|
||||
useUpdateDepartment: useUpdateDepartmentLe,
|
||||
}}
|
||||
>
|
||||
<ContextNProvider value={m}>
|
||||
<Row>
|
||||
<ComponentSe />
|
||||
<Button
|
||||
type="text"
|
||||
icon={<UserOutlined />}
|
||||
style={{
|
||||
textAlign: 'left',
|
||||
marginBottom: '5px',
|
||||
background: department ? '' : token.colorBgTextHover,
|
||||
}}
|
||||
onClick={() => {
|
||||
setDepartment(null);
|
||||
}}
|
||||
block={true}
|
||||
>
|
||||
{tval('All users')}
|
||||
</Button>
|
||||
<ComponentXxe />
|
||||
</Row>
|
||||
<Divider style={{ margin: '12px 0' }} />
|
||||
<ComponentX />
|
||||
<ActionContextProvider
|
||||
value={{
|
||||
visible: visible,
|
||||
setVisible: setVisible,
|
||||
}}
|
||||
>
|
||||
<RecordProvider record={drawer.node || {}}>
|
||||
<SchemaComponent
|
||||
scope={{
|
||||
t: tval,
|
||||
}}
|
||||
components={{
|
||||
DepartmentOwnersField,
|
||||
}}
|
||||
schema={drawer.schema || {}}
|
||||
/>
|
||||
</RecordProvider>
|
||||
</ActionContextProvider>
|
||||
</ContextNProvider>
|
||||
</SchemaComponentOptions>
|
||||
);
|
||||
|
||||
// return jsx(SchemaComponentOptions, {
|
||||
// scope: {
|
||||
// useCreateDepartment: useCreateDepartment,
|
||||
// useUpdateDepartment: useUpdateDepartmentLe,
|
||||
// },
|
||||
// children: jsxs(contextN.Provider, {
|
||||
// value: m,
|
||||
// children: [
|
||||
// jsxs(Row, {
|
||||
// children: [
|
||||
// jsx(ComponentSe, {}),
|
||||
// jsx(Button, {
|
||||
// type: 'text',
|
||||
// icon: jsx(UserOutlined, {}),
|
||||
// style: { textAlign: 'left', marginBottom: '5px', background: c ? '' : x.colorBgTextHover },
|
||||
// onClick: () => {
|
||||
// i(null);
|
||||
// },
|
||||
// block: true,
|
||||
// children: e('All users'),
|
||||
// }),
|
||||
// jsx(ComponentXxe, {}),
|
||||
// ],
|
||||
// }),
|
||||
// jsx(Divider, { style: { margin: '12px 0' } }),
|
||||
// jsx(ComponentX, {}),
|
||||
// jsx(ActionContextProvider, {
|
||||
// value: { visible: t, setVisible: o },
|
||||
// children: jsx(RecordProvider, {
|
||||
// record: a.node || {},
|
||||
// children: jsx(SchemaComponent, {
|
||||
// scope: { t: e },
|
||||
// components: { DepartmentOwnersField: DepartmentOwnersField },
|
||||
// schema: a.schema || {},
|
||||
// }),
|
||||
// }),
|
||||
// }),
|
||||
// ],
|
||||
// }),
|
||||
// });
|
||||
};
|
@ -0,0 +1,95 @@
|
||||
import { SchemaComponent, useResourceActionContext } from '@tachybase/client';
|
||||
import { useContext, useEffect, useMemo, Fragment } from 'react';
|
||||
import { jsx, jsxs } from 'react/jsx-runtime';
|
||||
import { useTranslation } from '../../../locale';
|
||||
import { contextK } from '../context/contextK';
|
||||
import { useFilterActionPropsZ } from '../scopes/useFilterActionPropsZ';
|
||||
import { DepartmentFieldYe } from './DepartmentFieldYe';
|
||||
import { IsOwnerFieldQe } from './IsOwnerFieldQe';
|
||||
import { UserDepartmentsFieldOot } from './UserDepartmentsFieldOot';
|
||||
import { AddMembersNnt } from './AddMembersNnt';
|
||||
import { useShowTotal } from '../hooks/useShowTotal';
|
||||
import { useMembersDataSource } from '../hooks/useMembersDataSource';
|
||||
import { useBulkRemoveMembersAction } from '../hooks/useBulkRemoveMembersAction';
|
||||
import { useRemoveMemberAction } from '../hooks/useRemoveMemberAction';
|
||||
import { getSchemaHe } from '../schema/getSchemaHe';
|
||||
import { schemaZe } from '../schema/schemaZe';
|
||||
import { schemaWe } from '../schema/schemaWe';
|
||||
import React from 'react';
|
||||
|
||||
export const ComponentIit = () => {
|
||||
const { t: tval } = useTranslation();
|
||||
const { department, user } = useContext(contextK);
|
||||
const { data, setState } = useResourceActionContext();
|
||||
|
||||
const MemberActions = () => (department ? <SchemaComponent schema={schemaZe} /> : null);
|
||||
const RowRemoveAction = () =>
|
||||
department ? (
|
||||
<SchemaComponent
|
||||
scope={{
|
||||
useRemoveMemberAction: useRemoveMemberAction,
|
||||
}}
|
||||
schema={schemaWe}
|
||||
/>
|
||||
) : null;
|
||||
|
||||
const schema = useMemo(() => getSchemaHe(department, user), [department, user]);
|
||||
|
||||
useEffect(() => {
|
||||
setState?.({
|
||||
selectedRowKeys: [],
|
||||
});
|
||||
}, [data, setState]);
|
||||
|
||||
return (
|
||||
<>
|
||||
<h2>{user ? tval('Search results') : tval(department?.title ?? 'All users')}</h2>
|
||||
<SchemaComponent
|
||||
scope={{
|
||||
useBulkRemoveMembersAction: useBulkRemoveMembersAction,
|
||||
useMembersDataSource: useMembersDataSource,
|
||||
t: tval,
|
||||
useShowTotal: useShowTotal,
|
||||
useFilterActionProps: useFilterActionPropsZ,
|
||||
}}
|
||||
components={{
|
||||
MemberActions: MemberActions,
|
||||
AddMembers: AddMembersNnt,
|
||||
RowRemoveAction: RowRemoveAction,
|
||||
DepartmentField: DepartmentFieldYe,
|
||||
IsOwnerField: IsOwnerFieldQe,
|
||||
UserDepartmentsField: UserDepartmentsFieldOot,
|
||||
}}
|
||||
schema={schema}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
|
||||
// return jsxs(Fragment, {
|
||||
// children: [
|
||||
// o
|
||||
// ? jsx('h2', { children: e('Search results') })
|
||||
// : jsx('h2', {
|
||||
// children: e((t == null ? void 0 : t.title) || 'All users'),
|
||||
// }),
|
||||
// jsx(SchemaComponent, {
|
||||
// scope: {
|
||||
// useBulkRemoveMembersAction: useBulkRemoveMembersAction,
|
||||
// useMembersDataSource: useMembersDataSource,
|
||||
// t: e,
|
||||
// useShowTotal: useShowTotal,
|
||||
// useFilterActionProps: useFilterActionPropsZ,
|
||||
// },
|
||||
// components: {
|
||||
// MemberActions: c,
|
||||
// AddMembers: AddMembersNnt,
|
||||
// RowRemoveAction: i,
|
||||
// DepartmentField: DepartmentFieldYe,
|
||||
// IsOwnerField: IsOwnerFieldQe,
|
||||
// UserDepartmentsField: UserDepartmentsFieldOot,
|
||||
// },
|
||||
// schema: x,
|
||||
// }),
|
||||
// ],
|
||||
// });
|
||||
};
|
@ -0,0 +1,112 @@
|
||||
import { useField } from '@tachybase/schema';
|
||||
import { TreeSelect } from 'antd';
|
||||
import React, { useEffect, useState } from 'react';
|
||||
// import { jsx } from 'react/jsx-runtime';
|
||||
import { k } from '../others/k';
|
||||
import { getDepartmentStr } from '../utils/getDepartmentStr';
|
||||
|
||||
interface tempField {
|
||||
value?: any;
|
||||
setValue: Function;
|
||||
}
|
||||
|
||||
interface IState {
|
||||
label?: object;
|
||||
value?: object;
|
||||
}
|
||||
|
||||
// 编辑部门-上级部门选择器
|
||||
export const ComponentLle = (props) => {
|
||||
const field = useField<tempField>();
|
||||
const [value, setValue] = useState<IState>({ label: null, value: null });
|
||||
const {
|
||||
treeData: treeData,
|
||||
initData: initData,
|
||||
getByKeyword: getByKeyword,
|
||||
loadData: loadData,
|
||||
loadedKeys: loadedKeys,
|
||||
setLoadedKeys: setLoadedKeys,
|
||||
originData: originData,
|
||||
} = props;
|
||||
const onSearch = (h) =>
|
||||
k(this, null, function* () {
|
||||
if (!h) {
|
||||
initData(originData);
|
||||
return;
|
||||
}
|
||||
yield getByKeyword(h);
|
||||
});
|
||||
// const b = useCallback((h) => {
|
||||
// const F = h.title,
|
||||
// C = h.parent;
|
||||
// return C ? b(C) + ' / ' + F : F;
|
||||
// }, []);
|
||||
|
||||
useEffect(() => {
|
||||
initData(originData);
|
||||
}, [originData, initData]);
|
||||
useEffect(() => {
|
||||
if (!field.value) {
|
||||
setValue({ label: null, value: null });
|
||||
return;
|
||||
}
|
||||
setValue({
|
||||
label: getDepartmentStr(field.value) || field.value.label,
|
||||
value: field.value.id,
|
||||
});
|
||||
}, [field.value, getDepartmentStr]);
|
||||
|
||||
// return null;
|
||||
return (
|
||||
<TreeSelect
|
||||
value={value}
|
||||
onSelect={(h, currValue) => {
|
||||
field.setValue(currValue);
|
||||
}}
|
||||
onChange={(h) => {
|
||||
h || field.setValue(null);
|
||||
}}
|
||||
treeData={treeData}
|
||||
treeLoadedKeys={loadedKeys}
|
||||
onTreeLoad={(keys) => setLoadedKeys(keys)}
|
||||
loadData={(value) => loadData({ key: value.id, children: value.children })}
|
||||
fieldNames={{ value: 'id' }}
|
||||
showSearch={true}
|
||||
allowClear={true}
|
||||
treeNodeFilterProp={'title'}
|
||||
onSearch={onSearch}
|
||||
labelInValue={true}
|
||||
/>
|
||||
);
|
||||
// return (
|
||||
// useEffect(() => {
|
||||
// c(d);
|
||||
// }, [d, c]),
|
||||
// useEffect(() => {
|
||||
// if (!t.value) {
|
||||
// a({ label: null, value: null });
|
||||
// return;
|
||||
// }
|
||||
// a({ label: b(t.value) || t.value.label, value: t.value.id });
|
||||
// }, [t.value, b]),
|
||||
// jsx(TreeSelect, {
|
||||
// value: o,
|
||||
// onSelect: (h, F) => {
|
||||
// t.setValue(F);
|
||||
// },
|
||||
// onChange: (h) => {
|
||||
// h || t.setValue(null);
|
||||
// },
|
||||
// treeData: r,
|
||||
// treeLoadedKeys: m,
|
||||
// onTreeLoad: (h) => g(h),
|
||||
// loadData: (h) => x({ key: h.id, children: h.children }),
|
||||
// fieldNames: { value: 'id' },
|
||||
// showSearch: true,
|
||||
// allowClear: true,
|
||||
// treeNodeFilterProp: 'title',
|
||||
// onSearch: A,
|
||||
// labelInValue: true,
|
||||
// })
|
||||
// );
|
||||
};
|
@ -0,0 +1,148 @@
|
||||
import { createStyles, useAPIClient, useRequest } from '@tachybase/client';
|
||||
import { Button, Dropdown, Empty, Input, theme } from 'antd';
|
||||
import { useContext, useState } from 'react';
|
||||
import { jsx, jsxs } from 'react/jsx-runtime';
|
||||
import { useTranslation } from '../../../locale';
|
||||
import { contextK } from '../context/contextK';
|
||||
|
||||
const createStyleAe = createStyles(({ css }) => ({
|
||||
searchDropdown: css`
|
||||
.ant-dropdown-menu {
|
||||
max-height: 500px;
|
||||
overflow-y: scroll;
|
||||
}
|
||||
`,
|
||||
}));
|
||||
|
||||
export const ComponentSe = () => {
|
||||
const { t: e } = useTranslation();
|
||||
const { token: t } = theme.useToken();
|
||||
const { setDepartment: setDepartment, setUser: setUser } = useContext(contextK);
|
||||
const [r, c] = useState(false);
|
||||
const [i, x] = useState('');
|
||||
const [m, g] = useState([]);
|
||||
const [d, A] = useState([]);
|
||||
const [b, h] = useState(true);
|
||||
const [F, C] = useState(true);
|
||||
const { styles } = createStyleAe();
|
||||
const l = 10;
|
||||
const api = useAPIClient();
|
||||
const data = useRequest(
|
||||
(M) =>
|
||||
api
|
||||
.resource('departments')
|
||||
.aggregateSearch(M)
|
||||
.then((P) => {
|
||||
var q;
|
||||
return (q = P == null ? void 0 : P.data) == null ? void 0 : q.data;
|
||||
}),
|
||||
{
|
||||
manual: true,
|
||||
onSuccess: (M, P) => {
|
||||
const {
|
||||
values: { type: q },
|
||||
} = P[0] || {};
|
||||
M &&
|
||||
((!q || q === 'user') && M.users.length < l && h(false),
|
||||
(!q || q === 'department') && M.departments.length < l && C(false),
|
||||
g((se) => [...se, ...M.users]),
|
||||
A((se) => [...se, ...M.departments]));
|
||||
},
|
||||
},
|
||||
);
|
||||
const { run: S } = data;
|
||||
const O = (M) => {
|
||||
x(M), g([]), A([]), h(true), C(true), M && (S({ values: { keyword: M, limit: l } }), c(true));
|
||||
};
|
||||
const $ = (M) => {
|
||||
M.target.value || (setUser(null), x(''), c(false), data.mutate({}), g([]), A([]));
|
||||
};
|
||||
const W = (M) => {
|
||||
const P = M.title,
|
||||
q = M.parent;
|
||||
return q ? W(q) + ' / ' + P : P;
|
||||
};
|
||||
const H = (M) =>
|
||||
jsx(Button, {
|
||||
type: 'link',
|
||||
style: { padding: '0 8px' },
|
||||
onClick: (P) => {
|
||||
c(true), S({ values: { keyword: i, limit: l, ...M } });
|
||||
},
|
||||
children: e('Load more'),
|
||||
});
|
||||
const J = () => {
|
||||
const M = [];
|
||||
return !m.length && !d.length
|
||||
? [
|
||||
{
|
||||
key: '0',
|
||||
label: jsx(Empty, {
|
||||
description: e('No results'),
|
||||
image: Empty.PRESENTED_IMAGE_SIMPLE,
|
||||
}),
|
||||
disabled: true,
|
||||
},
|
||||
]
|
||||
: (m.length &&
|
||||
(M.push({
|
||||
key: '0',
|
||||
type: 'group',
|
||||
label: e('Users'),
|
||||
children: m.map((P) => ({
|
||||
key: P.username,
|
||||
label: jsxs('div', {
|
||||
onClick: () => setUser(P),
|
||||
children: [
|
||||
jsx('div', { children: P.nickname || P.username }),
|
||||
jsx('div', {
|
||||
style: { fontSize: t.fontSizeSM, color: t.colorTextDescription },
|
||||
children: `${P.username}${P.phone ? ' | ' + P.phone : ''}${P.email ? ' | ' + P.email : ''}`,
|
||||
}),
|
||||
],
|
||||
}),
|
||||
})),
|
||||
}),
|
||||
b &&
|
||||
M.push({
|
||||
type: 'group',
|
||||
key: '0-loadMore',
|
||||
label: jsx(H, { type: 'user', last: m[m.length - 1].id }),
|
||||
})),
|
||||
d.length &&
|
||||
(M.push({
|
||||
key: '1',
|
||||
type: 'group',
|
||||
label: e('Departments'),
|
||||
children: d.map((P) => ({
|
||||
key: P.id,
|
||||
label: jsx('div', { onClick: () => setDepartment(P), children: W(P) }),
|
||||
})),
|
||||
}),
|
||||
F &&
|
||||
M.push({
|
||||
type: 'group',
|
||||
key: '1-loadMore',
|
||||
label: jsx(H, { type: 'department', last: d[d.length - 1].id }),
|
||||
})),
|
||||
M);
|
||||
};
|
||||
return jsx(Dropdown, {
|
||||
menu: { items: J() },
|
||||
overlayClassName: styles.searchDropdown,
|
||||
trigger: ['click'],
|
||||
open: r,
|
||||
onOpenChange: (M) => c(M),
|
||||
children: jsx(Input.Search, {
|
||||
allowClear: true,
|
||||
onClick: () => {
|
||||
i || c(false);
|
||||
},
|
||||
onFocus: () => setDepartment(null),
|
||||
onSearch: O,
|
||||
onChange: $,
|
||||
placeholder: e('Search for departments, users'),
|
||||
style: { marginBottom: '20px' },
|
||||
}),
|
||||
});
|
||||
};
|
@ -0,0 +1,161 @@
|
||||
import { MoreOutlined } from '@ant-design/icons';
|
||||
import { css, useAPIClient, useResourceActionContext } from '@tachybase/client';
|
||||
import { App, Dropdown, Empty, Tree } from 'antd';
|
||||
import { useContext, useEffect } from 'react';
|
||||
import { jsx, jsxs } from 'react/jsx-runtime';
|
||||
import { useTranslation } from '../../../locale';
|
||||
import { contextK } from '../context/contextK';
|
||||
import { k } from '../others/k';
|
||||
import { schemaHhe } from '../schema/schemaHhe';
|
||||
import { schemaYye } from '../schema/schemaYye';
|
||||
import { contextN } from '../context/contextN';
|
||||
|
||||
export const ComponentX = () => {
|
||||
const { data: e, loading: t } = useResourceActionContext();
|
||||
const { department, setDepartment, setUser } = useContext(contextK);
|
||||
const { treeData, nodeMap, loadData, loadedKeys, setLoadedKeys, initData, expandedKeys, setExpandedKeys } =
|
||||
useContext(contextN);
|
||||
|
||||
const h = (v) => {
|
||||
if (!v.length) return;
|
||||
const l = nodeMap[v[0]];
|
||||
setDepartment(l);
|
||||
setUser(null);
|
||||
};
|
||||
const F = (v) => {
|
||||
setExpandedKeys(v);
|
||||
};
|
||||
const C = (v) => {
|
||||
setLoadedKeys(v);
|
||||
};
|
||||
useEffect(() => {
|
||||
initData(e == null ? void 0 : e.data);
|
||||
}, [e, initData, t]);
|
||||
useEffect(() => {
|
||||
if (!department) return;
|
||||
const v = (u) => (u.parent ? [u.parent.id, ...v(u.parent)] : []),
|
||||
l = v(department);
|
||||
setExpandedKeys((u) => Array.from(new Set([...u, ...l])));
|
||||
}, [department, setExpandedKeys]);
|
||||
|
||||
return jsx('div', {
|
||||
className: css`
|
||||
height: 57vh;
|
||||
overflow: auto;
|
||||
.ant-tree-node-content-wrapper {
|
||||
overflow: hidden;
|
||||
}
|
||||
`,
|
||||
children:
|
||||
treeData != null && treeData.length
|
||||
? jsx(Tree.DirectoryTree, {
|
||||
loadData: loadData,
|
||||
treeData: treeData,
|
||||
loadedKeys: loadedKeys,
|
||||
onSelect: h,
|
||||
selectedKeys: [department == null ? void 0 : department.id],
|
||||
onExpand: F,
|
||||
onLoad: C,
|
||||
expandedKeys: expandedKeys,
|
||||
expandAction: false,
|
||||
showIcon: false,
|
||||
fieldNames: { key: 'id' },
|
||||
})
|
||||
: jsx(Empty, { image: Empty.PRESENTED_IMAGE_SIMPLE }),
|
||||
});
|
||||
// return (
|
||||
// useEffect(() => {
|
||||
// initData(e == null ? void 0 : e.data);
|
||||
// }, [e, initData, t]),
|
||||
// useEffect(() => {
|
||||
// if (!department) return;
|
||||
// const v = (u) => (u.parent ? [u.parent.id, ...v(u.parent)] : []),
|
||||
// l = v(department);
|
||||
// setExpandedKeys((u) => Array.from(new Set([...u, ...l])));
|
||||
// }, [department, setExpandedKeys]),
|
||||
// jsx('div', {
|
||||
// className: css`
|
||||
// height: 57vh;
|
||||
// overflow: auto;
|
||||
// .ant-tree-node-content-wrapper {
|
||||
// overflow: hidden;
|
||||
// }
|
||||
// `,
|
||||
// children:
|
||||
// treeData != null && treeData.length
|
||||
// ? jsx(Tree.DirectoryTree, {
|
||||
// loadData: loadData,
|
||||
// treeData: treeData,
|
||||
// loadedKeys: loadedKeys,
|
||||
// onSelect: h,
|
||||
// selectedKeys: [department == null ? void 0 : department.id],
|
||||
// onExpand: F,
|
||||
// onLoad: C,
|
||||
// expandedKeys: expandedKeys,
|
||||
// expandAction: false,
|
||||
// showIcon: false,
|
||||
// fieldNames: { key: 'id' },
|
||||
// })
|
||||
// : jsx(Empty, { image: Empty.PRESENTED_IMAGE_SIMPLE }),
|
||||
// })
|
||||
// );
|
||||
};
|
||||
ComponentX.Item = function ({ node: t, setVisible: o, setDrawer: a }) {
|
||||
const { t: r } = useTranslation(),
|
||||
{ refreshAsync: c } = useResourceActionContext(),
|
||||
{ setLoadedKeys: i, expandedKeys: x, setExpandedKeys: m } = useContext(contextN),
|
||||
{ modal: g, message: d } = App.useApp(),
|
||||
A = useAPIClient(),
|
||||
b = () => {
|
||||
g.confirm({
|
||||
title: r('Delete'),
|
||||
content: r('Are you sure you want to delete it?'),
|
||||
onOk: () =>
|
||||
k(this, null, function* () {
|
||||
yield A.resource('departments').destroy({ filterByTk: t.id }),
|
||||
d.success(r('Deleted successfully')),
|
||||
m((v) => v.filter((l) => l !== t.id));
|
||||
const C = [...x];
|
||||
i([]), m([]), yield c(), m(C);
|
||||
}),
|
||||
});
|
||||
},
|
||||
h = (C) => {
|
||||
a({ schema: C, node: t }), o(true);
|
||||
},
|
||||
F = ({ key: C, domEvent: v }) => {
|
||||
switch ((v.stopPropagation(), C)) {
|
||||
case 'new-sub':
|
||||
h(schemaYye);
|
||||
break;
|
||||
case 'edit':
|
||||
h(schemaHhe);
|
||||
break;
|
||||
case 'delete':
|
||||
b();
|
||||
}
|
||||
};
|
||||
return jsxs('div', {
|
||||
style: { display: 'flex', justifyContent: 'space-between', overflow: 'hidden' },
|
||||
children: [
|
||||
jsx('div', {
|
||||
style: { overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' },
|
||||
children: t.title,
|
||||
}),
|
||||
jsx(Dropdown, {
|
||||
menu: {
|
||||
items: [
|
||||
{ label: r('New sub department'), key: 'new-sub' },
|
||||
{ label: r('Edit department'), key: 'edit' },
|
||||
{ label: r('Delete department'), key: 'delete' },
|
||||
],
|
||||
onClick: F,
|
||||
},
|
||||
children: jsx('div', {
|
||||
style: { marginLeft: '15px' },
|
||||
children: jsx(MoreOutlined, {}),
|
||||
}),
|
||||
}),
|
||||
],
|
||||
});
|
||||
};
|
@ -0,0 +1,59 @@
|
||||
import { SchemaComponent } from '@tachybase/client';
|
||||
import { jsx } from 'react/jsx-runtime';
|
||||
import { useTranslation } from '../../../locale';
|
||||
|
||||
export const ComponentXxe = () => {
|
||||
const { t: e } = useTranslation();
|
||||
return jsx(SchemaComponent, {
|
||||
scope: { t: e },
|
||||
schema: {
|
||||
type: 'void',
|
||||
properties: {
|
||||
newDepartment: {
|
||||
type: 'void',
|
||||
title: e('New department'),
|
||||
'x-component': 'Action',
|
||||
'x-component-props': { type: 'text', icon: 'PlusOutlined', style: { width: '100%', textAlign: 'left' } },
|
||||
properties: {
|
||||
drawer: {
|
||||
type: 'void',
|
||||
'x-component': 'Action.Drawer',
|
||||
'x-decorator': 'Form',
|
||||
title: e('New department'),
|
||||
properties: {
|
||||
title: { 'x-component': 'CollectionField', 'x-decorator': 'FormItem', required: true },
|
||||
parent: {
|
||||
'x-component': 'CollectionField',
|
||||
'x-decorator': 'FormItem',
|
||||
'x-collection-field': 'departments.parent',
|
||||
'x-component-props': { component: 'DepartmentSelect' },
|
||||
},
|
||||
roles: {
|
||||
'x-component': 'CollectionField',
|
||||
'x-decorator': 'FormItem',
|
||||
'x-collection-field': 'departments.roles',
|
||||
},
|
||||
footer: {
|
||||
type: 'void',
|
||||
'x-component': 'Action.Drawer.Footer',
|
||||
properties: {
|
||||
cancel: {
|
||||
title: '{{t("Cancel")}}',
|
||||
'x-component': 'Action',
|
||||
'x-component-props': { useAction: '{{ cm.useCancelAction }}' },
|
||||
},
|
||||
submit: {
|
||||
title: '{{t("Submit")}}',
|
||||
'x-component': 'Action',
|
||||
'x-component-props': { type: 'primary', useAction: '{{ useCreateDepartment }}' },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
};
|
@ -0,0 +1,3 @@
|
||||
import React from 'react';
|
||||
|
||||
export const ContextR = React.createContext({});
|
@ -0,0 +1,72 @@
|
||||
import { EllipsisWithTooltip } from '@tachybase/client';
|
||||
import { useField } from '@tachybase/schema';
|
||||
import React, { useContext } from 'react';
|
||||
// import { jsx, jsxs } from 'react/jsx-runtime';
|
||||
import { contextK } from '../context/contextK';
|
||||
import { getDepartmentStr } from '../utils/getDepartmentStr';
|
||||
|
||||
export const DepartmentFieldYe = () => {
|
||||
const { setDepartment } = useContext(contextK);
|
||||
const field = useField<{ value: Array<any> }>();
|
||||
const fieldValues = field.value || [];
|
||||
|
||||
const department = fieldValues.reduce((acc, curr) => {
|
||||
acc[curr.id] = curr;
|
||||
return acc;
|
||||
}, {});
|
||||
|
||||
return (
|
||||
<EllipsisWithTooltip ellipsis={true}>
|
||||
{fieldValues.map((currFieldValue, index) => (
|
||||
<span key={index}>
|
||||
<a
|
||||
onClick={(event) => {
|
||||
event.preventDefault();
|
||||
setDepartment(department[currFieldValue.id]);
|
||||
}}
|
||||
>
|
||||
{getDepartmentStr(currFieldValue)}
|
||||
</a>
|
||||
{index !== fieldValues.length - 1 ? <span style={{ marginRight: 4, color: '#aaa' }}>,</span> : ''}
|
||||
</span>
|
||||
))}
|
||||
</EllipsisWithTooltip>
|
||||
);
|
||||
|
||||
// const children2 = fieldValues.map((currFieldValue, index) => {
|
||||
// return (
|
||||
// <span key={index}>
|
||||
// <a
|
||||
// onClick={(x) => {
|
||||
// x.preventDefault(), setDepartment(department[currFieldValue.id]);
|
||||
// }}
|
||||
// >
|
||||
// {getDepartmentStr(currFieldValue)}
|
||||
// </a>
|
||||
// {index !== fieldValues.length - 1 ? <span style={{ marginRight: 4, color: '#aaa' }}>,</span> : ''}
|
||||
// </span>
|
||||
// );
|
||||
// });
|
||||
|
||||
// const children = fieldValues.map((currFieldValue, index) =>
|
||||
// jsxs(
|
||||
// 'span',
|
||||
// {
|
||||
// children: [
|
||||
// jsx('a', {
|
||||
// onClick: (x) => {
|
||||
// x.preventDefault(), setDepartment(department[currFieldValue.id]);
|
||||
// },
|
||||
// children: getDepartmentStr(currFieldValue),
|
||||
// }),
|
||||
// index !== fieldValues.length - 1
|
||||
// ? jsx('span', { style: { marginRight: 4, color: '#aaa' }, children: ',' })
|
||||
// : '',
|
||||
// ],
|
||||
// },
|
||||
// index,
|
||||
// ),
|
||||
// );
|
||||
|
||||
// return jsx(EllipsisWithTooltip, { ellipsis: true, children: children });
|
||||
};
|
@ -0,0 +1,59 @@
|
||||
import { SchemaComponentOptions } from '@tachybase/client';
|
||||
import { Col, Row } from 'antd';
|
||||
// import { jsx, jsxs } from 'react/jsx-runtime';
|
||||
import React from 'react';
|
||||
import { useFilterActionPropsZ } from '../scopes/useFilterActionPropsZ';
|
||||
import { CeComponent } from './CeComponent';
|
||||
import { BeComponent } from './ComponentBe';
|
||||
import { ComponentEEE } from './ComponentEEE';
|
||||
import { ComponentIit } from './ComponentIit';
|
||||
import { DepartmentSelect } from './DepartmentSelect';
|
||||
import { SuperiorDepartmentSelect } from './SuperiorDepartmentSelect';
|
||||
|
||||
export const DepartmentManagement = () => {
|
||||
return (
|
||||
<SchemaComponentOptions
|
||||
components={{ SuperiorDepartmentSelect, DepartmentSelect }}
|
||||
scope={{ useFilterActionProps: useFilterActionPropsZ }}
|
||||
>
|
||||
<Row gutter={48} style={{ flexWrap: 'nowrap' }}>
|
||||
<Col span={6} style={{ borderRight: '1px solid #eee', minWidth: '300px' }}>
|
||||
<CeComponent>
|
||||
<ComponentEEE />
|
||||
</CeComponent>
|
||||
</Col>
|
||||
<Col flex="auto" style={{ overflow: 'hidden' }}>
|
||||
<BeComponent>
|
||||
<ComponentIit />
|
||||
</BeComponent>
|
||||
</Col>
|
||||
</Row>
|
||||
</SchemaComponentOptions>
|
||||
);
|
||||
// return jsx(SchemaComponentOptions, {
|
||||
// components: {
|
||||
// SuperiorDepartmentSelect: SuperiorDepartmentSelect,
|
||||
// DepartmentSelect: DepartmentSelect,
|
||||
// },
|
||||
// scope: {
|
||||
// useFilterActionProps: useFilterActionPropsZ,
|
||||
// },
|
||||
|
||||
// children: jsxs(Row, {
|
||||
// gutter: 48,
|
||||
// style: { flexWrap: 'nowrap' },
|
||||
// children: [
|
||||
// jsx(Col, {
|
||||
// span: 6,
|
||||
// style: { borderRight: '1px solid #eee', minWidth: '300px' },
|
||||
// children: jsx(CeComponent, { children: jsx(ComponentEEE, {}) }),
|
||||
// }),
|
||||
// jsx(Col, {
|
||||
// flex: 'auto',
|
||||
// style: { overflow: 'hidden' },
|
||||
// children: jsx(BeComponent, { children: jsx(ComponentIit, {}) }),
|
||||
// }),
|
||||
// ],
|
||||
// }),
|
||||
// });
|
||||
};
|
@ -0,0 +1,71 @@
|
||||
import {
|
||||
ResourceActionProvider,
|
||||
SchemaComponent,
|
||||
ActionContextProvider,
|
||||
useActionContext,
|
||||
useRecord,
|
||||
} from '@tachybase/client';
|
||||
import { useField } from '@tachybase/schema';
|
||||
import { Select } from 'antd';
|
||||
import { useEffect, useRef, useState } from 'react';
|
||||
import { jsx, jsxs } from 'react/jsx-runtime';
|
||||
import { schemaFfe } from '../schema/schemaFfe';
|
||||
|
||||
export const DepartmentOwnersField = () => {
|
||||
const [e, t] = useState(false),
|
||||
o = useRecord(),
|
||||
a = useField(),
|
||||
[r, c] = useState([]),
|
||||
i = useRef([]),
|
||||
x = (d, A) => {
|
||||
i.current = A;
|
||||
},
|
||||
m = () => {
|
||||
const { setVisible: d } = useActionContext();
|
||||
return {
|
||||
run() {
|
||||
const A = a.value || [];
|
||||
a.setValue([...A, ...i.current]), (i.current = []), d(false);
|
||||
},
|
||||
};
|
||||
};
|
||||
useEffect(() => {
|
||||
a.value && c(a.value.map((d) => ({ value: d.id, label: d.nickname || d.username })));
|
||||
}, [a.value]);
|
||||
const g = (d) => {
|
||||
var A;
|
||||
return jsx(ResourceActionProvider, {
|
||||
collection: 'users',
|
||||
request: {
|
||||
resource: `departments/${o.id}/members`,
|
||||
action: 'list',
|
||||
params: { filter: (A = a.value) != null && A.length ? { id: { $notIn: a.value.map((b) => b.id) } } : {} },
|
||||
},
|
||||
children: d.children,
|
||||
});
|
||||
};
|
||||
return jsxs(ActionContextProvider, {
|
||||
value: { visible: e, setVisible: t },
|
||||
children: [
|
||||
jsx(Select, {
|
||||
open: false,
|
||||
onChange: (d) => {
|
||||
if (!d) {
|
||||
a.setValue([]);
|
||||
return;
|
||||
}
|
||||
a.setValue(d.map(({ label: A, value: b }) => ({ id: b, nickname: A })));
|
||||
},
|
||||
mode: 'multiple',
|
||||
value: r,
|
||||
labelInValue: true,
|
||||
onDropdownVisibleChange: (d) => t(d),
|
||||
}),
|
||||
jsx(SchemaComponent, {
|
||||
schema: schemaFfe,
|
||||
components: { RequestProvider: g },
|
||||
scope: { department: o, handleSelect: x, useSelectOwners: m },
|
||||
}),
|
||||
],
|
||||
});
|
||||
};
|
@ -0,0 +1,16 @@
|
||||
import { useContext } from 'react';
|
||||
import { jsx } from 'react/jsx-runtime';
|
||||
import { T } from '../others/T';
|
||||
import { y } from '../others/y';
|
||||
import { contextK } from '../context/contextK';
|
||||
import { ComponentLle } from './ComponentLle';
|
||||
import { useHooksG } from '../hooks/useHooksG';
|
||||
|
||||
export const DepartmentSelect = () => {
|
||||
const e = useHooksG(),
|
||||
{ departmentsResource: t } = useContext(contextK),
|
||||
{
|
||||
service: { data: o },
|
||||
} = t || {};
|
||||
return jsx(ComponentLle, T(y({}, e), { originData: o == null ? void 0 : o.data }));
|
||||
};
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user