diff --git a/packages/plugins/@nocobase/plugin-workflow/src/client/components/AssignedFieldsFormSchemaConfig.tsx b/packages/plugins/@nocobase/plugin-workflow/src/client/components/AssignedFieldsFormSchemaConfig.tsx index c09fbb0a08..2faf440523 100644 --- a/packages/plugins/@nocobase/plugin-workflow/src/client/components/AssignedFieldsFormSchemaConfig.tsx +++ b/packages/plugins/@nocobase/plugin-workflow/src/client/components/AssignedFieldsFormSchemaConfig.tsx @@ -58,6 +58,7 @@ export function AssignedFieldsFormSchemaConfig(props) { const { setFormValueChanged } = useActionContext(); const api = useAPIClient(); const scope = useWorkflowVariableOptions(); + const { values, setValuesIn, disabled } = useForm(); const params = toJS(values.params); const [dataSourceName, collectionName] = parseCollectionName(values.collection); diff --git a/packages/plugins/@nocobase/plugin-workflow/src/client/components/FilterDynamicComponent.tsx b/packages/plugins/@nocobase/plugin-workflow/src/client/components/FilterDynamicComponent.tsx index 5dffedd14c..15a8d164cf 100644 --- a/packages/plugins/@nocobase/plugin-workflow/src/client/components/FilterDynamicComponent.tsx +++ b/packages/plugins/@nocobase/plugin-workflow/src/client/components/FilterDynamicComponent.tsx @@ -9,13 +9,131 @@ import React from 'react'; -import { Variable } from '@nocobase/client'; +import { useCompile, Variable } from '@nocobase/client'; +import type { DefaultOptionType } from 'antd/lib/cascader'; import { useWorkflowVariableOptions } from '../variable'; +import { NAMESPACE } from '../locale'; + +const dateRangeSystemVariables = { + key: 'dateRange', + label: `{{t('Date range', { ns: '${NAMESPACE}' })}}`, + value: 'dateRange', + children: [ + { + key: 'yesterday', + value: 'yesterday', + label: '{{t("Yesterday")}}', + }, + { + key: 'today', + value: 'today', + label: '{{t("Today")}}', + }, + { + key: 'tomorrow', + value: 'tomorrow', + label: '{{t("Tomorrow")}}', + }, + { + key: 'lastWeek', + value: 'lastWeek', + label: '{{t("Last week")}}', + }, + { + key: 'thisWeek', + value: 'thisWeek', + label: '{{t("This week")}}', + }, + { + key: 'nextWeek', + value: 'nextWeek', + label: '{{t("Next week")}}', + }, + { + key: 'lastMonth', + value: 'lastMonth', + label: '{{t("Last month")}}', + }, + { + key: 'thisMonth', + value: 'thisMonth', + label: '{{t("This month")}}', + }, + { + key: 'nextMonth', + value: 'nextMonth', + label: '{{t("Next month")}}', + }, + { + key: 'lastQuarter', + value: 'lastQuarter', + label: '{{t("Last quarter")}}', + }, + { + key: 'thisQuarter', + value: 'thisQuarter', + label: '{{t("This quarter")}}', + }, + { + key: 'nextQuarter', + value: 'nextQuarter', + label: '{{t("Next quarter")}}', + }, + { + key: 'lastYear', + value: 'lastYear', + label: '{{t("Last year")}}', + }, + { + key: 'thisYear', + value: 'thisYear', + label: '{{t("This year")}}', + }, + { + key: 'nextYear', + value: 'nextYear', + label: '{{t("Next year")}}', + }, + { + key: 'last7Days', + value: 'last7Days', + label: '{{t("Last 7 days")}}', + }, + { + key: 'next7Days', + value: 'next7Days', + label: '{{t("Next 7 days")}}', + }, + { + key: 'last30Days', + value: 'last30Days', + label: '{{t("Last 30 days")}}', + }, + { + key: 'next30Days', + value: 'next30Days', + label: '{{t("Next 30 days")}}', + }, + { + key: 'last90Days', + value: 'last90Days', + label: '{{t("Last 90 days")}}', + }, + { + key: 'next90Days', + value: 'next90Days', + label: '{{t("Next 90 days")}}', + }, + ], +}; export function FilterDynamicComponent({ value, onChange, renderSchemaComponent }) { - const scope = useWorkflowVariableOptions(); + const compile = useCompile(); + const scope: Partial[] | (() => Partial[]) = useWorkflowVariableOptions(); + const index = scope.findIndex((v) => v.key === '$system'); + scope[index].children.push(compile(dateRangeSystemVariables)); return ( {renderSchemaComponent()} diff --git a/packages/plugins/@nocobase/plugin-workflow/src/client/constants.tsx b/packages/plugins/@nocobase/plugin-workflow/src/client/constants.tsx index e45b2410fc..5d3e31dad5 100644 --- a/packages/plugins/@nocobase/plugin-workflow/src/client/constants.tsx +++ b/packages/plugins/@nocobase/plugin-workflow/src/client/constants.tsx @@ -18,7 +18,8 @@ import { LoadingOutlined, RedoOutlined, } from '@ant-design/icons'; -import { NAMESPACE } from './locale'; +import { i18n } from '@nocobase/client'; +import { NAMESPACE, lang } from './locale'; export const EXECUTION_STATUS = { QUEUEING: null, diff --git a/packages/plugins/@nocobase/plugin-workflow/src/client/index.tsx b/packages/plugins/@nocobase/plugin-workflow/src/client/index.tsx index 6e48619bc3..6bf9c2a6b2 100644 --- a/packages/plugins/@nocobase/plugin-workflow/src/client/index.tsx +++ b/packages/plugins/@nocobase/plugin-workflow/src/client/index.tsx @@ -126,118 +126,6 @@ export default class PluginWorkflowClient extends Plugin { label: `{{t("System time", { ns: "${NAMESPACE}" })}}`, value: 'now', }); - this.registerSystemVariable({ - key: 'dateRange', - label: `{{t("Date range", { ns: "${NAMESPACE}" })}}`, - value: 'dateRange', - children: [ - { - key: 'yesterday', - value: 'yesterday', - label: `{{t("Yesterday")}}`, - }, - { - key: 'today', - value: 'today', - label: `{{t("Today")}}`, - }, - { - key: 'tomorrow', - value: 'tomorrow', - label: `{{t("Tomorrow")}}`, - }, - { - key: 'lastWeek', - value: 'lastWeek', - label: `{{t("Last week")}}`, - }, - { - key: 'thisWeek', - value: 'thisWeek', - label: `{{t("This week")}}`, - }, - { - key: 'nextWeek', - value: 'nextWeek', - label: `{{t("Next week")}}`, - }, - { - key: 'lastMonth', - value: 'lastMonth', - label: `{{t("Last month")}}`, - }, - { - key: 'thisMonth', - value: 'thisMonth', - label: `{{t("This month")}}`, - }, - { - key: 'nextMonth', - value: 'nextMonth', - label: `{{t("Next month")}}`, - }, - { - key: 'lastQuarter', - value: 'lastQuarter', - label: `{{t("Last quarter")}}`, - }, - { - key: 'thisQuarter', - value: 'thisQuarter', - label: `{{t("This quarter")}}`, - }, - { - key: 'nextQuarter', - value: 'nextQuarter', - label: `{{t("Next quarter")}}`, - }, - { - key: 'lastYear', - value: 'lastYear', - label: `{{t("Last year")}}`, - }, - { - key: 'thisYear', - value: 'thisYear', - label: `{{t("This year")}}`, - }, - { - key: 'nextYear', - value: 'nextYear', - label: `{{t("Next year")}}`, - }, - { - key: 'last7Days', - value: 'last7Days', - label: `{{t("Last 7 days")}}`, - }, - { - key: 'next7Days', - value: 'next7Days', - label: `{{t("Next 7 days")}}`, - }, - { - key: 'last30Days', - value: 'last30Days', - label: `{{t("Last 30 days")}}`, - }, - { - key: 'next30Days', - value: 'next30Days', - label: `{{t("Next 30 days")}}`, - }, - { - key: 'last90Days', - value: 'last90Days', - label: `{{t("Last 90 days")}}`, - }, - { - key: 'next90Days', - value: 'next90Days', - label: `{{t("Next 90 days")}}`, - }, - ], - }); } }