diff --git a/spug_web/src/pages/system/role/Form.js b/spug_web/src/pages/system/role/Form.js index d369296..77cdff3 100644 --- a/spug_web/src/pages/system/role/Form.js +++ b/spug_web/src/pages/system/role/Form.js @@ -3,60 +3,45 @@ * 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/account/role/', 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('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/system/role/Table.js b/spug_web/src/pages/system/role/Table.js index a2b4d6e..ec2d213 100644 --- a/spug_web/src/pages/system/role/Table.js +++ b/spug_web/src/pages/system/role/Table.js @@ -5,10 +5,11 @@ */ import React from 'react'; import { observer } from 'mobx-react'; -import { Table, Divider, Modal, message } from 'antd'; +import { Divider, Modal, message } from 'antd'; +import { PlusOutlined } from '@ant-design/icons'; import http from 'libs/http'; import store from './store'; -import { LinkButton } from "components"; +import { LinkButton, TableCard, AuthButton } from "components"; @observer class ComTable extends React.Component { @@ -59,15 +60,16 @@ class ComTable extends React.Component { }; render() { - let data = store.records; - if (store.f_name) { - data = data.filter(item => item['name'].toLowerCase().includes(store.f_name.toLowerCase())) - } return ( - } onClick={() => store.showForm()}>新建 + ]} pagination={{ showSizeChanger: true, showLessItems: true, diff --git a/spug_web/src/pages/system/role/index.js b/spug_web/src/pages/system/role/index.js index fcd90ff..e1f2141 100644 --- a/spug_web/src/pages/system/role/index.js +++ b/spug_web/src/pages/system/role/index.js @@ -5,8 +5,8 @@ */ import React from 'react'; import { observer } from 'mobx-react'; -import { Input, Button } from 'antd'; -import { SearchForm, AuthCard } from 'components'; +import { Input } from 'antd'; +import { SearchForm, AuthDiv, Breadcrumb } from 'components'; import ComTable from './Table'; import ComForm from './Form'; import PagePerm from './PagePerm'; @@ -16,23 +16,22 @@ import store from './store'; export default observer(function () { return ( - + + + 首页 + 系统管理 + 角色管理 + store.f_name = e.target.value} placeholder="请输入"/> - - - -
- -
{store.formVisible && } {store.pagePermVisible && } {store.deployPermVisible && } {store.hostPermVisible && } -
- ) + + ); }) diff --git a/spug_web/src/pages/system/role/store.js b/spug_web/src/pages/system/role/store.js index 119a5e0..5a3ffc2 100644 --- a/spug_web/src/pages/system/role/store.js +++ b/spug_web/src/pages/system/role/store.js @@ -3,7 +3,7 @@ * Copyright (c) * Released under the AGPL-3.0 License. */ -import { observable } from "mobx"; +import { observable, computed } from 'mobx'; import http from 'libs/http'; import codes from './codes'; import lds from 'lodash'; @@ -24,6 +24,12 @@ class Store { @observable f_name; + @computed get dataSource() { + let records = this.records; + if (this.f_name) records = records.filter(x => x.name.toLowerCase().includes(this.f_name.toLowerCase())); + return records + } + constructor() { this.initPermissions() }