invoice_inquiry_completed.js 11 KB

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