mirror of https://github.com/openspug/spug
U 优化任务计划添加执行对象
parent
76458c6ade
commit
27aa9927df
|
@ -3,51 +3,61 @@
|
||||||
* Copyright (c) <spug.dev@gmail.com>
|
* Copyright (c) <spug.dev@gmail.com>
|
||||||
* Released under the AGPL-3.0 License.
|
* Released under the AGPL-3.0 License.
|
||||||
*/
|
*/
|
||||||
import React from 'react';
|
import React, { useState } from 'react';
|
||||||
import { observer } from 'mobx-react';
|
import { observer } from 'mobx-react';
|
||||||
import { MinusCircleOutlined, PlusOutlined } from '@ant-design/icons';
|
import { MinusCircleOutlined, PlusOutlined } from '@ant-design/icons';
|
||||||
import { Form, Select, Button } from 'antd';
|
import { Form, Select, Button } from 'antd';
|
||||||
|
import HostSelector from 'pages/host/Selector';
|
||||||
import store from './store';
|
import store from './store';
|
||||||
import hostStore from 'pages/host/store';
|
import hostStore from 'pages/host/store';
|
||||||
import styles from './index.module.css';
|
import styles from './index.module.css';
|
||||||
|
|
||||||
export default observer(function () {
|
export default observer(function () {
|
||||||
|
const [visible, setVisible] = useState(false)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Form labelCol={{span: 6}} wrapperCol={{span: 14}}>
|
<React.Fragment>
|
||||||
<Form.Item required label="执行对象">
|
<Form labelCol={{span: 6}} wrapperCol={{span: 14}} style={{minHeight: 350}}>
|
||||||
{store.targets.map((id, index) => (
|
<Form.Item required label="执行对象">
|
||||||
<React.Fragment key={index}>
|
{store.targets.map((id, index) => (
|
||||||
<Select
|
<React.Fragment key={index}>
|
||||||
value={id}
|
<Select
|
||||||
showSearch
|
value={id}
|
||||||
placeholder="请选择"
|
showSearch
|
||||||
optionFilterProp="children"
|
placeholder="请选择"
|
||||||
style={{width: '80%', marginRight: 10, marginBottom: 12}}
|
optionFilterProp="children"
|
||||||
filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0}
|
style={{width: '80%', marginRight: 10, marginBottom: 12}}
|
||||||
onChange={v => store.editTarget(index, v)}>
|
filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0}
|
||||||
<Select.Option value="local" disabled={store.targets.includes('local')}>本机</Select.Option>
|
onChange={v => store.editTarget(index, v)}>
|
||||||
{hostStore.records.map(item => (
|
<Select.Option value="local" disabled={store.targets.includes('local')}>本机</Select.Option>
|
||||||
<Select.Option key={item.id} value={item.id} disabled={store.targets.includes(item.id)}>
|
{hostStore.records.map(item => (
|
||||||
{`${item.name}(${item['hostname']}:${item['port']})`}
|
<Select.Option key={item.id} value={item.id} disabled={store.targets.includes(item.id)}>
|
||||||
</Select.Option>
|
{`${item.name}(${item['hostname']}:${item['port']})`}
|
||||||
))}
|
</Select.Option>
|
||||||
</Select>
|
))}
|
||||||
{store.targets.length > 1 && (
|
</Select>
|
||||||
<MinusCircleOutlined className={styles.delIcon} onClick={() => store.delTarget(index)}/>
|
{store.targets.length > 1 && (
|
||||||
)}
|
<MinusCircleOutlined className={styles.delIcon} onClick={() => store.delTarget(index)}/>
|
||||||
</React.Fragment>
|
)}
|
||||||
))}
|
</React.Fragment>
|
||||||
</Form.Item>
|
))}
|
||||||
<Form.Item wrapperCol={{span: 14, offset: 6}}>
|
</Form.Item>
|
||||||
<Button type="dashed" style={{width: '80%'}} onClick={store.addTarget}>
|
<Form.Item wrapperCol={{span: 14, offset: 6}}>
|
||||||
<PlusOutlined/>添加执行对象
|
<Button type="dashed" style={{width: '80%'}} onClick={() => setVisible(true)}>
|
||||||
</Button>
|
<PlusOutlined/>添加执行对象
|
||||||
</Form.Item>
|
</Button>
|
||||||
|
</Form.Item>
|
||||||
|
<HostSelector
|
||||||
|
visible={visible}
|
||||||
|
selectedRowKeys={[...store.targets]}
|
||||||
|
onCancel={() => setVisible(false)}
|
||||||
|
onOk={(_, ids) => store.targets = ids}/>
|
||||||
|
</Form>
|
||||||
<Form.Item wrapperCol={{span: 14, offset: 6}}>
|
<Form.Item wrapperCol={{span: 14, offset: 6}}>
|
||||||
<Button disabled={store.targets.filter(x => x).length === 0} type="primary"
|
<Button disabled={store.targets.filter(x => x).length === 0} type="primary"
|
||||||
onClick={() => store.page += 1}>下一步</Button>
|
onClick={() => store.page += 1}>下一步</Button>
|
||||||
<Button style={{marginLeft: 20}} onClick={() => store.page -= 1}>上一步</Button>
|
<Button style={{marginLeft: 20}} onClick={() => store.page -= 1}>上一步</Button>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
</Form>
|
</React.Fragment>
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
|
@ -6,7 +6,8 @@
|
||||||
.delIcon {
|
.delIcon {
|
||||||
font-size: 24px;
|
font-size: 24px;
|
||||||
position: relative;
|
position: relative;
|
||||||
top: 4px
|
top: 4px;
|
||||||
|
color: #999999;
|
||||||
}
|
}
|
||||||
|
|
||||||
.delIcon:hover {
|
.delIcon:hover {
|
||||||
|
|
|
@ -71,10 +71,6 @@ class Store {
|
||||||
this.record = info
|
this.record = info
|
||||||
};
|
};
|
||||||
|
|
||||||
addTarget = () => {
|
|
||||||
this.targets.push(undefined)
|
|
||||||
};
|
|
||||||
|
|
||||||
editTarget = (index, v) => {
|
editTarget = (index, v) => {
|
||||||
this.targets[index] = v
|
this.targets[index] = v
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue