UpdateProcess.js 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. import React, {Component} from 'react';
  2. import {
  3. View,
  4. Text,
  5. Image,
  6. ImageBackground,
  7. TouchableOpacity,
  8. StatusBar,
  9. DeviceEventEmitter,
  10. StyleSheet,
  11. TextInput,
  12. ScrollView,
  13. } from 'react-native';
  14. import {Provider, Toast, Button, List} from '@ant-design/react-native';
  15. import {connect} from 'react-redux';
  16. import {ComponentsStyles} from '../../components/ComponentsStyles';
  17. import MultiCameraButton from '../../components/MultiCameraButton';
  18. @connect(customer => ({...customer}))
  19. class UpdateProcess extends Component {
  20. // 填写跟踪报告
  21. constructor(props) {
  22. super(props);
  23. this.state = {
  24. customer: this.props.navigation.state.params.customer,
  25. notes: '',
  26. now_process_text: '',
  27. next_process_text: '',
  28. next_process_id: '',
  29. file: [],
  30. };
  31. };
  32. componentDidMount() {
  33. this._fetchData();
  34. }
  35. _fetchData = () => {
  36. this.props.dispatch({
  37. type: 'customer/getProcess',
  38. payload: {customer: this.state.customer},
  39. callback: (data) => {
  40. if (data.error_message) {
  41. Toast.info(data.error_message, 2, () => {
  42. this.props.navigation.goBack();
  43. });
  44. return;
  45. }
  46. this.setState({
  47. now_process_text: data.now_process_text,
  48. next_process_text: data.next_process_text,
  49. next_process_id: data.next_process_id,
  50. });
  51. },
  52. });
  53. };
  54. onSave = () => {
  55. if (!this.state.file.length) {
  56. Toast.info('请选择图片', 1);
  57. return;
  58. }
  59. this.props.dispatch({
  60. type: 'customer/addOrder',
  61. payload: this.state,
  62. callback: () => {
  63. // 返回,刷新潜客跟踪列表或潜客完善列表
  64. DeviceEventEmitter.emit('backRefesh');
  65. this.props.navigation.goBack();
  66. },
  67. });
  68. };
  69. _delPhoto = (fileName) => {
  70. let files = [];
  71. const {file} = this.state;
  72. for (let i in file) {
  73. if (file[i].fileName !== fileName) {
  74. files.push(file[i]);
  75. }
  76. }
  77. this.setState({file: files});
  78. };
  79. onImgUpload = (file) => {
  80. this.setState({
  81. file,
  82. });
  83. };
  84. render() {
  85. const {loading} = this.props.customer;
  86. return (
  87. <Provider>
  88. <StatusBar backgroundColor={'#fff'} barStyle='dark-content'/>
  89. <ScrollView style={{backgroundColor: '#fff'}}>
  90. <View style={styles.infoContent}>
  91. <List>
  92. <List.Item
  93. extra={<Text style={ComponentsStyles.font15}>{this.state.now_process_text}</Text>}
  94. arrow="empty">
  95. <Text style={ComponentsStyles.font15}>当前进度</Text>
  96. </List.Item>
  97. <List.Item
  98. extra={<Text style={ComponentsStyles.font15}>{this.state.next_process_text}</Text>}
  99. arrow="empty">
  100. <Text style={ComponentsStyles.font15}>下一进度</Text>
  101. </List.Item>
  102. </List>
  103. <TextInput
  104. style={{
  105. height: 140,
  106. borderColor: '#eee',
  107. textAlignVertical: 'top',
  108. borderBottomWidth: 1,
  109. paddingTop: 10,
  110. paddingHorizontal: 10,
  111. }}
  112. onChangeText={text => this.setState({notes: text})}
  113. value={this.state.notes}
  114. multiline={true}
  115. numberOfLines={4}
  116. maxLength={1000}
  117. placeholder={'请填备注'}
  118. />
  119. </View>
  120. <View style={styles.paperBody}>
  121. {this.state.file.map((item, index) => (
  122. <View key={index} style={styles.paperBodyItem}>
  123. <ImageBackground
  124. source={item.img_id ? {uri: item.uri} : {uri: item.uri}}
  125. style={{width: 60, height: 60}}
  126. >
  127. <View style={{flex: 1}}>
  128. <View style={{
  129. borderRadius: 4,
  130. padding: 3,
  131. flexDirection: 'row',
  132. justifyContent: 'flex-end',
  133. }}>
  134. <TouchableOpacity onPress={() => this._delPhoto(item.fileName)}
  135. style={{
  136. borderRadius: 20,
  137. backgroundColor: '#b6b6b6',
  138. }}>
  139. <Text style={{fontFamily: 'iconfont'}}>{'\ue606'}</Text>
  140. </TouchableOpacity>
  141. </View>
  142. </View>
  143. </ImageBackground>
  144. </View>
  145. ))
  146. }
  147. <MultiCameraButton
  148. photos={this.state.file}
  149. onFileUpload={this.onImgUpload}
  150. maxFiles={6}
  151. >
  152. <Image
  153. source={require('../../../assets/images/add.png')}
  154. style={{width: 60, height: 60}}
  155. />
  156. </MultiCameraButton>
  157. </View>
  158. </ScrollView>
  159. <Button
  160. type="primary"
  161. disabled={loading}
  162. onPress={() => this.onSave()}
  163. style={ComponentsStyles.button}
  164. >
  165. <Text style={{color: '#fff'}}>提交</Text></Button>
  166. </Provider>
  167. );
  168. }
  169. }
  170. const styles = StyleSheet.create({
  171. paperBody: {
  172. flexDirection: 'row',
  173. flexWrap: 'wrap',
  174. // borderBottomWidth: 10,
  175. // borderBottomColor: '#eee',
  176. paddingLeft: 5,
  177. },
  178. paperBodyItem: {
  179. alignItems: 'center',
  180. margin: 2,
  181. padding: 5,
  182. },
  183. dateInput: {
  184. borderWidth: 0,
  185. alignItems: 'flex-end',
  186. },
  187. infoContent: {
  188. marginTop: 5,
  189. backgroundColor: '#fff',
  190. },
  191. infoItem: {
  192. flexDirection: 'row',
  193. paddingVertical: 10,
  194. borderBottomWidth: 1,
  195. borderColor: '#eaeaea',
  196. justifyContent: 'space-between',
  197. },
  198. infoItemLeft: {color: '#000', fontSize: 19},
  199. infoItemRight: {fontSize: 15, paddingTop: 2},
  200. modelItem: {
  201. borderBottomWidth: 1,
  202. borderColor: '#eaeaea',
  203. textAlign: 'center',
  204. paddingVertical: 8,
  205. fontSize: 18,
  206. color: '#000',
  207. },
  208. });
  209. export default UpdateProcess;