SearchProcess.js 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. import React, {Component} from 'react';
  2. import {
  3. View,
  4. FlatList,
  5. Text, StyleSheet, StatusBar,
  6. } from 'react-native';
  7. import {connect} from 'react-redux';
  8. import TreeSelect from 'react-native-tree-select';
  9. @connect(customer => ({...customer}))
  10. class SearchProcess extends Component {
  11. // 搜索进度
  12. constructor(props) {
  13. super(props);
  14. this.state = {
  15. callback: this.props.navigation.state.params.callback,
  16. data: [],
  17. StageCount: [],
  18. field: '',
  19. store_id: '',
  20. };
  21. }
  22. componentDidMount() {
  23. this._fetchData();
  24. this._fetchStageCount();
  25. }
  26. _fetchData = () => {
  27. this.props.dispatch({
  28. type: 'customer/fetchEmployeeTree',
  29. callback: (data) => {
  30. this.setState({data: data});
  31. },
  32. });
  33. };
  34. _fetchStageCount = (type, id) => {
  35. this.props.dispatch({
  36. type: 'customer/queryStageCount',
  37. payload: {type, id},
  38. callback: (data) => {
  39. this.setState({StageCount: data});
  40. },
  41. });
  42. };
  43. _onClickLeaf = (item) => {
  44. this._fetchStageCount(item.item.field, item.item.id);
  45. this.setState({field: item.item.field, store_id: item.item.id});
  46. };
  47. _onStagePress = (stage_id, event) => {
  48. const {field, store_id} = this.state;
  49. let param = '';
  50. if (field && store_id) {
  51. param = field + '_' + store_id;
  52. }
  53. this.state.callback(stage_id, event, param);
  54. this.props.navigation.goBack();
  55. };
  56. renderItem = (data, index) => {
  57. return (
  58. <View style={index % 2 === 0 ? styles.tableRowOdd : styles.tableRowEven}>
  59. <Text
  60. onPress={() => this._onStagePress(data.stage_id, 'stage')}
  61. style={[styles.tableCell, {width: '30%'}]}>{data.stage}</Text>
  62. <Text
  63. onPress={() => this._onStagePress(data.stage_id, 'total')}
  64. style={[styles.tableCell, {width: '20%'}]}>{data.total_count}</Text>
  65. <Text
  66. onPress={() => this._onStagePress(data.stage_id, 'today')}
  67. style={[styles.tableCell, {width: '25%'}]}>{data.today_count}</Text>
  68. <Text
  69. onPress={() => this._onStagePress(data.stage_id, 'overdue')}
  70. style={[styles.tableCell, {width: '25%'}]}>{data.overdue_count}</Text>
  71. </View>
  72. );
  73. };
  74. render() {
  75. return (
  76. <View style={{flex: 1, backgroundColor: '#fff'}}>
  77. <StatusBar backgroundColor={'#fff'} barStyle='dark-content'/>
  78. <TreeSelect
  79. data={this.state.data}
  80. // isOpen={true}
  81. // openIds={[3]}
  82. // defaultSelectedId={['B062']}
  83. isShowTreeId={false}
  84. selectType="single"
  85. itemStyle={{
  86. marginVertical: 10,
  87. // backgroudColor: '#8bb0ee',
  88. fontSize: 14,
  89. // color: '#2b90ea',
  90. }}
  91. selectedItemStyle={{
  92. backgroudColor: '#f7edca',
  93. fontSize: 14,
  94. // color: '#171e99'
  95. }}
  96. leafCanBeSelected={true}
  97. // onClickLeaf={this._onClickLeaf}
  98. onClick={this._onClickLeaf}
  99. treeNodeStyle={{
  100. openIcon: <Text style={{fontFamily: 'iconfont'}}>{'\ue617'}</Text>,
  101. closeIcon: <Text style={{fontFamily: 'iconfont'}}>{'\ue601'}</Text>,
  102. }}
  103. />
  104. <View>
  105. <View style={styles.tableHeader}>
  106. <Text style={[styles.tableHeaderItem, {width: '30%'}]}>阶段</Text>
  107. <Text style={[styles.tableHeaderItem, {width: '20%'}]}>总数</Text>
  108. <Text style={[styles.tableHeaderItem, {width: '25%'}]}>今日</Text>
  109. <Text style={[styles.tableHeaderItem, {width: '25%'}]}>逾期</Text>
  110. </View>
  111. <FlatList
  112. data={this.state.StageCount}
  113. renderItem={({item, index}) => this.renderItem(item, index)}
  114. keyExtractor={(item, index) => index.toString()}
  115. />
  116. </View>
  117. </View>
  118. );
  119. }
  120. }
  121. const styles = StyleSheet.create({
  122. icon: {
  123. fontFamily: 'iconfont',
  124. fontSize: 14,
  125. color: '#2b90ea',
  126. padding: 3,
  127. },
  128. tableHeader: {
  129. backgroundColor: '#03C762',
  130. flexDirection: 'row',
  131. },
  132. tableHeaderItem: {
  133. color: '#fff',
  134. paddingVertical: 10,
  135. textAlign: 'center',
  136. // flex: 1
  137. },
  138. tableRowOdd: {
  139. flexDirection: 'row',
  140. },
  141. tableRowEven: {
  142. flexDirection: 'row',
  143. backgroundColor: '#f8f8f8',
  144. },
  145. tableCell: {
  146. color: '#666',
  147. padding: 10,
  148. textAlign: 'center',
  149. // flex: 1
  150. },
  151. });
  152. export default SearchProcess;