/** * Copyright (c) OpenSpug Organization. https://github.com/openspug/spug * Copyright (c) * Released under the AGPL-3.0 License. */ 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 contactStore from '../contact/store'; @observer class ComTable extends React.Component { constructor(props) { super(props); this.state = { contactMap: {} } } componentDidMount() { store.fetchRecords(); if (contactStore.records.length === 0) { contactStore.fetchRecords().then(this._handleContacts) } else { this._handleContacts() } } _handleContacts = () => { const tmp = {}; for (let item of contactStore.records) { tmp[item.id] = item } this.setState({contactMap: tmp}) }; handleDelete = (text) => { Modal.confirm({ title: '删除确认', content: `确定要删除【${text['name']}】?`, onOk: () => { return http.delete('/api/alarm/group/', {params: {id: text.id}}) .then(() => { message.success('删除成功'); store.fetchRecords() }) } }) }; render() { return ( } onClick={() => store.showForm()}>新建 ]} pagination={{ showSizeChanger: true, showLessItems: true, showTotal: total => `共 ${total} 条`, pageSizeOptions: ['10', '20', '50', '100'] }}> `${value.length}个`}/> {hasPermission('alarm.group.edit|alarm.group.del') && ( ( store.showForm(info)}>编辑 this.handleDelete(info)}>删除 )}/> )} ) } } export default ComTable