Authored by 孙凯

add 发货接口 review by hongmo

... ... @@ -44,7 +44,16 @@ export default class DeliverGoods extends Component {
}
_onValueChange(value){
this.props.setExpressId && this.props.setExpressId(value);
let {initialRes,resource} = this.props;
let {expressList} = resource;
let list = expressList?expressList.list:[];
let param = null;
list.map((item, i) => {
if (item.get('id') == value) {
param = item?item.toJS():'';
}
})
this.props.setExpressValue && this.props.setExpressValue(param,initialRes);
}
_renderRow(rowData, sectionID, rowID) {
... ... @@ -54,7 +63,7 @@ export default class DeliverGoods extends Component {
}
_picker() {
let {expressList,expressId} = this.props.resource;
let {expressList,expressValue} = this.props.resource;
let list = expressList?expressList.list:[];
return (
... ... @@ -66,11 +75,11 @@ export default class DeliverGoods extends Component {
</TouchableOpacity>
<View style={styles.pickerSubContainer}>
<Picker
selectedValue={expressId}
selectedValue={expressValue?expressValue.get('id'):''}
onValueChange={this._onValueChange}>
{list.map((value, i) => {
return (<Picker.Item label={value.get('companyName')} value={value.get('companyName')} />);
return (<Picker.Item key={'Picker'+i} label={value.get('companyName')} value={value.get('id')} />);
})
}
</Picker>
... ... @@ -81,12 +90,13 @@ export default class DeliverGoods extends Component {
render() {
let {initialRes,resource} = this.props;
let {expressList,storehouse,expressNum,expressId} = resource;
let {expressList,storehouse,expressNum,expressValue} = resource;
let address = storehouse?storehouse.get('address'):'';
let adminName = storehouse?storehouse.get('adminName'):'';
let storehouseName = storehouse?storehouse.get('storehouseName'):'';
let phone = storehouse?storehouse.get('phone'):'';
let expressName = expressValue?expressValue.get('companyName'):'';
return (
<View style={styles.container}>
... ... @@ -99,7 +109,7 @@ export default class DeliverGoods extends Component {
}}>
<View style={styles.pickerView}>
<Text style={styles.pickerText} numberOfLines={1}>
{expressId}
{expressName}
</Text>
</View>
</TouchableOpacity>
... ...
... ... @@ -38,14 +38,11 @@ export default class DeliverGoodsCell extends Component {
let skuFactoryCode = value.skuFactoryCode?value.skuFactoryCode:0;//商品条码
let factoryGoodsName = value.factoryGoodsName?value.factoryGoodsName:0;//厂家颜色
let sizeName = value.sizeName?value.sizeName:0;//尺码名
let lackNum = value.lackNum?value.lackNum:0;//缺货数
let shipmentsNums = value.shipmentsNums?value.shipmentsNums:0;//发货数量
let buyingNums = value.buyingNums?value.buyingNums:0;//外采数量 销售数
let lastNum = buyingNums - lackNum - shipmentsNums;//实际应发数
let lastNum = value.num?value.num:0;
return (
<View style={styles.cell}>
<View style={styles.cell} key={'j_'+i}>
<Text style={styles.cellText1} numberOfLines={1}>SKU:{sku}</Text>
<Text style={styles.cellText2} numberOfLines={1}>商品条码:{skuFactoryCode} {factoryGoodsName}/{sizeName}</Text>
<Text style={styles.cellText3} numberOfLines={1}>当前需发数:{lastNum}</Text>
... ...
... ... @@ -33,7 +33,7 @@ export default class TransferShipmentCell extends Component {
_onChangeText(text){
let {resource} = this.props;
let data = resource?resource.toJS():null;
let sku = data?data.sku:0;
let sku = data?data.productSku:0;
let lackNum = data.lackNum?data.lackNum:0;//缺货数
let shipmentsNums = data.shipmentsNums?data.shipmentsNums:0;//发货数量
let buyingNums = data.buyingNums?data.buyingNums:0;//外采数量 销售数
... ... @@ -50,7 +50,7 @@ export default class TransferShipmentCell extends Component {
this.setState({hasChecked : !checked});
let {resource} = this.props;
let data = resource?resource.toJS():null;
let sku = data?data.sku:0;
let sku = data?data.productSku:0;
this.props.checkUp && this.props.checkUp(!checked,sku);
}
... ...
... ... @@ -136,8 +136,8 @@ export default keyMirror({
SET_PURCHASE_NUM: null,
SET_LACK_NUM: null,
SET_EXPRESS_NUM: null,
SET_EXPRESS_ID: null,
SET_EXPRESS_VALUE: null,
SWITCH_SHOP: null,
LOGOUT: null,
});
... ...
... ... @@ -50,7 +50,7 @@ class DeliverGoodsContainer extends Component {
constructor(props) {
super(props);
this._setExpressNum = this._setExpressNum.bind(this);
this._setExpressId = this._setExpressId.bind(this);
this._setExpressValue = this._setExpressValue.bind(this);
}
componentDidMount() {
... ... @@ -62,12 +62,12 @@ class DeliverGoodsContainer extends Component {
this.props.actions.setExpressNum(text);
}
_setExpressId(value){
this.props.actions.setExpressId(value);
_setExpressValue(value,initialRes){
this.props.actions.setExpressValue(value,initialRes);
}
render() {
let {deliverGoods,initialRes,expressNum,expressId} = this.props;
let {deliverGoods,initialRes,expressNum,expressValue} = this.props;
return (
<View style={styles.container}>
... ... @@ -75,9 +75,9 @@ class DeliverGoodsContainer extends Component {
initialRes={initialRes}
resource={deliverGoods}
expressNum={expressNum}
expressId={expressId}
expressValue={expressValue}
setExpressNum={this._setExpressNum}
setExpressId={this._setExpressId}/>
setExpressValue={this._setExpressValue}/>
</View>
);
}
... ...
... ... @@ -26,7 +26,7 @@ const {
QUERYBYSUPPLIER_FAILURE,
SET_EXPRESS_NUM,
SET_EXPRESS_ID,
SET_EXPRESS_VALUE,
} = require('../../constants/actionTypes').default;
... ... @@ -37,10 +37,13 @@ export function setExpressNum(value) {
};
}
export function setExpressId(value) {
export function setExpressValue(value,initialRes) {
return {
type: SET_EXPRESS_ID,
payload: value,
type: SET_EXPRESS_VALUE,
payload: {
value,
initialRes,
},
};
}
... ... @@ -68,10 +71,22 @@ export function deliveryGoodsFailure(error) {
export function deliveryGoods() {
return (dispatch,getState) => {
let {deliverGoods,home} = getState();
let expressId = deliverGoods.expressId;
let deliverData = deliverGoods.deliverData?deliverGoods.deliverData:[];
let expressValue = deliverGoods.expressValue?deliverGoods.expressValue:null;
let expressId = expressValue?expressValue.get('id'):0;
let expressNumber = deliverGoods.expressNum;
let shopId = home.shopId;
let expressGoodsMap = 1;
let deliverDataJson = deliverData?deliverData.toJS():[];
let expressGoodsMap = {};
deliverDataJson.map((item0, i) => {
let id = item0.id;
let list = item0.value;
let expressList = [];
list.map((item1, i) => {
expressList.push({sku: item1.productSku,num: item1.num,factoryCode: item1.skuFactoryCode});
})
expressGoodsMap[id] = expressList;
})
dispatch(deliveryGoodsRequest())
return new DeliverGoodsService().deliveryGoods(expressId,expressNumber,shopId,expressGoodsMap)
... ...
... ... @@ -22,8 +22,9 @@ let InitialState = Record({
id: '',
status: '',
})),
expressNum: '',
expressId: '',
expressNum: null,
expressValue: null,
deliverData: null,
});
export default InitialState;
... ...
... ... @@ -24,7 +24,7 @@ const {
QUERYBYSUPPLIER_SUCCESS,
QUERYBYSUPPLIER_FAILURE,
SET_EXPRESS_NUM,
SET_EXPRESS_ID,
SET_EXPRESS_VALUE,
} = require('../../constants/actionTypes').default;
... ... @@ -82,8 +82,9 @@ export default function userReducer(state = initialState, action) {
case SET_EXPRESS_NUM:{
return state.set('expressNum', action.payload);
}
case SET_EXPRESS_ID:{
return state.set('expressId', action.payload);
case SET_EXPRESS_VALUE:{
return state.set('expressValue', Immutable.fromJS(action.payload.value))
.set('deliverData', Immutable.fromJS(action.payload.initialRes));
}
return state;
}
... ...
... ... @@ -53,7 +53,7 @@ export function goDeliverGoods(type) {
for (var i = 0; i < records.length; i++) {
let value = records[i];
if (value.checked) {
if (value.checked && value.num > 0) {
let id = value.id;
let hasPush = false;
... ... @@ -140,7 +140,7 @@ export function checkUp(checked,sku) {
let {purchaseList} = transferShipment;
let list = purchaseList && purchaseList.records && purchaseList.records.toJS();
list.map((item, i) => {
let p_sku = item.sku;
let p_sku = item.productSku;
if (sku == p_sku) {
item.checked = checked;
}
... ... @@ -163,7 +163,7 @@ export function setPurchaseNum(num,sku) {
let list = purchaseList && purchaseList.records && purchaseList.records.toJS();
list.map((item, i) => {
let p_sku = item.sku
let p_sku = item.productSku
if (sku == p_sku) {
item.num = num;
}
... ...