Commit 1c1e0e11 by peii

过滤及下拉刷新

parent 71810a43
{ {
"name": "BoneHouse_Hospital_APP", "name": "BoneHouse_Business_APP",
"displayName": "BoneHouse_Hospital_APP" "displayName": "BoneHouse_Business_APP"
} }
\ No newline at end of file
...@@ -66,7 +66,7 @@ class HomePage extends Component { ...@@ -66,7 +66,7 @@ class HomePage extends Component {
MOBILE_DISTRIBUTION_INVOICE_APPLICATION: { MOBILE_DISTRIBUTION_INVOICE_APPLICATION: {
icon: require('../../images/quick_order.png'), icon: require('../../images/quick_order.png'),
title: '分销-开票申请', title: '分销-开票申请',
page: 'QuickOrderPage', page: '',
}, },
MOBILE_DISTRIBUTION_SETTLEMENT_GATHER: { MOBILE_DISTRIBUTION_SETTLEMENT_GATHER: {
icon: require('../../images/settle_gather.png'), icon: require('../../images/settle_gather.png'),
...@@ -76,17 +76,17 @@ class HomePage extends Component { ...@@ -76,17 +76,17 @@ class HomePage extends Component {
MOBILE_DISTRIBUTION_INVOICE_GATHER: { MOBILE_DISTRIBUTION_INVOICE_GATHER: {
icon: require('../../images/quick_order.png'), icon: require('../../images/quick_order.png'),
title: '分销-开票汇总', title: '分销-开票汇总',
page: 'QuickOrderPage', page: '',
}, },
MOBILE_DIRECT_INVOICE_APPLICATION: { MOBILE_DIRECT_INVOICE_APPLICATION: {
icon: require('../../images/quick_order.png'), icon: require('../../images/quick_order.png'),
title: '直销-开票申请', title: '直销-开票申请',
page: 'QuickOrderPage', page: '',
}, },
MOBILE_DIRECT_INVOICE_GATHER: { MOBILE_DIRECT_INVOICE_GATHER: {
icon: require('../../images/quick_order.png'), icon: require('../../images/quick_order.png'),
title: '直销-开票汇总', title: '直销-开票汇总',
page: 'QuickOrderPage', page: '',
}, },
}, },
}, },
...@@ -130,7 +130,11 @@ class HomePage extends Component { ...@@ -130,7 +130,11 @@ class HomePage extends Component {
} }
} }
// 获取菜单权限 /**
* @description: 重新设置菜单
* @param {*}
* @return {*}
*/
getMenuRuleInfo() { getMenuRuleInfo() {
let { functions } = this.props.userInfo let { functions } = this.props.userInfo
let { menus, icons, tabs } = this.state let { menus, icons, tabs } = this.state
...@@ -202,6 +206,9 @@ class HomePage extends Component { ...@@ -202,6 +206,9 @@ class HomePage extends Component {
// 跳转页面 // 跳转页面
jumpToSubpage(menu) { jumpToSubpage(menu) {
const page = menu.page const page = menu.page
if (isBlank(page)) {
return show('该功能正在紧急开发暂未开放!')
}
if ('LoginPage' === page) { if ('LoginPage' === page) {
this.props.exitLoginStatus() this.props.exitLoginStatus()
} }
......
/*
* @FilePath: /BoneHouse_Business_APP/src/components/form/common.tsx
* @Author: peii
* @Date: 2021-12-21 10:19:25
* @LastEditTime: 2021-12-23 16:47:21
* @LastEditors: peii
* @Vision: 1.0
* @Description:
*/
// @ts-nocheck
import React, { Component } from 'react' import React, { Component } from 'react'
import { View, Text, Image, TouchableOpacity, TextInput } from 'react-native' import { View, Text, Image, TouchableOpacity, TextInput } from 'react-native'
import { IFormField } from 'bonehouse'
import { g, isRequired } from '../../utils/utils' import { g, isRequired } from '../../utils/utils'
import styles from './index.styl' import styles from './index.styl'
export const Title = props => { export const Title = props => {
const { item } = props const { item, style = {} } = props
const required = isRequired(item) const required = isRequired(item)
return ( return (
<Text style={g(styles, 'form-label')}> <Text style={[g(styles, 'form-label'), style]}>
{!!required && <Text style={g(styles, 'red', 'pr5')}>*</Text>} {!!required && <Text style={g(styles, 'red', 'pr5')}>*</Text>}
<Text>{item.label}</Text> <Text>{item.label}</Text>
</Text> </Text>
......
...@@ -124,13 +124,13 @@ ...@@ -124,13 +124,13 @@
.box .box
&-item &-item
flex-direction column flex-direction row
height auto height auto
&-radio &-radio
@extend .row @extend .row
flex 1 flex 1
justify-content flex-start justify-content flex-end
flex-wrap wrap flex-wrap wrap
margin-top 10px margin-top 10px
......
...@@ -34,11 +34,11 @@ export default class BoxRadio extends Component<IProps> { ...@@ -34,11 +34,11 @@ export default class BoxRadio extends Component<IProps> {
} }
render() { render() {
const { item, value, onChange, type = 'radio' } = this.props const { item, value, onChange } = this.props
return ( return (
<View style={g(styles, 'box-item')}> <View style={g(styles, 'box-item')}>
<Title item={item} style={{ alignSelf: 'flex-left' }} /> <Title item={item} style={{ width: 'auto' }} />
<View style={g(styles, 'box-radio')}> <View style={g(styles, 'box-radio')}>
{item.options && {item.options &&
...@@ -51,8 +51,14 @@ export default class BoxRadio extends Component<IProps> { ...@@ -51,8 +51,14 @@ export default class BoxRadio extends Component<IProps> {
key={option.value} key={option.value}
activeOpacity={0.8} activeOpacity={0.8}
onPress={() => { onPress={() => {
if (value === option.value) return let values = isBlank(value) ? [] : R.split(',', value)
onChange(item.field, option.value) if (active) {
values = R.compose(R.remove(R.__, 1, values), R.findIndex(R.equals(option.value)))(values)
} else {
values = R.append(option.value, values)
}
onChange(item.field, values.join(','))
}} }}
> >
{active && ( {active && (
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @FilePath: /BoneHouse_Business_APP/src/pages/settlement/collection.tsx * @FilePath: /BoneHouse_Business_APP/src/pages/settlement/collection.tsx
* @Author: peii * @Author: peii
* @Date: 2021-12-18 16:33:37 * @Date: 2021-12-18 16:33:37
* @LastEditTime: 2021-12-23 15:58:56 * @LastEditTime: 2021-12-23 19:07:42
* @LastEditors: peii * @LastEditors: peii
* @Vision: 1.0 * @Vision: 1.0
* @Description: 结算汇总 * @Description: 结算汇总
...@@ -15,12 +15,13 @@ import { connect } from 'react-redux' ...@@ -15,12 +15,13 @@ import { connect } from 'react-redux'
import * as R from 'ramda' import * as R from 'ramda'
import { INavigation } from 'navigation' import { INavigation } from 'navigation'
import { IFormField } from 'bonehouse' import { IFormField } from 'bonehouse'
import debounce from 'debounce'
import Loading from '../../../app/containers/common/LodingModel' import Loading from '../../../app/containers/common/LodingModel'
import Header from '../../components/header/header' import Header from '../../components/header/header'
import Resolution from '../../components/common/Resolution' import Resolution from '../../components/common/Resolution'
import FilterModal from './components/filter' import FilterModal from './components/filter'
import SettlementList from './components/list' import SettlementList from './components/list'
import { isBlank, g } from '../../utils/utils' import { isBlank, g, isNotBlank } from '../../utils/utils'
import { FieldType } from '../../enums' import { FieldType } from '../../enums'
import api from '../../services/api' import api from '../../services/api'
import styles from './index.styl' import styles from './index.styl'
...@@ -40,7 +41,7 @@ class SettlementCollection extends React.Component<IProps, IState> { ...@@ -40,7 +41,7 @@ class SettlementCollection extends React.Component<IProps, IState> {
constructor(props: IProps) { constructor(props: IProps) {
super(props) super(props)
this.toggleModalVisible = this.toggleModalVisible.bind(this) this.toggleModalVisible = this.toggleModalVisible.bind(this)
this.getData = this.getData.bind(this) this.getData = debounce(this.getData.bind(this), 200)
} }
state = { state = {
modalVisible: false, modalVisible: false,
...@@ -53,7 +54,7 @@ class SettlementCollection extends React.Component<IProps, IState> { ...@@ -53,7 +54,7 @@ class SettlementCollection extends React.Component<IProps, IState> {
type: FieldType.TEXT, type: FieldType.TEXT,
}, },
{ {
field: 'status', field: 'header_status',
label: '状态', label: '状态',
type: FieldType.RADIO, type: FieldType.RADIO,
options: R.map( options: R.map(
...@@ -64,11 +65,16 @@ class SettlementCollection extends React.Component<IProps, IState> { ...@@ -64,11 +65,16 @@ class SettlementCollection extends React.Component<IProps, IState> {
)(this.props.status), )(this.props.status),
}, },
], ],
pagination: {
start_index: 0,
limit: 10,
},
filterData: {},
isEnd: false,
} }
componentDidMount() { componentDidMount() {
this.toggleModalVisible() this.toggleModalVisible()
console.log(this.props.status)
} }
toggleModalVisible(): void { toggleModalVisible(): void {
...@@ -80,14 +86,47 @@ class SettlementCollection extends React.Component<IProps, IState> { ...@@ -80,14 +86,47 @@ class SettlementCollection extends React.Component<IProps, IState> {
* @param {*} * @param {*}
* @return {*} * @return {*}
*/ */
async getData(args): void { async getData(args, isRefresh = false, isNext = false): void {
// 确认页面只过滤出已输入的那些
let { pagination, filterData, data, isEnd } = this.state
if (isRefresh || isNotBlank(args)) {
pagination.start_index = 0
}
if (isNext) {
pagination.start_index += pagination.limit
if (isEnd) return
}
if (isBlank(args)) {
args = filterData
}
const params = {
...args,
...pagination,
}
if (!isRefresh && !isNext) {
this.setState({ loading: true }) this.setState({ loading: true })
const res = await api.getSettlements(args) }
const res = await api.getSettlements(params)
this.setState({ loading: false }) this.setState({ loading: false })
if (res.error_code !== 0) return if (res.error_code !== 0) return
const data = R.propOr([], 'data')(res) const newData = R.propOr([], 'data')(res)
this.setState({ data }) if (isBlank(newData) || newData.length < pagination.limit) {
isEnd = true
} else {
isEnd = false
}
if (isNext) {
data = R.concat(data, newData)
} else {
data = newData
}
this.setState({ data, filterData: args, isEnd })
} }
render() { render() {
...@@ -117,7 +156,11 @@ class SettlementCollection extends React.Component<IProps, IState> { ...@@ -117,7 +156,11 @@ class SettlementCollection extends React.Component<IProps, IState> {
otherFilterItems={otherFilterItems} otherFilterItems={otherFilterItems}
/> />
{loading ? <Loading show={loading} /> : <SettlementList data={data} {...this.props} isCollection={true} />} {loading ? (
<Loading show={loading} />
) : (
<SettlementList data={data} {...this.props} isCollection={true} getData={this.getData} />
)}
</View> </View>
</Resolution.FixWidthView> </Resolution.FixWidthView>
</View> </View>
......
...@@ -3,11 +3,13 @@ ...@@ -3,11 +3,13 @@
.list .list
width 100% width 100%
padding 20px padding-top 20px
margin-bottom 25px padding-bottom 25px
.item .item
background-color #fff background-color #fff
margin-left 20px
margin-right 20px
padding 15px padding 15px
margin-bottom 15px margin-bottom 15px
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @FilePath: /BoneHouse_Business_APP/src/pages/settlement/components/list.tsx * @FilePath: /BoneHouse_Business_APP/src/pages/settlement/components/list.tsx
* @Author: peii * @Author: peii
* @Date: 2021-12-19 10:44:15 * @Date: 2021-12-19 10:44:15
* @LastEditTime: 2021-12-21 17:21:48 * @LastEditTime: 2021-12-23 18:43:04
* @LastEditors: peii * @LastEditors: peii
* @Vision: 1.0 * @Vision: 1.0
* @Description: 汇总列表 * @Description: 汇总列表
...@@ -10,10 +10,11 @@ ...@@ -10,10 +10,11 @@
// @ts-nocheck // @ts-nocheck
import React, { Component } from 'react' import React, { Component } from 'react'
import { View, Text, TouchableOpacity, FlatList, Image } from 'react-native' import { View, Text, TouchableOpacity, FlatList, RefreshControl } from 'react-native'
import * as R from 'ramda' import * as R from 'ramda'
import { connect } from 'react-redux' import { connect } from 'react-redux'
import { INavigation } from 'navigation' import { INavigation } from 'navigation'
import debounce from 'debounce'
import Empty from '../../../components/empty' import Empty from '../../../components/empty'
import dayjs from 'dayjs' import dayjs from 'dayjs'
import { isBlank, g } from '../../../utils/utils' import { isBlank, g } from '../../../utils/utils'
...@@ -22,6 +23,7 @@ import styles from './list.styl' ...@@ -22,6 +23,7 @@ import styles from './list.styl'
type IProps = { type IProps = {
data: any[] data: any[]
navigation: INavigation navigation: INavigation
getData: Function
} }
class SettlementList extends Component<IProps> { class SettlementList extends Component<IProps> {
...@@ -31,6 +33,16 @@ class SettlementList extends Component<IProps> { ...@@ -31,6 +33,16 @@ class SettlementList extends Component<IProps> {
this.itemPressHandler = this.itemPressHandler.bind(this) this.itemPressHandler = this.itemPressHandler.bind(this)
} }
state = {
refreshing: false,
}
refreshing = false
componentDidMount() {
this.onRefreshHandler = debounce(this.onRefreshHandler.bind(this), 200)
this.onEndReachedHandler = debounce(this.onEndReachedHandler.bind(this), 500)
}
/** /**
* @description: * @description:
* @param {*} item * @param {*} item
...@@ -62,6 +74,31 @@ class SettlementList extends Component<IProps> { ...@@ -62,6 +74,31 @@ class SettlementList extends Component<IProps> {
[R.T, R.always('text-gray')], [R.T, R.always('text-gray')],
]) ])
refreshing = false
/**
* @description: 下拉刷新
* @param {*}
* @return {*}
*/
async onRefreshHandler() {
if (this.state.refreshing) return
refreshing = true
this.setState({ refreshing: true })
await this.props.getData(null, true)
refreshing = false
this.setState({ refreshing: false })
}
async onEndReachedHandler() {
if (this.refreshing || isBlank(this.props.data)) return
this.refreshing = true
await this.props.getData(null, false, true)
this.refreshing = false
}
/** /**
* @description: 结算单单项 * @description: 结算单单项
* @param {*} param1 * @param {*} param1
...@@ -99,14 +136,20 @@ class SettlementList extends Component<IProps> { ...@@ -99,14 +136,20 @@ class SettlementList extends Component<IProps> {
render() { render() {
const { data = [] } = this.props const { data = [] } = this.props
const { refreshing } = this.state
return ( return (
<View style={g(styles, 'list')}>
<FlatList <FlatList
data={data} data={data}
renderItem={this.renderItem} renderItem={this.renderItem}
ListEmptyComponent={Empty} ListEmptyComponent={Empty}
style={g(styles, 'list')} style={g(styles, 'list-inner')}
keyExtractor={it => it.settlement_number} keyExtractor={it => it.settlement_number}
refreshControl={<RefreshControl onRefresh={this.onRefreshHandler} refreshing={refreshing} />}
onEndReached={this.onEndReachedHandler}
></FlatList> ></FlatList>
</View>
) )
} }
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @FilePath: /BoneHouse_Business_APP/src/pages/settlement/index.tsx * @FilePath: /BoneHouse_Business_APP/src/pages/settlement/index.tsx
* @Author: peii * @Author: peii
* @Date: 2021-12-18 16:33:37 * @Date: 2021-12-18 16:33:37
* @LastEditTime: 2021-12-23 15:16:06 * @LastEditTime: 2021-12-23 19:06:35
* @LastEditors: peii * @LastEditors: peii
* @Vision: 1.0 * @Vision: 1.0
* @Description: 结算确认首页 * @Description: 结算确认首页
...@@ -14,12 +14,13 @@ import { View, Text, TouchableOpacity, FlatList, Image } from 'react-native' ...@@ -14,12 +14,13 @@ import { View, Text, TouchableOpacity, FlatList, Image } from 'react-native'
import { connect } from 'react-redux' import { connect } from 'react-redux'
import * as R from 'ramda' import * as R from 'ramda'
import { INavigation } from 'navigation' import { INavigation } from 'navigation'
import debounce from 'debounce'
import Loading from '../../../app/containers/common/LodingModel' import Loading from '../../../app/containers/common/LodingModel'
import Header from '../../components/header/header' import Header from '../../components/header/header'
import Resolution from '../../components/common/Resolution' import Resolution from '../../components/common/Resolution'
import FilterModal from './components/filter' import FilterModal from './components/filter'
import SettlementList from './components/list' import SettlementList from './components/list'
import { isBlank, g } from '../../utils/utils' import { isBlank, g, isNotBlank } from '../../utils/utils'
import api from '../../services/api' import api from '../../services/api'
import styles from './index.styl' import styles from './index.styl'
...@@ -37,12 +38,18 @@ class Settlement extends React.Component<IProps, IState> { ...@@ -37,12 +38,18 @@ class Settlement extends React.Component<IProps, IState> {
constructor(props: IProps) { constructor(props: IProps) {
super(props) super(props)
this.toggleModalVisible = this.toggleModalVisible.bind(this) this.toggleModalVisible = this.toggleModalVisible.bind(this)
this.getData = this.getData.bind(this) this.getData = debounce(this.getData.bind(this), 300)
} }
state = { state = {
modalVisible: false, modalVisible: false,
data: [], data: [],
loading: false, loading: false,
pagination: {
start_index: 0,
limit: 10,
},
filterData: {},
isEnd: false,
} }
componentDidMount() { componentDidMount() {
...@@ -58,17 +65,48 @@ class Settlement extends React.Component<IProps, IState> { ...@@ -58,17 +65,48 @@ class Settlement extends React.Component<IProps, IState> {
* @param {*} * @param {*}
* @return {*} * @return {*}
*/ */
async getData(args): void { async getData(args, isRefresh = false, isNext = false): void {
this.setState({ loading: true })
// 确认页面只过滤出已输入的那些 // 确认页面只过滤出已输入的那些
args.status = 'ENTERED' let { pagination, filterData, data, isEnd } = this.state
if (isRefresh || isNotBlank(args)) {
pagination.start_index = 0
}
if (isNext) {
pagination.start_index += pagination.limit
const res = await api.getSettlements(args) if (isEnd) return
}
if (isBlank(args)) {
args = filterData
}
const params = {
...args,
...pagination,
}
args.header_status = 'ENTERED'
if (!isRefresh && !isNext) {
this.setState({ loading: true })
}
const res = await api.getSettlements(params)
this.setState({ loading: false }) this.setState({ loading: false })
if (res.error_code !== 0) return if (res.error_code !== 0) return
const data = R.propOr([], 'data')(res) const newData = R.propOr([], 'data')(res)
this.setState({ data }) if (isBlank(newData) || newData.length < pagination.limit) {
isEnd = true
} else {
isEnd = false
}
if (isNext) {
data = R.concat(data, newData)
} else {
data = newData
}
this.setState({ data, filterData: args, isEnd })
} }
render() { render() {
...@@ -93,7 +131,11 @@ class Settlement extends React.Component<IProps, IState> { ...@@ -93,7 +131,11 @@ class Settlement extends React.Component<IProps, IState> {
{/* 过滤弹窗 */} {/* 过滤弹窗 */}
<FilterModal visible={modalVisible} onClose={this.toggleModalVisible} searchHandler={this.getData} /> <FilterModal visible={modalVisible} onClose={this.toggleModalVisible} searchHandler={this.getData} />
{loading ? <Loading show={loading} /> : <SettlementList data={data} {...this.props} />} {loading ? (
<Loading show={loading} />
) : (
<SettlementList data={data} {...this.props} getData={this.getData} />
)}
</View> </View>
</Resolution.FixWidthView> </Resolution.FixWidthView>
</View> </View>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment