罗广聪

全选还没处理完

... ... @@ -17,7 +17,9 @@ export default class Import extends Component {
constructor(props) {
super(props);
this.state = {
customersList: this.props.navigation.state.params.customersList
customersList: this.props.navigation.state.params.customersList,
selected_all: false,
selected_len: 5
};
}
componentWillMount() {}
... ... @@ -30,18 +32,10 @@ export default class Import extends Component {
post("/test/insurance/article", {}, res => {}, err => {});
}
/* customersList: [
...this.state.customersList.slice(0, index),
{
...this.state.customersList[index],
selected: !this.state.customersList[index].selected
},
...this.state.slice(index + 1)
] */
render() {
const { navigate } = this.props.navigation;
const { customersList } = this.state;
// const customersList = this.props.navigation.state.params.customersList;
const { customersList, selected_all, selected_len } = this.state;
let LEN = customersList.length;
const ds = new ListView.DataSource({
rowHasChanged: (r1, r2) => r1 !== r2
});
... ... @@ -52,7 +46,7 @@ export default class Import extends Component {
style={styles.mainSvcContainer}
dataSource={dataSource}
enableEmptySections={true}
renderRow={(item,secid, index) => {
renderRow={(item, secid, index) => {
return (
<TouchableOpacity
key={index}
... ... @@ -60,7 +54,6 @@ export default class Import extends Component {
onPress={() => {
let Temp = customersList;
console.log(index);
{/* return; */}
Temp.splice(index, 1, {
...customersList[index],
selected: !customersList[index].selected
... ... @@ -88,27 +81,36 @@ export default class Import extends Component {
);
}}
/>
{/* <ScrollView style={styles.mainSvcContainer}>
{customersList.map((item, index) => {
return (
<TouchableOpacity key={index} style={styles.CustomerItemContaier}>
<View style={styles.itemSelectIconContainer}>
<Image style={styles.itemSelectIcon} source={require("../../assets/customer/ic1_n.png")} />
</View>
<Text style={styles.CustomerItemText}>{item.name}</Text>
</TouchableOpacity>
);
})}
</ScrollView> */}
<View style={styles.selectBtnContaier}>
<View style={styles.selectBtnContaierLeft}>
<TouchableOpacity style={styles.selectAllContainer}>
<View style={styles.selectAllIcon} />
<TouchableOpacity
style={styles.selectAllContainer}
onPress={() => {
this.setState({
selected_all: !this.state.selected_all
});
}}
>
<View style={styles.selectAllIcon}>
{selected_all ? (
<Image
style={styles.allIcon}
source={require("../../assets/customer/ic2_s.png")}
/>
) : (
<Image
style={styles.allIcon}
source={require("../../assets/customer/ic2_n.png")}
/>
)}
</View>
<Text style={styles.selectAllText}>全选</Text>
</TouchableOpacity>
<View style={styles.selectedTextContaier}>
<Text>已选中</Text>
<Text>0</Text>
<Text style={styles.selected_num}>
{selected_all ? LEN : selected_len}
</Text>
<Text></Text>
</View>
</View>
... ... @@ -175,12 +177,32 @@ const styles = StyleSheet.create({
flexDirection: "row"
},
selectAllContainer: {
marginLeft: 20
marginLeft: 20,
flexDirection: "row",
justifyContent: "center",
alignItems: "center"
},
selectAllIcon: {
justifyContent: "center",
alignItems: "center",
marginRight: 10
},
allIcon: {
width: 22,
height: 22
},
selectAllText: {
fontSize: 17
},
selectAllText: {},
selectedTextContaier: {
flexDirection: "row",
marginLeft: 20
marginLeft: 20,
justifyContent: "center",
alignItems: "center"
},
selected_num: {
color: "#1B9341",
fontSize: 16
},
importBtnContaier: {
width: 100,
... ...