TransferShipmentCell.js
8.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
'use strict';
import React, {Component} from 'react';
import CheckBox from 'react-native-checkbox';
import CONFIG from '../../constants/config';
import {format} from '../../utils/dateTool';
import {
StyleSheet,
View,
Text,
ListView,
Image,
Dimensions,
TextInput,
TouchableOpacity,
} from 'react-native';
export default class TransferShipmentCell extends Component {
constructor(props) {
super (props);
this._onChangeText = this._onChangeText.bind(this);
this._onCheckBoxChanged = this._onCheckBoxChanged.bind(this);
let {resource} = this.props;
let data = resource?resource.toJS():null;
this.state = {
hasChecked: data.checked?data.checked:false,
};
}
_onChangeText(text){
let {resource} = this.props;
let data = resource?resource.toJS():null;
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;//外采数量 销售数
let lastNum = buyingNums - lackNum - shipmentsNums;//实际应发数
let num = text;
if ((num | 0) === num || num > lastNum) {
num = -1;
}
this.props.setPurchaseNum && this.props.setPurchaseNum(num,sku);
}
_onCheckBoxChanged(checked){
this.setState({hasChecked : !checked});
let {resource} = this.props;
let data = resource?resource.toJS():null;
let sku = data?data.productSku:0;
this.props.checkUp && this.props.checkUp(!checked,sku);
}
render() {
let {resource} = this.props;
let data = resource?resource.toJS():null;
if (!data) {
return null;
}
let sku = data.productSku?data.productSku:0;//sku
let createTimeStr=data.createTime?data.createTime:0;//下单时间
let createTime= format(parseInt(createTimeStr))
let isOvertime = data.isOvertime ? data.isOvertime : 'N';//是否超期
let checkBoxLableColor = isOvertime=='Y' ? 'red' : 'black';
let proRequisitionFormId = data.proRequisitionFormId?data.proRequisitionFormId:0;//单号
let factoryGoodsName = data.factoryGoodsName?data.factoryGoodsName:0;//厂家颜色
let sizeName = data.sizeName?data.sizeName:0;//尺码名
let skuFactoryCode = data.skuFactoryCode?data.skuFactoryCode:0;//商品条码
let lackNum = data.lackNum?data.lackNum:0;//缺货数
let shipmentsNums = data.shipmentsNums?data.shipmentsNums:0;//发货数量
let num = data.num?data.num:0;//输入发货
let inStoreNum = data.inStoreNum?data.inStoreNum:0;//入库数量 收货数量
let buyingNums = data.buyingNums?data.buyingNums:0;//外采数量 销售数
let lastNum = buyingNums - lackNum - shipmentsNums;//实际应发数
let checkedLable = 'SKU: ' + sku + ' ' + '下单时间:' + createTime;
let lackNumTextColor = lackNum > 0 ? 'red' : 'black';
let textInputColor = num >= 0 ? 'transparent' : 'red';
return (
<View style={styles.container}>
<View style={styles.titleBar}>
<CheckBox
label={checkedLable}
labelLines={2}
containerStyle={styles.checkboxStyle}
checkboxStyle={styles.checkboxIconStyle}
labelStyle={{
marginTop: 5,
fontSize: fontSize,
backgroundColor: 'transparent',
width: width - 30,
color: checkBoxLableColor,
}}
underlayColor={'transparent'}
checkedImage={require('../../images/fahuo/select_icon_20_h.png')}
uncheckedImage={require('../../images/fahuo/select_icon_20_n.png')}
checked={this.state.hasChecked}
onChange={this._onCheckBoxChanged}
/>
<TouchableOpacity onPress={() => {
this.props.goToStatsPage && this.props.goToStatsPage(CONFIG.statsKey.outOfStock,resource);
}}>
<View style={styles.tip}>
<Image style={styles.tip} source={require('../../images/fahuo/ring_tip_ic.png')} resizeMode={'contain'} />
</View>
</TouchableOpacity>
</View>
<View style={styles.cell}>
<Text style={styles.cellText} numberOfLines={1}>商品条码:{skuFactoryCode}</Text>
</View>
<View style={styles.cell}>
<Text style={styles.cellText} numberOfLines={1}>规格:{factoryGoodsName}/{sizeName} 单号:{proRequisitionFormId}</Text>
</View>
<View style={styles.cell}>
<Text style={{
fontSize:fontSize,
marginLeft: 10,
width: 2 * Math.ceil((width-10)/9),
textAlign: 'left',
color: lackNumTextColor,
}}
numberOfLines={1}>
缺货数:{lackNum}
</Text>
<Text style={styles.cellText2} numberOfLines={1}>收获数:{inStoreNum}</Text>
<Text style={styles.cellText3} numberOfLines={1}>已发数:{shipmentsNums}</Text>
<Text style={styles.cellText4} numberOfLines={1}>当前需发数:{lastNum}</Text>
</View>
<View style={styles.textInputCell}>
<Text style={styles.cellText} numberOfLines={1}>
发货:
</Text>
<TextInput style={{
width: width - 80,
height: 40,
fontSize:fontSize,
marginLeft: 10,
borderWidth: 1,
borderColor: '#CCC',
borderRadius: 4,
marginTop: 5,
color: 'black',
paddingLeft:10,
backgroundColor: textInputColor,
}}
ref = 'textInput'
placeholder={'单行输入'}
keyboardType={'numeric'}
onChangeText={this._onChangeText}
/>
</View>
<View style={styles.place}/>
</View>
);
}
}
let {width, height} = Dimensions.get('window');
let fontSize = width<375 ? 12 : 14;
const styles = StyleSheet.create({
container: {
width: width,
height: 220,
backgroundColor: 'white',
},
place: {
width: width,
height: 10,
backgroundColor: 'white',
},
titleBar: {
width: width,
height: 40,
backgroundColor: 'rgb(254,220,220)',
flexDirection: 'row',
alignItems: 'center',
},
checkboxStyle: {
width: width - 50,
height: 40,
backgroundColor: 'transparent',
},
checkboxIconStyle: {
marginLeft : 10,
marginTop: 6,
width: 18,
height: 18,
backgroundColor: 'transparent',
},
tip: {
width: 30,
height: 30,
backgroundColor: 'transparent',
},
cell: {
width: width,
height: 40,
backgroundColor: 'white',
flexDirection: 'row',
alignItems: 'center',
},
cellText: {
fontSize:fontSize,
marginLeft: 10,
alignItems: 'center',
},
cellText1: {
fontSize:fontSize,
marginLeft: 10,
width: 2 * Math.ceil((width-10)/9),
textAlign: 'left',
color: 'black',
},
cellText2: {
fontSize:fontSize,
width: 2 * Math.ceil((width-10)/9),
textAlign: 'left',
color: 'black',
},
cellText3: {
fontSize:fontSize,
width: 2 * Math.ceil((width-10)/9),
textAlign: 'left',
color: 'black',
},
cellText4: {
fontSize:fontSize,
width: 3 * Math.ceil((width-10)/9),
textAlign: 'left',
color: 'black',
},
textInputCell: {
width: width,
height: 50,
flexDirection: 'row',
alignItems: 'center',
},
inputText:{
width: width - 80,
height: 40,
backgroundColor:'transparent',
fontSize:fontSize,
marginLeft: 10,
borderWidth: 1,
borderColor: '#CCC',
borderRadius: 4,
marginTop: 5,
},
});