Showing
1 changed file
with
53 additions
and
31 deletions
| @@ -17,7 +17,9 @@ export default class Import extends Component { | @@ -17,7 +17,9 @@ export default class Import extends Component { | ||
| 17 | constructor(props) { | 17 | constructor(props) { |
| 18 | super(props); | 18 | super(props); |
| 19 | this.state = { | 19 | this.state = { |
| 20 | - customersList: this.props.navigation.state.params.customersList | 20 | + customersList: this.props.navigation.state.params.customersList, |
| 21 | + selected_all: false, | ||
| 22 | + selected_len: 5 | ||
| 21 | }; | 23 | }; |
| 22 | } | 24 | } |
| 23 | componentWillMount() {} | 25 | componentWillMount() {} |
| @@ -30,18 +32,10 @@ export default class Import extends Component { | @@ -30,18 +32,10 @@ export default class Import extends Component { | ||
| 30 | post("/test/insurance/article", {}, res => {}, err => {}); | 32 | post("/test/insurance/article", {}, res => {}, err => {}); |
| 31 | } | 33 | } |
| 32 | 34 | ||
| 33 | - /* customersList: [ | ||
| 34 | - ...this.state.customersList.slice(0, index), | ||
| 35 | - { | ||
| 36 | - ...this.state.customersList[index], | ||
| 37 | - selected: !this.state.customersList[index].selected | ||
| 38 | - }, | ||
| 39 | - ...this.state.slice(index + 1) | ||
| 40 | - ] */ | ||
| 41 | render() { | 35 | render() { |
| 42 | const { navigate } = this.props.navigation; | 36 | const { navigate } = this.props.navigation; |
| 43 | - const { customersList } = this.state; | 37 | + const { customersList, selected_all, selected_len } = this.state; |
| 44 | - // const customersList = this.props.navigation.state.params.customersList; | 38 | + let LEN = customersList.length; |
| 45 | const ds = new ListView.DataSource({ | 39 | const ds = new ListView.DataSource({ |
| 46 | rowHasChanged: (r1, r2) => r1 !== r2 | 40 | rowHasChanged: (r1, r2) => r1 !== r2 |
| 47 | }); | 41 | }); |
| @@ -52,7 +46,7 @@ export default class Import extends Component { | @@ -52,7 +46,7 @@ export default class Import extends Component { | ||
| 52 | style={styles.mainSvcContainer} | 46 | style={styles.mainSvcContainer} |
| 53 | dataSource={dataSource} | 47 | dataSource={dataSource} |
| 54 | enableEmptySections={true} | 48 | enableEmptySections={true} |
| 55 | - renderRow={(item,secid, index) => { | 49 | + renderRow={(item, secid, index) => { |
| 56 | return ( | 50 | return ( |
| 57 | <TouchableOpacity | 51 | <TouchableOpacity |
| 58 | key={index} | 52 | key={index} |
| @@ -60,7 +54,6 @@ export default class Import extends Component { | @@ -60,7 +54,6 @@ export default class Import extends Component { | ||
| 60 | onPress={() => { | 54 | onPress={() => { |
| 61 | let Temp = customersList; | 55 | let Temp = customersList; |
| 62 | console.log(index); | 56 | console.log(index); |
| 63 | - {/* return; */} | ||
| 64 | Temp.splice(index, 1, { | 57 | Temp.splice(index, 1, { |
| 65 | ...customersList[index], | 58 | ...customersList[index], |
| 66 | selected: !customersList[index].selected | 59 | selected: !customersList[index].selected |
| @@ -88,27 +81,36 @@ export default class Import extends Component { | @@ -88,27 +81,36 @@ export default class Import extends Component { | ||
| 88 | ); | 81 | ); |
| 89 | }} | 82 | }} |
| 90 | /> | 83 | /> |
| 91 | - {/* <ScrollView style={styles.mainSvcContainer}> | ||
| 92 | - {customersList.map((item, index) => { | ||
| 93 | - return ( | ||
| 94 | - <TouchableOpacity key={index} style={styles.CustomerItemContaier}> | ||
| 95 | - <View style={styles.itemSelectIconContainer}> | ||
| 96 | - <Image style={styles.itemSelectIcon} source={require("../../assets/customer/ic1_n.png")} /> | ||
| 97 | - </View> | ||
| 98 | - <Text style={styles.CustomerItemText}>{item.name}</Text> | ||
| 99 | - </TouchableOpacity> | ||
| 100 | - ); | ||
| 101 | - })} | ||
| 102 | - </ScrollView> */} | ||
| 103 | <View style={styles.selectBtnContaier}> | 84 | <View style={styles.selectBtnContaier}> |
| 104 | <View style={styles.selectBtnContaierLeft}> | 85 | <View style={styles.selectBtnContaierLeft}> |
| 105 | - <TouchableOpacity style={styles.selectAllContainer}> | 86 | + <TouchableOpacity |
| 106 | - <View style={styles.selectAllIcon} /> | 87 | + style={styles.selectAllContainer} |
| 88 | + onPress={() => { | ||
| 89 | + this.setState({ | ||
| 90 | + selected_all: !this.state.selected_all | ||
| 91 | + }); | ||
| 92 | + }} | ||
| 93 | + > | ||
| 94 | + <View style={styles.selectAllIcon}> | ||
| 95 | + {selected_all ? ( | ||
| 96 | + <Image | ||
| 97 | + style={styles.allIcon} | ||
| 98 | + source={require("../../assets/customer/ic2_s.png")} | ||
| 99 | + /> | ||
| 100 | + ) : ( | ||
| 101 | + <Image | ||
| 102 | + style={styles.allIcon} | ||
| 103 | + source={require("../../assets/customer/ic2_n.png")} | ||
| 104 | + /> | ||
| 105 | + )} | ||
| 106 | + </View> | ||
| 107 | <Text style={styles.selectAllText}>全选</Text> | 107 | <Text style={styles.selectAllText}>全选</Text> |
| 108 | </TouchableOpacity> | 108 | </TouchableOpacity> |
| 109 | <View style={styles.selectedTextContaier}> | 109 | <View style={styles.selectedTextContaier}> |
| 110 | <Text>已选中</Text> | 110 | <Text>已选中</Text> |
| 111 | - <Text>0</Text> | 111 | + <Text style={styles.selected_num}> |
| 112 | + {selected_all ? LEN : selected_len} | ||
| 113 | + </Text> | ||
| 112 | <Text>项</Text> | 114 | <Text>项</Text> |
| 113 | </View> | 115 | </View> |
| 114 | </View> | 116 | </View> |
| @@ -175,12 +177,32 @@ const styles = StyleSheet.create({ | @@ -175,12 +177,32 @@ const styles = StyleSheet.create({ | ||
| 175 | flexDirection: "row" | 177 | flexDirection: "row" |
| 176 | }, | 178 | }, |
| 177 | selectAllContainer: { | 179 | selectAllContainer: { |
| 178 | - marginLeft: 20 | 180 | + marginLeft: 20, |
| 181 | + flexDirection: "row", | ||
| 182 | + justifyContent: "center", | ||
| 183 | + alignItems: "center" | ||
| 184 | + }, | ||
| 185 | + selectAllIcon: { | ||
| 186 | + justifyContent: "center", | ||
| 187 | + alignItems: "center", | ||
| 188 | + marginRight: 10 | ||
| 189 | + }, | ||
| 190 | + allIcon: { | ||
| 191 | + width: 22, | ||
| 192 | + height: 22 | ||
| 193 | + }, | ||
| 194 | + selectAllText: { | ||
| 195 | + fontSize: 17 | ||
| 179 | }, | 196 | }, |
| 180 | - selectAllText: {}, | ||
| 181 | selectedTextContaier: { | 197 | selectedTextContaier: { |
| 182 | flexDirection: "row", | 198 | flexDirection: "row", |
| 183 | - marginLeft: 20 | 199 | + marginLeft: 20, |
| 200 | + justifyContent: "center", | ||
| 201 | + alignItems: "center" | ||
| 202 | + }, | ||
| 203 | + selected_num: { | ||
| 204 | + color: "#1B9341", | ||
| 205 | + fontSize: 16 | ||
| 184 | }, | 206 | }, |
| 185 | importBtnContaier: { | 207 | importBtnContaier: { |
| 186 | width: 100, | 208 | width: 100, |
-
Please register or login to post a comment