invoice_inquiry_ongoing.js 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  1. import React, {Component} from 'react';
  2. import {
  3. ActivityIndicator,
  4. FlatList,
  5. RefreshControl,
  6. Text,
  7. View,
  8. } from 'react-native';
  9. import {List, SwipeAction} from '@ant-design/react-native';
  10. import {RetrieveData} from '../../../data/storage';
  11. import {RequestNetwork} from '../../../data/encryption';
  12. import invoice_inquiry_css from './invoice_inquiry_css';
  13. let pageNo = 1; //当前第几页
  14. let totalPage = 5; //总的页数
  15. export default class invoice_inquiry_ongoing extends Component {
  16. constructor(props) {
  17. super(props);
  18. this.state = {
  19. listData: [],
  20. search_data: '',
  21. showFoot: 0, // 控制foot, 0:隐藏footer 1:已加载完成,没有更多数据 2 :显示加载中
  22. isLoading: false,
  23. visible1: false,
  24. };
  25. }
  26. render() {
  27. return (
  28. <View style={invoice_inquiry_css.container}>
  29. <FlatList
  30. data={this.state.listData}
  31. renderItem={(item) => this.renderItem(item)}
  32. refreshControl={
  33. <RefreshControl
  34. title={'加载中...'}
  35. colors={['#B7B7B7']} //此颜色无效
  36. tintColor={'#B7B7B7'}
  37. titleColor={'#B7B7B7'} //只有ios有效
  38. refreshing={this.state.isLoading}
  39. onRefresh={() => {
  40. this.initData();
  41. }}
  42. />
  43. }
  44. ListFooterComponent={this._renderFooter.bind(this)}
  45. onEndReached={this._onEndReached.bind(this)}
  46. onEndReachedThreshold={0.1}
  47. />
  48. </View>
  49. );
  50. }
  51. //初始化数据
  52. initData = () => {
  53. this.setState({
  54. listData: [],
  55. isLoading: false,
  56. showFoot: 0,
  57. });
  58. pageNo = 1;
  59. this.getSearchData();
  60. };
  61. //上拉加载
  62. _onEndReached() {
  63. if (this.state.showFoot === 0) {
  64. if (pageNo >= totalPage) {
  65. this.setState({showFoot: 1});
  66. return;
  67. } else {
  68. pageNo++;
  69. this.setState({showFoot: 2});
  70. //获取数据
  71. this.getSearchData();
  72. }
  73. }
  74. }
  75. //显示列表尾部
  76. _renderFooter() {
  77. if (this.state.showFoot === 1) {
  78. return (
  79. <View
  80. style={{
  81. height: 30,
  82. alignItems: 'center',
  83. justifyContent: 'flex-start',
  84. }}>
  85. <Text
  86. style={{
  87. color: '#999999',
  88. fontSize: 14,
  89. marginTop: 5,
  90. marginBottom: 5,
  91. }}>
  92. 没有更多数据了
  93. </Text>
  94. </View>
  95. );
  96. } else if (this.state.showFoot === 2) {
  97. return (
  98. <View style={invoice_inquiry_css.footer}>
  99. <ActivityIndicator />
  100. <Text>正在加载更多数据...</Text>
  101. </View>
  102. );
  103. } else if (this.state.showFoot === 0) {
  104. return (
  105. <View style={invoice_inquiry_css.footer}>
  106. <Text />
  107. </View>
  108. );
  109. }
  110. }
  111. //页面加载完成后加载数据
  112. componentDidMount(): void {
  113. this.props.children.getOnGoingRef(this);
  114. this.getSearchData();
  115. }
  116. //页面销毁
  117. componentWillUnmount(): void {
  118. pageNo = 1;
  119. }
  120. //获取查询数据
  121. getSearchData = async () => {
  122. let beginTime = '';
  123. let endTime = '';
  124. if (this.props.children.state.beginDateText !== undefined) {
  125. if (this.props.children.state.beginDateText !== '开始时间') {
  126. beginTime = this.props.children.state.beginDateText + ' 00:00:00';
  127. }
  128. }
  129. if (this.props.children.state.endDateText !== undefined) {
  130. if (this.props.children.state.endDateText !== '结束时间') {
  131. endTime = this.props.children.state.endDateText + ' 23:59:59';
  132. }
  133. }
  134. let account = await RetrieveData('account');
  135. let token = await RetrieveData('token');
  136. let company = JSON.parse(await RetrieveData('company'));
  137. console.log('12345');
  138. if (token && account) {
  139. const url = '/sys/invoice/findPage';
  140. let res = await RequestNetwork(
  141. url,
  142. token,
  143. {
  144. belongEntTaxId: company.entTaxId,
  145. mobile: account,
  146. reqChannel: 3,
  147. pageNum: pageNo,
  148. pageSize: 10,
  149. status: 1,
  150. invoiceDateBegin: beginTime,
  151. invoiceDateEnd: endTime,
  152. invoiceCategory: this.props.children.state.invoiceCategory,
  153. customerName: this.props.children.state.customerName,
  154. customerEntTaxId: this.props.children.state.customerEntTaxId,
  155. invoiceCode: this.props.children.state.invoiceCode,
  156. invoiceNumber: this.props.children.state.invoiceNumber,
  157. },
  158. false,
  159. 2,
  160. );
  161. if (res) {
  162. if (res.code === 0) {
  163. this.setList(res.data.records);
  164. }
  165. }
  166. }
  167. };
  168. //设置列表的list
  169. setList = data => {
  170. let listDatas = data.map((_, i) => ({
  171. key: data[i].invoiceId,
  172. invoiceType: data[i].invoiceType,
  173. invoiceCategory: data[i].invoiceCategory,
  174. invoiceCode: data[i].invoiceCode,
  175. invoiceNumber: data[i].invoiceNumber,
  176. invoiceDate: data[i].invoiceDate,
  177. customerName: data[i].customerName,
  178. customerEntTaxId: data[i].customerEntTaxId,
  179. totalAmountTaxes: data[i].totalAmountTaxes,
  180. invoiceReqFlowNo: data[i].invoiceReqFlowNo,
  181. status: data[i].status,
  182. }));
  183. let list = this.state.listData.concat(listDatas);
  184. this.setState({
  185. listData: list,
  186. showFoot: 0,
  187. });
  188. };
  189. //加载列表list
  190. renderItem = (data) => (
  191. <SwipeAction autoClose style={{backgroundColor: 'transparent'}}>
  192. <List.Item
  193. style={{backgroundColor: '#F7F7F7'}}>
  194. <View style={{backgroundColor: '#ffffff'}}>
  195. <View style={{flexDirection: 'row', marginLeft: 5, marginTop: 5, marginBottom: 5}}>
  196. <View style={{flex: 1}}>
  197. <Text style={invoice_inquiry_css.listHead}>{data.item.customerName}</Text>
  198. </View>
  199. {data.item.invoiceType === 0 ? (
  200. <View style={invoice_inquiry_css.listBlueHead}>
  201. <Text style={{color: '#ffffff'}}>蓝字发票</Text>
  202. </View>
  203. ) : data.item.invoiceType === 1 ? (
  204. <View style={invoice_inquiry_css.listRedHead}>
  205. <Text style={{color: '#ffffff'}}>红字发票</Text>
  206. </View>
  207. ) : data.item.invoiceType === 2 ? (
  208. <View style={invoice_inquiry_css.listInvalidHead}>
  209. <Text style={{color: '#ffffff'}}>空白作废发票</Text>
  210. </View>
  211. ) : (
  212. <View />
  213. )}
  214. </View>
  215. <View style={{marginLeft: 5}}>
  216. {data.item.invoiceCategory === 1 ? (
  217. <View>
  218. <Text style={{color: '#898989'}}>增值税普通电子发票</Text>
  219. </View>
  220. ) : data.item.invoiceCategory === 2 ? (
  221. <View>
  222. <Text style={{color: '#898989'}}>增值税电子专用发票</Text>
  223. </View>
  224. ) : data.item.invoiceCategory === 3 ? (
  225. <View>
  226. <Text style={{color: '#898989'}}>增值税普通纸质发票</Text>
  227. </View>
  228. ) : data.item.invoiceCategory === 4 ? (
  229. <View>
  230. <Text style={{color: '#898989'}}>增值税专用纸质发票</Text>
  231. </View>
  232. ) : (
  233. <View />
  234. )}
  235. </View>
  236. <View style={{flexDirection: 'row', margin: 5}}>
  237. <View style={{flex: 1}}>
  238. <View style={{marginTop: 5}}>
  239. {data.item.status === 1 ? (
  240. <View style={invoice_inquiry_css.listBlueStatus}>
  241. <Text style={{color: '#2A67FE'}}>开票中</Text>
  242. </View>
  243. ) : data.item.status === 2 ? (
  244. <View style={invoice_inquiry_css.listRedStatus}>
  245. <Text style={{color: '#F06969'}}>开票失败</Text>
  246. </View>
  247. ) : data.item.status === 3 ? (
  248. <View style={invoice_inquiry_css.listBlueStatus}>
  249. <Text style={{color: '#2A67FE'}}>正数开具成功</Text>
  250. </View>
  251. ) : data.item.status === 4 ? (
  252. <View style={invoice_inquiry_css.listBlueStatus}>
  253. <Text style={{color: '#2A67FE'}}>负数开具成功</Text>
  254. </View>
  255. ) : data.item.status === 5 ? (
  256. <View style={invoice_inquiry_css.listBlueStatus}>
  257. <Text style={{color: '#2A67FE'}}>正数已作废</Text>
  258. </View>
  259. ) : data.item.status === 6 ? (
  260. <View style={invoice_inquiry_css.listBlueStatus}>
  261. <Text style={{color: '#2A67FE'}}>负数已作废</Text>
  262. </View>
  263. ) : data.item.status === 7 ? (
  264. <View style={invoice_inquiry_css.listBlueStatus}>
  265. <Text style={{color: '#2A67FE'}}>空白作废</Text>
  266. </View>
  267. ) : (
  268. <View />
  269. )}
  270. </View>
  271. <View style={{marginTop: 5}}>
  272. <Text style={{color: '#A0A0A0'}}>{data.item.invoiceDate}</Text>
  273. </View>
  274. </View>
  275. <View style={{flex: 1, flexDirection: 'row', alignItems: 'flex-start', justifyContent: 'flex-end', marginRight: 5}}>
  276. <Text style={{color: '#393939', fontSize: 18, fontWeight: 'bold'}}>¥{data.item.totalAmountTaxes}</Text>
  277. </View>
  278. </View>
  279. </View>
  280. </List.Item>
  281. </SwipeAction>
  282. );
  283. }