告警模型和工单模型完成 错误模型
This commit is contained in:
@@ -371,3 +371,78 @@ export function deleteErrorApi(data) {
|
||||
});
|
||||
}
|
||||
|
||||
// ==================== 工单模型 ====================
|
||||
// 分页查询工单模型
|
||||
export function getWorkOrderModelPageApi(params) {
|
||||
return request({
|
||||
url: '/system/workOrderModel/page',
|
||||
method: 'get',
|
||||
params
|
||||
});
|
||||
}
|
||||
|
||||
// 查询工单模型列表
|
||||
export function getWorkOrderModelListApi(data) {
|
||||
return request({
|
||||
url: '/iot/orderModel/list',
|
||||
method: 'post',
|
||||
data
|
||||
});
|
||||
}
|
||||
|
||||
// 查询工单模型详情
|
||||
export function getWorkOrderModelDetailApi(id) {
|
||||
return request({
|
||||
url: `/system/workOrderModel/${id}`,
|
||||
method: 'get'
|
||||
});
|
||||
}
|
||||
|
||||
// 新增工单模型
|
||||
export function addWorkOrderModelApi(data) {
|
||||
return request({
|
||||
url: '/iot/orderModel/save',
|
||||
method: 'post',
|
||||
data
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// 删除工单模型
|
||||
export function deleteWorkOrderModelApi(data) {
|
||||
return request({
|
||||
url: `/iot/orderModel/delete`,
|
||||
method: 'post',
|
||||
data
|
||||
});
|
||||
}
|
||||
|
||||
// ==================== 告警配置 ====================
|
||||
// 查询告警模型列表
|
||||
export function getAlarmOrderConfigListApi(data) {
|
||||
return request({
|
||||
url: '/iot/alarmOrderConfig/list',
|
||||
method: 'post',
|
||||
data
|
||||
});
|
||||
}
|
||||
|
||||
// 新增或修改告警模型
|
||||
export function saveAlarmOrderConfigApi(data) {
|
||||
return request({
|
||||
url: '/iot/alarmOrderConfig/save',
|
||||
method: 'post',
|
||||
data
|
||||
});
|
||||
}
|
||||
|
||||
// 删除告警模型
|
||||
export function deleteAlarmOrderConfigApi(data) {
|
||||
return request({
|
||||
url: '/iot/alarmOrderConfig/delete',
|
||||
method: 'post',
|
||||
data
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
316
src/components/SystemSetting/AlarmSettingsManagement.tsx
Normal file
316
src/components/SystemSetting/AlarmSettingsManagement.tsx
Normal file
@@ -0,0 +1,316 @@
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import {
|
||||
Card,
|
||||
Row,
|
||||
Col,
|
||||
Button,
|
||||
Form,
|
||||
Input,
|
||||
Select,
|
||||
Switch,
|
||||
Space,
|
||||
Table,
|
||||
Modal,
|
||||
message,
|
||||
Tag,
|
||||
App
|
||||
} from 'antd';
|
||||
import {
|
||||
PlusOutlined,
|
||||
ReloadOutlined,
|
||||
EditOutlined,
|
||||
DeleteOutlined
|
||||
} from '@ant-design/icons';
|
||||
import {
|
||||
getAlarmOrderConfigListApi,
|
||||
saveAlarmOrderConfigApi,
|
||||
deleteAlarmOrderConfigApi,
|
||||
getErrorListAllApi, // 错误编码下拉数据源
|
||||
getWorkOrderModelListApi // 工单模型下拉数据源
|
||||
} from '../../api/systemSetting';
|
||||
import { useSelector } from 'react-redux';
|
||||
import { RootState } from '@/src/store';
|
||||
import utils, { workOrderTypeOptions, getWorkOrderTypeText, errorLevelOptions, LEVEL_TAG_COLOR } from '@/lib/utils';
|
||||
|
||||
const { Option } = Select;
|
||||
|
||||
// 告警模型管理子组件
|
||||
const AlarmModelManagement: React.FC = () => {
|
||||
const [form] = Form.useForm();
|
||||
const [list, setList] = useState<any[]>([]);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [modalVisible, setModalVisible] = useState(false);
|
||||
const [editingItem, setEditingItem] = useState<any>(null);
|
||||
const { stationId } = useSelector((state: RootState) => state.station);
|
||||
const { modal } = App.useApp();
|
||||
|
||||
// 批量多选
|
||||
const [selectedRowKeys, setSelectedRowKeys] = useState<(string | number)[]>([]);
|
||||
|
||||
// 下拉数据源:错误编码列表、工单模型列表
|
||||
const [errorCodeOptions, setErrorCodeOptions] = useState<{ label: string; value: string }[]>([]);
|
||||
const [modelOptions, setModelOptions] = useState<{ label: string; value: number }[]>([]);
|
||||
|
||||
// 获取告警模型列表
|
||||
const fetchList = async () => {
|
||||
setLoading(true);
|
||||
const data = { siteId: stationId || '' };
|
||||
try {
|
||||
const res = await getAlarmOrderConfigListApi(data);
|
||||
if (res.code === 200) {
|
||||
setList(res.rows || []);
|
||||
setSelectedRowKeys([]);
|
||||
}
|
||||
} catch (e) {
|
||||
utils.message.error('获取告警模型列表失败');
|
||||
setList([]);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
// 拉取【错误编码】下拉选项(来自错误管理接口)
|
||||
const fetchErrorCodeOptions = async () => {
|
||||
try {
|
||||
const params = { siteId: stationId || '' };
|
||||
const res = await getErrorListAllApi(params);
|
||||
if (res.code === 200 && res.rows) {
|
||||
const opts = res.rows.map((item: any) => ({
|
||||
label: `${item.errorCode} - ${item.errorName}`,
|
||||
value: item.errorCode
|
||||
}));
|
||||
setErrorCodeOptions(opts);
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('拉取错误编码失败', err);
|
||||
}
|
||||
};
|
||||
|
||||
// 拉取【工单模型】下拉选项(来自工单模型接口)
|
||||
const fetchModelOptions = async () => {
|
||||
try {
|
||||
const params = { siteId: stationId || '' };
|
||||
const res = await getWorkOrderModelListApi(params);
|
||||
if (res.code === 200 && res.rows) {
|
||||
const opts = res.rows.map((item: any) => ({
|
||||
label: item.orderName,
|
||||
value: Number(item.id)
|
||||
}));
|
||||
setModelOptions(opts);
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('拉取工单模型失败', err);
|
||||
}
|
||||
};
|
||||
|
||||
// 站点切换:刷新表格、刷新下拉数据源
|
||||
useEffect(() => {
|
||||
fetchList();
|
||||
fetchErrorCodeOptions();
|
||||
fetchModelOptions();
|
||||
}, [stationId]);
|
||||
|
||||
const handleAdd = () => {
|
||||
setEditingItem(null);
|
||||
form.resetFields();
|
||||
setModalVisible(true);
|
||||
};
|
||||
|
||||
const handleEdit = (record: any) => {
|
||||
setEditingItem(record);
|
||||
form.setFieldsValue({
|
||||
errorCode: record.errorCode,
|
||||
modelId: record.modelId,
|
||||
autoGenerateOrder: record.autoGenerateOrder
|
||||
});
|
||||
setModalVisible(true);
|
||||
};
|
||||
|
||||
// 单条删除
|
||||
const handleDelete = (id: string | number) => {
|
||||
modal.confirm({
|
||||
title: '确认删除',
|
||||
content: '您确定要删除这条告警模型吗?',
|
||||
okText: '确定',
|
||||
cancelText: '取消',
|
||||
onOk: async () => {
|
||||
try {
|
||||
const res = await deleteAlarmOrderConfigApi([id]);
|
||||
if (res.code === 200) {
|
||||
message.success('删除成功');
|
||||
fetchList();
|
||||
}
|
||||
} catch (e) {
|
||||
message.error('删除失败');
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// 批量删除
|
||||
const handleBatchDelete = () => {
|
||||
if (!selectedRowKeys.length) {
|
||||
message.warning('请先勾选要删除的数据');
|
||||
return;
|
||||
}
|
||||
modal.confirm({
|
||||
title: '批量删除确认',
|
||||
content: `您确定要删除选中的 ${selectedRowKeys.length} 条告警模型吗?删除后不可恢复!`,
|
||||
okText: '确定',
|
||||
cancelText: '取消',
|
||||
danger: true,
|
||||
onOk: async () => {
|
||||
try {
|
||||
const res = await deleteAlarmOrderConfigApi(selectedRowKeys);
|
||||
if (res.code === 200) {
|
||||
message.success('批量删除成功');
|
||||
fetchList();
|
||||
}
|
||||
} catch (e) {
|
||||
message.error('批量删除失败');
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// 保存:组装后端实体字段 ErrorCode / modelId / autoGenerateOrder
|
||||
const handleSave = async (values: any) => {
|
||||
try {
|
||||
const submitParams = {
|
||||
// 主键编辑时携带
|
||||
...(editingItem ? { id: editingItem.id } : {}),
|
||||
siteId: stationId,
|
||||
// 后端要求字段
|
||||
errorCode: values.errorCode,
|
||||
modelId: values.modelId,
|
||||
autoGenerateOrder: values.autoGenerateOrder ?? false
|
||||
};
|
||||
const res = await saveAlarmOrderConfigApi(submitParams);
|
||||
if (res.code === 200 && res.data === true) {
|
||||
message.success(editingItem ? '更新成功' : '新增成功');
|
||||
setModalVisible(false);
|
||||
form.resetFields();
|
||||
fetchList();
|
||||
}
|
||||
} catch (e) {
|
||||
message.error('保存失败');
|
||||
}
|
||||
};
|
||||
|
||||
// 表格列配置
|
||||
const columns = [
|
||||
{ title: '错误编码', dataIndex: 'errorCode', key: 'errorCode' },
|
||||
{
|
||||
title: '关联工单模型',
|
||||
dataIndex: 'modelId',
|
||||
key: 'modelId',
|
||||
render: (val: number) => {
|
||||
const target = modelOptions.find(m => m.value === val);
|
||||
return target?.label || val;
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '自动生成工单',
|
||||
dataIndex: 'autoGenerateOrder',
|
||||
key: 'autoGenerateOrder',
|
||||
render: (val: boolean) => val ? '是' : '否'
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
key: 'action',
|
||||
render: (_: any, record: any) => (
|
||||
<Space>
|
||||
<Button type="link" onClick={() => handleEdit(record)}>编辑</Button>
|
||||
<Button type="link" danger onClick={() => handleDelete(record.id)}>删除</Button>
|
||||
</Space>
|
||||
)
|
||||
}
|
||||
];
|
||||
|
||||
// 表格多选
|
||||
const rowSelection = {
|
||||
selectedRowKeys,
|
||||
onChange: (keys: (string | number)[]) => setSelectedRowKeys(keys),
|
||||
};
|
||||
|
||||
return (
|
||||
<div>
|
||||
<Card>
|
||||
<Space style={{ marginBottom: 16 }}>
|
||||
<Button type="primary" icon={<PlusOutlined />} onClick={handleAdd}>新增告警模型</Button>
|
||||
<Button icon={<ReloadOutlined />} onClick={fetchList}>刷新</Button>
|
||||
<Button
|
||||
danger
|
||||
icon={<DeleteOutlined />}
|
||||
onClick={handleBatchDelete}
|
||||
disabled={selectedRowKeys.length === 0}
|
||||
>
|
||||
批量删除{selectedRowKeys.length ? `(${selectedRowKeys.length})` : ''}
|
||||
</Button>
|
||||
</Space>
|
||||
<Table
|
||||
rowSelection={rowSelection}
|
||||
columns={columns}
|
||||
dataSource={list}
|
||||
rowKey="id"
|
||||
loading={loading}
|
||||
pagination={false}
|
||||
/>
|
||||
</Card>
|
||||
|
||||
<Modal
|
||||
title={editingItem ? '编辑告警模型' : '新增告警模型'}
|
||||
open={modalVisible}
|
||||
onCancel={() => setModalVisible(false)}
|
||||
footer={null}
|
||||
width={600}
|
||||
>
|
||||
<Form form={form} layout="vertical" onFinish={handleSave}>
|
||||
{/* 错误编码(关联错误管理) */}
|
||||
<Form.Item
|
||||
label="错误编码"
|
||||
name="errorCode"
|
||||
rules={[{ required: true, message: '请选择错误编码' }]}
|
||||
>
|
||||
<Select placeholder="请选择错误编码" options={errorCodeOptions} allowClear />
|
||||
</Form.Item>
|
||||
|
||||
{/* 工单模型ID(关联工单模型) */}
|
||||
<Form.Item
|
||||
label="关联工单模型"
|
||||
name="modelId"
|
||||
rules={[{ required: true, message: '请选择工单模型' }]}
|
||||
>
|
||||
<Select placeholder="请选择工单模型" options={modelOptions} allowClear />
|
||||
</Form.Item>
|
||||
|
||||
{/* 是否自动生成工单 */}
|
||||
<Form.Item
|
||||
label="自动生成工单"
|
||||
name="autoGenerateOrder"
|
||||
valuePropName="checked"
|
||||
>
|
||||
<Switch />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item>
|
||||
<Space>
|
||||
<Button type="primary" htmlType="submit">保存</Button>
|
||||
<Button onClick={() => setModalVisible(false)}>取消</Button>
|
||||
</Space>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</Modal>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
const AlarmSettingsManagement: React.FC = () => {
|
||||
return (
|
||||
<div style={{ padding: 0 }}>
|
||||
<AlarmModelManagement />
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default AlarmSettingsManagement;
|
||||
@@ -35,6 +35,8 @@ import {
|
||||
} from '@/api/systemSetting';
|
||||
import utils from '@/lib/utils';
|
||||
import { errorLevelOptions, errorSourceOptions, CompareEnumOptions } from '@/lib/utils';
|
||||
import { useSelector } from 'react-redux';
|
||||
import { RootState } from '@/src/store';
|
||||
|
||||
const { TextArea } = Input;
|
||||
const { Text, Title } = Typography;
|
||||
@@ -44,6 +46,8 @@ const AntdCard = Card as any;
|
||||
|
||||
|
||||
export default function ErrorManagement() {
|
||||
const { userInfo } = useSelector((state: RootState) => state.user);
|
||||
const { stationId } = useSelector((state: RootState) => state.station);
|
||||
const { modal } = App.useApp();
|
||||
const [form] = Form.useForm();
|
||||
const [searchForm] = Form.useForm();
|
||||
@@ -56,8 +60,11 @@ export default function ErrorManagement() {
|
||||
errorName: '',
|
||||
errorSource: '',
|
||||
errorLevel: '',
|
||||
orgId: userInfo?.orgId || '',
|
||||
siteId: stationId || '',
|
||||
});
|
||||
|
||||
|
||||
const [modalVisible, setModalVisible] = useState(false);
|
||||
const [modalType, setModalType] = useState<'add' | 'edit' | 'view'>('add');
|
||||
const [currentRecord, setCurrentRecord] = useState<any>(null);
|
||||
@@ -68,9 +75,14 @@ export default function ErrorManagement() {
|
||||
const fetchErrorList = async () => {
|
||||
setLoading(true);
|
||||
try {
|
||||
const requestParams = {
|
||||
...params,
|
||||
siteId: stationId || '',
|
||||
};
|
||||
const realParams = Object.fromEntries(
|
||||
Object.entries(params).filter(([_, val]) => val !== '')
|
||||
Object.entries(requestParams).filter(([_, val]) => val !== '')
|
||||
);
|
||||
|
||||
const res = await getErrorListAllApi(realParams);
|
||||
if (res.code === 200) {
|
||||
setErrorList(res.rows || []);
|
||||
@@ -83,6 +95,13 @@ export default function ErrorManagement() {
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
setParams(prev => ({
|
||||
...prev,
|
||||
siteId: stationId || ''
|
||||
}));
|
||||
}, [stationId]);
|
||||
|
||||
useEffect(() => {
|
||||
fetchErrorList();
|
||||
}, [params]);
|
||||
@@ -342,8 +361,8 @@ export default function ErrorManagement() {
|
||||
];
|
||||
|
||||
return (
|
||||
<div style={{ padding: '8px 0px', paddingTop: 8, background: '#f5f7fa', minHeight: 'calc(100vh - 120px)' }}>
|
||||
<AntdCard title="错误管理" style={{ borderRadius: 8 }}>
|
||||
<div style={{ padding: '0px 0px', background: '#f5f7fa', minHeight: 'calc(100vh - 120px)' }}>
|
||||
<AntdCard style={{ borderRadius: 8 }}>
|
||||
{/* 搜索区域完全不变 */}
|
||||
<Form form={searchForm} layout="inline" style={{ marginBottom: 0 }}>
|
||||
<Form.Item name="errorCode" label="错误编码">
|
||||
|
||||
352
src/components/SystemSetting/WorkOrderSettingsManagement.tsx
Normal file
352
src/components/SystemSetting/WorkOrderSettingsManagement.tsx
Normal file
@@ -0,0 +1,352 @@
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import {
|
||||
Card,
|
||||
Row,
|
||||
Col,
|
||||
Button,
|
||||
Form,
|
||||
Input,
|
||||
Select,
|
||||
Switch,
|
||||
Space,
|
||||
Typography,
|
||||
Table,
|
||||
Modal,
|
||||
InputNumber,
|
||||
message,
|
||||
Tag,
|
||||
App
|
||||
} from 'antd';
|
||||
import {
|
||||
PlusOutlined,
|
||||
ReloadOutlined,
|
||||
EditOutlined,
|
||||
DeleteOutlined
|
||||
} from '@ant-design/icons';
|
||||
import {
|
||||
getWorkOrderModelListApi,
|
||||
addWorkOrderModelApi,
|
||||
deleteWorkOrderModelApi,
|
||||
|
||||
} from '../../api/systemSetting';
|
||||
import { getSiteDevice, getRobotRouteList } from '../../api/device';
|
||||
import { useSelector } from 'react-redux';
|
||||
import { RootState } from '@/src/store';
|
||||
import utils, { workOrderTypeOptions, getWorkOrderTypeText, errorLevelOptions, LEVEL_TAG_COLOR } from '@/lib/utils';
|
||||
|
||||
const { TabPane } = Typography;
|
||||
const { Option } = Select;
|
||||
|
||||
// 工单模型管理子组件
|
||||
const WorkOrderModelManagement: React.FC = () => {
|
||||
const [form] = Form.useForm();
|
||||
const [list, setList] = useState([]);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [modalVisible, setModalVisible] = useState(false);
|
||||
const [editingItem, setEditingItem] = useState<any>(null);
|
||||
const { stationId } = useSelector((state: RootState) => state.station);
|
||||
const { userInfo } = useSelector((state: RootState) => state.user);
|
||||
|
||||
const { modal } = App.useApp();
|
||||
|
||||
// 设备和预设路径数据
|
||||
const [deviceOptions, setDeviceOptions] = useState([]);
|
||||
const [routeOptions, setRouteOptions] = useState([]);
|
||||
|
||||
// 批量多选
|
||||
const [selectedRowKeys, setSelectedRowKeys] = useState<(string | number)[]>([]);
|
||||
|
||||
// 获取设备列表
|
||||
const fetchDeviceList = async () => {
|
||||
try {
|
||||
const res = await getSiteDevice({
|
||||
siteId: stationId,
|
||||
pageSize: 9999,
|
||||
pageNum: 1,
|
||||
orgId: userInfo?.orgId
|
||||
});
|
||||
if (res.code === 200) {
|
||||
const devices = res.rows || [];
|
||||
setDeviceOptions(
|
||||
devices.map((item: any) => ({
|
||||
label: item.deviceAlias || item.serialNumber,
|
||||
value: item.serialNumber
|
||||
}))
|
||||
);
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('获取设备列表失败', e);
|
||||
}
|
||||
};
|
||||
|
||||
// 获取预设路径列表
|
||||
const fetchRouteList = async () => {
|
||||
try {
|
||||
const res = await getRobotRouteList({ siteId: stationId });
|
||||
if (res.code === 200) {
|
||||
const routes = res.data || [];
|
||||
setRouteOptions(
|
||||
routes.map((item: any) => ({
|
||||
label: item.workName,
|
||||
value: item.id
|
||||
}))
|
||||
);
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('获取预设路径失败', e);
|
||||
}
|
||||
};
|
||||
|
||||
// 获取数据
|
||||
const fetchList = async () => {
|
||||
setLoading(true);
|
||||
const data = {
|
||||
siteId: stationId || '',
|
||||
}
|
||||
try {
|
||||
const res = await getWorkOrderModelListApi(data);
|
||||
if (res.code === 200) {
|
||||
setList(res.rows || []);
|
||||
// 刷新后清空选中
|
||||
setSelectedRowKeys([]);
|
||||
}
|
||||
} catch (e) {
|
||||
utils.message.error('获取工单模型列表失败');
|
||||
setList([]);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (stationId) {
|
||||
fetchList();
|
||||
fetchDeviceList();
|
||||
fetchRouteList();
|
||||
}
|
||||
}, [stationId]);
|
||||
|
||||
const handleAdd = () => {
|
||||
setEditingItem(null);
|
||||
form.resetFields();
|
||||
setModalVisible(true);
|
||||
};
|
||||
|
||||
const handleEdit = (record: any) => {
|
||||
setEditingItem(record);
|
||||
form.setFieldsValue(record);
|
||||
setModalVisible(true);
|
||||
};
|
||||
|
||||
// 单条删除
|
||||
const handleDelete = (id: string | number) => {
|
||||
modal.confirm({
|
||||
title: '确认删除',
|
||||
content: '您确定要删除这条工单模型吗?',
|
||||
okText: '确定',
|
||||
cancelText: '取消',
|
||||
onOk: async () => {
|
||||
try {
|
||||
const res = await deleteWorkOrderModelApi([id]);
|
||||
if (res.code === 200) {
|
||||
message.success('删除成功');
|
||||
fetchList();
|
||||
}
|
||||
} catch (e) {
|
||||
message.error('删除失败');
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// 批量删除
|
||||
const handleBatchDelete = () => {
|
||||
if (!selectedRowKeys.length) {
|
||||
message.warning('请先勾选要删除的数据');
|
||||
return;
|
||||
}
|
||||
modal.confirm({
|
||||
title: '批量删除确认',
|
||||
content: `您确定要删除选中的 ${selectedRowKeys.length} 条工单模型吗?删除后不可恢复!`,
|
||||
okText: '确定',
|
||||
cancelText: '取消',
|
||||
danger: true,
|
||||
onOk: async () => {
|
||||
try {
|
||||
const res = await deleteWorkOrderModelApi(selectedRowKeys);
|
||||
if (res.code === 200) {
|
||||
message.success('批量删除成功');
|
||||
fetchList();
|
||||
}
|
||||
} catch (e) {
|
||||
message.error('批量删除失败');
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const handleSave = async (values: any) => {
|
||||
try {
|
||||
let res;
|
||||
const payload = {
|
||||
...values,
|
||||
siteId: stationId,
|
||||
deviceId: values.deviceId,
|
||||
routeId: values.routeId
|
||||
};
|
||||
if (editingItem) {
|
||||
res = await addWorkOrderModelApi({ ...payload, id: editingItem.id });
|
||||
} else {
|
||||
res = await addWorkOrderModelApi(payload);
|
||||
}
|
||||
if (res.code === 200 && res.data == true) {
|
||||
message.success(editingItem ? '更新成功' : '新增成功');
|
||||
setModalVisible(false);
|
||||
form.resetFields();
|
||||
fetchList();
|
||||
}
|
||||
} catch (e) {
|
||||
message.error('保存失败');
|
||||
}
|
||||
};
|
||||
|
||||
const columns = [
|
||||
{ title: '工单名称', dataIndex: 'orderName', key: 'orderName' },
|
||||
{
|
||||
title: '工单类型',
|
||||
dataIndex: 'orderType',
|
||||
key: 'orderType',
|
||||
render: getWorkOrderTypeText
|
||||
},
|
||||
{
|
||||
title: '错误等级',
|
||||
dataIndex: 'errorLevel',
|
||||
key: 'errorLevel',
|
||||
render: (val) => {
|
||||
const color = LEVEL_TAG_COLOR[val] || 'default';
|
||||
const text = { 1: '轻微', 2: '一般', 3: '严重' }[val] || val;
|
||||
return <Tag color={color}>{text}</Tag>;
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '机器人',
|
||||
dataIndex: 'deviceId',
|
||||
key: 'deviceId',
|
||||
render: (val) => {
|
||||
const device = deviceOptions.find(d => d.value === val);
|
||||
return device ? device.label : val;
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '预设路径',
|
||||
dataIndex: 'routeId',
|
||||
key: 'routeId',
|
||||
render: (val) => {
|
||||
const route = routeOptions.find(r => r.value === val);
|
||||
return route ? route.label : val;
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '自动生成任务',
|
||||
dataIndex: 'autoGenerateTask',
|
||||
key: 'autoGenerateTask',
|
||||
render: (val: boolean) => val ? '是' : '否'
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
key: 'action',
|
||||
render: (_: any, record: any) => (
|
||||
<Space>
|
||||
<Button type="link" onClick={() => handleEdit(record)}>编辑</Button>
|
||||
<Button type="link" danger onClick={() => handleDelete(record.id)}>删除</Button>
|
||||
</Space>
|
||||
)
|
||||
}
|
||||
];
|
||||
|
||||
// 表格多选配置
|
||||
const rowSelection = {
|
||||
selectedRowKeys,
|
||||
onChange: (keys: (string | number)[]) => setSelectedRowKeys(keys),
|
||||
};
|
||||
|
||||
return (
|
||||
<div>
|
||||
<Card>
|
||||
<Space style={{ marginBottom: 16 }}>
|
||||
<Button type="primary" icon={<PlusOutlined />} onClick={handleAdd}>新增工单模型</Button>
|
||||
<Button icon={<ReloadOutlined />} onClick={fetchList}>刷新</Button>
|
||||
<Button
|
||||
danger
|
||||
icon={<DeleteOutlined />}
|
||||
onClick={handleBatchDelete}
|
||||
disabled={selectedRowKeys.length === 0}
|
||||
>
|
||||
批量删除{selectedRowKeys.length ? `(${selectedRowKeys.length})` : ''}
|
||||
</Button>
|
||||
</Space>
|
||||
<Table
|
||||
rowSelection={rowSelection}
|
||||
columns={columns}
|
||||
dataSource={list}
|
||||
rowKey="id"
|
||||
loading={loading}
|
||||
pagination={false}
|
||||
/>
|
||||
</Card>
|
||||
|
||||
<Modal
|
||||
title={editingItem ? '编辑工单模型' : '新增工单模型'}
|
||||
open={modalVisible}
|
||||
onCancel={() => setModalVisible(false)}
|
||||
footer={null}
|
||||
width={600}
|
||||
>
|
||||
<Form form={form} layout="vertical" onFinish={handleSave}>
|
||||
<Form.Item label="工单名称" name="orderName" rules={[{ required: true, message: '请输入工单名称' }]}>
|
||||
<Input placeholder="请输入工单名称" />
|
||||
</Form.Item>
|
||||
<Form.Item label="工单类型" name="orderType" rules={[{ required: true, message: '请选择工单类型' }]}>
|
||||
<Select placeholder="请选择工单类型" options={workOrderTypeOptions} />
|
||||
</Form.Item>
|
||||
<Form.Item label="错误等级" name="errorLevel" rules={[{ required: true, message: '请选择错误等级' }]}>
|
||||
<Select placeholder="请选择错误等级" options={errorLevelOptions} />
|
||||
</Form.Item>
|
||||
<Form.Item label="机器人" name="deviceId" rules={[{ required: true, message: '请选择机器人' }]}>
|
||||
<Select placeholder="请选择机器人" options={deviceOptions} />
|
||||
</Form.Item>
|
||||
<Form.Item label="预设路径" name="routeId" rules={[{ required: true, message: '请选择预设路径' }]}>
|
||||
<Select placeholder="请选择预设路径" options={routeOptions} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="自动生成任务" name="autoGenerateTask" valuePropName="checked">
|
||||
<Switch />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item>
|
||||
<Space>
|
||||
<Button type="primary" htmlType="submit">保存</Button>
|
||||
<Button onClick={() => setModalVisible(false)}>取消</Button>
|
||||
</Space>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</Modal>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
|
||||
const WorkOrderSettingsManagement: React.FC = () => {
|
||||
const [activeSubTab, setActiveSubTab] = useState('model');
|
||||
|
||||
return (
|
||||
<div style={{ padding: 0 }}>
|
||||
|
||||
{activeSubTab === 'model' && <WorkOrderModelManagement />}
|
||||
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default WorkOrderSettingsManagement;
|
||||
@@ -251,6 +251,12 @@ export const errorLevelOptions = [
|
||||
{ label: '错误', value: 'ERROR' },
|
||||
];
|
||||
|
||||
export const LEVEL_TAG_COLOR = {
|
||||
1: 'success',
|
||||
2: 'warning',
|
||||
3: 'error',
|
||||
};
|
||||
|
||||
|
||||
export const CompareEnumOptions = [
|
||||
{ value: 'EQ', label: '等于', symbol: '=' },
|
||||
@@ -265,3 +271,45 @@ export const CompareEnumOptions = [
|
||||
{ value: 'NOT_CONTAIN', label: '不包含', symbol: 'notContain' },
|
||||
];
|
||||
|
||||
// 工单类型常量
|
||||
// 后端原始枚举定义映射
|
||||
export const WORK_ORDER_TYPE = {
|
||||
MOWER_ERROR: "MOWER_ERROR",
|
||||
UAV_ERROR: "UAV_ERROR",
|
||||
INSPECTION_TASK: "INSPECTION_TASK",
|
||||
COMPONENT_DEFECT: "COMPONENT_DEFECT",
|
||||
CLEAN_TASK: "CLEAN_TASK",
|
||||
MAINTAIN_TASK: "MAINTAIN_TASK",
|
||||
REPAIR_TASK: "REPAIR_TASK",
|
||||
OTHER: "OTHER",
|
||||
} as const;
|
||||
|
||||
// 提取类型,约束入参
|
||||
export type WorkOrderType = typeof WORK_ORDER_TYPE[keyof typeof WORK_ORDER_TYPE];
|
||||
|
||||
// 工单下拉选项(唯一数据源,页面下拉、回显共用)
|
||||
export const workOrderTypeOptions: Array<{
|
||||
value: WorkOrderType;
|
||||
label: string;
|
||||
}> = [
|
||||
{ value: WORK_ORDER_TYPE.MOWER_ERROR, label: "割草机故障" },
|
||||
{ value: WORK_ORDER_TYPE.UAV_ERROR, label: "无人机故障" },
|
||||
{ value: WORK_ORDER_TYPE.INSPECTION_TASK, label: "巡检" },
|
||||
{ value: WORK_ORDER_TYPE.COMPONENT_DEFECT, label: "光伏组件故障" },
|
||||
{ value: WORK_ORDER_TYPE.CLEAN_TASK, label: "清洗任务" },
|
||||
{ value: WORK_ORDER_TYPE.MAINTAIN_TASK, label: "维护任务" },
|
||||
{ value: WORK_ORDER_TYPE.REPAIR_TASK, label: "维修任务" },
|
||||
{ value: WORK_ORDER_TYPE.OTHER, label: "其他" },
|
||||
];
|
||||
|
||||
/**
|
||||
* 根据工单类型编码获取中文显示文本
|
||||
* @param type 工单编码
|
||||
* @returns 对应中文名称
|
||||
*/
|
||||
export const getWorkOrderTypeText = (type?: WorkOrderType | string): string => {
|
||||
if (!type) return "";
|
||||
const target = workOrderTypeOptions.find((item) => item.value === type);
|
||||
return target?.label ?? String(type);
|
||||
};
|
||||
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import {
|
||||
Layout, Menu, Card, Row, Col, Button, Form, Input, Select, Switch, Tag, Space, Typography, message, Table
|
||||
Layout, Menu, Card, Row, Col, Button, Form, Input, Select, Switch, Tag, Space, Typography, Tabs
|
||||
} from 'antd';
|
||||
const { TabPane } = Tabs;
|
||||
import {
|
||||
SettingOutlined, UserOutlined, BellOutlined, LinkOutlined, SafetyOutlined, SyncOutlined,
|
||||
CloudOutlined, TeamOutlined, FileTextOutlined, DatabaseOutlined, CalendarOutlined,
|
||||
@@ -10,7 +11,9 @@ import {
|
||||
NotificationOutlined,
|
||||
ExperimentOutlined,
|
||||
EnvironmentOutlined,
|
||||
ExclamationCircleOutlined
|
||||
ExclamationCircleOutlined,
|
||||
AlertOutlined,
|
||||
FormOutlined
|
||||
} from '@ant-design/icons';
|
||||
import UserRolePage from '../components/SystemSetting/UserPage';
|
||||
import MenuList from '../components/SystemSetting/MenuList';
|
||||
@@ -22,14 +25,34 @@ import OnlineUserPage from '../components/SystemSetting/OnlineUser';
|
||||
import DeviceManagementPage from '../components/SystemSetting/DeviceManagement';
|
||||
import BasicSettings from '../components/SystemSetting/BasicSettings';
|
||||
import ErrorManagement from '../components/SystemSetting/ErrorManagement';
|
||||
import AlarmSettingsManagement from '../components/SystemSetting/AlarmSettingsManagement';
|
||||
import WorkOrderSettingsManagement from '../components/SystemSetting/WorkOrderSettingsManagement';
|
||||
|
||||
const { Header, Content } = Layout;
|
||||
const { Text } = Typography;
|
||||
const { Option } = Select;
|
||||
const AntdCard = Card as any;
|
||||
|
||||
// 基础设置
|
||||
// 重构后的系统维护页面 - 使用Tabs样式
|
||||
const SystemMaintenancePage = () => {
|
||||
const [activeSubTab, setActiveSubTab] = useState('error');
|
||||
|
||||
return (
|
||||
<div className="p-0 pt-[8px] bg-[#f5f7fa] min-h-screen">
|
||||
<Card className="mb-4">
|
||||
<Tabs activeKey={activeSubTab} onChange={setActiveSubTab}>
|
||||
<TabPane tab={<span><ExclamationCircleOutlined />错误管理</span>} key="error" />
|
||||
<TabPane tab={<span><AlertOutlined />告警模型管理</span>} key="alarm" />
|
||||
<TabPane tab={<span><FormOutlined />工单模型管理</span>} key="workOrder" />
|
||||
</Tabs>
|
||||
</Card>
|
||||
|
||||
{activeSubTab === 'error' && <ErrorManagement />}
|
||||
{activeSubTab === 'alarm' && <AlarmSettingsManagement />}
|
||||
{activeSubTab === 'workOrder' && <WorkOrderSettingsManagement />}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
// 右侧面板
|
||||
const RightPanel = () => (
|
||||
@@ -118,9 +141,7 @@ export default function SystemSettings() {
|
||||
if (item.path === '/systemSetting/devices') {
|
||||
return { key: 'devices', label: '设备管理', icon: <AppstoreOutlined /> };
|
||||
}
|
||||
if (item.path === '/systemSetting/errorManage') {
|
||||
return { key: 'errorManager', label: '错误管理', icon: <ExclamationCircleOutlined /> };
|
||||
}
|
||||
// 移除错误管理的单独菜单,已经放在系统维护里面了
|
||||
return null;
|
||||
}).filter(Boolean);
|
||||
|
||||
@@ -133,9 +154,9 @@ export default function SystemSettings() {
|
||||
}
|
||||
});
|
||||
}, []);
|
||||
|
||||
const NoticePage = () => <div style={{ padding: 20 }}><h2>通知策略页面</h2></div>;
|
||||
const DataSafetyPage = () => <div style={{ padding: 20 }}><h2>数据与安全页面</h2></div>;
|
||||
const SystemMaintenancePage = () => <div style={{ padding: 20 }}><h2>系统维护页面</h2></div>;
|
||||
const DefaultPage = () => <div style={{ padding: 20 }}><h2>请选择菜单</h2></div>;
|
||||
const renderTabContent = () => {
|
||||
switch (activeTab) {
|
||||
@@ -161,8 +182,6 @@ export default function SystemSettings() {
|
||||
return <OnlineUserPage />;
|
||||
case 'devices':
|
||||
return <DeviceManagementPage />;
|
||||
case "errorManager":
|
||||
return <ErrorManagement />;
|
||||
default:
|
||||
return <DefaultPage />;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user