react 实现页面某个范围的展开、收起功能

导读:本篇文章讲解 react 实现页面某个范围的展开、收起功能,希望对大家有帮助,欢迎收藏,转发!站点地址:www.bmabk.com

效果图 

react 实现页面某个范围的展开、收起功能

react 实现页面某个范围的展开、收起功能

import React, { PureComponent, Fragment } from 'react';
import { Row, Col, Button, Card, Input, Radio, Select} from 'antd';



const Search = Input.Search;
const RadioGroup = Radio.Group;
const RadioButton = Radio.Button;

export default class Lt extends PureComponent {

  state= {

    expandForm: false,

  };


  // 表格上方筛选条件 ---- 展开、收起 表格筛选功能项
  toggleForm = () => {
    const { expandForm } = this.state;
    this.setState({
      expandForm: !expandForm,
    });
  };

  // 表格上方筛选条件 ---- 没有预警级别选项
  renderSimpleForm() {

    return (
      <div>

        <Row style={{ height: 62, width: '100%',backgroundColor: '#ECF1F1',marginTop: 13 }}>
          <Col span={24} style={{ display: 'flex' }}>
            <div style={{ margin: '18px 0 0 16px' }}>
              <span>选择范围:</span>
              <Radio.Group style={{ marginLeft: 2 }} className="lzpStyle" onChange={this.change} defaultValue="GL" buttonStyle="solid">
                <Radio.Button value="lt">财政</Radio.Button>
                <Radio.Button value="lzp">财务</Radio.Button>
                <Radio.Button value="mk">业务</Radio.Button>
                <Radio.Button value="ls">产品</Radio.Button>
              </Radio.Group>
            </div>

            <div style={{ margin: '15px 0 0 40px' }}>
              <span>分类范围:</span>
              <Select defaultValue="lucy" style={{ marginLeft:8, width: 120 }} onChange={this.handleChange}>
                <Option value="nn">检查流程</Option>
                <Option value="llw">检查工艺</Option>
              </Select>
            </div>

            <div style={{ marginTop: 20 }}>
              <a style={{ marginLeft: 36 }} onClick={this.toggleForm}>
                展开 <Icon type="down" />
              </a>
            </div>
          </Col>
        </Row>
      </div>
    );
  }

  // 表格上方筛选条件 ---- 展开全部(包括业务类型、预警级别)
  renderAllForm() {

    return (
      <div style={{ height: 100, width: '100%',backgroundColor: '#ECF1F1',marginTop: 13 }}>
        <Row>
          <Col span={24} style={{ display: 'flex' }}>
            <div style={{ margin: '18px 0 0 16px' }}>
              <span>选择范围:</span>
              <Radio.Group style={{ marginLeft: 2 }} className="lzpStyle" onChange={this.change} defaultValue="GL" buttonStyle="solid">
                <Radio.Button value="lt">财政</Radio.Button>
                <Radio.Button value="lzp">财务</Radio.Button>
                <Radio.Button value="mk">业务</Radio.Button>
                <Radio.Button value="ls">产品</Radio.Button>
              </Radio.Group>
            </div>

            <div style={{ margin: '15px 0 0 40px' }}>
              <span>分类范围:</span>
              <Select defaultValue="lucy" style={{ marginLeft:8, width: 120 }} onChange={this.handleChange}>
                <Option value="nn">检查流程</Option>
                <Option value="llw">检查工艺</Option>
              </Select>
            </div>

            <div style={{ marginTop: 20 }}>
              <a style={{ marginLeft: 36 }} onClick={this.toggleForm}>
                收起 <Icon type="up" />
              </a>
            </div>
          </Col>
        </Row>

        <Row style={{ margin: '10px 0 0 16px' }}>
          <Col span={12} style={{lineHeight:'30px'}}>
            <span>级别:</span>
            <RadioGroup  onChange={this.changeLevel} defaultValue={this.state.ruleLevel} value={this.state.ruleLevel} style={{marginLeft:"10px"}}>
              <Radio  value={2} style={{marginRight: 3}}>红色</Radio>
              <Radio  value={1} style={{marginRight: 3}}>黄色</Radio>
              <Radio  value={0} style={{marginRight: 3}}>橙色</Radio>
            </RadioGroup>
          </Col>
        </Row>
      </div>
    );
  }

  // 表格上方筛选条件 ---- 展开、收起 功能按钮
  renderForm() {
    const { expandForm } = this.state;
    return expandForm ? this.renderAllForm() : this.renderSimpleForm();
  }

  render(){


    return(
      <div style={{padding:'0 16px 16px', height:648, backgroundColor:'#fff'}}>

        <Row>

          <Col span={24}>

            <div>{this.renderForm()}</div>

          </Col>
        </Row>
      </div>
    )
  }
}

 

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

文章由极客之音整理,本文链接:https://www.bmabk.com/index.php/post/66408.html

(0)
小半的头像小半

相关推荐

极客之音——专业性很强的中文编程技术网站,欢迎收藏到浏览器,订阅我们!