优化机器人任务界面,增加根据区域下发任务,增加规则配置界面
This commit is contained in:
@@ -1280,6 +1280,9 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
|
||||
if (viewerRef.current) return;
|
||||
|
||||
const viewer = new window.Cesium.Viewer(containerRef.current, {
|
||||
useBrowserRecommendedResolution: false,
|
||||
|
||||
|
||||
animation: false,
|
||||
timeline: false,
|
||||
baseLayerPicker: true,
|
||||
@@ -1294,6 +1297,8 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
|
||||
fileExtension: "jpg"
|
||||
})
|
||||
});
|
||||
viewer.resolutionScale = 2.0;
|
||||
|
||||
viewerRef.current = viewer;
|
||||
viewer.scene.globe.baseColor = window.Cesium?.Color.BLACK;
|
||||
viewer.scene.globe.depthTestAgainstTerrain = false;
|
||||
@@ -1485,6 +1490,20 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
|
||||
),
|
||||
duration: 0.8,
|
||||
});
|
||||
} else if (focusOverlay.type === 'route') {
|
||||
// 飞到路线的边界框
|
||||
const pts = Array.isArray(focusOverlay.points) ? focusOverlay.points : [];
|
||||
const lons = pts.map(p => Number(p?.lng ?? p?.lon)).filter(n => isFinite(n) && n !== 0);
|
||||
const lats = pts.map(p => Number(p?.lat)).filter(n => isFinite(n) && n !== 0);
|
||||
if (!lons.length || !lats.length) return;
|
||||
setLegendHighlight('');
|
||||
setHighlightReturnPointId('');
|
||||
viewer.camera.flyTo({
|
||||
destination: Cesium.Rectangle.fromDegrees(
|
||||
Math.min(...lons), Math.min(...lats), Math.max(...lons), Math.max(...lats)
|
||||
),
|
||||
duration: 0.8,
|
||||
});
|
||||
}
|
||||
}, [focusOverlay, stationOverlay]);
|
||||
|
||||
|
||||
507
src/components/SystemSetting/RuleConfigManagement.tsx
Normal file
507
src/components/SystemSetting/RuleConfigManagement.tsx
Normal file
@@ -0,0 +1,507 @@
|
||||
import React, { useState, useEffect, useMemo } from 'react';
|
||||
import {
|
||||
Table,
|
||||
Input,
|
||||
Button,
|
||||
Form,
|
||||
Select,
|
||||
Space,
|
||||
Tag,
|
||||
Modal,
|
||||
Card,
|
||||
Typography,
|
||||
Switch,
|
||||
InputNumber,
|
||||
Row,
|
||||
Col,
|
||||
App,
|
||||
} from 'antd';
|
||||
import {
|
||||
SearchOutlined,
|
||||
ReloadOutlined,
|
||||
PlusOutlined,
|
||||
EditOutlined,
|
||||
DeleteOutlined,
|
||||
EyeOutlined,
|
||||
ExclamationCircleOutlined,
|
||||
} from '@ant-design/icons';
|
||||
import {
|
||||
updateTriggerRule,
|
||||
selectRuleBySiteId,
|
||||
deleteRule,
|
||||
} from '@/api/rule';
|
||||
import utils, { CompareEnumOptions } from '@/lib/utils';
|
||||
import { useSelector } from 'react-redux';
|
||||
import { RootState } from '@/src/store';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
const { TextArea } = Input;
|
||||
const { Text } = Typography;
|
||||
const { Option } = Select;
|
||||
|
||||
const AntdCard = Card as any;
|
||||
|
||||
// 规则类型
|
||||
const RuleTypeOptions = [
|
||||
{ value: 'LOW_BATTERY_RETURN', labelKey: 'ruleTypeLowBatteryReturn' },
|
||||
];
|
||||
|
||||
// 适用范围
|
||||
const DeviceScopeOptions = [
|
||||
{ value: 'ALL', labelKey: 'deviceScopeAll' },
|
||||
{ value: 'GROUP', labelKey: 'deviceScopeGroup' },
|
||||
{ value: 'SOME', labelKey: 'deviceScopeSome' },
|
||||
];
|
||||
|
||||
// 触发字段
|
||||
const TriggerKeyOptions = [
|
||||
{ value: 'battery', labelKey: 'triggerKeyBattery' },
|
||||
{ value: 'temperature', labelKey: 'triggerKeyTemperature' },
|
||||
{ value: 'offline_duration', labelKey: 'triggerKeyOfflineDuration' },
|
||||
{ value: 'voltage', labelKey: 'triggerKeyVoltage' },
|
||||
];
|
||||
|
||||
// 执行动作
|
||||
const ActionTypeOptions = [
|
||||
{ value: 'AUTO_TASK', labelKey: 'actionTypeAutoTask' },
|
||||
{ value: 'SEND_COMMAND', labelKey: 'actionTypeSendCommand' },
|
||||
{ value: 'ALARM', labelKey: 'actionTypeAlarm' },
|
||||
{ value: 'WORK_ORDER', labelKey: 'actionTypeWorkOrder' },
|
||||
];
|
||||
|
||||
const rangeOperators = ['BETWEEN', 'NOT_BETWEEN'];
|
||||
|
||||
export default function RuleConfigManagement() {
|
||||
const { t } = useTranslation();
|
||||
const { stationId, currentStation } = useSelector((state: RootState) => state.station);
|
||||
const { modal } = App.useApp();
|
||||
const [form] = Form.useForm();
|
||||
const [searchForm] = Form.useForm();
|
||||
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [ruleList, setRuleList] = useState<any[]>([]);
|
||||
const [filteredList, setFilteredList] = useState<any[]>([]);
|
||||
|
||||
const [modalVisible, setModalVisible] = useState(false);
|
||||
const [modalType, setModalType] = useState<'add' | 'edit' | 'view'>('add');
|
||||
const [currentRecord, setCurrentRecord] = useState<any>(null);
|
||||
const [submitting, setSubmitting] = useState(false);
|
||||
|
||||
// 获取规则列表
|
||||
const fetchRuleList = async () => {
|
||||
if (!stationId) return;
|
||||
setLoading(true);
|
||||
try {
|
||||
const res = await selectRuleBySiteId({ siteId: stationId });
|
||||
const list = res?.data || res?.rows || [];
|
||||
setRuleList(list);
|
||||
setFilteredList(list);
|
||||
} catch (err) {
|
||||
utils.message.error(t('systemSetting.operationFailed'));
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
fetchRuleList();
|
||||
}, [stationId]);
|
||||
|
||||
// 搜索过滤
|
||||
const handleSearch = () => {
|
||||
searchForm.validateFields().then(values => {
|
||||
const next = ruleList.filter(item => {
|
||||
const matchName = !values.ruleName || (item.ruleName || '').toLowerCase().includes(values.ruleName.toLowerCase());
|
||||
const matchType = !values.ruleType || item.ruleType === values.ruleType;
|
||||
const matchEnabled = values.enabled === undefined || values.enabled === '' || Number(item.enabled) === Number(values.enabled);
|
||||
return matchName && matchType && matchEnabled;
|
||||
});
|
||||
setFilteredList(next);
|
||||
});
|
||||
};
|
||||
|
||||
const handleReset = () => {
|
||||
searchForm.resetFields();
|
||||
setFilteredList(ruleList);
|
||||
};
|
||||
|
||||
// 打开弹窗
|
||||
const openModal = (type: 'add' | 'edit' | 'view', record?: any) => {
|
||||
setModalType(type);
|
||||
setCurrentRecord(record || null);
|
||||
setModalVisible(true);
|
||||
form.resetFields();
|
||||
|
||||
if ((type === 'edit' || type === 'view') && record) {
|
||||
const conditions = record.conditions || {};
|
||||
const actionConfig = record.actionConfig || {};
|
||||
const isRange = rangeOperators.includes(conditions.operator);
|
||||
let min = '';
|
||||
let max = '';
|
||||
let value = conditions.value;
|
||||
if (isRange && typeof conditions.value === 'string' && conditions.value.includes(',')) {
|
||||
const [a, b] = conditions.value.split(',');
|
||||
min = a;
|
||||
max = b;
|
||||
value = '';
|
||||
}
|
||||
let argsJson = '';
|
||||
try {
|
||||
argsJson = actionConfig.args ? JSON.stringify(actionConfig.args, null, 2) : '';
|
||||
} catch (e) {
|
||||
argsJson = '';
|
||||
}
|
||||
form.setFieldsValue({
|
||||
ruleName: record.ruleName,
|
||||
ruleType: record.ruleType,
|
||||
deviceScope: record.deviceScope,
|
||||
key: conditions.key,
|
||||
operator: conditions.operator,
|
||||
value,
|
||||
min,
|
||||
max,
|
||||
actionType: actionConfig.actionType,
|
||||
argsJson,
|
||||
enabled: record.enabled === true || record.enabled === 1,
|
||||
ForceExecute: record.ForceExecute === true || record.ForceExecute === 1,
|
||||
});
|
||||
} else {
|
||||
form.setFieldsValue({
|
||||
ruleType: 'LOW_BATTERY_RETURN',
|
||||
deviceScope: 'ALL',
|
||||
key: 'battery',
|
||||
operator: 'LT',
|
||||
actionType: 'AUTO_TASK',
|
||||
enabled: true,
|
||||
ForceExecute: false,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// 保存规则
|
||||
const handleSave = async (values: any) => {
|
||||
let argsObj: any = {};
|
||||
if (values.argsJson) {
|
||||
try {
|
||||
argsObj = JSON.parse(values.argsJson);
|
||||
} catch (e) {
|
||||
utils.message.error(t('systemSetting.invalidJson'));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
const isRange = rangeOperators.includes(values.operator);
|
||||
const value = isRange ? `${values.min},${values.max}` : values.value;
|
||||
|
||||
const submitData: any = {
|
||||
id: modalType === 'edit' ? currentRecord?.id : undefined,
|
||||
ruleName: values.ruleName,
|
||||
ruleType: values.ruleType,
|
||||
deviceScope: values.deviceScope,
|
||||
conditions: {
|
||||
key: values.key,
|
||||
operator: values.operator,
|
||||
value,
|
||||
},
|
||||
actionConfig: {
|
||||
actionType: values.actionType,
|
||||
args: argsObj,
|
||||
},
|
||||
enabled: values.enabled ? 1 : 0,
|
||||
ForceExecute: values.ForceExecute ? 1 : 0,
|
||||
orgId: currentStation?.orgId || '',
|
||||
siteId: stationId || '',
|
||||
};
|
||||
|
||||
setSubmitting(true);
|
||||
try {
|
||||
const res = await updateTriggerRule(submitData);
|
||||
if (res?.code === 200) {
|
||||
utils.message.success(modalType === 'edit' ? t('common.editSuccess') : t('common.addSuccess'));
|
||||
setModalVisible(false);
|
||||
fetchRuleList();
|
||||
} else {
|
||||
utils.message.error(res?.msg || t('systemSetting.operationFailed'));
|
||||
}
|
||||
} catch (err) {
|
||||
utils.message.error(t('systemSetting.operationFailed'));
|
||||
} finally {
|
||||
setSubmitting(false);
|
||||
}
|
||||
};
|
||||
|
||||
// 删除规则
|
||||
const handleDelete = (record: any) => {
|
||||
modal.confirm({
|
||||
title: t('common.confirmDelete'),
|
||||
content: t('systemSetting.confirmDeleteRule', { name: record.ruleName }),
|
||||
icon: <ExclamationCircleOutlined />,
|
||||
okText: t('common.ok'),
|
||||
cancelText: t('common.cancel'),
|
||||
onOk: async () => {
|
||||
try {
|
||||
const res = await deleteRule({ ids: [record.id] });
|
||||
if (res?.code === 200) {
|
||||
utils.message.success(t('common.deleteSuccess'));
|
||||
fetchRuleList();
|
||||
} else {
|
||||
utils.message.error(res?.msg || t('common.deleteFail'));
|
||||
}
|
||||
} catch (err) {
|
||||
utils.message.error(t('common.deleteFail'));
|
||||
}
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
const operatorWatch = Form.useWatch('operator', form);
|
||||
const isRangeOperator = useMemo(() => rangeOperators.includes(operatorWatch), [operatorWatch]);
|
||||
|
||||
const getLabel = (options: any[], value: string, ns: string = 'systemSetting') => {
|
||||
const item = options.find(o => o.value === value);
|
||||
return item ? t(`${ns}.${item.labelKey}`) : value;
|
||||
};
|
||||
|
||||
const renderConditions = (record: any) => {
|
||||
const c = record.conditions || {};
|
||||
const opItem = CompareEnumOptions.find(o => o.value === c.operator);
|
||||
const opLabel = opItem ? t(`constants.${opItem.label}`) : c.operator;
|
||||
return <Text type="secondary">{c.key} {opLabel} {c.value}</Text>;
|
||||
};
|
||||
|
||||
const columns = [
|
||||
{
|
||||
title: t('systemSetting.ruleName'),
|
||||
dataIndex: 'ruleName',
|
||||
key: 'ruleName',
|
||||
width: 180,
|
||||
fixed: 'left' as const,
|
||||
},
|
||||
{
|
||||
title: t('systemSetting.ruleType'),
|
||||
dataIndex: 'ruleType',
|
||||
key: 'ruleType',
|
||||
width: 140,
|
||||
render: (text: string) => getLabel(RuleTypeOptions, text),
|
||||
},
|
||||
{
|
||||
title: t('systemSetting.deviceScope'),
|
||||
dataIndex: 'deviceScope',
|
||||
key: 'deviceScope',
|
||||
width: 120,
|
||||
render: (text: string) => getLabel(DeviceScopeOptions, text),
|
||||
},
|
||||
{
|
||||
title: t('systemSetting.triggerKey'),
|
||||
key: 'conditions',
|
||||
width: 220,
|
||||
render: (_: any, record: any) => renderConditions(record),
|
||||
},
|
||||
{
|
||||
title: t('systemSetting.actionType'),
|
||||
dataIndex: ['actionConfig', 'actionType'],
|
||||
key: 'actionType',
|
||||
width: 140,
|
||||
render: (text: string) => getLabel(ActionTypeOptions, text),
|
||||
},
|
||||
{
|
||||
title: t('systemSetting.enabledLabel'),
|
||||
dataIndex: 'enabled',
|
||||
key: 'enabled',
|
||||
width: 100,
|
||||
render: (val: any) => <Tag color={val === 1 || val === true ? 'green' : 'default'}>{val === 1 || val === true ? t('common.enable') : t('common.disable')}</Tag>,
|
||||
},
|
||||
{
|
||||
title: t('systemSetting.forceExecute'),
|
||||
dataIndex: 'ForceExecute',
|
||||
key: 'ForceExecute',
|
||||
width: 100,
|
||||
render: (val: any) => <Tag color={val === 1 || val === true ? 'orange' : 'default'}>{val === 1 || val === true ? t('common.yes') : t('common.no')}</Tag>,
|
||||
},
|
||||
{
|
||||
title: t('common.actions'),
|
||||
key: 'action',
|
||||
width: 220,
|
||||
fixed: 'right' as const,
|
||||
render: (_: any, record: any) => (
|
||||
<Space>
|
||||
<Button type="link" size="small" icon={<EyeOutlined />} onClick={() => openModal('view', record)}>{t('common.view')}</Button>
|
||||
<Button type="link" size="small" icon={<EditOutlined />} onClick={() => openModal('edit', record)}>{t('common.edit')}</Button>
|
||||
<Button type="link" size="small" danger icon={<DeleteOutlined />} onClick={() => handleDelete(record)}>{t('common.delete')}</Button>
|
||||
</Space>
|
||||
),
|
||||
},
|
||||
];
|
||||
|
||||
const disabledForm = modalType === 'view';
|
||||
|
||||
return (
|
||||
<div style={{ padding: '0px 0px', background: '#f5f7fa', minHeight: 'calc(100vh - 120px)' }}>
|
||||
<AntdCard style={{ borderRadius: 8 }}>
|
||||
<Form form={searchForm} layout="inline" style={{ marginBottom: 16 }}>
|
||||
<Form.Item name="ruleName" label={t('systemSetting.ruleName')}>
|
||||
<Input placeholder={t('systemSetting.pleaseInputRuleName')} style={{ width: 160 }} allowClear />
|
||||
</Form.Item>
|
||||
<Form.Item name="ruleType" label={t('systemSetting.ruleType')}>
|
||||
<Select placeholder={t('systemSetting.pleaseSelectRuleType')} style={{ width: 150 }} allowClear>
|
||||
{RuleTypeOptions.map(option => (
|
||||
<Option key={option.value} value={option.value}>{t(`systemSetting.${option.labelKey}`)}</Option>
|
||||
))}
|
||||
</Select>
|
||||
</Form.Item>
|
||||
<Form.Item name="enabled" label={t('systemSetting.enabledLabel')}>
|
||||
<Select placeholder={t('common.pleaseSelect')} style={{ width: 120 }} allowClear>
|
||||
<Option value={1}>{t('common.enable')}</Option>
|
||||
<Option value={0}>{t('common.disable')}</Option>
|
||||
</Select>
|
||||
</Form.Item>
|
||||
<Form.Item>
|
||||
<Space>
|
||||
<Button type="primary" icon={<SearchOutlined />} onClick={handleSearch}>{t('common.search2')}</Button>
|
||||
<Button icon={<ReloadOutlined />} onClick={handleReset}>{t('common.reset')}</Button>
|
||||
<Button type="primary" icon={<PlusOutlined />} onClick={() => openModal('add')}>{t('systemSetting.addRule')}</Button>
|
||||
</Space>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
|
||||
<Table
|
||||
rowKey="id"
|
||||
columns={columns}
|
||||
dataSource={filteredList}
|
||||
loading={loading}
|
||||
scroll={{ x: 1100 }}
|
||||
pagination={{ pageSize: 10, showSizeChanger: true, showTotal: total => t('common.total', { total }) }}
|
||||
/>
|
||||
</AntdCard>
|
||||
|
||||
<Modal
|
||||
title={modalType === 'add' ? t('systemSetting.addRule') : modalType === 'edit' ? t('systemSetting.editRule') : t('systemSetting.viewRule')}
|
||||
open={modalVisible}
|
||||
width={720}
|
||||
maskClosable={false}
|
||||
destroyOnClose
|
||||
onCancel={() => setModalVisible(false)}
|
||||
footer={
|
||||
disabledForm ? (
|
||||
<Button onClick={() => setModalVisible(false)}>{t('common.close')}</Button>
|
||||
) : (
|
||||
<Space>
|
||||
<Button onClick={() => setModalVisible(false)}>{t('common.cancel')}</Button>
|
||||
<Button type="primary" loading={submitting} onClick={() => form.submit()}>{t('common.save')}</Button>
|
||||
</Space>
|
||||
)
|
||||
}
|
||||
>
|
||||
<Form
|
||||
form={form}
|
||||
layout="vertical"
|
||||
disabled={disabledForm}
|
||||
onFinish={handleSave}
|
||||
>
|
||||
<Row gutter={16}>
|
||||
<Col span={12}>
|
||||
<Form.Item name="ruleName" label={t('systemSetting.ruleName')} rules={[{ required: true, message: t('systemSetting.pleaseInputRuleName') }]}>
|
||||
<Input placeholder={t('systemSetting.pleaseInputRuleName')} />
|
||||
</Form.Item>
|
||||
</Col>
|
||||
<Col span={12}>
|
||||
<Form.Item name="ruleType" label={t('systemSetting.ruleType')} rules={[{ required: true, message: t('systemSetting.pleaseSelectRuleType') }]}>
|
||||
<Select placeholder={t('systemSetting.pleaseSelectRuleType')}>
|
||||
{RuleTypeOptions.map(option => (
|
||||
<Option key={option.value} value={option.value}>{t(`systemSetting.${option.labelKey}`)}</Option>
|
||||
))}
|
||||
</Select>
|
||||
</Form.Item>
|
||||
</Col>
|
||||
</Row>
|
||||
|
||||
<Row gutter={16}>
|
||||
<Col span={12}>
|
||||
<Form.Item name="deviceScope" label={t('systemSetting.deviceScope')} rules={[{ required: true, message: t('systemSetting.pleaseSelectDeviceScope') }]}>
|
||||
<Select placeholder={t('systemSetting.pleaseSelectDeviceScope')}>
|
||||
{DeviceScopeOptions.map(option => (
|
||||
<Option key={option.value} value={option.value}>{t(`systemSetting.${option.labelKey}`)}</Option>
|
||||
))}
|
||||
</Select>
|
||||
</Form.Item>
|
||||
</Col>
|
||||
<Col span={12}>
|
||||
<Form.Item name="key" label={t('systemSetting.triggerKey')} rules={[{ required: true, message: t('systemSetting.pleaseSelectTriggerKey') }]}>
|
||||
<Select placeholder={t('systemSetting.pleaseSelectTriggerKey')}>
|
||||
{TriggerKeyOptions.map(option => (
|
||||
<Option key={option.value} value={option.value}>{t(`systemSetting.${option.labelKey}`)}</Option>
|
||||
))}
|
||||
</Select>
|
||||
</Form.Item>
|
||||
</Col>
|
||||
</Row>
|
||||
|
||||
<Row gutter={16}>
|
||||
<Col span={12}>
|
||||
<Form.Item name="operator" label={t('systemSetting.operator')} rules={[{ required: true, message: t('systemSetting.pleaseSelectOperator') }]}>
|
||||
<Select placeholder={t('systemSetting.pleaseSelectOperator')}>
|
||||
{CompareEnumOptions.map(option => (
|
||||
<Option key={option.value} value={option.value}>{t(`constants.${option.label}`)}</Option>
|
||||
))}
|
||||
</Select>
|
||||
</Form.Item>
|
||||
</Col>
|
||||
<Col span={12}>
|
||||
{isRangeOperator ? (
|
||||
<Row gutter={8}>
|
||||
<Col span={12}>
|
||||
<Form.Item name="min" label={t('systemSetting.triggerValue')} rules={[{ required: true, message: t('systemSetting.pleaseInputTriggerValue') }]}>
|
||||
<InputNumber style={{ width: '100%' }} placeholder={t('systemSetting.pleaseInputTriggerValue')} />
|
||||
</Form.Item>
|
||||
</Col>
|
||||
<Col span={12}>
|
||||
<Form.Item name="max" label=" " rules={[{ required: true, message: t('systemSetting.pleaseInputTriggerValue') }]}>
|
||||
<InputNumber style={{ width: '100%' }} placeholder={t('systemSetting.pleaseInputTriggerValue')} />
|
||||
</Form.Item>
|
||||
</Col>
|
||||
</Row>
|
||||
) : (
|
||||
<Form.Item name="value" label={t('systemSetting.triggerValue')} rules={[{ required: true, message: t('systemSetting.pleaseInputTriggerValue') }]}>
|
||||
<InputNumber style={{ width: '100%' }} placeholder={t('systemSetting.pleaseInputTriggerValue')} />
|
||||
</Form.Item>
|
||||
)}
|
||||
</Col>
|
||||
</Row>
|
||||
|
||||
<Row gutter={16}>
|
||||
<Col span={12}>
|
||||
<Form.Item name="actionType" label={t('systemSetting.actionType')} rules={[{ required: true, message: t('systemSetting.pleaseSelectActionType') }]}>
|
||||
<Select placeholder={t('systemSetting.pleaseSelectActionType')}>
|
||||
{ActionTypeOptions.map(option => (
|
||||
<Option key={option.value} value={option.value}>{t(`systemSetting.${option.labelKey}`)}</Option>
|
||||
))}
|
||||
</Select>
|
||||
</Form.Item>
|
||||
</Col>
|
||||
<Col span={12}>
|
||||
<Form.Item name="enabled" label={t('systemSetting.enabledLabel')} valuePropName="checked">
|
||||
<Switch checkedChildren={t('common.enable')} unCheckedChildren={t('common.disable')} />
|
||||
</Form.Item>
|
||||
</Col>
|
||||
</Row>
|
||||
|
||||
<Row gutter={16}>
|
||||
<Col span={24}>
|
||||
<Form.Item name="argsJson" label={t('systemSetting.actionArgs')}>
|
||||
<TextArea rows={4} placeholder={`{\n "routeId": 123\n}`} />
|
||||
</Form.Item>
|
||||
</Col>
|
||||
</Row>
|
||||
|
||||
<Row gutter={16}>
|
||||
<Col span={12}>
|
||||
<Form.Item name="ForceExecute" label={t('systemSetting.forceExecute')} valuePropName="checked">
|
||||
<Switch checkedChildren={t('common.yes')} unCheckedChildren={t('common.no')} />
|
||||
</Form.Item>
|
||||
</Col>
|
||||
</Row>
|
||||
</Form>
|
||||
</Modal>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,10 +1,11 @@
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import { useSearchParams } from 'react-router-dom';
|
||||
import { Card, Tabs, Typography } from 'antd';
|
||||
import { ExclamationCircleOutlined, AlertOutlined, FormOutlined } from '@ant-design/icons';
|
||||
import { ExclamationCircleOutlined, AlertOutlined, FormOutlined, SafetyCertificateOutlined } from '@ant-design/icons';
|
||||
import ErrorManagement from './ErrorManagement';
|
||||
import AlarmSettingsManagement from './AlarmSettingsManagement';
|
||||
import WorkOrderSettingsManagement from './WorkOrderSettingsManagement';
|
||||
import RuleConfigManagement from './RuleConfigManagement';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
const { TabPane } = Tabs;
|
||||
@@ -17,7 +18,7 @@ export const SystemMaintenancePage = () => {
|
||||
// 初始化:从url读取tab
|
||||
useEffect(() => {
|
||||
const tab = searchParams.get('subTab');
|
||||
if (tab && ['error', 'alarm', 'workOrder'].includes(tab)) {
|
||||
if (tab && ['error', 'alarm', 'workOrder', 'rule'].includes(tab)) {
|
||||
setActiveSubTab(tab);
|
||||
}
|
||||
}, [searchParams]);
|
||||
@@ -38,12 +39,14 @@ export const SystemMaintenancePage = () => {
|
||||
<TabPane tab={<span><ExclamationCircleOutlined />{t('systemSetting.fixed2Error')}</span>} key="error" />
|
||||
<TabPane tab={<span><AlertOutlined />{t('systemSetting.fixed2Alert')}</span>} key="alarm" />
|
||||
<TabPane tab={<span><FormOutlined />{t('systemSetting.s2')}</span>} key="workOrder" />
|
||||
<TabPane tab={<span><SafetyCertificateOutlined />{t('systemSetting.ruleConfig')}</span>} key="rule" />
|
||||
</Tabs>
|
||||
</Card>
|
||||
|
||||
{activeSubTab === 'error' && <ErrorManagement />}
|
||||
{activeSubTab === 'alarm' && <AlarmSettingsManagement />}
|
||||
{activeSubTab === 'workOrder' && <WorkOrderSettingsManagement />}
|
||||
{activeSubTab === 'rule' && <RuleConfigManagement />}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -853,7 +853,7 @@ export default function MapEditorPage() {
|
||||
>
|
||||
<MapPinned size={18} color="#13C2C2" style={{ alignSelf: 'center' }} />
|
||||
<div style={{ fontSize: 13, marginTop: 4 }}>分区</div>
|
||||
<div style={{ fontSize: 11, color: '#86909C' }}>机器人任务中的休息位置</div>
|
||||
<div style={{ fontSize: 11, color: '#86909C' }}>场站中发分区,绑定规划路线</div>
|
||||
</div>
|
||||
<div
|
||||
onClick={() => setActiveType('routeGen')}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
161
src/components/taskRadio/TaskTypeRadio.css
Normal file
161
src/components/taskRadio/TaskTypeRadio.css
Normal file
@@ -0,0 +1,161 @@
|
||||
.task-type-radio {
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.task-type-radio__title {
|
||||
margin-bottom: 12px;
|
||||
color: #000;
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
line-height: 22px;
|
||||
}
|
||||
|
||||
.task-type-radio__group {
|
||||
display: flex;
|
||||
width: 100%;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.task-type-radio__option.ant-radio-wrapper {
|
||||
display: flex;
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
margin-inline-end: 0;
|
||||
align-items: stretch;
|
||||
color: inherit;
|
||||
white-space: normal;
|
||||
}
|
||||
|
||||
.task-type-radio__option > .ant-radio {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.task-type-radio__option > span:last-child {
|
||||
display: block;
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.task-type-radio__card {
|
||||
position: relative;
|
||||
display: flex;
|
||||
width: 100%;
|
||||
min-height: 62px;
|
||||
padding: 10px;
|
||||
box-sizing: border-box;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
|
||||
background: #fff;
|
||||
border: 1px solid #dce5f2;
|
||||
border-radius: 6px;
|
||||
|
||||
cursor: pointer;
|
||||
transition:
|
||||
border-color 0.2s ease,
|
||||
background-color 0.2s ease,
|
||||
box-shadow 0.2s ease;
|
||||
}
|
||||
|
||||
.task-type-radio__card:hover {
|
||||
border-color: #91caff;
|
||||
}
|
||||
|
||||
.task-type-radio__card--checked {
|
||||
border: 1px solid #4096ff;
|
||||
background: #f0f7ff;
|
||||
box-shadow: 0 0 0 1px rgb(22 119 255 / 5%);
|
||||
}
|
||||
|
||||
.task-type-radio__icon {
|
||||
display: flex;
|
||||
flex-shrink: 0;
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
color: #1677ff;
|
||||
background: #e6f4ff;
|
||||
border-radius: 5px;
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
.task-type-radio__content {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.task-type-radio__name {
|
||||
margin-bottom: 4px;
|
||||
overflow: hidden;
|
||||
|
||||
color: #262626;
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
line-height: 18px;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.task-type-radio__description {
|
||||
overflow: hidden;
|
||||
|
||||
color: #8c9bb0;
|
||||
font-size: 11px;
|
||||
font-weight: 400;
|
||||
line-height: 15px;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.task-type-radio__status {
|
||||
display: flex;
|
||||
flex-shrink: 0;
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
color: #1677ff;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.task-type-radio__empty {
|
||||
display: block;
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
box-sizing: border-box;
|
||||
border: 1px solid #cbd5e1;
|
||||
border-radius: 50%;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.task-type-radio__option:focus-visible
|
||||
.task-type-radio__card {
|
||||
outline: 2px solid #91caff;
|
||||
outline-offset: 2px;
|
||||
}
|
||||
|
||||
@media (max-width: 480px) {
|
||||
.task-type-radio__group {
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.task-type-radio__card {
|
||||
padding: 8px;
|
||||
gap: 7px;
|
||||
}
|
||||
|
||||
.task-type-radio__icon {
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
font-size: 17px;
|
||||
}
|
||||
|
||||
.task-type-radio__description {
|
||||
white-space: normal;
|
||||
}
|
||||
}
|
||||
100
src/components/taskRadio/taskRadio.tsx
Normal file
100
src/components/taskRadio/taskRadio.tsx
Normal file
@@ -0,0 +1,100 @@
|
||||
import React from 'react';
|
||||
import { Radio } from 'antd';
|
||||
import {
|
||||
LoginOutlined,
|
||||
ClockCircleOutlined,
|
||||
CheckCircleFilled,
|
||||
} from '@ant-design/icons';
|
||||
import './TaskTypeRadio.css'
|
||||
type DispatchMode = 'immediate' | 'scheduled';
|
||||
|
||||
interface TaskTypeRadioProps {
|
||||
value: DispatchMode;
|
||||
onChange: (value: DispatchMode) => void;
|
||||
}
|
||||
|
||||
const TaskTypeRadio: React.FC<TaskTypeRadioProps> = ({
|
||||
value,
|
||||
onChange,
|
||||
}) => {
|
||||
const options: {
|
||||
value: DispatchMode;
|
||||
title: string;
|
||||
description: string;
|
||||
icon: React.ReactNode;
|
||||
}[] = [
|
||||
{
|
||||
value: 'immediate',
|
||||
title: '立即执行任务',
|
||||
description: '下发后机器人立即开始执行',
|
||||
icon: <LoginOutlined />,
|
||||
},
|
||||
{
|
||||
value: 'scheduled',
|
||||
title: '定时任务',
|
||||
description: '设置开始时间和重复周期',
|
||||
icon: <ClockCircleOutlined />,
|
||||
},
|
||||
];
|
||||
|
||||
return (
|
||||
<div className="task-type-radio">
|
||||
<div className="task-type-radio__title">
|
||||
选择任务类型
|
||||
</div>
|
||||
|
||||
<Radio.Group
|
||||
value={value}
|
||||
onChange={(e) => onChange(e.target.value)}
|
||||
className="task-type-radio__group"
|
||||
>
|
||||
{options.map((option) => {
|
||||
const checked = value === option.value;
|
||||
|
||||
return (
|
||||
<Radio
|
||||
key={option.value}
|
||||
value={option.value}
|
||||
className="task-type-radio__option"
|
||||
>
|
||||
<div
|
||||
className={[
|
||||
'task-type-radio__card',
|
||||
checked
|
||||
? 'task-type-radio__card--checked'
|
||||
: '',
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join(' ')}
|
||||
>
|
||||
<div className="task-type-radio__icon">
|
||||
{option.icon}
|
||||
</div>
|
||||
|
||||
<div className="task-type-radio__content">
|
||||
<div className="task-type-radio__name">
|
||||
{option.title}
|
||||
</div>
|
||||
|
||||
<div className="task-type-radio__description">
|
||||
{option.description}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="task-type-radio__status">
|
||||
{checked ? (
|
||||
<CheckCircleFilled />
|
||||
) : (
|
||||
<span className="task-type-radio__empty" />
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</Radio>
|
||||
);
|
||||
})}
|
||||
</Radio.Group>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default TaskTypeRadio;
|
||||
Reference in New Issue
Block a user