Authored by 孙凯

部分接口 review by hongmo

... ... @@ -62,6 +62,9 @@ export default class DeliverGoods extends Component {
}
render() {
let {expressList,storehouse} = this.props.resource;
console.log(expressList?expressList.toJS():'s');
console.log(storehouse?storehouse.toJS():'s');
return (
<View style={styles.container}>
... ...
... ... @@ -35,7 +35,8 @@ export default class TransferShipment extends Component {
}
render() {
let {resource} = this.props;
console.log(resource?resource.toJS():'');
return (
<View style={styles.container}>
<ListView
... ...
... ... @@ -110,6 +110,26 @@ export default keyMirror({
REFOUND_STATS_FAILURE: null,
REFOUND_STATS_CLEAN: null,
GET_PURCHASE_LIST_REQUEST: null,
GET_PURCHASE_LIST_SUCCESS: null,
GET_PURCHASE_LIST_FAILURE: null,
DELIVERY_GOODS_REQUEST: null,
DELIVERY_GOODS_SUCCESS: null,
DELIVERY_GOODS_FAILURE: null,
GET_EXPRESS_LIST_REQUEST: null,
GET_EXPRESS_LIST_SUCCESS: null,
GET_EXPRESS_LIST_FAILURE: null,
QUERYBYSUPPLIER_REQUEST: null,
QUERYBYSUPPLIER_SUCCESS: null,
QUERYBYSUPPLIER_FAILURE: null,
STOCKOUT_REQUEST: null,
STOCKOUT_SUCCESS: null,
STOCKOUT_FAILURE: null,
SWITCH_SHOP: null,
LOGOUT: null,
});
... ...
... ... @@ -52,7 +52,8 @@ class DeliverGoodsContainer extends Component {
}
componentDidMount() {
this.props.actions.getExpressList();
this.props.actions.queryBySupplierId();
}
componentWillUnmount() {
... ... @@ -60,9 +61,11 @@ class DeliverGoodsContainer extends Component {
}
render() {
let {deliverGoods} = this.props;
return (
<View style={styles.container}>
<DeliverGoods />
<DeliverGoods resource={deliverGoods}/>
</View>
);
}
... ...
... ... @@ -60,6 +60,8 @@ class OutOfStockContainer extends Component {
}
render() {
let {outOfStock} = this.props;
return (
<View style={styles.container}>
<OutOfStock />
... ...
... ... @@ -53,7 +53,7 @@ class TransferShipmentContainer extends Component {
}
componentDidMount() {
this.props.actions.getPurchaseList();
}
componentWillUnmount() {
... ... @@ -65,9 +65,11 @@ class TransferShipmentContainer extends Component {
}
render() {
let {transferShipment} = this.props;
let {purchaseList} = transferShipment;
return (
<View style={styles.container}>
<TransferShipment goToStatsPage={this._goToStatsPage}/>
<TransferShipment resource={purchaseList} goToStatsPage={this._goToStatsPage}/>
</View>
);
}
... ...
... ... @@ -13,5 +13,143 @@ import {Alert, Linking} from 'react-native';
const {
LOGOUT,
DELIVERY_GOODS_REQUEST,
DELIVERY_GOODS_SUCCESS,
DELIVERY_GOODS_FAILURE,
GET_EXPRESS_LIST_REQUEST,
GET_EXPRESS_LIST_SUCCESS,
GET_EXPRESS_LIST_FAILURE,
QUERYBYSUPPLIER_REQUEST,
QUERYBYSUPPLIER_SUCCESS,
QUERYBYSUPPLIER_FAILURE,
} = require('../../constants/actionTypes').default;
export function deliveryGoodsRequest() {
return {
type: DELIVERY_GOODS_REQUEST,
};
}
export function deliveryGoodsSuccess(json) {
return {
type: DELIVERY_GOODS_SUCCESS,
payload: json,
};
}
export function deliveryGoodsFailure(error) {
return {
type: DELIVERY_GOODS_FAILURE,
payload: error,
};
}
export function deliveryGoods() {
return (dispatch,getState) => {
let {home} = getState();
dispatch(deliveryGoodsRequest())
return new DeliverGoodsService().deliveryGoods()
.then((json) => {
dispatch(deliveryGoodsSuccess(json))
})
.catch((error) => {
dispatch(deliveryGoodsFailure(error))
});
};
}
export function getExpressListRequest() {
return {
type: GET_EXPRESS_LIST_REQUEST,
};
}
export function getExpressListSuccess(json) {
return {
type: GET_EXPRESS_LIST_SUCCESS,
payload: json,
};
}
export function getExpressListFailure(error) {
return {
type: GET_EXPRESS_LIST_FAILURE,
payload: error,
};
}
export function getExpressList() {
return (dispatch,getState) => {
let {home} = getState();
dispatch(getExpressListRequest())
return new DeliverGoodsService().getExpressList()
.then((json) => {
dispatch(getExpressListSuccess(json))
})
.catch((error) => {
dispatch(getExpressListFailure(error))
});
};
}
export function queryBySupplierIdRequest() {
return {
type: QUERYBYSUPPLIER_REQUEST,
};
}
export function queryBySupplierIdSuccess(json) {
return {
type: QUERYBYSUPPLIER_SUCCESS,
payload: json,
};
}
export function queryBySupplierIdFailure(error) {
return {
type: QUERYBYSUPPLIER_FAILURE,
payload: error,
};
}
export function queryBySupplierId() {
return (dispatch,getState) => {
let {home} = getState();
let supplierId = 1;
dispatch(queryBySupplierIdRequest())
return new DeliverGoodsService().queryBySupplierId(supplierId)
.then((json) => {
let res = exposePruductListData(json);
dispatch(queryBySupplierIdSuccess(res))
})
.catch((error) => {
dispatch(queryBySupplierIdFailure(error))
});
};
}
function exposePruductListData(json) {
let adminName=json?json.adminName:'';
let address=json?json.address:'';
let phone=json?json.phone:'';
let storehouseName=json?json.storehouseName:'';
let id=json?json.id:'';
let status=json?json.status:'';
return {
adminName,
address,
phone,
storehouseName,
id,
status,
};
}
... ...
... ... @@ -7,7 +7,21 @@ import {List, Record} from 'immutable';
let InitialState = Record({
expressList: new (Record({
isFetching: false,
error: null,
list: List(),
})),
storehouse: new (Record({
isFetching: false,
error: null,
adminName: '',
address: '',
phone: '',
storehouseName: '',
id: '',
status: '',
})),
});
export default InitialState;
... ...
... ... @@ -12,6 +12,17 @@ import Immutable, {List, Record} from 'immutable';
const {
LOGOUT,
DELIVERY_GOODS_REQUEST,
DELIVERY_GOODS_SUCCESS,
DELIVERY_GOODS_FAILURE,
GET_EXPRESS_LIST_REQUEST,
GET_EXPRESS_LIST_SUCCESS,
GET_EXPRESS_LIST_FAILURE,
QUERYBYSUPPLIER_REQUEST,
QUERYBYSUPPLIER_SUCCESS,
QUERYBYSUPPLIER_FAILURE,
} = require('../../constants/actionTypes').default;
... ... @@ -26,9 +37,46 @@ export default function userReducer(state = initialState, action) {
if (!(state instanceof InitialState)) return initialState.merge(state);
switch (action.type) {
case LOGOUT:{
case DELIVERY_GOODS_REQUEST:{
return state;
}
case DELIVERY_GOODS_SUCCESS:{
return state;
}
case DELIVERY_GOODS_FAILURE:{
return state;
}
case GET_EXPRESS_LIST_REQUEST:{
return state.setIn(['expressList', 'isFetching'], true)
.setIn(['expressList', 'error'], null);
}
case GET_EXPRESS_LIST_SUCCESS:{
return state.setIn(['expressList', 'isFetching'], false)
.setIn(['expressList', 'error'], null)
.setIn(['expressList', 'list'], Immutable.fromJS(action.payload));
}
case GET_EXPRESS_LIST_FAILURE:{
return state.setIn(['expressList', 'isFetching'], false)
.setIn(['expressList', 'error'], action.payload);
}
case QUERYBYSUPPLIER_REQUEST:{
return state.setIn(['storehouse', 'isFetching'], true)
.setIn(['storehouse', 'error'], null);
}
case QUERYBYSUPPLIER_FAILURE:{
return state.setIn(['storehouse', 'isFetching'], false)
.setIn(['storehouse', 'adminName'], action.payload.adminName)
.setIn(['storehouse', 'address'], action.payload.address)
.setIn(['storehouse', 'phone'], action.payload.phone)
.setIn(['storehouse', 'storehouseName'], action.payload.storehouseName)
.setIn(['storehouse', 'id'], action.payload.id)
.setIn(['storehouse', 'status'], action.payload.status)
.setIn(['storehouse', 'error'], null)
}
case GET_EXPRESS_LIST_FAILURE:{
return state.setIn(['storehouse', 'isFetching'], false)
.setIn(['storehouse', 'error'], action.payload);
}
return state;
}
... ...
... ... @@ -7,11 +7,49 @@
'use strict';
import {Actions} from 'react-native-router-flux';
import TransferShipmentService from '../../services/OutOfStockService';
import OutOfStockService from '../../services/OutOfStockService';
import {Alert, Linking} from 'react-native';
const {
LOGOUT,
STOCKOUT_REQUEST,
STOCKOUT_SUCCESS,
STOCKOUT_FAILURE,
} = require('../../constants/actionTypes').default;
export function stockOutRequest() {
return {
type: STOCKOUT_REQUEST,
};
}
export function stockOutSuccess(json) {
return {
type: STOCKOUT_SUCCESS,
payload: json,
};
}
export function stockOutFailure(error) {
return {
type: STOCKOUT_FAILURE,
payload: error,
};
}
export function stockOut() {
return (dispatch,getState) => {
let {home} = getState();
let proReqFormId=1;
let productSku=1;
let num=1;
dispatch(stockOutRequest())
return new OutOfStockService().stockOut(proReqFormId,productSku,num)
.then((json) => {
dispatch(stockOutSuccess(json))
})
.catch((error) => {
dispatch(stockOutFailure(error))
});
};
}
... ...
... ... @@ -11,7 +11,9 @@ import Immutable, {List, Record} from 'immutable';
const {
LOGOUT,
STOCKOUT_REQUEST,
STOCKOUT_SUCCESS,
STOCKOUT_FAILURE,
} = require('../../constants/actionTypes').default;
... ... @@ -26,7 +28,13 @@ export default function userReducer(state = initialState, action) {
if (!(state instanceof InitialState)) return initialState.merge(state);
switch (action.type) {
case LOGOUT:{
case STOCKOUT_REQUEST:{
return state;
}
case STOCKOUT_SUCCESS:{
return state;
}
case STOCKOUT_FAILURE:{
return state;
}
return state;
... ...
... ... @@ -15,6 +15,9 @@ const {
GO_TO_OUT_STOCK,
GET_PURCHASE_LIST_REQUEST,
GET_PURCHASE_LIST_SUCCESS,
GET_PURCHASE_LIST_FAILURE,
} = require('../../constants/actionTypes').default;
export function goToStatsPage(type) {
... ... @@ -27,3 +30,55 @@ export function goToStatsPage(type) {
};
}
}
export function getPurchaseListRequest() {
return {
type: GET_PURCHASE_LIST_REQUEST,
};
}
export function getPurchaseListSuccess(json) {
return {
type: GET_PURCHASE_LIST_SUCCESS,
payload: json,
};
}
export function getPurchaseListFailure(error) {
return {
type: GET_PURCHASE_LIST_FAILURE,
payload: error,
};
}
export function getPurchaseList() {
return (dispatch,getState) => {
let {transferShipment,home} = getState();
let {purchaseList} = transferShipment;
if (purchaseList.isFetching || purchaseList.endReached) {
return;
}
let shopId = home.shopId;
let pageSize = purchaseList.pageSize;
let pageNo = purchaseList.pageNo + 1;
dispatch(getPurchaseListRequest())
return new TransferShipmentService().getPurchaseList(shopId,pageSize,pageNo)
.then((json) => {
json.endReached = json.pageNo == json.totalPage || json.records.length < pageSize;
if (json.pageNo > 1) {
let oldList = purchaseList.records.toJS();
let list = [...oldList, ...json.records];
json.records = list;
}
dispatch(getPurchaseListSuccess(json))
})
.catch((error) => {
dispatch(getPurchaseListFailure(error))
});
};
}
... ...
... ... @@ -7,7 +7,16 @@ import {List, Record} from 'immutable';
let InitialState = Record({
purchaseList: new (Record({
isFetching: false,
error: null,
records: List(),
pageNo: 0,
totalPage: 0,
pageSize: 10,
totalCount: 0,
endReached: false,
})),
});
export default InitialState;
... ...
... ... @@ -12,6 +12,9 @@ import Immutable, {List, Record} from 'immutable';
const {
GO_TO_OUT_STOCK,
GET_PURCHASE_LIST_REQUEST,
GET_PURCHASE_LIST_SUCCESS,
GET_PURCHASE_LIST_FAILURE,
} = require('../../constants/actionTypes').default;
... ... @@ -29,6 +32,36 @@ export default function userReducer(state = initialState, action) {
case GO_TO_OUT_STOCK:{
return state;
}
case GET_PURCHASE_LIST_REQUEST:{
return state.setIn(['purchaseList', 'isFetching'], true)
.setIn(['purchaseList', 'error'], null)
.setIn(['purchaseList', 'pageNo'], 0)
.setIn(['purchaseList', 'totalPage'], 0)
.setIn(['purchaseList', 'totalCount'], 0)
.setIn(['purchaseList', 'endReached'], false);
}
case GET_PURCHASE_LIST_SUCCESS:{
let {
records,
pageNo,
totalPage,
totalCount,
endReached,
} = action.payload;
return state.setIn(['purchaseList', 'isFetching'], false)
.setIn(['purchaseList', 'error'], null)
.setIn(['purchaseList', 'records'], Immutable.fromJS(records))
.setIn(['purchaseList', 'pageNo'], pageNo)
.setIn(['purchaseList', 'totalPage'], totalPage)
.setIn(['purchaseList', 'totalCount'], totalCount)
.setIn(['purchaseList', 'endReached'], endReached);
}
case GET_PURCHASE_LIST_FAILURE:{
return state.setIn(['purchaseList', 'isFetching'], false)
.setIn(['purchaseList', 'error'], action.payload)
}
return state;
}
... ...
... ... @@ -9,4 +9,63 @@ export default class DeliverGoodsService {
constructor () {
this.api = new Request();
}
async deliveryGoods(expressId,expressNumber,shopId,expressGoodsMap) {
return this.api.get({
url: '/purchase/delivery',
body: {
expressId: expressId,
expressNumber: expressNumber,
shopId: shopId,
expressGoodsMap: expressGoodsMap,
}
})
.then(data => {
console.log(data);
console.log('deliveryGoods');
return data;
})
.catch(error => {
console.log(error);
console.log('deliveryGoods error');
throw error;
});
}
async getExpressList() {
return this.api.get({
url: '/express/getExpressList',
body: {}
})
.then(data => {
console.log(data);
console.log('getExpressList');
return data;
})
.catch(error => {
console.log(error);
console.log('getExpressList error');
throw error;
});
}
async queryBySupplierId(supplierId) {
return this.api.get({
url: '/purchase/queryBySupplierId',
body: {
supplierId,
}
})
.then(data => {
console.log(data);
console.log('queryBySupplierId');
return data;
})
.catch(error => {
console.log(error);
console.log('queryBySupplierId error');
throw error;
});
}
}
... ...
... ... @@ -9,4 +9,26 @@ export default class OutOfStockService {
constructor () {
this.api = new Request();
}
async stockOut(proReqFormId,productSku,num) {
return this.api.get({
url: '/purchase/stockOut',
body: {
proReqFormId: proReqFormId,
productSku: productSku,
num: num,
}
})
.then(data => {
console.log(data);
console.log('stockOut data');
return data;
})
.catch(error => {
console.log(error);
console.log('stockOut error');
throw error;
});
}
}
... ...
... ... @@ -8,4 +8,25 @@ export default class TransferShipmentService {
constructor () {
this.api = new Request();
}
async getPurchaseList(shopId,pageSize,pageNo) {
return this.api.get({
url: '/purchase/list',
body: {
shopId: shopId,
pageSize: pageSize,
pageNo: pageNo,
}
})
.then(data => {
console.log(data);
console.log('data');
return data;
})
.catch(error => {
console.log(error);
console.log('error');
throw error;
});
}
}
... ...