TableList.js 2.4 KB
Newer Older
徐立's avatar
徐立 committed
1 2 3 4 5 6 7 8 9 10
/*
 * @Author: your name
 * @Date: 2019-10-23 18:27:52
 * @LastEditTime : 2020-02-11 15:36:01
 * @LastEditors  : Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \one_stop_front\src\components\libs\TableList.js
 */
import React from 'react';
import { Tree, Table, Spin } from 'antd';
徐立's avatar
徐立 committed
11
import FormList from './formList';
chscls@163.com's avatar
chscls@163.com committed
12
import TreeList from './formList/TreeList'
徐立's avatar
徐立 committed
13 14 15 16 17 18 19 20 21 22 23
import { connect } from 'dva';

export default class TableList extends React.Component {

  constructor(props) {
    super(props)
    const value = props.value || {};
    this.state = {
      isAll:value.isAll,
      querys: value.querys,
      sql: value.sql,
24
      btns:value.btns,
徐立's avatar
徐立 committed
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
      columns:value.columns,
    }
  }

  triggerChange = (changedValue) => {
    // Should provide an event to pass value to Form.
    const onChange = this.props.onChange;
    if (onChange) {
      onChange(Object.assign({}, this.state, changedValue));
    }
  }
  componentWillReceiveProps(nextProps) {
    // Should be a controlled component.
    if ('value' in nextProps) {
      const value = nextProps.value;
      this.setState(value);
    }
  }

  render() {
chscls@163.com's avatar
chscls@163.com committed
45
    const {isTree,json} = this.props
chscls@163.com's avatar
chscls@163.com committed
46 47
    return isTree?
    <TreeList 
chscls@163.com's avatar
chscls@163.com committed
48
    json={json}
chscls@163.com's avatar
chscls@163.com committed
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
    onSelectRow={this.props.value.onSelectRow}
    istableCom={true} 
    showHeader={this.props.showHeader} 
    get={this.props.get}
    isHiddenPage={
        this.props.isHiddenPage!=null?
              this.props.isHiddenPage
              :false} 
    loading={this.props.loading} 
    pageSize={this.props.pageSize||10} 
    value={this.state}  
    notShowBack={true} 
    rights={this.props.rights || []} 
    objCode={this.props.objCode} 
    isFormCom={true} 
    sql={this.props.sql}/>:
    
    
    
tb53863844's avatar
tb53863844 committed
68
    <FormList   json={json}
69
                onSelectRow={this.props.value.onSelectRow}
徐立's avatar
徐立 committed
70 71
                istableCom={true} 
                showHeader={this.props.showHeader} 
徐立's avatar
徐立 committed
72
                get={this.props.get}
徐立's avatar
徐立 committed
73 74 75 76 77 78 79 80 81 82 83 84
                isHiddenPage={
                    this.props.isHiddenPage!=null?
                          this.props.isHiddenPage
                          :false} 
                loading={this.props.loading} 
                pageSize={this.props.pageSize||10} 
                value={this.state}  
                notShowBack={true} 
                rights={this.props.rights || []} 
                objCode={this.props.objCode} 
                isFormCom={true} 
                sql={this.props.sql} />
徐立's avatar
徐立 committed
85 86 87

  }
}