Replenishment.js 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599
  1. import React, { Component } from 'react'
  2. import {
  3. StyleSheet,
  4. ScrollView,
  5. View,
  6. Text,
  7. Image,
  8. Dimensions,
  9. StatusBar,
  10. TouchableOpacity,
  11. PixelRatio,
  12. FlatList,
  13. } from 'react-native'
  14. import { connect } from 'react-redux'
  15. import png from '../../../static/images/defaultimg.jpg'
  16. import Icon from '../../../components/Iconfont/Iconfont'
  17. import { NavigationActions, createAction } from '../../../utils'
  18. import Checkbox from '../../../components/checkbox/index'
  19. import CountNum from '../../../components/CountNum'
  20. import Collapsible from 'react-native-collapsible'
  21. import { ImageBaseUrl } from '../../../utils/fetch/Fetchx'
  22. import dataModel from '../../common/datamodel/dataModel'
  23. import { accSub } from '../../../utils/utils'
  24. import Setting from '../../mine/Setting'
  25. const { width, height } = Dimensions.get('window')
  26. @connect(({ theme, attention, orderlist }) => ({
  27. ...theme,
  28. ...attention,
  29. ...orderlist,
  30. }))
  31. class Unpaid extends Component {
  32. constructor(props) {
  33. super(props)
  34. this.state = {
  35. topNavIndex: 2,
  36. listIndex: true,
  37. selectAll: false,
  38. }
  39. }
  40. // 头部
  41. header() {
  42. return (
  43. <View
  44. style={{
  45. height: HEADERSTYLE.height,
  46. paddingTop: HEADERSTYLE.paddingTop + 5,
  47. backgroundColor: '#fff',
  48. borderBottomColor: '#eee',
  49. borderBottomWidth: 1 / PixelRatio.get(),
  50. }}
  51. >
  52. <View
  53. style={{
  54. flex: 1,
  55. justifyContent: 'center',
  56. }}
  57. >
  58. <TouchableOpacity
  59. style={{
  60. position: 'absolute',
  61. left: 10,
  62. flexDirection: 'row',
  63. }}
  64. onPress={() => this.props.dispatch(NavigationActions.back())}
  65. >
  66. <Icon
  67. name="icon-icon-fanhui"
  68. size={20}
  69. color={'#666'}
  70. style={{ marginTop: 4 }}
  71. />
  72. <Text
  73. style={{
  74. fontSize: 14,
  75. lineHeight: 20,
  76. color: '#666',
  77. alignSelf: 'center',
  78. }}
  79. >
  80. 返回
  81. </Text>
  82. </TouchableOpacity>
  83. <Text
  84. style={{
  85. alignSelf: 'center',
  86. fontSize: 18,
  87. lineHeight: 25,
  88. letterSpacing: 0.19,
  89. color: '#333',
  90. }}
  91. >
  92. 关注
  93. </Text>
  94. {/* <TouchableOpacity
  95. style={{ position: "absolute", right: 10 }}
  96. onPress={() => this.setState({ listIndex: !this.state.listIndex })}
  97. >
  98. <Text
  99. style={{
  100. fontSize: 14,
  101. lineHeight: 20,
  102. letterSpacing: 0.17,
  103. color: "#666"
  104. }}
  105. >
  106. {this.state.listIndex ? "展开" : "收起"}
  107. </Text>
  108. </TouchableOpacity> */}
  109. </View>
  110. </View>
  111. )
  112. }
  113. componentDidMount() {
  114. let date = new Date().getTime()
  115. this.props.dispatch(createAction('attention/getAttentionList')())
  116. this.props.dispatch(
  117. createAction('orderlist/getOrderList')({
  118. listData: [],
  119. pageInfo: { page: 0, size: 20 },
  120. touchCode: 0,
  121. searchInfo: {
  122. search_IN_saleModel: '01,03',
  123. search_GTE_orderDate_date: date - 7 * 24 * 3600 * 1000,
  124. search_LT_orderDate_date: date,
  125. },
  126. })
  127. )
  128. }
  129. replenList(item, index) {
  130. return (
  131. <View style={{ marginBottom: 10 }}>
  132. <View
  133. style={{
  134. flexDirection: 'row',
  135. padding: 10,
  136. backgroundColor: '#FFF',
  137. }}
  138. >
  139. <View style={{ flex: 1 }}>
  140. <View
  141. style={{
  142. flexDirection: 'row',
  143. paddingBottom: 10,
  144. }}
  145. >
  146. {/* {this.state.topNavIndex == 1 ? null : (
  147. <Checkbox
  148. checkBoxColor={"#CCC"}
  149. checked={item.isChecked}
  150. size={26}
  151. onChange={bool => {
  152. item.isChecked = bool;
  153. if (
  154. this.props.attentData &&
  155. this.props.attentData.every(
  156. item => item.isChecked == true
  157. )
  158. ) {
  159. this.setState({ selectAll: true });
  160. } else {
  161. this.setState({ selectAll: false });
  162. }
  163. }}
  164. />
  165. )} */}
  166. <Image
  167. source={
  168. item.goodsImg ? { uri: ImageBaseUrl + item.goodsImg } : png
  169. }
  170. style={{ width: 80, height: 80, marginLeft: 10 }}
  171. />
  172. <View style={{ marginLeft: 10, flex: 1 }}>
  173. <Text style={{ fontSize: 14, lineHeight: 20, color: '#333' }}>
  174. {item.goodsDisplayName}
  175. </Text>
  176. <Text
  177. style={{
  178. fontSize: 12,
  179. lineHeight: 17,
  180. color: '#666',
  181. marginVertical: 3,
  182. }}
  183. >
  184. 编码:{item.goodsCode}
  185. </Text>
  186. <View
  187. style={{
  188. flexDirection: 'row',
  189. justifyContent: 'space-between',
  190. alignItems: 'center',
  191. }}
  192. >
  193. {/* <Text style={{ fontSize: 12, lineHeight: 17, color: '#666' }}>
  194. 库存:{item.stock || 0} {item.mainNumUnitName}
  195. </Text> */}
  196. <View style={{ flexDirection: 'row' }}>
  197. <TouchableOpacity
  198. onPress={() => {
  199. this.props.dispatch(
  200. createAction('attention/delAttention')(item.id)
  201. )
  202. }}
  203. >
  204. <Icon
  205. name="icon-icon-qingkong"
  206. size={22}
  207. color={'#666'}
  208. />
  209. </TouchableOpacity>
  210. <TouchableOpacity
  211. onPress={() => {
  212. let postData = dataModel(
  213. item,
  214. CUSTOMERINFO.id,
  215. CUSTOMERINFO.customerRankCode
  216. )
  217. this.props.dispatch(
  218. createAction('shoppingcart/addShop')(postData)
  219. )
  220. }}
  221. >
  222. <Icon
  223. name="icon-icon-gouwuche"
  224. size={22}
  225. color={'#666'}
  226. style={{ marginLeft: 30 }}
  227. />
  228. </TouchableOpacity>
  229. </View>
  230. </View>
  231. </View>
  232. </View>
  233. {/* <View
  234. style={{
  235. flexDirection: "row",
  236. justifyContent: "space-between",
  237. paddingTop: 10,
  238. marginLeft: 30,
  239. borderTopWidth: 1 / PixelRatio.get(),
  240. borderTopColor: "#EEE"
  241. }}
  242. >
  243. <View style={{ flexDirection: "row" }}>
  244. <CountNum
  245. defaultValue={4}
  246. size={24}
  247. callback={nv => console.log(nv)}
  248. />
  249. <Text
  250. style={{
  251. fontSize: 12,
  252. lineHeight: 17,
  253. color: "#666",
  254. alignSelf: "center",
  255. marginLeft: 10
  256. }}
  257. >
  258. 主数量:20
  259. </Text>
  260. </View>
  261. <Text
  262. style={{
  263. fontSize: 12,
  264. lineHeight: 17,
  265. color: "#666",
  266. alignSelf: "center"
  267. }}
  268. >
  269. 金额:<Text style={{ fontSize: 14, color: "#E70013" }}>
  270. {CURRENCY.currencySign}72000.00
  271. </Text>
  272. </Text>
  273. </View> */}
  274. </View>
  275. </View>
  276. {/* <Collapsible collapsed={this.state.listIndex}>
  277. <View style={{ paddingHorizontal: 10 }}>
  278. <View
  279. style={{
  280. paddingVertical: 10,
  281. flexDirection: "row",
  282. justifyContent: "space-between",
  283. borderBottomWidth: 1,
  284. borderBottomColor: "#EEE"
  285. }}
  286. >
  287. <Text style={{ fontSize: 12, lineHeight: 17, color: "#666" }}>
  288. {this.state.topNavIndex !== 1
  289. ? `建议补货数量:100`
  290. : `2018-12-12 已订购100件`}
  291. </Text>
  292. {this.state.topNavIndex !== 1 ? (
  293. <Text style={{ fontSize: 12, lineHeight: 17, color: "#666" }}>
  294. 在途量:15件
  295. </Text>
  296. ) : null}
  297. </View>
  298. <View
  299. style={{
  300. paddingTop: 10,
  301. flexDirection: "row",
  302. justifyContent: "space-between"
  303. }}
  304. >
  305. <Text style={{ fontSize: 12, lineHeight: 17, color: "#666" }}>
  306. {this.state.topNavIndex !== 1
  307. ? `安全库存天数:100件`
  308. : `建议补货数量:100`}
  309. </Text>
  310. <Text style={{ fontSize: 12, lineHeight: 17, color: "#666" }}>
  311. {this.state.topNavIndex !== 1
  312. ? `日均销量:100件`
  313. : `在途量:15件`}
  314. </Text>
  315. </View>
  316. </View>
  317. </Collapsible> */}
  318. </View>
  319. )
  320. }
  321. selectAll(bool) {
  322. for (let item of this.props.attentData) {
  323. if (item && !item.isChecked) {
  324. item.isChecked = bool
  325. } else {
  326. item.isChecked = bool
  327. }
  328. }
  329. this.props.dispatch(
  330. createAction('attention/updateAttention')({
  331. attentData: this.props.attentData,
  332. })
  333. )
  334. this.setState({ selectAll: bool })
  335. }
  336. render() {
  337. const { appTheme, attentData, listData } = this.props
  338. const { topNavIndex } = this.state
  339. let newListData = []
  340. if (
  341. listData &&
  342. listData.length > 0 &&
  343. listData[1] &&
  344. Object.keys(listData[1]).length > 0
  345. ) {
  346. listData.sort((a, b) => b.orderDate - a.orderDate)
  347. newListData = listData.slice(0, 20)
  348. }
  349. let FlatData = [],
  350. mapObj = {}
  351. if (topNavIndex == 1) {
  352. if (newListData && newListData.length > 0) {
  353. newListData.map(data => {
  354. if (data.reqOrderItems && data.reqOrderItems.length > 0) {
  355. data.reqOrderItems.map(item => {
  356. item.saleOrgName = data.saleOrgName
  357. item.saleOrgCode = data.saleOrgCode
  358. item.saleOrgId = data.saleOrgId
  359. mapObj[item.goodsId] = item
  360. })
  361. }
  362. })
  363. for (let objdata in mapObj) {
  364. FlatData.push(mapObj[objdata])
  365. }
  366. } else {
  367. FlatData = []
  368. }
  369. } else if (topNavIndex == 2) {
  370. FlatData = attentData
  371. }
  372. return (
  373. <View
  374. style={[
  375. styles.container,
  376. { backgroundColor: appTheme.backgroundColor },
  377. ]}
  378. >
  379. <StatusBar
  380. animated={true}
  381. barStyle={appTheme.barStyle}
  382. // barStyle={"dark-content"}
  383. backgroundColor={'transparent'}
  384. translucent={true}
  385. />
  386. {/* 头部导航 */}
  387. {this.header()}
  388. {/* 二级导航 */}
  389. <View
  390. style={{
  391. flexDirection: 'row',
  392. backgroundColor: '#FFF',
  393. paddingVertical: 5,
  394. paddingHorizontal: 10,
  395. borderBottomColor: '#eee',
  396. borderBottomWidth: 1 / PixelRatio.get(),
  397. }}
  398. >
  399. {/* <TouchableOpacity
  400. onPress={() => this.setState({ topNavIndex: 0, data: data1 })}
  401. style={{
  402. flex: 1,
  403. alignItems: "center"
  404. }}
  405. >
  406. <View
  407. style={{
  408. paddingVertical: 4,
  409. borderBottomColor:
  410. this.state.topNavIndex == 0 ? "#E70013" : "transparent",
  411. borderBottomWidth: 2
  412. }}
  413. >
  414. <Text
  415. style={{
  416. fontSize: 14,
  417. lineHeight: 20,
  418. letterSpacing: 0.17,
  419. color: this.state.topNavIndex == 0 ? "#E70013" : "#333"
  420. }}
  421. >
  422. 快速补货(99+)
  423. </Text>
  424. </View>
  425. </TouchableOpacity> */}
  426. <TouchableOpacity
  427. onPress={() => this.setState({ topNavIndex: 1, selectAll: false })}
  428. style={{ flex: 1, alignItems: 'center' }}
  429. >
  430. <View
  431. style={{
  432. paddingVertical: 4,
  433. borderBottomColor:
  434. this.state.topNavIndex == 1 ? '#E70013' : 'transparent',
  435. borderBottomWidth: 2,
  436. }}
  437. >
  438. <Text
  439. style={{
  440. fontSize: 14,
  441. lineHeight: 20,
  442. letterSpacing: 0.17,
  443. color: this.state.topNavIndex == 1 ? '#E70013' : '#333',
  444. }}
  445. >
  446. 最近购买
  447. </Text>
  448. </View>
  449. </TouchableOpacity>
  450. <TouchableOpacity
  451. onPress={() => {
  452. attentData.map(data => (data.isChecked = false))
  453. this.setState({ topNavIndex: 2, selectAll: false })
  454. }}
  455. style={{ flex: 1, alignItems: 'center' }}
  456. >
  457. <View
  458. style={{
  459. paddingVertical: 4,
  460. borderBottomColor:
  461. this.state.topNavIndex == 2 ? '#E70013' : 'transparent',
  462. borderBottomWidth: 2,
  463. }}
  464. >
  465. <Text
  466. style={{
  467. fontSize: 14,
  468. lineHeight: 20,
  469. letterSpacing: 0.17,
  470. color: this.state.topNavIndex == 2 ? '#E70013' : '#333',
  471. }}
  472. >
  473. 关注商品
  474. </Text>
  475. </View>
  476. </TouchableOpacity>
  477. </View>
  478. {/* 列表 */}
  479. <FlatList
  480. keyExtractor={(item, index) => index}
  481. data={FlatData}
  482. extraData={this.state}
  483. renderItem={({ item, index }) => this.replenList(item, index)}
  484. />
  485. {/* 底部加入购物车 */}
  486. {/* <View
  487. style={{
  488. height: 45,
  489. flexDirection: "row",
  490. borderTopColor: "#EEE",
  491. borderTopWidth: 1
  492. }}
  493. >
  494. <View
  495. style={{
  496. flex: 2,
  497. backgroundColor: "#FFF",
  498. flexDirection: "row",
  499. justifyContent: "space-between",
  500. paddingHorizontal: 10
  501. }}
  502. >
  503. <View style={{ flexDirection: "row", alignSelf: "center" }}>
  504. <View
  505. style={{
  506. marginBottom: 4
  507. }}
  508. >
  509. {this.state.topNavIndex == 1 ? null : (
  510. <Checkbox
  511. checkBoxColor={"#CCC"}
  512. checked={this.state.selectAll}
  513. size={26}
  514. onChange={bool => this.selectAll(bool)}
  515. label={
  516. <Text
  517. style={{
  518. alignSelf: "center",
  519. marginBottom: 2,
  520. marginLeft: 2,
  521. color: "#333"
  522. }}
  523. >
  524. 全选
  525. </Text>
  526. }
  527. labelStyle={{
  528. fontSize: 14,
  529. lineHeight: 20,
  530. color: "#333",
  531. alignSelf: "center"
  532. }}
  533. />
  534. )}
  535. </View>
  536. </View>
  537. <Text
  538. style={{
  539. alignSelf: "center",
  540. fontSize: 13,
  541. lineHeight: 18,
  542. color: "#333"
  543. }}
  544. >
  545. 合计:<Text
  546. style={{
  547. fontSize: 16,
  548. color: "#E70013",
  549. alignSelf: "center"
  550. }}
  551. >
  552. {CURRENCY.currencySign}72000.00
  553. </Text>
  554. </Text>
  555. </View>
  556. <View
  557. style={{
  558. flex: 1,
  559. backgroundColor: "#E70013",
  560. justifyContent: "center"
  561. }}
  562. >
  563. <Text
  564. style={{
  565. alignSelf: "center",
  566. fontSize: 14,
  567. lineHeight: 20,
  568. color: "#FFF"
  569. }}
  570. >
  571. 加入购物车
  572. </Text>
  573. </View>
  574. </View> */}
  575. </View>
  576. )
  577. }
  578. }
  579. const styles = StyleSheet.create({
  580. container: {
  581. flex: 1,
  582. },
  583. })
  584. export default Unpaid