diff --git a/package-lock.json b/package-lock.json index 2db8880..c4e1c4e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -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", diff --git a/package.json b/package.json index af51d0b..0d7a4c7 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/api/systemSetting.ts b/src/api/systemSetting.ts index f72a082..1473d0d 100644 --- a/src/api/systemSetting.ts +++ b/src/api/systemSetting.ts @@ -126,7 +126,7 @@ export function getRobotModelDetailApi(id) { } // 新增机器人型号 -export function addRobotModel(data) { +export function addRobotModelApi(data) { return request({ url: '/system/robot/model', method: 'post', diff --git a/src/components/DictManager.jsx b/src/components/DictManager.jsx index d763558..1813634 100644 --- a/src/components/DictManager.jsx +++ b/src/components/DictManager.jsx @@ -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 = ({ - + + ), }, diff --git a/src/components/SystemSetting/SerialNumGenerate.jsx b/src/components/SystemSetting/SerialNumGenerate.jsx index 15dbe15..10c9e79 100644 --- a/src/components/SystemSetting/SerialNumGenerate.jsx +++ b/src/components/SystemSetting/SerialNumGenerate.jsx @@ -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 = () => { @@ -293,7 +360,7 @@ const SerialNumGenerate = () => { 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} /> + {/* 国家 */} + + {/* 省份 */} + + {/* 配置 */} + );