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,23 @@
1
+ import React from 'react';
2
+ import variables from '../db/variables';
3
+
4
+ class Loading extends React.Component{
5
+ constructor(props) {
6
+ super(props);
7
+ this.state = {
8
+ loadingIcon: "",
9
+ className: ""
10
+ }
11
+ }
12
+
13
+ render(){
14
+ return (
15
+ <div>
16
+ <img width="50px" height="40px" src={variables.loadingIcon}/><br/>
17
+ 加载中...
18
+ </div>
19
+ )
20
+ }
21
+ }
22
+
23
+ export default Loading;
@@ -0,0 +1,34 @@
1
+ import React from 'react';
2
+ import Boxs from 'saltui/lib/Boxs';
3
+ const { VBox, Box } = Boxs;
4
+
5
+ class NoData extends React.Component{
6
+ constructor(props) {
7
+ super(props);
8
+ this.state = {
9
+ nodataIcon: "../image/nodata.png",
10
+ className: "",
11
+ nullmsg: "",
12
+ styleName: ""
13
+ }
14
+ }
15
+
16
+ render(){
17
+ return (
18
+ <div className="dd-nodata">
19
+ <VBox hAlign="center">
20
+ <Box className={this.props.className?this.props.className:'t-MT20'} >
21
+ <img src={this.props.nodataIcon?this.props.nodataIcon:this.state.nodataIcon} style={{width: 60 + 'px'}} />
22
+ </Box>
23
+ <Box className="t-FC6">
24
+ {this.props.nullmsg?this.props.nullmsg:'无搜索结果'}
25
+ </Box>
26
+ </VBox>
27
+ </div>
28
+ );
29
+ }
30
+ }
31
+
32
+ export default NoData;
33
+
34
+
@@ -0,0 +1,500 @@
1
+ import React from 'react';
2
+
3
+ import Boxs from 'saltui/lib/Boxs';
4
+ import Button from 'saltui/lib/Button';
5
+ import Dialog from 'saltui/lib/Dialog';
6
+ const { HBox, Box} = Boxs;
7
+ import TableSelect from './table/table';
8
+ import TreeSelect from './tree/tree';
9
+ import TreeTableSelect from './treetable/treetable';
10
+ import utils from './utils';
11
+
12
+ import 'whatwg-fetch';
13
+ import 'es6-promise';
14
+
15
+ export default class PageHome extends React.Component {
16
+
17
+ constructor(props) {
18
+ super(props);
19
+ let t = this;
20
+
21
+ var baseContext = document.getElementById("baseContext").value;
22
+ var context = getLoginUserInfo().context;
23
+ var token = document.getElementById("token").value;
24
+ this.state = {
25
+ search:'',
26
+ change:true,
27
+ selectText:'',
28
+
29
+ data: [],
30
+ selectedData:[],
31
+ selectNum:0,
32
+ checked:'checkbox',
33
+ placeholder:'搜索',
34
+ showName:'text',
35
+
36
+ visible:false,
37
+ top:0,
38
+
39
+ baseContext:baseContext,
40
+ context:context,
41
+ token:token,
42
+ corpId:'0',
43
+
44
+ popType:'table',
45
+
46
+ searchField:'text',
47
+ }
48
+
49
+ t.listener = t.handleHidePopup.bind(t);
50
+ }
51
+
52
+ componentDidMount(){
53
+ }
54
+
55
+ // 去除监听并关闭弹出页
56
+ handleHidePopup() {
57
+ const t = this;
58
+ window.removeEventListener('popstate', t.listener, false);
59
+ t.setState({
60
+ visible: false,
61
+ }, () => {
62
+ let popType = t.state.popType;
63
+ if (popType == 'tree') {
64
+ t.refs.tree.initState();
65
+ } else if (popType == 'treetable') {
66
+ t.refs.treetable.initState();
67
+ } else {
68
+ t.refs.table.initState();
69
+ }
70
+ $("#App").removeAttr("style");
71
+ $(document).scrollTop(t.state.top);
72
+ });
73
+ }
74
+
75
+ // 选择确认
76
+ selectConfirm(result){
77
+ let t = this;
78
+ // 是否是对接系统弹出选择
79
+ let popCode = t.props.popCode;
80
+ if (popCode == null || popCode == 'null' || popCode == '' || popCode == undefined || popCode == 'undefined') {
81
+ popCode = '';
82
+ }
83
+
84
+ if (popCode == '') {
85
+ // 不关联PC弹出选择
86
+ this.props.onChange(result);
87
+ } else {
88
+ // 关联PC弹出选择
89
+
90
+ // 回显的属性
91
+ let showName = this.state.showName;
92
+ // 单选多选标识
93
+ let checked = this.state.checked;
94
+
95
+ // 回显的值
96
+ let returnValue = '';
97
+ if (checked == 'radio') {
98
+ // 单选
99
+ returnValue = result[showName];
100
+ if (returnValue == null || returnValue == 'null' || returnValue == '' || returnValue == undefined || returnValue == 'undefined') {
101
+ returnValue = '';
102
+ }
103
+ } else {
104
+ // 多选
105
+ if (result != null && result.length > 0) {
106
+ for (var h = 0; h < result.length; h++) {
107
+ var rObj = result[h];
108
+ var show = rObj[showName];
109
+ if (show != null && show != 'null' && show != '' && show != undefined && show != 'undefined') {
110
+ if (returnValue == '') {
111
+ returnValue = show;
112
+ } else {
113
+ returnValue += ',' + show;
114
+ }
115
+ }
116
+ }
117
+ }
118
+ }
119
+ this.props.onChange(returnValue);
120
+ }
121
+ //防止双击选项时back两次
122
+ if(!location.hash.includes('POPPAGE')) {
123
+ return ;
124
+ }else {
125
+ history.back();
126
+ }
127
+
128
+ }
129
+
130
+ // 触发弹出选择
131
+ popupFuc(){
132
+ let t = this;
133
+ // 只读状态
134
+ let readOnly = this.props.readOnly;
135
+ if (readOnly) {
136
+ return false;
137
+ }
138
+
139
+ // 当前页面的高度
140
+ var top = $(window).scrollTop();
141
+ // 控制底层页面不可动
142
+ $('#App').css("top",-top+"px");
143
+ $('#App').css("width",100+"%");
144
+ $('#App').css('position','fixed');
145
+
146
+ // 是否是对接系统弹出选择
147
+ let popCode = t.props.popCode;
148
+ let popType = "";
149
+ if (popCode == null || popCode == 'null' || popCode == '' || popCode == undefined || popCode == 'undefined') {
150
+ popCode = '';
151
+ popType = 'table';
152
+ }
153
+
154
+
155
+ // 单选多选标识
156
+ let checked = this.props.checked;
157
+ if (checked == null || checked == 'null' || checked == '' || checked == undefined || checked == 'undefined') {
158
+ checked = 'checkbox';
159
+ }
160
+
161
+ // 搜索提示语
162
+ let placeholder = this.props.placeholder;
163
+ if (placeholder == null || placeholder == 'null' || placeholder == '' || placeholder == undefined || placeholder == 'undefined') {
164
+ placeholder = '搜索';
165
+ }
166
+
167
+ // 回显属性名
168
+ let showName = this.props.showName;
169
+ if (showName == null || showName == 'null' || showName == '' || showName == undefined || showName == 'undefined') {
170
+ showName = 'text';
171
+ }
172
+
173
+ // 搜索属性
174
+ let searchField = this.props.searchField;
175
+ if (searchField == null || searchField == 'null' || searchField == '' || searchField == undefined || searchField == 'undefined') {
176
+ searchField = 'text';
177
+ }
178
+
179
+ // 选择列表数据
180
+ let data = this.props.data;
181
+ // 被选中的个数
182
+ let selectNum = 0;
183
+ // 选中的数据
184
+ let value = this.props.value;
185
+
186
+ // 请求后台获取弹出数据
187
+ if (popCode != '') {
188
+ // 调用弹出选择Api接口
189
+ var url = this.state.context + "/api/m/cmp/poppage/mobile/getPoppageInfo?token="+this.state.token+"&corpId="+this.state.corpId+"&popCode="+popCode;
190
+ fetch(url,{
191
+ method: "GET",
192
+ mode: "cors",
193
+ headers: {
194
+ 'Accept': 'application/json, text/plain, */*',
195
+ 'Content-Type': 'application/x-www-form-urlencoded'
196
+ }
197
+ }).then((response) => response.json()).then((result) => {
198
+ // 选中数据处理
199
+ let tempData1 = null;
200
+ // 获取数据成功
201
+ if (result != null && result.type == 'success') {
202
+ // 弹出选择数据
203
+ let popData = result.data;
204
+ // 弹出类型
205
+ popType = popData.popType;
206
+ // 显示字段
207
+ if (popType == 'treetable') {
208
+ Dialog.alert({
209
+ content: '暂不支持树-列表格式的弹出选择!',
210
+ onConfirm() {
211
+ $("#App").removeAttr("style");
212
+ $(document).scrollTop(top);
213
+ },
214
+ });
215
+ return false;
216
+ } else if (popType == 'tree') {
217
+ showName = 'name';
218
+ } else {
219
+ showName = popData.queryShowfield;
220
+ }
221
+
222
+ // 查询字段
223
+ let queryCondition = popData.queryCondition;
224
+ if (queryCondition != '' && queryCondition != null) {
225
+ let tempCondition = '';
226
+ let conditionArr = queryCondition.split(';');
227
+ if (conditionArr != null && conditionArr.length > 0) {
228
+ for (var i = conditionArr.length - 1; i >= 0; i--) {
229
+ var obj = conditionArr[i];
230
+ if (obj != '' && obj != null) {
231
+ var objArr = obj.split(',');
232
+ if (objArr != null && objArr.length > 0) {
233
+ if (tempCondition == '') {
234
+ tempCondition = objArr[0];
235
+ } else {
236
+ tempCondition += ',' + objArr[0];
237
+ }
238
+ }
239
+ }
240
+ }
241
+ }
242
+ queryCondition = tempCondition;
243
+ }
244
+
245
+ searchField = queryCondition;
246
+
247
+ // 选择列表数据
248
+ data = popData.data;
249
+ if (value != null && value != 'null' && value != '' && value != undefined && value != 'undefined') {
250
+
251
+ if (checked == 'radio') {
252
+ tempData1 = {};
253
+ // 单选
254
+ for (var k = 0; k < data.length; k++) {
255
+ var obj = data[k];
256
+ if (obj[showName] == value) {
257
+ tempData1 = obj;
258
+ break;
259
+ }
260
+ }
261
+ } else {
262
+ // 多选
263
+ tempData1 = [];
264
+
265
+ // 选中得值
266
+ var valueArr = value.split(',');
267
+
268
+ // 验证标识
269
+ let checkStr = '';
270
+ for (var kk = 0; kk < data.length; kk++) {
271
+ var dobj = data[kk];
272
+
273
+ var id = dobj.value;
274
+ for (var jj = 0; jj < valueArr.length; jj++) {
275
+ var valueStr = valueArr[jj];
276
+ if (dobj[showName] == valueStr) {
277
+ tempData1.push(dobj);
278
+ valueArr.splice(jj,1);
279
+ break;
280
+ }
281
+ }
282
+ }
283
+ }
284
+ }
285
+ }
286
+
287
+ this.setState({
288
+ change:true,
289
+ data:data,
290
+ selectNum:selectNum,
291
+ checked:checked,
292
+ placeholder:placeholder,
293
+ selectedData:tempData1,
294
+ showName:showName,
295
+ popType:popType,
296
+ top:top,
297
+ visible: true,
298
+ searchField:searchField,
299
+ historyStamp: `SearchPanel.index_${Date.now()}`,
300
+ }, () => {
301
+ if (popType == 'tree') {
302
+ t.refs.tree.initState();
303
+ } else if (popType == 'treetable') {
304
+ t.refs.treetable.initState();
305
+ } else {
306
+ t.refs.table.initState();
307
+ }
308
+ // 防止双击字段时间戳加了两次 back一次回不去
309
+ if(!location.hash.includes('POPPAGE')) {
310
+ window.history.pushState({
311
+ Poppage: t.state.historyStamp,
312
+ }, '', utils.addUrlParam('POPPAGE', Date.now()));
313
+ window.addEventListener('popstate', t.listener, false);
314
+ }else {
315
+ return
316
+ }
317
+
318
+ });
319
+
320
+ }).catch((error) => {
321
+ alert("错误:"+error);
322
+ });
323
+ } else {
324
+ this.setState({
325
+ change:true,
326
+ data:data,
327
+ selectNum:selectNum,
328
+ checked:checked,
329
+ placeholder:placeholder,
330
+ selectedData:value,
331
+ showName:showName,
332
+ popType:popType,
333
+ top:top,
334
+ visible: true,
335
+ searchField:searchField,
336
+ historyStamp: `SearchPanel.index_${Date.now()}`,
337
+ }, () => {
338
+ t.refs.table.initState();
339
+ // 防止双击字段时间戳加了两次 back一次回不去
340
+ if(!location.hash.includes('POPPAGE')) {
341
+ window.history.pushState({
342
+ Poppage: t.state.historyStamp,
343
+ }, '', utils.addUrlParam('POPPAGE', Date.now()));
344
+ window.addEventListener('popstate', t.listener, false);
345
+ }else {
346
+ return
347
+ }
348
+ });
349
+
350
+ }
351
+
352
+ }
353
+
354
+ // 点击蒙层关闭
355
+ closMask(){
356
+ history.back();
357
+ }
358
+
359
+ render() {
360
+ const t = this;
361
+ let selectText = '';
362
+ // 必选标识
363
+ let required = this.props.required;
364
+
365
+ // label
366
+ let label = this.props.label;
367
+ if (label == null || label == 'null' || label == '' || label == undefined || label == 'undefined') {
368
+ label = '弹出选择';
369
+ }
370
+
371
+ // 是否回显
372
+ let isShow = this.props.isShow;
373
+
374
+ // 是否显示箭头
375
+ let isIcon = this.props.isIcon;
376
+
377
+ // 表现形式: 0:常规,1:按钮 默认:常规
378
+ let showType = this.props.showType;
379
+ if (showType == null || showType == 'null' || showType == '' || showType == undefined || showType == 'undefined') {
380
+ showType = '0';
381
+ }
382
+
383
+ // 单选多选标识
384
+ let checked = this.props.checked;
385
+ if (checked == null || checked == 'null' || checked == '' || checked == undefined || checked == 'undefined') {
386
+ checked = 'checkbox';
387
+ }
388
+
389
+ let popCode = t.props.popCode;
390
+ if (popCode == null || popCode == 'null' || popCode == '' || popCode == undefined || popCode == 'undefined') {
391
+ popCode = '';
392
+ }
393
+
394
+ if (popCode != '') {
395
+ // 关联PC端弹出选择
396
+ let value = this.props.value;
397
+ if (value == null || value == 'null' || value == '' || value == undefined || value == 'undefined') {
398
+ value = '';
399
+ }
400
+ selectText = value;
401
+ } else {
402
+ // 不是PC端的弹出选择
403
+ // 选中的数据
404
+ let value = this.props.value;
405
+ let showName = this.props.showName;
406
+ if (showName == null || showName == 'null' || showName == '' || showName == undefined || showName == 'undefined') {
407
+ showName = this.state.showName;
408
+ }
409
+ // 单选
410
+ if (checked == 'radio') {
411
+ if (value != null && value != 'null' && value != '' && value != undefined && value != 'undefined') {
412
+ selectText = '';
413
+ selectText = value[showName];
414
+ }
415
+ } else {
416
+ // 多选
417
+ if (value == null || value == 'null' || value == '' || value == undefined || value == 'undefined') {
418
+ value = [];
419
+ }
420
+ selectText = '';
421
+ for (var ii=0;ii<value.length;ii++) {
422
+ var obj = value[ii];
423
+ if (selectText == '') {
424
+ selectText = obj[showName];
425
+ } else {
426
+ selectText = selectText + ',' + obj[showName];
427
+ }
428
+ }
429
+ }
430
+ }
431
+
432
+ // 只读状态
433
+ let readOnly = this.props.readOnly;
434
+
435
+ return (
436
+ <div >
437
+ <div>
438
+ <div className={showType == '1' ? 'demo-section' : 't-DN'} >
439
+ <div className="section-content">
440
+ <Button type="primary" onClick={() => {this.popupFuc(); }}>{label}</Button>
441
+ </div>
442
+ </div>
443
+
444
+ <HBox vAlign="center" className={showType!='1' ? 't-field-box t-FS16 t-PR16' : 't-DN'} onClick={() => {this.popupFuc(); }}>
445
+ <Box className={required ? 't-field-layout-h-label required' : 't-field-layout-h-label'}>{label}</Box>
446
+ <HBox flex={1} >
447
+ <Box flex={1} className={isShow ? 't-DN' : 't-FAL t-LH1_4 t-omit'}>{selectText}</Box>
448
+ <Box className={isIcon || readOnly ? 't-DN' : 't-PR4'}>
449
+ <b className="iconfont icon-back t-rotate-180 t-FCc t-FS16 t-FS14"></b>
450
+ </Box>
451
+ </HBox>
452
+ </HBox>
453
+ </div>
454
+
455
+ <TableSelect className={this.state.popType == 'table' ? '' : 't-DN'}
456
+ placeholder={this.state.placeholder}
457
+ data={this.state.data}
458
+ onChange={this.selectConfirm.bind(this)}
459
+ closMask={this.closMask.bind(this)}
460
+ value={this.state.selectedData}
461
+ checked={this.state.checked}
462
+ showName={this.state.showName}
463
+ visible={this.state.visible}
464
+ top={this.state.top}
465
+ searchField={this.state.searchField}
466
+ ref="table"
467
+ />
468
+
469
+ <TreeSelect className={this.state.popType == 'tree' ? '' : 't-DN'}
470
+ placeholder={this.state.placeholder}
471
+ data={this.state.data}
472
+ onChange={this.selectConfirm.bind(this)}
473
+ closMask={this.closMask.bind(this)}
474
+ value={this.state.selectedData}
475
+ checked={this.state.checked}
476
+ showName={this.state.showName}
477
+ visible={this.state.visible}
478
+ top={this.state.top}
479
+ searchField={this.state.searchField}
480
+ ref="tree"
481
+ />
482
+
483
+ <TreeTableSelect className={this.state.popType == 'treetable' ? '' : 't-DN'}
484
+ placeholder={this.state.placeholder}
485
+ data={this.state.data}
486
+ onChange={this.selectConfirm.bind(this)}
487
+ closMask={this.closMask.bind(this)}
488
+ value={this.state.selectedData}
489
+ checked={this.state.checked}
490
+ showName={this.state.showName}
491
+ visible={this.state.visible}
492
+ top={this.state.top}
493
+ searchField={this.state.searchField}
494
+ ref="treetable"
495
+ />
496
+ </div>
497
+ )
498
+ }
499
+ }
500
+