diff --git a/spug_web/src/pages/alarm/contact/Form.js b/spug_web/src/pages/alarm/contact/Form.js index 91b8804..16f4762 100644 --- a/spug_web/src/pages/alarm/contact/Form.js +++ b/spug_web/src/pages/alarm/contact/Form.js @@ -3,86 +3,63 @@ * 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/alarm/contact/', formData) .then(res => { message.success('操作成功'); store.formVisible = false; store.fetchRecords() - }, () => this.setState({loading: false})) - }; + }, () => setLoading(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('phone', {initialValue: info['phone']})( - - )} - - - {getFieldDecorator('email', {initialValue: info['email']})( - - )} - - 如何获取微信 Token ?}> - {getFieldDecorator('wx_token', {initialValue: info['wx_token']})( - - )} - - + return ( + store.formVisible = false} + confirmLoading={loading} + onOk={handleSubmit}> + + + + + + + + + + + 如何获取微信 Token ?}> + + + 钉钉收不到通知?请参考 官方文档 }> - {getFieldDecorator('ding', {initialValue: info['ding']})( - - )} - - - {getFieldDecorator('qy_wx', {initialValue: info['qy_wx']})( - - )} - - - - ) - } -} - -export default Form.create()(ComForm) + +
+ + + + +
+ ) +}) \ No newline at end of file diff --git a/spug_web/src/pages/alarm/contact/Table.js b/spug_web/src/pages/alarm/contact/Table.js index 89a4491..3ee3d6f 100644 --- a/spug_web/src/pages/alarm/contact/Table.js +++ b/spug_web/src/pages/alarm/contact/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 { @@ -32,40 +32,42 @@ 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 ( - - `共 ${total} 条`, - pageSizeOptions: ['10', '20', '50', '100'] - }}> - index + 1}/> - - - - - - {hasPermission('alarm.contact.edit|alarm.contact.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'] + }}> + + + + + + + {hasPermission('alarm.contact.edit|alarm.contact.del') && ( + ( + + store.showForm(info)}>编辑 + this.handleDelete(info)}>删除 + + )}/> + )} + ) } } diff --git a/spug_web/src/pages/alarm/contact/index.js b/spug_web/src/pages/alarm/contact/index.js index d139189..f7894fc 100644 --- a/spug_web/src/pages/alarm/contact/index.js +++ b/spug_web/src/pages/alarm/contact/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 && } + + ); }) diff --git a/spug_web/src/pages/alarm/contact/store.js b/spug_web/src/pages/alarm/contact/store.js index fd443a6..27f46c6 100644 --- a/spug_web/src/pages/alarm/contact/store.js +++ b/spug_web/src/pages/alarm/contact/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'; class Store { @@ -14,6 +14,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 + } + fetchRecords = () => { this.isFetching = true; return http.get('/api/alarm/contact/')