Cost.js 32 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106
  1. import React, { Component } from 'react'
  2. import {
  3. StyleSheet,
  4. View,
  5. Text,
  6. Dimensions,
  7. StatusBar,
  8. TouchableOpacity,
  9. PixelRatio,
  10. FlatList,
  11. Platform,
  12. DatePickerAndroid,
  13. RefreshControl,
  14. ActivityIndicator,
  15. } from 'react-native'
  16. import { connect } from 'react-redux'
  17. import Input from '../../../components/input/index'
  18. import Icon from '../../../components/Iconfont/Iconfont'
  19. import { NavigationActions, createAction } from '../../../utils'
  20. import { ReturnDate, setNowFormatDate } from '../../../utils/utils'
  21. import Collapsible from 'react-native-collapsible'
  22. import SelectTime from '../../common/SelectTime'
  23. import moment from 'moment'
  24. const { width, height } = Dimensions.get('window')
  25. /**
  26. * 查询条件
  27. * search_IN_financeOrg:'', 财务组织 Id
  28. * search_EQ_billStatus:'', 订单状态 Code
  29. * search_EQ_billCode:'', Code
  30. * search_EQ_paymentMethod:'', 费用冲抵 Code
  31. * search_IN_saleOrg:'', 销售组织 Id
  32. * search_GTE_billDate_date, 开始时间
  33. * search_LT_billDate_date 结束时间
  34. */
  35. @connect(({ theme, mine_header, mine }) => ({
  36. ...theme,
  37. ...mine_header,
  38. ...mine,
  39. }))
  40. class Cost extends Component {
  41. constructor(props) {
  42. const date = new Date()
  43. super(props)
  44. this.state = {
  45. data: [],
  46. activeSection: true, //筛选条件折叠-true为关
  47. dateActive: true, //时间折叠-true为关
  48. filiter: 0,
  49. showSearch: false,
  50. // 应收组织Index
  51. receiveIndex: 0,
  52. // 销售组织Index
  53. saleIndex: 0,
  54. // 状态Index
  55. stateIndex: 0,
  56. // 冲抵Index
  57. offsetIndex: 0,
  58. // 应收组织
  59. receivableOrgan:
  60. props.FinancialOrg.length > 0
  61. ? props.FinancialOrg[0].organizationName
  62. : '',
  63. // 销售组织
  64. saleOrgan:
  65. props.SupplierInfo.length > 0
  66. ? props.SupplierInfo[0].saleOrganizationName
  67. : '',
  68. // 状态
  69. stateSelect: '订单状态',
  70. // 冲抵
  71. offsetSelect: '费用冲抵',
  72. // 开始时间
  73. startTime: setNowFormatDate(true),
  74. // 结束时间
  75. endTime: setNowFormatDate(),
  76. // 查询条件
  77. offsetSelectCode: '',
  78. stateSelectCode: '',
  79. saleOrganId: '',
  80. // props.SupplierInfo.length > 0
  81. // ? props.SupplierInfo[0].saleOrganizationId
  82. // : "",
  83. receivableOrganId:
  84. props.FinancialOrg.length > 0 ? props.FinancialOrg[0].finanOrgId : '',
  85. }
  86. this.startTime = 0
  87. // date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + date.getDate();
  88. this.endTime = 0
  89. // date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + date.getDate();
  90. this.page = 0
  91. this.size = 5
  92. }
  93. componentDidMount = () => {
  94. // 可用财务组织、销售组织
  95. this.props.dispatch(
  96. createAction('mine/getCusSup')({
  97. customerId: CUSTOMERINFO.id,
  98. customerRankCode: CUSTOMERINFO.customerRankCode,
  99. comeFrom: 'castBalance',
  100. })
  101. )
  102. this.props.dispatch(
  103. createAction('mine_header/CastSaga')({
  104. pageInfo: { size: 5, page: 0 },
  105. searchInfo: this.searchInfo(),
  106. castData: [],
  107. })
  108. )
  109. }
  110. searchInfo() {
  111. let searchInfo = {
  112. search_EQ_financeOrg: this.state.receivableOrganId,
  113. // search_IN_saleOrg: this.state.saleOrganId,
  114. search_EQ_customer: CUSTOMERINFO.id,
  115. }
  116. if (this.state.saleOrganId) {
  117. searchInfo.search_EQ_saleOrg = this.state.saleOrganId
  118. }
  119. if (this.state.offsetSelectCode) {
  120. searchInfo.search_EQ_paymentMethod = this.state.offsetSelectCode
  121. }
  122. if (this.state.stateSelectCode) {
  123. searchInfo.search_EQ_billStatus = this.state.stateSelectCode
  124. }
  125. if (this.startTime !== 0) {
  126. searchInfo.search_GTE_billDate_date = new Date(this.startTime).getTime()
  127. }
  128. if (this.endTime !== 0) {
  129. searchInfo.search_LT_billDate_date = new Date(this.endTime).getTime()
  130. }
  131. return searchInfo
  132. }
  133. onRefresh() {
  134. this.props.dispatch(
  135. createAction('mine_header/CastSaga')({
  136. castData: [],
  137. pageInfo: { page: 0, size: this.size },
  138. searchInfo: this.searchInfo(),
  139. })
  140. )
  141. this.page = 0
  142. }
  143. // 头部
  144. header() {
  145. return (
  146. <View
  147. style={{
  148. height: HEADERSTYLE.height,
  149. paddingTop: HEADERSTYLE.paddingTop + 5,
  150. backgroundColor: '#fff',
  151. borderBottomColor: '#eee',
  152. borderBottomWidth: 1 / PixelRatio.get(),
  153. }}
  154. >
  155. <View
  156. style={{
  157. flex: 1,
  158. justifyContent: 'center',
  159. }}
  160. >
  161. <TouchableOpacity
  162. style={{ position: 'absolute', left: 10, flexDirection: 'row' }}
  163. onPress={() => this.props.dispatch(NavigationActions.back())}
  164. >
  165. <Icon
  166. name="icon-icon-fanhui"
  167. size={20}
  168. color={'#666'}
  169. style={{ marginTop: 4 }}
  170. />
  171. <Text
  172. style={{
  173. fontSize: 14,
  174. lineHeight: 20,
  175. color: '#666',
  176. alignSelf: 'center',
  177. }}
  178. >
  179. 返回
  180. </Text>
  181. </TouchableOpacity>
  182. {this.state.showSearch ? (
  183. <Input
  184. autoFocus={this.state.showSearch}
  185. style={{
  186. marginLeft: 25,
  187. marginTop: 8,
  188. height: 28,
  189. width: width / 1.6,
  190. borderRadius: width / 2,
  191. alignSelf: 'center',
  192. marginBottom: 8,
  193. paddingLeft: 14,
  194. }}
  195. textStyle={{
  196. paddingLeft: 10,
  197. height: 32,
  198. fontSize: 11,
  199. padding: 0,
  200. }}
  201. iconSize={14}
  202. blurOnSubmit={true}
  203. textInputBacg={'#F5F5F5'}
  204. iconColor={'#CCC'}
  205. placeholderTextColor={'#CCC'}
  206. placeholderSize={8}
  207. onchangeFn={e => {
  208. this.setState({ activeSection: true })
  209. }}
  210. />
  211. ) : (
  212. <Text
  213. style={{
  214. alignSelf: 'center',
  215. fontSize: 18,
  216. lineHeight: 25,
  217. letterSpacing: 0.19,
  218. color: '#333',
  219. }}
  220. >
  221. 费用余额
  222. </Text>
  223. )}
  224. {this.state.showSearch ? (
  225. <TouchableOpacity
  226. onPress={() =>
  227. this.setState({ showSearch: false, activeSection: true })
  228. }
  229. style={{ position: 'absolute', right: 10, flexDirection: 'row' }}
  230. >
  231. <Text style={{ fontSize: 14, lineHeight: 20, color: '#666' }}>
  232. 取消
  233. </Text>
  234. </TouchableOpacity>
  235. ) : (
  236. <View
  237. style={{ position: 'absolute', right: 10, flexDirection: 'row' }}
  238. >
  239. <TouchableOpacity
  240. style={{ marginRight: 10 }}
  241. onPress={() =>
  242. this.setState({
  243. showSearch: true,
  244. activeSection: true,
  245. dateActive: true,
  246. })
  247. }
  248. >
  249. <Icon name="icon-icon-sousuo" size={24} color={'#333'} />
  250. </TouchableOpacity>
  251. <TouchableOpacity
  252. onPress={() =>
  253. this.setState({
  254. dateActive: !this.state.dateActive,
  255. activeSection: true,
  256. })
  257. }
  258. >
  259. <Icon name="icon-icon-rili" size={24} color={'#333'} />
  260. </TouchableOpacity>
  261. </View>
  262. )}
  263. </View>
  264. </View>
  265. )
  266. }
  267. costList(item) {
  268. return (
  269. <TouchableOpacity
  270. onPress={() => {
  271. this.props.dispatch(
  272. createAction('mine_header/CastDetailSaga')({ id: item.id })
  273. )
  274. this.props.dispatch(
  275. NavigationActions.navigate({
  276. routeName: 'CostDetail',
  277. params: { castData: item },
  278. })
  279. )
  280. }}
  281. style={{ padding: 10, marginTop: 10, backgroundColor: '#FFF' }}
  282. >
  283. <View
  284. style={{
  285. paddingBottom: 10,
  286. borderBottomColor: '#EEE',
  287. borderBottomWidth: 1,
  288. }}
  289. >
  290. <View
  291. style={{ flexDirection: 'row', justifyContent: 'space-between' }}
  292. >
  293. <View style={{ flexDirection: 'row' }}>
  294. <Text
  295. style={{
  296. fontSize: 13,
  297. lineHeight: 18,
  298. letterSpacing: 0.16,
  299. color: '#333',
  300. }}
  301. >
  302. {item.billCode}
  303. </Text>
  304. <Text
  305. style={{
  306. fontSize: 13,
  307. lineHeight: 16,
  308. color: '#333',
  309. marginLeft: 10,
  310. }}
  311. >
  312. {item.castTypeName}
  313. </Text>
  314. <Text
  315. style={{
  316. fontSize: 13,
  317. lineHeight: 16,
  318. color: '#59C152',
  319. marginLeft: 10,
  320. }}
  321. >
  322. 保存
  323. </Text>
  324. </View>
  325. <Text style={{ fontSize: 12, lineHeight: 17, color: '#999' }}>
  326. {ReturnDate(item.billDate, true)}
  327. </Text>
  328. </View>
  329. <Text
  330. style={{
  331. fontSize: 14,
  332. lineHeight: 20,
  333. letterSpacing: 0.17,
  334. color: '#333',
  335. marginTop: 4,
  336. }}
  337. >
  338. {item.customerName}
  339. </Text>
  340. </View>
  341. <View style={{ flexDirection: 'row', paddingTop: 10 }}>
  342. <View style={{ flex: 1 }}>
  343. <Text
  344. style={{
  345. fontSize: 13,
  346. lineHeight: 18,
  347. letterSpacing: 0.16,
  348. color: '#999',
  349. }}
  350. >
  351. 费用金额
  352. </Text>
  353. <Text
  354. style={{
  355. marginTop: 10,
  356. fontSize: 15,
  357. lineHeight: 21,
  358. letterSpacing: 0.18,
  359. color: '#333',
  360. }}
  361. >
  362. {item.castAmount}
  363. </Text>
  364. </View>
  365. <View style={{ flex: 1 }}>
  366. <Text
  367. style={{
  368. fontSize: 13,
  369. lineHeight: 18,
  370. letterSpacing: 0.16,
  371. color: '#999',
  372. }}
  373. >
  374. 余额
  375. </Text>
  376. <Text
  377. style={{
  378. marginTop: 10,
  379. fontSize: 15,
  380. lineHeight: 21,
  381. letterSpacing: 0.18,
  382. color: '#E70013',
  383. }}
  384. >
  385. {item.castBalance}
  386. </Text>
  387. </View>
  388. </View>
  389. </TouchableOpacity>
  390. )
  391. }
  392. collapsibleData(item, index) {
  393. return (
  394. <TouchableOpacity
  395. onPress={() => {
  396. switch (this.state.filiter) {
  397. case 'Receivable':
  398. this.state.receivableOrganId = item.finanOrgId
  399. this.setState({
  400. receivableOrgan: item.finanOrgName,
  401. receivableOrganId: item.finanOrgId,
  402. activeSection: true,
  403. receiveIndex: index,
  404. })
  405. break
  406. case 'Sale':
  407. this.state.saleOrganId = item.saleOrganizationId
  408. this.setState({
  409. saleOrgan: item.saleOrganizationName,
  410. saleOrganId: item.saleOrganizationId,
  411. activeSection: true,
  412. saleIndex: index,
  413. })
  414. break
  415. case 'State':
  416. this.state.stateSelectCode = item.code
  417. this.setState({
  418. stateSelect: item.name,
  419. // stateSelectCode: item.id,
  420. activeSection: true,
  421. stateIndex: index,
  422. })
  423. break
  424. case 'Offset':
  425. this.state.offsetSelectCode = item.code
  426. this.setState({
  427. offsetSelect: item.name,
  428. // offsetSelectCode: item.id,
  429. activeSection: true,
  430. offsetIndex: index,
  431. })
  432. break
  433. }
  434. this.props.dispatch(
  435. createAction('mine_header/CastSaga')({
  436. castData: [],
  437. pageInfo: { page: 0, size: this.size },
  438. searchInfo: this.searchInfo(),
  439. })
  440. )
  441. this.page = 0
  442. }}
  443. style={{
  444. flexDirection: 'row',
  445. padding: 10,
  446. justifyContent: 'space-between',
  447. }}
  448. >
  449. <Text style={{ fontSize: 13, lineHeight: 18, color: '#333' }}>
  450. {item.saleOrganizationName || item.finanOrgName || item.name}
  451. </Text>
  452. {this.state.filiter == 'Receivable' &&
  453. this.state.receiveIndex == index ? (
  454. <Icon name="icon-icon-duigou" size={16} color={'red'} />
  455. ) : null}
  456. {this.state.filiter == 'Sale' && this.state.saleIndex == index ? (
  457. <Icon name="icon-icon-duigou" size={16} color={'red'} />
  458. ) : null}
  459. {this.state.filiter == 'State' && this.state.stateIndex == index ? (
  460. <Icon name="icon-icon-duigou" size={16} color={'red'} />
  461. ) : null}
  462. {this.state.filiter == 'Offset' && this.state.offsetIndex == index ? (
  463. <Icon name="icon-icon-duigou" size={16} color={'red'} />
  464. ) : null}
  465. </TouchableOpacity>
  466. )
  467. }
  468. HeadScreening(from, data) {
  469. if (this.state.filiter !== from) {
  470. this.setState({ activeSection: false })
  471. } else if (this.state.filiter == from) {
  472. if (this.state.activeSection == false) {
  473. this.setState({ activeSection: true })
  474. } else {
  475. this.setState({ activeSection: false })
  476. }
  477. }
  478. switch (from) {
  479. case 'Receivable':
  480. this.state.filiter = 'Receivable'
  481. this.setState({ data: data, showSearch: false })
  482. break
  483. case 'Sale':
  484. this.state.filiter = 'Sale'
  485. this.setState({ data: data, showSearch: false })
  486. break
  487. case 'State':
  488. this.state.filiter = 'State'
  489. this.setState({ data: data, showSearch: false })
  490. break
  491. case 'Offset':
  492. this.state.filiter = 'Offset'
  493. this.setState({ data: data, showSearch: false })
  494. break
  495. }
  496. }
  497. async TimeAndroid(mark) {
  498. const { action, year, month, day } = await DatePickerAndroid.open({
  499. date: new Date(),
  500. // minDate: new Date(),
  501. mode: 'spinner',
  502. })
  503. if (action !== DatePickerAndroid.dismissedAction) {
  504. let newDate = `${year}-${month + 1}-${day}`
  505. if (mark == 'start') {
  506. if (newDate <= this.state.endTime) {
  507. this.setState({
  508. startTime: newDate,
  509. })
  510. }
  511. } else if (mark == 'end') {
  512. if (this.state.startTime <= newDate) {
  513. this.setState({
  514. endTime: newDate,
  515. })
  516. }
  517. }
  518. // 这里开始可以处理用户选好的年月日三个参数:year, month (0-11), day
  519. }
  520. }
  521. // 底部
  522. footerCom() {
  523. if (this.props.showFoot == 0) {
  524. return <View />
  525. } else if (this.props.showFoot == 1) {
  526. return (
  527. <View style={styles.footer}>
  528. <Text
  529. style={{
  530. fontSize: 14,
  531. lineHeight: 20,
  532. letterSpacing: 0.17,
  533. color: '#999',
  534. }}
  535. >
  536. 没有更多数据
  537. </Text>
  538. </View>
  539. )
  540. } else if (this.props.showFoot == 2) {
  541. return (
  542. <View style={styles.footer}>
  543. <ActivityIndicator />
  544. <Text>正在加载更多数据...</Text>
  545. </View>
  546. )
  547. }
  548. }
  549. render() {
  550. const {
  551. appTheme,
  552. castData,
  553. totalPages,
  554. FinancialOrg,
  555. SaleOrg,
  556. Balance,
  557. OffsetMod,
  558. StateMod,
  559. SupplierInfo,
  560. } = this.props
  561. return (
  562. <View
  563. style={[
  564. styles.container,
  565. { backgroundColor: appTheme.backgroundColor },
  566. ]}
  567. >
  568. <StatusBar
  569. animated={true}
  570. barStyle={appTheme.barStyle}
  571. // barStyle={"dark-content"}
  572. backgroundColor={'transparent'}
  573. translucent={true}
  574. />
  575. {this.header()}
  576. {/* 头部筛选条件 */}
  577. <View
  578. style={{
  579. backgroundColor: '#FFF',
  580. paddingVertical: 10,
  581. paddingLeft: 5,
  582. flexDirection: 'row',
  583. borderBottomColor: '#EEE',
  584. borderBottomWidth: 1,
  585. }}
  586. >
  587. <TouchableOpacity
  588. onPress={() => this.HeadScreening('Receivable', FinancialOrg)}
  589. style={{
  590. flex: 1,
  591. justifyContent: 'center',
  592. flexDirection: 'row',
  593. borderRightColor: '#EEE',
  594. borderRightWidth: 1,
  595. paddingHorizontal: 10,
  596. }}
  597. >
  598. <Text
  599. numberOfLines={1}
  600. style={{
  601. fontSize: 13,
  602. lineHeight: 20,
  603. letterSpacing: 0.17,
  604. color:
  605. this.state.filiter == 'Receivable'
  606. ? this.state.activeSection ? '#333' : '#E70013'
  607. : '#333',
  608. marginRight: 5,
  609. }}
  610. >
  611. {this.state.receivableOrgan}
  612. </Text>
  613. <Icon
  614. name="icon-icon-xialaxiaosanjiao"
  615. size={14}
  616. color={
  617. this.state.filiter == 'Receivable'
  618. ? this.state.activeSection ? '#999' : '#E70013'
  619. : '#999'
  620. }
  621. style={{ alignSelf: 'center' }}
  622. />
  623. </TouchableOpacity>
  624. <TouchableOpacity
  625. onPress={() => this.HeadScreening('Sale', SupplierInfo)}
  626. style={{
  627. flex: 1,
  628. justifyContent: 'center',
  629. flexDirection: 'row',
  630. borderRightColor: '#EEE',
  631. borderRightWidth: 1,
  632. paddingHorizontal: 10,
  633. }}
  634. >
  635. <Text
  636. numberOfLines={1}
  637. style={{
  638. fontSize: 13,
  639. lineHeight: 20,
  640. letterSpacing: 0.17,
  641. color:
  642. this.state.filiter == 'Sale'
  643. ? this.state.activeSection ? '#333' : '#E70013'
  644. : '#333',
  645. marginRight: 5,
  646. }}
  647. >
  648. {this.state.saleOrgan}
  649. </Text>
  650. <Icon
  651. name="icon-icon-xialaxiaosanjiao"
  652. size={14}
  653. color={
  654. this.state.filiter == 'Sale'
  655. ? this.state.activeSection ? '#999' : '#E70013'
  656. : '#999'
  657. }
  658. style={{ alignSelf: 'center' }}
  659. />
  660. </TouchableOpacity>
  661. <TouchableOpacity
  662. style={{
  663. flex: 1,
  664. justifyContent: 'center',
  665. flexDirection: 'row',
  666. borderRightColor: '#EEE',
  667. borderRightWidth: 1,
  668. paddingHorizontal: 10,
  669. }}
  670. onPress={() => this.HeadScreening('State', StateMod)}
  671. >
  672. <Text
  673. numberOfLines={1}
  674. style={{
  675. fontSize: 13,
  676. lineHeight: 20,
  677. letterSpacing: 0.17,
  678. color:
  679. this.state.filiter == 'State'
  680. ? this.state.activeSection ? '#333' : '#E70013'
  681. : '#333',
  682. marginRight: 5,
  683. }}
  684. >
  685. {this.state.stateSelect}
  686. </Text>
  687. <Icon
  688. name="icon-icon-xialaxiaosanjiao"
  689. size={14}
  690. color={
  691. this.state.filiter == 'State'
  692. ? this.state.activeSection ? '#999' : '#E70013'
  693. : '#999'
  694. }
  695. style={{ alignSelf: 'center' }}
  696. />
  697. </TouchableOpacity>
  698. <TouchableOpacity
  699. style={{
  700. flex: 1,
  701. justifyContent: 'center',
  702. flexDirection: 'row',
  703. paddingLeft: 10,
  704. paddingRight: 7,
  705. }}
  706. onPress={() => this.HeadScreening('Offset', OffsetMod)}
  707. >
  708. <Text
  709. numberOfLines={1}
  710. style={{
  711. fontSize: 13,
  712. lineHeight: 20,
  713. letterSpacing: 0.17,
  714. color:
  715. this.state.filiter == 'Offset'
  716. ? this.state.activeSection ? '#333' : '#E70013'
  717. : '#333',
  718. marginRight: 5,
  719. }}
  720. >
  721. {this.state.offsetSelect}
  722. </Text>
  723. <Icon
  724. name="icon-icon-xialaxiaosanjiao"
  725. size={14}
  726. color={
  727. this.state.filiter == 'SOffset'
  728. ? this.state.activeSection ? '#999' : '#E70013'
  729. : '#999'
  730. }
  731. style={{ alignSelf: 'center' }}
  732. />
  733. </TouchableOpacity>
  734. </View>
  735. {/* 票扣及货补余额 */}
  736. <View
  737. style={{
  738. height: 80,
  739. flexDirection: 'row',
  740. backgroundColor: '#FF7D64',
  741. marginBottom: 3,
  742. }}
  743. >
  744. <View
  745. style={{
  746. flex: 1,
  747. paddingLeft: 10,
  748. justifyContent: 'center',
  749. }}
  750. >
  751. <Text
  752. style={{
  753. fontSize: 13,
  754. lineHeight: 18,
  755. letterSpacing: 0.16,
  756. color: '#FFF',
  757. }}
  758. >
  759. 票扣余额
  760. </Text>
  761. <Text
  762. style={{
  763. fontSize: 18,
  764. lineHeight: 25,
  765. letterSpacing: 0.22,
  766. color: '#FFF',
  767. }}
  768. >
  769. {Balance['票扣余额']}
  770. </Text>
  771. </View>
  772. <View
  773. style={{
  774. flex: 1,
  775. justifyContent: 'center',
  776. }}
  777. >
  778. <Text
  779. style={{
  780. fontSize: 13,
  781. lineHeight: 18,
  782. letterSpacing: 0.16,
  783. color: '#FFF',
  784. }}
  785. >
  786. 货补余额
  787. </Text>
  788. <Text
  789. style={{
  790. fontSize: 18,
  791. lineHeight: 25,
  792. letterSpacing: 0.22,
  793. color: '#FFF',
  794. }}
  795. >
  796. {Balance['货补余额']}
  797. </Text>
  798. </View>
  799. </View>
  800. {/* 列表 */}
  801. <FlatList
  802. keyExtractor={(item, index) => item.id + index}
  803. data={castData}
  804. renderItem={({ item, index }) => this.costList(item, index)}
  805. ListFooterComponent={this.footerCom.bind(this)}
  806. // initialNumToRender={5}
  807. onEndReachedThreshold={0.1}
  808. onEndReached={e => {
  809. if (this.props.showFoot != 0) {
  810. return
  811. }
  812. if (this.page != 1 && this.page >= totalPages) {
  813. return
  814. } else {
  815. this.page++
  816. }
  817. this.props.dispatch(
  818. createAction('mine_header/CastSaga')({
  819. castData: castData,
  820. pageInfo: { page: this.page, size: this.size },
  821. searchInfo: this.searchInfo(),
  822. forUse: 'slipOn',
  823. })
  824. )
  825. }}
  826. refreshControl={
  827. <RefreshControl
  828. refreshing={this.props.isRefreshing}
  829. onRefresh={this.onRefresh.bind(this)} //(()=>this.onRefresh)或者通过bind来绑定this引用来调用方法
  830. tintColor="red"
  831. title={this.props.isRefreshing ? '刷新中....' : '下拉刷新'}
  832. />
  833. }
  834. />
  835. {/* 下拉遮罩 */}
  836. {!this.state.activeSection || !this.state.dateActive ? (
  837. <View
  838. style={{
  839. position: 'absolute',
  840. width: width,
  841. height: height,
  842. backgroundColor: '#000',
  843. opacity: 0.5,
  844. top: 101,
  845. }}
  846. />
  847. ) : null}
  848. {/* 筛选条件下拉 */}
  849. <View
  850. style={{
  851. position: 'absolute',
  852. top: 101,
  853. left: 0,
  854. width: width,
  855. backgroundColor: '#FFF',
  856. }}
  857. >
  858. <Collapsible collapsed={this.state.activeSection}>
  859. <FlatList
  860. keyExtractor={(item, index) => item.id + index}
  861. data={this.state.data}
  862. extraData={this.state}
  863. renderItem={({ item, index }) =>
  864. this.collapsibleData(item, index)
  865. }
  866. />
  867. </Collapsible>
  868. </View>
  869. {/* 时间弹窗 */}
  870. <SelectTime
  871. ref={showTime => (this.showTime = showTime)}
  872. cb={(date, mark) => {
  873. let newDate = moment(date).format('YYYY-MM-DD')
  874. if (mark == 'start') {
  875. if (newDate <= this.state.endTime) {
  876. this.setState({
  877. startTime: newDate,
  878. })
  879. }
  880. } else if (mark == 'end') {
  881. if (this.state.startTime <= newDate) {
  882. this.setState({
  883. endTime: newDate,
  884. })
  885. }
  886. }
  887. }}
  888. />
  889. {/* 时间选择下拉 */}
  890. <View
  891. style={{
  892. position: 'absolute',
  893. top: 60,
  894. left: 0,
  895. width: width,
  896. backgroundColor: '#FFF',
  897. }}
  898. >
  899. <Collapsible collapsed={this.state.dateActive}>
  900. <View>
  901. <View
  902. style={{
  903. flexDirection: 'row',
  904. justifyContent: 'space-between',
  905. padding: 20,
  906. marginBottom: 20,
  907. }}
  908. >
  909. <View>
  910. <Text
  911. style={{
  912. fontSize: 13,
  913. lineHeight: 18,
  914. letterSpacing: 0.16,
  915. color: '#333',
  916. alignSelf: 'center',
  917. }}
  918. >
  919. 开始时间
  920. </Text>
  921. <TouchableOpacity
  922. onPress={() =>
  923. Platform.OS == 'ios'
  924. ? this.showTime._openModal('start')
  925. : this.TimeAndroid('start')
  926. }
  927. style={{
  928. paddingHorizontal: 40,
  929. paddingVertical: 7,
  930. marginTop: 16,
  931. borderColor: '#DDD',
  932. borderWidth: 1,
  933. borderRadius: 100,
  934. }}
  935. >
  936. <Text
  937. style={{
  938. fontSize: 13,
  939. lineHeight: 18,
  940. letterSpacing: 0.16,
  941. color: '#333',
  942. }}
  943. >
  944. {this.state.startTime}
  945. </Text>
  946. </TouchableOpacity>
  947. </View>
  948. <View style={{ paddingTop: 37 }}>
  949. <Text
  950. style={{
  951. fontSize: 18,
  952. lineHeight: 25,
  953. letterSpacing: 0.22,
  954. color: '#333',
  955. }}
  956. >
  957. ~
  958. </Text>
  959. </View>
  960. <View>
  961. <Text
  962. style={{
  963. fontSize: 13,
  964. lineHeight: 18,
  965. letterSpacing: 0.16,
  966. color: '#333',
  967. alignSelf: 'center',
  968. }}
  969. >
  970. 结束时间
  971. </Text>
  972. <TouchableOpacity
  973. onPress={() =>
  974. Platform.OS == 'ios'
  975. ? this.showTime._openModal('end')
  976. : this.TimeAndroid('end')
  977. }
  978. style={{
  979. paddingHorizontal: 40,
  980. paddingVertical: 7,
  981. marginTop: 16,
  982. borderColor: '#DDD',
  983. borderWidth: 1,
  984. borderRadius: 100,
  985. }}
  986. >
  987. <Text
  988. style={{
  989. fontSize: 13,
  990. lineHeight: 18,
  991. letterSpacing: 0.16,
  992. color: '#333',
  993. }}
  994. >
  995. {this.state.endTime}
  996. </Text>
  997. </TouchableOpacity>
  998. </View>
  999. </View>
  1000. <View style={{ height: 40, flexDirection: 'row' }}>
  1001. <TouchableOpacity
  1002. onPress={() =>
  1003. this.setState({
  1004. dateActive: true,
  1005. startTime: this.startTime,
  1006. endTime: this.endTime,
  1007. })
  1008. }
  1009. style={{
  1010. width: width / 2,
  1011. backgroundColor: '#FFF',
  1012. justifyContent: 'center',
  1013. }}
  1014. >
  1015. <Text
  1016. style={{
  1017. fontSize: 14,
  1018. lineHeight: 22,
  1019. letterSpacing: 0.21,
  1020. color: '#333',
  1021. alignSelf: 'center',
  1022. }}
  1023. >
  1024. 取消
  1025. </Text>
  1026. </TouchableOpacity>
  1027. <TouchableOpacity
  1028. onPress={() => {
  1029. this.setState({ dateActive: true })
  1030. this.startTime = this.state.startTime
  1031. this.endTime = this.state.endTime
  1032. this.props.dispatch(
  1033. createAction('mine_header/CastSaga')({
  1034. castData: [],
  1035. pageInfo: { page: 0, size: this.size },
  1036. searchInfo: this.searchInfo(),
  1037. })
  1038. )
  1039. this.page = 0
  1040. }}
  1041. style={{
  1042. width: width / 2,
  1043. backgroundColor: '#E70013',
  1044. justifyContent: 'center',
  1045. }}
  1046. >
  1047. <Text
  1048. style={{
  1049. fontSize: 14,
  1050. lineHeight: 22,
  1051. letterSpacing: 0.21,
  1052. color: '#FFF',
  1053. alignSelf: 'center',
  1054. }}
  1055. >
  1056. 确定
  1057. </Text>
  1058. </TouchableOpacity>
  1059. </View>
  1060. </View>
  1061. </Collapsible>
  1062. </View>
  1063. </View>
  1064. )
  1065. }
  1066. }
  1067. const styles = StyleSheet.create({
  1068. container: {
  1069. flex: 1,
  1070. },
  1071. footer: {
  1072. flexDirection: 'row',
  1073. height: 24,
  1074. justifyContent: 'center',
  1075. alignItems: 'center',
  1076. marginBottom: 10,
  1077. marginTop: 10,
  1078. },
  1079. })
  1080. export default Cost