PayReconciliation.js 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631
  1. import React, { Component } from 'react'
  2. import {
  3. StyleSheet,
  4. ScrollView,
  5. View,
  6. Image,
  7. ImageBackground,
  8. Text,
  9. Dimensions,
  10. StatusBar,
  11. TouchableOpacity,
  12. FlatList,
  13. PixelRatio,
  14. Platform,
  15. DatePickerAndroid,
  16. } from 'react-native'
  17. import { connect } from 'react-redux'
  18. import Input from '../../../components/input/index'
  19. import Icon from '../../../components/Iconfont/Iconfont'
  20. import { NavigationActions, createAction } from '../../../utils'
  21. import SelectTime from '../../common/SelectTime'
  22. import Collapsible from 'react-native-collapsible'
  23. import SelectTimeCom from '../../../components/selectTime/selectTime'
  24. import { ReturnDate } from '../../../utils/utils'
  25. const { width, height } = Dimensions.get('window')
  26. @connect(({ theme, mine, mine_payment }) => ({
  27. ...theme,
  28. ...mine,
  29. ...mine_payment,
  30. }))
  31. class PayReconciliation extends Component {
  32. constructor(props) {
  33. const date = new Date()
  34. super(props)
  35. this.state = {
  36. data: [],
  37. showSearch: false,
  38. dateActive: true, //时间折叠-true为关
  39. activeSection: true,
  40. // 应收组织Index
  41. receiveIndex: 0,
  42. // 销售组织Index
  43. saleIndex: 'fff',
  44. // 应收组织
  45. receivableOrgan:
  46. props.FinancialOrg && props.FinancialOrg.length > 0
  47. ? props.FinancialOrg[0].finanOrgName
  48. : '',
  49. receivableId:
  50. props.FinancialOrg && props.FinancialOrg.length > 0
  51. ? props.FinancialOrg[0].finanOrgId
  52. : '',
  53. // 销售组织
  54. saleOrgan: '请选择销售组织',
  55. // props.SupplierInfo && props.SupplierInfo.length > 0
  56. // ? props.SupplierInfo[0].saleOrganizationName
  57. // : "请选择销售组织",
  58. saleId: '',
  59. // props.SupplierInfo && props.SupplierInfo.length > 0
  60. // ? props.SupplierInfo[0].saleOrganizationId
  61. // : "",
  62. // saleOrgan: "请选择销售组织",
  63. // 头部inputText
  64. inputText: '',
  65. // 开始时间
  66. startTime: '',
  67. // 结束时间
  68. endTime: '',
  69. }
  70. // this.startTime = date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + 1;
  71. // this.endTime =
  72. // date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + date.getDate();
  73. // this.startTime = 0;
  74. // this.endTime = 0;
  75. }
  76. componentDidMount() {
  77. // 可用财务组织
  78. this.props.dispatch(
  79. createAction('mine/getCusSup')({
  80. customerId: CUSTOMERINFO.id,
  81. customerRankCode: CUSTOMERINFO.customerRankCode,
  82. })
  83. )
  84. this.statisticPatch()
  85. this.findSaleOrg()
  86. }
  87. // 应收组织统计页
  88. statisticPatch() {
  89. this.props.dispatch(
  90. createAction('mine_payment/getPayStatistic')({
  91. searchInfo: this.statsticInfo(),
  92. })
  93. )
  94. }
  95. statsticInfo() {
  96. let search = {
  97. financeOrgId: this.state.receivableId,
  98. }
  99. if (this.state.saleId) {
  100. search.saleOrgId = this.state.saleId
  101. }
  102. if (this.state.startTime && this.state.endTime) {
  103. search.startTime = this.state.startTime
  104. search.endTime = this.state.endTime
  105. }
  106. return search
  107. }
  108. findSaleOrg() {
  109. // 通过财务组织找销售组织
  110. this.props.dispatch(
  111. createAction('mine/findSaleOrgByFinance')({
  112. search_EQ_finanOrg: this.state.receivableId,
  113. size: 20,
  114. page: 0,
  115. })
  116. )
  117. }
  118. // 头部
  119. header() {
  120. return (
  121. <View
  122. style={{
  123. height: HEADERSTYLE.height,
  124. paddingTop: HEADERSTYLE.paddingTop + 5,
  125. backgroundColor: '#fff',
  126. borderBottomColor: '#eee',
  127. borderBottomWidth: 1 / PixelRatio.get(),
  128. }}
  129. >
  130. <View
  131. style={{
  132. flex: 1,
  133. justifyContent: 'center',
  134. }}
  135. >
  136. <TouchableOpacity
  137. style={{ position: 'absolute', left: 10, flexDirection: 'row' }}
  138. onPress={() => this.props.dispatch(NavigationActions.back())}
  139. >
  140. <Icon
  141. name="icon-icon-fanhui"
  142. size={20}
  143. color={'#666'}
  144. style={{ marginTop: 4 }}
  145. />
  146. <Text
  147. style={{
  148. fontSize: 14,
  149. lineHeight: 20,
  150. color: '#666',
  151. alignSelf: 'center',
  152. }}
  153. >
  154. 返回
  155. </Text>
  156. </TouchableOpacity>
  157. {this.state.showSearch ? (
  158. <Input
  159. autoFocus={this.state.showSearch}
  160. isBlurTrue={false}
  161. style={{
  162. marginLeft: 25,
  163. marginTop: 8,
  164. height: 28,
  165. width: width / 1.6,
  166. borderRadius: width / 2,
  167. alignSelf: 'center',
  168. marginBottom: 8,
  169. paddingLeft: 14,
  170. }}
  171. textStyle={{
  172. paddingLeft: 10,
  173. height: 32,
  174. fontSize: 11,
  175. padding: 0,
  176. }}
  177. iconSize={14}
  178. blurOnSubmit={true}
  179. textInputBacg={'#F5F5F5'}
  180. iconColor={'#CCC'}
  181. placeholderTextColor={'#CCC'}
  182. placeholderSize={8}
  183. onchangeFn={e => {
  184. this.setState({ inputText: e })
  185. }}
  186. />
  187. ) : (
  188. <Text
  189. style={{
  190. alignSelf: 'center',
  191. fontSize: 18,
  192. lineHeight: 25,
  193. letterSpacing: 0.19,
  194. color: '#333',
  195. }}
  196. >
  197. 应付对账
  198. </Text>
  199. )}
  200. {this.state.showSearch ? (
  201. <TouchableOpacity
  202. onPress={() =>
  203. this.setState({ showSearch: false, activeSection: true })
  204. }
  205. style={{ position: 'absolute', right: 10, flexDirection: 'row' }}
  206. >
  207. <Text style={{ fontSize: 14, lineHeight: 20, color: '#666' }}>
  208. 取消
  209. </Text>
  210. </TouchableOpacity>
  211. ) : (
  212. <View
  213. style={{ position: 'absolute', right: 10, flexDirection: 'row' }}
  214. >
  215. {/* <TouchableOpacity
  216. style={{ marginRight: 10 }}
  217. onPress={() =>
  218. this.setState({ showSearch: true, activeSection: true })
  219. }
  220. >
  221. <Icon name="icon-icon-sousuo" size={24} color={"#666"} />
  222. </TouchableOpacity> */}
  223. <TouchableOpacity
  224. onPress={() =>
  225. this.setState({ dateActive: !this.state.dateActive })
  226. }
  227. >
  228. <Icon name="icon-icon-rili" size={24} color={'#666'} />
  229. </TouchableOpacity>
  230. </View>
  231. )}
  232. </View>
  233. </View>
  234. )
  235. }
  236. collapsibleData(item, index) {
  237. return (
  238. <TouchableOpacity
  239. onPress={() => {
  240. if (this.state.filiter == 'Receivable') {
  241. this.state.receivableId = item.finanOrgId
  242. this.setState({
  243. receivableOrgan: item.finanOrgName,
  244. receivableId: item.finanOrgId,
  245. activeSection: true,
  246. receiveIndex: index,
  247. })
  248. } else {
  249. this.state.saleId = item.saleOrganizationId
  250. this.setState({
  251. saleOrgan: item.saleOrganizationName,
  252. saleId: item.saleOrganizationId,
  253. activeSection: true,
  254. saleIndex: index,
  255. })
  256. }
  257. this.statisticPatch()
  258. }}
  259. style={{
  260. flexDirection: 'row',
  261. padding: 10,
  262. justifyContent: 'space-between',
  263. }}
  264. >
  265. <Text style={{ fontSize: 13, lineHeight: 18, color: '#333' }}>
  266. {this.state.filiter == 'Receivable'
  267. ? item.finanOrgName
  268. : item.saleOrganizationName}
  269. </Text>
  270. {this.state.filiter == 'Receivable' &&
  271. this.state.receiveIndex == index ? (
  272. <Icon name="icon-icon-duigou" size={16} color={'red'} />
  273. ) : null}
  274. {this.state.filiter == 'Sale' && this.state.saleIndex == index ? (
  275. <Icon name="icon-icon-duigou" size={16} color={'red'} />
  276. ) : null}
  277. </TouchableOpacity>
  278. )
  279. }
  280. HeadScreening(from) {
  281. if (this.state.filiter !== from) {
  282. this.setState({ activeSection: false })
  283. } else if (this.state.filiter == from) {
  284. if (this.state.activeSection == false) {
  285. this.setState({ activeSection: true })
  286. } else {
  287. this.setState({ activeSection: false })
  288. }
  289. }
  290. switch (from) {
  291. case 'Receivable':
  292. this.state.filiter = 'Receivable'
  293. this.setState({ data: this.props.FinancialOrg })
  294. break
  295. case 'Sale':
  296. this.state.filiter = 'Sale'
  297. this.setState({ data: this.props.SupplierInfo })
  298. break
  299. }
  300. }
  301. dateCbFn(data) {
  302. if (data.fn && data.fn == 'cancel') {
  303. this.setState({ dateActive: true })
  304. } else {
  305. this.state.startTime = data.startTime
  306. this.state.endTime = data.endTime
  307. this.setState({
  308. dateActive: true,
  309. })
  310. this.statisticPatch()
  311. }
  312. }
  313. receiveList(item, index) {
  314. return (
  315. <TouchableOpacity
  316. onPress={() =>
  317. this.props.dispatch(
  318. NavigationActions.navigate({
  319. routeName: 'ReconciliationDetail',
  320. params: {
  321. comeFrom: 'Pay',
  322. startTime: this.state.startTime,
  323. endTime: this.endTime,
  324. Search_FinaOrg: item.financeOrgId,
  325. saleId: item.saleOrgId,
  326. },
  327. })
  328. )
  329. }
  330. style={{ padding: 10, marginTop: 10, backgroundColor: '#FFF' }}
  331. >
  332. <View
  333. style={{
  334. borderBottomColor: '#DDD',
  335. borderBottomWidth: 1 / PixelRatio.get(),
  336. paddingBottom: 7,
  337. }}
  338. >
  339. <Text
  340. style={{
  341. fontSize: 14,
  342. lineHeight: 20,
  343. letterSpacing: 0.17,
  344. color: '#333',
  345. }}
  346. >
  347. {item.saleOrgName}
  348. </Text>
  349. </View>
  350. <View style={{ flexDirection: 'row', paddingTop: 10 }}>
  351. <View style={{ flex: 1 }}>
  352. <Text
  353. style={{
  354. fontSize: 13,
  355. lineHeight: 18,
  356. letterSpacing: 0.16,
  357. color: '#999',
  358. }}
  359. >
  360. 期初余额
  361. </Text>
  362. <Text
  363. style={{
  364. fontSize: 15,
  365. lineHeight: 21,
  366. letterSpacing: 0.18,
  367. color: '#333',
  368. marginTop: 10,
  369. }}
  370. >
  371. {item.initialBalance}
  372. </Text>
  373. </View>
  374. <View style={{ flex: 1 }}>
  375. <Text
  376. style={{
  377. fontSize: 13,
  378. lineHeight: 18,
  379. letterSpacing: 0.16,
  380. color: '#999',
  381. }}
  382. >
  383. 本期发生
  384. </Text>
  385. <Text
  386. style={{
  387. fontSize: 15,
  388. lineHeight: 21,
  389. letterSpacing: 0.18,
  390. color: '#333',
  391. marginTop: 10,
  392. }}
  393. >
  394. {item.occurrenceOfThisPeriod}
  395. </Text>
  396. </View>
  397. <View style={{ flex: 1 }}>
  398. <Text
  399. style={{
  400. fontSize: 13,
  401. lineHeight: 18,
  402. letterSpacing: 0.16,
  403. color: '#999',
  404. }}
  405. >
  406. 本期收款
  407. </Text>
  408. <Text
  409. style={{
  410. fontSize: 15,
  411. lineHeight: 21,
  412. letterSpacing: 0.18,
  413. color: '#333',
  414. marginTop: 10,
  415. }}
  416. >
  417. {item.currenTreceipts}
  418. </Text>
  419. </View>
  420. <View style={{ flex: 1 }}>
  421. <Text
  422. style={{
  423. fontSize: 13,
  424. lineHeight: 18,
  425. letterSpacing: 0.16,
  426. color: '#999',
  427. }}
  428. >
  429. 期末余额
  430. </Text>
  431. <Text
  432. style={{
  433. fontSize: 15,
  434. lineHeight: 21,
  435. letterSpacing: 0.18,
  436. color: '#333',
  437. marginTop: 10,
  438. }}
  439. >
  440. {item.finalBalance}
  441. </Text>
  442. </View>
  443. </View>
  444. </TouchableOpacity>
  445. )
  446. }
  447. render() {
  448. const { appTheme, payStaticData } = this.props
  449. return (
  450. <View
  451. style={[
  452. styles.container,
  453. { backgroundColor: appTheme.backgroundColor },
  454. ]}
  455. >
  456. <StatusBar
  457. animated={true}
  458. barStyle={appTheme.barStyle}
  459. // barStyle={"dark-content"}
  460. backgroundColor={'transparent'}
  461. translucent={true}
  462. />
  463. {this.header()}
  464. {/* 头部筛选条件 */}
  465. <View
  466. style={{
  467. backgroundColor: '#FFF',
  468. paddingVertical: 10,
  469. flexDirection: 'row',
  470. borderBottomColor: '#EEE',
  471. borderBottomWidth: 1,
  472. }}
  473. >
  474. <TouchableOpacity
  475. onPress={() => this.HeadScreening('Receivable')}
  476. style={{
  477. flex: 1,
  478. alignItems: 'center',
  479. borderRightColor: '#EEE',
  480. borderRightWidth: 1,
  481. }}
  482. >
  483. <View style={{ flexDirection: 'row' }}>
  484. <Text
  485. numberOfLines={1}
  486. style={{
  487. fontSize: 14,
  488. lineHeight: 20,
  489. letterSpacing: 0.17,
  490. color:
  491. this.state.filiter == 'Receivable'
  492. ? this.state.activeSection ? '#333' : '#E70013'
  493. : '#333',
  494. marginRight: 5,
  495. }}
  496. >
  497. {this.state.receivableOrgan}
  498. </Text>
  499. <Icon
  500. name="icon-icon-xialaxiaosanjiao"
  501. size={14}
  502. color={
  503. this.state.filiter == 'Receivable'
  504. ? this.state.activeSection ? '#999' : '#E70013'
  505. : '#999'
  506. }
  507. style={{ alignSelf: 'center' }}
  508. />
  509. </View>
  510. </TouchableOpacity>
  511. <TouchableOpacity
  512. onPress={() => this.HeadScreening('Sale')}
  513. style={{
  514. flex: 1,
  515. alignItems: 'center',
  516. }}
  517. >
  518. <View style={{ flexDirection: 'row' }}>
  519. <Text
  520. numberOfLines={1}
  521. style={{
  522. fontSize: 14,
  523. lineHeight: 20,
  524. letterSpacing: 0.17,
  525. color:
  526. this.state.filiter == 'Sale'
  527. ? this.state.activeSection ? '#333' : '#E70013'
  528. : '#333',
  529. marginRight: 5,
  530. }}
  531. >
  532. {this.state.saleOrgan || '-'}
  533. </Text>
  534. <Icon
  535. name="icon-icon-xialaxiaosanjiao"
  536. size={14}
  537. color={
  538. this.state.filiter == 'Sale'
  539. ? this.state.activeSection ? '#999' : '#E70013'
  540. : '#999'
  541. }
  542. style={{ alignSelf: 'center' }}
  543. />
  544. </View>
  545. </TouchableOpacity>
  546. </View>
  547. <FlatList
  548. keyExtractor={(item, index) => index}
  549. data={payStaticData}
  550. renderItem={({ item, index }) => this.receiveList(item, index)}
  551. />
  552. {/* 下拉遮罩 */}
  553. {!this.state.activeSection || !this.state.dateActive ? (
  554. <View
  555. style={{
  556. position: 'absolute',
  557. width: width,
  558. height: height,
  559. backgroundColor: '#000',
  560. opacity: 0.5,
  561. top: 101,
  562. }}
  563. />
  564. ) : null}
  565. {/* 筛选条件下拉 */}
  566. <View
  567. style={{
  568. position: 'absolute',
  569. top: 101,
  570. left: 0,
  571. width: width,
  572. backgroundColor: '#FFF',
  573. }}
  574. >
  575. <Collapsible collapsed={this.state.activeSection}>
  576. <FlatList
  577. keyExtractor={(item, index) => index}
  578. data={this.state.data}
  579. extraData={this.state}
  580. renderItem={({ item, index }) =>
  581. this.collapsibleData(item, index)
  582. }
  583. />
  584. </Collapsible>
  585. </View>
  586. <SelectTimeCom
  587. dateActive={this.state.dateActive}
  588. dateCb={data => this.dateCbFn(data)}
  589. />
  590. </View>
  591. )
  592. }
  593. }
  594. const styles = StyleSheet.create({
  595. container: {
  596. flex: 1,
  597. },
  598. pngstyle: {
  599. width: width,
  600. },
  601. buttonStyle: {
  602. backgroundColor: 'transparent',
  603. flexDirection: 'column',
  604. alignItems: 'center',
  605. },
  606. buttonText: {
  607. marginTop: 9,
  608. fontSize: 14,
  609. color: '#FFF',
  610. },
  611. })
  612. export default PayReconciliation