Merge branches 'feat/company-expire' and 'feat/platform-limit' into dev/2.0
Resolved conflicts: - typings.d.ts: Keep both validity fields and platform quota fields in CompanyListItem - company/Popup.tsx: Merge imports (Card, Col, Row from platform-limit + Dayjs from company-expire) - company/index.tsx: Keep useAccess and Typography imports needed by company-expire - rules/index.tsx: Keep validityStatus check from company-expire, adopt simplified clone button from platform-limit Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
import { useModel } from '@umijs/max';
|
import { useModel } from '@umijs/max';
|
||||||
|
import { useMemo } from 'react';
|
||||||
|
|
||||||
export default function useUserInfo() {
|
export default function useUserInfo() {
|
||||||
const { initialState, setInitialState } = useModel('@@initialState');
|
const { initialState, setInitialState } = useModel('@@initialState');
|
||||||
@@ -14,5 +15,24 @@ export default function useUserInfo() {
|
|||||||
setUserInfo(info);
|
setUserInfo(info);
|
||||||
};
|
};
|
||||||
|
|
||||||
return { userInfo, refreshUserInfo, setUserInfo };
|
const userPlatform = useMemo(() => {
|
||||||
|
const company = userInfo?.company;
|
||||||
|
const originalPlatform = [
|
||||||
|
{
|
||||||
|
label: 'MT5',
|
||||||
|
value: 5,
|
||||||
|
isOpen: company?.mt5Open === 1,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'MT4',
|
||||||
|
value: 4,
|
||||||
|
isOpen: company?.mt4Open === 1,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
// return originalPlatform.filter((item) => item.isOpen);
|
||||||
|
return originalPlatform;
|
||||||
|
}, [userInfo]);
|
||||||
|
|
||||||
|
return { userInfo, refreshUserInfo, setUserInfo, userPlatform };
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ export default {
|
|||||||
'common.loading': 'Loading...',
|
'common.loading': 'Loading...',
|
||||||
'common.content.noRules': 'No rules available',
|
'common.content.noRules': 'No rules available',
|
||||||
'common.content.noData': 'No data available',
|
'common.content.noData': 'No data available',
|
||||||
|
'table.platformAccess': 'Platform Quota',
|
||||||
'table.group': 'Group',
|
'table.group': 'Group',
|
||||||
'table.operatorRecords': 'Operator Records',
|
'table.operatorRecords': 'Operator Records',
|
||||||
'table.operatorAction': 'Operator Action',
|
'table.operatorAction': 'Operator Action',
|
||||||
@@ -615,6 +616,10 @@ export default {
|
|||||||
'Enter verified sender emails (comma separated)',
|
'Enter verified sender emails (comma separated)',
|
||||||
'pages.email.status.normal': 'Active',
|
'pages.email.status.normal': 'Active',
|
||||||
'pages.email.status.disabled': 'Inactive',
|
'pages.email.status.disabled': 'Inactive',
|
||||||
|
'pages.email.platformAccess': ' Platform Access',
|
||||||
|
'pages.email.platformAccessEnable': ' Access',
|
||||||
|
'pages.email.platformMax': 'Quota Limit',
|
||||||
|
'pages.email.platformAssigned': 'Assigned',
|
||||||
'pages.email.notification': 'Email Notification Config',
|
'pages.email.notification': 'Email Notification Config',
|
||||||
'pages.email.notificationEmail': 'Notification Email',
|
'pages.email.notificationEmail': 'Notification Email',
|
||||||
'pages.email.notificationEmail.tips':
|
'pages.email.notificationEmail.tips':
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ export default {
|
|||||||
'common.loading': '加载中...',
|
'common.loading': '加载中...',
|
||||||
'common.content.noRules': '暂无规则',
|
'common.content.noRules': '暂无规则',
|
||||||
'common.content.noData': '暂无数据',
|
'common.content.noData': '暂无数据',
|
||||||
|
'table.platformAccess': '平台配额',
|
||||||
'table.group': '所属组',
|
'table.group': '所属组',
|
||||||
'table.operatorRecords': '操作记录',
|
'table.operatorRecords': '操作记录',
|
||||||
'table.operatorAction': '操作动作',
|
'table.operatorAction': '操作动作',
|
||||||
@@ -581,6 +582,10 @@ export default {
|
|||||||
'pages.email.availableEmails.tips': '在服务商已验证的邮箱,多个用逗号分隔',
|
'pages.email.availableEmails.tips': '在服务商已验证的邮箱,多个用逗号分隔',
|
||||||
'pages.email.status.normal': '正常',
|
'pages.email.status.normal': '正常',
|
||||||
'pages.email.status.disabled': '停用',
|
'pages.email.status.disabled': '停用',
|
||||||
|
'pages.email.platformAccess': '平台接入权限',
|
||||||
|
'pages.email.platformAccessEnable': '接入',
|
||||||
|
'pages.email.platformMax': '最大数量上限',
|
||||||
|
'pages.email.platformAssigned': '已配',
|
||||||
'pages.email.notification': '邮件通知配置',
|
'pages.email.notification': '邮件通知配置',
|
||||||
'pages.email.notificationEmail': '通知邮箱',
|
'pages.email.notificationEmail': '通知邮箱',
|
||||||
'pages.email.notificationEmail.tips':
|
'pages.email.notificationEmail.tips':
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ const maxAlertHideCount = 9999;
|
|||||||
|
|
||||||
const Account: React.FC = () => {
|
const Account: React.FC = () => {
|
||||||
const { isGlobalCompany } = useAccess();
|
const { isGlobalCompany } = useAccess();
|
||||||
const { userInfo } = useUserInfo();
|
const { userInfo, userPlatform } = useUserInfo();
|
||||||
const companyInfo = userInfo?.company;
|
const companyInfo = userInfo?.company;
|
||||||
|
|
||||||
const [visible, setVisible] = useState(false);
|
const [visible, setVisible] = useState(false);
|
||||||
@@ -122,14 +122,7 @@ const Account: React.FC = () => {
|
|||||||
label: $t('table.all'),
|
label: $t('table.all'),
|
||||||
value: '',
|
value: '',
|
||||||
},
|
},
|
||||||
// {
|
...userPlatform,
|
||||||
// label: 'MT4',
|
|
||||||
// value: '4',
|
|
||||||
// },
|
|
||||||
{
|
|
||||||
label: 'MT5',
|
|
||||||
value: '5',
|
|
||||||
},
|
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ const Alert: React.FC = () => {
|
|||||||
const [dataSourceList, setDataSourceList] = useState<
|
const [dataSourceList, setDataSourceList] = useState<
|
||||||
API.DataSourceListItem[]
|
API.DataSourceListItem[]
|
||||||
>([]);
|
>([]);
|
||||||
const { userInfo } = useUserInfo();
|
const { userInfo, userPlatform } = useUserInfo();
|
||||||
const userDataSourceList = userInfo?.userDataSourceList;
|
const userDataSourceList = userInfo?.userDataSourceList;
|
||||||
const companyInfo = userInfo?.company;
|
const companyInfo = userInfo?.company;
|
||||||
|
|
||||||
@@ -257,14 +257,7 @@ const Alert: React.FC = () => {
|
|||||||
label: $t('table.all'),
|
label: $t('table.all'),
|
||||||
value: '',
|
value: '',
|
||||||
},
|
},
|
||||||
// {
|
...userPlatform,
|
||||||
// label: 'MT4',
|
|
||||||
// value: 4,
|
|
||||||
// },
|
|
||||||
{
|
|
||||||
label: 'MT5',
|
|
||||||
value: 5,
|
|
||||||
},
|
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
render: (_, { platform }) => {
|
render: (_, { platform }) => {
|
||||||
|
|||||||
@@ -2,13 +2,14 @@ import {
|
|||||||
ModalForm,
|
ModalForm,
|
||||||
ProFormDatePicker,
|
ProFormDatePicker,
|
||||||
ProFormDependency,
|
ProFormDependency,
|
||||||
|
ProFormDigit,
|
||||||
type ProFormInstance,
|
type ProFormInstance,
|
||||||
ProFormSelect,
|
ProFormSelect,
|
||||||
ProFormSwitch,
|
ProFormSwitch,
|
||||||
ProFormText,
|
ProFormText,
|
||||||
} from '@ant-design/pro-components';
|
} from '@ant-design/pro-components';
|
||||||
import { useAccess } from '@umijs/max';
|
import { useAccess } from '@umijs/max';
|
||||||
import { Divider, Space, Typography } from 'antd';
|
import { Card, Col, Divider, Row, Space, Typography } from 'antd';
|
||||||
import type { Dayjs } from 'dayjs';
|
import type { Dayjs } from 'dayjs';
|
||||||
import { useRef } from 'react';
|
import { useRef } from 'react';
|
||||||
import useUserInfo from '@/hooks/useUserInfo';
|
import useUserInfo from '@/hooks/useUserInfo';
|
||||||
@@ -138,6 +139,75 @@ export default (props: {
|
|||||||
{formValues?.id !== void 0 && (
|
{formValues?.id !== void 0 && (
|
||||||
<>
|
<>
|
||||||
<Divider size="small" />
|
<Divider size="small" />
|
||||||
|
|
||||||
|
<Text strong style={{ lineHeight: '40px', fontSize: 16 }}>
|
||||||
|
⚙️ {$t('pages.email.platformAccess')}
|
||||||
|
</Text>
|
||||||
|
<Row gutter={16}>
|
||||||
|
<Col span={12}>
|
||||||
|
<Card
|
||||||
|
title={`MT4 ${$t('pages.email.platformAccessEnable')}`}
|
||||||
|
extra={
|
||||||
|
<ProFormSwitch
|
||||||
|
name="mt4Open"
|
||||||
|
noStyle
|
||||||
|
transform={(value) => +value}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
styles={{
|
||||||
|
header: { fontSize: 14, minHeight: 40, paddingInline: 14 },
|
||||||
|
body: { paddingInline: 14 },
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<ProFormDependency name={['mt4Open']}>
|
||||||
|
{({ mt4Open }) => (
|
||||||
|
<ProFormDigit
|
||||||
|
name="mt4Count"
|
||||||
|
label={`${$t('pages.email.platformMax')}`}
|
||||||
|
min={0}
|
||||||
|
step={1}
|
||||||
|
disabled={!mt4Open}
|
||||||
|
formItemProps={{
|
||||||
|
style: { marginBottom: 0 },
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</ProFormDependency>
|
||||||
|
</Card>
|
||||||
|
</Col>
|
||||||
|
<Col span={12}>
|
||||||
|
<Card
|
||||||
|
title={`MT5 ${$t('pages.email.platformAccessEnable')}`}
|
||||||
|
extra={
|
||||||
|
<ProFormSwitch
|
||||||
|
name="mt5Open"
|
||||||
|
noStyle
|
||||||
|
transform={(value) => +value}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
styles={{
|
||||||
|
header: { fontSize: 14, minHeight: 40, paddingInline: 14 },
|
||||||
|
body: { paddingInline: 14 },
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<ProFormDependency name={['mt5Open']}>
|
||||||
|
{({ mt5Open }) => (
|
||||||
|
<ProFormDigit
|
||||||
|
name="mt5Count"
|
||||||
|
label={`${$t('pages.email.platformMax')}`}
|
||||||
|
min={0}
|
||||||
|
step={1}
|
||||||
|
disabled={!mt5Open}
|
||||||
|
formItemProps={{
|
||||||
|
style: { marginBottom: 0 },
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</ProFormDependency>
|
||||||
|
</Card>
|
||||||
|
</Col>
|
||||||
|
</Row>
|
||||||
|
{/* <Divider size="small" /> */}
|
||||||
<Text strong style={{ lineHeight: '40px', fontSize: 16 }}>
|
<Text strong style={{ lineHeight: '40px', fontSize: 16 }}>
|
||||||
📧 {$t('pages.email.notification')}
|
📧 {$t('pages.email.notification')}
|
||||||
</Text>
|
</Text>
|
||||||
|
|||||||
@@ -74,6 +74,46 @@ const Company: React.FC = () => {
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
title: $t('table.platformAccess'),
|
||||||
|
dataIndex: 'platformAccess',
|
||||||
|
render: (
|
||||||
|
_,
|
||||||
|
{
|
||||||
|
mt4Count,
|
||||||
|
mt4Open,
|
||||||
|
mt5Count,
|
||||||
|
mt5Open,
|
||||||
|
sourceType4Count,
|
||||||
|
sourceType5Count,
|
||||||
|
},
|
||||||
|
) => {
|
||||||
|
return (
|
||||||
|
<Space direction="vertical" size={4}>
|
||||||
|
<MyTag color={mt4Open === 1 ? '#818cf8' : '#94a3b8'}>
|
||||||
|
MT4:{' '}
|
||||||
|
{mt4Open === 1 ? (
|
||||||
|
<span>
|
||||||
|
{sourceType4Count ?? '-'} / {mt4Count ?? '-'}
|
||||||
|
</span>
|
||||||
|
) : (
|
||||||
|
$t('pages.rules.disable')
|
||||||
|
)}
|
||||||
|
</MyTag>
|
||||||
|
<MyTag color={mt5Open === 1 ? '#3b82f6' : '#94a3b8'}>
|
||||||
|
MT5:{' '}
|
||||||
|
{mt5Open === 1 ? (
|
||||||
|
<span>
|
||||||
|
{sourceType5Count ?? '-'} / {mt5Count ?? '-'}
|
||||||
|
</span>
|
||||||
|
) : (
|
||||||
|
$t('pages.rules.disable')
|
||||||
|
)}
|
||||||
|
</MyTag>
|
||||||
|
</Space>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
title: $t('table.userCount'),
|
title: $t('table.userCount'),
|
||||||
dataIndex: 'userCount',
|
dataIndex: 'userCount',
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import {
|
|||||||
} from '@ant-design/pro-components';
|
} from '@ant-design/pro-components';
|
||||||
import { useAccess } from '@umijs/max';
|
import { useAccess } from '@umijs/max';
|
||||||
import { Divider, type FormInstance, Typography } from 'antd';
|
import { Divider, type FormInstance, Typography } from 'antd';
|
||||||
import { useRef } from 'react';
|
import { useMemo, useRef } from 'react';
|
||||||
import useUserInfo from '@/hooks/useUserInfo';
|
import useUserInfo from '@/hooks/useUserInfo';
|
||||||
import { preventScientificNotation } from '@/utils';
|
import { preventScientificNotation } from '@/utils';
|
||||||
import { $t } from '@/utils/i18n';
|
import { $t } from '@/utils/i18n';
|
||||||
@@ -22,7 +22,7 @@ export default (props: {
|
|||||||
}) => {
|
}) => {
|
||||||
const { visible, formValues, onSubmit, onDone, companyList } = props;
|
const { visible, formValues, onSubmit, onDone, companyList } = props;
|
||||||
|
|
||||||
const { userInfo } = useUserInfo();
|
const { userInfo, userPlatform } = useUserInfo();
|
||||||
const { isGlobalCompany } = useAccess();
|
const { isGlobalCompany } = useAccess();
|
||||||
const globalCompanyId = isGlobalCompany ? userInfo?.companyId : 0;
|
const globalCompanyId = isGlobalCompany ? userInfo?.companyId : 0;
|
||||||
const formRef = useRef<FormInstance>(null);
|
const formRef = useRef<FormInstance>(null);
|
||||||
@@ -41,6 +41,12 @@ export default (props: {
|
|||||||
message: $t('form.placeholder.ipAddress'),
|
message: $t('form.placeholder.ipAddress'),
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const filteredUserPlatform = useMemo(
|
||||||
|
() => userPlatform.filter((v) => v?.isOpen),
|
||||||
|
[userPlatform],
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ModalForm
|
<ModalForm
|
||||||
width="600px"
|
width="600px"
|
||||||
@@ -50,7 +56,10 @@ export default (props: {
|
|||||||
formValues?.id
|
formValues?.id
|
||||||
? formValues
|
? formValues
|
||||||
: {
|
: {
|
||||||
sourceType: 5,
|
sourceType:
|
||||||
|
filteredUserPlatform.length > 0
|
||||||
|
? filteredUserPlatform[0].value
|
||||||
|
: null,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
open={visible}
|
open={visible}
|
||||||
@@ -78,16 +87,7 @@ export default (props: {
|
|||||||
label={$t('form.dataSource.type')}
|
label={$t('form.dataSource.type')}
|
||||||
allowClear={false}
|
allowClear={false}
|
||||||
rules={[{ required: true, message: $t('form.required') }]}
|
rules={[{ required: true, message: $t('form.required') }]}
|
||||||
options={[
|
options={filteredUserPlatform}
|
||||||
// {
|
|
||||||
// value: 4,
|
|
||||||
// label: 'MT4',
|
|
||||||
// },
|
|
||||||
{
|
|
||||||
value: 5,
|
|
||||||
label: 'MT5',
|
|
||||||
},
|
|
||||||
]}
|
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{isGlobalCompany && (
|
{isGlobalCompany && (
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import {
|
|||||||
dataSourceHandle,
|
dataSourceHandle,
|
||||||
getCompanyList,
|
getCompanyList,
|
||||||
getDataSourcePages,
|
getDataSourcePages,
|
||||||
|
getPlatformList,
|
||||||
} from '@/services/api';
|
} from '@/services/api';
|
||||||
import { $t } from '@/utils/i18n';
|
import { $t } from '@/utils/i18n';
|
||||||
import Popup from './Popup';
|
import Popup from './Popup';
|
||||||
@@ -49,6 +50,7 @@ const DataSource: React.FC = () => {
|
|||||||
setCompanyList(data || []);
|
setCompanyList(data || []);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
getPlatformList();
|
||||||
}, []);
|
}, []);
|
||||||
const [cardInfo, setCardInfo] = useState({
|
const [cardInfo, setCardInfo] = useState({
|
||||||
// mt4Count: 0,
|
// mt4Count: 0,
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import {
|
|||||||
useBreakpoint,
|
useBreakpoint,
|
||||||
} from '@ant-design/pro-components';
|
} from '@ant-design/pro-components';
|
||||||
import { Button, Divider, Flex, Input, Modal, Space, Typography } from 'antd';
|
import { Button, Divider, Flex, Input, Modal, Space, Typography } from 'antd';
|
||||||
import { createContext, useMemo, useRef, useState } from 'react';
|
import { useMemo, useRef, useState } from 'react';
|
||||||
import useRichFormat from '@/hooks/useRichI18n';
|
import useRichFormat from '@/hooks/useRichI18n';
|
||||||
import { $t } from '@/utils/i18n';
|
import { $t } from '@/utils/i18n';
|
||||||
import '../style.less';
|
import '../style.less';
|
||||||
@@ -14,26 +14,9 @@ import { handleEmptyValuesFunc } from '../../utils';
|
|||||||
import BatchCloneModal from './comp/BatchCloneModal';
|
import BatchCloneModal from './comp/BatchCloneModal';
|
||||||
import Step1 from './comp/Step1';
|
import Step1 from './comp/Step1';
|
||||||
import Step2 from './comp/Step2';
|
import Step2 from './comp/Step2';
|
||||||
|
import { MultiCopyPopupContext } from './context';
|
||||||
|
|
||||||
const { Text, Title } = Typography;
|
const { Text, Title } = Typography;
|
||||||
type MultiCopyPopupContextValue = {
|
|
||||||
ruleMeta: Record<string, any>;
|
|
||||||
dataSourceList: API.DataSourceListItem[];
|
|
||||||
currentRuleType: number;
|
|
||||||
targetDataSourceId: string | number | null;
|
|
||||||
selectRules: API.RuleListItem[];
|
|
||||||
setSelectRules: (rules: API.RuleListItem[]) => void;
|
|
||||||
currentSchemaMap: Record<string, any>;
|
|
||||||
};
|
|
||||||
export const MultiCopyPopupContext = createContext<MultiCopyPopupContextValue>({
|
|
||||||
ruleMeta: {},
|
|
||||||
dataSourceList: [],
|
|
||||||
currentRuleType: 0,
|
|
||||||
targetDataSourceId: null,
|
|
||||||
selectRules: [],
|
|
||||||
setSelectRules: () => {},
|
|
||||||
currentSchemaMap: {},
|
|
||||||
});
|
|
||||||
type MultiCopyPopupProps = {
|
type MultiCopyPopupProps = {
|
||||||
visible: boolean;
|
visible: boolean;
|
||||||
ruleMeta: Record<string, any>;
|
ruleMeta: Record<string, any>;
|
||||||
@@ -232,22 +215,22 @@ const MultiCopyPopup = ({
|
|||||||
onValuesChange={({ sourceDataSourceId }) => {
|
onValuesChange={({ sourceDataSourceId }) => {
|
||||||
if (sourceDataSourceId) {
|
if (sourceDataSourceId) {
|
||||||
const curFormRef = formMapRef?.current?.[0]?.current;
|
const curFormRef = formMapRef?.current?.[0]?.current;
|
||||||
const curTargetDataSourceId =
|
const curTargetId = curFormRef?.getFieldValue('targetDataSourceId');
|
||||||
curFormRef?.getFieldValue('targetDataSourceId');
|
const sourceItem = dataSourceList.find(
|
||||||
if (curTargetDataSourceId === sourceDataSourceId) {
|
(item) => item.id === sourceDataSourceId,
|
||||||
let targetDataSourceId: string | number | null = null;
|
);
|
||||||
for (const item of dataSourceList) {
|
const targetItem = dataSourceList.find(
|
||||||
if (item.id !== sourceDataSourceId) {
|
(item) => item.id === curTargetId,
|
||||||
targetDataSourceId = item.id;
|
);
|
||||||
break;
|
if (targetItem && sourceItem && targetItem.sourceType !== sourceItem.sourceType) {
|
||||||
}
|
const fallback =
|
||||||
}
|
dataSourceList.find(
|
||||||
if (targetDataSourceId) {
|
(item) =>
|
||||||
curFormRef?.setFieldsValue({
|
item.id !== sourceDataSourceId &&
|
||||||
targetDataSourceId,
|
item.sourceType === sourceItem.sourceType,
|
||||||
});
|
)?.id || sourceDataSourceId;
|
||||||
setTargetDataSourceId(targetDataSourceId);
|
curFormRef?.setFieldsValue({ targetDataSourceId: fallback });
|
||||||
}
|
setTargetDataSourceId(fallback);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import {
|
|||||||
Row,
|
Row,
|
||||||
Typography,
|
Typography,
|
||||||
} from 'antd';
|
} from 'antd';
|
||||||
import { useEffect, useRef, useState } from 'react';
|
import { useEffect, useMemo, useRef, useState } from 'react';
|
||||||
import useRichFormat from '@/hooks/useRichI18n';
|
import useRichFormat from '@/hooks/useRichI18n';
|
||||||
import { $t } from '@/utils/i18n';
|
import { $t } from '@/utils/i18n';
|
||||||
import { type SchemaType, schemaMap } from '../../ruleFormSchema';
|
import { type SchemaType, schemaMap } from '../../ruleFormSchema';
|
||||||
@@ -68,49 +68,83 @@ const SingleCopyPopup = ({
|
|||||||
} =
|
} =
|
||||||
schemaMap[currentRuleType as unknown as SchemaType]?.({ richFormat }) || {};
|
schemaMap[currentRuleType as unknown as SchemaType]?.({ richFormat }) || {};
|
||||||
|
|
||||||
const rightDataSourceList = dataSourceList.filter(
|
const sourceSourceType = useMemo(() => {
|
||||||
(item) => item.id !== formValues?.dataSourceId,
|
return dataSourceList.find((item) => item.id === formValues?.dataSourceId)
|
||||||
);
|
?.sourceType;
|
||||||
|
}, [dataSourceList, formValues?.dataSourceId]);
|
||||||
|
|
||||||
|
const dataSourceOptions = useMemo(() => {
|
||||||
|
return dataSourceList.map((item) => ({
|
||||||
|
...item,
|
||||||
|
disabled: item.sourceType !== sourceSourceType,
|
||||||
|
label: (
|
||||||
|
<Flex justify="space-between" align="center">
|
||||||
|
<span>{item.sourceName}</span>
|
||||||
|
<Typography.Text
|
||||||
|
type="secondary"
|
||||||
|
style={{ fontSize: 12, marginLeft: 8 }}
|
||||||
|
>
|
||||||
|
MT{item.sourceType}
|
||||||
|
</Typography.Text>
|
||||||
|
</Flex>
|
||||||
|
),
|
||||||
|
}));
|
||||||
|
}, [dataSourceList, sourceSourceType]);
|
||||||
|
|
||||||
const initialValues = transformInitialValue?.(formValues) || formValues;
|
const initialValues = transformInitialValue?.(formValues) || formValues;
|
||||||
|
|
||||||
const rightFirstDataSource = rightDataSourceList[0];
|
const rightFirstDataSource =
|
||||||
|
dataSourceOptions.find(
|
||||||
|
(item) => item.id !== formValues?.dataSourceId && !item.disabled,
|
||||||
|
) || dataSourceOptions[0];
|
||||||
|
const isSameSource = rightFirstDataSource?.id === formValues?.dataSourceId;
|
||||||
const copyFormValues = {
|
const copyFormValues = {
|
||||||
...initialValues,
|
...initialValues,
|
||||||
name: initialValues?.name
|
name: initialValues?.name
|
||||||
? `${initialValues.name} - ${rightFirstDataSource?.sourceName}`
|
? `${initialValues.name} - ${rightFirstDataSource?.sourceName}`
|
||||||
: `${Date.now()} - ${rightFirstDataSource?.sourceName}`,
|
: `${Date.now()} - ${rightFirstDataSource?.sourceName}`,
|
||||||
groupFilter: '',
|
|
||||||
id: void 0,
|
id: void 0,
|
||||||
dataSourceId: rightFirstDataSource?.id || '',
|
dataSourceId: rightFirstDataSource?.id || '',
|
||||||
|
...(isSameSource
|
||||||
|
? {}
|
||||||
|
: {
|
||||||
|
groupFilter: '',
|
||||||
|
...(symbolFormShow ? { param2: '' } : {}),
|
||||||
|
...(assetFormShow ? { param1: '' } : {}),
|
||||||
|
}),
|
||||||
};
|
};
|
||||||
if (symbolFormShow) {
|
|
||||||
copyFormValues.param2 = '';
|
|
||||||
}
|
|
||||||
if (assetFormShow) {
|
|
||||||
copyFormValues.param1 = '';
|
|
||||||
}
|
|
||||||
|
|
||||||
const formContent = ({
|
const formContent = ({
|
||||||
dataSourceList,
|
dataSourceList: options,
|
||||||
formAttr,
|
formAttr,
|
||||||
|
onDataSourceChange,
|
||||||
}: {
|
}: {
|
||||||
dataSourceList: API.DataSourceListItem[];
|
dataSourceList: any[];
|
||||||
formAttr: Record<string, any>;
|
formAttr: Record<string, any>;
|
||||||
|
onDataSourceChange?: (dataSourceId: string | number) => void;
|
||||||
}) => {
|
}) => {
|
||||||
return (
|
return (
|
||||||
<ProForm {...formAttr} submitter={false}>
|
<ProForm
|
||||||
|
{...formAttr}
|
||||||
|
submitter={false}
|
||||||
|
onValuesChange={(changedValues) => {
|
||||||
|
if (changedValues.dataSourceId && onDataSourceChange) {
|
||||||
|
onDataSourceChange(changedValues.dataSourceId);
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
<ProFormSelect
|
<ProFormSelect
|
||||||
name="dataSourceId"
|
name="dataSourceId"
|
||||||
label={$t('table.dataSource')}
|
label={$t('table.dataSource')}
|
||||||
options={dataSourceList}
|
options={options}
|
||||||
rules={[{ required: true, message: $t('form.required') }]}
|
rules={[{ required: true, message: $t('form.required') }]}
|
||||||
fieldProps={{
|
fieldProps={{
|
||||||
allowClear: false,
|
allowClear: false,
|
||||||
fieldNames: {
|
fieldNames: {
|
||||||
label: 'sourceName',
|
label: 'label',
|
||||||
value: 'id',
|
value: 'id',
|
||||||
},
|
},
|
||||||
|
optionLabelProp: 'label',
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<BetaSchemaForm layoutType="Embed" columns={leftForm} />
|
<BetaSchemaForm layoutType="Embed" columns={leftForm} />
|
||||||
@@ -194,53 +228,64 @@ const SingleCopyPopup = ({
|
|||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Row>
|
{visible && (
|
||||||
<Col xs={24} sm={11}>
|
<Row>
|
||||||
<div style={{ marginBottom: 12 }}>
|
<Col xs={24} sm={11}>
|
||||||
<Text strong>📋 {$t('pages.rules.originalRule')}</Text>
|
<div style={{ marginBottom: 12 }}>
|
||||||
</div>
|
<Text strong>📋 {$t('pages.rules.originalRule')}</Text>
|
||||||
{formContent({
|
</div>
|
||||||
dataSourceList,
|
{formContent({
|
||||||
formAttr: { initialValues, disabled: true },
|
dataSourceList: dataSourceOptions,
|
||||||
})}
|
formAttr: { initialValues, disabled: true },
|
||||||
</Col>
|
})}
|
||||||
|
</Col>
|
||||||
|
|
||||||
<Col xs={0} sm={1}>
|
<Col xs={0} sm={1}>
|
||||||
<Flex vertical align="center" style={{ height: '100%' }}>
|
<Flex vertical align="center" style={{ height: '100%' }}>
|
||||||
<ArrowRightOutlined style={{ marginTop: 2, fontSize: 18 }} />
|
<ArrowRightOutlined style={{ marginTop: 2, fontSize: 18 }} />
|
||||||
<Divider type="vertical" style={{ flex: 1, marginTop: 16 }} />
|
<Divider type="vertical" style={{ flex: 1, marginTop: 16 }} />
|
||||||
</Flex>
|
</Flex>
|
||||||
</Col>
|
</Col>
|
||||||
|
|
||||||
<Col xs={24} sm={0}>
|
<Col xs={24} sm={0}>
|
||||||
<div className="text-center" style={{ marginBottom: 16 }}>
|
<div className="text-center" style={{ marginBottom: 16 }}>
|
||||||
<ArrowDownOutlined />
|
<ArrowDownOutlined />
|
||||||
</div>
|
</div>
|
||||||
</Col>
|
</Col>
|
||||||
|
|
||||||
<Col xs={24} sm={12}>
|
<Col xs={24} sm={12}>
|
||||||
<div style={{ marginBottom: 12 }}>
|
<div style={{ marginBottom: 12 }}>
|
||||||
<Text strong>✏️ {$t('pages.rules.cloneRulePreview')}</Text>
|
<Text strong>✏️ {$t('pages.rules.cloneRulePreview')}</Text>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{formContent({
|
{formContent({
|
||||||
dataSourceList: rightDataSourceList,
|
dataSourceList: dataSourceOptions,
|
||||||
formAttr: {
|
formAttr: {
|
||||||
initialValues: copyFormValues,
|
initialValues: copyFormValues,
|
||||||
formRef: formRef,
|
formRef: formRef,
|
||||||
disabled: confirmLoading,
|
disabled: confirmLoading,
|
||||||
},
|
},
|
||||||
})}
|
onDataSourceChange: (dataSourceId) => {
|
||||||
{errMsg && (
|
const isSame = dataSourceId === formValues?.dataSourceId;
|
||||||
<Alert
|
if (!isSame) {
|
||||||
message={errMsg}
|
const fields: Record<string, any> = { groupFilter: '' };
|
||||||
type="error"
|
if (symbolFormShow) fields.param2 = '';
|
||||||
showIcon
|
if (assetFormShow) fields.param1 = '';
|
||||||
style={{ marginBottom: 16 }}
|
formRef.current?.setFieldsValue(fields);
|
||||||
/>
|
}
|
||||||
)}
|
},
|
||||||
</Col>
|
})}
|
||||||
</Row>
|
{errMsg && (
|
||||||
|
<Alert
|
||||||
|
message={errMsg}
|
||||||
|
type="error"
|
||||||
|
showIcon
|
||||||
|
style={{ marginBottom: 16 }}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</Col>
|
||||||
|
</Row>
|
||||||
|
)}
|
||||||
</Modal>
|
</Modal>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -17,10 +17,13 @@ import {
|
|||||||
Tag,
|
Tag,
|
||||||
Tooltip,
|
Tooltip,
|
||||||
} from 'antd';
|
} from 'antd';
|
||||||
import { useEffect, useMemo, useState } from 'react';
|
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
||||||
import { processSingleRule } from '@/pages/rules/utils';
|
import { processSingleRule } from '@/pages/rules/utils';
|
||||||
import { $t } from '@/utils/i18n';
|
import { $t } from '@/utils/i18n';
|
||||||
|
|
||||||
|
type TaskStatus = 'waiting' | 'processing' | 'success' | 'warning' | 'error';
|
||||||
|
type Task = { name: string; status: TaskStatus; errorMsg: string };
|
||||||
|
|
||||||
type BatchCloneModalProps = {
|
type BatchCloneModalProps = {
|
||||||
visible: boolean;
|
visible: boolean;
|
||||||
selectedRows: Partial<API.RuleListItem>[];
|
selectedRows: Partial<API.RuleListItem>[];
|
||||||
@@ -33,26 +36,33 @@ const BatchCloneModal = ({
|
|||||||
onClose,
|
onClose,
|
||||||
onFinish,
|
onFinish,
|
||||||
}: BatchCloneModalProps) => {
|
}: BatchCloneModalProps) => {
|
||||||
const [tasks, setTasks] = useState<any[]>([]);
|
const [tasks, setTasks] = useState<Task[]>([]);
|
||||||
const [isRunning, setIsRunning] = useState(false);
|
const [isRunning, setIsRunning] = useState(false);
|
||||||
const [currentRunning, setCurrentRunning] = useState(0);
|
const [currentRunning, setCurrentRunning] = useState(0);
|
||||||
|
const selectedRowsRef = useRef(selectedRows);
|
||||||
|
selectedRowsRef.current = selectedRows;
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const initialTasks = selectedRows.map((row) => ({
|
if (visible) {
|
||||||
name: row.name,
|
setTasks(
|
||||||
status: 'waiting', // waiting, processing, success, error
|
selectedRows.map((row) => ({
|
||||||
errorMsg: '',
|
name: row.name || '',
|
||||||
}));
|
status: 'waiting',
|
||||||
setTasks(initialTasks);
|
errorMsg: '',
|
||||||
}, [visible, selectedRows]);
|
})),
|
||||||
|
);
|
||||||
|
setIsRunning(false);
|
||||||
|
setCurrentRunning(0);
|
||||||
|
}
|
||||||
|
}, [visible]);
|
||||||
|
|
||||||
const finishedTasks = useMemo(
|
const finishedTasks = useMemo(
|
||||||
() => tasks.filter((t) => ['success', 'warning'].includes(t.status)),
|
() => tasks.filter((t) => t.status === 'success' || t.status === 'warning'),
|
||||||
[tasks],
|
[tasks],
|
||||||
);
|
);
|
||||||
|
|
||||||
const finishedMessage = useMemo(() => {
|
const finishedMessage = useMemo(() => {
|
||||||
const hasWarning = finishedTasks.find((t) => t.status === 'warning');
|
const hasWarning = finishedTasks.some((t) => t.status === 'warning');
|
||||||
const type: AlertProps['type'] = hasWarning
|
const type: AlertProps['type'] = hasWarning
|
||||||
? 'warning'
|
? 'warning'
|
||||||
: finishedTasks.length === tasks.length
|
: finishedTasks.length === tasks.length
|
||||||
@@ -69,9 +79,10 @@ const BatchCloneModal = ({
|
|||||||
};
|
};
|
||||||
}, [finishedTasks, tasks]);
|
}, [finishedTasks, tasks]);
|
||||||
|
|
||||||
const startBatch = async () => {
|
const startBatch = useCallback(async () => {
|
||||||
|
const rows = selectedRowsRef.current;
|
||||||
setIsRunning(true);
|
setIsRunning(true);
|
||||||
for (let i = 0; i < selectedRows.length; i++) {
|
for (let i = 0; i < rows.length; i++) {
|
||||||
setCurrentRunning(i + 1);
|
setCurrentRunning(i + 1);
|
||||||
setTasks((prev) => {
|
setTasks((prev) => {
|
||||||
const next = [...prev];
|
const next = [...prev];
|
||||||
@@ -79,8 +90,7 @@ const BatchCloneModal = ({
|
|||||||
return next;
|
return next;
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
await processSingleRule({ payload: selectedRows[i] });
|
await processSingleRule({ payload: rows[i] });
|
||||||
|
|
||||||
setTasks((prev) => {
|
setTasks((prev) => {
|
||||||
const next = [...prev];
|
const next = [...prev];
|
||||||
next[i].status = 'success';
|
next[i].status = 'success';
|
||||||
@@ -96,13 +106,13 @@ const BatchCloneModal = ({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
setIsRunning(false);
|
setIsRunning(false);
|
||||||
};
|
}, []);
|
||||||
|
|
||||||
const handleReset = () => {
|
const handleReset = useCallback(() => {
|
||||||
setTasks([]);
|
setTasks([]);
|
||||||
setIsRunning(false);
|
setIsRunning(false);
|
||||||
setCurrentRunning(0);
|
setCurrentRunning(0);
|
||||||
};
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
|
|||||||
@@ -1,22 +1,20 @@
|
|||||||
import { CheckCard, ProCard } from '@ant-design/pro-components';
|
import { CheckCard, ProCard } from '@ant-design/pro-components';
|
||||||
import { useRequest } from '@umijs/max';
|
import { useRequest } from '@umijs/max';
|
||||||
import { Col, Row, Spin } from 'antd';
|
import { Col, Row, Spin } from 'antd';
|
||||||
import { useContext, useState } from 'react';
|
import { useContext, useEffect, useState } from 'react';
|
||||||
import { getRuleList } from '@/services/api';
|
import { getRuleList } from '@/services/api';
|
||||||
import { $t } from '@/utils/i18n';
|
import { $t } from '@/utils/i18n';
|
||||||
import { RuleCardBodyInfo } from '../../RuleCardBody';
|
import { RuleCardBodyInfo } from '../../RuleCardBody';
|
||||||
import { MultiCopyPopupContext } from '../MultiCopyPopup';
|
import { MultiCopyPopupContext } from '../context';
|
||||||
|
|
||||||
type RuleCheckCardProps = {
|
type RuleCheckCardProps = {
|
||||||
dataSourceId: string | number;
|
dataSourceId: string | number;
|
||||||
onChange?: (id: string | number) => void;
|
|
||||||
};
|
};
|
||||||
const RuleCheckCard = ({ dataSourceId }: RuleCheckCardProps) => {
|
const RuleCheckCard = ({ dataSourceId }: RuleCheckCardProps) => {
|
||||||
const [ruleList, setRuleList] = useState<API.RuleListItem[]>([]);
|
|
||||||
|
|
||||||
const { ruleMeta, currentRuleType, setSelectRules } = useContext(
|
const { ruleMeta, currentRuleType, setSelectRules } = useContext(
|
||||||
MultiCopyPopupContext,
|
MultiCopyPopupContext,
|
||||||
);
|
);
|
||||||
|
const [ruleList, setRuleList] = useState<API.RuleListItem[]>([]);
|
||||||
|
|
||||||
const { loading } = useRequest(
|
const { loading } = useRequest(
|
||||||
() =>
|
() =>
|
||||||
@@ -25,7 +23,6 @@ const RuleCheckCard = ({ dataSourceId }: RuleCheckCardProps) => {
|
|||||||
dataSourceId,
|
dataSourceId,
|
||||||
}),
|
}),
|
||||||
{
|
{
|
||||||
// manual: true,
|
|
||||||
refreshDeps: [dataSourceId, currentRuleType],
|
refreshDeps: [dataSourceId, currentRuleType],
|
||||||
onSuccess: ({ data = [] }: { data: API.RuleListItem[] }) => {
|
onSuccess: ({ data = [] }: { data: API.RuleListItem[] }) => {
|
||||||
setRuleList(data);
|
setRuleList(data);
|
||||||
@@ -37,15 +34,17 @@ const RuleCheckCard = ({ dataSourceId }: RuleCheckCardProps) => {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
return () => setSelectRules([]);
|
||||||
|
}, []);
|
||||||
|
|
||||||
if (!dataSourceId) return <div>{$t('pages.clones.step1.tips')}</div>;
|
if (!dataSourceId) return <div>{$t('pages.clones.step1.tips')}</div>;
|
||||||
if (loading) return <Spin />;
|
if (loading) return <Spin />;
|
||||||
|
|
||||||
// const
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ProCard
|
<ProCard
|
||||||
title={$t('pages.clones.step1.sourceRules', {
|
title={$t('pages.clones.step1.sourceRules', {
|
||||||
count: ruleList?.length,
|
count: ruleList.length,
|
||||||
ruleType: ruleMeta?.title || '-',
|
ruleType: ruleMeta?.title || '-',
|
||||||
})}
|
})}
|
||||||
collapsible
|
collapsible
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import { ArrowDownOutlined } from '@ant-design/icons';
|
import { ArrowDownOutlined } from '@ant-design/icons';
|
||||||
import { ProFormDependency, ProFormSelect } from '@ant-design/pro-components';
|
import { ProFormDependency, ProFormSelect } from '@ant-design/pro-components';
|
||||||
import { Divider, Tag } from 'antd';
|
import { Divider, Flex, Tag, Typography } from 'antd';
|
||||||
import { useContext, useEffect } from 'react';
|
import { useContext, useEffect, useMemo } from 'react';
|
||||||
import { $t } from '@/utils/i18n';
|
import { $t } from '@/utils/i18n';
|
||||||
import { MultiCopyPopupContext } from '../MultiCopyPopup';
|
import { MultiCopyPopupContext } from '../context';
|
||||||
import RuleCheckCard from './RuleCheckCard';
|
import RuleCheckCard from './RuleCheckCard';
|
||||||
|
|
||||||
type Step1Props = {
|
type Step1Props = {
|
||||||
@@ -13,11 +13,52 @@ type Step1Props = {
|
|||||||
const Step1 = ({ formMapRef, setTargetDataSourceId }: Step1Props) => {
|
const Step1 = ({ formMapRef, setTargetDataSourceId }: Step1Props) => {
|
||||||
const { dataSourceList } = useContext(MultiCopyPopupContext);
|
const { dataSourceList } = useContext(MultiCopyPopupContext);
|
||||||
|
|
||||||
|
const buildOptions = (sourceId?: string | number) => {
|
||||||
|
const sourceType = dataSourceList.find((item) => item.id === sourceId)
|
||||||
|
?.sourceType;
|
||||||
|
return dataSourceList.map((item) => ({
|
||||||
|
...item,
|
||||||
|
disabled: item.sourceType !== sourceType,
|
||||||
|
label: (
|
||||||
|
<Flex justify="space-between" align="center">
|
||||||
|
<span>{item.sourceName}</span>
|
||||||
|
<Typography.Text
|
||||||
|
type="secondary"
|
||||||
|
style={{ fontSize: 12, marginLeft: 8 }}
|
||||||
|
>
|
||||||
|
MT{item.sourceType}
|
||||||
|
</Typography.Text>
|
||||||
|
</Flex>
|
||||||
|
),
|
||||||
|
}));
|
||||||
|
};
|
||||||
|
|
||||||
|
const sourceOptions = useMemo(
|
||||||
|
() => dataSourceList.map((item) => ({
|
||||||
|
...item,
|
||||||
|
label: (
|
||||||
|
<Flex justify="space-between" align="center">
|
||||||
|
<span>{item.sourceName}</span>
|
||||||
|
<Typography.Text
|
||||||
|
type="secondary"
|
||||||
|
style={{ fontSize: 12, marginLeft: 8 }}
|
||||||
|
>
|
||||||
|
MT{item.sourceType}
|
||||||
|
</Typography.Text>
|
||||||
|
</Flex>
|
||||||
|
),
|
||||||
|
})),
|
||||||
|
[dataSourceList],
|
||||||
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (dataSourceList?.length) {
|
if (dataSourceList?.length) {
|
||||||
// waitTime(1000).then(() => {
|
const sourceItem = dataSourceList[0];
|
||||||
const sourceDataSourceId = dataSourceList[0]?.id || '';
|
const sourceDataSourceId = sourceItem?.id || '';
|
||||||
const targetDataSourceId = dataSourceList[1]?.id || '';
|
const sameTypeItem = dataSourceList.find(
|
||||||
|
(item) => item.id !== sourceDataSourceId && item.sourceType === sourceItem?.sourceType,
|
||||||
|
);
|
||||||
|
const targetDataSourceId = sameTypeItem?.id || sourceDataSourceId;
|
||||||
const curFormRef = formMapRef?.current?.[0]?.current;
|
const curFormRef = formMapRef?.current?.[0]?.current;
|
||||||
if (curFormRef) {
|
if (curFormRef) {
|
||||||
curFormRef?.setFieldsValue({
|
curFormRef?.setFieldsValue({
|
||||||
@@ -26,7 +67,6 @@ const Step1 = ({ formMapRef, setTargetDataSourceId }: Step1Props) => {
|
|||||||
});
|
});
|
||||||
setTargetDataSourceId(targetDataSourceId);
|
setTargetDataSourceId(targetDataSourceId);
|
||||||
}
|
}
|
||||||
// });
|
|
||||||
}
|
}
|
||||||
}, [dataSourceList]);
|
}, [dataSourceList]);
|
||||||
|
|
||||||
@@ -35,14 +75,15 @@ const Step1 = ({ formMapRef, setTargetDataSourceId }: Step1Props) => {
|
|||||||
<ProFormSelect
|
<ProFormSelect
|
||||||
name="sourceDataSourceId"
|
name="sourceDataSourceId"
|
||||||
label={$t('pages.clones.step1.source')}
|
label={$t('pages.clones.step1.source')}
|
||||||
options={dataSourceList}
|
options={sourceOptions}
|
||||||
rules={[{ required: true, message: $t('form.required') }]}
|
rules={[{ required: true, message: $t('form.required') }]}
|
||||||
fieldProps={{
|
fieldProps={{
|
||||||
allowClear: false,
|
allowClear: false,
|
||||||
fieldNames: {
|
fieldNames: {
|
||||||
label: 'sourceName',
|
label: 'label',
|
||||||
value: 'id',
|
value: 'id',
|
||||||
},
|
},
|
||||||
|
optionLabelProp: 'label',
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<ProFormDependency name={['sourceDataSourceId']}>
|
<ProFormDependency name={['sourceDataSourceId']}>
|
||||||
@@ -61,21 +102,20 @@ const Step1 = ({ formMapRef, setTargetDataSourceId }: Step1Props) => {
|
|||||||
<ProFormDependency name={['sourceDataSourceId']}>
|
<ProFormDependency name={['sourceDataSourceId']}>
|
||||||
{({ sourceDataSourceId }) => {
|
{({ sourceDataSourceId }) => {
|
||||||
if (!sourceDataSourceId) return null;
|
if (!sourceDataSourceId) return null;
|
||||||
const dataSourceOptions = dataSourceList.filter(
|
const targetOptions = buildOptions(sourceDataSourceId);
|
||||||
(item) => item.id !== sourceDataSourceId,
|
|
||||||
);
|
|
||||||
return (
|
return (
|
||||||
<ProFormSelect
|
<ProFormSelect
|
||||||
name="targetDataSourceId"
|
name="targetDataSourceId"
|
||||||
label={$t('pages.clones.step1.target')}
|
label={$t('pages.clones.step1.target')}
|
||||||
options={dataSourceOptions}
|
options={targetOptions}
|
||||||
rules={[{ required: true, message: $t('form.required') }]}
|
rules={[{ required: true, message: $t('form.required') }]}
|
||||||
fieldProps={{
|
fieldProps={{
|
||||||
allowClear: false,
|
allowClear: false,
|
||||||
fieldNames: {
|
fieldNames: {
|
||||||
label: 'sourceName',
|
label: 'label',
|
||||||
value: 'id',
|
value: 'id',
|
||||||
},
|
},
|
||||||
|
optionLabelProp: 'label',
|
||||||
}}
|
}}
|
||||||
onChange={(value: string | number | null) => {
|
onChange={(value: string | number | null) => {
|
||||||
setTargetDataSourceId(value || null);
|
setTargetDataSourceId(value || null);
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import {
|
|||||||
import { useContext, useEffect, useMemo, useState } from 'react';
|
import { useContext, useEffect, useMemo, useState } from 'react';
|
||||||
import { $t } from '@/utils/i18n';
|
import { $t } from '@/utils/i18n';
|
||||||
import { RuleCardBodyInfo } from '../../RuleCardBody';
|
import { RuleCardBodyInfo } from '../../RuleCardBody';
|
||||||
import { MultiCopyPopupContext } from '../MultiCopyPopup';
|
import { MultiCopyPopupContext } from '../context';
|
||||||
|
|
||||||
const { Text } = Typography;
|
const { Text } = Typography;
|
||||||
|
|
||||||
|
|||||||
21
src/pages/rules/components/CopyRule/context.ts
Normal file
21
src/pages/rules/components/CopyRule/context.ts
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
import { createContext } from 'react';
|
||||||
|
|
||||||
|
type MultiCopyPopupContextValue = {
|
||||||
|
ruleMeta: Record<string, any>;
|
||||||
|
dataSourceList: API.DataSourceListItem[];
|
||||||
|
currentRuleType: number;
|
||||||
|
targetDataSourceId: string | number | null;
|
||||||
|
selectRules: API.RuleListItem[];
|
||||||
|
setSelectRules: (rules: API.RuleListItem[]) => void;
|
||||||
|
currentSchemaMap: Record<string, any>;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const MultiCopyPopupContext = createContext<MultiCopyPopupContextValue>({
|
||||||
|
ruleMeta: {},
|
||||||
|
dataSourceList: [],
|
||||||
|
currentRuleType: 0,
|
||||||
|
targetDataSourceId: null,
|
||||||
|
selectRules: [],
|
||||||
|
setSelectRules: () => {},
|
||||||
|
currentSchemaMap: {},
|
||||||
|
});
|
||||||
@@ -297,10 +297,6 @@ const RuleCommon: React.FC = () => {
|
|||||||
<Button
|
<Button
|
||||||
icon={<CopyOutlined />}
|
icon={<CopyOutlined />}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
if (dataSourceList.length < 2) {
|
|
||||||
message.warning($t('pages.rules.cloneRuleWarning'));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
setFormValues(rule);
|
setFormValues(rule);
|
||||||
setCopyVisible(true);
|
setCopyVisible(true);
|
||||||
}}
|
}}
|
||||||
@@ -459,10 +455,6 @@ const RuleCommon: React.FC = () => {
|
|||||||
<Button
|
<Button
|
||||||
icon={<CopyOutlined />}
|
icon={<CopyOutlined />}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
if (dataSourceList.length < 2) {
|
|
||||||
message.warning($t('pages.rules.cloneRuleWarning'));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
setMultiCopyVisible(true);
|
setMultiCopyVisible(true);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -614,6 +614,12 @@ export async function closeSSEWithApi(options?: ObjType) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function getPlatformList(options?: ObjType) {
|
||||||
|
return request("/system/platform-list", {
|
||||||
|
method: "GET",
|
||||||
|
...(options || {}),
|
||||||
|
});
|
||||||
|
}
|
||||||
export async function getDashboardTotal(options?: ObjType) {
|
export async function getDashboardTotal(options?: ObjType) {
|
||||||
return request("/dashboard/total", {
|
return request("/dashboard/total", {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
|
|||||||
7
src/services/typings.d.ts
vendored
7
src/services/typings.d.ts
vendored
@@ -116,6 +116,13 @@ declare namespace API {
|
|||||||
validityStartTime?: string | null;
|
validityStartTime?: string | null;
|
||||||
validityEndTime?: string | null;
|
validityEndTime?: string | null;
|
||||||
validityStatus?: number | null;
|
validityStatus?: number | null;
|
||||||
|
|
||||||
|
mt4Count: number;
|
||||||
|
mt4Open: number;
|
||||||
|
mt5Count: number;
|
||||||
|
mt5Open: number;
|
||||||
|
sourceType4Count: number;
|
||||||
|
sourceType5Count: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
// "DataSource" Type
|
// "DataSource" Type
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
|
"ignoreDeprecations": "6.0",
|
||||||
"baseUrl": "./",
|
"baseUrl": "./",
|
||||||
"target": "esnext",
|
"target": "esnext",
|
||||||
"moduleResolution": "node",
|
"moduleResolution": "node",
|
||||||
|
|||||||
Reference in New Issue
Block a user