CostReconciliation.js 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729
  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. DatePickerAndroid,
  13. Platform,
  14. } from 'react-native'
  15. import { connect } from 'react-redux'
  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. import { setNowFormatDate } from '../../../utils/utils'
  22. const { width, height } = Dimensions.get('window')
  23. const data = [
  24. { proTitle: 'A应收组织', Quota: 8000, Occupancy: 2330 },
  25. { proTitle: 'B应收组织', Quota: 4000, Occupancy: 2330 },
  26. { proTitle: 'C应收组织', Quota: 12000, Occupancy: 5748 },
  27. ]
  28. @connect(({ theme, mine_header, mine }) => ({ ...theme, ...mine_header, mine }))
  29. class CostReconciliation extends Component {
  30. constructor(props) {
  31. const date = new Date()
  32. super(props)
  33. this.state = {
  34. reflsh: true,
  35. castAmtData: [],
  36. FinancialOrg: props.mine.FinancialOrg,
  37. Show_FinaOrg:
  38. props.mine.FinancialOrg.length > 0
  39. ? props.mine.FinancialOrg[0].finanOrgName
  40. : '应收组织',
  41. Search_FinaOrg:
  42. props.mine.FinancialOrg.length > 0
  43. ? props.mine.FinancialOrg[0].finanOrgId
  44. : '',
  45. activeSection: true,
  46. dateActive: true,
  47. echartData: data[0],
  48. touchIndex: 0,
  49. // 开始时间 --显示用
  50. startTime: setNowFormatDate(true),
  51. // 结束时间 ---显示用
  52. endTime: setNowFormatDate(),
  53. }
  54. }
  55. componentDidMount = () => {
  56. this.searchTouch()
  57. }
  58. searchTouch() {
  59. this.props
  60. .dispatch(
  61. createAction('mine_header/CastAmountSaga')({
  62. pageInfo: { size: 5, page: 0 },
  63. castAmt: [],
  64. searchInfo: this.searchCast(),
  65. })
  66. )
  67. .finally(() => {
  68. if (this.props.castAmtData) {
  69. this.state.castAmtData = this.props.castAmtData
  70. this.setState({
  71. castAmtData: this.props.castAmtData,
  72. })
  73. }
  74. })
  75. }
  76. searchCast() {
  77. postInfo = {
  78. search_IN_financeOrg: this.state.Search_FinaOrg,
  79. search_IN_customer: CUSTOMERINFO.id,
  80. }
  81. if (this.state.startTime) {
  82. postInfo.search_GTE_billDate_date = new Date(
  83. this.state.startTime
  84. ).getTime()
  85. }
  86. if (this.state.endTime) {
  87. postInfo.search_LT_billDate_date = new Date(this.state.endTime).getTime()
  88. }
  89. return postInfo
  90. }
  91. dateCbFn(data) {
  92. if (data.fn && data.fn == 'cancel') {
  93. this.setState({ dateActive: true })
  94. } else {
  95. this.state.startTime = data.startTime
  96. this.state.endTime = data.endTime
  97. this.setState({
  98. dateActive: true,
  99. })
  100. this.searchTouch()
  101. }
  102. }
  103. // 头部
  104. header() {
  105. return (
  106. <View
  107. style={{
  108. height: HEADERSTYLE.height,
  109. paddingTop: HEADERSTYLE.paddingTop + 5,
  110. backgroundColor: '#fff',
  111. borderBottomColor: '#eee',
  112. borderBottomWidth: 1 / PixelRatio.get(),
  113. }}
  114. >
  115. <View
  116. style={{
  117. flex: 1,
  118. justifyContent: 'center',
  119. }}
  120. >
  121. <TouchableOpacity
  122. style={{ position: 'absolute', left: 10, flexDirection: 'row' }}
  123. onPress={() => this.props.dispatch(NavigationActions.back())}
  124. >
  125. <Icon
  126. name="icon-icon-fanhui"
  127. size={20}
  128. color={'#666'}
  129. style={{ marginTop: 4 }}
  130. />
  131. <Text
  132. style={{
  133. fontSize: 14,
  134. lineHeight: 20,
  135. color: '#666',
  136. alignSelf: 'center',
  137. }}
  138. >
  139. 返回
  140. </Text>
  141. </TouchableOpacity>
  142. <Text
  143. style={{
  144. alignSelf: 'center',
  145. fontSize: 18,
  146. lineHeight: 25,
  147. letterSpacing: 0.19,
  148. color: '#333',
  149. }}
  150. >
  151. 费用对账
  152. </Text>
  153. <View
  154. style={{ position: 'absolute', right: 10, flexDirection: 'row' }}
  155. >
  156. <TouchableOpacity
  157. style={{ marginRight: 10 }}
  158. onPress={() =>
  159. this.setState({
  160. dateActive: !this.state.dateActive,
  161. activeSection: true,
  162. reflsh: false,
  163. })
  164. }
  165. >
  166. <Icon name="icon-icon-rili" size={24} color={'#666'} />
  167. </TouchableOpacity>
  168. </View>
  169. </View>
  170. </View>
  171. )
  172. }
  173. _topOrganization(item, index) {
  174. return (
  175. <TouchableOpacity
  176. activeOpacity={1}
  177. onPress={() => {
  178. this.state.Search_FinaOrg = item.finanOrgId
  179. this.setState({
  180. activeSection: true,
  181. Show_FinaOrg: item.finanOrgName,
  182. touchIndex: index,
  183. reflsh: true,
  184. })
  185. this.searchTouch()
  186. }}
  187. style={{
  188. flexDirection: 'row',
  189. justifyContent: 'space-between',
  190. padding: 10,
  191. backgroundColor: '#FFF',
  192. }}
  193. >
  194. <Text
  195. style={{
  196. fontSize: 14,
  197. lineHeight: 20,
  198. letterSpacing: 0.17,
  199. color: '#333',
  200. }}
  201. >
  202. {item.finanOrgName}
  203. </Text>
  204. {this.state.touchIndex == index ? (
  205. <Icon name="icon-icon-duigou" size={16} color={'red'} />
  206. ) : null}
  207. </TouchableOpacity>
  208. )
  209. }
  210. // async TimeAndroid(mark) {
  211. // const { action, year, month, day } = await DatePickerAndroid.open({
  212. // date: new Date(),
  213. // // minDate: new Date(),
  214. // mode: "spinner"
  215. // });
  216. // if (action !== DatePickerAndroid.dismissedAction) {
  217. // let newDate = `${year}-${month + 1}-${day}`;
  218. // if (mark == "start") {
  219. // if (newDate <= this.state.endTime) {
  220. // this.setState({
  221. // startTime: newDate
  222. // });
  223. // }
  224. // } else if (mark == "end") {
  225. // if (this.state.startTime <= newDate) {
  226. // this.setState({
  227. // endTime: newDate
  228. // });
  229. // }
  230. // }
  231. // // 这里开始可以处理用户选好的年月日三个参数:year, month (0-11), day
  232. // }
  233. // }
  234. render() {
  235. const { appTheme } = this.props
  236. const { castAmtData } = this.state
  237. // echart 刷新问题 后期优化
  238. let echartDatas = {
  239. proTitle: this.state.reflsh,
  240. creditBalance: castAmtData.endBalance,
  241. creditLimit: 0,
  242. }
  243. return (
  244. <View
  245. style={[
  246. styles.container,
  247. { backgroundColor: appTheme.backgroundColor },
  248. ]}
  249. >
  250. <StatusBar
  251. animated={true}
  252. barStyle={appTheme.barStyle}
  253. // barStyle={"dark-content"}
  254. backgroundColor={'transparent'}
  255. translucent={true}
  256. />
  257. {this.header()}
  258. <ScrollView style={{ flex: 1 }}>
  259. <TouchableOpacity
  260. activeOpacity={1}
  261. onPress={() =>
  262. this.setState({
  263. activeSection: !this.state.activeSection,
  264. dateActive: true,
  265. reflsh: false,
  266. })
  267. }
  268. style={{
  269. flexDirection: 'row',
  270. padding: 10,
  271. backgroundColor: '#FFF',
  272. borderBottomColor: '#DDD',
  273. borderBottomWidth: 1 / PixelRatio.get(),
  274. }}
  275. >
  276. <Text
  277. style={{
  278. fontSize: 14,
  279. lineHeight: 20,
  280. letterSpacing: 0.17,
  281. color: '#333',
  282. }}
  283. >
  284. {this.state.Show_FinaOrg}
  285. </Text>
  286. <Icon
  287. name="icon-icon-xialaxiaosanjiao"
  288. size={16}
  289. color={'#333'}
  290. style={[
  291. !this.state.activeSection
  292. ? { transform: [{ rotate: '180deg' }] }
  293. : {},
  294. {
  295. marginLeft: 10,
  296. marginTop: 2,
  297. },
  298. ]}
  299. />
  300. </TouchableOpacity>
  301. {/* 图表 */}
  302. <View
  303. style={{
  304. backgroundColor: '#FFF',
  305. borderBottomColor: '#DDD',
  306. borderBottomWidth: 1 / PixelRatio.get(),
  307. }}
  308. >
  309. <Echarts
  310. data={echartDatas}
  311. height={240}
  312. color={['#FF7D64', '#FF7D64']}
  313. bottomText={'期末余额'}
  314. bottom={'27%'} //字体距离底的高度
  315. fontSize={24} //余额数字字体
  316. />
  317. </View>
  318. {/* 余额显示 */}
  319. <View
  320. style={{
  321. backgroundColor: '#FFF',
  322. paddingVertical: 17,
  323. flexDirection: 'row',
  324. borderBottomColor: '#DDD',
  325. borderBottomWidth: 1 / PixelRatio.get(),
  326. }}
  327. >
  328. <View style={{ flex: 1, paddingHorizontal: 10 }}>
  329. <Text
  330. style={{
  331. fontSize: 13,
  332. lineHeight: 18,
  333. letterSpacing: 0.16,
  334. color: '#999',
  335. }}
  336. >
  337. 期初余额
  338. </Text>
  339. <Text
  340. style={{
  341. fontSize: 15,
  342. lineHeight: 21,
  343. letterSpacing: 0.18,
  344. color: '#333',
  345. marginTop: 7,
  346. }}
  347. >
  348. {castAmtData.openBalance || 0}
  349. </Text>
  350. </View>
  351. <View
  352. style={{
  353. height: 30,
  354. width: 1,
  355. backgroundColor: '#DDD',
  356. alignSelf: 'center',
  357. }}
  358. />
  359. <View
  360. style={{
  361. flex: 1,
  362. paddingHorizontal: 10,
  363. }}
  364. >
  365. <Text
  366. style={{
  367. fontSize: 13,
  368. lineHeight: 18,
  369. letterSpacing: 0.16,
  370. color: '#999',
  371. }}
  372. >
  373. 增加
  374. </Text>
  375. <Text
  376. style={{
  377. fontSize: 15,
  378. lineHeight: 21,
  379. letterSpacing: 0.18,
  380. color: '#333',
  381. marginTop: 7,
  382. }}
  383. >
  384. {castAmtData.castIncre || 0}
  385. </Text>
  386. </View>
  387. <View
  388. style={{
  389. height: 30,
  390. width: 1,
  391. backgroundColor: '#DDD',
  392. alignSelf: 'center',
  393. }}
  394. />
  395. <View
  396. style={{
  397. flex: 1,
  398. paddingHorizontal: 10,
  399. }}
  400. >
  401. <Text
  402. style={{
  403. fontSize: 13,
  404. lineHeight: 18,
  405. letterSpacing: 0.16,
  406. color: '#999',
  407. }}
  408. >
  409. 减少
  410. </Text>
  411. <Text
  412. style={{
  413. fontSize: 15,
  414. lineHeight: 21,
  415. letterSpacing: 0.18,
  416. color: '#333',
  417. marginTop: 7,
  418. }}
  419. >
  420. {castAmtData.castReduce || 0}
  421. </Text>
  422. </View>
  423. </View>
  424. {/* 查看详情 */}
  425. <View style={{ paddingVertical: 30, backgroundColor: '#FFF' }}>
  426. <TouchableOpacity
  427. onPress={() =>
  428. this.props.dispatch(
  429. NavigationActions.navigate({
  430. routeName: 'ReconciliationDetail',
  431. params: {
  432. comeFrom: 'Cost',
  433. startTime: this.state.startTime,
  434. endTime: this.state.endTime,
  435. Search_FinaOrg: this.state.Search_FinaOrg,
  436. },
  437. })
  438. )
  439. }
  440. style={{
  441. alignSelf: 'center',
  442. paddingVertical: 9,
  443. paddingHorizontal: 36,
  444. backgroundColor: '#F56151',
  445. borderRadius: 100,
  446. }}
  447. >
  448. <Text
  449. style={{
  450. fontSize: 14,
  451. lineHeight: 20,
  452. letterSpacing: 0.17,
  453. color: '#FFF',
  454. }}
  455. >
  456. 查看详情
  457. </Text>
  458. </TouchableOpacity>
  459. </View>
  460. {/* 下拉遮罩 */}
  461. {!this.state.activeSection || !this.state.dateActive ? (
  462. <View
  463. style={{
  464. position: 'absolute',
  465. width: width,
  466. height: height,
  467. backgroundColor: '#000',
  468. opacity: 0.5,
  469. top: 101,
  470. }}
  471. />
  472. ) : null}
  473. {/* 应收组织折叠 ---悬浮*/}
  474. <View
  475. style={{ position: 'absolute', top: 40, left: 0, width: width }}
  476. >
  477. <Collapsible collapsed={this.state.activeSection}>
  478. <FlatList
  479. keyExtractor={(item, index) => item.id + index}
  480. data={this.state.FinancialOrg}
  481. extraData={this.state.touchIndex}
  482. renderItem={({ item, index }) =>
  483. this._topOrganization(item, index)
  484. }
  485. />
  486. </Collapsible>
  487. </View>
  488. {/* 时间弹窗 */}
  489. <SelectTimeCom
  490. dateActive={this.state.dateActive}
  491. dateCb={data => this.dateCbFn(data)}
  492. />
  493. {/* <SelectTime
  494. ref={showTime => (this.showTime = showTime)}
  495. cb={(date, mark) => {
  496. let newDate =
  497. date &&
  498. `${date.getFullYear()}-${date.getMonth() +
  499. 1}-${date.getDate()}`;
  500. if (mark == "start") {
  501. // if (newDate <= this.endTime) {
  502. this.setState({
  503. startTime: newDate
  504. });
  505. // }
  506. } else if (mark == "end") {
  507. // if (this.startTime <= newDate) {
  508. this.setState({
  509. endTime: newDate
  510. });
  511. // }
  512. }
  513. }}
  514. /> */}
  515. {/* 时间选择下拉 */}
  516. {/* <View
  517. style={{
  518. position: "absolute",
  519. left: 0,
  520. width: width,
  521. backgroundColor: "#FFF"
  522. }}
  523. >
  524. <Collapsible collapsed={this.state.dateActive}>
  525. <View>
  526. <View
  527. style={{
  528. flexDirection: "row",
  529. justifyContent: "space-between",
  530. padding: 20,
  531. marginBottom: 20
  532. }}
  533. >
  534. <View>
  535. <Text
  536. style={{
  537. fontSize: 13,
  538. lineHeight: 18,
  539. letterSpacing: 0.16,
  540. color: "#333",
  541. alignSelf: "center"
  542. }}
  543. >
  544. 开始时间
  545. </Text>
  546. <TouchableOpacity
  547. onPress={() =>
  548. Platform.OS == "ios"
  549. ? this.showTime._openModal("start")
  550. : this.TimeAndroid("start")
  551. }
  552. style={{
  553. paddingHorizontal: 40,
  554. paddingVertical: 7,
  555. marginTop: 16,
  556. borderColor: "#DDD",
  557. borderWidth: 1,
  558. borderRadius: 100
  559. }}
  560. >
  561. <Text
  562. style={{
  563. fontSize: 13,
  564. lineHeight: 18,
  565. letterSpacing: 0.16,
  566. color: "#333"
  567. }}
  568. >
  569. {this.state.startTime}
  570. </Text>
  571. </TouchableOpacity>
  572. </View>
  573. <View style={{ paddingTop: 37 }}>
  574. <Text
  575. style={{
  576. fontSize: 18,
  577. lineHeight: 25,
  578. letterSpacing: 0.22,
  579. color: "#333"
  580. }}
  581. >
  582. ~
  583. </Text>
  584. </View>
  585. <View>
  586. <Text
  587. style={{
  588. fontSize: 13,
  589. lineHeight: 18,
  590. letterSpacing: 0.16,
  591. color: "#333",
  592. alignSelf: "center"
  593. }}
  594. >
  595. 结束时间
  596. </Text>
  597. <TouchableOpacity
  598. onPress={() =>
  599. Platform.OS == "ios"
  600. ? this.showTime._openModal("end")
  601. : this.TimeAndroid("end")
  602. }
  603. style={{
  604. paddingHorizontal: 40,
  605. paddingVertical: 7,
  606. marginTop: 16,
  607. borderColor: "#DDD",
  608. borderWidth: 1,
  609. borderRadius: 100
  610. }}
  611. >
  612. <Text
  613. style={{
  614. fontSize: 13,
  615. lineHeight: 18,
  616. letterSpacing: 0.16,
  617. color: "#333"
  618. }}
  619. >
  620. {this.state.endTime}
  621. </Text>
  622. </TouchableOpacity>
  623. </View>
  624. </View>
  625. <View style={{ height: 40, flexDirection: "row" }}>
  626. <TouchableOpacity
  627. onPress={() => {
  628. this.setState({
  629. dateActive: true,
  630. startTime: this.startTime,
  631. endTime: this.endTime
  632. });
  633. }}
  634. style={{
  635. width: width / 2,
  636. backgroundColor: "#FFF",
  637. justifyContent: "center"
  638. }}
  639. >
  640. <Text
  641. style={{
  642. fontSize: 14,
  643. lineHeight: 22,
  644. letterSpacing: 0.21,
  645. color: "#333",
  646. alignSelf: "center"
  647. }}
  648. >
  649. 取消
  650. </Text>
  651. </TouchableOpacity>
  652. <TouchableOpacity
  653. onPress={() => {
  654. this.startTime = this.state.startTime;
  655. this.endTime = this.state.endTime;
  656. this.setState({
  657. dateActive: true,
  658. reflsh: true
  659. });
  660. this.searchTouch();
  661. }}
  662. style={{
  663. width: width / 2,
  664. backgroundColor: "#E70013",
  665. justifyContent: "center"
  666. }}
  667. >
  668. <Text
  669. style={{
  670. fontSize: 14,
  671. lineHeight: 22,
  672. letterSpacing: 0.21,
  673. color: "#FFF",
  674. alignSelf: "center"
  675. }}
  676. >
  677. 确定
  678. </Text>
  679. </TouchableOpacity>
  680. </View>
  681. </View>
  682. </Collapsible>
  683. </View> */}
  684. </ScrollView>
  685. </View>
  686. )
  687. }
  688. }
  689. const styles = StyleSheet.create({
  690. container: {
  691. flex: 1,
  692. },
  693. pngstyle: {
  694. width: width,
  695. },
  696. buttonStyle: {
  697. backgroundColor: 'transparent',
  698. flexDirection: 'column',
  699. alignItems: 'center',
  700. },
  701. buttonText: {
  702. marginTop: 9,
  703. fontSize: 14,
  704. color: '#FFF',
  705. },
  706. })
  707. export default CostReconciliation