diff --git a/spug_web/src/pages/config/app/Form.js b/spug_web/src/pages/config/app/Form.js index d62337a..e16a8fd 100644 --- a/spug_web/src/pages/config/app/Form.js +++ b/spug_web/src/pages/config/app/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/app/', 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/app/Rel.js b/spug_web/src/pages/config/app/Rel.js index ed28c02..1507efe 100644 --- a/spug_web/src/pages/config/app/Rel.js +++ b/spug_web/src/pages/config/app/Rel.js @@ -4,8 +4,8 @@ * Released under the AGPL-3.0 License. */ import React from 'react'; -import {observer} from 'mobx-react'; -import {Modal, Form, Transfer, message, Tabs, Alert} from 'antd'; +import { observer } from 'mobx-react'; +import { Modal, Form, Transfer, message, Tabs, Alert } from 'antd'; import { http, hasPermission } from 'libs'; import serviceStore from '../service/store'; import store from './store'; diff --git a/spug_web/src/pages/config/app/Table.js b/spug_web/src/pages/config/app/Table.js index 8dc6403..4679e7b 100644 --- a/spug_web/src/pages/config/app/Table.js +++ b/spug_web/src/pages/config/app/Table.js @@ -6,9 +6,10 @@ import React from 'react'; import { observer } from 'mobx-react'; import { Table, Modal, message } from 'antd'; +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 { @@ -36,10 +37,19 @@ class ComTable extends React.Component { data = data.filter(item => item['name'].toLowerCase().includes(store.f_name.toLowerCase())) } return ( - } + onClick={() => store.showForm()}>新建 + ]} pagination={{ showSizeChanger: true, showLessItems: true, @@ -52,7 +62,7 @@ class ComTable extends React.Component { {hasPermission('config.app.edit|config.app.del|config.app.view_config') && ( - ( + ( store.showForm(info)}>编辑 this.handleDelete(info)}>删除 @@ -61,7 +71,7 @@ class ComTable extends React.Component { )}/> )} -
+ ) } } diff --git a/spug_web/src/pages/config/app/index.js b/spug_web/src/pages/config/app/index.js index 94d3722..f1d0790 100644 --- a/spug_web/src/pages/config/app/index.js +++ b/spug_web/src/pages/config/app/index.js @@ -5,8 +5,8 @@ */ 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 Rel from './Rel'; @@ -14,21 +14,20 @@ import store from './store'; export default observer(function () { return ( - + + + 首页 + 配置中心 + 应用配置 + store.f_name = e.target.value} placeholder="请输入"/> - - - - - - {store.formVisible && } {store.relVisible && } - + ) })