xx
This commit is contained in:
@@ -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>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user