记录一下最近根据自己写代码的习惯进行了一个改进后的写法调整,主要是为了增强可阅读性与美观性的,实现了增删改查等基础功能,用的react+typescript开发。
import {
inject,observer } from 'mobx-react';
import * as React from 'react';
import {
Table, Input, Button,Modal, Form, Select,message } from 'antd';
import {
FormInstance } from 'antd/lib/form';
import {
ExclamationCircleOutlined } from "@ant-design/icons";
import {
columns } from './constans';
import {
API } from "@/http";
import './style.less';
const {
Search } = Input;
const {
Option } = Select;
const {
confirm } = Modal;
const formRef = React.createRef<FormInstance>();
const layout = {
labelCol: {
span: 6 },
wrapperCol: {
span: 18 },
};
interface IProps {
children: React.ReactNode;
home: any;
global: any;
route: any;
}
interface IState {
visible: boolean;
dataSource: any[];
typeList: any[];
total:number;
title:string;
isEdit:boolean;
initReqParams:{
page: number;
pageSize: number;
};
editId:number;
search:string;
}
class DataManager extends React.Component<IProps, IState> {
constructor(IProps: any) {
super(IProps);
}
state: IState = {
visible: false,
dataSource: [],
typeList:[],
total: 0,
title: '',
isEdit: false,
editId:undefined,
initReqParams: {
page: 1,
pageSize: 10,
},
search:'',
};
componentDidMount = ()=>{
this.getDataSourceList();
this.getDataType();
}
// 获取数据源类型
getDataType