add 发货接口 review by hongmo
Showing
9 changed files
with
59 additions
and
35 deletions
@@ -44,7 +44,16 @@ export default class DeliverGoods extends Component { | @@ -44,7 +44,16 @@ export default class DeliverGoods extends Component { | ||
44 | } | 44 | } |
45 | 45 | ||
46 | _onValueChange(value){ | 46 | _onValueChange(value){ |
47 | - this.props.setExpressId && this.props.setExpressId(value); | 47 | + let {initialRes,resource} = this.props; |
48 | + let {expressList} = resource; | ||
49 | + let list = expressList?expressList.list:[]; | ||
50 | + let param = null; | ||
51 | + list.map((item, i) => { | ||
52 | + if (item.get('id') == value) { | ||
53 | + param = item?item.toJS():''; | ||
54 | + } | ||
55 | + }) | ||
56 | + this.props.setExpressValue && this.props.setExpressValue(param,initialRes); | ||
48 | } | 57 | } |
49 | 58 | ||
50 | _renderRow(rowData, sectionID, rowID) { | 59 | _renderRow(rowData, sectionID, rowID) { |
@@ -54,7 +63,7 @@ export default class DeliverGoods extends Component { | @@ -54,7 +63,7 @@ export default class DeliverGoods extends Component { | ||
54 | } | 63 | } |
55 | 64 | ||
56 | _picker() { | 65 | _picker() { |
57 | - let {expressList,expressId} = this.props.resource; | 66 | + let {expressList,expressValue} = this.props.resource; |
58 | let list = expressList?expressList.list:[]; | 67 | let list = expressList?expressList.list:[]; |
59 | 68 | ||
60 | return ( | 69 | return ( |
@@ -66,11 +75,11 @@ export default class DeliverGoods extends Component { | @@ -66,11 +75,11 @@ export default class DeliverGoods extends Component { | ||
66 | </TouchableOpacity> | 75 | </TouchableOpacity> |
67 | <View style={styles.pickerSubContainer}> | 76 | <View style={styles.pickerSubContainer}> |
68 | <Picker | 77 | <Picker |
69 | - selectedValue={expressId} | 78 | + selectedValue={expressValue?expressValue.get('id'):''} |
70 | onValueChange={this._onValueChange}> | 79 | onValueChange={this._onValueChange}> |
71 | 80 | ||
72 | {list.map((value, i) => { | 81 | {list.map((value, i) => { |
73 | - return (<Picker.Item label={value.get('companyName')} value={value.get('companyName')} />); | 82 | + return (<Picker.Item key={'Picker'+i} label={value.get('companyName')} value={value.get('id')} />); |
74 | }) | 83 | }) |
75 | } | 84 | } |
76 | </Picker> | 85 | </Picker> |
@@ -81,12 +90,13 @@ export default class DeliverGoods extends Component { | @@ -81,12 +90,13 @@ export default class DeliverGoods extends Component { | ||
81 | 90 | ||
82 | render() { | 91 | render() { |
83 | let {initialRes,resource} = this.props; | 92 | let {initialRes,resource} = this.props; |
84 | - let {expressList,storehouse,expressNum,expressId} = resource; | 93 | + let {expressList,storehouse,expressNum,expressValue} = resource; |
85 | 94 | ||
86 | let address = storehouse?storehouse.get('address'):''; | 95 | let address = storehouse?storehouse.get('address'):''; |
87 | let adminName = storehouse?storehouse.get('adminName'):''; | 96 | let adminName = storehouse?storehouse.get('adminName'):''; |
88 | let storehouseName = storehouse?storehouse.get('storehouseName'):''; | 97 | let storehouseName = storehouse?storehouse.get('storehouseName'):''; |
89 | let phone = storehouse?storehouse.get('phone'):''; | 98 | let phone = storehouse?storehouse.get('phone'):''; |
99 | + let expressName = expressValue?expressValue.get('companyName'):''; | ||
90 | 100 | ||
91 | return ( | 101 | return ( |
92 | <View style={styles.container}> | 102 | <View style={styles.container}> |
@@ -99,7 +109,7 @@ export default class DeliverGoods extends Component { | @@ -99,7 +109,7 @@ export default class DeliverGoods extends Component { | ||
99 | }}> | 109 | }}> |
100 | <View style={styles.pickerView}> | 110 | <View style={styles.pickerView}> |
101 | <Text style={styles.pickerText} numberOfLines={1}> | 111 | <Text style={styles.pickerText} numberOfLines={1}> |
102 | - {expressId} | 112 | + {expressName} |
103 | </Text> | 113 | </Text> |
104 | </View> | 114 | </View> |
105 | </TouchableOpacity> | 115 | </TouchableOpacity> |
@@ -38,14 +38,11 @@ export default class DeliverGoodsCell extends Component { | @@ -38,14 +38,11 @@ export default class DeliverGoodsCell extends Component { | ||
38 | let skuFactoryCode = value.skuFactoryCode?value.skuFactoryCode:0;//商品条码 | 38 | let skuFactoryCode = value.skuFactoryCode?value.skuFactoryCode:0;//商品条码 |
39 | let factoryGoodsName = value.factoryGoodsName?value.factoryGoodsName:0;//厂家颜色 | 39 | let factoryGoodsName = value.factoryGoodsName?value.factoryGoodsName:0;//厂家颜色 |
40 | let sizeName = value.sizeName?value.sizeName:0;//尺码名 | 40 | let sizeName = value.sizeName?value.sizeName:0;//尺码名 |
41 | - let lackNum = value.lackNum?value.lackNum:0;//缺货数 | ||
42 | - let shipmentsNums = value.shipmentsNums?value.shipmentsNums:0;//发货数量 | ||
43 | - let buyingNums = value.buyingNums?value.buyingNums:0;//外采数量 销售数 | ||
44 | 41 | ||
45 | - let lastNum = buyingNums - lackNum - shipmentsNums;//实际应发数 | 42 | + let lastNum = value.num?value.num:0; |
46 | 43 | ||
47 | return ( | 44 | return ( |
48 | - <View style={styles.cell}> | 45 | + <View style={styles.cell} key={'j_'+i}> |
49 | <Text style={styles.cellText1} numberOfLines={1}>SKU:{sku}</Text> | 46 | <Text style={styles.cellText1} numberOfLines={1}>SKU:{sku}</Text> |
50 | <Text style={styles.cellText2} numberOfLines={1}>商品条码:{skuFactoryCode} {factoryGoodsName}/{sizeName}</Text> | 47 | <Text style={styles.cellText2} numberOfLines={1}>商品条码:{skuFactoryCode} {factoryGoodsName}/{sizeName}</Text> |
51 | <Text style={styles.cellText3} numberOfLines={1}>当前需发数:{lastNum}</Text> | 48 | <Text style={styles.cellText3} numberOfLines={1}>当前需发数:{lastNum}</Text> |
@@ -33,7 +33,7 @@ export default class TransferShipmentCell extends Component { | @@ -33,7 +33,7 @@ export default class TransferShipmentCell extends Component { | ||
33 | _onChangeText(text){ | 33 | _onChangeText(text){ |
34 | let {resource} = this.props; | 34 | let {resource} = this.props; |
35 | let data = resource?resource.toJS():null; | 35 | let data = resource?resource.toJS():null; |
36 | - let sku = data?data.sku:0; | 36 | + let sku = data?data.productSku:0; |
37 | let lackNum = data.lackNum?data.lackNum:0;//缺货数 | 37 | let lackNum = data.lackNum?data.lackNum:0;//缺货数 |
38 | let shipmentsNums = data.shipmentsNums?data.shipmentsNums:0;//发货数量 | 38 | let shipmentsNums = data.shipmentsNums?data.shipmentsNums:0;//发货数量 |
39 | let buyingNums = data.buyingNums?data.buyingNums:0;//外采数量 销售数 | 39 | let buyingNums = data.buyingNums?data.buyingNums:0;//外采数量 销售数 |
@@ -50,7 +50,7 @@ export default class TransferShipmentCell extends Component { | @@ -50,7 +50,7 @@ export default class TransferShipmentCell extends Component { | ||
50 | this.setState({hasChecked : !checked}); | 50 | this.setState({hasChecked : !checked}); |
51 | let {resource} = this.props; | 51 | let {resource} = this.props; |
52 | let data = resource?resource.toJS():null; | 52 | let data = resource?resource.toJS():null; |
53 | - let sku = data?data.sku:0; | 53 | + let sku = data?data.productSku:0; |
54 | 54 | ||
55 | this.props.checkUp && this.props.checkUp(!checked,sku); | 55 | this.props.checkUp && this.props.checkUp(!checked,sku); |
56 | } | 56 | } |
@@ -136,8 +136,8 @@ export default keyMirror({ | @@ -136,8 +136,8 @@ export default keyMirror({ | ||
136 | SET_PURCHASE_NUM: null, | 136 | SET_PURCHASE_NUM: null, |
137 | SET_LACK_NUM: null, | 137 | SET_LACK_NUM: null, |
138 | SET_EXPRESS_NUM: null, | 138 | SET_EXPRESS_NUM: null, |
139 | - SET_EXPRESS_ID: null, | ||
140 | - | 139 | + SET_EXPRESS_VALUE: null, |
140 | + | ||
141 | SWITCH_SHOP: null, | 141 | SWITCH_SHOP: null, |
142 | LOGOUT: null, | 142 | LOGOUT: null, |
143 | }); | 143 | }); |
@@ -50,7 +50,7 @@ class DeliverGoodsContainer extends Component { | @@ -50,7 +50,7 @@ class DeliverGoodsContainer extends Component { | ||
50 | constructor(props) { | 50 | constructor(props) { |
51 | super(props); | 51 | super(props); |
52 | this._setExpressNum = this._setExpressNum.bind(this); | 52 | this._setExpressNum = this._setExpressNum.bind(this); |
53 | - this._setExpressId = this._setExpressId.bind(this); | 53 | + this._setExpressValue = this._setExpressValue.bind(this); |
54 | } | 54 | } |
55 | 55 | ||
56 | componentDidMount() { | 56 | componentDidMount() { |
@@ -62,12 +62,12 @@ class DeliverGoodsContainer extends Component { | @@ -62,12 +62,12 @@ class DeliverGoodsContainer extends Component { | ||
62 | this.props.actions.setExpressNum(text); | 62 | this.props.actions.setExpressNum(text); |
63 | } | 63 | } |
64 | 64 | ||
65 | - _setExpressId(value){ | ||
66 | - this.props.actions.setExpressId(value); | 65 | + _setExpressValue(value,initialRes){ |
66 | + this.props.actions.setExpressValue(value,initialRes); | ||
67 | } | 67 | } |
68 | 68 | ||
69 | render() { | 69 | render() { |
70 | - let {deliverGoods,initialRes,expressNum,expressId} = this.props; | 70 | + let {deliverGoods,initialRes,expressNum,expressValue} = this.props; |
71 | 71 | ||
72 | return ( | 72 | return ( |
73 | <View style={styles.container}> | 73 | <View style={styles.container}> |
@@ -75,9 +75,9 @@ class DeliverGoodsContainer extends Component { | @@ -75,9 +75,9 @@ class DeliverGoodsContainer extends Component { | ||
75 | initialRes={initialRes} | 75 | initialRes={initialRes} |
76 | resource={deliverGoods} | 76 | resource={deliverGoods} |
77 | expressNum={expressNum} | 77 | expressNum={expressNum} |
78 | - expressId={expressId} | 78 | + expressValue={expressValue} |
79 | setExpressNum={this._setExpressNum} | 79 | setExpressNum={this._setExpressNum} |
80 | - setExpressId={this._setExpressId}/> | 80 | + setExpressValue={this._setExpressValue}/> |
81 | </View> | 81 | </View> |
82 | ); | 82 | ); |
83 | } | 83 | } |
@@ -26,7 +26,7 @@ const { | @@ -26,7 +26,7 @@ const { | ||
26 | QUERYBYSUPPLIER_FAILURE, | 26 | QUERYBYSUPPLIER_FAILURE, |
27 | 27 | ||
28 | SET_EXPRESS_NUM, | 28 | SET_EXPRESS_NUM, |
29 | - SET_EXPRESS_ID, | 29 | + SET_EXPRESS_VALUE, |
30 | 30 | ||
31 | } = require('../../constants/actionTypes').default; | 31 | } = require('../../constants/actionTypes').default; |
32 | 32 | ||
@@ -37,10 +37,13 @@ export function setExpressNum(value) { | @@ -37,10 +37,13 @@ export function setExpressNum(value) { | ||
37 | }; | 37 | }; |
38 | } | 38 | } |
39 | 39 | ||
40 | -export function setExpressId(value) { | 40 | +export function setExpressValue(value,initialRes) { |
41 | return { | 41 | return { |
42 | - type: SET_EXPRESS_ID, | ||
43 | - payload: value, | 42 | + type: SET_EXPRESS_VALUE, |
43 | + payload: { | ||
44 | + value, | ||
45 | + initialRes, | ||
46 | + }, | ||
44 | }; | 47 | }; |
45 | } | 48 | } |
46 | 49 | ||
@@ -68,10 +71,22 @@ export function deliveryGoodsFailure(error) { | @@ -68,10 +71,22 @@ export function deliveryGoodsFailure(error) { | ||
68 | export function deliveryGoods() { | 71 | export function deliveryGoods() { |
69 | return (dispatch,getState) => { | 72 | return (dispatch,getState) => { |
70 | let {deliverGoods,home} = getState(); | 73 | let {deliverGoods,home} = getState(); |
71 | - let expressId = deliverGoods.expressId; | 74 | + let deliverData = deliverGoods.deliverData?deliverGoods.deliverData:[]; |
75 | + let expressValue = deliverGoods.expressValue?deliverGoods.expressValue:null; | ||
76 | + let expressId = expressValue?expressValue.get('id'):0; | ||
72 | let expressNumber = deliverGoods.expressNum; | 77 | let expressNumber = deliverGoods.expressNum; |
73 | let shopId = home.shopId; | 78 | let shopId = home.shopId; |
74 | - let expressGoodsMap = 1; | 79 | + let deliverDataJson = deliverData?deliverData.toJS():[]; |
80 | + let expressGoodsMap = {}; | ||
81 | + deliverDataJson.map((item0, i) => { | ||
82 | + let id = item0.id; | ||
83 | + let list = item0.value; | ||
84 | + let expressList = []; | ||
85 | + list.map((item1, i) => { | ||
86 | + expressList.push({sku: item1.productSku,num: item1.num,factoryCode: item1.skuFactoryCode}); | ||
87 | + }) | ||
88 | + expressGoodsMap[id] = expressList; | ||
89 | + }) | ||
75 | 90 | ||
76 | dispatch(deliveryGoodsRequest()) | 91 | dispatch(deliveryGoodsRequest()) |
77 | return new DeliverGoodsService().deliveryGoods(expressId,expressNumber,shopId,expressGoodsMap) | 92 | return new DeliverGoodsService().deliveryGoods(expressId,expressNumber,shopId,expressGoodsMap) |
@@ -22,8 +22,9 @@ let InitialState = Record({ | @@ -22,8 +22,9 @@ let InitialState = Record({ | ||
22 | id: '', | 22 | id: '', |
23 | status: '', | 23 | status: '', |
24 | })), | 24 | })), |
25 | - expressNum: '', | ||
26 | - expressId: '', | 25 | + expressNum: null, |
26 | + expressValue: null, | ||
27 | + deliverData: null, | ||
27 | }); | 28 | }); |
28 | 29 | ||
29 | export default InitialState; | 30 | export default InitialState; |
@@ -24,7 +24,7 @@ const { | @@ -24,7 +24,7 @@ const { | ||
24 | QUERYBYSUPPLIER_SUCCESS, | 24 | QUERYBYSUPPLIER_SUCCESS, |
25 | QUERYBYSUPPLIER_FAILURE, | 25 | QUERYBYSUPPLIER_FAILURE, |
26 | SET_EXPRESS_NUM, | 26 | SET_EXPRESS_NUM, |
27 | - SET_EXPRESS_ID, | 27 | + SET_EXPRESS_VALUE, |
28 | 28 | ||
29 | } = require('../../constants/actionTypes').default; | 29 | } = require('../../constants/actionTypes').default; |
30 | 30 | ||
@@ -82,8 +82,9 @@ export default function userReducer(state = initialState, action) { | @@ -82,8 +82,9 @@ export default function userReducer(state = initialState, action) { | ||
82 | case SET_EXPRESS_NUM:{ | 82 | case SET_EXPRESS_NUM:{ |
83 | return state.set('expressNum', action.payload); | 83 | return state.set('expressNum', action.payload); |
84 | } | 84 | } |
85 | - case SET_EXPRESS_ID:{ | ||
86 | - return state.set('expressId', action.payload); | 85 | + case SET_EXPRESS_VALUE:{ |
86 | + return state.set('expressValue', Immutable.fromJS(action.payload.value)) | ||
87 | + .set('deliverData', Immutable.fromJS(action.payload.initialRes)); | ||
87 | } | 88 | } |
88 | return state; | 89 | return state; |
89 | } | 90 | } |
@@ -53,7 +53,7 @@ export function goDeliverGoods(type) { | @@ -53,7 +53,7 @@ export function goDeliverGoods(type) { | ||
53 | 53 | ||
54 | for (var i = 0; i < records.length; i++) { | 54 | for (var i = 0; i < records.length; i++) { |
55 | let value = records[i]; | 55 | let value = records[i]; |
56 | - if (value.checked) { | 56 | + if (value.checked && value.num > 0) { |
57 | let id = value.id; | 57 | let id = value.id; |
58 | let hasPush = false; | 58 | let hasPush = false; |
59 | 59 | ||
@@ -140,7 +140,7 @@ export function checkUp(checked,sku) { | @@ -140,7 +140,7 @@ export function checkUp(checked,sku) { | ||
140 | let {purchaseList} = transferShipment; | 140 | let {purchaseList} = transferShipment; |
141 | let list = purchaseList && purchaseList.records && purchaseList.records.toJS(); | 141 | let list = purchaseList && purchaseList.records && purchaseList.records.toJS(); |
142 | list.map((item, i) => { | 142 | list.map((item, i) => { |
143 | - let p_sku = item.sku; | 143 | + let p_sku = item.productSku; |
144 | if (sku == p_sku) { | 144 | if (sku == p_sku) { |
145 | item.checked = checked; | 145 | item.checked = checked; |
146 | } | 146 | } |
@@ -163,7 +163,7 @@ export function setPurchaseNum(num,sku) { | @@ -163,7 +163,7 @@ export function setPurchaseNum(num,sku) { | ||
163 | let list = purchaseList && purchaseList.records && purchaseList.records.toJS(); | 163 | let list = purchaseList && purchaseList.records && purchaseList.records.toJS(); |
164 | 164 | ||
165 | list.map((item, i) => { | 165 | list.map((item, i) => { |
166 | - let p_sku = item.sku | 166 | + let p_sku = item.productSku |
167 | if (sku == p_sku) { | 167 | if (sku == p_sku) { |
168 | item.num = num; | 168 | item.num = num; |
169 | } | 169 | } |
-
Please register or login to post a comment