Commit 79de63e3 by lhc

fix: bug

parent 5a971a0e
...@@ -866,91 +866,92 @@ class ChooseProductPage extends Component { ...@@ -866,91 +866,92 @@ class ChooseProductPage extends Component {
// 返回搜索元素 // 返回搜索元素
renderSearchItem() { renderSearchItem() {
const { navigation } = this.props const { navigation } = this.props
const { leftActiveIndex, filterData, authorizations, topProcOptionList } = this.state const { authorizations, topProcOptionList, topActiveIndex } = this.state
let cur_org_code = '' let cur_org_code = ''
if (navigation.state.params.selfData) { if (navigation.state.params.selfData) {
cur_org_code = navigation.state.params.selfData.org_code cur_org_code = navigation.state.params.selfData.org_code
} }
if (leftActiveIndex) { // if (leftActiveIndex) {
return ( return (
<TouchableOpacity <TouchableOpacity
onPress={() => { onPress={() => {
navigation.navigate('SearchPage', { navigation.navigate('SearchPage', {
title: `选择产品`, title: `选择产品`,
topProcOptionList, topProcOptionList,
title: '搜索', topActiveIndex,
setTopProcOptionListCallBack: setTopProcOptionList => { title: '搜索',
console.log('click') setTopProcOptionListCallBack: setTopProcOptionList => {
setTopProcOptionList.then(topProcOptionList => { console.log('click')
console.log('addSuccess') setTopProcOptionList.then(topProcOptionList => {
this.setState( console.log('addSuccess')
{ this.setState(
topProcOptionList: [...topProcOptionList], {
}, topProcOptionList: [...topProcOptionList],
// () => { },
// console.log('goback') // () => {
// this.props.navigation.goBack() // console.log('goback')
// }, // this.props.navigation.goBack()
) // },
}) )
},
selfData: {
org_code: cur_org_code,
authorizations,
},
})
}}
>
<View style={list_common_item.ser_cont}>
<View style={list_common_item.ser_text_input}></View>
<View style={list_common_item.ser_img_box}>
<Image source={require('../../../images/search_icon.png')} style={icon_style} />
</View>
</View>
</TouchableOpacity>
)
} else {
return (
<View>
<TouchableOpacity
onPress={() => {
navigation.navigate('SearchPage', {
title: `选择产品`,
topProcOptionList,
title: '搜索',
setTopProcOptionListCallBack: setTopProcOptionList => {
console.log('click')
setTopProcOptionList.then(topProcOptionList => {
console.log('addSuccess')
this.setState(
{
topProcOptionList: [...topProcOptionList],
},
// () => {
// console.log('goback')
// this.props.navigation.goBack()
// },
)
})
},
selfData: {
org_code: cur_org_code,
authorizations,
},
}) })
}} },
> selfData: {
<View style={list_common_item.ser_cont}> org_code: cur_org_code,
<View style={list_common_item.ser_text_input}></View> authorizations,
<View style={list_common_item.ser_img_box}> },
<Image source={require('../../../images/search_icon.png')} style={icon_style} /> })
</View> }}
</View> >
</TouchableOpacity> <View style={list_common_item.ser_cont}>
<ChooseFilter filterData={filterData} onCallback={this.fillterCallback.bind(this)} /> <View style={list_common_item.ser_text_input}></View>
<View style={list_common_item.ser_img_box}>
<Image source={require('../../../images/search_icon.png')} style={icon_style} />
</View>
</View> </View>
) </TouchableOpacity>
} )
// } else {
// return (
// <View>
// <TouchableOpacity
// onPress={() => {
// navigation.navigate('SearchPage', {
// title: `选择产品`,
// topProcOptionList,
// title: '搜索',
// setTopProcOptionListCallBack: setTopProcOptionList => {
// console.log('click')
// setTopProcOptionList.then(topProcOptionList => {
// console.log('addSuccess')
// this.setState(
// {
// topProcOptionList: [...topProcOptionList],
// },
// // () => {
// // console.log('goback')
// // this.props.navigation.goBack()
// // },
// )
// })
// },
// selfData: {
// org_code: cur_org_code,
// authorizations,
// },
// })
// }}
// >
// <View style={list_common_item.ser_cont}>
// <View style={list_common_item.ser_text_input}></View>
// <View style={list_common_item.ser_img_box}>
// <Image source={require('../../../images/search_icon.png')} style={icon_style} />
// </View>
// </View>
// </TouchableOpacity>
// <ChooseFilter filterData={filterData} onCallback={this.fillterCallback.bind(this)} />
// </View>
// )
// }
} }
// 返回顶部厂家 // 返回顶部厂家
......
...@@ -18,14 +18,13 @@ import LocalVariable from '../../common/LocalVariable' ...@@ -18,14 +18,13 @@ import LocalVariable from '../../common/LocalVariable'
import { reqGlobalSearch, reqSingleConsumSearch, reqProCategorySearch } from '../../../action/SelfAction' import { reqGlobalSearch, reqSingleConsumSearch, reqProCategorySearch } from '../../../action/SelfAction'
import ChooseCardList from '../../common/listDataComponent/ChooseCardList' import ChooseCardList from '../../common/listDataComponent/ChooseCardList'
import { connect } from 'react-redux' import { connect } from 'react-redux'
import { cloneObject } from '../../../utils/Utils'
// import ChooseCardList from '../../common/listDataComponent/ChooseCardList'; // import ChooseCardList from '../../common/listDataComponent/ChooseCardList';
import LoadingModel from '../../common/listDataComponent/LoadingModel' import LoadingModel from '../../common/listDataComponent/LoadingModel'
import { Width } from '../../../base/BaseStyle' import { Width } from '../../../base/BaseStyle'
import debounce from 'debounce'
class SearchPage extends Component { class SearchPage extends Component {
constructor(props) { constructor(props) {
super(props) super(props)
this.state = { this.state = {
defalutLeftItem: [ defalutLeftItem: [
{ {
...@@ -50,20 +49,65 @@ class SearchPage extends Component { ...@@ -50,20 +49,65 @@ class SearchPage extends Component {
}, },
], ],
searchValue: '', searchValue: '',
dataList: [], data: {
topActiveIndex: 0, item: [],
total: 0,
},
page: 1,
} }
this.inputSearchValue = debounce(this.inputSearchValue.bind(this), 1000) // this.inputSearchValue = debounce(this.inputSearchValue.bind(this), 1000)
} }
componentDidMount() { componentDidMount() {
this.getSearchData() const { navigation } = this.props
console.log('navigation', navigation)
const { topActiveIndex } = navigation.state.params
this.setState({
topActiveIndex,
})
// this.getSearchData()
}
initData() {
this.setState(
{
data: {
item: [],
total: 0,
},
page: 1,
},
() => {
this.getSearchData()
},
)
}
// 上拉刷新
onMomentumScrollEnd = event => {
const offSetY = event.nativeEvent.contentOffset.y // 获取滑动的距离
const contentSizeHeight = event.nativeEvent.contentSize.height // scrollView contentSize 高度
const oriageScrollHeight = event.nativeEvent.layoutMeasurement.height // scrollView高度
const { page, data } = this.state
if (offSetY + oriageScrollHeight >= contentSizeHeight - 400) {
if (data.item.length < data.total) {
this.setState(
{
page: page + 1,
},
() => {
this.getSearchData()
},
)
}
}
} }
// 获取搜索数据 // 获取搜索数据
async getSearchData() { async getSearchData() {
const { navigation, global_domain_config, token } = this.props const { navigation, global_domain_config, token } = this.props
const { topActiveIndex, searchValue } = this.state const { topActiveIndex, searchValue, page, data } = this.state
const { selfData, topProcOptionList } = navigation.state.params const { selfData, topProcOptionList } = navigation.state.params
const { authorizations } = selfData const { authorizations } = selfData
...@@ -77,14 +121,18 @@ class SearchPage extends Component { ...@@ -77,14 +121,18 @@ class SearchPage extends Component {
manufacturerCode: topProcOptionList[topActiveIndex].supplier_code, manufacturerCode: topProcOptionList[topActiveIndex].supplier_code,
productLineCategory, productLineCategory,
keyword: encodeURIComponent(searchValue), keyword: encodeURIComponent(searchValue),
pageSize: 9999, page,
} }
this.refs.LoadingModel.show() this.refs.LoadingModel.show()
const single_all_search = await reqGlobalSearch(global_domain_config, JSON.parse(JSON.stringify(params))) const single_all_search = await reqGlobalSearch(global_domain_config, JSON.parse(JSON.stringify(params)))
this.refs.LoadingModel.hide() this.refs.LoadingModel.hide()
console.log('single_all_search', single_all_search) console.log('single_all_search', single_all_search)
const oldData = data.item
this.setState({ this.setState({
dataList: single_all_search?.data?.item ? single_all_search?.data?.item : [], data: {
...single_all_search?.data,
item: [...oldData, ...single_all_search?.data.item],
},
}) })
} }
...@@ -260,7 +308,10 @@ class SearchPage extends Component { ...@@ -260,7 +308,10 @@ class SearchPage extends Component {
} }
}), }),
} }
this.props.navigation.goBack() // this.props.navigation.goBack()
this.setState({
topProcOptionList,
})
return Promise.resolve(topProcOptionList) return Promise.resolve(topProcOptionList)
} }
...@@ -321,7 +372,7 @@ class SearchPage extends Component { ...@@ -321,7 +372,7 @@ class SearchPage extends Component {
topActiveIndex, topActiveIndex,
}, },
() => { () => {
this.getSearchData() this.initData()
}, },
) )
} }
...@@ -331,11 +382,11 @@ class SearchPage extends Component { ...@@ -331,11 +382,11 @@ class SearchPage extends Component {
render() { render() {
const { navigation } = this.props const { navigation } = this.props
const { title, topProcOptionList } = navigation.state.params const { title, topProcOptionList } = navigation.state.params
const { dataList, topActiveIndex } = this.state const { data, topActiveIndex } = this.state
const cur_icon = 'supplier_icon' const cur_icon = 'supplier_icon'
console.log('dataList', dataList) console.log('dataList', data.item)
return ( return (
<SafeAreaView style={safe_view}> <SafeAreaView style={safe_view}>
<HeadBackItem title={title} navigation={navigation} /> <HeadBackItem title={title} navigation={navigation} />
...@@ -348,7 +399,7 @@ class SearchPage extends Component { ...@@ -348,7 +399,7 @@ class SearchPage extends Component {
<View style={list_common_item.ser_btn}> <View style={list_common_item.ser_btn}>
<TouchableOpacity <TouchableOpacity
onPress={() => { onPress={() => {
this.getSearchData() this.initData()
}} }}
> >
<Text style={list_common_item.ser_text_btn}>搜索</Text> <Text style={list_common_item.ser_text_btn}>搜索</Text>
...@@ -375,17 +426,21 @@ class SearchPage extends Component { ...@@ -375,17 +426,21 @@ class SearchPage extends Component {
cardShowDefIcon={true} cardShowDefIcon={true}
/> />
<ScrollView showsVerticalScrollIndicator={false}> <ScrollView showsVerticalScrollIndicator={false} onScrollEndDrag={this.onMomentumScrollEnd}>
{dataList.length > 0 ? ( {data.item.length > 0 && (
<FlatList <FlatList
keyExtractor={item => item.id} keyExtractor={item => item.id}
data={dataList} data={data.item}
extraData={this.state} extraData={this.state}
renderItem={({ item, index }) => this.renderContColumnItem(item, index)} renderItem={({ item, index }) => this.renderContColumnItem(item, index)}
/> />
) : (
<PicListNoData />
)} )}
{data.item.length === data.total && data?.item?.length > 0 && (
<View>
<Text style={{ textAlign: 'center', lineHeight: 40 }}>没有更多数据了</Text>
</View>
)}
{!data?.item?.length && <PicListNoData />}
</ScrollView> </ScrollView>
<LoadingModel ref="LoadingModel" /> <LoadingModel ref="LoadingModel" />
</SafeAreaView> </SafeAreaView>
......
...@@ -83,7 +83,7 @@ class Settlement extends React.Component<IProps, IState> { ...@@ -83,7 +83,7 @@ class Settlement extends React.Component<IProps, IState> {
args = filterData args = filterData
} }
args.header_status = 'ENTERED' args.header_status = 'SETTLING'
const params = R.filter(isNotBlank)({ const params = R.filter(isNotBlank)({
...args, ...args,
...pagination, ...pagination,
......
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