ProcessManagement.js
6.5 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
import React, {Component} from 'react';
import {
View,
Text,
Image,
ScrollView,
TouchableOpacity,
StyleSheet
} from "react-native";
import {NoDoublePress} from "../utils/Common";
import {width} from "../utils/getSize";
export default class ProcessManagement extends Component {
constructor(props) {
super(props);
this.state={
querySwitch: 'Common',
};
this.commonModuleList=[
{name: '单行输入框', icon: require('../img/check_alt.png')}, {name: '多行输入框', icon: require('../img/check_alt.png')},
{name: '数字输入框', icon: require('../img/check_alt.png')}, {name: '金额', icon: require('../img/check_alt.png')},
{name: '下拉选择', icon: require('../img/check_alt.png')}, {name: '级联选择', icon: require('../img/check_alt.png')},
{name: '省市区', icon: require('../img/check_alt.png')}, {name: '单选框组', icon: require('../img/check_alt.png')},
{name: '多选框组', icon: require('../img/check_alt.png')}, {name: '滑块', icon: require('../img/check_alt.png')},
{name: '组织机构', icon: require('../img/check_alt.png')}, {name: '时间选择', icon: require('../img/check_alt.png')},
{name: '时间范围', icon: require('../img/check_alt.png')}, {name: '日期选择', icon: require('../img/check_alt.png')},
{name: '日期范围', icon: require('../img/check_alt.png')}, {name: '评分', icon: require('../img/check_alt.png')},
{name: '附件', icon: require('../img/check_alt.png')}, {name: '计算公式', icon: require('../img/check_alt.png')},
{name: '布局容器', icon: require('../img/check_alt.png')}, {name: '表格/明细', icon: require('../img/check_alt.png')}
]
}
componentWillMount() {
//设置头部
this.props.navigation.setParams({
isBack:true,
title: '组件'
});
}
renderComponentItem(item, index) {
let marginLeft = index % 2 === 1 ? 10 : 0;
let itemWidth = (width - 30) / 2;
return(
<TouchableOpacity
key={index}
style={{
width: itemWidth,
paddingVertical: 5,
marginTop: 10,
marginLeft: marginLeft,
backgroundColor: "white",
borderWidth: 1,
borderColor: 'rgba(0, 0, 0, 0.2)',
borderRadius: 2,
justifyContent: 'center',
alignItems: 'center',
flexDirection: 'row',
textAlign: 'left',
}}
activeOpacity={0.8}
onPress={() => {
//
}}
>
<Text style={{width: 90, fontSize: 14, color: 'black'}}>{item.name}</Text>
<Image style={{width: 24, height: 24}} source={item.icon} resizeMode={'contain'}/>
</TouchableOpacity>
)
}
renderComponentTab() {
// <View style={{flex: 1, backgroundColor: 'rgba(250, 250, 250, 1)'}}></View>
switch (this.state.querySwitch) {
case "Common":
return (
<ScrollView
automaticallyAdjustContentInsets={false}
alwaysBounceVertical={true}
alwaysBounceHorizontal={false}
showsVerticalScrollIndicator={false}
showsHorizontalScrollIndicator={false}
>
<View style={{
flexDirection: 'row',
justifyContent: 'flex-start',
alignItems: 'flex-start',
flexWrap: 'wrap',
paddingHorizontal: 10,
width: width
}}>
{this.commonModuleList.map((v, i) => this.renderComponentItem(v, i))}
</View>
</ScrollView>
);
case "Custom":
return (
<View style={{flex: 1, backgroundColor: 'rgba(250, 250, 250, 1)'}}>
<ScrollView>
</ScrollView>
</View>
);
}
}
render() {
return (
<View>
<View style={{width:'100%',flexDirection:'row', height: 38, backgroundColor: 'white'}}>
<TouchableOpacity
activeOpacity={1}
style={{flex: 1, justifyContent:'center', alignItems:'center'}}
onPress={()=>NoDoublePress.onPress(()=>{
this.setState({
querySwitch:'Common',
})
})}>
<Text style={{
fontSize:14,
color:this.state.querySwitch === 'Common'? global.homeColor: 'rgba(0, 0, 0, 0.3)',
fontWeight: 'bold',
}}>常用组件</Text>
{this.state.querySwitch === 'Common' && <View style={[styles.lineStyle, {backgroundColor: global.homeColor}]} />}
</TouchableOpacity>
<TouchableOpacity
activeOpacity={1}
style={{flex: 1, justifyContent:'center', alignItems:'center'}}
onPress={()=>NoDoublePress.onPress(()=>{
this.setState({
querySwitch:'Custom',
})
})}>
<Text style={{
fontSize:14,
color:this.state.querySwitch === 'Custom'? global.homeColor: 'rgba(0, 0, 0, 0.3)',
fontWeight: 'bold',
}}>定制组件</Text>
{this.state.querySwitch === 'Custom' && <View style={[styles.lineStyle, {backgroundColor: global.homeColor}]} />}
</TouchableOpacity>
</View>
{/** 组件列表 */}
{this.renderComponentTab()}
</View>
);
}
}
const styles = StyleSheet.create({
lineStyle: {
width: '100%',
height: 3,
position: 'absolute',
bottom: 0,
},
})