invoice_inquiry.js 8.0 KB

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