paper_major_invoice.js 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553
  1. import React, {Component} from 'react';
  2. import {
  3. View,
  4. TouchableOpacity,
  5. Text,
  6. TextInput,
  7. ScrollView,
  8. SafeAreaView,
  9. } from 'react-native';
  10. import { Drawer, List, Picker, Provider, Tabs, WhiteSpace } from "@ant-design/react-native";
  11. import DateTimePicker from '@react-native-community/datetimepicker';
  12. import Invoice_inquiry_ongoing from './invoice_inquiry_ongoing';
  13. import Invoice_inquiry_completed from './invoice_inquiry_completed';
  14. import Invoice_inquiry_all from './invoice_inquiry_all';
  15. import public_css from '../../../source/css/public_css';
  16. import invoice_inquiry_css from './invoice_inquiry_css';
  17. import {GetDateString} from '../../../utils/date';
  18. export default class paper_major_invoice extends Component {
  19. constructor(props) {
  20. super(props);
  21. this.props.navigation.dangerouslyGetParent().setOptions({
  22. tabBarVisible: false,
  23. });
  24. this.state = {
  25. isShowSearch: false,
  26. visible1: false,
  27. tab: 0,
  28. clickNum: 0,
  29. invoiceStatus: null,
  30. beginDateTime: undefined,
  31. endDateTime: undefined,
  32. customerName: '',
  33. customerEntTaxId: '',
  34. invoiceCode: '',
  35. invoiceNumber: '',
  36. beginDate: new Date(),
  37. beginDateText: '开始时间',
  38. endDate: new Date(),
  39. endDateText: '结束时间',
  40. beginDateShow: false,
  41. endDateShow: false,
  42. invoiceCategory: 4,
  43. };
  44. }
  45. render() {
  46. const tabs = [{title: '全部'}, {title: '开票中'}, {title: '开票成功'}];
  47. const seasons = [
  48. [
  49. {
  50. label: '全部',
  51. value: null,
  52. },
  53. {
  54. label: '正数开具成功',
  55. value: 3,
  56. },
  57. {
  58. label: '负数开具成功',
  59. value: 4,
  60. },
  61. {
  62. label: '正数已作废',
  63. value: 5,
  64. },
  65. {
  66. label: '负数已作废',
  67. value: 6,
  68. },
  69. {
  70. label: '空白作废',
  71. value: 7,
  72. },
  73. ],
  74. ];
  75. let draw = (
  76. <SafeAreaView style={public_css.body}>
  77. <ScrollView>
  78. <View>
  79. <Picker
  80. data={seasons}
  81. cols={1}
  82. value={[this.state.invoiceStatus]}
  83. onChange={(select) => this.invoiceStatusChange(select)}
  84. cascade={false}>
  85. <List.Item>
  86. <Text
  87. style={{color: '#414141', fontSize: 16, fontWeight: 'bold'}}>
  88. 发票状态:
  89. </Text>
  90. </List.Item>
  91. </Picker>
  92. <View style={{margin: 10}}>
  93. <Text
  94. style={{color: '#414141', fontSize: 16, fontWeight: 'bold'}}>
  95. 时间区间
  96. </Text>
  97. </View>
  98. <View
  99. style={{
  100. flexDirection: 'row',
  101. justifyContent: 'center',
  102. alignItems: 'center',
  103. }}>
  104. <TouchableOpacity
  105. style={{
  106. backgroundColor: '#F5F5F5',
  107. width: 120,
  108. height: 40,
  109. borderRadius: 99,
  110. alignItems: 'center',
  111. justifyContent: 'center',
  112. }}
  113. onPress={() => {
  114. this.isShowDateSelect(1);
  115. }}>
  116. <View>
  117. <Text
  118. style={{
  119. color: '#D7D7D7',
  120. fontWeight: 'bold',
  121. fontSize: 16,
  122. }}>
  123. {this.state.beginDateText}
  124. </Text>
  125. </View>
  126. </TouchableOpacity>
  127. <View>
  128. <Text style={{color: '#8C8C8C'}}>—</Text>
  129. </View>
  130. <TouchableOpacity
  131. style={{
  132. backgroundColor: '#F5F5F5',
  133. width: 120,
  134. height: 40,
  135. borderRadius: 99,
  136. alignItems: 'center',
  137. justifyContent: 'center',
  138. }}
  139. onPress={() => {
  140. this.isShowDateSelect(2);
  141. }}>
  142. <View>
  143. <Text
  144. style={{
  145. color: '#D7D7D7',
  146. fontWeight: 'bold',
  147. fontSize: 16,
  148. }}>
  149. {this.state.endDateText}
  150. </Text>
  151. </View>
  152. </TouchableOpacity>
  153. </View>
  154. {this.state.beginDateShow === true ? (
  155. <DateTimePicker
  156. testID="dateTimePicker"
  157. value={this.state.beginDate}
  158. mode={'date'}
  159. is24Hour={true}
  160. display="default"
  161. placeholder="起始时间"
  162. dateFormat="yyyy-MM-dd"
  163. onChange={(event, date) => {
  164. this.beginDateChange(event, date);
  165. }}
  166. />
  167. ) : (
  168. <View />
  169. )}
  170. {this.state.endDateShow === true ? (
  171. <DateTimePicker
  172. testID="dateTimePicker"
  173. value={this.state.endDate}
  174. mode={'date'}
  175. is24Hour={true}
  176. display="default"
  177. placeholder="起始时间"
  178. dateFormat="yyyy-MM-dd"
  179. onChange={(event, date) => {
  180. this.endDateChange(event, date);
  181. }}
  182. />
  183. ) : (
  184. <View />
  185. )}
  186. </View>
  187. <View>
  188. <View>
  189. <Text
  190. style={{
  191. fontWeight: 'bold',
  192. color: '#414141',
  193. fontSize: 16,
  194. margin: 10,
  195. }}>
  196. 客户名称:
  197. </Text>
  198. </View>
  199. <View
  200. style={{
  201. justifyContent: 'center',
  202. alignItems: 'center',
  203. }}>
  204. <TextInput
  205. style={{
  206. paddingVertical: 0,
  207. width: 260,
  208. height: 35,
  209. borderRadius: 99,
  210. backgroundColor: '#F5F5F5',
  211. }}
  212. placeholder={'请输入要查询的客户名称'}
  213. clearButtonMode={'while-editing'}
  214. value={this.state.customerName}
  215. onChangeText={(value) => {
  216. this.setState({
  217. customerName: value,
  218. });
  219. }}
  220. />
  221. </View>
  222. </View>
  223. <View>
  224. <View>
  225. <Text
  226. style={{
  227. fontWeight: 'bold',
  228. color: '#414141',
  229. fontSize: 16,
  230. margin: 10,
  231. }}>
  232. 客户企业税号:
  233. </Text>
  234. </View>
  235. <View
  236. style={{
  237. justifyContent: 'center',
  238. alignItems: 'center',
  239. }}>
  240. <TextInput
  241. style={{
  242. paddingVertical: 0,
  243. width: 260,
  244. height: 35,
  245. borderRadius: 99,
  246. backgroundColor: '#F5F5F5',
  247. }}
  248. placeholder={'请输入要查询的客户企业税号'}
  249. clearButtonMode={'while-editing'}
  250. value={this.state.customerEntTaxId}
  251. onChangeText={(value) => {
  252. this.setState({
  253. customerEntTaxId: value,
  254. });
  255. }}
  256. />
  257. </View>
  258. </View>
  259. <View>
  260. <View>
  261. <Text
  262. style={{
  263. fontWeight: 'bold',
  264. color: '#414141',
  265. fontSize: 16,
  266. margin: 10,
  267. }}>
  268. 发票代码:
  269. </Text>
  270. </View>
  271. <View
  272. style={{
  273. justifyContent: 'center',
  274. alignItems: 'center',
  275. }}>
  276. <TextInput
  277. style={{
  278. paddingVertical: 0,
  279. width: 260,
  280. height: 35,
  281. borderRadius: 99,
  282. backgroundColor: '#F5F5F5',
  283. }}
  284. placeholder={'请输入要查询的发票代码'}
  285. clearButtonMode={'while-editing'}
  286. value={this.state.invoiceCode}
  287. onChangeText={(value) => {
  288. this.setState({
  289. invoiceCode: value,
  290. });
  291. }}
  292. />
  293. </View>
  294. </View>
  295. <View>
  296. <View>
  297. <Text
  298. style={{
  299. fontWeight: 'bold',
  300. color: '#414141',
  301. fontSize: 16,
  302. margin: 10,
  303. }}>
  304. 发票号码:
  305. </Text>
  306. </View>
  307. <View
  308. style={{
  309. justifyContent: 'center',
  310. alignItems: 'center',
  311. }}>
  312. <TextInput
  313. style={{
  314. paddingVertical: 0,
  315. width: 260,
  316. height: 35,
  317. borderRadius: 99,
  318. backgroundColor: '#F5F5F5',
  319. }}
  320. placeholder={'请输入要查询的发票号码'}
  321. // clearButtonMode={'while-editing'}
  322. value={this.state.invoiceNumber}
  323. onChangeText={(value) => {
  324. console.log(value);
  325. this.setState({
  326. invoiceNumber: value,
  327. });
  328. }}
  329. />
  330. </View>
  331. </View>
  332. </ScrollView>
  333. <View style={public_css.bottomStatus}>
  334. <View
  335. style={{flex: 1, justifyContent: 'center', alignItems: 'center'}}>
  336. <TouchableOpacity
  337. style={{
  338. borderWidth: 1,
  339. borderRadius: 30,
  340. borderColor: '#8B8B8B',
  341. width: 120,
  342. height: 40,
  343. justifyContent: 'center',
  344. alignItems: 'center',
  345. }}
  346. onPress={() => {
  347. this.searchDataEmpty();
  348. }}>
  349. <Text style={{color: '#262626'}}>重置</Text>
  350. </TouchableOpacity>
  351. </View>
  352. <View
  353. style={{flex: 1, justifyContent: 'center', alignItems: 'center'}}>
  354. <TouchableOpacity
  355. style={{
  356. borderWidth: 1,
  357. borderRadius: 30,
  358. borderColor: '#2A67FE',
  359. backgroundColor: '#2A67FE',
  360. width: 120,
  361. height: 40,
  362. justifyContent: 'center',
  363. alignItems: 'center',
  364. }}
  365. onPress={() => this.submitData()}>
  366. <Text style={{color: '#FFFFFF'}}>查询</Text>
  367. </TouchableOpacity>
  368. </View>
  369. </View>
  370. <WhiteSpace />
  371. </SafeAreaView>
  372. );
  373. return (
  374. <View style={{flex: 1}}>
  375. <Provider>
  376. <Drawer
  377. sidebar={draw}
  378. position="right"
  379. open={false}
  380. drawerRef={(el) => (this.drawer = el)}
  381. onOpenChange={(open) => this.openStatus(open)}
  382. drawerBackgroundColor="#ccc"
  383. drawerWidth={300}>
  384. <Tabs
  385. tabs={tabs}
  386. onChange={(i, l) => this.onChanges(i, l)}
  387. page={0}>
  388. <View style={invoice_inquiry_css.container}>
  389. <Invoice_inquiry_all children={this} />
  390. </View>
  391. <View style={invoice_inquiry_css.container}>
  392. <Invoice_inquiry_ongoing children={this} />
  393. </View>
  394. <View style={invoice_inquiry_css.container}>
  395. <Invoice_inquiry_completed children={this} />
  396. </View>
  397. </Tabs>
  398. </Drawer>
  399. </Provider>
  400. </View>
  401. );
  402. }
  403. //判断是否点击了查询
  404. shouldComponentUpdate(
  405. nextProps: Readonly<P>,
  406. nextState: Readonly<S>,
  407. nextContext: any,
  408. ): boolean {
  409. if (nextProps.route.params !== undefined) {
  410. if (nextProps.route.params.isShow) {
  411. if (this.state.clickNum === 0) {
  412. this.setState({
  413. isShowSearch: true,
  414. clickNum: this.state.clickNum++,
  415. });
  416. this.drawer.openDrawer();
  417. this.props.navigation.setParams({
  418. isShow: false,
  419. });
  420. }
  421. }
  422. }
  423. return true;
  424. }
  425. //tab变化事件
  426. onChanges = (i, l) => {
  427. if (this.state.tab !== l) {
  428. this.setState({
  429. tab: l,
  430. clickNum: 0,
  431. invoiceStatus: null,
  432. beginDate: new Date(),
  433. beginDateText: '开始时间',
  434. endDate: new Date(),
  435. endDateText: '结束时间',
  436. beginDateShow: false,
  437. endDateShow: false,
  438. customerName: '',
  439. customerEntTaxId: '',
  440. invoiceCode: '',
  441. invoiceNumber: '',
  442. invoiceCategory: 4,
  443. });
  444. }
  445. };
  446. //传递方法到子组件
  447. getOnGoingRef = (ref) => {
  448. this.goingChild = ref;
  449. };
  450. //传递方法到子组件
  451. getCompletedRef = (ref) => {
  452. this.completedChild = ref;
  453. };
  454. //传递方法到子组件
  455. getAllRef = (ref) => {
  456. this.allChild = ref;
  457. };
  458. //查询菜单开关状态
  459. openStatus = (open) => {
  460. if (open) {
  461. } else {
  462. // this.props.children.setClickNum();
  463. }
  464. };
  465. // 发票状态选择
  466. invoiceStatusChange = (data) => {
  467. let status = '';
  468. if (data.length > 0) {
  469. status = data[0];
  470. }
  471. this.setState({
  472. invoiceStatus: status,
  473. });
  474. };
  475. //查询
  476. submitData = () => {
  477. let tab = this.state.tab;
  478. if (tab === 0) {
  479. this.drawer.closeDrawer();
  480. this.allChild.initData();
  481. }
  482. if (tab === 1) {
  483. this.drawer.closeDrawer();
  484. this.goingChild.initData();
  485. }
  486. if (tab === 2) {
  487. this.drawer.closeDrawer();
  488. this.completedChild.initData();
  489. }
  490. };
  491. //清空查询数据
  492. searchDataEmpty = () => {
  493. this.setState({
  494. invoiceStatus: null,
  495. beginDate: new Date(),
  496. beginDateText: '开始时间',
  497. endDate: new Date(),
  498. endDateText: '结束时间',
  499. beginDateShow: false,
  500. endDateShow: false,
  501. customerName: '',
  502. customerEntTaxId: '',
  503. invoiceCode: '',
  504. invoiceNumber: '',
  505. invoiceCategory: 4,
  506. });
  507. };
  508. // 点击开始和结束时间显示时间选择器
  509. isShowDateSelect = (dateStatus) => {
  510. // 开始时间和结束时间选择器显示 1:开始时间 2:结束时间
  511. if (dateStatus === 1) {
  512. this.setState({
  513. beginDateShow: true,
  514. });
  515. } else {
  516. this.setState({
  517. endDateShow: true,
  518. });
  519. }
  520. };
  521. // 获取开始时间
  522. beginDateChange = (event, date) => {
  523. let dateText = GetDateString(date);
  524. this.setState({
  525. beginDate: date,
  526. beginDateShow: false,
  527. beginDateText: dateText,
  528. });
  529. };
  530. //获取结束时间
  531. endDateChange = (event, date) => {
  532. let dateText = GetDateString(date);
  533. this.setState({
  534. endDate: date,
  535. endDateShow: false,
  536. endDateText: dateText,
  537. });
  538. };
  539. }