Account.js 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646
  1. import React, { Component } from 'react'
  2. import {
  3. StyleSheet,
  4. ScrollView,
  5. View,
  6. Text,
  7. Dimensions,
  8. StatusBar,
  9. TouchableOpacity,
  10. PixelRatio,
  11. FlatList,
  12. RefreshControl,
  13. } from 'react-native'
  14. import { connect } from 'react-redux'
  15. import { ReturnDate } from '../../../utils/utils'
  16. import Icon from '../../../components/Iconfont/Iconfont'
  17. import { NavigationActions, createAction } from '../../../utils'
  18. import Echarts from '../../../components/echarts/EchartsComponent'
  19. import Collapsible from 'react-native-collapsible'
  20. import SelectTimeCom from '../../../components/selectTime/selectTime'
  21. const { width, height } = Dimensions.get('window')
  22. const data = [
  23. { proTitle: 'A应收组织', Quota: 8000, Occupancy: 2330 },
  24. { proTitle: 'B应收组织', Quota: 4000, Occupancy: 2330 },
  25. { proTitle: 'C应收组织', Quota: 12000, Occupancy: 5748 },
  26. ]
  27. @connect(({ theme, mine, mine_account }) => ({
  28. ...theme,
  29. ...mine,
  30. ...mine_account,
  31. }))
  32. class Account extends Component {
  33. constructor(props) {
  34. super(props)
  35. this.state = {
  36. reflsh: true,
  37. activeSection: true,
  38. selectText: '全部',
  39. // props.FinancialOrg && props.FinancialOrg.length > 0
  40. // ? props.FinancialOrg[0].finanOrgName
  41. // : "",
  42. finanOrgId: '',
  43. // props.FinancialOrg && props.FinancialOrg.length > 0
  44. // ? props.FinancialOrg[0].finanOrgId
  45. // : "",
  46. echartData: '',
  47. touchIndex: 0,
  48. listIndex: 'dsadsa',
  49. dateActive: true, //时间折叠-true为关
  50. startTime: '',
  51. endTime: '',
  52. IsScrollEnabled: true,
  53. }
  54. // console.disableYellowBox = true;
  55. this.page = 0
  56. this.size = 5
  57. }
  58. componentDidMount() {
  59. // 可用财务组织
  60. this.props.dispatch(
  61. createAction('mine/getCusSup')({
  62. customerId: CUSTOMERINFO.id,
  63. customerRankCode: CUSTOMERINFO.customerRankCode,
  64. })
  65. )
  66. this.FindAmount()
  67. this.onRefresh()
  68. }
  69. FindAmount() {
  70. // 预付余额
  71. this.props.dispatch(
  72. createAction('mine_account/getAccountBalance')({
  73. searchInfo: { financeOrgId: this.state.finanOrgId },
  74. })
  75. )
  76. }
  77. onRefresh() {
  78. this.props.dispatch(
  79. createAction('mine_account/AccountSagas')({
  80. searchInfo: this.searchInfoFn(),
  81. pageInfo: { size: 5, page: 0 },
  82. accountReturn: [],
  83. })
  84. )
  85. }
  86. searchInfoFn() {
  87. let searchData = {}
  88. // 时间格式需要search_ 和 _date
  89. if (this.state.startTime) {
  90. searchData.search_GTE_creationTime_date = new Date(
  91. this.state.startTime
  92. ).getTime()
  93. }
  94. if (this.state.endTime) {
  95. searchData.search_LT_creationTime_date = new Date(
  96. this.state.endTime
  97. ).getTime()
  98. }
  99. return searchData
  100. }
  101. // 头部
  102. header() {
  103. return (
  104. <View
  105. style={{
  106. height: HEADERSTYLE.height,
  107. paddingTop: HEADERSTYLE.paddingTop + 5,
  108. backgroundColor: '#fff',
  109. borderBottomColor: '#eee',
  110. borderBottomWidth: 1 / PixelRatio.get(),
  111. }}
  112. >
  113. <View
  114. style={{
  115. flex: 1,
  116. justifyContent: 'center',
  117. }}
  118. >
  119. <TouchableOpacity
  120. style={{ position: 'absolute', left: 10, flexDirection: 'row' }}
  121. onPress={() => this.props.dispatch(NavigationActions.back())}
  122. >
  123. <Icon
  124. name="icon-icon-fanhui"
  125. size={20}
  126. color={'#666'}
  127. style={{ marginTop: 4 }}
  128. />
  129. <Text
  130. style={{
  131. fontSize: 14,
  132. lineHeight: 20,
  133. color: '#666',
  134. alignSelf: 'center',
  135. }}
  136. >
  137. 返回
  138. </Text>
  139. </TouchableOpacity>
  140. <Text
  141. style={{
  142. alignSelf: 'center',
  143. fontSize: 18,
  144. lineHeight: 25,
  145. letterSpacing: 0.19,
  146. color: '#333',
  147. }}
  148. >
  149. 账户余额
  150. </Text>
  151. <View
  152. style={{ position: 'absolute', right: 10, flexDirection: 'row' }}
  153. >
  154. <TouchableOpacity
  155. onPress={() =>
  156. this.setState({
  157. dateActive: !this.state.dateActive,
  158. activeSection: true,
  159. reflsh: false,
  160. })
  161. }
  162. >
  163. <Icon name="icon-icon-rili" size={24} color={'#333'} />
  164. </TouchableOpacity>
  165. </View>
  166. </View>
  167. </View>
  168. )
  169. }
  170. _topOrganization(item, index) {
  171. return (
  172. <TouchableOpacity
  173. onPress={() => {
  174. this.state.finanOrgId = item.finanOrgId
  175. this.setState({
  176. activeSection: true,
  177. selectText: item.finanOrgName,
  178. finanOrgId: item.finanOrgId,
  179. echartData: item,
  180. touchIndex: index,
  181. reflsh: true,
  182. })
  183. this.FindAmount()
  184. }}
  185. style={{
  186. flexDirection: 'row',
  187. justifyContent: 'space-between',
  188. padding: 10,
  189. backgroundColor: '#FFF',
  190. }}
  191. >
  192. <Text
  193. style={{
  194. fontSize: 14,
  195. lineHeight: 20,
  196. letterSpacing: 0.17,
  197. color: '#333',
  198. }}
  199. >
  200. {item.finanOrgName}
  201. </Text>
  202. {this.state.touchIndex == index ? (
  203. <Icon name="icon-icon-duigou" size={16} color={'red'} />
  204. ) : null}
  205. </TouchableOpacity>
  206. )
  207. }
  208. jobList(item, key) {
  209. const stateList = [
  210. '',
  211. '保存',
  212. '提交',
  213. '审批通过',
  214. '审批中',
  215. '收回',
  216. '审批不过',
  217. ]
  218. return (
  219. <View>
  220. <TouchableOpacity
  221. onPress={() =>
  222. this.state.listIndex == key
  223. ? this.setState({ listIndex: 'dsadsa', reflsh: false })
  224. : this.setState({ listIndex: key, reflsh: false })
  225. }
  226. key={key}
  227. style={{ backgroundColor: '#FFF', flex: 1, marginTop: 10 }}
  228. >
  229. <View
  230. style={{
  231. borderBottomColor: '#EEE',
  232. borderBottomWidth: 1 / PixelRatio.get(),
  233. flexDirection: 'row',
  234. padding: 10,
  235. justifyContent: 'space-between',
  236. }}
  237. >
  238. <View style={{ flexDirection: 'row' }}>
  239. <Text
  240. style={{
  241. fontSize: 13,
  242. lineHeight: 18,
  243. letterSpacing: 0.16,
  244. color: '#333',
  245. }}
  246. >
  247. {item.code}
  248. </Text>
  249. <Text
  250. style={{
  251. fontSize: 13,
  252. lineHeight: 16,
  253. color: '#333',
  254. marginLeft: 10,
  255. }}
  256. >
  257. {item.isRedflush == 0 ? '付款单' : '退款单'}
  258. </Text>
  259. <Text
  260. style={{
  261. fontSize: 13,
  262. lineHeight: 16,
  263. color: item.billreceiptState == 3 ? '#59C152' : '#E14C46',
  264. marginLeft: 10,
  265. }}
  266. >
  267. {item.billreceiptState ? stateList[item.billreceiptState] : ''}
  268. </Text>
  269. </View>
  270. <Text style={{ fontSize: 12, lineHeight: 17, color: '#999' }}>
  271. {ReturnDate(item.creationTime, true, '/')}
  272. </Text>
  273. </View>
  274. <View style={{ padding: 10, flexDirection: 'row' }}>
  275. <View style={{ flex: 1 }}>
  276. <Text
  277. style={{
  278. fontSize: 13,
  279. lineHeight: 18,
  280. letterSpacing: 0.16,
  281. color: '#999',
  282. }}
  283. >
  284. 付款金额
  285. </Text>
  286. <Text
  287. style={{
  288. fontSize: 15,
  289. lineHeight: 21,
  290. letterSpacing: 0.18,
  291. color: '#333',
  292. marginTop: 10,
  293. }}
  294. >
  295. {item.money}
  296. </Text>
  297. </View>
  298. <View style={{ flex: 1 }}>
  299. <Text
  300. style={{
  301. fontSize: 13,
  302. lineHeight: 18,
  303. letterSpacing: 0.16,
  304. color: '#999',
  305. }}
  306. >
  307. 核销金额
  308. </Text>
  309. <Text
  310. style={{
  311. fontSize: 15,
  312. lineHeight: 21,
  313. letterSpacing: 0.18,
  314. color: '#333',
  315. marginTop: 10,
  316. }}
  317. >
  318. {item.alreadyMoney || 0}
  319. </Text>
  320. </View>
  321. <View style={{ flex: 1 }}>
  322. <Text
  323. style={{
  324. fontSize: 13,
  325. lineHeight: 18,
  326. letterSpacing: 0.16,
  327. color: '#999',
  328. }}
  329. >
  330. 余额
  331. </Text>
  332. <Text
  333. style={{
  334. fontSize: 15,
  335. lineHeight: 21,
  336. letterSpacing: 0.18,
  337. color: '#E70013',
  338. marginTop: 10,
  339. }}
  340. >
  341. {item.remainMoney || 0}
  342. </Text>
  343. </View>
  344. </View>
  345. </TouchableOpacity>
  346. <Collapsible collapsed={this.state.listIndex !== key}>
  347. <View
  348. style={{
  349. padding: 10,
  350. marginHorizontal: 10,
  351. backgroundColor: '#FFFBF2',
  352. }}
  353. >
  354. <Text style={{ fontSize: 13, lineHeight: 22, color: '#666' }}>
  355. 结算方式:{item.settleMethodName}
  356. </Text>
  357. <Text style={{ fontSize: 13, lineHeight: 22, color: '#666' }}>
  358. 收款银行账户:{item.receiptAccountAccountNumber}
  359. </Text>
  360. <Text style={{ fontSize: 13, lineHeight: 22, color: '#666' }}>
  361. 产品线:{item.productLineName}
  362. </Text>
  363. <Text style={{ fontSize: 13, lineHeight: 22, color: '#666' }}>
  364. 收款业务类型:{item.billreceiptTypeName}
  365. </Text>
  366. <Text style={{ fontSize: 13, lineHeight: 22, color: '#666' }}>
  367. 收款金额:{CURRENCY.currencySign}
  368. {item.money}
  369. </Text>
  370. <View
  371. style={{
  372. marginTop: 5,
  373. borderTopColor: '#ddd',
  374. borderTopWidth: 1,
  375. paddingVertical: 5,
  376. }}
  377. >
  378. <View
  379. style={{
  380. flexDirection: 'row',
  381. justifyContent: 'space-between',
  382. marginBottom: 5,
  383. }}
  384. >
  385. <Text style={{ fontSize: 13, color: '#333' }}>核销订单</Text>
  386. <Text style={{ fontSize: 13, color: '#333' }}>核销金额</Text>
  387. </View>
  388. <FlatList
  389. keyExtractor={(item, index) => index}
  390. data={item.billlistCheck}
  391. extraData={this.state.touchIndex}
  392. renderItem={({ item, index }) => (
  393. <View
  394. style={{
  395. flexDirection: 'row',
  396. justifyContent: 'space-between',
  397. }}
  398. >
  399. <Text style={{ fontSize: 12, color: '#666' }}>
  400. {item.checkCode || ''}
  401. </Text>
  402. <Text style={{ fontSize: 12, color: '#666' }}>
  403. {item.checkMoney || ''}
  404. </Text>
  405. </View>
  406. )}
  407. />
  408. </View>
  409. </View>
  410. </Collapsible>
  411. </View>
  412. )
  413. }
  414. dateCbFn(data) {
  415. if (data.fn && data.fn == 'cancel') {
  416. this.setState({ dateActive: true })
  417. } else {
  418. this.state.startTime = data.startTime
  419. this.state.endTime = data.endTime
  420. this.setState({
  421. dateActive: true,
  422. reflsh: true,
  423. })
  424. this.onRefresh()
  425. }
  426. }
  427. // 底部
  428. footerCom() {
  429. if (this.props.showFoot == 0) {
  430. return <View />
  431. } else if (this.props.showFoot == 1) {
  432. return (
  433. <View style={styles.footer}>
  434. <Text
  435. style={{
  436. fontSize: 14,
  437. lineHeight: 20,
  438. letterSpacing: 0.17,
  439. color: '#999',
  440. }}
  441. >
  442. 没有更多数据
  443. </Text>
  444. </View>
  445. )
  446. } else if (this.props.showFoot == 2) {
  447. return (
  448. <View style={styles.footer}>
  449. <ActivityIndicator />
  450. <Text>正在加载更多数据...</Text>
  451. </View>
  452. )
  453. }
  454. }
  455. render() {
  456. const { appTheme, accountData, accountBalance, totalPages } = this.props
  457. // echart 刷新问题 后期优化
  458. echartDatas = {
  459. proTitle: this.state.reflsh,
  460. creditBalance: accountBalance,
  461. creditLimit: 0,
  462. }
  463. return (
  464. <View
  465. style={[
  466. styles.container,
  467. { backgroundColor: appTheme.backgroundColor },
  468. ]}
  469. >
  470. <StatusBar
  471. animated={true}
  472. barStyle={appTheme.barStyle}
  473. // barStyle={"dark-content"}
  474. backgroundColor={'transparent'}
  475. translucent={true}
  476. />
  477. {this.header()}
  478. <View
  479. style={{ flex: 1 }}
  480. // scrollEnabled={false}
  481. // onScrollBeginDrag={() => {
  482. // console.log("开始");
  483. // this.setState({ IsScrollEnabled: true });
  484. // }}
  485. // onMomentumScrollEnd={() => {
  486. // console.log("结束");
  487. // this.setState({ IsScrollEnabled: false });
  488. // }}
  489. >
  490. <TouchableOpacity
  491. onPress={() =>
  492. this.setState({
  493. activeSection: !this.state.activeSection,
  494. reflsh: false,
  495. })
  496. }
  497. style={{
  498. flexDirection: 'row',
  499. padding: 7,
  500. backgroundColor: '#FFF',
  501. borderBottomColor: '#DDD',
  502. borderBottomWidth: 1 / PixelRatio.get(),
  503. }}
  504. >
  505. <Text
  506. style={{
  507. fontSize: 14,
  508. lineHeight: 20,
  509. letterSpacing: 0.17,
  510. color: '#333',
  511. }}
  512. >
  513. {this.state.selectText}
  514. </Text>
  515. <Icon
  516. name="icon-icon-xialaxiaosanjiao"
  517. size={16}
  518. color={'#333'}
  519. style={[
  520. !this.state.activeSection
  521. ? { transform: [{ rotate: '180deg' }] }
  522. : {},
  523. {
  524. marginLeft: 10,
  525. marginTop: 2,
  526. },
  527. ]}
  528. />
  529. </TouchableOpacity>
  530. {/* 图表 */}
  531. <View style={{ backgroundColor: '#FFF' }}>
  532. <Echarts
  533. data={echartDatas}
  534. height={200}
  535. color={['#FF7D64', '#FF7D64']}
  536. bottomText={'当前预付余额'}
  537. bottom={'27%'} //字体距离底的高度
  538. fontSize={24} //余额数字字体
  539. />
  540. </View>
  541. <FlatList
  542. keyExtractor={item => item.id}
  543. data={accountData}
  544. renderItem={({ item, index }) => this.jobList(item, index)}
  545. ListFooterComponent={this.footerCom.bind(this)}
  546. onEndReachedThreshold={0.1}
  547. onEndReached={e => {
  548. if (this.props.showFoot != 0) {
  549. return
  550. }
  551. if (this.page != 1 && this.page >= totalPages) {
  552. return
  553. } else {
  554. this.page++
  555. }
  556. this.props.dispatch(
  557. createAction('mine_account/AccountSagas')({
  558. accountReturn: accountData,
  559. pageInfo: { page: this.page, size: this.size },
  560. searchInfo: this.searchInfoFn(),
  561. forUse: 'slipOn',
  562. })
  563. )
  564. }}
  565. refreshControl={
  566. <RefreshControl
  567. refreshing={this.props.isRefreshing}
  568. onRefresh={this.onRefresh.bind(this)} //(()=>this.onRefresh)或者通过bind来绑定this引用来调用方法
  569. tintColor="red"
  570. title={this.props.isRefreshing ? '刷新中....' : '下拉刷新'}
  571. />
  572. }
  573. />
  574. {/* 下拉遮罩 */}
  575. {!this.state.activeSection || !this.state.dateActive ? (
  576. <View
  577. style={{
  578. position: 'absolute',
  579. width: width,
  580. height: height,
  581. backgroundColor: '#000',
  582. opacity: 0.5,
  583. top: 101,
  584. }}
  585. />
  586. ) : null}
  587. {/* 应收组织折叠 ---悬浮*/}
  588. <View
  589. style={{ position: 'absolute', top: 40, left: 0, width: width }}
  590. >
  591. <Collapsible collapsed={this.state.activeSection}>
  592. <FlatList
  593. keyExtractor={(item, index) => index}
  594. data={this.props.FinancialOrg}
  595. extraData={this.state.touchIndex}
  596. renderItem={({ item, index }) =>
  597. this._topOrganization(item, index)
  598. }
  599. />
  600. </Collapsible>
  601. </View>
  602. </View>
  603. <SelectTimeCom
  604. dateActive={this.state.dateActive}
  605. dateCb={data => this.dateCbFn(data)}
  606. />
  607. </View>
  608. )
  609. }
  610. }
  611. const styles = StyleSheet.create({
  612. container: {
  613. flex: 1,
  614. },
  615. footer: {
  616. flexDirection: 'row',
  617. height: 24,
  618. justifyContent: 'center',
  619. alignItems: 'center',
  620. marginBottom: 10,
  621. marginTop: 10,
  622. },
  623. })
  624. export default Account