Toggle navigation
Toggle navigation
This project
Loading...
Sign in
mobile
/
yh_vendor
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
叶弯弯
9 years ago
Commit
c3915edbcfaf6e3ce5ea4517bfb5509606b1b83a
1 parent
6bb59525
发货入库接口调试。修复了一个日期bug。reviewed by yuliang。
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
98 additions
and
46 deletions
js/components/StockStats.js
js/containers/DeliveryStatsContainer.js
js/containers/StockStatsContainer.js
js/reducers/deliveryStats/deliveryStatsActions.js
js/reducers/deliveryStats/deliveryStatsInitialState.js
js/reducers/deliveryStats/deliveryStatsReducer.js
js/services/HomeService.js
js/utils/dateTool.js
js/components/StockStats.js
View file @
c3915ed
...
...
@@ -4,6 +4,7 @@ import React, {Component} from 'react';
import
PlainTextSection
from
'./PlainTextSection'
;
import
Placeholder
from
'./Placeholder'
;
import
LoadMoreIndicator
from
'./indicator/LoadMoreIndicator'
;
import
moment
from
'moment'
;
import
{
StyleSheet
,
...
...
@@ -34,7 +35,7 @@ export default class StockStats extends Component {
return
(
<
View
style
=
{
styles
.
container
}
>
<
PlainTextSection
content
=
{
rowData
.
section2
}
/
>
<
Placeholder
/>
<
Placeholder
containerStyle
=
{{
borderBottomWidth
:
0
}}
/
>
<
/View
>
);
...
...
@@ -44,9 +45,9 @@ export default class StockStats extends Component {
<
View
style
=
{
styles
.
container
}
>
<
View
style
=
{
styles
.
dateContainer
}
>
<
Image
source
=
{
require
(
'../images/date.png'
)}
/
>
<
Text
style
=
{
styles
.
date
}
>
{
rowData
.
section1
}
<
/Text
>
<
Text
style
=
{
styles
.
date
}
>
{
moment
().
subtract
(
1
,
'days'
).
format
(
'YYYY年M月D日'
)
}
<
/Text
>
<
/View
>
<
Placeholder
/>
<
Placeholder
containerStyle
=
{{
borderBottomWidth
:
0
}}
/
>
<
/View
>
);
...
...
js/containers/DeliveryStatsContainer.js
View file @
c3915ed
...
...
@@ -54,7 +54,7 @@ export default class DeliveryStatsContainer extends Component {
}
componentDidMount
()
{
this
.
props
.
actions
.
requestData
();
this
.
_
requestData
();
}
componentWillUnmount
()
{
...
...
@@ -62,7 +62,14 @@ export default class DeliveryStatsContainer extends Component {
}
_requestData
()
{
this
.
props
.
actions
.
requestData
();
let
params
=
{
page
:
this
.
props
.
deliveryStats
.
currentPage
+
1
,
size
:
20
,
beginTime
:
this
.
props
.
deliveryStats
.
startDay
,
endTime
:
this
.
props
.
deliveryStats
.
endDay
,
brandId
:
this
.
props
.
home
.
brandId
,
};
this
.
props
.
actions
.
requestData
(
params
);
}
render
()
{
...
...
@@ -95,6 +102,7 @@ export default class DeliveryStatsContainer extends Component {
section2
=
{
section2
}
content
=
{
this
.
props
.
deliveryStats
.
jsonData
.
toJS
()}
header
=
{
header
}
requestData
=
{
this
.
_requestData
}
/
>
<
/View
>
);
...
...
js/containers/StockStatsContainer.js
View file @
c3915ed
...
...
@@ -67,9 +67,6 @@ export default class StockStatsContainer extends Component {
}
render
()
{
let
date
=
new
Date
();
let
section1
=
date
.
getFullYear
()
+
'年'
+
(
date
.
getMonth
()
+
1
)
+
'月'
+
date
.
getDate
()
+
'日'
;
let
section2
=
[
{
top
:
'库存总数'
,
...
...
@@ -81,7 +78,7 @@ export default class StockStatsContainer extends Component {
}
];
let
dataBlob
=
{
'SECTION_TIME'
:
[{
section1
}],
'SECTION_TIME'
:
[{}],
'SECTION_HEADER'
:
[{
section2
}],
'SECTION_CONTENT'
:
this
.
props
.
stockStats
.
jsonData
,
}
...
...
js/reducers/deliveryStats/deliveryStatsActions.js
View file @
c3915ed
...
...
@@ -13,7 +13,6 @@ const {
}
=
require
(
'../../constants/actionTypes'
).
default
;
export
function
chooseStartDate
(
startDay
)
{
requestData
();
return
{
type
:
CHOOSE_DELIVERY_START_DATE
,
payload
:
startDay
,
...
...
@@ -21,7 +20,6 @@ export function chooseStartDate(startDay) {
}
export
function
chooseEndDate
(
endDay
)
{
requestData
();
return
{
type
:
CHOOSE_DELIVERY_END_DATE
,
payload
:
endDay
,
...
...
@@ -29,7 +27,23 @@ export function chooseEndDate(endDay) {
}
export
function
newDatePicked
(
pickedDate
,
isStartDate
)
{
return
isStartDate
?
chooseStartDate
(
pickedDate
)
:
chooseEndDate
(
pickedDate
);
return
(
dispatch
,
getState
)
=>
{
if
(
isStartDate
)
{
dispatch
(
chooseStartDate
(
pickedDate
));
}
else
{
dispatch
(
chooseEndDate
(
pickedDate
));
}
const
{
deliveryStats
,
home
}
=
getState
();
let
params
=
{
page
:
deliveryStats
.
currentPage
+
1
,
size
:
20
,
beginTime
:
deliveryStats
.
startDay
,
endTime
:
deliveryStats
.
endDay
,
brandId
:
home
.
brandId
,
}
dispatch
(
requestData
(
params
));
};
}
export
function
showDatePickerIOS
(
isShowDatePickerIOS
,
isStartDate
)
{
...
...
@@ -40,7 +54,7 @@ export function showDatePickerIOS(isShowDatePickerIOS, isStartDate) {
}
}
export
function
selected
DateIOS
(
selectedDate
,
isStartDate
)
{
export
function
choose
DateIOS
(
selectedDate
,
isStartDate
)
{
return
{
type
:
SELECT_DELIVERY_DATE_IOS
,
selectedDate
:
selectedDate
,
...
...
@@ -48,6 +62,22 @@ export function selectedDateIOS(selectedDate, isStartDate) {
}
}
export
function
selectedDateIOS
(
selectedDate
,
isStartDate
)
{
return
(
dispatch
,
getState
)
=>
{
dispatch
(
chooseDateIOS
(
selectedDate
,
isStartDate
));
const
{
deliveryStats
,
home
}
=
getState
();
let
params
=
{
page
:
deliveryStats
.
currentPage
+
1
,
size
:
20
,
beginTime
:
deliveryStats
.
startDay
,
endTime
:
deliveryStats
.
endDay
,
brandId
:
home
.
brandId
,
}
dispatch
(
requestData
(
params
));
};
}
export
function
request
()
{
return
{
type
:
DELIVERY_STATS_REQUEST
,
...
...
@@ -68,19 +98,25 @@ export function failure(error) {
}
}
export
function
requestData
()
{
// return dispatch => {
// dispatch(request());
// return new DeliveryStatsService()
// .deliveryStatsData()
// .then(json => {
// dispatch(success(json));
// })
// .catch(error => {
// dispatch(failure(error));
// })
// };
return
success
(
testStockStatsData
);
export
function
requestData
(
params
)
{
return
(
dispatch
,
getState
)
=>
{
const
{
deliveryStats
}
=
getState
();
if
(
deliveryStats
.
currentPage
>=
deliveryStats
.
pageCount
||
deliveryStats
.
isFetching
)
{
//Last page reached....
return
;
}
dispatch
(
request
());
return
new
DeliveryStatsService
()
.
deliveryStatsData
(
params
)
.
then
(
json
=>
{
dispatch
(
success
(
json
));
})
.
catch
(
error
=>
{
dispatch
(
failure
(
error
));
})
};
}
let
testStockStatsData
=
{
...
...
js/reducers/deliveryStats/deliveryStatsInitialState.js
View file @
c3915ed
...
...
@@ -6,7 +6,8 @@ import {getLastDay} from '../../utils/dateTool';
let
InitialState
=
Record
({
error
:
null
,
isFetching
:
false
,
pageCount
:
0
,
currentPage
:
0
,
pageCount
:
1
,
startDay
:
getLastDay
(),
endDay
:
getLastDay
(),
isShowDatePickerIOS
:
false
,
...
...
js/reducers/deliveryStats/deliveryStatsReducer.js
View file @
c3915ed
...
...
@@ -27,15 +27,16 @@ export default function deliveryStatsReducer(state = initialState, action) {
return
nextState
;
}
case
DELIVERY_STATS_SUCCESS
:
{
// const {jsonData} = state;
// let origin = jsonData.toJS();
let
data
=
[...
action
.
payload
.
list
];
// let newPageCount = action.payload.list ? state.pageCount + 1 : state.pageCount;
let
nextState
=
state
.
set
(
'isFetching'
,
false
)
.
set
(
'sum'
,
action
.
payload
.
sum
)
.
set
(
'totalAmount'
,
action
.
payload
.
totalAmount
)
.
set
(
'jsonData'
,
List
(
data
));
// .set('pageCount', newPageCount)
const
{
jsonData
}
=
state
;
let
origin
=
jsonData
.
toJS
();
let
{
additionInfo
,
list
}
=
action
.
payload
;
let
data
=
[...
origin
,
...(
list
||
[])];
let
nextState
=
state
.
set
(
'isFetching'
,
false
)
.
set
(
'sum'
,
additionInfo
.
allNumber
)
.
set
(
'totalAmount'
,
additionInfo
.
allAmount
)
.
set
(
'currentPage'
,
action
.
payload
.
page
)
.
set
(
'pageCount'
,
action
.
payload
.
totalPage
)
.
set
(
'jsonData'
,
Immutable
.
fromJS
(
data
));
return
nextState
;
}
case
DELIVERY_STATS_FAILURE
:
{
...
...
@@ -45,12 +46,16 @@ export default function deliveryStatsReducer(state = initialState, action) {
}
case
CHOOSE_DELIVERY_START_DATE
:
{
let
nextState
=
state
.
set
(
'startDay'
,
action
.
payload
)
.
set
(
'isShowDatePickerIOS'
,
false
);
.
set
(
'isShowDatePickerIOS'
,
false
)
.
set
(
'currentPage'
,
0
)
.
set
(
'pageCount'
,
1
);
return
nextState
;
}
case
CHOOSE_DELIVERY_END_DATE
:
{
let
nextState
=
state
.
set
(
'endDay'
,
action
.
payload
)
.
set
(
'isShowDatePickerIOS'
,
false
);
.
set
(
'isShowDatePickerIOS'
,
false
)
.
set
(
'currentPage'
,
0
)
.
set
(
'pageCount'
,
1
);
return
nextState
;
}
case
SHOW_DELIVERY_DATEPICKER_IOS
:
{
...
...
@@ -60,7 +65,7 @@ export default function deliveryStatsReducer(state = initialState, action) {
}
case
SELECT_DELIVERY_DATE_IOS
:
{
let
nextState
=
action
.
isStartDate
?
state
.
set
(
'startDay'
,
action
.
selectedDate
)
:
state
.
set
(
'endDay'
,
action
.
selectedDate
);
return
nextState
;
return
nextState
.
set
(
'currentPage'
,
0
).
set
(
'pageCount'
,
1
)
;
}
case
SWITCH_BRAND
:
...
...
js/services/HomeService.js
View file @
c3915ed
...
...
@@ -50,7 +50,7 @@ export default class UserService {
url
:
''
,
body
:
{
method
:
'app.shops.accountbalance'
,
...
param
s
,
...
param
}
})
.
then
((
json
)
=>
{
...
...
@@ -110,11 +110,16 @@ export default class UserService {
})
}
async
deliveryStatsData
()
{
async
deliveryStatsData
(
params
)
{
return
await
this
.
api
.
get
({
url
:
'
/
'
,
url
:
''
,
body
:
{
method
:
'app.shops.storagein'
,
page
:
params
.
page
,
size
:
params
.
size
,
beginTime
:
moment
(
params
.
beginTime
).
format
(
'YYYYMMDD'
),
endTime
:
moment
(
params
.
endTime
).
format
(
'YYYYMMDD'
),
brandId
:
params
.
brandId
,
}
})
.
then
((
json
)
=>
{
...
...
js/utils/dateTool.js
View file @
c3915ed
'use strict'
import
moment
from
'moment'
;
export
function
getLastDay
()
{
let
date
=
new
Date
();
let
lastDay
=
date
.
getFullYear
()
+
'-'
+
(
date
.
getMonth
()
+
1
)
+
'-'
+
(
date
.
getDate
()
-
1
);
return
lastDay
;
return
moment
().
subtract
(
1
,
'days'
).
format
(
'YYYY-M-D'
);
}
...
...
Please
register
or
login
to post a comment