告警模型和工单模型完成 错误模型
This commit is contained in:
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;
|
||||
Reference in New Issue
Block a user