DispatchProcess.js 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. import React, {Component} from 'react';
  2. import {
  3. View,
  4. Text,
  5. StatusBar,
  6. DeviceEventEmitter,
  7. StyleSheet,
  8. } from 'react-native';
  9. import {Provider, Toast, Button, List, Picker} from '@ant-design/react-native';
  10. import {connect} from 'react-redux';
  11. import {ComponentsStyles} from '../../components/ComponentsStyles';
  12. @connect(customer => ({...customer}))
  13. class DispatchProcess extends Component {
  14. // 分配
  15. constructor(props) {
  16. super(props);
  17. this.state = {
  18. customer: this.props.navigation.state.params.customer,
  19. order: this.props.navigation.state.params.order,
  20. now_process_text: '',
  21. next_process: '',
  22. PROCESS: [],
  23. USERS: [],
  24. service: '',
  25. };
  26. };
  27. componentDidMount() {
  28. this._fetchData();
  29. }
  30. _fetchData = () => {
  31. this.props.dispatch({
  32. type: 'customer/fetchProcessDict',
  33. payload: {customer_id: this.state.customer},
  34. callback: (data) => {
  35. let PROCESS = [];
  36. data.map((item, index) => {
  37. PROCESS.push({
  38. value: item.value, label: item.label,
  39. });
  40. });
  41. this.setState({PROCESS});
  42. },
  43. });
  44. this.props.dispatch({
  45. type: 'customer/getUser',
  46. callback: (data) => {
  47. let USERS = [];
  48. data.map((item, index) => {
  49. USERS.push({
  50. value: item.value, label: item.lable,
  51. });
  52. });
  53. this.setState({USERS});
  54. },
  55. });
  56. this.props.dispatch({
  57. type: 'customer/getProcess',
  58. payload: {customer_id: this.state.customer},
  59. callback: (data) => {
  60. if (data.error_message) {
  61. Toast.info(data.error_message, 2, () => {
  62. this.props.navigation.goBack();
  63. });
  64. return;
  65. }
  66. this.setState({
  67. now_process_text: data.now_process_text,
  68. next_process: [data.next_process_id],
  69. });
  70. },
  71. });
  72. };
  73. onSave = () => {
  74. if (!this.state.next_process.length) {
  75. Toast.info('请下一进度', 1);
  76. return;
  77. }
  78. if (!this.state.service.length) {
  79. Toast.info('请选择人员', 1);
  80. return;
  81. }
  82. this.props.dispatch({
  83. type: 'customer/dispatchService',
  84. payload: this.state,
  85. callback: () => {
  86. Toast.info('分配成功', 1, () => {
  87. DeviceEventEmitter.emit('refeshProcess');
  88. DeviceEventEmitter.emit('backRefesh');
  89. this.props.navigation.goBack();
  90. });
  91. },
  92. });
  93. };
  94. render() {
  95. const {loading} = this.props.customer;
  96. return (
  97. <Provider>
  98. <StatusBar backgroundColor={'#fff'} barStyle='dark-content'/>
  99. <View style={styles.infoContent}>
  100. <List>
  101. <List.Item
  102. extra={<Text style={ComponentsStyles.font15}>{this.state.now_process_text}</Text>}
  103. arrow="empty">
  104. <Text style={ComponentsStyles.font16}>当前进度</Text>
  105. </List.Item>
  106. <Picker
  107. data={this.state.PROCESS}
  108. cols={1}
  109. value={this.state.next_process}
  110. onChange={(val) => this.setState({next_process: val})}
  111. >
  112. <List.Item arrow="horizontal">
  113. 下一进度
  114. </List.Item>
  115. </Picker>
  116. <Picker
  117. data={this.state.USERS}
  118. cols={1}
  119. value={this.state.service}
  120. onChange={(val) => this.setState({service: val})}
  121. >
  122. <List.Item arrow="horizontal">
  123. 服务人员
  124. </List.Item>
  125. </Picker>
  126. </List>
  127. </View>
  128. <Button
  129. type="primary"
  130. disabled={loading}
  131. onPress={() => this.onSave()}
  132. style={ComponentsStyles.button}
  133. >
  134. <Text style={{color: '#fff'}}>提交</Text></Button>
  135. </Provider>
  136. );
  137. }
  138. }
  139. const styles = StyleSheet.create({
  140. paperBody: {
  141. flexDirection: 'row',
  142. flexWrap: 'wrap',
  143. // borderBottomWidth: 10,
  144. // borderBottomColor: '#eee',
  145. paddingLeft: 5,
  146. },
  147. paperBodyItem: {
  148. alignItems: 'center',
  149. margin: 2,
  150. padding: 5,
  151. },
  152. dateInput: {
  153. borderWidth: 0,
  154. alignItems: 'flex-end',
  155. },
  156. infoContent: {
  157. flex: 1,
  158. marginTop: 5,
  159. backgroundColor: '#fff',
  160. },
  161. infoItem: {
  162. flexDirection: 'row',
  163. paddingVertical: 10,
  164. borderBottomWidth: 1,
  165. borderColor: '#eaeaea',
  166. justifyContent: 'space-between',
  167. },
  168. infoItemLeft: {color: '#000', fontSize: 19},
  169. infoItemRight: {fontSize: 15, paddingTop: 2},
  170. modelItem: {
  171. borderBottomWidth: 1,
  172. borderColor: '#eaeaea',
  173. textAlign: 'center',
  174. paddingVertical: 8,
  175. fontSize: 18,
  176. color: '#000',
  177. },
  178. });
  179. export default DispatchProcess;