OutOfStock.js
4.62 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
'use strict';
import React, {Component} from 'react';
import LoadMoreIndicator from '../indicator/LoadMoreIndicator';
import LoadingIndicator from '../indicator/LoadingIndicator';
import moment from 'moment';
import {
StyleSheet,
View,
Text,
ListView,
Image,
Dimensions,
TouchableHighlight,
TextInput,
} from 'react-native';
export default class OutOfStock extends Component {
constructor(props) {
super (props);
this._onChangeText = this._onChangeText.bind(this);
}
_onChangeText(text){
let {resource} = this.props;
let data = resource?resource.toJS():null;
let id = data?data.id: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.setLackNum && this.props.setLackNum(num);
this.props.setInitialRes && this.props.setInitialRes(data);
}
render() {
let {resource,outOfStock} = this.props;
let num = outOfStock?outOfStock.lackNum:0;
let textInputColor = num >= 0 ? 'transparent' : 'red';
let data = resource?resource.toJS():null;
let sku = data.productSku?data.productSku:0;//sku
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 inStoreNum = data.inStoreNum?data.inStoreNum:0;//入库数量 收货数量
let buyingNums = data.buyingNums?data.buyingNums:0;//外采数量 销售数
let lastNum = buyingNums - lackNum - shipmentsNums;//实际应发数
return (
<View style={styles.container}>
<View style={styles.cell}>
<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>
</View>
<View style={styles.textInputCell}>
<Text style={styles.cellText} numberOfLines={1}>缺货:</Text>
<TextInput style={{
width: width - 80,
height: 40,
backgroundColor: textInputColor,
fontSize:15,
marginLeft: 10,
borderWidth: 1,
borderColor: '#CCC',
borderRadius: 4,
marginTop: 5,
}}
ref = 'textInput'
placeholder={'单行输入'}
keyboardType={'numeric'}
onChangeText={this._onChangeText}
/>
</View>
<Text style={styles.tip} numberOfLines={1}>*提货报缺后不可修改,平台将对顾客订单商品进行退单处理</Text>
</View>
);
}
}
let {width, height} = Dimensions.get('window');
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: 'white',
},
cell: {
width: width,
height: 40,
backgroundColor: 'white',
flexDirection: 'row',
alignItems: 'center',
},
cellText1: {
fontSize:12,
marginLeft: 10,
width: Math.ceil((width-20)/3)-30,
textAlign: 'left',
color: 'black',
},
cellText2: {
fontSize:12,
width: Math.ceil((width-20)/3)+60,
textAlign: 'center',
color: 'black',
},
cellText3: {
fontSize:12,
width: Math.ceil((width-20)/3)-30,
textAlign: 'right',
color: 'black',
},
textInputCell: {
width: width,
height: 50,
flexDirection: 'row',
alignItems: 'center',
marginLeft: 20,
},
inputText:{
width: width - 80,
height: 40,
backgroundColor:'transparent',
fontSize:15,
marginLeft: 10,
borderWidth: 1,
borderColor: '#CCC',
borderRadius: 4,
marginTop: 5,
},
tip: {
marginTop: 20,
marginLeft: 20,
fontSize:12,
width: width-20,
textAlign: 'left',
color: 'red',
}
});