|
|
@@ -26,7 +26,13 @@ import { saveListState } from '../../../redux/actions/listState'
|
|
|
import { LIST_PAGE_SIZE } from '../../../configs/constans.config'
|
|
|
import CurrencyDetail from '../currencyDetail/CurrencyDetail'
|
|
|
import { refreshFormState } from '../../../redux/actions/formState'
|
|
|
-import { getFormAndGrid } from '../../../utils/common/form.request'
|
|
|
+import {
|
|
|
+ getBillGroup,
|
|
|
+ getFormAndGrid,
|
|
|
+} from '../../../utils/common/form.request'
|
|
|
+import { fetchPostObj } from '../../../utils/common/fetchRequest'
|
|
|
+import { API } from '../../../configs/api.config'
|
|
|
+import { message } from 'antd'
|
|
|
|
|
|
class CurrencyList extends Component {
|
|
|
|
|
|
@@ -56,27 +62,28 @@ class CurrencyList extends Component {
|
|
|
})
|
|
|
|
|
|
const {
|
|
|
- requestList,
|
|
|
- requestTab,
|
|
|
+ tabUrl,
|
|
|
+ listUrl,
|
|
|
listState: { tabList, listData },
|
|
|
} = this.props
|
|
|
|
|
|
- if (isObjEmpty(tabList) && isObjEmpty(listData) && !isObjNull(requestTab)) {
|
|
|
- requestTab()
|
|
|
- } else if (isObjEmpty(listData) && !isObjNull(requestList)) {
|
|
|
+ if (isObjEmpty(tabList) && isObjEmpty(listData) && !isObjNull(tabUrl)) {
|
|
|
+ this.requestTab()
|
|
|
+ } else if (isObjEmpty(listData) && !isObjNull(listUrl)) {
|
|
|
saveListState({
|
|
|
pageIndex: 0,
|
|
|
})
|
|
|
- requestList()
|
|
|
+ this.requestList()
|
|
|
} else {
|
|
|
this.recoveryScroll()
|
|
|
}
|
|
|
+
|
|
|
const {
|
|
|
- requestSearchConfig,
|
|
|
+ searchUrl,
|
|
|
formState: { filterGroupList },
|
|
|
} = this.props
|
|
|
- if (isObjEmpty(filterGroupList) && !isObjNull(requestSearchConfig)) {
|
|
|
- requestSearchConfig()
|
|
|
+ if (isObjEmpty(filterGroupList) && !isObjNull(searchUrl)) {
|
|
|
+ this.requestSearchConfig()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -85,8 +92,24 @@ class CurrencyList extends Component {
|
|
|
}
|
|
|
|
|
|
render () {
|
|
|
- const { listState: { tabList, tabSelect, listData, pageIndex }, rowCount, addAble } = this.props
|
|
|
- const { listDataSource, height, hasNextPage, filterOpen } = this.state
|
|
|
+ const {
|
|
|
+ listState: {
|
|
|
+ tabList,
|
|
|
+ tabSelect,
|
|
|
+ listData,
|
|
|
+ pageIndex,
|
|
|
+ searchValue,
|
|
|
+ },
|
|
|
+ rowCount,
|
|
|
+ addAble,
|
|
|
+ filterAble,
|
|
|
+ } = this.props
|
|
|
+ const {
|
|
|
+ listDataSource,
|
|
|
+ height,
|
|
|
+ hasNextPage,
|
|
|
+ filterOpen,
|
|
|
+ } = this.state
|
|
|
|
|
|
const refreshLayout = this.getRefreshLayout()
|
|
|
const filterLayout = this.getFilterLayout()
|
|
|
@@ -117,11 +140,18 @@ class CurrencyList extends Component {
|
|
|
<SearchBar
|
|
|
className='currency-list-search-search'
|
|
|
placeholder={'搜索'}
|
|
|
+ value={searchValue}
|
|
|
+ onSubmit={this.onSearchSubmit}
|
|
|
+ onChange={this.onSearchChange}
|
|
|
+ onCancel={this.onSearchCancel}
|
|
|
/>
|
|
|
- <UasIcon
|
|
|
- className='currency-list-search-filter'
|
|
|
- type={'uas-search-filter'}
|
|
|
- onClick={this.onFilterOpen}/>
|
|
|
+ {
|
|
|
+ filterAble && <UasIcon
|
|
|
+ className='currency-list-search-filter'
|
|
|
+ type={'uas-search-filter'}
|
|
|
+ onClick={this.onFilterOpen}/>
|
|
|
+ }
|
|
|
+
|
|
|
</div>
|
|
|
<div className='currency-list-tab-root'>
|
|
|
{tabItems}
|
|
|
@@ -137,17 +167,15 @@ class CurrencyList extends Component {
|
|
|
return <CurrencyListItem
|
|
|
rowCount={rowCount}
|
|
|
rowData={rowData}
|
|
|
- onItemClick={this.onItemClick}/>
|
|
|
+ onItemClick={this.onItemClick}
|
|
|
+ />
|
|
|
}}
|
|
|
style={{
|
|
|
height,
|
|
|
}}
|
|
|
- onContentSizeChange={() => {
|
|
|
- console.log('onContentSizeChange', 'onContentSizeChange')
|
|
|
- }}
|
|
|
pullToRefresh={refreshLayout}
|
|
|
onEndReachedThreshold={10}
|
|
|
- onEndReached={hasNextPage ? this.loadDataList : null}
|
|
|
+ onEndReached={hasNextPage ? this.requestList : null}
|
|
|
pageSize={LIST_PAGE_SIZE}
|
|
|
/>
|
|
|
{this.props.children}
|
|
|
@@ -181,7 +209,7 @@ class CurrencyList extends Component {
|
|
|
pageIndex: 0,
|
|
|
listData: [],
|
|
|
})
|
|
|
- this.loadDataList()
|
|
|
+ this.requestList()
|
|
|
}}
|
|
|
/>
|
|
|
}
|
|
|
@@ -196,7 +224,7 @@ class CurrencyList extends Component {
|
|
|
<CurrencyDetail
|
|
|
onRef={ref => this.cd = ref}
|
|
|
caller={params.caller}
|
|
|
- id={params.id}
|
|
|
+ id={0}
|
|
|
formData={filterGroupList}
|
|
|
>
|
|
|
<div className='currency-list-content-filter-func'>
|
|
|
@@ -223,23 +251,111 @@ class CurrencyList extends Component {
|
|
|
})
|
|
|
//Todo 解决redux修改数据不同步问题
|
|
|
setTimeout(() => {
|
|
|
- this.loadDataList()
|
|
|
+ this.requestList()
|
|
|
}, 0)
|
|
|
}
|
|
|
|
|
|
- loadDataList = () => {
|
|
|
- const { requestList, listState: { tabList, tabSelect } } = this.props
|
|
|
-
|
|
|
- requestList && requestList(tabList ? tabList[tabSelect].CODE : '')
|
|
|
- .then(() => {
|
|
|
- this.setState({
|
|
|
- refreshing: false,
|
|
|
- })
|
|
|
- }).catch(() => {
|
|
|
- this.setState({
|
|
|
- refreshing: false,
|
|
|
+ /**
|
|
|
+ * 获取应用状态列表
|
|
|
+ */
|
|
|
+ requestTab () {
|
|
|
+ const { tabUrl, params } = this.props
|
|
|
+ Toast.loading('', 0)
|
|
|
+ fetchPostObj(tabUrl, params).then(response => {
|
|
|
+ Toast.hide()
|
|
|
+ if (!isObjEmpty(response, response.data, response.data.list)) {
|
|
|
+ saveListState({
|
|
|
+ tabList: response.data.list,
|
|
|
+ tabSelect: 0,
|
|
|
})
|
|
|
+ this.requestList()
|
|
|
+ } else {
|
|
|
+ this.requestList()
|
|
|
+ }
|
|
|
+ }).catch(error => {
|
|
|
+ Toast.hide()
|
|
|
+ if (typeof error === 'string') {
|
|
|
+ message.error(error)
|
|
|
+ } else {
|
|
|
+ message.error('应用状态获取失败')
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取单据列表
|
|
|
+ * @param code
|
|
|
+ */
|
|
|
+ requestList = (extraParams) => {
|
|
|
+ let {
|
|
|
+ listUrl,
|
|
|
+ params,
|
|
|
+ listState: { listData, pageIndex, oldSearch, tabList, tabSelect },
|
|
|
+ } = this.props
|
|
|
+
|
|
|
+ pageIndex++
|
|
|
+ if (pageIndex === 1) {
|
|
|
+ listData = []
|
|
|
+ }
|
|
|
+ return fetchPostObj(listUrl, {
|
|
|
+ code: tabList ? tabList[tabSelect].CODE : '',
|
|
|
+ pageIndex,
|
|
|
+ pageSize: LIST_PAGE_SIZE,
|
|
|
+ condition: '1=1',
|
|
|
+ keyWords: oldSearch,
|
|
|
+ ...params,
|
|
|
+ ...extraParams,
|
|
|
+ }).then(response => {
|
|
|
+ if (!isObjEmpty(response, response.data, response.data.list)) {
|
|
|
+ listData = listData.concat(response.data.list)
|
|
|
+ } else {
|
|
|
+ pageIndex--
|
|
|
+ }
|
|
|
+ this.setState({
|
|
|
+ refreshing: false,
|
|
|
})
|
|
|
+ saveListState({
|
|
|
+ listData,
|
|
|
+ pageIndex,
|
|
|
+ })
|
|
|
+ }).catch(error => {
|
|
|
+ pageIndex--
|
|
|
+ if (typeof error === 'string') {
|
|
|
+ message.error(error)
|
|
|
+ } else {
|
|
|
+ message.error('数据获取失败')
|
|
|
+ }
|
|
|
+ this.setState({
|
|
|
+ refreshing: false,
|
|
|
+ })
|
|
|
+ saveListState({
|
|
|
+ listData,
|
|
|
+ pageIndex,
|
|
|
+ })
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取筛选条件配置
|
|
|
+ */
|
|
|
+ requestSearchConfig = () => {
|
|
|
+ const { searchUrl, params } = this.props
|
|
|
+ fetchPostObj(searchUrl, params).then(response => {
|
|
|
+ if (!isObjEmpty(response, response.data, response.data.list)) {
|
|
|
+ const formGroup = {
|
|
|
+ groupTitle: '筛选条件',
|
|
|
+ isForm: true,
|
|
|
+ fieldList: response.data.list,
|
|
|
+ }
|
|
|
+ const billGroup = getBillGroup(formGroup, 0)
|
|
|
+ const billGroupList = [billGroup]
|
|
|
+ refreshFormState({
|
|
|
+ filterGroupList: billGroupList,
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }).catch(error => {
|
|
|
+
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
onItemClick = (rowData) => {
|
|
|
@@ -283,6 +399,38 @@ class CurrencyList extends Component {
|
|
|
let formAndGrid = getFormAndGrid(filterGroupList)
|
|
|
console.log(formAndGrid)
|
|
|
}
|
|
|
+
|
|
|
+ onSearchChange = (val) => {
|
|
|
+ saveListState({
|
|
|
+ searchValue: val,
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ onSearchSubmit = (val) => {
|
|
|
+ this.searchSubmit(val)
|
|
|
+ }
|
|
|
+
|
|
|
+ onSearchCancel = (val) => {
|
|
|
+ saveListState({
|
|
|
+ searchValue: '',
|
|
|
+ })
|
|
|
+ const { oldSearch } = this.props.listState
|
|
|
+ if (!isObjEmpty(oldSearch)) {
|
|
|
+ this.searchSubmit('')
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ searchSubmit = (keyword) => {
|
|
|
+ saveListState({
|
|
|
+ pageIndex: 0,
|
|
|
+ listData: [],
|
|
|
+ oldSearch: keyword,
|
|
|
+ })
|
|
|
+ //Todo 解决redux修改数据不同步问题
|
|
|
+ setTimeout(() => {
|
|
|
+ this.requestList()
|
|
|
+ }, 0)
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
let mapStateToProps = (state) => ({
|