二维码生成和下载保存列表 优化 切换ws遗留的上一个在线设备数据 增加预定义路线生成 完善任务规划界面 的中英文
This commit is contained in:
@@ -293,10 +293,11 @@ export function getCodeListApi() {
|
||||
|
||||
//分页查询二维码/system/qrcode/page
|
||||
|
||||
export function getCodeListPageApi() {
|
||||
export function getCodeListPageApi(params) {
|
||||
return request({
|
||||
url: `/system/qrcode/page`,
|
||||
method: 'get',
|
||||
params
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1112,6 +1112,7 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
|
||||
function resolveDeviceStatus(device) {
|
||||
const fsRaw = device?.feStatus;
|
||||
const stRaw = device?.status;
|
||||
if (device?.onlineStatus == 0) return 'offline';
|
||||
|
||||
// feStatus:0=离线,1=工作中,2=空闲
|
||||
if (fsRaw !== undefined && fsRaw !== null && fsRaw !== '') {
|
||||
@@ -3894,7 +3895,7 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
|
||||
}}
|
||||
>
|
||||
<span style={{ fontSize: '18px', lineHeight: 1 }}>⌖</span>
|
||||
<span>定位到机器</span>
|
||||
<span>{t('devices.mapEditor.location')}</span>
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
|
||||
@@ -6,12 +6,12 @@ import {
|
||||
import QRCode from 'qrcode';
|
||||
import DictManager from "../DictManager";
|
||||
import request from '../../api/request';
|
||||
import { Country, State } from 'country-state-city';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import {
|
||||
EyeOutlined,
|
||||
EditOutlined,
|
||||
DeleteOutlined,
|
||||
DownloadOutlined
|
||||
} from '@ant-design/icons';
|
||||
|
||||
// 接口导入
|
||||
@@ -45,10 +45,6 @@ const SerialNumGenerate = () => {
|
||||
const [form] = Form.useForm();
|
||||
const [searchForm] = Form.useForm();
|
||||
|
||||
// 国家/省份
|
||||
const [allCountries, setAllCountries] = useState([]);
|
||||
const [provinces, setProvinces] = useState([]);
|
||||
|
||||
// 二维码生成
|
||||
const [qrUrl, setQrUrl] = useState('');
|
||||
const [serialNumber, setSerialNumber] = useState('');
|
||||
@@ -62,10 +58,7 @@ const SerialNumGenerate = () => {
|
||||
const [manageVisible, setManageVisible] = useState(false);
|
||||
const [addModalVisible, setAddModalVisible] = useState(false);
|
||||
|
||||
// 业务数据
|
||||
const [types, setTypes] = useState([]);
|
||||
const [models, setModels] = useState([]);
|
||||
const [configs, setConfigs] = useState([]);
|
||||
|
||||
|
||||
// 二维码列表
|
||||
const [codeList, setCodeList] = useState([]);
|
||||
@@ -81,40 +74,12 @@ const SerialNumGenerate = () => {
|
||||
const [viewModal, setViewModal] = useState(false);
|
||||
const [viewRecord, setViewRecord] = useState(null);
|
||||
|
||||
// 映射
|
||||
const countryNameMap = useRef({});
|
||||
const provinceNameMap = useRef({});
|
||||
|
||||
// 工具方法:解析 qrJson
|
||||
const parseQrJson = (qrJson) => {
|
||||
if (!qrJson) return {};
|
||||
try {
|
||||
return JSON.parse(qrJson);
|
||||
} catch {
|
||||
return {};
|
||||
}
|
||||
};
|
||||
|
||||
// 初始化
|
||||
useEffect(() => {
|
||||
const countries = Country.getAllCountries();
|
||||
setAllCountries(countries || []);
|
||||
countries.forEach(item => {
|
||||
countryNameMap.current[item.isoCode] = item.name;
|
||||
});
|
||||
loadTypeList();
|
||||
loadModelList();
|
||||
loadConfigList();
|
||||
|
||||
loadCodeList();
|
||||
}, [currentPage]);
|
||||
|
||||
// 国家切换
|
||||
const handleCountryChange = (countryCode) => {
|
||||
const states = State.getStatesOfCountry(countryCode);
|
||||
setProvinces(states || []);
|
||||
form.setFieldsValue({ province: undefined });
|
||||
};
|
||||
|
||||
// 加载二维码列表
|
||||
const loadCodeList = async () => {
|
||||
setCodeLoading(true);
|
||||
@@ -165,64 +130,28 @@ const SerialNumGenerate = () => {
|
||||
setViewModal(true);
|
||||
};
|
||||
|
||||
// 加载数据
|
||||
const loadTypeList = async () => {
|
||||
try {
|
||||
const res = await getRobotTypeListApi({});
|
||||
if (res?.code === 200) setTypes(res.data || []);
|
||||
} catch (e) { }
|
||||
};
|
||||
const loadModelList = async () => {
|
||||
try {
|
||||
const res = await getRobotModelPageApi({ pageNum: 1, pageSize: 100 });
|
||||
if (res?.code === 200) setModels(res.data || []);
|
||||
} catch (e) { }
|
||||
};
|
||||
const loadConfigList = async () => {
|
||||
try {
|
||||
const res = await getRobotConfigListApi({});
|
||||
if (res?.code === 200) setConfigs(res.data || []);
|
||||
} catch (e) { }
|
||||
// 列表下载单个二维码
|
||||
const handleDownloadItem = async (record) => {
|
||||
if (!record.qrCodeBase64) {
|
||||
return messageApi.warning(t('systemSetting.s26'));
|
||||
}
|
||||
const link = document.createElement('a');
|
||||
link.download = `${record.serialNumber || 'qrcode'}.png`;
|
||||
link.href = record.qrCodeBase64;
|
||||
link.click();
|
||||
};
|
||||
|
||||
// 生成序列号
|
||||
const generateSerialSuffix = () => {
|
||||
const num = Math.floor(Math.random() * 100000000).toString(16).toUpperCase().padStart(8, '0');
|
||||
const check = Math.floor(Math.random() * 256).toString(16).toUpperCase().padStart(2, '0');
|
||||
return `${num}-${check}`;
|
||||
};
|
||||
|
||||
// 生成二维码
|
||||
const generateQRCode = async () => {
|
||||
|
||||
// 根据输入的序列号生成二维码
|
||||
const generateQRCodeBySn = async (sn: string) => {
|
||||
try {
|
||||
const values = await form.validateFields();
|
||||
const { model, config, type, country, province } = values;
|
||||
const ts = Date.now();
|
||||
const suffix = generateSerialSuffix();
|
||||
|
||||
const parts = [];
|
||||
if (model) parts.push(model + config);
|
||||
if (country) parts.push(country);
|
||||
if (province) parts.push(province);
|
||||
parts.push(ts);
|
||||
parts.push(suffix);
|
||||
|
||||
const serialNumber = parts.join('-');
|
||||
|
||||
const qrData = {
|
||||
model,
|
||||
config,
|
||||
type,
|
||||
countryCode: country,
|
||||
countryFullName: countryNameMap.current[country] || country,
|
||||
provinceCode: province,
|
||||
provinceFullName: provinceNameMap.current[province] || province,
|
||||
serialNumber
|
||||
serialNumber: sn
|
||||
};
|
||||
const qrContent = JSON.stringify(qrData, null, 2);
|
||||
const url = await QRCode.toDataURL(qrContent);
|
||||
|
||||
setSerialNumber(serialNumber);
|
||||
setSerialNumber(sn);
|
||||
setQrJson(qrContent);
|
||||
setQrUrl(url);
|
||||
} catch (err) {
|
||||
@@ -230,7 +159,19 @@ const SerialNumGenerate = () => {
|
||||
}
|
||||
};
|
||||
|
||||
// 下载
|
||||
// 新增弹窗序列号输入变化时自动生成二维码
|
||||
const handleSnChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
const sn = e.target.value.trim();
|
||||
if (sn) {
|
||||
generateQRCodeBySn(sn);
|
||||
} else {
|
||||
setSerialNumber('');
|
||||
setQrUrl('');
|
||||
setQrJson('');
|
||||
}
|
||||
};
|
||||
|
||||
// 下载当前弹窗二维码
|
||||
const downloadQRCode = () => {
|
||||
if (!qrUrl) return messageApi.warning(t('systemSetting.s26'));
|
||||
const link = document.createElement('a');
|
||||
@@ -239,23 +180,15 @@ const SerialNumGenerate = () => {
|
||||
link.click();
|
||||
};
|
||||
|
||||
// 保存
|
||||
// 保存到数据库
|
||||
const saveToDatabase = async () => {
|
||||
if (!serialNumber) return messageApi.warning(t('systemSetting.s26'));
|
||||
try {
|
||||
setLoading(true);
|
||||
const values = form.getFieldsValue();
|
||||
const model = models.find(m => m.displayName === values.model);
|
||||
const config = configs.find(c => c.displayName === values.config);
|
||||
const type = types.find(t => t.storeValue === values.type);
|
||||
|
||||
const data = {
|
||||
serialNumber,
|
||||
modelId: model?.id || 0,
|
||||
configId: config?.id || 0,
|
||||
typeId: type?.id || 0,
|
||||
qrCode: qrUrl,
|
||||
qrJson: qrJson
|
||||
|
||||
};
|
||||
|
||||
const res = await saveCodeApi(data);
|
||||
@@ -279,9 +212,7 @@ const SerialNumGenerate = () => {
|
||||
|
||||
// 查询
|
||||
const handleQueryQRCode = async () => {
|
||||
// 从搜索表单中获取序列号
|
||||
const serialNumber = searchForm.getFieldValue('serialNumber');
|
||||
|
||||
if (!serialNumber) {
|
||||
loadCodeList();
|
||||
return;
|
||||
@@ -290,7 +221,6 @@ const SerialNumGenerate = () => {
|
||||
try {
|
||||
const res = await getCodeImgApi(serialNumber);
|
||||
if (res.data) {
|
||||
|
||||
setCodeList([res.data]);
|
||||
} else {
|
||||
messageApi.warning(t('systemSetting.notFixed2Search'));
|
||||
@@ -323,52 +253,8 @@ const SerialNumGenerate = () => {
|
||||
};
|
||||
|
||||
// 表格列
|
||||
// 表格列 —— 已修改:全部显示名称,不显示编码
|
||||
const columns = [
|
||||
{
|
||||
title: t('systemSetting.s222'),
|
||||
key: 'idx',
|
||||
width: 70,
|
||||
render: (_, __, index) => (currentPage - 1) * pageSize + index + 1
|
||||
},
|
||||
{ title: t('systemSetting.s6'), width: 380, dataIndex: 'serialNumber', key: 'sn', ellipsis: true },
|
||||
{
|
||||
title: t('systemSetting.s92'),
|
||||
key: 'model',
|
||||
render: (_, r) => {
|
||||
const qrInfo = parseQrJson(r.qrJson);
|
||||
const modelItem = models.find(m => m.storeValue == qrInfo.model);
|
||||
return modelItem?.displayName || qrInfo.model || '-';
|
||||
}
|
||||
},
|
||||
{
|
||||
title: t('systemSetting.s112'),
|
||||
key: 'config',
|
||||
render: (_, r) => {
|
||||
const qrInfo = parseQrJson(r.qrJson);
|
||||
const configItem = configs.find(c => c.storeValue === qrInfo.config);
|
||||
return configItem?.displayName || qrInfo.config || '-';
|
||||
}
|
||||
},
|
||||
{
|
||||
title: t('common.type'),
|
||||
key: 'type',
|
||||
render: (_, r) => {
|
||||
const qrInfo = parseQrJson(r.qrJson);
|
||||
const typeItem = types.find(t => t.storeValue === qrInfo.type);
|
||||
return typeItem?.displayName || qrInfo.type || '-';
|
||||
}
|
||||
},
|
||||
{
|
||||
title: t('systemSetting.s142'),
|
||||
key: 'country',
|
||||
render: (_, r) => parseQrJson(r.qrJson).countryFullName || '-'
|
||||
},
|
||||
{
|
||||
title: t('systemSetting.s162'),
|
||||
key: 'province',
|
||||
render: (_, r) => parseQrJson(r.qrJson).provinceFullName || '-'
|
||||
},
|
||||
{
|
||||
title: t('systemSetting.s23'),
|
||||
key: 'img',
|
||||
@@ -378,11 +264,12 @@ const SerialNumGenerate = () => {
|
||||
{
|
||||
title: t('roles.actions'),
|
||||
key: 'opt',
|
||||
width: 180,
|
||||
width: 240,
|
||||
fixed: "right",
|
||||
render: (_, r) => (
|
||||
<Space>
|
||||
<Button type="link" icon={<EyeOutlined />} onClick={() => handleView(r)}>{t('common.view')}</Button>
|
||||
<Button type="link" icon={<DownloadOutlined />} onClick={() => handleDownloadItem(r)}>{t('common.download')}</Button>
|
||||
<Popconfirm
|
||||
title={t('common.confirmDelete')}
|
||||
onConfirm={() => handleDelete(r.id)}
|
||||
@@ -410,14 +297,13 @@ const SerialNumGenerate = () => {
|
||||
extra={
|
||||
<Space wrap>
|
||||
<Button type="primary" onClick={() => setAddModalVisible(true)}>{t('common.addNew')}</Button>
|
||||
<Button onClick={() => setManageVisible(true)}>{t('systemSetting.s110')}</Button>
|
||||
{/*<Button onClick={() => setManageVisible(true)}>{t('systemSetting.s110')}</Button>*/}
|
||||
<Popconfirm title={t('systemSetting.fixed2OkFixed2Delete')} onConfirm={handleBatchDelete}>
|
||||
<Button danger disabled={selectedRowKeys.length === 0}>{t('common.batchDelete')}</Button>
|
||||
</Popconfirm>
|
||||
</Space>
|
||||
}
|
||||
>
|
||||
|
||||
{/* 筛选栏 */}
|
||||
<Form form={searchForm} layout="inline" style={{ marginBottom: 16, flexWrap: 'wrap', gap: 8 }}>
|
||||
<Form.Item name="serialNumber" label={t('systemSetting.s6')}>
|
||||
@@ -431,7 +317,7 @@ const SerialNumGenerate = () => {
|
||||
</Form.Item>
|
||||
</Form>
|
||||
|
||||
{/* 列表 —— 完全自适应 + 右侧固定 + 不溢出 */}
|
||||
{/* 列表 */}
|
||||
<div style={{ width: '100%', overflow: 'auto' }}>
|
||||
<Table
|
||||
rowKey="id"
|
||||
@@ -446,12 +332,11 @@ const SerialNumGenerate = () => {
|
||||
</div>
|
||||
</Card>
|
||||
|
||||
{/* 新增弹窗 */}
|
||||
{/* 新增弹窗 - 优化样式,只留序列号 */}
|
||||
<Modal
|
||||
title={t('systemSetting.robotFixed2Fixed2')}
|
||||
open={addModalVisible}
|
||||
width="90%"
|
||||
style={{ maxWidth: 900 }}
|
||||
width={600}
|
||||
onCancel={() => {
|
||||
setAddModalVisible(false);
|
||||
form.resetFields();
|
||||
@@ -461,44 +346,41 @@ const SerialNumGenerate = () => {
|
||||
footer={null}
|
||||
destroyOnClose
|
||||
>
|
||||
<Row gutter={[24, 16]}>
|
||||
<Col xs={24} lg={14}>
|
||||
<Form form={form} labelCol={{ md: 5 }} wrapperCol={{ md: 19 }} size="large">
|
||||
<Form.Item name="model" label={t('systemSetting.s92')} rules={[{ required: true }]}>
|
||||
<Select placeholder={t('systemSetting.s10')} showSearch>
|
||||
{models.map(m => <Option key={m.id} value={m.storeValue}>{m.displayName}</Option>)}
|
||||
</Select>
|
||||
</Form.Item>
|
||||
<Form.Item name="config" label={t('systemSetting.s112')} rules={[{ required: true }]}>
|
||||
<Select placeholder={t('systemSetting.s12')} showSearch>
|
||||
{configs.map(c => <Option key={c.id} value={c.storeValue}>{c.displayName}</Option>)}
|
||||
</Select>
|
||||
</Form.Item>
|
||||
<Form.Item name="type" label={t('common.type')} rules={[{ required: true }]}>
|
||||
<Select placeholder={t('systemSetting.typeFixed22')} showSearch>
|
||||
{types.map(t => <Option key={t.id} value={t.storeValue}>{t.displayName}</Option>)}
|
||||
</Select>
|
||||
</Form.Item>
|
||||
<Form.Item name="country" label={t('systemSetting.s142')}>
|
||||
<Select placeholder={t('systemSetting.s152')} showSearch allowClear onChange={handleCountryChange}>
|
||||
{allCountries.map(c => <Option key={c.isoCode} value={c.isoCode}>{c.name}</Option>)}
|
||||
</Select>
|
||||
</Form.Item>
|
||||
<Form.Item name="province" label={t('systemSetting.s162')}>
|
||||
<Select placeholder={t('systemSetting.s172')} showSearch allowClear disabled={provinces.length === 0}>
|
||||
{provinces.map(p => <Option key={p.isoCode} value={p.isoCode}>{p.name}</Option>)}
|
||||
</Select>
|
||||
</Form.Item>
|
||||
<Form.Item wrapperCol={{ offset: 5 }}>
|
||||
<Button type="primary" onClick={generateQRCode} block>{t('systemSetting.fixed22')}</Button>
|
||||
<Row gutter={[24, 24]}>
|
||||
<Col span={24}>
|
||||
<Form form={form} layout="vertical" size="large">
|
||||
<Form.Item
|
||||
name="serialNumber"
|
||||
label={t('systemSetting.s6')}
|
||||
rules={[{ required: true, message: t('systemSetting.fixed2PleaseEnter') }]}
|
||||
>
|
||||
<Input
|
||||
placeholder={t('systemSetting.fixed2PleaseEnter')}
|
||||
onChange={handleSnChange}
|
||||
/>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</Col>
|
||||
|
||||
<Col xs={24} lg={10}>
|
||||
<div style={{ padding: 20, background: '#fafafa', borderRadius: 12, border: '1px dashed #d9d9d9', display: 'flex', flexDirection: 'column', alignItems: 'center', minHeight: 400 }}>
|
||||
<Col span={24}>
|
||||
<div style={{
|
||||
padding: 24,
|
||||
background: '#fafafa',
|
||||
borderRadius: 12,
|
||||
border: '1px dashed #d9d9d9',
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
alignItems: 'center',
|
||||
minHeight: 320
|
||||
}}>
|
||||
{serialNumber && (
|
||||
<div style={{ padding: 12, background: '#e6f7ff', borderRadius: 8, width: '100%', textAlign: 'center', marginBottom: 20 }}>
|
||||
<div style={{
|
||||
padding: 12,
|
||||
background: '#e6f7ff',
|
||||
borderRadius: 8,
|
||||
width: '100%',
|
||||
textAlign: 'center',
|
||||
marginBottom: 20
|
||||
}}>
|
||||
<Text strong>{t('systemSetting.s6')}:{serialNumber}</Text>
|
||||
</div>
|
||||
)}
|
||||
@@ -516,22 +398,44 @@ const SerialNumGenerate = () => {
|
||||
</Row>
|
||||
</Modal>
|
||||
|
||||
{/* 查看二维码 */}
|
||||
<Modal open={viewModal} title={t('systemSetting.detailFixed2')} onCancel={() => setViewModal(false)} footer={null} width={400}>
|
||||
{/* 查看二维码弹窗 - 优化样式 + 增加下载 */}
|
||||
<Modal
|
||||
open={viewModal}
|
||||
title={t('systemSetting.detailFixed2')}
|
||||
onCancel={() => setViewModal(false)}
|
||||
footer={null}
|
||||
width={420}
|
||||
>
|
||||
{viewRecord && (
|
||||
<div style={{ textAlign: 'center', display: "flex", flexDirection: "column", justifyContent: "center", alignItems: 'center' }}>
|
||||
<img src={viewRecord.qrCodeBase64} style={{ width: 200, height: 200, maxWidth: '100%' }} alt="qrcode" />
|
||||
<div style={{ marginTop: 16 }}>{t('systemSetting.s6')}:{viewRecord.serialNumber}</div>
|
||||
<div style={{ textAlign: 'center', padding: '16px 8px' }}>
|
||||
<div style={{
|
||||
padding: 24,
|
||||
background: '#fafafa',
|
||||
borderRadius: 12,
|
||||
border: '1px dashed #d9d9d9',
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
alignItems: 'center',
|
||||
}}>
|
||||
<img src={viewRecord.qrCodeBase64} style={{ width: 220, height: 220, maxWidth: '100%' }} alt="qrcode" />
|
||||
|
||||
</div>
|
||||
<div style={{ marginTop: 16, marginBottom: 20 }}>
|
||||
<Text strong>{t('systemSetting.s6')}:{viewRecord.serialNumber}</Text>
|
||||
</div>
|
||||
<Button icon={<DownloadOutlined />} onClick={() => handleDownloadItem(viewRecord)}>
|
||||
{t('common.download')}
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
</Modal>
|
||||
|
||||
{/* 数据管理 */}
|
||||
<Modal open={manageVisible} title={t('systemSetting.s110')} width="90%" style={{ maxWidth: 900 }} onCancel={() => setManageVisible(false)} footer={<Button onClick={() => setManageVisible(false)}>{t('common.close')}</Button>} destroyOnClose>
|
||||
{/*<Modal open={manageVisible} title={t('systemSetting.s110')} width="90%" style={{ maxWidth: 900 }} onCancel={() => setManageVisible(false)} footer={<Button onClick={() => setManageVisible(false)}>{t('common.close')}</Button>} destroyOnClose>
|
||||
<DictManager title={t('systemSetting.fixed2RobotFixed2TypeFixed2')} data={types} fields={[{ name: 'displayName', label: t('systemSetting.fixed2TypeFixed2NameFixed2'), required: true }, { name: 'storeValue', label: t('common.storeValue'), required: true }, { name: 'remark', label: t('roles.remark') }]} onAdd={handleAddType} onUpdate={handleUpdateType} onDelete={deleteRobotTypeApi} refresh={loadTypeList} />
|
||||
<DictManager title={t('systemSetting.fixed2Robot')} data={models} fields={[{ name: 'displayName', label: t('systemSetting.nameFixed22'), required: true }, { name: 'storeValue', label: t('common.storeValue'), required: true }]} onAdd={handleAddModel} onUpdate={handleUpdateModel} onDelete={deleteRobotModelApi} refresh={loadModelList} />
|
||||
<DictManager title={t('systemSetting.s112')} data={configs} fields={[{ name: 'displayName', label: t('systemSetting.nameFixed22'), required: true }, { name: 'storeValue', label: t('common.storeValue'), required: true }]} onAdd={handleAddConfig} onUpdate={handleUpdateConfig} onDelete={deleteRobotConfigApi} refresh={loadConfigList} />
|
||||
</Modal>
|
||||
</Modal>*/}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -109,8 +109,11 @@ export const MapEditorView = React.forwardRef(function MapEditorView(
|
||||
remark: '',
|
||||
});
|
||||
|
||||
// 路径生成:工作模式(覆盖=true / 单点=false)、保存状态
|
||||
const [isCoverage, setIscoverage] = useState(true);
|
||||
// 路径生成:工作模式(coverage=覆盖 / single_point=单点 / predefined_path=预定义)、保存状态
|
||||
const [workMode, setWorkMode] = useState<'coverage' | 'single_point' | 'predefined_path'>('coverage');
|
||||
// 预定义模式:是否启动机器
|
||||
const [ifStart, setIfStart] = useState(true);
|
||||
const isCoverage = workMode === 'coverage' || workMode === 'predefined_path';
|
||||
const [isSaving, setIsSaving] = useState(false);
|
||||
// 预设路径点击预览(覆盖=多边形框,单点=折线)
|
||||
const [previewPolyPoints, setPreviewPolyPoints] = useState<any[]>([]);
|
||||
@@ -215,7 +218,7 @@ export const MapEditorView = React.forwardRef(function MapEditorView(
|
||||
id: String(p.id ?? genId()),
|
||||
lon,
|
||||
lat,
|
||||
name: (p.alias || '').trim() || `返航点-${String(idx + 1).padStart(2, '0')}`,
|
||||
name: (p.alias || '').trim() || `${t('devices.mapEditor.returnPoint')}-${String(idx + 1).padStart(2, '0')}`,
|
||||
deviceId: p.bindDeviceId || undefined,
|
||||
};
|
||||
});
|
||||
@@ -225,7 +228,7 @@ export const MapEditorView = React.forwardRef(function MapEditorView(
|
||||
const savedObstacles = (res?.data?.tempObstaclePoints || []).map((op: any, idx: number) => {
|
||||
const lon = Number(op.position?.lng ?? op.position?.lon ?? op.position?.longitude ?? op.center?.lng ?? op.center?.lon ?? op.center?.longitude ?? op.longitude ?? 0);
|
||||
const lat = Number(op.position?.lat ?? op.position?.latitude ?? op.center?.lat ?? op.center?.latitude ?? op.latitude ?? 0);
|
||||
const name = (op.alias || op.name || '').trim() || `障碍物点-${idx + 1}`;
|
||||
const name = (op.alias || op.name || '').trim() || t('devices.mapEditor.defaultObstaclePointName', { n: idx + 1 });
|
||||
return {
|
||||
id: op.id || genId(),
|
||||
lon,
|
||||
@@ -345,7 +348,7 @@ export const MapEditorView = React.forwardRef(function MapEditorView(
|
||||
...prev,
|
||||
{
|
||||
...point,
|
||||
name: `返航点-${String(prev.length + 1).padStart(2, '0')}`,
|
||||
name: `${t('devices.mapEditor.returnPoint')}-${String(prev.length + 1).padStart(2, '0')}`,
|
||||
deviceId: selectedRobotId,
|
||||
},
|
||||
]);
|
||||
@@ -354,7 +357,7 @@ export const MapEditorView = React.forwardRef(function MapEditorView(
|
||||
...prev,
|
||||
{
|
||||
...point,
|
||||
name: `分区点-${String(prev.length + 1).padStart(2, '0')}`,
|
||||
name: t('devices.mapEditor.defaultRegionName', { n: String(prev.length + 1).padStart(2, '0') }),
|
||||
},
|
||||
]);
|
||||
} else if (activeType === 'routeGen') {
|
||||
@@ -362,7 +365,7 @@ export const MapEditorView = React.forwardRef(function MapEditorView(
|
||||
...prev,
|
||||
{
|
||||
...point,
|
||||
name: `路径点-${prev.length + 1}`,
|
||||
name: t('devices.mapEditor.defaultRoutePointName', { n: prev.length + 1 }),
|
||||
},
|
||||
]);
|
||||
} else {
|
||||
@@ -371,7 +374,7 @@ export const MapEditorView = React.forwardRef(function MapEditorView(
|
||||
...prev,
|
||||
{
|
||||
...point,
|
||||
name: `障碍物点-${prev.length + 1}`,
|
||||
name: t('devices.mapEditor.defaultObstaclePointName', { n: prev.length + 1 }),
|
||||
radius: 0.5,
|
||||
shapeType: 'rect',
|
||||
size_x: 0.5,
|
||||
@@ -686,14 +689,14 @@ export const MapEditorView = React.forwardRef(function MapEditorView(
|
||||
if (!isReturnPoint && !isObstaclePoint) return;
|
||||
|
||||
const pointName = isReturnPoint
|
||||
? item.alias || `返航点-${index + 1}`
|
||||
: item.name || item.alias || `障碍物点-${index + 1}`;
|
||||
? item.alias || `${t('devices.mapEditor.returnPoint')}-${index + 1}`
|
||||
: item.name || item.alias || t('devices.mapEditor.defaultObstaclePointName', { n: index + 1 });
|
||||
|
||||
modal.confirm({
|
||||
title: '确认删除',
|
||||
content: `确定删除「${pointName}」吗?`,
|
||||
okText: '删除',
|
||||
cancelText: '取消',
|
||||
title: t('devices.mapEditor.confirmDeleteTitle'),
|
||||
content: t('devices.mapEditor.confirmDeleteContent', { name: pointName }),
|
||||
okText: t('common.delete'),
|
||||
cancelText: t('common.cancel'),
|
||||
okButtonProps: { danger: true },
|
||||
|
||||
onOk: async () => {
|
||||
@@ -754,69 +757,22 @@ export const MapEditorView = React.forwardRef(function MapEditorView(
|
||||
const res: any = await saveSiteMapInfo(payload);
|
||||
|
||||
if (res?.code === 200) {
|
||||
messageApi.success('删除成功');
|
||||
messageApi.success(t('common.deleteSuccess'));
|
||||
|
||||
// 刷新服务端数据及地图覆盖物
|
||||
await getSiteMapInfoFn();
|
||||
setOverlayRefreshKey((k) => k + 1);
|
||||
} else {
|
||||
messageApi.error(res?.msg || '删除失败');
|
||||
messageApi.error(res?.msg || t('common.deleteFail'));
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('[MapEditor] 删除返航点/障碍物点失败:', error);
|
||||
messageApi.error('删除失败,请稍后重试');
|
||||
messageApi.error(t('devices.mapEditor.deleteFailedRetry'));
|
||||
}
|
||||
},
|
||||
});
|
||||
}; // 修改已配置障碍物点的尺寸
|
||||
const handleUpdateObstacleDimensions = async (
|
||||
item: any,
|
||||
dimensions: { radius?: number; size_x?: number; size_y?: number; shapeType?: 'circle' | 'rect' }
|
||||
) => {
|
||||
try {
|
||||
// 保留其他已配置障碍物点的数据,只修改当前项
|
||||
const tempObstaclePoints = obstaclePointConfigList.map(
|
||||
(point: any) => {
|
||||
const isTarget = String(point.id) === String(item.id);
|
||||
return {
|
||||
position: {
|
||||
lat: Number(point.position?.lat ?? point.lat ?? 0),
|
||||
lng: Number(point.position?.lng ?? point.position?.lon ?? point.lon ?? 0),
|
||||
},
|
||||
radius: isTarget ? (dimensions.radius ?? point.radius) : Number(point.radius),
|
||||
size_x: isTarget ? (dimensions.size_x ?? point.size_x) : Number(point.size_x),
|
||||
size_y: isTarget ? (dimensions.size_y ?? point.size_y) : Number(point.size_y),
|
||||
shapeType: isTarget ? (dimensions.shapeType ?? point.shapeType) : (point.shapeType || 'rect'),
|
||||
alias: point.alias ?? point.name ?? '',
|
||||
source: 'platform'
|
||||
};
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
const payload: any = {
|
||||
tempObstaclePoints,
|
||||
siteId: stationId,
|
||||
orgId: currentStation?.orgId,
|
||||
};
|
||||
|
||||
if (siteMapInfoId != null) {
|
||||
payload.id = siteMapInfoId;
|
||||
}
|
||||
|
||||
const res: any = await saveSiteMapInfo(payload);
|
||||
|
||||
if (res?.code === 200) {
|
||||
messageApi.success('障碍物点修改成功');
|
||||
getSiteMapInfoFn();
|
||||
setOverlayRefreshKey(k => k + 1);
|
||||
} else {
|
||||
messageApi.error(res?.msg || '障碍物点修改失败');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('[MapEditor] update obstacle dimensions failed:', error);
|
||||
messageApi.error('障碍物点修改失败');
|
||||
}
|
||||
};
|
||||
|
||||
// ========== 删除预设路径 ==========
|
||||
const handleDeletePresetRoute = (route: any) => {
|
||||
@@ -896,8 +852,9 @@ export const MapEditorView = React.forwardRef(function MapEditorView(
|
||||
siteId: stationId,
|
||||
orgId: currentStation?.orgId,
|
||||
jsonData: resultObj,
|
||||
mode: isCoverage ? 'coverage' : 'single_point',
|
||||
mode: workMode,
|
||||
routeType: routeForm.routeType,
|
||||
...(workMode === 'predefined_path' ? { ifStart } : {}),
|
||||
|
||||
};
|
||||
formData.append('workRecord', new Blob([JSON.stringify(workRecord)], { type: 'application/json' }));
|
||||
@@ -963,7 +920,7 @@ export const MapEditorView = React.forwardRef(function MapEditorView(
|
||||
onClick={() => setActiveType('returnPoint')}
|
||||
icon={<Navigation size={14} />}
|
||||
>
|
||||
返航点
|
||||
{t('devices.mapEditor.returnPoint')}
|
||||
</Button>
|
||||
<Button
|
||||
type={activeType === 'restArea' ? 'primary' : 'default'}
|
||||
@@ -971,7 +928,7 @@ export const MapEditorView = React.forwardRef(function MapEditorView(
|
||||
onClick={() => setActiveType('restArea')}
|
||||
icon={<MapPinned size={14} />}
|
||||
>
|
||||
分区
|
||||
{t('devices.mapEditor.restArea')}
|
||||
</Button>
|
||||
<Button
|
||||
type={activeType === 'obstaclePoint' ? 'primary' : 'default'}
|
||||
@@ -979,7 +936,7 @@ export const MapEditorView = React.forwardRef(function MapEditorView(
|
||||
onClick={() => setActiveType('obstaclePoint')}
|
||||
icon={<MapPinned size={14} />}
|
||||
>
|
||||
障碍物点
|
||||
{t('devices.mapEditor.obstaclePoint')}
|
||||
</Button>
|
||||
<Button
|
||||
type={activeType === 'routeGen' ? 'primary' : 'default'}
|
||||
@@ -987,7 +944,7 @@ export const MapEditorView = React.forwardRef(function MapEditorView(
|
||||
onClick={() => setActiveType('routeGen')}
|
||||
icon={<Route size={14} />}
|
||||
>
|
||||
路径生成
|
||||
{t('devices.mapEditor.routeGen')}
|
||||
</Button>
|
||||
</Space>
|
||||
|
||||
@@ -1016,16 +973,16 @@ export const MapEditorView = React.forwardRef(function MapEditorView(
|
||||
/>
|
||||
</Space>
|
||||
) : (
|
||||
<span style={{ color: '#999', fontSize: 12 }}>路径模式:点击地图依次添加路径点</span>
|
||||
<span style={{ color: '#999', fontSize: 12 }}>{t('devices.mapEditor.routeModeTip')}</span>
|
||||
)}
|
||||
|
||||
<div style={{ flex: 1 }} />
|
||||
|
||||
<Space size={6}>
|
||||
<Tooltip title="撤销">
|
||||
<Tooltip title={t('devices.mapEditor.undo')}>
|
||||
<Button size="small" icon={<UndoOutlined />} onClick={handleUndo} disabled={currentList.length === 0 && points.length === 0} />
|
||||
</Tooltip>
|
||||
<Tooltip title="清空">
|
||||
<Tooltip title={t('devices.mapEditor.clearAll')}>
|
||||
<Button size="small" icon={<ClearOutlined />} onClick={handleClearAll} />
|
||||
</Tooltip>
|
||||
</Space>
|
||||
@@ -1072,7 +1029,7 @@ export const MapEditorView = React.forwardRef(function MapEditorView(
|
||||
zIndex: 10,
|
||||
}}
|
||||
>
|
||||
{isRouteGen ? '点击地图添加路径点,按顺序生成路线' : '点击地图添加点位'}
|
||||
{isRouteGen ? t('devices.mapEditor.clickAddRoutePoint') : t('devices.mapEditor.clickAddPoint')}
|
||||
</div>
|
||||
)}
|
||||
|
||||
@@ -1088,7 +1045,7 @@ export const MapEditorView = React.forwardRef(function MapEditorView(
|
||||
zIndex: 10,
|
||||
}}
|
||||
>
|
||||
已选点位:{currentList.length}
|
||||
{t('devices.mapEditor.selectedPoints', { count: currentList.length })}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
@@ -1111,7 +1068,7 @@ export const MapEditorView = React.forwardRef(function MapEditorView(
|
||||
{/* 【选择类型】卡片:嵌入模式下由任务规划右侧入口替代 */}
|
||||
{!embedded && (<Card
|
||||
size="small"
|
||||
title="选择类型"
|
||||
title={t('devices.mapEditor.selectType')}
|
||||
variant="borderless"
|
||||
styles={{ body: { padding: 12 } }}
|
||||
>
|
||||
@@ -1132,8 +1089,8 @@ export const MapEditorView = React.forwardRef(function MapEditorView(
|
||||
}}
|
||||
>
|
||||
<Navigation size={18} color="#165DFF" style={{ alignSelf: 'center' }} />
|
||||
<div style={{ fontSize: 13, marginTop: 4 }}>返航点</div>
|
||||
<div style={{ fontSize: 11, color: '#86909C' }}>机器人任务结束后返回的点位</div>
|
||||
<div style={{ fontSize: 13, marginTop: 4 }}>{t('devices.mapEditor.returnPoint')}</div>
|
||||
<div style={{ fontSize: 11, color: '#86909C' }}>{t('devices.mapEditor.returnPointDesc')}</div>
|
||||
</div>
|
||||
<div
|
||||
onClick={() => setActiveType('restArea')}
|
||||
@@ -1151,8 +1108,8 @@ export const MapEditorView = React.forwardRef(function MapEditorView(
|
||||
}}
|
||||
>
|
||||
<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: 13, marginTop: 4 }}>{t('devices.mapEditor.restArea')}</div>
|
||||
<div style={{ fontSize: 11, color: '#86909C' }}>{t('devices.mapEditor.restAreaDesc')}</div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
@@ -1171,8 +1128,8 @@ export const MapEditorView = React.forwardRef(function MapEditorView(
|
||||
}}
|
||||
>
|
||||
<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: 13, marginTop: 4 }}>{t('devices.mapEditor.obstaclePoint')}</div>
|
||||
<div style={{ fontSize: 11, color: '#86909C' }}>{t('devices.mapEditor.obstaclePointDesc')}</div>
|
||||
</div>
|
||||
<div
|
||||
onClick={() => setActiveType('routeGen')}
|
||||
@@ -1190,8 +1147,8 @@ export const MapEditorView = React.forwardRef(function MapEditorView(
|
||||
}}
|
||||
>
|
||||
<Route size={18} color="#00B42A" style={{ alignSelf: 'center' }} />
|
||||
<div style={{ fontSize: 13, marginTop: 4 }}>路径生成</div>
|
||||
<div style={{ fontSize: 11, color: '#86909C' }}>生成规划路径</div>
|
||||
<div style={{ fontSize: 13, marginTop: 4 }}>{t('devices.mapEditor.routeGen')}</div>
|
||||
<div style={{ fontSize: 11, color: '#86909C' }}>{t('devices.mapEditor.routeGenDesc')}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1259,21 +1216,38 @@ export const MapEditorView = React.forwardRef(function MapEditorView(
|
||||
</label>
|
||||
<Select
|
||||
className="w-full"
|
||||
value={isCoverage}
|
||||
onChange={(v) => setIscoverage(v)}
|
||||
value={workMode}
|
||||
onChange={(v) => setWorkMode(v)}
|
||||
options={[
|
||||
{ value: true, label: t('devices.coverageMode') },
|
||||
{ value: false, label: t('devices.singleMode') },
|
||||
{ value: 'coverage', label: t('devices.coverageMode') },
|
||||
{ value: 'single_point', label: t('devices.singleMode') },
|
||||
{ value: 'predefined_path', label: t('devices.predefinedPathMode') },
|
||||
]}
|
||||
/>
|
||||
</div>
|
||||
{workMode === 'predefined_path' && (
|
||||
<div>
|
||||
<label style={{ display: 'block', marginBottom: 6, fontSize: 13, color: '#333' }}>
|
||||
{t('devices.startMachine')}
|
||||
</label>
|
||||
<Select
|
||||
className="w-full"
|
||||
value={ifStart}
|
||||
onChange={(v) => setIfStart(v)}
|
||||
options={[
|
||||
{ value: true, label: t('common.yes') },
|
||||
{ value: false, label: t('common.no') },
|
||||
]}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* 路径点列表 */}
|
||||
<div style={{ borderTop: '1px solid #f0f0f0', paddingTop: 10 }}>
|
||||
<div style={{ fontSize: 13, fontWeight: 600, marginBottom: 8 }}>
|
||||
{t('devices.mapEditor.routePoints')}
|
||||
<span style={{ marginLeft: 8, fontSize: 12, color: '#999', fontWeight: 400 }}>
|
||||
已选 {currentList.length} 个
|
||||
{t('devices.mapEditor.selectedCount', { count: currentList.length })}
|
||||
</span>
|
||||
</div>
|
||||
{currentList.length === 0 ? (
|
||||
@@ -1328,9 +1302,9 @@ export const MapEditorView = React.forwardRef(function MapEditorView(
|
||||
size="small"
|
||||
title={
|
||||
<span style={{ fontSize: 14, fontWeight: 600 }}>
|
||||
{activeType === 'returnPoint' ? '返航点列表' : activeType === 'obstaclePoint' ? '障碍物点列表' : '分区列表'}
|
||||
{activeType === 'returnPoint' ? t('devices.mapEditor.returnPointList') : activeType === 'obstaclePoint' ? t('devices.mapEditor.configuredObstaclePoints') : t('devices.mapEditor.regionList')}
|
||||
<span style={{ marginLeft: 8, fontSize: 12, color: '#999', fontWeight: 400 }}>
|
||||
已选 {currentList.length} 个
|
||||
{t('devices.mapEditor.selectedCount', { count: currentList.length })}
|
||||
</span>
|
||||
</span>
|
||||
}
|
||||
@@ -1354,7 +1328,7 @@ export const MapEditorView = React.forwardRef(function MapEditorView(
|
||||
{currentList.length === 0 ? (
|
||||
<Empty
|
||||
image={Empty.PRESENTED_IMAGE_SIMPLE}
|
||||
description="请在地图上选择或添加点位"
|
||||
description={t('devices.mapEditor.pleaseAddPoint')}
|
||||
/>
|
||||
) : (
|
||||
<div style={{ display: 'flex', flexDirection: 'column', gap: 8 }}>
|
||||
@@ -1395,8 +1369,8 @@ export const MapEditorView = React.forwardRef(function MapEditorView(
|
||||
}}
|
||||
style={{ marginBottom: 4 }}
|
||||
>
|
||||
<Radio value="rect">矩形</Radio>
|
||||
{/*<Radio value="circle">圆形</Radio>*/}
|
||||
<Radio value="rect">{t('devices.mapEditor.shapeRect')}</Radio>
|
||||
{/*<Radio value="circle">{t('devices.mapEditor.shapeCircle')}</Radio>*/}
|
||||
</Radio.Group>
|
||||
{p.shapeType === 'circle' ? (
|
||||
<Input
|
||||
@@ -1404,7 +1378,7 @@ export const MapEditorView = React.forwardRef(function MapEditorView(
|
||||
value={p.radius}
|
||||
type="number"
|
||||
step="0.01"
|
||||
prefix="半径:"
|
||||
prefix={t('devices.mapEditor.radiusLabel') + ':'}
|
||||
suffix="m"
|
||||
onChange={(e) => {
|
||||
const val = parseFloat(e.target.value);
|
||||
@@ -1453,7 +1427,7 @@ export const MapEditorView = React.forwardRef(function MapEditorView(
|
||||
size="small"
|
||||
value={p.deviceId}
|
||||
allowClear
|
||||
placeholder="未绑定"
|
||||
placeholder={t('devices.mapEditor.unbound')}
|
||||
onChange={(v) => bindRobot(p.id, v)}
|
||||
style={{ width: '100%', marginTop: 4 }}
|
||||
options={robots.map(r => ({
|
||||
@@ -1487,7 +1461,7 @@ export const MapEditorView = React.forwardRef(function MapEditorView(
|
||||
<span style={{ fontSize: 14, fontWeight: 600 }}>
|
||||
{t('devices.presetRoutes')}
|
||||
<span style={{ marginLeft: 8, fontSize: 12, color: '#999', fontWeight: 400 }}>
|
||||
共 {presetRoutes.length} 条
|
||||
{t('devices.mapEditor.totalCountWithUnit', { count: presetRoutes.length })}
|
||||
</span>
|
||||
</span>
|
||||
}
|
||||
@@ -1524,8 +1498,8 @@ export const MapEditorView = React.forwardRef(function MapEditorView(
|
||||
</div>
|
||||
<div style={{ fontSize: 11, color: '#86909C', marginTop: 2 }}>
|
||||
{t('devices.mapEditor.mode')}: {route.mode === 'coverage' || route.mode === 'coverage_area'
|
||||
? t('devices.coverageMode')
|
||||
: t('devices.singleMode')}
|
||||
? t('devices.coverageMode') : route.mode === 'predefined_path' ? t('devices.predefinedPathMode')
|
||||
: t('devices.singleMode')}
|
||||
{route.routeType && (
|
||||
<span style={{ marginLeft: 8 }}>
|
||||
· {route.routeType === 'MOWING_TASK' ? t('devices.mapEditor.typeMowing')
|
||||
@@ -1563,7 +1537,7 @@ export const MapEditorView = React.forwardRef(function MapEditorView(
|
||||
{activeType === 'returnPoint'
|
||||
? t('devices.mapEditor.configuredReturnPoints')
|
||||
: activeType === 'obstaclePoint'
|
||||
? '已配置障碍物点'
|
||||
? t('devices.mapEditor.configuredObstaclePoints')
|
||||
: t('devices.mapEditor.configuredRegions')}
|
||||
<span
|
||||
style={{
|
||||
@@ -1691,10 +1665,10 @@ export const MapEditorView = React.forwardRef(function MapEditorView(
|
||||
>
|
||||
<div onClick={(e) => e.stopPropagation()} style={{ fontSize: 13, fontWeight: 500, padding: '4px 0' }}>
|
||||
{isReturnPoint
|
||||
? ((item.alias || '').trim() || `返航点-${String(idx + 1).padStart(2, '0')}`)
|
||||
? ((item.alias || '').trim() || `${t('devices.mapEditor.returnPoint')}-${String(idx + 1).padStart(2, '0')}`)
|
||||
: isObstaclePoint
|
||||
? (item.name || item.alias || `障碍物点-${idx + 1}`)
|
||||
: (item.regionName || `分区-${idx + 1}`)}
|
||||
? (item.name || item.alias || `${t('devices.mapEditor.obstaclePoint')}-${idx + 1}`)
|
||||
: (item.regionName || `${t('devices.mapEditor.restArea')}-${idx + 1}`)}
|
||||
</div>
|
||||
|
||||
{/* 已配置障碍物点:展示类型、尺寸与坐标 */}
|
||||
@@ -1707,29 +1681,29 @@ export const MapEditorView = React.forwardRef(function MapEditorView(
|
||||
marginTop: 2,
|
||||
}}
|
||||
>
|
||||
<div>类型: {item.shapeType === 'circle' ? '圆形' : '矩形'}</div>
|
||||
<div>{t('common.type')}: {item.shapeType === 'circle' ? t('devices.mapEditor.shapeCircle') : t('devices.mapEditor.shapeRect')}</div>
|
||||
{item.shapeType === 'circle' ? (
|
||||
<div>半径: {item.radius}m</div>
|
||||
<div>{t('devices.mapEditor.radiusLabel')}: {item.radius}m</div>
|
||||
) : (
|
||||
<div>尺寸: {item.size_x}m x {item.size_y}m</div>
|
||||
<div>{t('devices.mapEditor.sizeLabel')}: {item.size_x}m x {item.size_y}m</div>
|
||||
)}
|
||||
<div style={{ color: '#C9CDD4', marginTop: 2 }}>
|
||||
经度: {Number(item.lon ?? item.position?.lng ?? item.position?.lon ?? 0).toFixed(6)}
|
||||
纬度: {Number(item.lat ?? item.position?.lat ?? 0).toFixed(6)}
|
||||
{t('devices.mapEditor.longitude')}: {Number(item.lon ?? item.position?.lng ?? item.position?.lon ?? 0).toFixed(6)}
|
||||
{t('devices.mapEditor.latitude')}: {Number(item.lat ?? item.position?.lat ?? 0).toFixed(6)}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
{isReturnPoint && (
|
||||
<div style={{ fontSize: 11, color: '#C9CDD4', marginTop: 2 }}>
|
||||
经度: {Number(item.lon ?? item.position?.lng ?? item.position?.lon ?? 0).toFixed(6)}
|
||||
纬度: {Number(item.lat ?? item.position?.lat ?? 0).toFixed(6)}
|
||||
{t('devices.mapEditor.longitude')}: {Number(item.lon ?? item.position?.lng ?? item.position?.lon ?? 0).toFixed(6)}
|
||||
{t('devices.mapEditor.latitude')}: {Number(item.lat ?? item.position?.lat ?? 0).toFixed(6)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* 已配置返航点:展示绑定信息 */}
|
||||
{isReturnPoint && item.bindDeviceId && (
|
||||
<div style={{ fontSize: 11, color: '#86909C', marginTop: 2 }}>
|
||||
绑定设备: {(() => {
|
||||
{t('devices.mapEditor.bindDevice')}: {(() => {
|
||||
const r = robots.find((x: any) => x.serialNumber === item.bindDeviceId);
|
||||
return r ? `${r.deviceAlias || r.deviceName || r.serialNumber}(${r.serialNumber})` : item.bindDeviceId;
|
||||
})()}
|
||||
|
||||
@@ -824,7 +824,7 @@ export function TaskPlanningView({ selectedMachineSn, embedded = false, onStatsC
|
||||
fetchTaskPoolList();
|
||||
fetchTaskHistoryList();
|
||||
} else {
|
||||
utils.message.error(res.msg || '暂停失败');
|
||||
utils.message.error(res.msg || t('devices.pauseFailed'));
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('暂停任务失败:', err);
|
||||
@@ -846,7 +846,7 @@ export function TaskPlanningView({ selectedMachineSn, embedded = false, onStatsC
|
||||
fetchTaskPoolList();
|
||||
fetchTaskHistoryList();
|
||||
} else {
|
||||
utils.message.error(res.msg || '恢复失败');
|
||||
utils.message.error(res.msg || t('devices.resumeFailed'));
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('恢复任务失败:', err);
|
||||
@@ -1627,7 +1627,7 @@ export function TaskPlanningView({ selectedMachineSn, embedded = false, onStatsC
|
||||
}}
|
||||
>
|
||||
<span style={{ fontSize: 14, fontWeight: 700 }}>
|
||||
任务规划
|
||||
{t('devices.mapEditor.taskPlan')}
|
||||
</span>
|
||||
|
||||
|
||||
@@ -2031,7 +2031,7 @@ export function TaskPlanningView({ selectedMachineSn, embedded = false, onStatsC
|
||||
rowKey="id"
|
||||
columns={taskHistoryColumns}
|
||||
dataSource={taskHistoryList}
|
||||
pagination={{ pageSize: 10, showSizeChanger: false, showQuickJumper: true, showTotal: (total) => '共 ' + total + ' 条' }}
|
||||
pagination={{ pageSize: 10, showSizeChanger: false, showQuickJumper: true, showTotal: (total) => t('devices.mapEditor.totalCountWithUnit', { count: total }) }}
|
||||
|
||||
scroll={{ x: 800, y: 140 }}
|
||||
/>
|
||||
@@ -2097,7 +2097,7 @@ export function TaskPlanningView({ selectedMachineSn, embedded = false, onStatsC
|
||||
]}
|
||||
dataSource={consecutiveTaskList ?? []}
|
||||
loading={consecutiveLoading}
|
||||
pagination={{ pageSize: 10, showSizeChanger: false, showQuickJumper: true, showTotal: (total) => '共 ' + total + ' 条' }}
|
||||
pagination={{ pageSize: 10, showSizeChanger: false, showQuickJumper: true, showTotal: (total) => t('devices.mapEditor.totalCountWithUnit', { count: total }) }}
|
||||
scroll={{ x: 760, y: 140 }}
|
||||
empty={<Empty image={Empty.PRESENTED_IMAGE_SIMPLE} />}
|
||||
/>
|
||||
@@ -2112,17 +2112,17 @@ export function TaskPlanningView({ selectedMachineSn, embedded = false, onStatsC
|
||||
<Col xs={24} xl={8} style={{ display: "flex", flexDirection: "column" }}>
|
||||
{/* 机器人任务规划:地图编辑能力入口 */}
|
||||
<Card
|
||||
title={<span style={{ fontSize: fontTitle, fontWeight: 700 }}>机器人任务规划</span>}
|
||||
title={<span style={{ fontSize: fontTitle, fontWeight: 700 }}>{t('devices.mapEditor.robotTaskPlam')}</span>}
|
||||
variant="borderless"
|
||||
styles={{ body: { padding: 12 } }}
|
||||
style={{ ...cardStyle, marginBottom: 10 }}
|
||||
>
|
||||
<div style={{ display: 'grid', gridTemplateColumns: 'repeat(4, minmax(0, 1fr))', gap: 8 }}>
|
||||
{([
|
||||
{ type: 'returnPoint' as const, label: '返航点', desc: '任务结束返回点', icon: <Navigation size={18} color="#165DFF" /> },
|
||||
{ type: 'restArea' as const, label: '分区', desc: '绑定规划路线', icon: <MapPinned size={18} color="#13C2C2" /> },
|
||||
{ type: 'obstaclePoint' as const, label: '障碍点', desc: '标记障碍区域', icon: <MapPinned size={18} color="#FF7D00" /> },
|
||||
{ type: 'routeGen' as const, label: '路径生成', desc: '生成规划路径', icon: <Route size={18} color="#00B42A" /> },
|
||||
{ type: 'returnPoint' as const, label: t('devices.mapEditor.returnPoint'), desc: t('devices.mapEditor.returnPointDesc'), icon: <Navigation size={18} color="#165DFF" /> },
|
||||
{ type: 'restArea' as const, label: t('devices.mapEditor.restArea'), desc: t('devices.mapEditor.restAreaDesc'), icon: <MapPinned size={18} color="#13C2C2" /> },
|
||||
{ type: 'obstaclePoint' as const, label: t('devices.mapEditor.obstaclePointLabel'), desc: t('devices.mapEditor.obstaclePointDesc'), icon: <MapPinned size={18} color="#FF7D00" /> },
|
||||
{ type: 'routeGen' as const, label: t('devices.mapEditor.routeGen'), desc: t('devices.mapEditor.routeGenDesc'), icon: <Route size={18} color="#00B42A" /> },
|
||||
]).map((item) => {
|
||||
const selected = editorType === item.type;
|
||||
return (
|
||||
@@ -2258,7 +2258,7 @@ export function TaskPlanningView({ selectedMachineSn, embedded = false, onStatsC
|
||||
lineHeight: '16px',
|
||||
}}
|
||||
>
|
||||
选择需要执行任务的区域(可多选)
|
||||
{t('devices.selectDispatchRegions')}
|
||||
</div>
|
||||
|
||||
{/* 区域选择卡片 */}
|
||||
@@ -2408,7 +2408,7 @@ export function TaskPlanningView({ selectedMachineSn, embedded = false, onStatsC
|
||||
lineHeight: '16px',
|
||||
}}
|
||||
>
|
||||
选择需要执行任务的路线(可多选)
|
||||
{t('devices.selectDispatchRoutes')}
|
||||
</div>
|
||||
|
||||
{/* 路线选择卡片 */}
|
||||
@@ -2532,8 +2532,8 @@ export function TaskPlanningView({ selectedMachineSn, embedded = false, onStatsC
|
||||
>
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: 6, marginBottom: 12 }}>
|
||||
<TrendingUp size={16} style={{ color: '#1677ff' }} />
|
||||
<span style={{ fontWeight: 600, fontSize: 13, color: '#1d2129' }}>调节执行顺序 (拖拽排序)</span>
|
||||
<Tooltip title="机器人将按照下方列表从上到下的顺序依次执行路径任务">
|
||||
<span style={{ fontWeight: 600, fontSize: 13, color: '#1d2129' }}>{t('devices.adjustExecutionOrder')}</span>
|
||||
<Tooltip title={t('devices.dragSortTooltip')}>
|
||||
<AlertCircle size={14} style={{ color: '#86909c', cursor: 'help' }} />
|
||||
</Tooltip>
|
||||
</div>
|
||||
|
||||
@@ -30,6 +30,9 @@ export default class DeviceController {
|
||||
this.wsStatus = 'disconnected';
|
||||
this.wsDeviceInfo = {};
|
||||
this.locationInfo = {};
|
||||
// 切换设备后的实时数据门禁:AUTH 确认前丢弃无设备标识的遗留消息
|
||||
this.authConfirmed = true;
|
||||
this.switchAt = 0;
|
||||
|
||||
this.controlTimeout = null;
|
||||
this.keepAliveInterval = null;
|
||||
@@ -360,6 +363,9 @@ export default class DeviceController {
|
||||
this.connectedDeviceSn = newSn;
|
||||
this.wsDeviceInfo = {};
|
||||
this.locationInfo = {};
|
||||
// 切换设备:AUTH 确认前丢弃旧设备遗留的实时数据
|
||||
this.authConfirmed = false;
|
||||
this.switchAt = Date.now();
|
||||
this.isControlled = false;
|
||||
this.onControlStatusChange?.(false);
|
||||
|
||||
@@ -437,6 +443,20 @@ export default class DeviceController {
|
||||
});
|
||||
}
|
||||
|
||||
// 判断实时消息是否属于当前连接设备;设备切换过程中旧设备的遗留消息返回 true
|
||||
isStaleRealtimeMessage(msg, data) {
|
||||
const msgSn = data?.deviceId ?? data?.device_id ?? data?.deviceSn
|
||||
?? msg?.deviceId ?? msg?.device_id ?? msg?.deviceSn ?? msg?.sn;
|
||||
if (msgSn != null && String(msgSn) !== '') {
|
||||
if (String(msgSn) !== String(this.connectedDeviceSn)) return true;
|
||||
this.authConfirmed = true;
|
||||
return false;
|
||||
}
|
||||
// 无设备标识:切换后 AUTH 确认前一律视为遗留数据(兜底 2 秒防止永久丢弃)
|
||||
if (!this.authConfirmed) return Date.now() - (this.switchAt || 0) < 2000;
|
||||
return false;
|
||||
}
|
||||
|
||||
handleWsMessage(msg) {
|
||||
console.log('WS message:', msg);
|
||||
switch (msg.type) {
|
||||
@@ -446,7 +466,7 @@ export default class DeviceController {
|
||||
data[item.name] = item.value;
|
||||
});
|
||||
// 切换任务/切换设备时,忽略上一个设备遗留的实时数据
|
||||
if (data?.deviceId && data.deviceId !== this.connectedDeviceSn) {
|
||||
if (this.isStaleRealtimeMessage(msg, data)) {
|
||||
break;
|
||||
}
|
||||
this.wsDeviceInfo = data;
|
||||
@@ -459,7 +479,7 @@ export default class DeviceController {
|
||||
data[item.name] = item.value;
|
||||
});
|
||||
// 切换任务/切换设备时,忽略上一个设备遗留的实时经纬度,只显示当前连接设备的实时轨迹
|
||||
if (data?.deviceId && data.deviceId !== this.connectedDeviceSn) {
|
||||
if (this.isStaleRealtimeMessage(msg, data)) {
|
||||
break;
|
||||
}
|
||||
this.locationInfo = data;
|
||||
@@ -469,6 +489,7 @@ export default class DeviceController {
|
||||
|
||||
case 'AUTH': {
|
||||
if (msg.isAuth) {
|
||||
this.authConfirmed = true;
|
||||
this.getControl(this.connectedDeviceSn);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -6,6 +6,8 @@ import {
|
||||
CheckCircleFilled,
|
||||
} from '@ant-design/icons';
|
||||
import './TaskTypeRadio.css'
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
type DispatchMode = 'immediate' | 'scheduled';
|
||||
|
||||
interface TaskTypeRadioProps {
|
||||
@@ -17,6 +19,8 @@ const TaskTypeRadio: React.FC<TaskTypeRadioProps> = ({
|
||||
value,
|
||||
onChange,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const options: {
|
||||
value: DispatchMode;
|
||||
title: string;
|
||||
@@ -25,22 +29,24 @@ const TaskTypeRadio: React.FC<TaskTypeRadioProps> = ({
|
||||
}[] = [
|
||||
{
|
||||
value: 'immediate',
|
||||
title: '立即执行任务',
|
||||
description: '下发后机器人立即开始执行',
|
||||
title: t('devices.taskTypeRadio.immediate'),
|
||||
description: t('devices.taskTypeRadio.immediateDescription'),
|
||||
icon: <LoginOutlined />,
|
||||
},
|
||||
{
|
||||
value: 'scheduled',
|
||||
title: '定时任务',
|
||||
description: '设置开始时间和重复周期',
|
||||
title: t('devices.taskTypeRadio.scheduled'),
|
||||
description: t('devices.taskTypeRadio.scheduledDescription'),
|
||||
icon: <ClockCircleOutlined />,
|
||||
},
|
||||
];
|
||||
|
||||
|
||||
|
||||
return (
|
||||
<div className="task-type-radio">
|
||||
<div className="task-type-radio__title">
|
||||
选择任务类型
|
||||
{t('devices.taskTypeRadio.taskType')}
|
||||
</div>
|
||||
|
||||
<Radio.Group
|
||||
|
||||
@@ -789,7 +789,8 @@
|
||||
platformRequestControl: "{{platform}} platformRequestControl",
|
||||
coverageMode: 'coverageMode',
|
||||
singleMode: 'singleMode',
|
||||
|
||||
predefinedPathMode: 'predefinedPathMode',
|
||||
startMachine: 'Start Machine',
|
||||
outDock: 'Out Dock',
|
||||
outdoor: 'Outdoor',
|
||||
panorama: 'Panorama',
|
||||
@@ -909,10 +910,22 @@
|
||||
handleSbus: 'SBUS',
|
||||
handleCustom: 'Custom',
|
||||
},
|
||||
taskTypeRadio: {
|
||||
scheduled: 'Scheduled Task',
|
||||
scheduledDescription: 'Set start time and repeat cycle',
|
||||
immediate: 'Immediate Task',
|
||||
immediateDescription: 'Execute task immediately',
|
||||
taskType: 'Task Type',
|
||||
},
|
||||
|
||||
mapEditor: {
|
||||
returnPoint: 'Return Point',
|
||||
noConfiguredReturnPoints: 'noConfiguredReturnPoints',
|
||||
obstaclePoint: "obstaclePoint",
|
||||
backToResrAfterTask: 'Back To Rest After Task',
|
||||
bindPlanRoute: 'Bind Plan Route',
|
||||
markObstacleArea: 'Mark Obstacle Area',
|
||||
generatePlanArea: 'Generate Plan Area',
|
||||
noConfiguredRegions: 'noConfiguredRegions',
|
||||
noConfiguredObstaclePoints: "noConfiguredObstaclePoints",
|
||||
legend: 'Legend',
|
||||
@@ -956,8 +969,60 @@
|
||||
fillName: 'Please enter route name',
|
||||
needAtLeast2Points: 'At least 2 points required',
|
||||
obstacle: 'Obstacle',
|
||||
location: 'Location',
|
||||
taskPlan: 'Task Plan',
|
||||
robotTaskPlam: 'Robot Task Plan',
|
||||
// card subtitles
|
||||
returnPointDesc: 'Waypoints returned after robot task completes',
|
||||
restAreaDesc: 'Create regions at station and bind preset routes',
|
||||
obstaclePointDesc: 'Mark obstacles on the map (radius defines area)',
|
||||
routeGenDesc: 'Generate a planned route',
|
||||
// toolbar / hints
|
||||
selectType: 'Select Type',
|
||||
routeModeTip: 'Route mode: click map to add points in order',
|
||||
clickAddRoutePoint: 'Click map to add route points, build route in order',
|
||||
clickAddPoint: 'Click map to add a point',
|
||||
selectedPoints: 'Selected points: {{count}}',
|
||||
selectedCount: '{{count}} selected',
|
||||
pleaseAddPoint: 'Please select or add points on the map',
|
||||
// shapes / coordinates
|
||||
shapeRect: 'Rectangle',
|
||||
shapeCircle: 'Circle',
|
||||
radiusLabel: 'Radius',
|
||||
sizeLabel: 'Size',
|
||||
longitude: 'Longitude',
|
||||
latitude: 'Latitude',
|
||||
bindDevice: 'Bound Device',
|
||||
// configured obstacles
|
||||
configuredObstaclePoints: 'Configured Obstacles',
|
||||
// messages
|
||||
confirmDeleteTitle: 'Confirm Delete',
|
||||
confirmDeleteContent: 'Delete "{{name}}" ?',
|
||||
deleteFailedRetry: 'Delete failed, please try again later',
|
||||
obstacleModifySuccess: 'Obstacle updated successfully',
|
||||
obstacleModifyFailed: 'Failed to update obstacle',
|
||||
// default name templates
|
||||
defaultReturnPointName: 'Return Point-{{n}}',
|
||||
defaultRegionName: 'Region Point-{{n}}',
|
||||
defaultRoutePointName: 'Route Point-{{n}}',
|
||||
defaultObstaclePointName: 'Obstacle-{{n}}',
|
||||
totalCountWithUnit: '{{count}} total',
|
||||
|
||||
}, turnSpeed: 'Turn Speed',
|
||||
|
||||
obstaclePointLabel: 'Obstacle',
|
||||
|
||||
saveRegion: 'Save Region',
|
||||
editRegion: 'Edit Region',
|
||||
regionName: 'Region Name',
|
||||
regionNamePlaceholder: 'Enter region name',
|
||||
regionNameRequired: 'Please enter region name',
|
||||
regionCode: 'Region Code',
|
||||
regionCodePlaceholder: 'Enter region code (optional)',
|
||||
defaultRoute: 'Default Route',
|
||||
selectRoutePlaceholder: 'Select default route',
|
||||
bindRoutes: 'Bind Routes',
|
||||
selectRoutesPlaceholder: 'Select routes to bind',
|
||||
currentScopePoints: 'Current region scope points',}, turnSpeed: 'Turn Speed',
|
||||
realtimeVideoMonitor: 'Realtime Video Monitor',
|
||||
rechargeBtn: 'Recharge Btn',
|
||||
rechargeCommandSent: 'Recharge Command Sent',
|
||||
@@ -1572,6 +1637,13 @@
|
||||
|
||||
fixed2ControlFixed2: 'Fixed2 Control 请求 超时 Fixed2',
|
||||
controlFailed: "controlFailed",
|
||||
|
||||
pauseFailed: 'Pause failed',
|
||||
resumeFailed: 'Resume failed',
|
||||
selectDispatchRegions: 'Select regions for task execution (multi-select)',
|
||||
selectDispatchRoutes: 'Select routes for task execution (multi-select)',
|
||||
adjustExecutionOrder: 'Adjust execution order (drag to reorder)',
|
||||
dragSortTooltip: 'Robot will execute route tasks sequentially from top to bottom',
|
||||
},
|
||||
video: {
|
||||
onlineVideo: 'Online Video',
|
||||
|
||||
@@ -553,6 +553,8 @@ const zh = {
|
||||
coverOpen: '打开',
|
||||
coverageMode: '覆盖模式',
|
||||
singleMode: '单点模式',
|
||||
predefinedPathMode: '预定义模式',
|
||||
startMachine: '是否启动机器',
|
||||
coverageEquipment: '覆盖设备',
|
||||
coverageValue: '{{types}}/{{units}}',
|
||||
createSuccess: '创建成功',
|
||||
@@ -1541,10 +1543,22 @@ const zh = {
|
||||
handleSbus: 'SBUS',
|
||||
handleCustom: '自定义',
|
||||
},
|
||||
taskTypeRadio: {
|
||||
scheduled: 'd定时任务',
|
||||
scheduledDescription: '设置开始时间和重复周期',
|
||||
immediate: '立即任务',
|
||||
immediateDescription: '下发后机器人立即执行',
|
||||
taskType: '任务类型',
|
||||
},
|
||||
|
||||
mapEditor: {
|
||||
returnPoint: '返航点',
|
||||
restArea: '分区',
|
||||
obstaclePoint: "障碍物点",
|
||||
backToResrAfterTask: '任务结束后返航',
|
||||
bindPlanRoute: '绑定预设路径',
|
||||
markObstacleArea: '标记障碍区域',
|
||||
generatePlanArea: '生成规划区域',
|
||||
legend: '图例',
|
||||
unbound: '未绑定',
|
||||
region: '分区',
|
||||
@@ -1612,7 +1626,55 @@ const zh = {
|
||||
bindRoutes: '绑定线路',
|
||||
selectRoutesPlaceholder: '请选择绑定的预设路径',
|
||||
currentScopePoints: '当前区域范围点数',
|
||||
location: '定位',
|
||||
taskPlan: '任务规划',
|
||||
robotTaskPlam: '机器人任务规划',
|
||||
// 卡片副标题
|
||||
returnPointDesc: '机器人任务结束后返回的点位',
|
||||
restAreaDesc: '场站中发分区,绑定规划路线',
|
||||
obstaclePointDesc: '场站中标记障碍物点,以半径为一个区域',
|
||||
routeGenDesc: '生成规划路径',
|
||||
// 工具栏 / 提示
|
||||
selectType: '选择类型',
|
||||
routeModeTip: '路径模式:点击地图依次添加路径点',
|
||||
clickAddRoutePoint: '点击地图添加路径点,按顺序生成路线',
|
||||
clickAddPoint: '点击地图添加点位',
|
||||
selectedPoints: '已选点位:{{count}}',
|
||||
selectedCount: '已选 {{count}} 个',
|
||||
pleaseAddPoint: '请在地图上选择或添加点位',
|
||||
// 形状 / 坐标
|
||||
shapeRect: '矩形',
|
||||
shapeCircle: '圆形',
|
||||
radiusLabel: '半径',
|
||||
sizeLabel: '尺寸',
|
||||
longitude: '经度',
|
||||
latitude: '纬度',
|
||||
bindDevice: '绑定设备',
|
||||
// 已配置障碍物
|
||||
configuredObstaclePoints: '已配置障碍物点',
|
||||
// 消息提示
|
||||
confirmDeleteTitle: '确认删除',
|
||||
confirmDeleteContent: '确定删除「{{name}}」吗?',
|
||||
deleteFailedRetry: '删除失败,请稍后重试',
|
||||
obstacleModifySuccess: '障碍物点修改成功',
|
||||
obstacleModifyFailed: '障碍物点修改失败',
|
||||
// 默认名称模板
|
||||
defaultReturnPointName: '返航点-{{n}}',
|
||||
defaultRegionName: '分区点-{{n}}',
|
||||
defaultRoutePointName: '路径点-{{n}}',
|
||||
defaultObstaclePointName: '障碍物点-{{n}}',
|
||||
totalCountWithUnit: '共 {{count}} 条',
|
||||
|
||||
|
||||
obstaclePointLabel: '障碍点',
|
||||
},
|
||||
|
||||
pauseFailed: '暂停失败',
|
||||
resumeFailed: '恢复失败',
|
||||
selectDispatchRegions: '选择需要执行任务的区域(可多选)',
|
||||
selectDispatchRoutes: '选择需要执行任务的路线(可多选)',
|
||||
adjustExecutionOrder: '调节执行顺序 (拖拽排序)',
|
||||
dragSortTooltip: '机器人将按照下方列表从上到下的顺序依次执行路径任务',
|
||||
},
|
||||
video: {
|
||||
onlineVideo: '在线视频',
|
||||
|
||||
Reference in New Issue
Block a user