This commit is contained in:
mmc
2026-05-15 10:03:33 +08:00
parent 59a328c10b
commit de2219b4b5
5 changed files with 179 additions and 73 deletions

7
package-lock.json generated
View File

@@ -20,6 +20,7 @@
"axios": "^1.15.1",
"cesium": "^1.140.0",
"clsx": "^2.1.1",
"country-state-city": "^3.2.1",
"dotenv": "^17.2.3",
"echarts": "^6.0.0",
"express": "^4.21.2",
@@ -3329,6 +3330,12 @@
"toggle-selection": "^1.0.6"
}
},
"node_modules/country-state-city": {
"version": "3.2.1",
"resolved": "https://registry.npmjs.org/country-state-city/-/country-state-city-3.2.1.tgz",
"integrity": "sha512-kxbanqMc6izjhc/EHkGPCTabSPZ2G6eG4/97akAYHJUN4stzzFEvQPZoF8oXDQ+10gM/O/yUmISCR1ZVxyb6EA==",
"license": "GPL-3.0"
},
"node_modules/css-color-keywords": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/css-color-keywords/-/css-color-keywords-1.0.0.tgz",

View File

@@ -23,6 +23,7 @@
"axios": "^1.15.1",
"cesium": "^1.140.0",
"clsx": "^2.1.1",
"country-state-city": "^3.2.1",
"dotenv": "^17.2.3",
"echarts": "^6.0.0",
"express": "^4.21.2",

View File

