Authored by 孙凯

发货页面 接口数据 review by hongmo

... ... @@ -17,6 +17,12 @@ import RNRF, {
import configureStore from './store/configureStore';
import {
deliveryGoods,
} from './reducers/deliverGoods/deliverGoodsActions';
import {
goDeliverGoods,
} from './reducers/transferShipment/transferShipmentActions';
... ... @@ -325,7 +331,7 @@ export default function native(platform) {
title='发货'
rightTitle='提交'
onRight={()=>{
console.log('sssssssssssss');;
store.dispatch(deliveryGoods());
}}
titleStyle={styles.navTitle}
type="push"
... ...
... ... @@ -31,13 +31,22 @@ export default class DeliverGoods extends Component {
});
this._renderRow = this._renderRow.bind(this);
this._picker = this._picker.bind(this);
this._onChangeText = this._onChangeText.bind(this);
this._onValueChange = this._onValueChange.bind(this);
this.state = {
express: '',
showPicker: false,
qrCode: ''
};
}
_onChangeText(text){
this.props.setExpressNum && this.props.setExpressNum(text);
}
_onValueChange(value){
this.props.setExpressId && this.props.setExpressId(value);
}
_renderRow(rowData, sectionID, rowID) {
return(
<DeliverGoodsCell resource={rowData}/>
... ... @@ -45,7 +54,7 @@ export default class DeliverGoods extends Component {
}
_picker() {
let {expressList} = this.props.resource;
let {expressList,expressId} = this.props.resource;
let list = expressList?expressList.list:[];
return (
... ... @@ -57,8 +66,8 @@ export default class DeliverGoods extends Component {
</TouchableOpacity>
<View style={styles.pickerSubContainer}>
<Picker
selectedValue={this.state.express}
onValueChange={(lang) => this.setState({express: lang})}>
selectedValue={expressId}
onValueChange={this._onValueChange}>
{list.map((value, i) => {
return (<Picker.Item label={value.get('companyName')} value={value.get('companyName')} />);
... ... @@ -72,7 +81,7 @@ export default class DeliverGoods extends Component {
render() {
let {initialRes,resource} = this.props;
let {expressList,storehouse} = resource;
let {expressList,storehouse,expressNum,expressId} = resource;
let address = storehouse?storehouse.get('address'):'';
let adminName = storehouse?storehouse.get('adminName'):'';
... ... @@ -90,7 +99,7 @@ export default class DeliverGoods extends Component {
}}>
<View style={styles.pickerView}>
<Text style={styles.pickerText} numberOfLines={1}>
{this.state.express}
{expressId}
</Text>
</View>
</TouchableOpacity>
... ... @@ -102,8 +111,8 @@ export default class DeliverGoods extends Component {
<TextInput style={styles.numberInputText}
ref = 'textInput1'
placeholder={'输入物流单号'}
onChangeText={(text) => this.setState({qrCode: text})}
value={this.state.qrCode}
onChangeText={this._onChangeText}
value={expressNum}
/>
<TouchableOpacity onPress={() => {
QRNativeConfig.startScanQRCode();
... ... @@ -130,11 +139,9 @@ export default class DeliverGoods extends Component {
componentWillMount() {
let that = this;
DeviceEventEmitter.addListener('scanQRComplete', function(param) {
that.setState({qrCode: param.QRCode})
console.log(that.state.qrCode);
this.props.setExpressNum && this.props.setExpressNum(param.QRCode);
});
}
}
let {width, height} = Dimensions.get('window');
... ...
... ... @@ -135,7 +135,9 @@ export default keyMirror({
CHECKUP_REQUEST: null,
SET_PURCHASE_NUM: null,
SET_LACK_NUM: null,
SET_EXPRESS_NUM: null,
SET_EXPRESS_ID: null,
SWITCH_SHOP: null,
LOGOUT: null,
});
... ...
... ... @@ -49,6 +49,8 @@ class DeliverGoodsContainer extends Component {
constructor(props) {
super(props);
this._setExpressNum = this._setExpressNum.bind(this);
this._setExpressId = this._setExpressId.bind(this);
}
componentDidMount() {
... ... @@ -56,16 +58,26 @@ class DeliverGoodsContainer extends Component {
this.props.actions.queryBySupplierId();
}
componentWillUnmount() {
_setExpressNum(text){
this.props.actions.setExpressNum(text);
}
_setExpressId(value){
this.props.actions.setExpressId(value);
}
render() {
let {deliverGoods,initialRes} = this.props;
let {deliverGoods,initialRes,expressNum,expressId} = this.props;
return (
<View style={styles.container}>
<DeliverGoods initialRes={initialRes} resource={deliverGoods}/>
<DeliverGoods
initialRes={initialRes}
resource={deliverGoods}
expressNum={expressNum}
expressId={expressId}
setExpressNum={this._setExpressNum}
setExpressId={this._setExpressId}/>
</View>
);
}
... ...
... ... @@ -25,8 +25,26 @@ const {
QUERYBYSUPPLIER_SUCCESS,
QUERYBYSUPPLIER_FAILURE,
SET_EXPRESS_NUM,
SET_EXPRESS_ID,
} = require('../../constants/actionTypes').default;
export function setExpressNum(value) {
return {
type: SET_EXPRESS_NUM,
payload: value,
};
}
export function setExpressId(value) {
return {
type: SET_EXPRESS_ID,
payload: value,
};
}
export function deliveryGoodsRequest() {
return {
type: DELIVERY_GOODS_REQUEST,
... ... @@ -49,10 +67,14 @@ export function deliveryGoodsFailure(error) {
export function deliveryGoods() {
return (dispatch,getState) => {
let {home} = getState();
let {deliverGoods,home} = getState();
let expressId = deliverGoods.expressId;
let expressNumber = deliverGoods.expressNum;
let shopId = home.shopId;
let expressGoodsMap = 1;
dispatch(deliveryGoodsRequest())
return new DeliverGoodsService().deliveryGoods()
return new DeliverGoodsService().deliveryGoods(expressId,expressNumber,shopId,expressGoodsMap)
.then((json) => {
dispatch(deliveryGoodsSuccess(json))
})
... ...
... ... @@ -22,6 +22,8 @@ let InitialState = Record({
id: '',
status: '',
})),
expressNum: '',
expressId: '',
});
export default InitialState;
... ...
... ... @@ -23,6 +23,8 @@ const {
QUERYBYSUPPLIER_REQUEST,
QUERYBYSUPPLIER_SUCCESS,
QUERYBYSUPPLIER_FAILURE,
SET_EXPRESS_NUM,
SET_EXPRESS_ID,
} = require('../../constants/actionTypes').default;
... ... @@ -77,6 +79,12 @@ export default function userReducer(state = initialState, action) {
return state.setIn(['storehouse', 'isFetching'], false)
.setIn(['storehouse', 'error'], action.payload);
}
case SET_EXPRESS_NUM:{
return state.set('expressNum', action.payload);
}
case SET_EXPRESS_ID:{
return state.set('expressId', action.payload);
}
return state;
}
... ...
... ... @@ -43,14 +43,15 @@ export function stockOutFailure(error) {
export function stockOut() {
return (dispatch,getState) => {
let {outOfStock} = getState();
let {outOfStock,home} = getState();
let {initialRes} = outOfStock;
let productSku = initialRes?initialRes.productSku:0;
let proReqFormId = initialRes?initialRes.proRequisitionFormId:0;
let num = outOfStock.lackNum;
let shopId = home.shopId;
dispatch(stockOutRequest())
return new OutOfStockService().stockOut(proReqFormId,productSku,num)
return new OutOfStockService().stockOut(proReqFormId,productSku,num,shopId)
.then((json) => {
dispatch(stockOutSuccess(json))
})
... ...
... ... @@ -10,13 +10,14 @@ export default class OutOfStockService {
this.api = new Request();
}
async stockOut(proReqFormId,productSku,num) {
async stockOut(proReqFormId,productSku,num,shopId) {
return this.api.get({
url: '',
body: {
proReqFormId: proReqFormId,
productSku: productSku,
num: num,
shopId: shopId,
method:'app.purchase.stockOut',
}
})
... ...