|
|
@@ -5,7 +5,7 @@
|
|
|
|
|
|
import React, { Component } from 'react'
|
|
|
import ReactDOM from 'react-dom'
|
|
|
-import { TabBar } from 'antd-mobile'
|
|
|
+import { TabBar, SearchBar } from 'antd-mobile'
|
|
|
import { List, Icon, Skeleton, message } from 'antd'
|
|
|
import './approval.css'
|
|
|
import Swiper from 'swiper/js/swiper.min'
|
|
|
@@ -41,8 +41,6 @@ let mBaseUrl = window.location.origin
|
|
|
// && 'http://erp.yitoa.com:8888/ERP'
|
|
|
// && 'http://29226oq576.qicp.vip/erp'
|
|
|
|
|
|
-// process.env.REACT_APP_ROUTER_BASE_NAME || '/ERP'
|
|
|
-
|
|
|
class ApprovalHome extends Component {
|
|
|
|
|
|
constructor () {
|
|
|
@@ -60,6 +58,8 @@ class ApprovalHome extends Component {
|
|
|
// sendHeight: document.documentElement.clientHeight,
|
|
|
isSendRefresh: false,
|
|
|
isSendLoading: true,
|
|
|
+ receiveKey: '',
|
|
|
+ sendKey: '',
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -94,6 +94,11 @@ class ApprovalHome extends Component {
|
|
|
|
|
|
this.initSwiper(receiveState)
|
|
|
|
|
|
+ this.setState({
|
|
|
+ receiveKey: receiveState.searchKey,
|
|
|
+ sendKey: sendState.searchKey,
|
|
|
+ })
|
|
|
+
|
|
|
let pageType = this.props.match.params.type
|
|
|
if (pageType == 'receive') {
|
|
|
selectedTab = 1
|
|
|
@@ -129,7 +134,7 @@ class ApprovalHome extends Component {
|
|
|
this.mySwiper = new Swiper('.swiper-container', {
|
|
|
autoplay: false,
|
|
|
loop: false,
|
|
|
- noSwiping: false,
|
|
|
+ noSwiping: true,
|
|
|
initialSlide: receiveState.tabIndex,
|
|
|
on: {
|
|
|
slideChangeTransitionEnd: function () {
|
|
|
@@ -432,12 +437,37 @@ class ApprovalHome extends Component {
|
|
|
}
|
|
|
|
|
|
renderReceiveTab = () => {
|
|
|
- const { homeState: { receiveState: { tabIndex } } } = this.props
|
|
|
+ const { homeState: { receiveState } } = this.props
|
|
|
+ const { tabIndex } = receiveState
|
|
|
const todoItems = this.renderReceiveTodoItems()
|
|
|
const doneItems = this.renderReceiveDoneItems()
|
|
|
return (
|
|
|
<div className='receive-root'>
|
|
|
- <div className='line'></div>
|
|
|
+ <SearchBar
|
|
|
+ value={this.state.receiveKey}
|
|
|
+ placeholder={'搜索单据'}
|
|
|
+ maxLength={16}
|
|
|
+ onChange={value => {
|
|
|
+ this.setState({
|
|
|
+ receiveKey: value,
|
|
|
+ })
|
|
|
+ }}
|
|
|
+ onClear={value => {
|
|
|
+ this.setState({
|
|
|
+ receiveKey: value,
|
|
|
+ })
|
|
|
+ }}
|
|
|
+ onCancel={() => {
|
|
|
+ this.setState({
|
|
|
+ receiveKey: '',
|
|
|
+ })
|
|
|
+ if (!isObjEmpty(receiveState.searchKey)) {
|
|
|
+ this.searchSubmit(0, '')
|
|
|
+ }
|
|
|
+ }}
|
|
|
+ onSubmit={this.searchSubmit.bind(this, 0, this.state.receiveKey)}
|
|
|
+ />
|
|
|
+ {/*<div className='line'></div>*/}
|
|
|
<div className='identity-select'>
|
|
|
<div className={tabIndex === 0 ?
|
|
|
'identity-item-select' : 'identity-item-normal'}
|
|
|
@@ -473,10 +503,10 @@ class ApprovalHome extends Component {
|
|
|
this.contain = el
|
|
|
}}>
|
|
|
<div className="swiper-wrapper">
|
|
|
- <div className="swiper-slide">
|
|
|
+ <div className="swiper-slide swiper-no-swiping">
|
|
|
{todoItems}
|
|
|
</div>
|
|
|
- <div className="swiper-slide">
|
|
|
+ <div className="swiper-slide swiper-no-swiping">
|
|
|
{doneItems}
|
|
|
</div>
|
|
|
</div>
|
|
|
@@ -516,6 +546,8 @@ class ApprovalHome extends Component {
|
|
|
}
|
|
|
|
|
|
renderSendTab = () => {
|
|
|
+ const { homeState: { sendState } } = this.props
|
|
|
+
|
|
|
return (
|
|
|
<div className='receive-content-root'>
|
|
|
{/*<RefreshLayout*/}
|
|
|
@@ -537,30 +569,57 @@ class ApprovalHome extends Component {
|
|
|
{/* )}/>*/}
|
|
|
{/* </Skeleton>*/}
|
|
|
{/*</RefreshLayout>*/}
|
|
|
-
|
|
|
- <InfiniteScroll
|
|
|
- initialLoad={false}
|
|
|
- pageStart={0}
|
|
|
- ref={el => {
|
|
|
- this.sendList = el
|
|
|
+ <SearchBar
|
|
|
+ value={this.state.sendKey}
|
|
|
+ placeholder={'搜索单据'}
|
|
|
+ maxLength={16}
|
|
|
+ onChange={value => {
|
|
|
+ this.setState({
|
|
|
+ sendKey: value,
|
|
|
+ })
|
|
|
+ }}
|
|
|
+ onClear={value => {
|
|
|
+ this.setState({
|
|
|
+ sendKey: value,
|
|
|
+ })
|
|
|
}}
|
|
|
- loadMore={this.loadSendList}
|
|
|
- hasMore={this.props.homeState.sendState.sendHasMore}
|
|
|
- loader={<LoadingMore/>}
|
|
|
- threshold={1}
|
|
|
- useWindow={false}>
|
|
|
- <Skeleton loading={this.state.isSendLoading} active
|
|
|
- paragraph={{ rows: 4 }}>
|
|
|
- <List split={false}
|
|
|
- dataSource={this.props.homeState.sendState.sendList}
|
|
|
- renderItem={(item, index) => (
|
|
|
- <ApprovalItem approval={item}
|
|
|
- type={3}
|
|
|
- onItemClick={this.onSendItemClick.bind(this)}
|
|
|
- index={index}/>
|
|
|
- )}/>
|
|
|
- </Skeleton>
|
|
|
- </InfiniteScroll>
|
|
|
+ onCancel={() => {
|
|
|
+ this.setState({
|
|
|
+ sendKey: '',
|
|
|
+ })
|
|
|
+ if (!isObjEmpty(sendState.searchKey)) {
|
|
|
+ this.searchSubmit(1, '')
|
|
|
+ }
|
|
|
+ }}
|
|
|
+ onSubmit={this.searchSubmit.bind(this, 1, this.state.sendKey)}
|
|
|
+ />
|
|
|
+ <div className='receive-content-root'>
|
|
|
+ <InfiniteScroll
|
|
|
+ initialLoad={false}
|
|
|
+ pageStart={0}
|
|
|
+ ref={el => {
|
|
|
+ this.sendList = el
|
|
|
+ }}
|
|
|
+ loadMore={this.loadSendList}
|
|
|
+ hasMore={sendState.sendHasMore}
|
|
|
+ loader={<LoadingMore/>}
|
|
|
+ threshold={1}
|
|
|
+ useWindow={false}>
|
|
|
+ <Skeleton loading={this.state.isSendLoading} active
|
|
|
+ paragraph={{ rows: 4 }}>
|
|
|
+ <List split={false}
|
|
|
+ dataSource={sendState.sendList}
|
|
|
+ renderItem={(item, index) => (
|
|
|
+ <ApprovalItem approval={item}
|
|
|
+ type={3}
|
|
|
+ onItemClick={this.onSendItemClick.bind(
|
|
|
+ this)}
|
|
|
+ index={index}/>
|
|
|
+ )}/>
|
|
|
+ </Skeleton>
|
|
|
+ </InfiniteScroll>
|
|
|
+ </div>
|
|
|
+
|
|
|
</div>
|
|
|
)
|
|
|
}
|
|
|
@@ -683,6 +742,49 @@ class ApprovalHome extends Component {
|
|
|
return newMenu
|
|
|
}
|
|
|
|
|
|
+ searchSubmit = (type, value) => {
|
|
|
+ if (type === 0) {
|
|
|
+ const { isReceiveTodoLoading, isReceiveDoneLoading } = this.state
|
|
|
+ this.setState({
|
|
|
+ receiveKey: value,
|
|
|
+ })
|
|
|
+ clearReceiveState({
|
|
|
+ searchKey: value,
|
|
|
+ tabIndex: this.props.homeState.receiveState.tabIndex,
|
|
|
+ })()
|
|
|
+ // this.mySwiper.slideTo(0, 0, false)
|
|
|
+ if (!isReceiveTodoLoading) {
|
|
|
+ this.setState({
|
|
|
+ isReceiveTodoLoading: true,
|
|
|
+ })
|
|
|
+ mTodoIndex = 0
|
|
|
+ this.loadTodoList(value)
|
|
|
+ }
|
|
|
+ if (!isReceiveDoneLoading) {
|
|
|
+ this.setState({
|
|
|
+ isReceiveDoneLoading: true,
|
|
|
+ })
|
|
|
+ mDoneIndex = 0
|
|
|
+ this.loadDoneList(value)
|
|
|
+ }
|
|
|
+ } else if (type === 1) {
|
|
|
+ const { isSendLoading } = this.state
|
|
|
+ this.setState({
|
|
|
+ sendKey: value,
|
|
|
+ })
|
|
|
+ clearSendState({
|
|
|
+ searchKey: value,
|
|
|
+ })()
|
|
|
+ if (!isSendLoading) {
|
|
|
+ this.setState({
|
|
|
+ isSendLoading: true,
|
|
|
+ })
|
|
|
+ mSendIndex = 0
|
|
|
+ this.loadSendList(value)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
onFuncClick = (obj) => {
|
|
|
this.cacheScrollState()
|
|
|
this.props.history.push('/approvalAdd/' + obj.sv_caller + '/' + mMaster)
|
|
|
@@ -772,8 +874,9 @@ class ApprovalHome extends Component {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
- loadTodoList = () => {
|
|
|
- let { homeState: { receiveState: { listData } } } = this.props
|
|
|
+ loadTodoList = (keyword) => {
|
|
|
+ let { homeState: { receiveState } } = this.props
|
|
|
+ let { listData } = receiveState
|
|
|
if (isObjEmpty(listData)) {
|
|
|
mTodoIndex = 0
|
|
|
}
|
|
|
@@ -791,6 +894,7 @@ class ApprovalHome extends Component {
|
|
|
fetchGet(mBaseUrl + '/common/desktop/process/uapproval/toDo.action', {
|
|
|
pageSize: mPageSize,
|
|
|
page: mTodoIndex,
|
|
|
+ keyword: !isObjNull(keyword) ? keyword : receiveState.searchKey,
|
|
|
}).then(response => {
|
|
|
this.setState({
|
|
|
isReceiveTodoLoading: false,
|
|
|
@@ -815,6 +919,7 @@ class ApprovalHome extends Component {
|
|
|
mTodoIndex--
|
|
|
}
|
|
|
saveReceiveState({
|
|
|
+ hasMore1: false,
|
|
|
listData,
|
|
|
pageIndex: mTodoIndex,
|
|
|
})()
|
|
|
@@ -830,8 +935,9 @@ class ApprovalHome extends Component {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
- loadDoneList = () => {
|
|
|
- let { homeState: { receiveState: { listData2 } } } = this.props
|
|
|
+ loadDoneList = (keyword) => {
|
|
|
+ let { homeState: { receiveState } } = this.props
|
|
|
+ let { listData2 } = receiveState
|
|
|
if (isObjEmpty(listData2)) {
|
|
|
mDoneIndex = 0
|
|
|
}
|
|
|
@@ -849,6 +955,7 @@ class ApprovalHome extends Component {
|
|
|
fetchGet(mBaseUrl + '/common/desktop/process/uapproval/alreadyDo.action', {
|
|
|
pageSize: mPageSize,
|
|
|
page: mDoneIndex,
|
|
|
+ keyword: !isObjNull(keyword) ? keyword : receiveState.searchKey,
|
|
|
isMobile: 1,
|
|
|
_do: 1,
|
|
|
}).then(response => {
|
|
|
@@ -875,6 +982,7 @@ class ApprovalHome extends Component {
|
|
|
mDoneIndex--
|
|
|
}
|
|
|
saveReceiveState({
|
|
|
+ hasMore2: false,
|
|
|
listData2,
|
|
|
pageIndex: mDoneIndex,
|
|
|
})()
|
|
|
@@ -890,8 +998,9 @@ class ApprovalHome extends Component {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
- loadSendList = () => {
|
|
|
- let { homeState: { sendState: { sendList } } } = this.props
|
|
|
+ loadSendList = (keyword) => {
|
|
|
+ let { homeState: { sendState } } = this.props
|
|
|
+ let { sendList } = sendState
|
|
|
if (isObjEmpty(sendList)) {
|
|
|
mSendIndex = 0
|
|
|
}
|
|
|
@@ -911,6 +1020,7 @@ class ApprovalHome extends Component {
|
|
|
{
|
|
|
pageSize: mPageSize,
|
|
|
page: mSendIndex,
|
|
|
+ keyword: !isObjNull(keyword) ? keyword : sendState.searchKey,
|
|
|
isMobile: 1,
|
|
|
_do: 1,
|
|
|
}).then(response => {
|
|
|
@@ -936,6 +1046,7 @@ class ApprovalHome extends Component {
|
|
|
mSendIndex--
|
|
|
}
|
|
|
saveSendState({
|
|
|
+ sendHasMore: false,
|
|
|
sendList,
|
|
|
pageIndex: mSendIndex,
|
|
|
})()
|