invoice_inquiry_red_rush.js 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. import React, {Component} from 'react';
  2. import {Image, Text, TouchableOpacity, View} from 'react-native';
  3. import {
  4. DatePicker,
  5. Drawer,
  6. List,
  7. Provider,
  8. Tabs,
  9. InputItem,
  10. } from '@ant-design/react-native';
  11. import Invoice_inquiry_ongoing from './invoice_inquiry_ongoing';
  12. import Invoice_inquiry_completed from './invoice_inquiry_completed';
  13. import Invoice_inquiry_fail from './invoice_inquiry_fail';
  14. import public_css from '../../source/css/public_css';
  15. import invoice_red_rush_css from './invoice_red_rush_css';
  16. export default class invoice_inquiry_red_rush extends Component {
  17. constructor(props) {
  18. super(props);
  19. this.props.navigation.dangerouslyGetParent().setOptions({
  20. tabBarVisible: false,
  21. });
  22. this.state = {
  23. isShowSearch: false,
  24. visible1: false,
  25. tab: 0,
  26. clickNum: 0,
  27. beginDateTime: undefined,
  28. endDateTime: undefined,
  29. belongEntTaxId: '',
  30. invoiceCode: '',
  31. invoiceNumber: '',
  32. };
  33. }
  34. render() {
  35. const tabs = [{title: '进行中'}, {title: '开具完成'}, {title: '开具失败'}];
  36. let draw = (
  37. <View style={public_css.body}>
  38. <View style={{flex: 1}}>
  39. <View>
  40. <List>
  41. <DatePicker
  42. value={this.state.beginDateTime}
  43. mode="date"
  44. defaultDate={new Date()}
  45. minDate={new Date(2020, 0, 1)}
  46. maxDate={new Date(2030, 11, 3)}
  47. onChange={time => this.beginTimeChange(time)}
  48. format="YYYY-MM-DD">
  49. <List.Item arrow="horizontal">开始时间</List.Item>
  50. </DatePicker>
  51. </List>
  52. </View>
  53. <View>
  54. <List>
  55. <DatePicker
  56. value={this.state.endDateTime}
  57. mode="date"
  58. defaultDate={new Date()}
  59. minDate={this.state.beginDateTime}
  60. maxDate={new Date(2030, 11, 3)}
  61. onChange={time => this.endTimeChange(time)}
  62. format="YYYY-MM-DD">
  63. <List.Item arrow="horizontal">结束时间</List.Item>
  64. </DatePicker>
  65. </List>
  66. </View>
  67. <InputItem
  68. clear
  69. value={this.state.belongEntTaxId}
  70. onChange={value => {
  71. this.setState({
  72. belongEntTaxId: value,
  73. });
  74. }}
  75. placeholder="请输入要查询的开发票的企业税号">
  76. 开发票的企业税号:
  77. </InputItem>
  78. <InputItem
  79. clear
  80. value={this.state.invoiceCode}
  81. onChange={value => {
  82. this.setState({
  83. invoiceCode: value,
  84. });
  85. }}
  86. placeholder="请输入要查询的发票代码">
  87. 发票代码:
  88. </InputItem>
  89. <InputItem
  90. clear
  91. value={this.state.invoiceNumber}
  92. onChange={value => {
  93. this.setState({
  94. invoiceNumber: value,
  95. });
  96. }}
  97. placeholder="请输入要查询的发票号码">
  98. 发票号码:
  99. </InputItem>
  100. </View>
  101. <View style={public_css.bottomStaus}>
  102. <TouchableOpacity
  103. style={[public_css.statusBtn, public_css.statusLBtn]}
  104. onPress={() => {
  105. this.searchDataEmpty();
  106. }}>
  107. <Image
  108. source={require('../../source/img/productImg/clear.png')}
  109. style={{width: 32, height: 32}}
  110. />
  111. <Text>全部清除</Text>
  112. </TouchableOpacity>
  113. <TouchableOpacity
  114. style={[public_css.statusBtn, public_css.statusRBtn]}
  115. onPress={() => this.submitData()}>
  116. <Image
  117. source={require('../../source/img/productImg/confirm.png')}
  118. style={{width: 32, height: 32}}
  119. />
  120. <Text style={{color: '#fff'}}>查询</Text>
  121. </TouchableOpacity>
  122. </View>
  123. </View>
  124. );
  125. return (
  126. <View style={{flex: 1}}>
  127. <Provider>
  128. <Drawer
  129. sidebar={draw}
  130. position="right"
  131. open={false}
  132. drawerRef={el => (this.drawer = el)}
  133. onOpenChange={open => this.openStatus(open)}
  134. drawerBackgroundColor="#ccc"
  135. drawerWidth={300}>
  136. <Tabs
  137. tabs={tabs}
  138. onChange={(i, l) => this.onChanges(i, l)}
  139. page={0}>
  140. <View style={invoice_red_rush_css.container}>
  141. <Invoice_inquiry_ongoing children={this} />
  142. </View>
  143. <View style={invoice_red_rush_css.container}>
  144. <Invoice_inquiry_completed children={this} />
  145. </View>
  146. <View style={invoice_red_rush_css.container}>
  147. <Invoice_inquiry_fail children={this} />
  148. </View>
  149. </Tabs>
  150. </Drawer>
  151. </Provider>
  152. </View>
  153. );
  154. }
  155. //判断是否点击了查询
  156. shouldComponentUpdate(
  157. nextProps: Readonly<P>,
  158. nextState: Readonly<S>,
  159. nextContext: any,
  160. ): boolean {
  161. if (nextProps.route.params != undefined) {
  162. if (nextProps.route.params.isShow) {
  163. if (this.state.clickNum === 0) {
  164. this.setState({
  165. isShowSearch: true,
  166. clickNum: this.state.clickNum++,
  167. });
  168. this.drawer.openDrawer();
  169. this.props.navigation.setParams({
  170. isShow: false,
  171. });
  172. }
  173. }
  174. }
  175. return true;
  176. }
  177. //tab变化事件
  178. onChanges = (i, l) => {
  179. this.setState({
  180. tab: l,
  181. clickNum: 0,
  182. beginDateTime: undefined,
  183. endDateTime: undefined,
  184. belongEntTaxId: '',
  185. invoiceCode: '',
  186. invoiceNumber: '',
  187. });
  188. };
  189. //传递方法到子组件
  190. getOnGoingRef = ref => {
  191. this.goingChild = ref;
  192. };
  193. //传递方法到子组件
  194. getCompletedRef = ref => {
  195. this.completedChild = ref;
  196. };
  197. //传递方法到子组件
  198. getFailRef = ref => {
  199. this.failChild = ref;
  200. };
  201. //查询菜单开关状态
  202. openStatus = open => {
  203. if (open) {
  204. } else {
  205. // this.props.children.setClickNum();
  206. }
  207. };
  208. //获取查询开始时间
  209. beginTimeChange = time => {
  210. this.setState({
  211. beginDateTime: time,
  212. });
  213. };
  214. //获取查询结束时间
  215. endTimeChange = time => {
  216. this.setState({
  217. endDateTime: time,
  218. });
  219. };
  220. //查询
  221. submitData = () => {
  222. let tab = this.state.tab;
  223. if (tab == 0) {
  224. this.drawer.closeDrawer();
  225. this.goingChild.initData();
  226. }
  227. if (tab == 1) {
  228. this.drawer.closeDrawer();
  229. this.completedChild.initData();
  230. }
  231. if (tab == 2) {
  232. this.drawer.closeDrawer();
  233. this.failChild.initData();
  234. }
  235. };
  236. //清空查询数据
  237. searchDataEmpty = () => {
  238. this.setState({
  239. beginDateTime: undefined,
  240. endDateTime: undefined,
  241. belongEntTaxId: '',
  242. invoiceCode: '',
  243. invoiceNumber: '',
  244. });
  245. };
  246. }