样式和工单列表接口

This commit is contained in:
mmc
2026-05-15 15:39:28 +08:00
parent ae7368b3d0
commit bc48abc038
20 changed files with 251 additions and 93 deletions

View File

@@ -78,6 +78,8 @@ const WorkOrderPage = () => {
const [completeModalVisible, setCompleteModalVisible] = useState(false);
const [completeForm] = Form.useForm(); // 完成工单表单
const [messageApi, contextHolder] = message.useMessage();
// 统计数据(保留原模拟不变)
const stats = [
@@ -122,7 +124,7 @@ const WorkOrderPage = () => {
}
}
} catch (error) {
message.error('获取工单列表失败');
messageApi.error('获取工单列表失败');
} finally {
setLoading(false);
}
@@ -130,7 +132,7 @@ const WorkOrderPage = () => {
// 打开完成工单弹窗
const openCompleteModal = () => {
if (!selectedRowKey) return message.warning('请先选择工单');
if (!selectedRowKey) return messageApi.warning('请先选择工单');
completeForm.setFieldsValue({
id: currentDetail?.id,
orderNo: currentDetail?.orderNo,
@@ -151,13 +153,13 @@ const WorkOrderPage = () => {
};
await completeWorkOrder(params);
message.success('工单已完成');
messageApi.success('工单已完成');
setCompleteModalVisible(false);
// 刷新列表 + 详情
getWorkOrderList();
getWorkOrderDetail(selectedRowKey);
} catch (err) {
message.error('工单完成失败');
messageApi.error('工单完成失败');
console.error(err);
}
};
@@ -170,7 +172,7 @@ const WorkOrderPage = () => {
setCurrentDetail(res.data);
}
} catch (error) {
message.error('获取工单详情失败');
messageApi.error('获取工单详情失败');
}
};
@@ -184,13 +186,12 @@ const WorkOrderPage = () => {
// 打开修改工单弹窗
const openEditModal = () => {
if (!selectedRowKey) return message.warning('请先选择一条工单');
if (!selectedRowKey) return messageApi.warning('请先选择一条工单');
form.setFieldsValue({
title: currentDetail?.orderTitle,
content: currentDetail?.taskDescription,
priority: currentDetail?.priorityLevel,
type: currentDetail?.orderType,
remark: currentDetail?.remark
orderTitle: currentDetail?.orderTitle,
orderType: currentDetail?.orderType,
priorityLevel: currentDetail?.priorityLevel,
taskDescription: currentDetail?.taskDescription,
});
setEditModalVisible(true);
};
@@ -198,7 +199,7 @@ const WorkOrderPage = () => {
// 打开派发工单弹窗
// 打开派发工单弹窗
const openDispatchModal = () => {
if (!selectedRowKey) return message.warning('请先选择一条工单');
if (!selectedRowKey) return messageApi.warning('请先选择一条工单');
form.setFieldsValue({
orderId: selectedRowKey, // 自动回填工单ID
assigneeName: currentDetail?.assigneeName || '',
@@ -210,22 +211,54 @@ const WorkOrderPage = () => {
};
// 提交修改工单
// 提交修改工单(完整匹配后端参数)
const submitEdit = async (values) => {
try {
// 适配后端传参:id、title、content、priority、type、remark
await updateWorkOrder({
id: selectedRowKey,
orderTitle: values.title,
taskDescription: values.content,
priorityLevel: values.priority,
orderType: values.type,
remark: values.remark
});
message.success('修改工单成功');
// 拼接你给的所有工单参数(1:1 匹配)
const params = {
id: selectedRowKey, // 主键ID
orderNo: currentDetail?.orderNo, // 工单编号
orderTitle: values.orderTitle, // 工单标题
sourceType: currentDetail?.sourceType, // 来源(保持不变)
orderType: values.orderType, // 类型
priorityLevel: values.priorityLevel, // 优先级
deviceId: currentDetail?.deviceId, // 设备ID
deviceName: currentDetail?.deviceName, // 设备名称
deviceType: currentDetail?.deviceType,
siteId: currentDetail?.siteId,
siteName: currentDetail?.siteName,
orgId: currentDetail?.orgId,
assigneeId: currentDetail?.assigneeId,
assigneeName: currentDetail?.assigneeName,
collaboratorIds: currentDetail?.collaboratorIds,
collaboratorNames: currentDetail?.collaboratorNames,
planStartTime: currentDetail?.planStartTime,
planEndTime: currentDetail?.planEndTime,
deadlineTime: currentDetail?.deadlineTime,
actualStartTime: currentDetail?.actualStartTime,
actualEndTime: currentDetail?.actualEndTime,
orderStatus: currentDetail?.orderStatus,
alarmId: currentDetail?.alarmId,
alarmNo: currentDetail?.alarmNo,
taskDescription: values.taskDescription, // 任务描述
aiSuggestion: currentDetail?.aiSuggestion,
requiredEquipment: currentDetail?.requiredEquipment,
estimatedImpact: currentDetail?.estimatedImpact,
handleResult: currentDetail?.handleResult,
handleRemark: currentDetail?.handleRemark,
};
// 调用你提供的接口
await updateWorkOrder(params);
messageApi.success('修改工单成功');
setEditModalVisible(false);
// 刷新列表和详情
getWorkOrderList();
getWorkOrderDetail(selectedRowKey);
} catch (error) {
message.error('修改工单失败');
messageApi.error('修改工单失败');
console.error(error);
}
};
@@ -247,11 +280,11 @@ const WorkOrderPage = () => {
await dispatchWorkOrder(params);
message.success('工单派发成功');
messageApi.success('工单派发成功');
setDispatchModalVisible(false);
getWorkOrderList(); // 刷新列表
} catch (error) {
message.error('工单派发失败');
messageApi.error('工单派发失败');
console.error(error);
}
};
@@ -333,7 +366,8 @@ const WorkOrderPage = () => {
];
return (
<div style={{ padding: '16px 24px', background: '#f5f7fa', minHeight: '100vh', boxSizing: 'border-box' }}>
<div style={{ padding: '0px 0px', background: '#f5f7fa', minHeight: '100vh', boxSizing: 'border-box' }}>
{contextHolder}
<style>
{`
.compact-table .ant-table-thead > tr > th {
@@ -364,8 +398,8 @@ const WorkOrderPage = () => {
</style>
{/* 顶部标题和页签 */}
<div style={{ display: 'flex', alignItems: 'center', marginBottom: 16 }}>
<Title level={4} style={{ margin: '0 32px 0 0', fontWeight: 800 }}>工单任务管理</Title>
<div style={{ display: 'flex', alignItems: 'center', marginBottom: 8 }}>
<Title level={4} style={{ margin: '0 32px 0 0', }}>工单任务管理</Title>
<Tabs
activeKey={activeTab}
onChange={setActiveTab}
@@ -589,7 +623,7 @@ const WorkOrderPage = () => {
<div style={{ marginBottom: 24 }}>
<div style={{ display: 'flex', alignItems: 'center', marginBottom: 16, flexWrap: 'wrap', gap: 12 }}>
<Title level={4} style={{ margin: 0, fontSize: 18, fontWeight: 800 }}>{currentDetail?.orderTitle || '暂无标题'}</Title>
<span level={4} style={{ margin: 0, fontSize: 18, fontWeight: 800 }}>{currentDetail?.orderTitle || '暂无标题'}</span>
{currentDetail?.priorityLevel && (
<Tag
style={{
@@ -607,19 +641,19 @@ const WorkOrderPage = () => {
</div>
<Row gutter={[16, 16]} style={{ background: '#f8fafc', padding: 16, borderRadius: 12, marginBottom: 20 }}>
<Col span={12}><Text type="secondary" style={{ fontSize: 12 }}>来源:</Text><Text style={{ fontSize: 12, fontWeight: 500 }}>{currentDetail?.sourceType || '--'}</Text></Col>
<Col span={12}><Text type="secondary" style={{ fontSize: 12 }}>工单类型:</Text><Text style={{ fontSize: 12, fontWeight: 500 }}>{orderTypeConfig[currentDetail?.orderType] || '--'}</Text></Col>
<Col span={12}><Text type="secondary" style={{ fontSize: 12 }}>负责人:</Text><Text style={{ fontSize: 12, fontWeight: 500 }}>{currentDetail?.assigneeName || '--'}</Text></Col>
<Col span={12}><Text type="secondary" style={{ fontSize: 12 }}>协同人员:</Text><Text style={{ fontSize: 12, fontWeight: 500 }}>{currentDetail?.collaboratorNames || '无'}</Text></Col>
<Col span={24}><Text type="secondary" style={{ fontSize: 12 }}>计划时间:</Text><Text style={{ fontSize: 12, fontWeight: 500 }}>{currentDetail?.planStartTime ? `${currentDetail.planStartTime} ~ ${currentDetail.planEndTime}` : '--'}</Text></Col>
<Col span={12}><Text type="secondary" style={{ fontSize: 12 }}>关联设备:</Text><Text style={{ fontSize: 12, color: '#165DFF', fontWeight: 600 }}>{currentDetail?.deviceName || '无'}</Text></Col>
<Col span={12}><Text type="secondary" style={{ fontSize: 12 }}>关联区域:</Text><Text style={{ fontSize: 12, fontWeight: 500 }}>{currentDetail?.siteName || '无'}</Text></Col>
<Col span={12}><span style={{ fontSize: 12 }}>来源:</span><span style={{ fontSize: 12, fontWeight: 500 }}>{currentDetail?.sourceType || '--'}</span></Col>
<Col span={12}><span style={{ fontSize: 12 }}>工单类型:</span><span style={{ fontSize: 12, fontWeight: 500 }}>{orderTypeConfig[currentDetail?.orderType] || '--'}</span></Col>
<Col span={12}><span style={{ fontSize: 12 }}>负责人:</span><span style={{ fontSize: 12, fontWeight: 500 }}>{currentDetail?.assigneeName || '--'}</span></Col>
<Col span={12}><span style={{ fontSize: 12 }}>协同人员:</span><span style={{ fontSize: 12, fontWeight: 500 }}>{currentDetail?.collaboratorNames || '无'}</span></Col>
<Col span={24}><span style={{ fontSize: 12 }}>计划时间:</span><span style={{ fontSize: 12, fontWeight: 500 }}>{currentDetail?.planStartTime ? `${currentDetail.planStartTime} ~ ${currentDetail.planEndTime}` : '--'}</span></Col>
<Col span={12}><span style={{ fontSize: 12 }}>关联设备:</span><span style={{ fontSize: 12, color: '#165DFF', fontWeight: 600 }}>{currentDetail?.deviceName || '无'}</span></Col>
<Col span={12}><span style={{ fontSize: 12 }}>关联区域:</span><span style={{ fontSize: 12, fontWeight: 500 }}>{currentDetail?.siteName || '无'}</span></Col>
<Col span={24}>
<Text type="secondary" style={{ fontSize: 12 }}>当前状态:</Text>
<span style={{ fontSize: 12 }}>当前状态:</span>
<Tag color="blue" style={{ borderRadius: 4, fontWeight: 600, border: 'none', background: '#E8F3FF', color: '#165DFF' }}>{orderStatusConfig[currentDetail?.orderStatus]?.label || '--'}</Tag>
</Col>
<Col span={24}>
<Text type="secondary" style={{ fontSize: 12 }}>任务描述:</Text>
<span style={{ fontSize: 12 }}>任务描述:</span>
<div style={{ fontSize: 12, color: '#4E5969', marginTop: 4, lineHeight: 1.6 }}>{currentDetail?.taskDescription || '暂无描述'}</div>
</Col>
</Row>
@@ -750,31 +784,57 @@ const WorkOrderPage = () => {
</Col>
</Row>
{/* 修改工单弹窗 */}
{/* 修改工单弹窗 */}
<Modal title="修改工单" open={editModalVisible} onCancel={() => setEditModalVisible(false)} footer={null} width={520}>
<Form form={form} layout="vertical" onFinish={submitEdit}>
<FormItem name="title" label="工单标题">
<FormItem
name="orderTitle"
label="工单标题"
rules={[{ required: true, message: '请输入工单标题' }]}
>
<Input placeholder="请输入工单标题" />
</FormItem>
<FormItem name="content" label="工单内容">
<Input.TextArea rows={4} placeholder="请输入工单内容" />
<FormItem
name="orderType"
label="工单类型"
rules={[{ required: true, message: '请选择工单类型' }]}
>
<Select placeholder="请选择工单类型">
<Option value={1}>巡检</Option>
<Option value={2}>检修</Option>
<Option value={3}>清洗</Option>
<Option value={4}>维修</Option>
<Option value={5}>运维</Option>
</Select>
</FormItem>
<FormItem name="priority" label="优先级">
<FormItem
name="priorityLevel"
label="优先级"
rules={[{ required: true, message: '请选择优先级' }]}
>
<Select placeholder="请选择优先级">
<Option value={1}>高</Option>
<Option value={2}>中</Option>
<Option value={3}>低</Option>
</Select>
</FormItem>
<FormItem name="type" label="工单类型">
<Input placeholder="请输入工单类型" />
</FormItem>
<FormItem name="remark" label="备注">
<Input.TextArea rows={2} placeholder="请输入备注" />
<FormItem
name="taskDescription"
label="任务描述"
rules={[{ required: true, message: '请输入任务描述' }]}
>
<Input.TextArea rows={4} placeholder="请输入任务描述" />
</FormItem>
<FormItem style={{ textAlign: 'right', marginBottom: 0 }}>
<Button onClick={() => setEditModalVisible(false)}>取消</Button>
<Button type="primary" htmlType="submit" style={{ marginLeft: 8 }}>确认修改</Button>
<Button type="primary" htmlType="submit" style={{ marginLeft: 8 }}>
确认修改
</Button>
</FormItem>
</Form>
</Modal>