@@ -126,7 +126,7 @@ export function getRobotModelDetailApi(id) {
}
// 新增机器人型号
export function addRobotModel(data) {
export function addRobotModelApi(data) {
return request({
url: '/system/robot/model',
method: 'post',

View File

@@ -1,6 +1,6 @@
import React, { useState } from 'react';
import {
Table, Input, Button, Form, Space, Card, Modal, message
Table, Input, Button, Form, Space, Card, Modal, message, Popconfirm
} from 'antd';
import { EditOutlined, DeleteOutlined } from '@ant-design/icons';
@@ -77,11 +77,12 @@ const DictManager = ({
<Button type="link" icon={<EditOutlined />} onClick={() => handleEdit(record)}>
编辑
</Button>
<Button
type="link"
danger
icon={<DeleteOutlined />}
onClick={async () => {
<Popconfirm
title="确定要删除这条数据吗?"
description="删除后将无法恢复"
okText="确定"
cancelText="取消"
onConfirm={async () => {
try {
const res = await onDelete(record.id);
if (res?.code === 200) {
@@ -95,8 +96,10 @@ const DictManager = ({
}
}}
>
删除
</Button>
<Button type="link" danger icon={<DeleteOutlined />}>
删除
</Button>
</Popconfirm>
</Space>
),
},

View File

@@ -5,7 +5,9 @@ import {
} from 'antd';
import QRCode from 'qrcode';
import DictManager from "../DictManager";
import request from '../../api/request';
import request from '../../api/request'; import { Country, State } from 'country-state-city';
// 接口导入
import {
@@ -18,12 +20,26 @@ import {
updateRobotProvinceApi,
deleteRobotProvinceApi,
getRobotModelPageApi,
addRebotModel
addRobotModelApi,
updateRobotModelApi,
deleteRobotModelApi,
getRobotCountryListApi,
addRobotCountryApi,
updateRobotCountryApi,
deleteRobotCountryApi,
getRobotConfigListApi,
addRobotConfigApi,
updateRobotConfigApi,
deleteRobotConfigApi,
} from '../../api/systemSetting';
const { Text } = Typography;
const SerialNumGenerate = () => {
// 获取国家
const countries1 = Country.getAllCountries();
// 根据国家获取省份
const states = State.getStatesOfCountry('CN');
const [form] = Form.useForm();
const [qrUrl, setQrUrl] = useState('');
const [serialNumber, setSerialNumber] = useState('');
@@ -39,29 +55,26 @@ const SerialNumGenerate = () => {
const [types, setTypes] = useState([]);
const [models, setModels] = useState([]);
const [provinces, setProvinces] = useState([]);
const [countries] = useState([
{ id: 1, value: 'CN', label: '中国' },
{ id: 2, value: 'US', label: '美国' },
]);
const [configs] = useState([
{ id: 1, value: 'AIR', label: 'AIR' },
{ id: 2, value: 'PRO', label: 'PRO' },
]);
const [countries, setCountries] = useState([]);
const [configs, setConfigs] = useState([]);
// 初始化加载
useEffect(() => {
loadTypeList();
loadModelList();
loadProvinceList();
loadCountryList();
loadConfigList();
}, []);
// 加载机器人类型
const loadTypeList = async () => {
try {
const res = await getRobotTypeListApi({});
setTypes(res.rows || []);
if (res?.code == 200) {
setTypes(res.data || []);
}
} catch (e) {
message.error('加载类型失败');
}
};
@@ -69,9 +82,10 @@ const SerialNumGenerate = () => {
const loadModelList = async () => {
try {
const res = await getRobotModelPageApi({ pageNum: 1, pageSize: 100 });
setModels(res.rows || []);
if (res?.code == 200) {
setModels(res?.data || []);
}
} catch (e) {
message.error('加载型号失败');
}
};
@@ -85,6 +99,26 @@ const SerialNumGenerate = () => {
}
};
// 加载国家
const loadCountryList = async () => {
try {
const res = await getRobotCountryListApi({});
setCountries(res.rows || []);
} catch (e) {
message.error('加载国家失败');
}
};
// 加载配置
const loadConfigList = async () => {
try {
const res = await getRobotConfigListApi({});
setConfigs(res.rows || []);
} catch (e) {
message.error('加载配置失败');
}
};
// 生成序号
const generateSerialSuffix = () => {
const num = Math.floor(Math.random() * 100000000).toString(16).toUpperCase().padStart(8, '0');
@@ -185,54 +219,83 @@ const SerialNumGenerate = () => {
}
};
// ==================== 机器人类型:增删改查 ====================
// ==================== 类型 ====================
const handleAddType = async (values) => {
const params = {
typeName: values.typeName,
return await addRobotTypeApi({
storeValue: values.storeValue,
displayName: values.displayName,
remark: values.remark || ''
};
return await addRobotTypeApi(params);
});
};
const handleUpdateType = async (values) => {
const params = {
return await updateRobotTypeApi({
id: values.id,
typeName: values.typeName,
storeValue: values.storeValue,
displayName: values.displayName,
remark: values.remark || ''
};
return await updateRobotTypeApi(params);
};
// ==================== 机器人型号:增删改查 ====================
const handleAddModel = async (values) => {
const params = {
modelName: values.modelName,
storeValue: values.storeValue,
remark: values.remark || ''
};
return await addRebotModel(params)
};
const handleUpdateModel = async (values) => {
const params = {
id: values.id,
modelName: values.modelName,
storeValue: values.storeValue,
remark: values.remark || ''
};
return await request({
url: '/system/robot/model',
method: 'put',
data: params
});
};
const handleDeleteModel = async (id) => {
return await request({
url: `/system/robot/model/${id}`,
method: 'delete'
// ==================== 型号 ====================
const handleAddModel = async (values) => {
return await addRobotModelApi({
modelName: values.modelName,
storeValue: values.storeValue,
displayName: ''
});
};
const handleUpdateModel = async (values) => {
return await updateRobotModelApi({
id: values.id,
modelName: values.modelName,
displayName: values.displayName
});
};
// ==================== 省份 ====================
const handleAddProvince = async (values) => {
return await addRobotProvinceApi({
storeValue: values.storeValue,
displayName: values.displayName,
remark: values.remark || ''
});
};
const handleUpdateProvince = async (values) => {
return await updateRobotProvinceApi({
id: values.id,
storeValue: values.storeValue,
displayName: values.displayName,
remark: values.remark || ''
});
};
// ==================== 国家 ====================
const handleAddCountry = async (values) => {
return await addRobotCountryApi({
countryName: values.countryName,
displayName: values.displayName
});
};
const handleUpdateCountry = async (values) => {
return await updateRobotCountryApi({
id: values.id,
countryName: values.countryName,
displayName: values.displayName
});
};
// ==================== 配置 ====================
const handleAddConfig = async (values) => {
return await addRobotConfigApi({
configName: values.configName,
displayName: values.displayName
});
};
const handleUpdateConfig = async (values) => {
return await updateRobotConfigApi({
id: values.id,
configName: values.configName,
displayName: values.displayName
});
};
@@ -249,35 +312,39 @@ const SerialNumGenerate = () => {
<Form.Item name="model" label="型号" rules={[{ required: true }]}>
<Select placeholder="选择型号">
{models.map(m => (
<Select.Option key={m.id} value={m.storeValue}>{m.modelName}</Select.Option>
<Select.Option key={m.id} value={m.displayName}>{m.modelName}</Select.Option>
))}
</Select>
</Form.Item>
<Form.Item name="config" label="配置" rules={[{ required: true }]}>
<Select placeholder="选择配置">
{configs.map(c => <Select.Option key={c.value} value={c.value}>{c.label}</Select.Option>)}
{configs.map(c => (
<Select.Option key={c.id} value={c.displayName}>{c.configName}</Select.Option>
))}
</Select>
</Form.Item>
<Form.Item name="type" label="类型" rules={[{ required: true }]}>
<Select placeholder="选择类型">
{types.map(t => (
<Select.Option key={t.id} value={t.storeValue}>{t.typeName}</Select.Option>
<Select.Option key={t.id} value={t.displayName}>{t.storeValue}</Select.Option>
))}
</Select>
</Form.Item>
<Form.Item name="country" label="国家" rules={[{ required: true }]}>
<Select placeholder="选择国家">
{countries.map(c => <Select.Option key={c.value} value={c.value}>{c.label}</Select.Option>)}
{countries.map(c => (
<Select.Option key={c.id} value={c.displayName}>{c.countryName}</Select.Option>
))}
</Select>
</Form.Item>
<Form.Item name="province" label="省份" rules={[{ required: true }]}>
<Select placeholder="选择省份">
{provinces.map(p => (
<Select.Option key={p.id} value={p.storeValue}>{p.typeName}</Select.Option>
<Select.Option key={p.id} value={p.displayName}>{p.storeValue}</Select.Option>
))}
</Select>
</Form.Item>
@@ -293,7 +360,7 @@ const SerialNumGenerate = () => {
<Space style={{ width: '100%' }}>
<Input
value={queryCode}
onChange={(e) => setQueryCode(e.value)}
onChange={(e) => setQueryCode(e.target.value)}
placeholder="输入序列号查询"
style={{ width: '300px' }}
/>
@@ -343,8 +410,8 @@ const SerialNumGenerate = () => {
title="机器人类型"
data={types}
fields={[
{ name: 'typeName', label: '类型名称', required: true },
{ name: 'storeValue', label: '存储值', required: true },
{ name: 'storeValue', label: '类型名称', required: true },
{ name: 'displayName', label: '存储值', required: true },
{ name: 'remark', label: '备注', required: false }
]}
onAdd={handleAddType}
@@ -363,24 +430,52 @@ const SerialNumGenerate = () => {
]}
onAdd={handleAddModel}
onUpdate={handleUpdateModel}
onDelete={handleDeleteModel}
onDelete={deleteRobotModelApi}
refresh={loadModelList}
/>
{/* 国家 */}
<DictManager
title="国家"
data={countries}
fields={[
{ name: 'countryName', label: '国家名称', required: true },
{ name: 'displayName', label: '存储值', required: true },
]}
onAdd={handleAddCountry}
onUpdate={handleUpdateCountry}
onDelete={deleteRobotCountryApi}
refresh={loadCountryList}
/>
{/* 省份 */}
<DictManager
title="省份"
data={provinces}
fields={[
{ name: 'typeName', label: '省份名称', required: true },
{ name: 'storeValue', label: '存储值', required: true },
{ name: 'storeValue', label: '省份名称', required: true },
{ name: 'displayName', label: '存储值', required: true },
{ name: 'remark', label: '备注', required: false }
]}
onAdd={addRobotProvinceApi}
onUpdate={updateRobotProvinceApi}
onAdd={handleAddProvince}
onUpdate={handleUpdateProvince}
onDelete={deleteRobotProvinceApi}
refresh={loadProvinceList}
/>
{/* 配置 */}
<DictManager
title="配置"
data={configs}
fields={[
{ name: 'configName', label: '配置名称', required: true },
{ name: 'displayName', label: '存储值', required: true },
]}
onAdd={handleAddConfig}
onUpdate={handleUpdateConfig}
onDelete={deleteRobotConfigApi}
refresh={loadConfigList}
/>
</Modal>
</div>
);