/*
* @Author: your name
* @Date: 2021-04-27 11:19:40
* @LastEditTime: 2021-05-16 21:50:53
* @LastEditors: Please set LastEditors
* @Description: In User Settings Edit
* @FilePath: /react-antd-admin-template/src/views/groupManage/groupIdentity/table.js
*/
import React from 'react';
import { Table,Popconfirm, Form} from 'antd';
class EditableTable extends React.Component {
constructor(props) {
super(props);
this.state = { data:[], editingKey: '',loading:false};
this.columns = [
...props.columns,
{
title: '操作',
dataIndex: 'operation',
render: (text, record) => {
const { editingKey} = this.state;
// console.log({editingKey,record});
return (
this.delItem(record)}>
删除
);
},
},
];
}
componentDidMount(){
this.setState({
data:this.props.data
});
}
componentDidUpdate(prevProps, prevState){
// console.log({prevProps, prevState});
if(prevProps.ifUpdateList){
console.log('update');
this.setState({
data:this.props.data
});
}
}
isEditing = record => {
// console.log(record.id,this.state.editingKey);
return record.id === this.state.editingKey;
}
editItem=(record)=>{
this.props.callbackFromChild(record);
}
delItem=record=>{
this.props.deleteCallback(record);
}
changePage(current){
this.setState({ loading: true });
this.props.paginationCallback({'currPage':current})
}
render() {
const columns = this.columns.map(col => {
if (!col.editable) {
return col;
}
return {
...col,
onCell: record => ({
record,
}),
};
});
const {
currPage,
totalCount,
} = this.props.pages;
const paginationProps = {
showSizeChanger: false,
showQuickJumper: false,
showTotal: () => `共${totalCount}条`,
pageSize: 10,
current: currPage,
total: totalCount,
onChange: (current) => this.changePage(current),
}
return (
);
}
}
const EditableFormTable = Form.create()(EditableTable);
export default EditableFormTable;