ProcessDetail.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  1. import React, {Component} from 'react';
  2. import {
  3. View,
  4. Text,
  5. StyleSheet,
  6. ScrollView,
  7. TouchableOpacity,
  8. Dimensions, DeviceEventEmitter,
  9. } from 'react-native';
  10. import {Tabs, Provider, Button, List} from '@ant-design/react-native';
  11. import {createAction} from '../../utils';
  12. import {connect} from 'react-redux';
  13. import CallPhone from '../../components/CallPhone';
  14. import ComponentsStyles from '../../components/ComponentsStyles';
  15. import RefreshFlatList from 'react-native-refresh-flatlist';
  16. const tabs = [
  17. {title: '基本信息', id: 1},
  18. {title: '进度明细', id: 2},
  19. ];
  20. const {width} = Dimensions.get('window');
  21. @connect(customer => ({...customer}))
  22. class ProcessDetail extends Component {
  23. // 潜客跟踪
  24. constructor(props) {
  25. super(props);
  26. this.state = {
  27. page: 1,
  28. rows: 10,
  29. order_id: this.props.navigation.state.params.order_id,
  30. source: this.props.navigation.state.params.source,
  31. };
  32. };
  33. componentDidMount() {
  34. this._fetchProcessReoprt();
  35. this._fetchData();
  36. this.refeshProcess = DeviceEventEmitter.addListener('refeshProcess', (param) => {
  37. this._fetchProcessReoprt(1);
  38. });
  39. this.refeshProcessDetail = DeviceEventEmitter.addListener('refeshProcessDetail', (param) => {
  40. this._fetchData();
  41. });
  42. }
  43. componentWillUnmount() {
  44. this.refeshProcess.remove();
  45. this.refeshProcessDetail.remove();
  46. }
  47. _fetchData = () => {
  48. this.props.dispatch({
  49. type: 'customer/fetchProcessDetail',
  50. payload: {id: this.state.order_id},
  51. });
  52. };
  53. _fetchMore = () => {
  54. const {page, totalRecord} = this.props.customer;
  55. if (page * this.state.rows >= totalRecord) {
  56. return;
  57. }
  58. const currentPage = page + 1;
  59. this._fetchProcessReoprt(currentPage);
  60. };
  61. _keyExtractor = (item, index) => {
  62. return index.toString();
  63. };
  64. _fetchProcessReoprt = (page) => {
  65. if (page) {
  66. this.state.page = page;
  67. }
  68. this.props.dispatch(createAction('customer/fetchProcessRecord')(this.state));
  69. };
  70. baseInfo = (ProcessDetailData) => {
  71. return <View style={{marginTop: 5}}>
  72. <List>
  73. <List.Item extra={<Text style={ComponentsStyles.font15}>{ProcessDetailData.name}</Text>} arrow="empty">
  74. <Text style={ComponentsStyles.font15}>单号</Text>
  75. </List.Item>
  76. <List.Item extra={<Text style={ComponentsStyles.font15}>{ProcessDetailData.no}</Text>} arrow="empty">
  77. <Text style={ComponentsStyles.font15}>姓名</Text>
  78. </List.Item>
  79. <View style={styles.telItemView}>
  80. <Text style={ComponentsStyles.font15}>电话</Text>
  81. <View style={styles.telView}>
  82. <Text style={ComponentsStyles.icon}>{'\ue61a'}</Text>
  83. <Text
  84. style={styles.telText}
  85. onPress={() => CallPhone(ProcessDetailData.tel, 1)}>
  86. {ProcessDetailData.tel}
  87. </Text>
  88. </View>
  89. </View>
  90. <List.Item extra={<Text style={ComponentsStyles.IDText}>{ProcessDetailData.address}</Text>}
  91. wrap
  92. multipleLine arrow="empty">
  93. <Text style={ComponentsStyles.font15}>地址</Text>
  94. </List.Item>
  95. <List.Item extra={<Text style={ComponentsStyles.IDText}>{ProcessDetailData.village}</Text>}
  96. wrap
  97. multipleLine arrow="empty">
  98. <Text style={ComponentsStyles.font15}>小区</Text>
  99. </List.Item>
  100. <List.Item extra={<Text style={ComponentsStyles.font15}>{ProcessDetailData.project_text}</Text>}
  101. arrow="empty">
  102. <Text style={ComponentsStyles.font15}>项目</Text>
  103. </List.Item>
  104. <List.Item extra={<Text style={ComponentsStyles.font15}>{ProcessDetailData.status_text}</Text>}
  105. arrow="empty">
  106. <Text style={ComponentsStyles.font15}>订单状态</Text>
  107. </List.Item>
  108. <List.Item extra={<Text style={ComponentsStyles.font15}>{ProcessDetailData.stage_progress_text}</Text>}
  109. arrow="empty">
  110. <Text style={ComponentsStyles.font15}>阶段进度</Text>
  111. </List.Item>
  112. <List.Item extra={<Text style={ComponentsStyles.font15}>{ProcessDetailData.service_user_text}</Text>}
  113. arrow="empty">
  114. <Text style={ComponentsStyles.font15}>当前服务人员</Text>
  115. </List.Item>
  116. <List.Item extra={<Text style={ComponentsStyles.font15}>{ProcessDetailData.create_time_f}</Text>}
  117. arrow="empty">
  118. <Text style={ComponentsStyles.font15}>下单时间</Text>
  119. </List.Item>
  120. </List>
  121. </View>;
  122. };
  123. gotoImage = (id, has_img) => {
  124. if (has_img) {
  125. this.props.navigation.navigate('BrowseImage',
  126. {
  127. id: id,
  128. },
  129. );
  130. }
  131. };
  132. renderItem = (data) => {
  133. const item = data.item;
  134. return <TouchableOpacity
  135. activeOpacity={0.9}
  136. onPress={() => this.gotoImage(item.id, item.has_img)}
  137. style={styles.reportMain}>
  138. <View style={styles.row5}>
  139. <View style={ComponentsStyles.itemView}>
  140. <Text style={ComponentsStyles.icon}>{'\ue619'} <Text
  141. style={ComponentsStyles.font15}>{item.user_text}</Text>
  142. </Text>
  143. </View>
  144. <View style={ComponentsStyles.itemViewEnd}>
  145. <Text style={ComponentsStyles.icon}>{'\ue6cc'}</Text>
  146. <Text style={ComponentsStyles.font15}>{item.operation_time_f}</Text>
  147. </View>
  148. </View>
  149. <View style={styles.row5}>
  150. <View style={ComponentsStyles.itemView}>
  151. <Text style={ComponentsStyles.icon}>{'\ue6ed'} </Text>
  152. <Text style={ComponentsStyles.font15}>{item.operation}</Text>
  153. </View>
  154. {item.has_img &&
  155. <View style={ComponentsStyles.itemViewEnd}>
  156. <Text style={ComponentsStyles.icon}>{'\ue61b'}</Text>
  157. </View>
  158. }
  159. </View>
  160. <View style={styles.row5}>
  161. <Text style={ComponentsStyles.icon}>{'\ue605'} </Text>
  162. <Text style={[ComponentsStyles.font15, {width: '95%'}]}>{item.notes}</Text>
  163. </View>
  164. </TouchableOpacity>;
  165. };
  166. render() {
  167. const {processRecordData, processRecordRState, processDetail} = this.props.customer;
  168. return (
  169. <Provider>
  170. <Tabs
  171. tabs={tabs}
  172. initialPage={0}
  173. tabBarPosition="top"
  174. styles={{
  175. topTabBarSplitLine: {
  176. borderBottomWidth: 0,
  177. },
  178. }}
  179. tabBarUnderlineStyle={{
  180. backgroundColor: '#03C762',
  181. width: 40,
  182. marginLeft: (width / 2 - 38) / 2,
  183. height: 3,
  184. borderRadius: 2,
  185. }}
  186. tabBarActiveTextColor="#000"
  187. >
  188. {/*基本信息*/}
  189. <ScrollView>
  190. {this.baseInfo(processDetail)}
  191. </ScrollView>
  192. {/* 跟踪记录*/}
  193. <View>
  194. <RefreshFlatList
  195. data={processRecordData}
  196. renderItem={(item) => this.renderItem(item)}
  197. keyExtractor={this._keyExtractor}
  198. themeColor="#5eafe4"
  199. refreshState={processRecordRState}
  200. footerRefreshingText="正在加载"
  201. footerFailureText="加载失败"
  202. onHeaderRefresh={() => this._fetchProcessReoprt(1)}
  203. onFooterRefresh={() => this._fetchMore()}
  204. ListHeaderComponent={() => <View style={{height: 0}}/>}
  205. ItemSeparatorComponent={() => <View style={{height: 0}}/>}
  206. />
  207. </View>
  208. </Tabs>
  209. {this.state.source === 1 ?
  210. <Button
  211. type="primary"
  212. onPress={() => this.props.navigation.navigate('UpdateProcess',
  213. {
  214. customer: processDetail.customer,
  215. })}
  216. style={ComponentsStyles.button}
  217. >
  218. <Text
  219. style={{color: '#fff'}}>更新进度</Text>
  220. </Button>
  221. :
  222. <Button
  223. type="primary"
  224. onPress={() => this.props.navigation.navigate('DispatchProcess',
  225. {
  226. customer: processDetail.customer,
  227. order: processDetail.id,
  228. })}
  229. style={ComponentsStyles.button}
  230. >
  231. <Text
  232. style={{color: '#fff'}}>分配</Text>
  233. </Button>
  234. }
  235. </Provider>
  236. );
  237. }
  238. }
  239. const styles = StyleSheet.create({
  240. descView: {
  241. marginHorizontal: 15,
  242. paddingVertical: 2,
  243. borderBottomWidth: 1,
  244. borderBottomColor: '#eee',
  245. },
  246. descText: {
  247. color: '#928f8f',
  248. paddingVertical: 2,
  249. },
  250. telItemView: {
  251. flex: 1,
  252. flexDirection: 'row',
  253. marginLeft: 15,
  254. paddingRight: 18,
  255. paddingVertical: 8,
  256. borderBottomWidth: 0.5,
  257. borderBottomColor: '#eaeaea',
  258. },
  259. telName: {
  260. color: '#333',
  261. fontSize: 18,
  262. },
  263. telView: {
  264. flex: 1,
  265. flexDirection: 'row',
  266. justifyContent: 'flex-end',
  267. alignItems: 'center',
  268. },
  269. telText: {
  270. color: '#2b90ea',
  271. fontSize: 15,
  272. },
  273. listStyle: {
  274. // borderBottomWidth: 10,
  275. borderBottomColor: '#f6f7f8',
  276. },
  277. reportMain: {
  278. marginTop: 5,
  279. backgroundColor: '#fff',
  280. paddingHorizontal: 10,
  281. // borderWidth:1,
  282. },
  283. customerText: {
  284. color: '#333',
  285. fontSize: 16,
  286. },
  287. row5: {
  288. flexDirection: 'row',
  289. paddingVertical: 3,
  290. },
  291. red5: {
  292. fontSize: 15,
  293. color: 'red',
  294. padding: 2,
  295. },
  296. });
  297. export default ProcessDetail;