A web update

pull/22/head
雷二猛 2019-12-14 14:33:32 +08:00
parent 54571048d6
commit c05139f16d
3 changed files with 9 additions and 7 deletions

View File

@ -24,6 +24,7 @@ class AddSelect extends React.Component {
store.record = { store.record = {
is_audit: false, is_audit: false,
host_ids: [undefined], host_ids: [undefined],
actions: [{}]
} }
}; };

View File

@ -19,7 +19,8 @@ class Ext2Setup3 extends React.Component {
handleSubmit = () => { handleSubmit = () => {
this.setState({loading: true}); this.setState({loading: true});
http.post('/api/app/', {extend: '2', actions: store.actions}) store.record['extend'] = '2';
http.post('/api/app/', store.record)
.then(res => { .then(res => {
message.success('保存成功'); message.success('保存成功');
store.ext2Visible = false; store.ext2Visible = false;
@ -28,9 +29,10 @@ class Ext2Setup3 extends React.Component {
}; };
render() { render() {
const actions = store.record['actions'];
return ( return (
<Form labelCol={{span: 6}} wrapperCol={{span: 14}} className={styles.ext2Form}> <Form labelCol={{span: 6}} wrapperCol={{span: 14}} className={styles.ext2Form}>
{store.actions.map((item, index) => ( {actions.map((item, index) => (
<div key={index} style={{marginBottom: 30, position: 'relative'}}> <div key={index} style={{marginBottom: 30, position: 'relative'}}>
<Form.Item required label={`动作${index + 1}`}> <Form.Item required label={`动作${index + 1}`}>
<Input value={item['title']} onChange={e => item['title'] = e.target.value} placeholder="请输入"/> <Input value={item['title']} onChange={e => item['title'] = e.target.value} placeholder="请输入"/>
@ -45,21 +47,21 @@ class Ext2Setup3 extends React.Component {
onChange={v => item['data'] = v} onChange={v => item['data'] = v}
placeholder="请输入要执行的动作"/> placeholder="请输入要执行的动作"/>
</Form.Item> </Form.Item>
{store.actions.length > 1 && ( {actions.length > 1 && (
<div className={styles.delAction} onClick={() => store.actions.splice(index, 1)}><Icon <div className={styles.delAction} onClick={() => actions.splice(index, 1)}><Icon
type="minus-circle"/>移除</div> type="minus-circle"/>移除</div>
)} )}
</div> </div>
))} ))}
<Form.Item wrapperCol={{span: 14, offset: 6}}> <Form.Item wrapperCol={{span: 14, offset: 6}}>
<Button type="dashed" block onClick={() => store.actions.push({})}> <Button type="dashed" block onClick={() => actions.push({})}>
<Icon type="plus"/>添加执行动作 <Icon type="plus"/>添加执行动作
</Button> </Button>
</Form.Item> </Form.Item>
<Form.Item wrapperCol={{span: 14, offset: 6}}> <Form.Item wrapperCol={{span: 14, offset: 6}}>
<Button <Button
type="primary" type="primary"
disabled={store.actions.filter(x => x.title && x.data).length === 0} disabled={actions.filter(x => x.title && x.data).length === 0}
loading={this.state.loading} loading={this.state.loading}
onClick={this.handleSubmit}>提交</Button> onClick={this.handleSubmit}>提交</Button>
<Button style={{marginLeft: 20}} onClick={() => store.page -= 1}>上一步</Button> <Button style={{marginLeft: 20}} onClick={() => store.page -= 1}>上一步</Button>

View File

@ -4,7 +4,6 @@ import http from 'libs/http';
class Store { class Store {
@observable records = []; @observable records = [];
@observable record = {}; @observable record = {};
@observable actions = [{}];
@observable page = 0; @observable page = 0;
@observable isFetching = false; @observable isFetching = false;
@observable addVisible = false; @observable addVisible = false;