Audit.js 5.25 KB
import React, { Component } from 'react';
import { connect } from 'dva';
import { routerRedux } from 'dva/router';
import { Tabs, Toast } from 'antd-mobile';
import MemberList from '../../components/MemberList/MemberList';
import { dataFilter } from '../../utils/dataFilter';
import shareHide from "../../utils/shareHide";

import css from './css.less';
class Audit extends Component{
  constructor(props) {
    super(props);
    this.state = {
      clientList: [],
      cientListed: [],
      storeclientList: [],
      storecientListed: [],
      isShowPassedInfo: false,
      infoList: {},
      show: false,
      show1: false
    }
  }

  componentDidMount() { 
    shareHide();
    Toast.loading('loading...', 88);
    this.getClientUnpassList();
  }

  getClientPassedList() {
    Toast.loading('loading...',88);
    const _this = this;
    this.props.dispatch({
      type: 'governortraining/getClientList',
      payload: {
        id: window.localStorage.getItem("id"),
        auditedState: 1
      },
      callback(res) {
        if (res.status) {
          _this.setState({
            cientListed: res.data,
            storecientListed: res.data,
            show: true
          }, () => {
            Toast.hide();
          })
        }
      }
    })
  }

  getClientUnpassList() {
    const _this = this;
    this.props.dispatch({
      type: 'governortraining/getClientList',
      payload: {
        id: window.localStorage.getItem("id"),
        auditedState: 0
      },
      callback(res) {
        if (res.status) {
          _this.setState({
            clientList: res.data,
            storeclientList: res.data,
            show1: true
          }, () => {
              Toast.hide();
          })
        }
      }
    });
  }

  chooseClient(pass, item) {
    localStorage.setItem('auditClientInfo', JSON.stringify({ ...item, isShowPassedInfo: pass }));
    this.props.dispatch(routerRedux.push({
      pathname: '/governortraining/auditinfo'
    }));
  }



  render() {
    return <div className={css.auditWrap}>
      <Tabs
        tabs={[{ title: '未审核', sub: '1' }, { title: '已审核', sub: '2' }]}
        // page={1}
        onChange={(t, i) => {
          if (i === 0 && this.state.clientList.length === 0) { this.getClientUnpassList(); } else if (this.state.cientListed.length === 0){
            this.getClientPassedList();
          }
        }}
      >
        <div>
          {
            this.state.clientList.length === 0 && this.state.show1 && < div >
              <div className={css.splitline}></div>
              <div className={css.noData}>
                <div className={css.img}></div>
                您当前客户均已审核完毕
              </div>
            </div>
          }
          
          { this.state.clientList.length>0 && this.state.show1 &&  <MemberList
            dataList={this.state.storeclientList} 
            renderType={['name']}
            filterData={(keywords) => {
              this.setState({
                storeclientList: dataFilter(this.state.clientList, ['name'], keywords)
              })
             
            }}
            renderItem={item => {
              return <div className={css.clientItem}>
                <span className={css.name}>{item.name}</span><span className={css.time}>{item.createTime.substr(0,16)}</span>
              </div>
            }}
            chooseClient={this.chooseClient.bind(this,false)}
            pTitle='未审核客户' />}
        </div>
        <div>
        {
          this.state.cientListed.length === 0 && this.state.show && < div >
            <div className={css.splitline}></div>
            <div className={css.noData}>
              <div className={css.img}></div>
              您当前没有已审核客户
            </div>
          </div>
        }
          {this.state.cientListed.length>0 && this.state.show && <MemberList
            dataList={this.state.storecientListed}
            renderType={['name']}
            chooseClient={this.chooseClient.bind(this,true)}
            filterData={(keywords) => {
              this.setState({
                storecientListed: dataFilter(this.state.cientListed, ['name'], keywords)
              })
             
            }}
            renderItem={item => {
              let status = '';
              switch (item.currentState) {
                case '2':
                  status = '审核退回';
                  break;
                case '3':
                  status = '审核通过';
                  break;
                case '4':
                  status = '已成单';
                  break;
                case '5':
                  status = '已上传';
                  break;
                case '6':
                  status = '跟进中';
                  break;
                case '7':
                  status = '停止跟进';
                  break;
                default:
              }
              return <div className={css.clientItem}>
                <span className={css.name}>{item.name}</span>
                <span className={css.time}>{item.createTime.substr(0, 16)}</span>
                <span className={css.status}>{status}</span>
              </div>
            }}
            pTitle='已审核客户' />}
        </div>
      </Tabs>
    </div>
  } 
}

export default connect()(Audit);