优化机器人任务界面,增加根据区域下发任务,增加规则配置界面
This commit is contained in:
161
src/components/taskRadio/TaskTypeRadio.css
Normal file
161
src/components/taskRadio/TaskTypeRadio.css
Normal file
@@ -0,0 +1,161 @@
|
||||
.task-type-radio {
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.task-type-radio__title {
|
||||
margin-bottom: 12px;
|
||||
color: #000;
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
line-height: 22px;
|
||||
}
|
||||
|
||||
.task-type-radio__group {
|
||||
display: flex;
|
||||
width: 100%;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.task-type-radio__option.ant-radio-wrapper {
|
||||
display: flex;
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
margin-inline-end: 0;
|
||||
align-items: stretch;
|
||||
color: inherit;
|
||||
white-space: normal;
|
||||
}
|
||||
|
||||
.task-type-radio__option > .ant-radio {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.task-type-radio__option > span:last-child {
|
||||
display: block;
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.task-type-radio__card {
|
||||
position: relative;
|
||||
display: flex;
|
||||
width: 100%;
|
||||
min-height: 62px;
|
||||
padding: 10px;
|
||||
box-sizing: border-box;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
|
||||
background: #fff;
|
||||
border: 1px solid #dce5f2;
|
||||
border-radius: 6px;
|
||||
|
||||
cursor: pointer;
|
||||
transition:
|
||||
border-color 0.2s ease,
|
||||
background-color 0.2s ease,
|
||||
box-shadow 0.2s ease;
|
||||
}
|
||||
|
||||
.task-type-radio__card:hover {
|
||||
border-color: #91caff;
|
||||
}
|
||||
|
||||
.task-type-radio__card--checked {
|
||||
border: 1px solid #4096ff;
|
||||
background: #f0f7ff;
|
||||
box-shadow: 0 0 0 1px rgb(22 119 255 / 5%);
|
||||
}
|
||||
|
||||
.task-type-radio__icon {
|
||||
display: flex;
|
||||
flex-shrink: 0;
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
color: #1677ff;
|
||||
background: #e6f4ff;
|
||||
border-radius: 5px;
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
.task-type-radio__content {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.task-type-radio__name {
|
||||
margin-bottom: 4px;
|
||||
overflow: hidden;
|
||||
|
||||
color: #262626;
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
line-height: 18px;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.task-type-radio__description {
|
||||
overflow: hidden;
|
||||
|
||||
color: #8c9bb0;
|
||||
font-size: 11px;
|
||||
font-weight: 400;
|
||||
line-height: 15px;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.task-type-radio__status {
|
||||
display: flex;
|
||||
flex-shrink: 0;
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
color: #1677ff;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.task-type-radio__empty {
|
||||
display: block;
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
box-sizing: border-box;
|
||||
border: 1px solid #cbd5e1;
|
||||
border-radius: 50%;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.task-type-radio__option:focus-visible
|
||||
.task-type-radio__card {
|
||||
outline: 2px solid #91caff;
|
||||
outline-offset: 2px;
|
||||
}
|
||||
|
||||
@media (max-width: 480px) {
|
||||
.task-type-radio__group {
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.task-type-radio__card {
|
||||
padding: 8px;
|
||||
gap: 7px;
|
||||
}
|
||||
|
||||
.task-type-radio__icon {
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
font-size: 17px;
|
||||
}
|
||||
|
||||
.task-type-radio__description {
|
||||
white-space: normal;
|
||||
}
|
||||
}
|
||||
100
src/components/taskRadio/taskRadio.tsx
Normal file
100
src/components/taskRadio/taskRadio.tsx
Normal file
@@ -0,0 +1,100 @@
|
||||
import React from 'react';
|
||||
import { Radio } from 'antd';
|
||||
import {
|
||||
LoginOutlined,
|
||||
ClockCircleOutlined,
|
||||
CheckCircleFilled,
|
||||
} from '@ant-design/icons';
|
||||
import './TaskTypeRadio.css'
|
||||
type DispatchMode = 'immediate' | 'scheduled';
|
||||
|
||||
interface TaskTypeRadioProps {
|
||||
value: DispatchMode;
|
||||
onChange: (value: DispatchMode) => void;
|
||||
}
|
||||
|
||||
const TaskTypeRadio: React.FC<TaskTypeRadioProps> = ({
|
||||
value,
|
||||
onChange,
|
||||
}) => {
|
||||
const options: {
|
||||
value: DispatchMode;
|
||||
title: string;
|
||||
description: string;
|
||||
icon: React.ReactNode;
|
||||
}[] = [
|
||||
{
|
||||
value: 'immediate',
|
||||
title: '立即执行任务',
|
||||
description: '下发后机器人立即开始执行',
|
||||
icon: <LoginOutlined />,
|
||||
},
|
||||
{
|
||||
value: 'scheduled',
|
||||
title: '定时任务',
|
||||
description: '设置开始时间和重复周期',
|
||||
icon: <ClockCircleOutlined />,
|
||||
},
|
||||
];
|
||||
|
||||
return (
|
||||
<div className="task-type-radio">
|
||||
<div className="task-type-radio__title">
|
||||
选择任务类型
|
||||
</div>
|
||||
|
||||
<Radio.Group
|
||||
value={value}
|
||||
onChange={(e) => onChange(e.target.value)}
|
||||
className="task-type-radio__group"
|
||||
>
|
||||
{options.map((option) => {
|
||||
const checked = value === option.value;
|
||||
|
||||
return (
|
||||
<Radio
|
||||
key={option.value}
|
||||
value={option.value}
|
||||
className="task-type-radio__option"
|
||||
>
|
||||
<div
|
||||
className={[
|
||||
'task-type-radio__card',
|
||||
checked
|
||||
? 'task-type-radio__card--checked'
|
||||
: '',
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join(' ')}
|
||||
>
|
||||
<div className="task-type-radio__icon">
|
||||
{option.icon}
|
||||
</div>
|
||||
|
||||
<div className="task-type-radio__content">
|
||||
<div className="task-type-radio__name">
|
||||
{option.title}
|
||||
</div>
|
||||
|
||||
<div className="task-type-radio__description">
|
||||
{option.description}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="task-type-radio__status">
|
||||
{checked ? (
|
||||
<CheckCircleFilled />
|
||||
) : (
|
||||
<span className="task-type-radio__empty" />
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</Radio>
|
||||
);
|
||||
})}
|
||||
</Radio.Group>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default TaskTypeRadio;
|
||||
Reference in New Issue
Block a user