fmui-base 2.1.83 → 2.1.85

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,340 @@
1
+ import React from 'react';
2
+
3
+ import Boxs from 'saltui/lib/Boxs';
4
+ import SearchBar from 'saltui/lib/SearchBar';
5
+ import Button from 'saltui/lib/Button';
6
+ import Popup from 'saltui/lib/Popup';
7
+
8
+ const { HBox, Box,} = Boxs;
9
+
10
+ import './treetable.less';
11
+
12
+
13
+
14
+ export default class Page extends React.Component {
15
+ constructor(props) {
16
+ super(props);
17
+
18
+ var u = navigator.userAgent;
19
+ var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android终端
20
+ var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
21
+ var height='';
22
+ if(isAndroid==true){
23
+ height = window.screen.height-70-44-45+"px";
24
+ }else if(isiOS==true){
25
+ height = window.screen.availHeight-70-44-45+"px";
26
+ }else {
27
+ if(window.screen.availHeight) {
28
+ height = '550px';
29
+ }
30
+ }
31
+
32
+ this.state = {
33
+ all:0,
34
+ height:height,
35
+ visible:false,
36
+
37
+ todoList:[ {
38
+ "checked":false,
39
+ "name":"一级11111111111111111111111",
40
+ "show":true,
41
+ "id":0,
42
+ "showSubList":false,
43
+ "checkedAll":false,
44
+ "todo":[
45
+ {
46
+ "name":"二级1111111111",
47
+ "show":true,
48
+ "id":1,
49
+ "pId":0,
50
+ "showSubList":false,
51
+ "checked":false,
52
+ "todo":[
53
+ {
54
+ "name":"三级1111111111",
55
+ "show":true,
56
+ "id":2,
57
+ "pId":1,
58
+ "checked":false,
59
+ },
60
+ {
61
+ "name":"三级22222",
62
+ "show":true,
63
+ "id":3,
64
+ "pId":1,
65
+ "checked":false,
66
+ },
67
+ ]
68
+ },
69
+ {
70
+ "name":"二级222222222222222",
71
+ "show":true,
72
+ "id":2,
73
+ "pId":0,
74
+ "showSubList":false,
75
+ "checked":false,
76
+ "todo":[
77
+ {
78
+ "name":"三级1111111111",
79
+ "show":true,
80
+ "id":3,
81
+ "pId":2,
82
+ "checked":false,
83
+ },
84
+ {
85
+ "name":"三级22222",
86
+ "show":true,
87
+ "id":4,
88
+ "pId":2,
89
+ "checked":false,
90
+ },
91
+ ]
92
+ }
93
+ ]
94
+ }
95
+ ],
96
+ };
97
+ }
98
+
99
+ componentDidMount (){
100
+ }
101
+
102
+ // 子组件初始化
103
+ initState() {
104
+ let t = this;
105
+ // 控制弹出
106
+ let visible = t.props.visible;
107
+
108
+ t.setState({
109
+ visible:visible,
110
+ });
111
+ }
112
+
113
+ //点击当前,子栏目全选是否取消
114
+ abc(sublist,list){
115
+ if (sublist != null && sublist.length > 0) {
116
+ for (var i = 0; i < sublist.length; i++) {
117
+ var obj = sublist[i];
118
+ if(list.checked == true){
119
+ obj.checked = true;
120
+ }else{
121
+ obj.checked = false;
122
+ }
123
+ var todo = obj.todo;
124
+ this.abc(todo,obj);
125
+ }
126
+ }
127
+ return list;
128
+ }
129
+
130
+ //点击当前,父级栏目全选是否取消
131
+ mml(plist,id,list){
132
+
133
+ var n = 0;
134
+ for ( var k = 0; k < list.length; k++){
135
+ if(list[k].checked == true){
136
+ n = n + 1;
137
+ }
138
+ }
139
+ if (plist != null && plist.length > 0) {
140
+ for (var i = 0; i < plist.length; i++) {
141
+ var obj = plist[i];
142
+ if(obj.id == id){
143
+ if(obj.todo.length == n){
144
+ obj.checked = true;
145
+ }else{
146
+ obj.checked = false;
147
+ }
148
+ };
149
+ this.mml(obj.todo,list[i].pId,list)
150
+ }
151
+ }
152
+
153
+ // return plist;
154
+
155
+ }
156
+
157
+ bindCheck1(i,e){
158
+ var todoList=this.state.todoList;
159
+ todoList[i].checked=!todoList[i].checked;
160
+ this.abc(todoList[i].todo,todoList[i]);
161
+
162
+ this.setState({
163
+ todoList:todoList,
164
+ })
165
+ }
166
+
167
+ bindCheck2(i,j,e){
168
+ var todoList=this.state.todoList;
169
+ j[i].checked=!j[i].checked;
170
+
171
+ this.abc(j[i].todo,j[i]);
172
+ var id = j[i].pId;
173
+ this.mml(todoList,id,j);
174
+
175
+ this.setState({
176
+ todoList:todoList,
177
+ })
178
+ }
179
+
180
+ showSubList1(i,e){
181
+ var todoList=this.state.todoList;
182
+ todoList[i].showSubList=!todoList[i].showSubList;
183
+
184
+ this.setState({
185
+ todoList:todoList,
186
+ })
187
+ }
188
+
189
+ showSubList2(i,j,e){
190
+
191
+ j[i].showSubList=!j[i].showSubList;
192
+
193
+ this.setState({
194
+ todoList:this.state.todoList,
195
+ })
196
+ }
197
+
198
+ // 点击蒙层关闭
199
+ closMask(){
200
+ this.props.closMask(this);
201
+ }
202
+
203
+ // 获取选择结构
204
+ getContent(){
205
+
206
+ }
207
+
208
+ render() {
209
+ const t = this;
210
+ const props = {
211
+ locale: 'zh_CN',
212
+ instantSearch: true,
213
+ hasHistory: true,
214
+ searchDelay: 450,
215
+ onEnter: () => { console.log('enter'); },
216
+ onExit: () => { console.log('exit'); },
217
+ onChange: (value) => {
218
+ console.log(`Typing>>${value}`);
219
+ },
220
+ onSearch: (value) => {
221
+ console.info(`Do search>>${value}`);
222
+ if (t.refs.list) {
223
+ t.refs.list.fetchData({
224
+ keyword: value,
225
+ });
226
+ }
227
+ },
228
+ };
229
+
230
+ return (
231
+
232
+ <div >
233
+ <Popup
234
+ content={
235
+ <div className="t-BCf" style={{width:300}}>
236
+ <SearchBar {...props} />
237
+ <div className={this.state.checkedAll?"t-PL16 t-PR16 t-PT10 t-PB10 dd-top-border ":"t-PL16 t-PR16 t-PT10 t-PB10 un-checked dd-top-border"}>
238
+ <HBox vAlign="center">
239
+ <HBox>
240
+ <div className='t-checkbox-field-icon-list' >
241
+ <i className="iconfont icon-checked t-FCf t-FS14"></i>
242
+ </div>
243
+ </HBox>
244
+ <Box flex={1} className="t-ML10">
245
+ 全选
246
+ </Box>
247
+ </HBox>
248
+ </div>
249
+ <div className="t-H10 t-BCf7"></div>
250
+
251
+ {
252
+ this.state.todoList.map(function(item,i){
253
+ return(
254
+ <div>
255
+ <HBox vAlign="center" className="dd-top-border ">
256
+
257
+ <Box className="t-PT12 t-PB12 t-PL16 t-PR6"><i className="iconfont icon-personnelregister t-FCd t-FS20"></i></Box>
258
+ <HBox flex={1} onClick={this.showSubList1.bind(this,i)}>
259
+ <Box flex={1} className="t-FS16 t-PL4 t-PR10 t-omit t-WB">{item.name}</Box>
260
+ <Box className="t-PR16"><i className={item.showSubList?"iconfont icon-arrow-up t-rotate-180 t-FCc":"iconfont icon-arrow-up t-rotate-90 t-FCc"}></i></Box>
261
+ </HBox>
262
+
263
+ </HBox>
264
+ <div className={item.showSubList?"":"t-DN"}>
265
+ {
266
+ item.todo.map(function(subItem,j,i){
267
+ return(
268
+ <div className="dd-top-border" >
269
+ <HBox vAlign="center">
270
+
271
+ <Box className="t-PT12 t-PB12 t-PL16 t-PR6"><i className="iconfont icon-personnelregister t-FCd t-FS20"></i></Box>
272
+ <HBox flex={1} onClick={this.showSubList2.bind(this,j,i)}>
273
+ <Box flex={1} className="t-FS16 t-PL4 t-PR10 t-omit t-WB">{subItem.name}</Box>
274
+ <Box className="t-PR16"><i className={subItem.showSubList?"iconfont icon-arrow-up t-rotate-180 t-FCc":"iconfont icon-arrow-up t-rotate-90 t-FCc"}></i></Box>
275
+ </HBox>
276
+ </HBox>
277
+ <div className={subItem.showSubList?"":"t-DN"}>
278
+ {
279
+ subItem.todo.map(function(subItem2,j,i){
280
+ return(
281
+ <div className="dd-top-border" onClick={this.bindCheck2.bind(this,j,i)}>
282
+ <HBox vAlign="center">
283
+ <Box className="t-PL16">
284
+ <div className={subItem2.checked?"t-checkbox-field-icon-list":"un-checked t-checkbox-field-icon-list"} >
285
+ <i className="iconfont icon-checked t-FCf t-FS14"></i>
286
+ </div>
287
+ </Box>
288
+ <Box className="t-PT12 t-PB12 t-PL10 t-PR6"><i className="iconfont icon-personnelregister t-FCd t-FS20"></i></Box>
289
+ <Box flex={1} className="t-FS16 t-PL4 t-PR10 t-omit">{subItem2.name}</Box>
290
+
291
+ </HBox>
292
+
293
+ </div>
294
+ )
295
+ }.bind(this))
296
+ }
297
+
298
+ </div>
299
+
300
+ </div>
301
+ )
302
+ }.bind(this))
303
+ }
304
+
305
+ </div>
306
+ </div>
307
+ )
308
+
309
+ }.bind(this))
310
+ }
311
+
312
+ <HBox vAlign="center" className="t-bottom-fixed t-P16 t-PT10 t-PB10">
313
+ <Box flex={1} >
314
+
315
+ </Box>
316
+ <Box className="t-MR4">
317
+ <Button type="secondary" size="small" display="inline">取消</Button>
318
+ </Box>
319
+ <Box>
320
+ <Button type="primary" size="small" display="inline">确定</Button>
321
+ </Box>
322
+ </HBox>
323
+
324
+ </div>
325
+
326
+
327
+ }
328
+ animationType="slide-left"
329
+ onMaskClick={() => { this.setState({ visible: false });this.closMask(); }}
330
+ visible={this.state.visible}
331
+ >
332
+ {null}
333
+ </Popup>
334
+ </div>
335
+
336
+ );
337
+ }
338
+ }
339
+
340
+
@@ -0,0 +1,92 @@
1
+ import React from 'react';
2
+
3
+ import TextField from 'saltui/lib/TextField';
4
+ const { RightAddon } = TextField;
5
+ import AngleRight from 'salt-icon/lib/AngleRight';
6
+
7
+ export default class PageHome extends React.Component {
8
+
9
+ constructor(props) {
10
+ super(props);
11
+ var label = props.label;
12
+ if(!label){
13
+ label = '';
14
+ }
15
+ this.state = {
16
+ };
17
+ }
18
+
19
+ componentDidMount() {
20
+ let t = this;
21
+ }
22
+
23
+ //点击
24
+ click(){
25
+ let t = this;
26
+ var value = this.props.value;
27
+ if(t.props.readOnly){//只读
28
+ var canShowLocate = this.props.canShowLocate;
29
+ if(canShowLocate == null || canShowLocate == undefined || (typeof(canShowLocate) !== 'boolean' && canShowLocate == '')){
30
+ canShowLocate = true;
31
+ }else{
32
+ canShowLocate = canShowLocate;
33
+ }
34
+ if(value && canShowLocate){
35
+ if(value.latitude && value.longitude){
36
+ showLocate(value);
37
+ }
38
+ }
39
+
40
+ }else{
41
+ if(value){
42
+ if(value.latitude && value.longitude){
43
+ getLocate(value,function(result){
44
+ var name = result.province+result.city+result.adName+result.snippet+result.title;
45
+ var returnData = {'name':name,'latitude':result.latitude,'longitude':result.longitude};
46
+ t.props.onChange(returnData);
47
+ });
48
+ }else{
49
+ getLocate(null,function(result){
50
+ var name = result.province+result.city+result.adName+result.snippet+result.title;
51
+ var returnData = {'name':name,'latitude':result.latitude,'longitude':result.longitude};
52
+ t.props.onChange(returnData);
53
+ });
54
+ }
55
+ }else{
56
+ getLocate(null,function(result){
57
+ var name = result.province+result.city+result.adName+result.snippet+result.title;
58
+ var returnData = {'name':name,'latitude':result.latitude,'longitude':result.longitude};
59
+ t.props.onChange(returnData);
60
+ });
61
+ }
62
+
63
+ }
64
+ }
65
+
66
+ //初始化ids
67
+ initData(){
68
+ }
69
+
70
+ //加载文件列表
71
+
72
+ render() {
73
+ const t = this;
74
+ return (
75
+ <div className="" onClick={this.click.bind(this)}>
76
+ <TextField
77
+ required={t.props.required}
78
+ readOnly={true}
79
+ label={t.props.label}
80
+ placeholder={t.props.readOnly?'':t.props.placeholder}
81
+ value={t.props.value == null || t.props.value == undefined ?'':t.props.value.name}
82
+ >
83
+ <RightAddon>
84
+ <AngleRight width={20} height={20} fill="#ccc" className={t.props.readOnly?'t-DN':'demo-t-list-arrow'} />
85
+ </RightAddon>
86
+ </TextField>
87
+ </div>
88
+
89
+ );
90
+ }
91
+ }
92
+