/** * 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, history } from 'libs'; import store from './store'; @observer class ComTable extends React.Component { componentDidMount() { store.fetchRecords() } handleDelete = (text) => { Modal.confirm({ title: '删除确认', content: `确定要删除【${text['name']}】?`, onOk: () => { return http.delete('/api/app/', {params: {id: text.id}}) .then(() => { message.success('删除成功'); store.fetchRecords() }) } }) }; toConfig = (info) => { store.record = info; history.push(`/config/setting/app/${info.id}`) } 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, hideOnSinglePage: true, showTotal: total => `共 ${total} 条`, pageSizeOptions: ['10', '20', '50', '100'] }}> {hasPermission('config.app.edit|config.app.del|config.app.view_config') && ( ( store.showForm(info)}>编辑 store.showRel(info)}>依赖 this.toConfig(info)}>配置 this.handleDelete(info)}>删除 )}/> )} ) } } export default ComTable