From 55ba3633c851a088d765c9086bcc0e8e23560319 Mon Sep 17 00:00:00 2001 From: vapao Date: Fri, 27 Nov 2020 09:55:18 +0800 Subject: [PATCH] style migrate v3 --- spug_web/src/pages/config/environment/Form.js | 79 ++++++++----------- .../src/pages/config/environment/Table.js | 64 ++++++++------- .../src/pages/config/environment/index.js | 21 ++--- 3 files changed, 77 insertions(+), 87 deletions(-) diff --git a/spug_web/src/pages/config/environment/Form.js b/spug_web/src/pages/config/environment/Form.js index 33ef0f6..841c5f9 100644 --- a/spug_web/src/pages/config/environment/Form.js +++ b/spug_web/src/pages/config/environment/Form.js @@ -3,65 +3,48 @@ * Copyright (c) * Released under the AGPL-3.0 License. */ -import React from 'react'; +import React, { useState } from 'react'; import { observer } from 'mobx-react'; import { Modal, Form, Input, message } from 'antd'; import http from 'libs/http'; import store from './store'; -@observer -class ComForm extends React.Component { - constructor(props) { - super(props); - this.state = { - loading: false, - } - } +export default observer(function () { + const [form] = Form.useForm(); + const [loading, setLoading] = useState(false); - handleSubmit = () => { - this.setState({loading: true}); - const formData = this.props.form.getFieldsValue(); + function handleSubmit() { + setLoading(true); + const formData = form.getFieldsValue(); formData['id'] = store.record.id; http.post('/api/config/environment/', formData) .then(res => { message.success('操作成功'); store.formVisible = false; store.fetchRecords() - }, () => this.setState({loading: false})) - }; - - render() { - const info = store.record; - const {getFieldDecorator} = this.props.form; - return ( - store.formVisible = false} - confirmLoading={this.state.loading} - onOk={this.handleSubmit}> -
- - {getFieldDecorator('name', {initialValue: info['name']})( - - )} - - - {getFieldDecorator('key', {initialValue: info['key']})( - - )} - - - {getFieldDecorator('desc', {initialValue: info['desc']})( - - )} - -
-
- ) + }, () => setLoading(false)) } -} -export default Form.create()(ComForm) + return ( + store.formVisible = false} + confirmLoading={loading} + onOk={handleSubmit}> +
+ + + + + + + + + +
+
+ ) +}) \ No newline at end of file diff --git a/spug_web/src/pages/config/environment/Table.js b/spug_web/src/pages/config/environment/Table.js index c75f043..7962ee2 100644 --- a/spug_web/src/pages/config/environment/Table.js +++ b/spug_web/src/pages/config/environment/Table.js @@ -6,10 +6,10 @@ import React from 'react'; import { observer } from 'mobx-react'; import { Table, Modal, message } from 'antd'; -import ComForm from './Form'; +import { PlusOutlined } from '@ant-design/icons'; +import { Action, TableCard, AuthButton } from 'components'; import { http, hasPermission } from 'libs'; import store from './store'; -import { Action } from "components"; @observer class ComTable extends React.Component { @@ -37,33 +37,39 @@ class ComTable extends React.Component { data = data.filter(item => item['name'].toLowerCase().includes(store.f_name.toLowerCase())) } return ( - - `共 ${total} 条`, - pageSizeOptions: ['10', '20', '50', '100'] - }}> - index + 1}/> - - - - {hasPermission('config.env.edit|config.env.del') && ( - ( - - store.showForm(info)}>编辑 - this.handleDelete(info)}>删除 - - )}/> - )} -
- {store.formVisible && } -
+ } + onClick={() => store.showForm()}>新建 + ]} + pagination={{ + showSizeChanger: true, + showLessItems: true, + hideOnSinglePage: true, + showTotal: total => `共 ${total} 条`, + pageSizeOptions: ['10', '20', '50', '100'] + }}> + index + 1}/> + + + + {hasPermission('config.env.edit|config.env.del') && ( + ( + + store.showForm(info)}>编辑 + this.handleDelete(info)}>删除 + + )}/> + )} + ) } } diff --git a/spug_web/src/pages/config/environment/index.js b/spug_web/src/pages/config/environment/index.js index a8b2aa6..9fba7c7 100644 --- a/spug_web/src/pages/config/environment/index.js +++ b/spug_web/src/pages/config/environment/index.js @@ -5,26 +5,27 @@ */ import React from 'react'; import { observer } from 'mobx-react'; -import { Input, Button } from 'antd'; -import { SearchForm, AuthDiv, AuthCard } from 'components'; +import { Input } from 'antd'; +import { SearchForm, AuthDiv, Breadcrumb } from 'components'; import ComTable from './Table'; +import ComForm from './Form'; import store from './store'; export default observer(function () { return ( - + + + 首页 + 配置中心 + 环境管理 + store.f_name = e.target.value} placeholder="请输入"/> - - - - - - - + {store.formVisible && } + ) })